mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 12:05:39 +00:00
Format code [skip actions]
This commit is contained in:
parent
ed97201473
commit
f8fb6732de
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user