Format code [skip actions]

This commit is contained in:
github-actions 2023-09-02 15:55:11 +00:00
parent ed97201473
commit f8fb6732de
7 changed files with 70 additions and 58 deletions

View File

@ -12,7 +12,6 @@ import emu.grasscutter.game.props.SceneType;
import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass; import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
@ -74,19 +73,22 @@ public class GameHome {
public static GameHome create(Integer uid) { public static GameHome create(Integer uid) {
return GameHome.of() return GameHome.of()
.ownerUid(uid) .ownerUid(uid)
.level(1) .level(1)
.sceneMap(new ConcurrentHashMap<>()) .sceneMap(new ConcurrentHashMap<>())
.mainHouseMap(new ConcurrentHashMap<>()) .mainHouseMap(new ConcurrentHashMap<>())
.unlockedHomeBgmList(new HashSet<>()) .unlockedHomeBgmList(new HashSet<>())
.finishedTalkIdMap(new HashMap<>()) .finishedTalkIdMap(new HashMap<>())
.build(); .build();
} }
// Data fixer. // Data fixer.
private void fixMainHouseIfOld() { private void fixMainHouseIfOld() {
if (this.getMainHouseMap() == null) { 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. this.mainHouseMap = new ConcurrentHashMap<>(); // assign.
} }
@ -121,18 +123,24 @@ public class GameHome {
} }
public HomeSceneItem getMainHouseItem(int outdoorSceneId) { public HomeSceneItem getMainHouseItem(int outdoorSceneId) {
return this.getMainHouseMap().computeIfAbsent(outdoorSceneId, integer -> { return this.getMainHouseMap()
var curHomeSceneItem = this.getHomeSceneItem(outdoorSceneId); .computeIfAbsent(
var roomSceneId = curHomeSceneItem.getRoomSceneId(); outdoorSceneId,
var defaultItem = GameData.getHomeworldDefaultSaveData().get(roomSceneId); integer -> {
if (defaultItem == null) { var curHomeSceneItem = this.getHomeSceneItem(outdoorSceneId);
Grasscutter.getLogger().info("defaultItem == null! returns Liyue style house."); var roomSceneId = curHomeSceneItem.getRoomSceneId();
return HomeSceneItem.parseFrom(GameData.getHomeworldDefaultSaveData().get(2202), 2202); // Liyue style 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); Grasscutter.getLogger()
return HomeSceneItem.parseFrom(defaultItem, roomSceneId); .info(
}); "Set player {} main house {} to initial setting", this.ownerUid, roomSceneId);
return HomeSceneItem.parseFrom(defaultItem, roomSceneId);
});
} }
public void onMainHouseChanged() { public void onMainHouseChanged() {
@ -321,16 +329,16 @@ public class GameHome {
if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) { if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) {
// Indoors avatars // Indoors avatars
mainHouseMap mainHouseMap
.get(player.getCurrentRealmId() + 2000) .get(player.getCurrentRealmId() + 2000)
.getBlockItems() .getBlockItems()
.forEach( .forEach(
(i, e) -> { (i, e) -> {
e.getDeployNPCList() e.getDeployNPCList()
.forEach( .forEach(
id -> { id -> {
invitedAvatars.add(id.getAvatarId()); invitedAvatars.add(id.getAvatarId());
}); });
}); });
} }
// Add exp to all avatars // Add exp to all avatars

View File

@ -5,7 +5,6 @@ import emu.grasscutter.data.GameData;
import emu.grasscutter.data.binout.HomeworldDefaultSaveData; import emu.grasscutter.data.binout.HomeworldDefaultSaveData;
import emu.grasscutter.data.excels.ItemData; import emu.grasscutter.data.excels.ItemData;
import emu.grasscutter.game.world.Position; import emu.grasscutter.game.world.Position;
import emu.grasscutter.net.proto.*; import emu.grasscutter.net.proto.*;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -9,7 +9,6 @@ import emu.grasscutter.game.entity.EntityHomeAnimal;
import emu.grasscutter.game.world.Position; import emu.grasscutter.game.world.Position;
import emu.grasscutter.game.world.Scene; import emu.grasscutter.game.world.Scene;
import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo; import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -8,7 +8,6 @@ import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HomeChangeModuleReqOuterClass; import emu.grasscutter.net.proto.HomeChangeModuleReqOuterClass;
import emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType; import emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketHomeAvatarTalkFinishInfoNotify; import emu.grasscutter.server.packet.send.PacketHomeAvatarTalkFinishInfoNotify;
import emu.grasscutter.server.packet.send.PacketHomeChangeModuleRsp; import emu.grasscutter.server.packet.send.PacketHomeChangeModuleRsp;
import emu.grasscutter.server.packet.send.PacketHomeComfortInfoNotify; import emu.grasscutter.server.packet.send.PacketHomeComfortInfoNotify;

View File

@ -5,9 +5,8 @@ import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HomeUpdateArrangementInfoReqOuterClass; import emu.grasscutter.net.proto.HomeUpdateArrangementInfoReqOuterClass;
import emu.grasscutter.server.game.GameSession; 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.PacketHomeAvatarTalkFinishInfoNotify;
import emu.grasscutter.server.packet.send.PacketHomeBasicInfoNotify;
import emu.grasscutter.server.packet.send.PacketHomeMarkPointNotify; import emu.grasscutter.server.packet.send.PacketHomeMarkPointNotify;
import emu.grasscutter.server.packet.send.PacketHomeUpdateArrangementInfoRsp; import emu.grasscutter.server.packet.send.PacketHomeUpdateArrangementInfoRsp;
@ -28,7 +27,8 @@ public class HandlerHomeUpdateArrangementInfoReq extends PacketHandler {
session.getPlayer().getHome().onMainHouseChanged(); 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 PacketHomeAvatarTalkFinishInfoNotify(session.getPlayer()));
session.send(new PacketHomeMarkPointNotify(session.getPlayer())); session.send(new PacketHomeMarkPointNotify(session.getPlayer()));

View File

@ -22,7 +22,8 @@ public class PacketHomeChangeModuleRsp extends BasePacket {
public PacketHomeChangeModuleRsp() { public PacketHomeChangeModuleRsp() {
super(PacketOpcodes.HomeChangeModuleRsp); super(PacketOpcodes.HomeChangeModuleRsp);
this.setData(HomeChangeModuleRspOuterClass.HomeChangeModuleRsp.newBuilder() this.setData(
.setRetcode(RetcodeOuterClass.Retcode.RET_HOME_HAS_GUEST_VALUE)); HomeChangeModuleRspOuterClass.HomeChangeModuleRsp.newBuilder()
.setRetcode(RetcodeOuterClass.Retcode.RET_HOME_HAS_GUEST_VALUE));
} }
} }

View File

@ -3,7 +3,6 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.home.HomeBlockItem; import emu.grasscutter.game.home.HomeBlockItem;
import emu.grasscutter.game.home.HomeMarkPointProtoFactory; import emu.grasscutter.game.home.HomeMarkPointProtoFactory;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.*; import emu.grasscutter.net.packet.*;
import emu.grasscutter.net.proto.*; import emu.grasscutter.net.proto.*;
import java.util.Collection; import java.util.Collection;
@ -28,28 +27,35 @@ public class PacketHomeMarkPointNotify extends BasePacket {
var homeScene = home.getHomeSceneItem(moduleId + 2000); var homeScene = home.getHomeSceneItem(moduleId + 2000);
var mainHouse = home.getMainHouseItem(moduleId + 2000); var mainHouse = home.getMainHouseItem(moduleId + 2000);
Set.of(homeScene, mainHouse).forEach(homeSceneItem -> { Set.of(homeScene, mainHouse)
var markPointData = .forEach(
HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData.newBuilder() homeSceneItem -> {
.setModuleId(moduleId) var markPointData =
.setSceneId(homeSceneItem.getSceneId()); HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData.newBuilder()
.setModuleId(moduleId)
.setSceneId(homeSceneItem.getSceneId());
if (!homeSceneItem.isRoom()) { if (!homeSceneItem.isRoom()) {
var config = world.getSceneById(moduleId + 2000).getScriptManager().getConfig(); var config = world.getSceneById(moduleId + 2000).getScriptManager().getConfig();
markPointData.setSafePointPos(config == null ? homeSceneItem.getBornPos().toProto() : config.born_pos.toProto()) markPointData
.setTeapotSpiritPos(homeSceneItem.getDjinnPos().toProto()); .setSafePointPos(
} config == null
? homeSceneItem.getBornPos().toProto()
: config.born_pos.toProto())
.setTeapotSpiritPos(homeSceneItem.getDjinnPos().toProto());
}
var marks = homeSceneItem.getBlockItems().values().stream() var marks =
.map(HomeBlockItem::getMarkPointProtoFactories) homeSceneItem.getBlockItems().values().stream()
.flatMap(Collection::stream) .map(HomeBlockItem::getMarkPointProtoFactories)
.filter(HomeMarkPointProtoFactory::isProtoConvertible) .flatMap(Collection::stream)
.map(HomeMarkPointProtoFactory::toMarkPointProto) .filter(HomeMarkPointProtoFactory::isProtoConvertible)
.toList(); .map(HomeMarkPointProtoFactory::toMarkPointProto)
.toList();
markPointData.addAllFurnitureList(marks); markPointData.addAllFurnitureList(marks);
proto.addMarkPointDataList(markPointData); proto.addMarkPointDataList(markPointData);
}); });
this.setData(proto); this.setData(proto);
} }