diff --git a/src/main/java/emu/grasscutter/game/home/GameHome.java b/src/main/java/emu/grasscutter/game/home/GameHome.java index e078b8f2d..52f58e3f6 100644 --- a/src/main/java/emu/grasscutter/game/home/GameHome.java +++ b/src/main/java/emu/grasscutter/game/home/GameHome.java @@ -12,7 +12,6 @@ import emu.grasscutter.game.props.SceneType; import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass; import emu.grasscutter.server.packet.send.*; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; - import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.*; @@ -74,19 +73,22 @@ public class GameHome { public static GameHome create(Integer uid) { return GameHome.of() - .ownerUid(uid) - .level(1) - .sceneMap(new ConcurrentHashMap<>()) - .mainHouseMap(new ConcurrentHashMap<>()) - .unlockedHomeBgmList(new HashSet<>()) - .finishedTalkIdMap(new HashMap<>()) - .build(); + .ownerUid(uid) + .level(1) + .sceneMap(new ConcurrentHashMap<>()) + .mainHouseMap(new ConcurrentHashMap<>()) + .unlockedHomeBgmList(new HashSet<>()) + .finishedTalkIdMap(new HashMap<>()) + .build(); } // Data fixer. private void fixMainHouseIfOld() { if (this.getMainHouseMap() == null) { - Grasscutter.getLogger().debug("Player {}'s main house will be deleted due to GC update! (ps. sorry XD)", this.getPlayer().getUid()); + Grasscutter.getLogger() + .debug( + "Player {}'s main house will be deleted due to GC update! (ps. sorry XD)", + this.getPlayer().getUid()); this.mainHouseMap = new ConcurrentHashMap<>(); // assign. } @@ -121,18 +123,24 @@ public class GameHome { } public HomeSceneItem getMainHouseItem(int outdoorSceneId) { - return this.getMainHouseMap().computeIfAbsent(outdoorSceneId, integer -> { - var curHomeSceneItem = this.getHomeSceneItem(outdoorSceneId); - var roomSceneId = curHomeSceneItem.getRoomSceneId(); - var defaultItem = GameData.getHomeworldDefaultSaveData().get(roomSceneId); - if (defaultItem == null) { - Grasscutter.getLogger().info("defaultItem == null! returns Liyue style house."); - return HomeSceneItem.parseFrom(GameData.getHomeworldDefaultSaveData().get(2202), 2202); // Liyue style - } + return this.getMainHouseMap() + .computeIfAbsent( + outdoorSceneId, + integer -> { + var curHomeSceneItem = this.getHomeSceneItem(outdoorSceneId); + var roomSceneId = curHomeSceneItem.getRoomSceneId(); + var defaultItem = GameData.getHomeworldDefaultSaveData().get(roomSceneId); + if (defaultItem == null) { + Grasscutter.getLogger().info("defaultItem == null! returns Liyue style house."); + return HomeSceneItem.parseFrom( + GameData.getHomeworldDefaultSaveData().get(2202), 2202); // Liyue style + } - Grasscutter.getLogger().info("Set player {} main house {} to initial setting", this.ownerUid, roomSceneId); - return HomeSceneItem.parseFrom(defaultItem, roomSceneId); - }); + Grasscutter.getLogger() + .info( + "Set player {} main house {} to initial setting", this.ownerUid, roomSceneId); + return HomeSceneItem.parseFrom(defaultItem, roomSceneId); + }); } public void onMainHouseChanged() { @@ -321,16 +329,16 @@ public class GameHome { if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) { // Indoors avatars mainHouseMap - .get(player.getCurrentRealmId() + 2000) - .getBlockItems() - .forEach( - (i, e) -> { - e.getDeployNPCList() - .forEach( - id -> { - invitedAvatars.add(id.getAvatarId()); - }); - }); + .get(player.getCurrentRealmId() + 2000) + .getBlockItems() + .forEach( + (i, e) -> { + e.getDeployNPCList() + .forEach( + id -> { + invitedAvatars.add(id.getAvatarId()); + }); + }); } // Add exp to all avatars diff --git a/src/main/java/emu/grasscutter/game/home/HomeFurnitureItem.java b/src/main/java/emu/grasscutter/game/home/HomeFurnitureItem.java index 2e1bd2703..7b50292eb 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeFurnitureItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeFurnitureItem.java @@ -5,7 +5,6 @@ import emu.grasscutter.data.GameData; import emu.grasscutter.data.binout.HomeworldDefaultSaveData; import emu.grasscutter.data.excels.ItemData; import emu.grasscutter.game.world.Position; - import emu.grasscutter.net.proto.*; import java.util.Set; import java.util.stream.Collectors; diff --git a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java index a313c08dc..96de2ce33 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java @@ -9,7 +9,6 @@ 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 java.util.Collection; import java.util.List; import java.util.Map; diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChangeModuleReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChangeModuleReq.java index ccb9262a3..cff46aab2 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChangeModuleReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChangeModuleReq.java @@ -8,7 +8,6 @@ import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.HomeChangeModuleReqOuterClass; import emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType; import emu.grasscutter.server.game.GameSession; - import emu.grasscutter.server.packet.send.PacketHomeAvatarTalkFinishInfoNotify; import emu.grasscutter.server.packet.send.PacketHomeChangeModuleRsp; import emu.grasscutter.server.packet.send.PacketHomeComfortInfoNotify; diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeUpdateArrangementInfoReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeUpdateArrangementInfoReq.java index 84edb8c9d..2b93ac718 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeUpdateArrangementInfoReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeUpdateArrangementInfoReq.java @@ -5,9 +5,8 @@ import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.HomeUpdateArrangementInfoReqOuterClass; import emu.grasscutter.server.game.GameSession; - -import emu.grasscutter.server.packet.send.PacketHomeBasicInfoNotify; import emu.grasscutter.server.packet.send.PacketHomeAvatarTalkFinishInfoNotify; +import emu.grasscutter.server.packet.send.PacketHomeBasicInfoNotify; import emu.grasscutter.server.packet.send.PacketHomeMarkPointNotify; import emu.grasscutter.server.packet.send.PacketHomeUpdateArrangementInfoRsp; @@ -28,7 +27,8 @@ public class HandlerHomeUpdateArrangementInfoReq extends PacketHandler { session.getPlayer().getHome().onMainHouseChanged(); } - session.send(new PacketHomeBasicInfoNotify(session.getPlayer(), session.getPlayer().isInEditMode())); + session.send( + new PacketHomeBasicInfoNotify(session.getPlayer(), session.getPlayer().isInEditMode())); session.send(new PacketHomeAvatarTalkFinishInfoNotify(session.getPlayer())); session.send(new PacketHomeMarkPointNotify(session.getPlayer())); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketHomeChangeModuleRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketHomeChangeModuleRsp.java index 85055bf04..641d989ac 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketHomeChangeModuleRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketHomeChangeModuleRsp.java @@ -22,7 +22,8 @@ public class PacketHomeChangeModuleRsp extends BasePacket { public PacketHomeChangeModuleRsp() { super(PacketOpcodes.HomeChangeModuleRsp); - this.setData(HomeChangeModuleRspOuterClass.HomeChangeModuleRsp.newBuilder() - .setRetcode(RetcodeOuterClass.Retcode.RET_HOME_HAS_GUEST_VALUE)); + this.setData( + HomeChangeModuleRspOuterClass.HomeChangeModuleRsp.newBuilder() + .setRetcode(RetcodeOuterClass.Retcode.RET_HOME_HAS_GUEST_VALUE)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketHomeMarkPointNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketHomeMarkPointNotify.java index 9fff3088a..6646efccb 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketHomeMarkPointNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketHomeMarkPointNotify.java @@ -3,7 +3,6 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.game.home.HomeBlockItem; import emu.grasscutter.game.home.HomeMarkPointProtoFactory; import emu.grasscutter.game.player.Player; - import emu.grasscutter.net.packet.*; import emu.grasscutter.net.proto.*; import java.util.Collection; @@ -28,28 +27,35 @@ public class PacketHomeMarkPointNotify extends BasePacket { var homeScene = home.getHomeSceneItem(moduleId + 2000); var mainHouse = home.getMainHouseItem(moduleId + 2000); - Set.of(homeScene, mainHouse).forEach(homeSceneItem -> { - var markPointData = - HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData.newBuilder() - .setModuleId(moduleId) - .setSceneId(homeSceneItem.getSceneId()); + Set.of(homeScene, mainHouse) + .forEach( + homeSceneItem -> { + var markPointData = + HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData.newBuilder() + .setModuleId(moduleId) + .setSceneId(homeSceneItem.getSceneId()); - if (!homeSceneItem.isRoom()) { - var config = world.getSceneById(moduleId + 2000).getScriptManager().getConfig(); - markPointData.setSafePointPos(config == null ? homeSceneItem.getBornPos().toProto() : config.born_pos.toProto()) - .setTeapotSpiritPos(homeSceneItem.getDjinnPos().toProto()); - } + if (!homeSceneItem.isRoom()) { + var config = world.getSceneById(moduleId + 2000).getScriptManager().getConfig(); + markPointData + .setSafePointPos( + config == null + ? homeSceneItem.getBornPos().toProto() + : config.born_pos.toProto()) + .setTeapotSpiritPos(homeSceneItem.getDjinnPos().toProto()); + } - var marks = homeSceneItem.getBlockItems().values().stream() - .map(HomeBlockItem::getMarkPointProtoFactories) - .flatMap(Collection::stream) - .filter(HomeMarkPointProtoFactory::isProtoConvertible) - .map(HomeMarkPointProtoFactory::toMarkPointProto) - .toList(); + var marks = + homeSceneItem.getBlockItems().values().stream() + .map(HomeBlockItem::getMarkPointProtoFactories) + .flatMap(Collection::stream) + .filter(HomeMarkPointProtoFactory::isProtoConvertible) + .map(HomeMarkPointProtoFactory::toMarkPointProto) + .toList(); - markPointData.addAllFurnitureList(marks); - proto.addMarkPointDataList(markPointData); - }); + markPointData.addAllFurnitureList(marks); + proto.addMarkPointDataList(markPointData); + }); this.setData(proto); }