mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 21:10:54 +00:00
Added GetMailItemReq/Rsp & PacketMailChangeNotify
Mail still doesn't work for whatever reason. I also added a temporary SendMailCommand just to receive PacketMailChangeNotify. I feel like I'm about to lose my mind.
This commit is contained in:
parent
dd42d3b027
commit
d0538f7aee
@ -1 +1 @@
|
||||
Subproject commit 0537e9cc4c7856a7c6f88bbbaa908a80c4ee677e
|
||||
Subproject commit ba0eab7d629b5adeb145bc430e14ffcb4bdf3d6a
|
@ -0,0 +1,19 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.GenshinPlayer;
|
||||
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Command(label = "sendmail", usage = "sendmail")
|
||||
public class SendMailCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(GenshinPlayer sender, List<String> args) {
|
||||
// This is literally so I can test the notification
|
||||
sender.getSession().send(new PacketMailChangeNotify(sender));
|
||||
sender.dropMessage("Check your inbox");
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.GetMailItemReqOuterClass;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketGetAllMailRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketGetMailItemRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.GetMailItemReq)
|
||||
public class HandlerGetMailItemReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
Grasscutter.getLogger().info("Mail Item Req");
|
||||
GetMailItemReqOuterClass.GetMailItemReq req = GetMailItemReqOuterClass.GetMailItemReq.parseFrom(payload);
|
||||
session.send(new PacketGetMailItemRsp(session.getPlayer(), req.getMailIdListList()));
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +1,56 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
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.DateTimeDeleteOuterClass;
|
||||
import emu.grasscutter.net.proto.GetAllMailRspOuterClass.GetAllMailRsp;
|
||||
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||
import emu.grasscutter.net.proto.MailDataOuterClass.MailData;
|
||||
import emu.grasscutter.net.proto.MailItemOuterClass;
|
||||
import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent;
|
||||
|
||||
import java.time.Instant;
|
||||
import emu.grasscutter.net.proto.MaterialDeleteInfoOuterClass;
|
||||
|
||||
public class PacketGetAllMailRsp extends GenshinPacket {
|
||||
|
||||
public PacketGetAllMailRsp(GenshinPlayer player, boolean isGiftMail) {
|
||||
super(PacketOpcodes.GetAllMailRsp);
|
||||
Grasscutter.getLogger().info(String.valueOf(isGiftMail));
|
||||
|
||||
GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder();
|
||||
|
||||
// Dummy data.
|
||||
MailTextContent.Builder mailTextContent = MailTextContent.newBuilder();
|
||||
mailTextContent.setTitle("System Message");
|
||||
mailTextContent.setContent("I'm going to kill you...");
|
||||
mailTextContent.setSender("YOU");
|
||||
mailTextContent.setTitle("Hello Traveller..");
|
||||
mailTextContent.setContent("You've called me emergency food for the last time. \n Get ready to die!");
|
||||
mailTextContent.setSender("P·A·I·M·O·N");
|
||||
|
||||
MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder();
|
||||
ItemParamOuterClass.ItemParam.Builder itemParam = ItemParamOuterClass.ItemParam.newBuilder();
|
||||
|
||||
itemParam.setItemId(1062);
|
||||
itemParam.setCount(1);
|
||||
mailItem.setItemParam(itemParam.build());
|
||||
|
||||
MailData.Builder mailData = MailData.newBuilder();
|
||||
mailData.setMailId(0);
|
||||
mailData.setMailId(100);
|
||||
mailData.setMailTextContent(mailTextContent.build());
|
||||
mailData.setSendTime((int) Instant.now().getEpochSecond());
|
||||
mailData.setExpireTime(999999999);
|
||||
mailData.addItemList(mailItem.build());
|
||||
mailData.setSendTime(1634100481);
|
||||
mailData.setExpireTime(1664498747);
|
||||
mailData.setImportance(1);
|
||||
mailData.setIsRead(false);
|
||||
mailData.setIsAttachmentGot(false);
|
||||
maildata.
|
||||
mailData.setStateValue(1);
|
||||
|
||||
proto.addMailList(mailData.build());
|
||||
proto.setIsTruncated(false);
|
||||
proto.addMailList(mailData.setMailId(101).build());
|
||||
proto.setIsTruncated(true);
|
||||
|
||||
this.setData(proto);
|
||||
Grasscutter.getLogger().info(Grasscutter.getDispatchServer().getGsonFactory().toJson(proto.build()));
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.game.GenshinPlayer;
|
||||
import emu.grasscutter.net.packet.GenshinPacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.GetMailItemRspOuterClass.GetMailItemRsp;
|
||||
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||
import emu.grasscutter.net.proto.MailItemOuterClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PacketGetMailItemRsp extends GenshinPacket {
|
||||
|
||||
public PacketGetMailItemRsp(GenshinPlayer player, List<Integer> mailList) {
|
||||
super(PacketOpcodes.GetMailItemRsp);
|
||||
|
||||
//I'm assuming that this is to receive the attachments on the message.
|
||||
// TODO: This.
|
||||
|
||||
//GetMailItemRsp.Builder proto = GetMailItemRsp.newBuilder();
|
||||
|
||||
//MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder();
|
||||
|
||||
//ItemParamOuterClass.ItemParam.Builder itemParam = ItemParamOuterClass.ItemParam.newBuilder();
|
||||
|
||||
//mailItem.setItemParam(itemParam);
|
||||
|
||||
//proto.addAllMailIdList(mailList);
|
||||
//proto.addItemList();
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
|
||||
import emu.grasscutter.game.GenshinPlayer;
|
||||
import emu.grasscutter.net.packet.GenshinPacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PacketMailChangeNotify extends GenshinPacket {
|
||||
|
||||
public PacketMailChangeNotify(GenshinPlayer player) {
|
||||
super(PacketOpcodes.MailChangeNotify);
|
||||
|
||||
MailChangeNotifyOuterClass.MailChangeNotify.Builder proto = MailChangeNotifyOuterClass.MailChangeNotify.newBuilder();
|
||||
|
||||
// Dummy data.
|
||||
MailTextContentOuterClass.MailTextContent.Builder mailTextContent = MailTextContentOuterClass.MailTextContent.newBuilder();
|
||||
mailTextContent.setTitle("System Message");
|
||||
mailTextContent.setContent("I'm going to kill you...");
|
||||
mailTextContent.setSender("YOU");
|
||||
|
||||
MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder();
|
||||
ItemParamOuterClass.ItemParam.Builder itemParam = ItemParamOuterClass.ItemParam.newBuilder();
|
||||
|
||||
itemParam.setItemId(1062);
|
||||
itemParam.setCount(1);
|
||||
mailItem.setItemParam(itemParam.build());
|
||||
|
||||
MailDataOuterClass.MailData.Builder mailData = MailDataOuterClass.MailData.newBuilder();
|
||||
mailData.setMailId(100);
|
||||
mailData.setMailTextContent(mailTextContent.build());
|
||||
mailData.addItemList(mailItem.build());
|
||||
mailData.setSendTime(1634100481);
|
||||
mailData.setExpireTime(1664498747);
|
||||
mailData.setImportance(1);
|
||||
mailData.setIsRead(false);
|
||||
mailData.setIsAttachmentGot(false);
|
||||
mailData.setStateValue(1);
|
||||
|
||||
proto.addMailList(mailData.build());
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user