mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 06:50:36 +00:00
THE MAILBOX ACTUALLY WORKS CORRECTLY NOW
This commit is contained in:
parent
b10a889d76
commit
c7096f9e49
@ -47,7 +47,7 @@ public class Mail {
|
|||||||
this._id = _id;
|
this._id = _id;
|
||||||
this.mailContent = mailContent;
|
this.mailContent = mailContent;
|
||||||
this.itemList = itemList;
|
this.itemList = itemList;
|
||||||
this.sendTime = (int) Instant.now().EPOCH.getEpochSecond();
|
this.sendTime = (int) Instant.now().getEpochSecond();
|
||||||
this.expireTime = expireTime;
|
this.expireTime = expireTime;
|
||||||
this.importance = importance;
|
this.importance = importance;
|
||||||
this.isRead = false;
|
this.isRead = false;
|
||||||
|
@ -11,7 +11,9 @@ import emu.grasscutter.net.proto.GetAllMailRspOuterClass.GetAllMailRsp;
|
|||||||
import emu.grasscutter.net.proto.MailDataOuterClass.MailData;
|
import emu.grasscutter.net.proto.MailDataOuterClass.MailData;
|
||||||
import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent;
|
import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PacketGetAllMailRsp extends GenshinPacket {
|
public class PacketGetAllMailRsp extends GenshinPacket {
|
||||||
@ -20,48 +22,69 @@ public class PacketGetAllMailRsp extends GenshinPacket {
|
|||||||
super(PacketOpcodes.GetAllMailRsp);
|
super(PacketOpcodes.GetAllMailRsp);
|
||||||
Grasscutter.getLogger().info(String.valueOf(isGiftMail));
|
Grasscutter.getLogger().info(String.valueOf(isGiftMail));
|
||||||
|
|
||||||
GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder();
|
if (isGiftMail) {
|
||||||
|
// TODO: Gift Mail
|
||||||
List<MailData> mailDataList = new ArrayList<MailData>();
|
// Make sure to send the stupid empty packet
|
||||||
|
Base64.Decoder decoder = Base64.getDecoder();
|
||||||
// Dummy data.
|
byte[] rsp = decoder.decode("IAE=");
|
||||||
for(Mail message : player.getMail()) {
|
try {
|
||||||
MailTextContent.Builder mailTextContent = MailTextContent.newBuilder();
|
GetAllMailRsp var = GetAllMailRsp.parseFrom(rsp);
|
||||||
mailTextContent.setTitle(message.mailContent.title);
|
this.setData(var.toBuilder().build());
|
||||||
mailTextContent.setContent(message.mailContent.content);
|
} catch (Exception e) {
|
||||||
mailTextContent.setSender(message.mailContent.sender);
|
|
||||||
|
|
||||||
List<MailItemOuterClass.MailItem> mailItems = new ArrayList<MailItemOuterClass.MailItem>();
|
|
||||||
|
|
||||||
for(Mail.MailItem item : message.itemList) {
|
|
||||||
MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder();
|
|
||||||
ItemParamOuterClass.ItemParam.Builder itemParam = ItemParamOuterClass.ItemParam.newBuilder();
|
|
||||||
itemParam.setItemId(item.itemId);
|
|
||||||
itemParam.setCount(item.itemCount);
|
|
||||||
mailItem.setItemParam(itemParam.build());
|
|
||||||
|
|
||||||
mailItems.add(mailItem.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MailDataOuterClass.MailData.Builder mailData = MailDataOuterClass.MailData.newBuilder();
|
} else {
|
||||||
mailData.setMailId(message._id);
|
if (player.getMail().size() != 0) { // Make sure the player has mail
|
||||||
mailData.setMailTextContent(mailTextContent.build());
|
GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder();
|
||||||
mailData.addAllItemList(mailItems);
|
List<MailData> mailDataList = new ArrayList<MailData>();
|
||||||
mailData.setSendTime((int)message.sendTime);
|
|
||||||
mailData.setExpireTime((int)message.expireTime);
|
|
||||||
mailData.setImportance(message.importance);
|
|
||||||
mailData.setIsRead(message.isRead);
|
|
||||||
mailData.setIsAttachmentGot(message.isAttachmentGot);
|
|
||||||
mailData.setStateValue(message.stateValue);
|
|
||||||
|
|
||||||
mailDataList.add(mailData.build());
|
for (Mail message : player.getMail()) {
|
||||||
|
if(message.stateValue == 1) { //Make sure it isn't a gift
|
||||||
|
MailTextContent.Builder mailTextContent = MailTextContent.newBuilder();
|
||||||
|
mailTextContent.setTitle(message.mailContent.title);
|
||||||
|
mailTextContent.setContent(message.mailContent.content);
|
||||||
|
mailTextContent.setSender(message.mailContent.sender);
|
||||||
|
|
||||||
|
List<MailItemOuterClass.MailItem> mailItems = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Mail.MailItem item : message.itemList) {
|
||||||
|
MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder();
|
||||||
|
ItemParamOuterClass.ItemParam.Builder itemParam = ItemParamOuterClass.ItemParam.newBuilder();
|
||||||
|
itemParam.setItemId(item.itemId);
|
||||||
|
itemParam.setCount(item.itemCount);
|
||||||
|
mailItem.setItemParam(itemParam.build());
|
||||||
|
|
||||||
|
mailItems.add(mailItem.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
MailDataOuterClass.MailData.Builder mailData = MailDataOuterClass.MailData.newBuilder();
|
||||||
|
mailData.setMailId(message._id);
|
||||||
|
mailData.setMailTextContent(mailTextContent.build());
|
||||||
|
mailData.addAllItemList(mailItems);
|
||||||
|
mailData.setSendTime((int) message.sendTime);
|
||||||
|
mailData.setExpireTime((int) message.expireTime);
|
||||||
|
mailData.setImportance(message.importance);
|
||||||
|
mailData.setIsRead(message.isRead);
|
||||||
|
mailData.setIsAttachmentGot(message.isAttachmentGot);
|
||||||
|
mailData.setStateValue(1);
|
||||||
|
|
||||||
|
mailDataList.add(mailData.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proto.addAllMailList(mailDataList);
|
||||||
|
proto.setIsTruncated(true);
|
||||||
|
|
||||||
|
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) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proto.addAllMailList(mailDataList);
|
|
||||||
//proto.setIsTruncated(true);
|
|
||||||
|
|
||||||
Grasscutter.getLogger().info(Grasscutter.getDispatchServer().getGsonFactory().toJson(proto.build()));
|
|
||||||
|
|
||||||
this.setData(proto.build());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user