diff --git a/proto/GetAllMailRsp.proto b/proto/GetAllMailRsp.proto index 0613899cb..968916640 100644 --- a/proto/GetAllMailRsp.proto +++ b/proto/GetAllMailRsp.proto @@ -8,4 +8,5 @@ message GetAllMailRsp { int32 retcode = 1; repeated MailData mail_list = 2; bool is_truncated = 3; + bool isGiftMail = 4; } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java index 8c8fb4b07..59af30f42 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java @@ -14,32 +14,23 @@ import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent; import java.time.Instant; import java.util.ArrayList; -import java.util.Base64; import java.util.List; public class PacketGetAllMailRsp extends BasePacket { public PacketGetAllMailRsp(Player player, boolean isGiftMail) { super(PacketOpcodes.GetAllMailRsp); + GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder(); if (isGiftMail) { - // TODO: Gift Mail - // Make sure to send the stupid empty packet - Base64.Decoder decoder = Base64.getDecoder(); - byte[] rsp = decoder.decode("IAE="); - try { - GetAllMailRsp var = GetAllMailRsp.parseFrom(rsp); - this.setData(var.toBuilder().build()); - } catch (Exception e) { - } - + proto.setIsGiftMail(true); } else { + proto.setIsGiftMail(false); + if (player.getAllMail().size() != 0) { // Make sure the player has mail - GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder(); List mailDataList = new ArrayList(); for (Mail message : player.getAllMail()) { - if(message.stateValue == 1) { // Make sure it isn't a gift if (message.expireTime > (int) Instant.now().getEpochSecond()) { // Make sure the message isn't expired (The game won't show expired mail, but I don't want to send unnecessary information). if(mailDataList.size() <= 1000) { // Make sure that there isn't over 1000 messages in the mailbox. (idk what will happen if there is but the game probably won't like it.) @@ -79,17 +70,8 @@ public class PacketGetAllMailRsp extends BasePacket { proto.addAllMailList(mailDataList); proto.setIsTruncated(mailDataList.size() <= 1000 ? false : true); // When enabled this will send a notification to the user telling them their inbox is full and they should delete old messages when opening the mailbox. - - this.setData(proto.build()); - } else { - // Make sure to send the stupid empty packet - Base64.Decoder decoder = Base64.getDecoder(); - byte[] rsp = decoder.decode("IAE="); - try { - GetAllMailRsp var = GetAllMailRsp.parseFrom(rsp); - this.setData(var.toBuilder().build()); - } catch (Exception e) {} } } + this.setData(proto.build()); } }