From dd42d3b02793e30c5306f95a24388f5e22d97875 Mon Sep 17 00:00:00 2001 From: Benjamin Elsdon Date: Fri, 22 Apr 2022 15:52:31 +0800 Subject: [PATCH] Initial work on mail --- .../packet/recv/HandlerGetAllMailReq.java | 23 +++++++++++ .../packet/send/PacketGetAllMailRsp.java | 39 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/main/java/emu/grasscutter/server/packet/recv/HandlerGetAllMailReq.java create mode 100644 src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetAllMailReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetAllMailReq.java new file mode 100644 index 000000000..9a1d1294e --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetAllMailReq.java @@ -0,0 +1,23 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.proto.GetAllMailReqOuterClass; +import emu.grasscutter.net.proto.GetPlayerTokenReqOuterClass; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketGetAllMailRsp; +import emu.grasscutter.server.packet.send.PacketGetGachaInfoRsp; + +@Opcodes(PacketOpcodes.GetAllMailReq) +public class HandlerGetAllMailReq extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + Grasscutter.getLogger().info("Mail Req"); + GetAllMailReqOuterClass.GetAllMailReq req = GetAllMailReqOuterClass.GetAllMailReq.parseFrom(payload); + session.send(new PacketGetAllMailRsp(session.getPlayer(), req.getIsGiftMail())); + } + +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java new file mode 100644 index 000000000..d2362862c --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailRsp.java @@ -0,0 +1,39 @@ +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.GetAllMailRspOuterClass.GetAllMailRsp; +import emu.grasscutter.net.proto.MailDataOuterClass.MailData; +import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent; + +import java.time.Instant; + +public class PacketGetAllMailRsp extends GenshinPacket { + + public PacketGetAllMailRsp(GenshinPlayer player, boolean isGiftMail) { + super(PacketOpcodes.GetAllMailRsp); + + GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder(); + + MailTextContent.Builder mailTextContent = MailTextContent.newBuilder(); + mailTextContent.setTitle("System Message"); + mailTextContent.setContent("I'm going to kill you..."); + mailTextContent.setSender("YOU"); + + MailData.Builder mailData = MailData.newBuilder(); + mailData.setMailId(0); + mailData.setMailTextContent(mailTextContent.build()); + mailData.setSendTime((int) Instant.now().getEpochSecond()); + mailData.setExpireTime(999999999); + mailData.setImportance(1); + mailData.setIsRead(false); + mailData.setIsAttachmentGot(false); + maildata. + + proto.addMailList(mailData.build()); + proto.setIsTruncated(false); + + this.setData(proto); + } +}