Commit 0e3a8040 authored by ayy lmao's avatar ayy lmao Committed by memetrollsXD
Browse files

Added missing isGiftMail section to GetAllMailRsp

parent d1fc8c1f
......@@ -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<MailData> mailDataList = new ArrayList<MailData>();
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());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment