mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-05-17 04:22:32 +08:00
Refactoring (#1660)
* Refactor a couple of iterators * Use side-effect instead of second iterator * Make World::onTick return shouldDelete instead of success * Replace Shop iterator with side effects * Scene * Clean up Expeditions * Refactor Expeditions * Clean up Expeditions, Player * Limit Expeditions by AR * Lombokify props Co-authored-by: AnimeGitB <AnimeGitB@bigblueball.in>
This commit is contained in:
committed by
GitHub
Unverified
parent
bccf516ca7
commit
dc9cef8ab7
+11
-17
@@ -1,33 +1,27 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.expedition.ExpeditionInfo;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionAllDataRspOuterClass.AvatarExpeditionAllDataRsp;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketAvatarExpeditionAllDataRsp extends BasePacket {
|
||||
public PacketAvatarExpeditionAllDataRsp(Player player) {
|
||||
public PacketAvatarExpeditionAllDataRsp(Map<Long, ExpeditionInfo> expeditionInfo, int expeditionCountLimit) {
|
||||
super(PacketOpcodes.AvatarExpeditionAllDataRsp);
|
||||
|
||||
List<Integer> openExpeditionList = new ArrayList<>(List.of(306,305,304,303,302,301,206,105,204,104,203,103,202,101,102,201,106,205));
|
||||
Map<Long, AvatarExpeditionInfo> avatarExpeditionInfoList = new HashMap<Long, AvatarExpeditionInfo>();
|
||||
|
||||
var expeditionInfo = player.getExpeditionInfo();
|
||||
for (Long key : player.getExpeditionInfo().keySet()) {
|
||||
ExpeditionInfo e = expeditionInfo.get(key);
|
||||
avatarExpeditionInfoList.put(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
|
||||
};
|
||||
|
||||
AvatarExpeditionAllDataRsp.Builder proto = AvatarExpeditionAllDataRsp.newBuilder()
|
||||
.addAllOpenExpeditionList(openExpeditionList)
|
||||
.setExpeditionCountLimit(5)
|
||||
.putAllExpeditionInfoMap(avatarExpeditionInfoList);
|
||||
|
||||
this.setData(proto.build());
|
||||
this.setData(AvatarExpeditionAllDataRsp.newBuilder()
|
||||
.addAllOpenExpeditionList(openExpeditionList)
|
||||
.setExpeditionCountLimit(expeditionCountLimit)
|
||||
.putAllExpeditionInfoMap(
|
||||
expeditionInfo.entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
e -> e.getKey(),
|
||||
e -> e.getValue().toProto())))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user