Mail.java 2.79 KB
Newer Older
Melledy's avatar
Melledy committed
1
package emu.grasscutter.game.mail;
2

3
import dev.morphia.annotations.Entity;
Melledy's avatar
Melledy committed
4
import emu.grasscutter.game.player.Player;
5

6
7
8
9
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

10
@Entity
11
12
13
14
15
16
17
18
19
20
21
22
public class Mail {

    public MailContent mailContent;
    public List<MailItem> itemList;
    public long sendTime;
    public long expireTime;
    public int importance;
    public boolean isRead;
    public boolean isAttachmentGot;
    public int stateValue;

    public Mail() {
Benjamin Elsdon's avatar
Benjamin Elsdon committed
23
        this(new MailContent(), new ArrayList<MailItem>(), (int) Instant.now().getEpochSecond() + 604800); // TODO: add expire time to send mail command
24
25
26
    }

    public Mail(MailContent mailContent, List<MailItem> itemList, long expireTime) {
27
        this(mailContent, itemList, expireTime, 0);
28
29
30
31
32
33
34
35
36
    }

    public Mail(MailContent mailContent, List<MailItem> itemList, long expireTime, int importance) {
        this(mailContent, itemList, expireTime, importance, 1);
    }

    public Mail(MailContent mailContent, List<MailItem> itemList, long expireTime, int importance, int state) {
        this.mailContent = mailContent;
        this.itemList = itemList;
37
        this.sendTime = (int) Instant.now().getEpochSecond();
38
        this.expireTime = expireTime;
Benjamin Elsdon's avatar
Benjamin Elsdon committed
39
        this.importance = importance; // Starred mail, 0 = No star, 1 = Star.
40
41
        this.isRead = false;
        this.isAttachmentGot = false;
Benjamin Elsdon's avatar
Benjamin Elsdon committed
42
        this.stateValue = state; // Different mailboxes, 1 = Default, 3 = Gift-box.
43
44
    }

45
    @Entity
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    public static class MailContent {
        public String title;
        public String content;
        public String sender;

        public MailContent() {
            this.title = "";
            this.content = "loading...";
            this.sender = "loading";
        }

        public MailContent(String title, String content) {
            this(title, content, "Server");
        }

61
        public MailContent(String title, String content, Player sender) {
62
63
64
65
66
67
68
69
70
71
            this(title, content, sender.getNickname());
        }

        public MailContent(String title, String content, String sender) {
            this.title = title;
            this.content = content;
            this.sender = sender;
        }
    }

72
    @Entity
73
74
75
    public static class MailItem {
        public int itemId;
        public int itemCount;
76
        public int itemLevel;
77
78
79
80

        public MailItem() {
            this.itemId = 11101;
            this.itemCount = 1;
81
            this.itemLevel = 1;
82
83
84
85
86
87
        }

        public MailItem(int itemId) {
            this(itemId, 1);
        }

88
89
90
        public MailItem(int itemId, int itemCount) { this(itemId, itemCount, 1); }

        public MailItem(int itemId, int itemCount, int itemLevel) {
91
92
            this.itemId = itemId;
            this.itemCount = itemCount;
93
            this.itemLevel = itemLevel;
94
95
96
        }
    }
}