mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 13:19:59 +00:00
Implement Avatar Expedition System
Co-Authored-By: ShigemoriHakura <62388797+ShigemoriHakura@users.noreply.github.com> Co-Authored-By: KanyeWestc <104547412+KanyeWestc@users.noreply.github.com> Co-Authored-By: QAQ 天小络 <72185326+XTL676@users.noreply.github.com> Co-Authored-By: nkxingxh <25559053+nkxingxh@users.noreply.github.com> Co-Authored-By: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Co-Authored-By: wuwuwu223 <81224214+wuwuwu223@users.noreply.github.com> Co-Authored-By: omg-xtao <100690902+omg-xtao@users.noreply.github.com> Co-Authored-By: Sakura <104815797+Sakura@users.noreply.github.com> Co-Authored-By: NewNeko-2022 <104819344+NewNeko-2022@users.noreply.github.com> Co-Authored-By: JimWails <30657653+JimWails@users.noreply.github.com> Co-Authored-By: buttercookies <19878609+ButterCookies@users.noreply.github.com>
This commit is contained in:
parent
63a37acc1b
commit
19a2c9b7ea
112
data/ExpeditionReward.json
Normal file
112
data/ExpeditionReward.json
Normal file
@ -0,0 +1,112 @@
|
||||
[
|
||||
{
|
||||
"expId": 301,
|
||||
"expeditionRewardDataList": [
|
||||
{
|
||||
"hourTime": 4,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 202,
|
||||
"minCount": 625,
|
||||
"maxCount": 625
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"hourTime": 8,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 202,
|
||||
"minCount": 1575,
|
||||
"maxCount": 1575
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"hourTime": 12,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 202,
|
||||
"minCount": 2500,
|
||||
"maxCount": 2500
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"hourTime": 20,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 202,
|
||||
"minCount": 5000,
|
||||
"maxCount": 5000
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"expId": 305,
|
||||
"expeditionRewardDataList": [
|
||||
{
|
||||
"hourTime": 4,
|
||||
"rewardMora": 0,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 100064,
|
||||
"minCount": 1,
|
||||
"maxCount": 1
|
||||
}, {
|
||||
"itemId": 101210,
|
||||
"minCount": 1,
|
||||
"maxCount": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"hourTime": 8,
|
||||
"rewardMora": 0,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 100064,
|
||||
"minCount": 2,
|
||||
"maxCount": 4
|
||||
}, {
|
||||
"itemId": 101210,
|
||||
"minCount": 2,
|
||||
"maxCount": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"hourTime": 12,
|
||||
"rewardMora": 0,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 100064,
|
||||
"minCount": 4,
|
||||
"maxCount": 6
|
||||
}, {
|
||||
"itemId": 101210,
|
||||
"minCount": 4,
|
||||
"maxCount": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"hourTime": 20,
|
||||
"rewardMora": 0,
|
||||
"expeditionRewardData": [
|
||||
{
|
||||
"itemId": 100064,
|
||||
"minCount": 8,
|
||||
"maxCount": 12
|
||||
}, {
|
||||
"itemId": 101210,
|
||||
"minCount": 8,
|
||||
"maxCount": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -0,0 +1,44 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
|
||||
@Entity
|
||||
public class ExpeditionInfo {
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getExpId() {
|
||||
return expId;
|
||||
}
|
||||
|
||||
public void setExpId(int expId) {
|
||||
this.expId = expId;
|
||||
}
|
||||
|
||||
public int getHourTime() {
|
||||
return hourTime;
|
||||
}
|
||||
|
||||
public void setHourTime(int hourTime) {
|
||||
this.hourTime = hourTime;
|
||||
}
|
||||
|
||||
public int getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(int startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
private int state;
|
||||
private int expId;
|
||||
private int hourTime;
|
||||
private int startTime;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ExpeditionManager {
|
||||
public GameServer getGameServer() {
|
||||
return gameServer;
|
||||
}
|
||||
|
||||
private final GameServer gameServer;
|
||||
|
||||
public Int2ObjectMap<List<ExpeditionRewardDataList>> getExpeditionRewardDataList() { return expeditionRewardData; }
|
||||
|
||||
private final Int2ObjectMap<List<ExpeditionRewardDataList>> expeditionRewardData;
|
||||
|
||||
public ExpeditionManager(GameServer gameServer) {
|
||||
this.gameServer = gameServer;
|
||||
this.expeditionRewardData = new Int2ObjectOpenHashMap<>();
|
||||
this.load();
|
||||
}
|
||||
|
||||
public synchronized void load() {
|
||||
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "ExpeditionReward.json")) {
|
||||
getExpeditionRewardDataList().clear();
|
||||
List<ExpeditionRewardInfo> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ExpeditionRewardInfo.class).getType());
|
||||
if(banners.size() > 0) {
|
||||
for (ExpeditionRewardInfo di : banners) {
|
||||
getExpeditionRewardDataList().put(di.getExpId(), di.getExpeditionRewardDataList());
|
||||
}
|
||||
Grasscutter.getLogger().info("Expedition reward successfully loaded.");
|
||||
} else {
|
||||
Grasscutter.getLogger().error("Unable to load expedition reward. Expedition reward size is 0.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load expedition reward.", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
public class ExpeditionRewardData {
|
||||
private int itemId;
|
||||
private int minCount;
|
||||
private int maxCount;
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public int getMinCount() { return minCount; }
|
||||
|
||||
public int getMaxCount() {
|
||||
return maxCount;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ExpeditionRewardDataList {
|
||||
public int getHourTime() {
|
||||
return hourTime;
|
||||
}
|
||||
public List<ExpeditionRewardData> getExpeditionRewardData() {
|
||||
return expeditionRewardData;
|
||||
}
|
||||
|
||||
private int hourTime;
|
||||
private List<ExpeditionRewardData> expeditionRewardData;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ExpeditionRewardInfo {
|
||||
public int getExpId() {
|
||||
return expId;
|
||||
}
|
||||
|
||||
public List<ExpeditionRewardDataList> getExpeditionRewardDataList() {
|
||||
return expeditionRewardDataList;
|
||||
}
|
||||
|
||||
private int expId;
|
||||
private List<ExpeditionRewardDataList> expeditionRewardDataList;
|
||||
}
|
@ -14,6 +14,7 @@ import emu.grasscutter.game.avatar.AvatarStorage;
|
||||
import emu.grasscutter.game.entity.EntityGadget;
|
||||
import emu.grasscutter.game.entity.EntityItem;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.game.expedition.ExpeditionInfo;
|
||||
import emu.grasscutter.game.friends.FriendsList;
|
||||
import emu.grasscutter.game.friends.PlayerProfile;
|
||||
import emu.grasscutter.game.gacha.PlayerGachaInfo;
|
||||
@ -50,6 +51,7 @@ import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.DateHelper;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import emu.grasscutter.utils.MessageHandler;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
@ -101,6 +103,7 @@ public class Player {
|
||||
private ArrayList<AvatarProfileData> shownAvatars;
|
||||
private Set<Integer> rewardedLevels;
|
||||
private ArrayList<ShopLimit> shopLimit;
|
||||
private Map<Long, ExpeditionInfo> expeditionInfo;
|
||||
|
||||
private int sceneId;
|
||||
private int regionId;
|
||||
@ -170,6 +173,7 @@ public class Player {
|
||||
this.moonCardGetTimes = new HashSet<>();
|
||||
|
||||
this.shopLimit = new ArrayList<>();
|
||||
this.expeditionInfo = new HashMap<>();
|
||||
this.messageHandler = null;
|
||||
this.mapMarksManager = new MapMarksManager();
|
||||
this.movementManager = new MovementManager(this);
|
||||
@ -673,6 +677,28 @@ public class Player {
|
||||
session.send(new PacketCardProductRewardNotify(getMoonCardRemainDays()));
|
||||
}
|
||||
|
||||
public Map<Long, ExpeditionInfo> getExpeditionInfo() {
|
||||
return expeditionInfo;
|
||||
}
|
||||
|
||||
public void addExpeditionInfo(long avaterGuid, int expId, int hourTime, int startTime){
|
||||
ExpeditionInfo exp = new ExpeditionInfo();
|
||||
exp.setExpId(expId);
|
||||
exp.setHourTime(hourTime);
|
||||
exp.setState(1);
|
||||
exp.setStartTime(startTime);
|
||||
expeditionInfo.put(avaterGuid, exp);
|
||||
}
|
||||
|
||||
public void removeExpeditionInfo(long avaterGuid){
|
||||
expeditionInfo.remove(avaterGuid);
|
||||
}
|
||||
|
||||
public ExpeditionInfo getExpeditionInfo(long avaterGuid){
|
||||
return expeditionInfo.get(avaterGuid);
|
||||
}
|
||||
|
||||
|
||||
public List<ShopLimit> getShopLimit() {
|
||||
return shopLimit;
|
||||
}
|
||||
@ -1029,6 +1055,22 @@ public class Player {
|
||||
this.resetSendPlayerLocTime();
|
||||
}
|
||||
}
|
||||
// Expedition
|
||||
var timeNow = Utils.getCurrentSeconds();
|
||||
var needNotify = false;
|
||||
for (Long key : expeditionInfo.keySet()) {
|
||||
ExpeditionInfo e = expeditionInfo.get(key);
|
||||
if(e.getState() == 1){
|
||||
if(timeNow - e.getStartTime() >= e.getHourTime() * 60 * 60){
|
||||
e.setState(2);
|
||||
needNotify = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(needNotify){
|
||||
this.save();
|
||||
this.sendPacket(new PacketAvatarExpeditionDataNotify(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ import emu.grasscutter.game.Account;
|
||||
import emu.grasscutter.game.combine.CombineManger;
|
||||
import emu.grasscutter.game.drop.DropManager;
|
||||
import emu.grasscutter.game.dungeons.DungeonManager;
|
||||
import emu.grasscutter.game.expedition.ExpeditionManager;
|
||||
import emu.grasscutter.game.gacha.GachaManager;
|
||||
import emu.grasscutter.game.managers.ChatManager;
|
||||
import emu.grasscutter.game.managers.InventoryManager;
|
||||
@ -42,6 +43,7 @@ public final class GameServer extends KcpServer {
|
||||
private final ShopManager shopManager;
|
||||
private final MultiplayerManager multiplayerManager;
|
||||
private final DungeonManager dungeonManager;
|
||||
private final ExpeditionManager expeditionManager;
|
||||
private final CommandMap commandMap;
|
||||
private final TaskMap taskMap;
|
||||
private final DropManager dropManager;
|
||||
@ -66,6 +68,7 @@ public final class GameServer extends KcpServer {
|
||||
this.commandMap = new CommandMap(true);
|
||||
this.taskMap = new TaskMap(true);
|
||||
this.dropManager = new DropManager(this);
|
||||
this.expeditionManager = new ExpeditionManager(this);
|
||||
this.combineManger = new CombineManger(this);
|
||||
|
||||
// Schedule game loop.
|
||||
@ -124,7 +127,11 @@ public final class GameServer extends KcpServer {
|
||||
public DungeonManager getDungeonManager() {
|
||||
return dungeonManager;
|
||||
}
|
||||
|
||||
|
||||
public ExpeditionManager getExpeditionManager() {
|
||||
return expeditionManager;
|
||||
}
|
||||
|
||||
public CommandMap getCommandMap() {
|
||||
return this.commandMap;
|
||||
}
|
||||
@ -132,6 +139,7 @@ public final class GameServer extends KcpServer {
|
||||
public CombineManger getCombineManger(){
|
||||
return this.combineManger;
|
||||
}
|
||||
|
||||
public TaskMap getTaskMap() {
|
||||
return this.taskMap;
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionAllDataRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.AvatarExpeditionAllDataReq)
|
||||
public class HandlerAvatarExpeditionAllDataReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
session.send(new PacketAvatarExpeditionAllDataRsp(session.getPlayer()));
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionCallBackReqOuterClass.AvatarExpeditionCallBackReq;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionCallBackRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionStartRsp;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
@Opcodes(PacketOpcodes.AvatarExpeditionCallBackReq)
|
||||
public class HandlerAvatarExpeditionCallBackReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
AvatarExpeditionCallBackReq req = AvatarExpeditionCallBackReq.parseFrom(payload);
|
||||
|
||||
for (int i = 0; i < req.getAvatarGuidCount(); i++) {
|
||||
session.getPlayer().removeExpeditionInfo(req.getAvatarGuid(i));
|
||||
}
|
||||
|
||||
session.getPlayer().save();
|
||||
session.send(new PacketAvatarExpeditionCallBackRsp(session.getPlayer()));
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.drop.DropData;
|
||||
import emu.grasscutter.game.expedition.ExpeditionInfo;
|
||||
import emu.grasscutter.game.expedition.ExpeditionRewardData;
|
||||
import emu.grasscutter.game.expedition.ExpeditionRewardDataList;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionGetRewardReqOuterClass.AvatarExpeditionGetRewardReq;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionCallBackRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionGetRewardRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Opcodes(PacketOpcodes.AvatarExpeditionGetRewardReq)
|
||||
public class HandlerAvatarExpeditionGetRewardReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
AvatarExpeditionGetRewardReq req = AvatarExpeditionGetRewardReq.parseFrom(payload);
|
||||
|
||||
ExpeditionInfo expInfo = session.getPlayer().getExpeditionInfo(req.getAvatarGuid());
|
||||
|
||||
List<GameItem> items = new LinkedList<>();
|
||||
|
||||
if (session.getServer().getExpeditionManager().getExpeditionRewardDataList().containsKey(expInfo.getExpId())) {
|
||||
for (ExpeditionRewardDataList RewardDataList : session.getServer().getExpeditionManager().getExpeditionRewardDataList().get(expInfo.getExpId())) {
|
||||
if(RewardDataList.getHourTime() == expInfo.getHourTime()){
|
||||
if(!RewardDataList.getExpeditionRewardData().isEmpty()){
|
||||
for (ExpeditionRewardData RewardData :RewardDataList.getExpeditionRewardData()) {
|
||||
int num = RewardData.getMinCount();
|
||||
if(RewardData.getMinCount() != RewardData.getMaxCount()){
|
||||
num = Utils.randomRange(RewardData.getMinCount(), RewardData.getMaxCount());
|
||||
}
|
||||
items.add(new GameItem(RewardData.getItemId(), num));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
session.getPlayer().getInventory().addItems(items);
|
||||
session.getPlayer().sendPacket(new PacketItemAddHintNotify(items, ActionReason.ExpeditionReward));
|
||||
|
||||
session.getPlayer().removeExpeditionInfo(req.getAvatarGuid());
|
||||
session.getPlayer().save();
|
||||
session.send(new PacketAvatarExpeditionGetRewardRsp(session.getPlayer(), items));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionStartReqOuterClass.AvatarExpeditionStartReq;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionStartRsp;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
@Opcodes(PacketOpcodes.AvatarExpeditionStartReq)
|
||||
public class HandlerAvatarExpeditionStartReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
AvatarExpeditionStartReq req = AvatarExpeditionStartReq.parseFrom(payload);
|
||||
|
||||
int startTime = Utils.getCurrentSeconds();
|
||||
session.getPlayer().addExpeditionInfo(req.getAvatarGuid(), req.getExpId(), req.getHourTime(), startTime);
|
||||
session.getPlayer().save();
|
||||
session.send(new PacketAvatarExpeditionStartRsp(session.getPlayer()));
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
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.*;
|
||||
|
||||
public class PacketAvatarExpeditionAllDataRsp extends BasePacket {
|
||||
public PacketAvatarExpeditionAllDataRsp(Player player) {
|
||||
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());
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
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.AvatarExpeditionCallBackRspOuterClass.AvatarExpeditionCallBackRsp;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
|
||||
|
||||
public class PacketAvatarExpeditionCallBackRsp extends BasePacket {
|
||||
public PacketAvatarExpeditionCallBackRsp(Player player) {
|
||||
super(PacketOpcodes.AvatarExpeditionCallBackRsp);
|
||||
|
||||
AvatarExpeditionCallBackRsp.Builder proto = AvatarExpeditionCallBackRsp.newBuilder();
|
||||
var expeditionInfo = player.getExpeditionInfo();
|
||||
for (Long key : player.getExpeditionInfo().keySet()) {
|
||||
ExpeditionInfo e = expeditionInfo.get(key);
|
||||
proto.putExpeditionInfoMap(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
|
||||
};
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
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.AvatarExpeditionDataNotifyOuterClass.AvatarExpeditionDataNotify;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PacketAvatarExpeditionDataNotify extends BasePacket {
|
||||
public PacketAvatarExpeditionDataNotify(Player player) {
|
||||
super(PacketOpcodes.AvatarExpeditionDataNotify);
|
||||
|
||||
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());
|
||||
};
|
||||
|
||||
AvatarExpeditionDataNotify.Builder proto = AvatarExpeditionDataNotify.newBuilder()
|
||||
.putAllExpeditionInfoMap(avatarExpeditionInfoList);
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.game.expedition.ExpeditionInfo;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionGetRewardRspOuterClass.AvatarExpeditionGetRewardRsp;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class PacketAvatarExpeditionGetRewardRsp extends BasePacket {
|
||||
public PacketAvatarExpeditionGetRewardRsp(Player player, Collection<GameItem> items) {
|
||||
super(PacketOpcodes.AvatarExpeditionGetRewardRsp);
|
||||
|
||||
AvatarExpeditionGetRewardRsp.Builder proto = AvatarExpeditionGetRewardRsp.newBuilder();
|
||||
var expeditionInfo = player.getExpeditionInfo();
|
||||
for (Long key : player.getExpeditionInfo().keySet()) {
|
||||
ExpeditionInfo e = expeditionInfo.get(key);
|
||||
proto.putExpeditionInfoMap(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
|
||||
};
|
||||
|
||||
for (GameItem item : items) {
|
||||
proto.addItemList(item.toItemParam());
|
||||
}
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
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.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionStartRspOuterClass.AvatarExpeditionStartRsp;
|
||||
|
||||
public class PacketAvatarExpeditionStartRsp extends BasePacket {
|
||||
public PacketAvatarExpeditionStartRsp(Player player) {
|
||||
super(PacketOpcodes.AvatarExpeditionStartRsp);
|
||||
|
||||
AvatarExpeditionStartRsp.Builder proto = AvatarExpeditionStartRsp.newBuilder();
|
||||
var expeditionInfo = player.getExpeditionInfo();
|
||||
for (Long key : player.getExpeditionInfo().keySet()) {
|
||||
ExpeditionInfo e = expeditionInfo.get(key);
|
||||
proto.putExpeditionInfoMap(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
|
||||
};
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user