From 122568ad2767a08fc81bf3550c425462343b6528 Mon Sep 17 00:00:00 2001 From: Asnxthaony Date: Mon, 25 Apr 2022 13:46:16 +0800 Subject: [PATCH] fix SetPlayerBirthdayRsp --- .../recv/HandlerSetPlayerBirthdayReq.java | 45 +++++++++---------- .../send/PacketSetPlayerBirthdayRsp.java | 4 +- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java index 0edb08f73..5bfa9f8d5 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java @@ -1,38 +1,33 @@ 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.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq; +import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.PacketGetPlayerSocialDetailRsp; import emu.grasscutter.server.packet.send.PacketSetPlayerBirthdayRsp; -import emu.grasscutter.net.packet.Opcodes; -import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.packet.PacketHandler; - -import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; -import emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq; - -import com.google.gson.Gson; - @Opcodes(PacketOpcodes.SetPlayerBirthdayReq) public class HandlerSetPlayerBirthdayReq extends PacketHandler { - @Override - public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - SetPlayerBirthdayReq req = SetPlayerBirthdayReq.parseFrom(payload); + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + SetPlayerBirthdayReq req = SetPlayerBirthdayReq.parseFrom(payload); - if(req.getBirth() != null && req.getBirth().getDay() > 0 && req.getBirth().getMonth() > 0) - { - int day = req.getBirth().getDay(); - int month = req.getBirth().getMonth(); + if (req.getBirthday().getDay() > 0 && req.getBirthday().getMonth() > 0) { + int day = req.getBirthday().getDay(); + int month = req.getBirthday().getMonth(); - // Update birthday value - session.getPlayer().setBirthday(day, month); + // Update birthday value + session.getPlayer().setBirthday(day, month); - // Save birthday month and day - session.getPlayer().save(); - SocialDetail.Builder detail = session.getPlayer().getSocialDetail(); + // Save birthday month and day + session.getPlayer().save(); + SocialDetail.Builder detail = session.getPlayer().getSocialDetail(); - session.send(new PacketSetPlayerBirthdayRsp(session.getPlayer())); - session.send(new PacketGetPlayerSocialDetailRsp(detail)); - } - } + session.send(new PacketSetPlayerBirthdayRsp(session.getPlayer())); + session.send(new PacketGetPlayerSocialDetailRsp(detail)); + } + } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java index 9b73b6b13..135d22f2f 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java @@ -1,18 +1,16 @@ package emu.grasscutter.server.packet.send; -import emu.grasscutter.Grasscutter; import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp; -import emu.grasscutter.net.proto.BirthdayOuterClass.Birthday; public class PacketSetPlayerBirthdayRsp extends GenshinPacket { public PacketSetPlayerBirthdayRsp(GenshinPlayer player) { super(PacketOpcodes.SetPlayerBirthdayRsp); SetPlayerBirthdayRsp proto = SetPlayerBirthdayRsp.newBuilder() - .setBirth(player.getBirthday().toProto()) + .setBirthday(player.getBirthday().toProto()) .build(); this.setData(proto);