From 022dcf60ad5c9080811440ea57891cb9faa2b231 Mon Sep 17 00:00:00 2001 From: ShigemoriHakura <62388797+ShigemoriHakura@users.noreply.github.com> Date: Thu, 5 May 2022 01:06:33 +0800 Subject: [PATCH] fix achievement proto (#507) * fix achievement proto TakeAchievementRewardReq tells client the achievements achieved or not and it's progress. * add import --- proto/AchievementInfo.proto | 17 +++++++++++ proto/TakeAchievementRewardReq.proto | 17 +++++++++++ .../packet/recv/HandlerPlayerLoginReq.java | 2 ++ .../send/PacketTakeAchievementRewardReq.java | 30 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 proto/AchievementInfo.proto create mode 100644 proto/TakeAchievementRewardReq.proto create mode 100644 src/main/java/emu/grasscutter/server/packet/send/PacketTakeAchievementRewardReq.java diff --git a/proto/AchievementInfo.proto b/proto/AchievementInfo.proto new file mode 100644 index 000000000..81d78eb77 --- /dev/null +++ b/proto/AchievementInfo.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +option java_package = "emu.grasscutter.net.proto"; +message AchievementInfo { + enum AchievementInfoStatus { + ACHIEVEMENT_INVALID = 0; + ACHIEVEMENT_UNFINISHED = 1; + ACHIEVEMENT_FINISHED = 2; + ACHIEVEMENT_POINT_TAKEN = 3; + } + + uint32 id = 1; + AchievementInfoStatus status = 2; + uint32 current = 3; + uint32 goal = 4; + uint32 achievedate = 5; +} diff --git a/proto/TakeAchievementRewardReq.proto b/proto/TakeAchievementRewardReq.proto new file mode 100644 index 000000000..64ac2d3ae --- /dev/null +++ b/proto/TakeAchievementRewardReq.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +option java_package = "emu.grasscutter.net.proto"; + +import "AchievementInfo.proto"; +message TakeAchievementRewardReq { + enum CmdId { + option allow_alias = true; + ENET_CHANNEL_ID = 0; + NONE = 0; + ENET_IS_RELIABLE = 1; + IS_ALLOW_CLIENT = 1; + CMD_ID = 2677; + } + + repeated AchievementInfo a_list = 1; +} diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java index a419a0db9..cfdce5b59 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java @@ -10,6 +10,7 @@ import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession.SessionState; import emu.grasscutter.server.packet.send.PacketPlayerLoginRsp; +import emu.grasscutter.server.packet.send.PacketTakeAchievementRewardReq; @Opcodes(PacketOpcodes.PlayerLoginReq) // Sends initial data packets public class HandlerPlayerLoginReq extends PacketHandler { @@ -47,6 +48,7 @@ public class HandlerPlayerLoginReq extends PacketHandler { // Final packet to tell client logging in is done session.send(new PacketPlayerLoginRsp(session)); + session.send(new PacketTakeAchievementRewardReq(session)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketTakeAchievementRewardReq.java b/src/main/java/emu/grasscutter/server/packet/send/PacketTakeAchievementRewardReq.java new file mode 100644 index 000000000..24135d52c --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketTakeAchievementRewardReq.java @@ -0,0 +1,30 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.BasePacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.AchievementInfoOuterClass; +import emu.grasscutter.net.proto.AchievementInfoOuterClass.AchievementInfo; +import emu.grasscutter.net.proto.TakeAchievementRewardReqOuterClass.TakeAchievementRewardReq; +import emu.grasscutter.server.game.GameSession; + +import java.util.ArrayList; +import java.util.List; + +public class PacketTakeAchievementRewardReq extends BasePacket { + + public PacketTakeAchievementRewardReq(GameSession session) { + super(PacketOpcodes.TakeAchievementRewardReq); + + List a_list = new ArrayList<>(); + a_list.add(AchievementInfo.newBuilder().setId(82044).setStatusValue(2).setCurrent(0).setGoal(1).build()); + a_list.add(AchievementInfo.newBuilder().setId(81205).setStatusValue(2).setCurrent(0).setGoal(1).build()); + + + TakeAchievementRewardReq proto = TakeAchievementRewardReq.newBuilder() + .addAllAList(a_list) + .build(); + + this.setData(proto); + } + +} \ No newline at end of file