Send Mail Command!

Almost done! Wooooo!
This commit is contained in:
Benjamin Elsdon
2022-04-25 21:53:10 +08:00
parent e30352a667
commit c68c75e8ce
6 changed files with 201 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ import java.util.*;
import dev.morphia.annotations.*;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.def.PlayerLevelData;
import emu.grasscutter.database.DatabaseHelper;
@@ -603,10 +604,13 @@ public class GenshinPlayer {
public List<Mail> getAllMail() { return this.mail; }
public void sendMail(Mail message) {
this.mail.add(message);
message._id = this.mail.size() + 1;
this.mail.add(message);
this.save();
this.sendPacket(new PacketMailChangeNotify(this, message));
Grasscutter.getLogger().info("Message sent to user [" + this.getUid() + ":" + this.getNickname() + "]!");
if(this.getSession() != null) {
this.sendPacket(new PacketMailChangeNotify(this, message));
} // TODO: setup a way for the mail notification to show up when someone receives mail when they were offline
}
public boolean deleteMail(int mailId) {

View File

@@ -20,15 +20,7 @@ public class Mail {
public int stateValue;
public Mail() {
_id = 1;
mailContent = new MailContent("No title set...", "No content set...");
itemList = new ArrayList<>();
sendTime = 0;
expireTime = 0;
importance = 0; // Starred mail, 0 = No star, 1 = Star.
isRead = true;
isAttachmentGot = true;
stateValue = 1; // Different mailboxes, 1 = Default, 3 = Gift-box.
this(new MailContent(), new ArrayList<MailItem>(), (int) Instant.now().getEpochSecond() + 604800); // TODO: add expire time to send mail command
}
public Mail(MailContent mailContent, List<MailItem> itemList, long expireTime) {
@@ -49,10 +41,10 @@ public class Mail {
this.itemList = itemList;
this.sendTime = (int) Instant.now().getEpochSecond();
this.expireTime = expireTime;
this.importance = importance;
this.importance = importance; // Starred mail, 0 = No star, 1 = Star.
this.isRead = false;
this.isAttachmentGot = false;
this.stateValue = state;
this.stateValue = state; // Different mailboxes, 1 = Default, 3 = Gift-box.
}
public int getId() {