Format code [skip actions]

This commit is contained in:
github-actions 2023-09-02 05:49:00 +00:00
parent 9c25060c78
commit decf494234
4 changed files with 33 additions and 23 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.*;
@ -70,12 +69,12 @@ 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<>())
.unlockedHomeBgmList(new HashSet<>()) .unlockedHomeBgmList(new HashSet<>())
.finishedTalkIdMap(new HashMap<>()) .finishedTalkIdMap(new HashMap<>())
.build(); .build();
} }
public void save() { public void save() {
@ -157,17 +156,21 @@ public class GameHome {
return this.finishedTalkIdMap.get(avatarId); return this.finishedTalkIdMap.get(avatarId);
} }
public List<HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTalkFinishInfo> toAvatarTalkFinishInfoProto() { public List<HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTalkFinishInfo>
toAvatarTalkFinishInfoProto() {
if (this.finishedTalkIdMap == null) { if (this.finishedTalkIdMap == null) {
this.finishedTalkIdMap = new HashMap<>(); this.finishedTalkIdMap = new HashMap<>();
} }
return this.finishedTalkIdMap.entrySet().stream().map(e -> { return this.finishedTalkIdMap.entrySet().stream()
return HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTalkFinishInfo.newBuilder() .map(
.setAvatarId(e.getKey()) e -> {
.addAllFinishTalkIdList(e.getValue()) return HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTalkFinishInfo.newBuilder()
.build(); .setAvatarId(e.getKey())
}).toList(); .addAllFinishTalkIdList(e.getValue())
.build();
})
.toList();
} }
public boolean addUnlockedHomeBgm(int homeBgmId) { public boolean addUnlockedHomeBgm(int homeBgmId) {

View File

@ -13,7 +13,12 @@ public class HandlerHomeAvatarTalkReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = HomeAvatarTalkReqOuterClass.HomeAvatarTalkReq.parseFrom(payload); var req = HomeAvatarTalkReqOuterClass.HomeAvatarTalkReq.parseFrom(payload);
var talkIdSet = session.getPlayer().getCurHomeWorld().getHome().onTalkedWithAvatar(req.getAvatarId(), req.getTalkId()); var talkIdSet =
session
.getPlayer()
.getCurHomeWorld()
.getHome()
.onTalkedWithAvatar(req.getAvatarId(), req.getTalkId());
session.send(new PacketHomeAvatarTalkFinishInfoNotify(session.getPlayer())); session.send(new PacketHomeAvatarTalkFinishInfoNotify(session.getPlayer()));
session.send(new PacketHomeAvatarTalkRsp(req.getAvatarId(), talkIdSet)); session.send(new PacketHomeAvatarTalkRsp(req.getAvatarId(), talkIdSet));
} }

View File

@ -9,7 +9,8 @@ public class PacketHomeAvatarTalkFinishInfoNotify extends BasePacket {
public PacketHomeAvatarTalkFinishInfoNotify(Player homeOwner) { public PacketHomeAvatarTalkFinishInfoNotify(Player homeOwner) {
super(PacketOpcodes.HomeAvatarTalkFinishInfoNotify); super(PacketOpcodes.HomeAvatarTalkFinishInfoNotify);
this.setData(HomeAvatarTalkFinishInfoNotifyOuterClass.HomeAvatarTalkFinishInfoNotify.newBuilder() this.setData(
.addAllAvatarTalkInfoList(homeOwner.getHome().toAvatarTalkFinishInfoProto())); HomeAvatarTalkFinishInfoNotifyOuterClass.HomeAvatarTalkFinishInfoNotify.newBuilder()
.addAllAvatarTalkInfoList(homeOwner.getHome().toAvatarTalkFinishInfoProto()));
} }
} }

View File

@ -4,17 +4,18 @@ import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass; import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass;
import emu.grasscutter.net.proto.HomeAvatarTalkRspOuterClass; import emu.grasscutter.net.proto.HomeAvatarTalkRspOuterClass;
import java.util.Set; import java.util.Set;
public class PacketHomeAvatarTalkRsp extends BasePacket { public class PacketHomeAvatarTalkRsp extends BasePacket {
public PacketHomeAvatarTalkRsp(int avatarId, Set<Integer> talkIdSet) { public PacketHomeAvatarTalkRsp(int avatarId, Set<Integer> talkIdSet) {
super(PacketOpcodes.HomeAvatarTalkRsp); super(PacketOpcodes.HomeAvatarTalkRsp);
this.setData(HomeAvatarTalkRspOuterClass.HomeAvatarTalkRsp.newBuilder() this.setData(
.setAvatarTalkInfo(HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTalkFinishInfo.newBuilder() HomeAvatarTalkRspOuterClass.HomeAvatarTalkRsp.newBuilder()
.setAvatarId(avatarId) .setAvatarTalkInfo(
.addAllFinishTalkIdList(talkIdSet) HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTalkFinishInfo.newBuilder()
.build())); .setAvatarId(avatarId)
.addAllFinishTalkIdList(talkIdSet)
.build()));
} }
} }