Mail.java 2.75 KB
Newer Older
1
2
package emu.grasscutter.game;

3
4
import dev.morphia.annotations.Entity;

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

9
@Entity
10
11
12
13
14
15
16
17
18
19
20
21
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
22
        this(new MailContent(), new ArrayList<MailItem>(), (int) Instant.now().getEpochSecond() + 604800); // TODO: add expire time to send mail command
23
24
25
    }

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

    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;
36
        this.sendTime = (int) Instant.now().getEpochSecond();
37
        this.expireTime = expireTime;
Benjamin Elsdon's avatar
Benjamin Elsdon committed
38
        this.importance = importance; // Starred mail, 0 = No star, 1 = Star.
39
40
        this.isRead = false;
        this.isAttachmentGot = false;
Benjamin Elsdon's avatar
Benjamin Elsdon committed
41
        this.stateValue = state; // Different mailboxes, 1 = Default, 3 = Gift-box.
42
43
    }

44
    @Entity
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    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");
        }

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

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

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

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

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

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

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