diff --git a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java index 7fc0039c9..7449f029f 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java @@ -9,13 +9,12 @@ import emu.grasscutter.game.entity.EntityHomeAnimal; import emu.grasscutter.game.world.Position; import emu.grasscutter.game.world.Scene; import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo; - -import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import javax.annotation.Nullable; import lombok.*; import lombok.experimental.FieldDefaults; @@ -84,17 +83,16 @@ public class HomeSceneItem { return mainHouse == null || mainHouse.getAsItem() == null; } - @Nullable - public Position getTeleportPointPos(int guid) { + @Nullable public Position getTeleportPointPos(int guid) { var pos = new AtomicReference(); this.getBlockItems().values().stream() - .map(HomeBlockItem::getDeployFurnitureList) - .flatMap(Collection::stream) - .filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == guid) - .map(HomeFurnitureItem::getSpawnPos) - .findFirst() - .ifPresent(pos::set); + .map(HomeBlockItem::getDeployFurnitureList) + .flatMap(Collection::stream) + .filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == guid) + .map(HomeFurnitureItem::getSpawnPos) + .findFirst() + .ifPresent(pos::set); return pos.get(); } diff --git a/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java b/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java index 8a28595b1..aecacb21c 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java @@ -143,7 +143,10 @@ public class HomeWorldMPSystem extends BaseGameSystem { int realmId = 2000 + owner.getCurrentRealmId(); var item = targetHome.getHomeSceneItem(realmId); targetHome.save(); - var pos = toSafe ? world.getSceneById(realmId).getScriptManager().getConfig().born_pos : item.getBornPos(); + var pos = + toSafe + ? world.getSceneById(realmId).getScriptManager().getConfig().born_pos + : item.getBornPos(); if (teleportPoint != 0) { var target = item.getTeleportPointPos(teleportPoint); @@ -202,12 +205,23 @@ public class HomeWorldMPSystem extends BaseGameSystem { player.getPosition().set(pos); var world = new World(player); world.addPlayer(player, prevScene); - player.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(player, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); + player + .getCurHomeWorld() + .sendPacketToHostIfOnline( + new PacketOtherPlayerEnterOrLeaveHomeNotify( + player, + OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); var myHome = this.server.getHomeWorldOrCreate(player); player.setCurHomeWorld(myHome); myHome.getHome().onOwnerLogin(player); - player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK, EnterReason.TeamBack, prevScene, pos)); + player.sendPacket( + new PacketPlayerEnterSceneNotify( + player, + EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK, + EnterReason.TeamBack, + prevScene, + pos)); return true; } @@ -239,7 +253,12 @@ public class HomeWorldMPSystem extends BaseGameSystem { victim.getPosition().set(victim.getPrevPosForHome()); var world = new World(victim); world.addPlayer(victim, 3); - victim.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(victim, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); + victim + .getCurHomeWorld() + .sendPacketToHostIfOnline( + new PacketOtherPlayerEnterOrLeaveHomeNotify( + victim, + OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); var myHome = this.server.getHomeWorldOrCreate(victim); victim.setCurHomeWorld(myHome); myHome.getHome().onOwnerLogin(victim); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java index 3f1394932..07ebfcb2b 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java @@ -16,7 +16,15 @@ public class HandlerHomeTransferReq extends PacketHandler { var home = player.getCurHomeWorld().getHome(); var item = home.getHomeSceneItem(player.getSceneId()); - var pos = req.getIsTransferToMainHousePoint() ? item.getBornPos() : player.getCurHomeWorld().getSceneById(player.getSceneId()).getScriptManager().getConfig().born_pos; + var pos = + req.getIsTransferToMainHousePoint() + ? item.getBornPos() + : player + .getCurHomeWorld() + .getSceneById(player.getSceneId()) + .getScriptManager() + .getConfig() + .born_pos; if (req.getGuid() != 0) { var target = item.getTeleportPointPos(req.getGuid()); if (target != null) { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java index 15ac73f39..6eaebaaa7 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java @@ -50,15 +50,29 @@ public class HandlerTryEnterHomeReq extends PacketHandler { req.getTargetUid())); } - case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> { - session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint()); - + case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption + .FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> { + session + .getServer() + .getHomeWorldMPSystem() + .enterHome( + session.getPlayer(), + targetPlayer, + req.getTargetPoint(), + req.getIsTransferToSafePoint()); } } return; } - session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint()); + session + .getServer() + .getHomeWorldMPSystem() + .enterHome( + session.getPlayer(), + targetPlayer, + req.getTargetPoint(), + req.getIsTransferToSafePoint()); } }