Mail.java 2.84 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
public class Mail {

    public int _id;
    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() {
        _id = 1;
        mailContent = new MailContent("No title set...", "No content set...");
        itemList = new ArrayList<>();
        sendTime = 0;
        expireTime = 0;
        importance = 1;
        isRead = true;
        isAttachmentGot = true;
        stateValue = 1;
    }

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

    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(0, mailContent, itemList, expireTime, importance, state);
    }

    public Mail(int _id, MailContent mailContent, List<MailItem> itemList, long expireTime, int importance, int state) {
        this._id = _id;
        this.mailContent = mailContent;
        this.itemList = itemList;
        this.sendTime = (int) Instant.now().EPOCH.getEpochSecond();
        this.expireTime = expireTime;
        this.importance = importance;
        this.isRead = false;
        this.isAttachmentGot = false;
        this.stateValue = state;
    }

58
    @Entity
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    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");
        }

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

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

85
    @Entity
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    public static class MailItem {
        public int itemId;
        public int itemCount;

        public MailItem() {
            this.itemId = 11101;
            this.itemCount = 1;
        }

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

        public MailItem(int itemId, int itemCount) {
            this.itemId = itemId;
            this.itemCount = itemCount;
        }
    }
}