Commit 8d427f23 authored by Benjamin Elsdon's avatar Benjamin Elsdon
Browse files

Mail read notify

parent 67b4c274
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.Mail;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetAllMailReqOuterClass;
import emu.grasscutter.net.proto.ReadMailNotifyOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
import java.util.ArrayList;
import java.util.List;
@Opcodes(PacketOpcodes.ReadMailNotify)
public class HandlerReadMailNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
ReadMailNotifyOuterClass.ReadMailNotify req = ReadMailNotifyOuterClass.ReadMailNotify.parseFrom(payload);
List<Mail> updatedMail = new ArrayList<>();
for (int mailId : req.getMailIdListList()) {
Mail message = session.getPlayer().getMailById(mailId);
int messageIndex = session.getPlayer().getMailIndex(message);
message.isRead = true;
session.getPlayer().replaceMailByIndex(messageIndex, message);
updatedMail.add(message);
}
session.send(new PacketMailChangeNotify(session.getPlayer(), updatedMail));
}
}
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