Mail.java 3.04 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
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() {
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
37
38
39
40
41
    }

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

Benjamin Elsdon's avatar
Benjamin Elsdon committed
50
51
52
53
    public int getId() {
        return this._id;
    }

54
    @Entity
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
    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;
        }
    }

81
    @Entity
82
83
84
    public static class MailItem {
        public int itemId;
        public int itemCount;
85
        public int itemLevel;
86
87
88
89

        public MailItem() {
            this.itemId = 11101;
            this.itemCount = 1;
90
            this.itemLevel = 1;
91
92
93
94
95
96
        }

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

97
98
99
        public MailItem(int itemId, int itemCount) { this(itemId, itemCount, 1); }

        public MailItem(int itemId, int itemCount, int itemLevel) {
100
101
            this.itemId = itemId;
            this.itemCount = itemCount;
102
            this.itemLevel = itemLevel;
103
104
105
        }
    }
}