-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathMailBoxItem.java
More file actions
98 lines (86 loc) · 2.36 KB
/
MailBoxItem.java
File metadata and controls
98 lines (86 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
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
58
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package fr.maxlego08.essentials.api.mailbox;
import fr.maxlego08.essentials.api.dto.MailBoxDTO;
import fr.maxlego08.menu.common.utils.nms.ItemStackUtils;
import org.bukkit.inventory.ItemStack;
import java.util.Date;
import java.util.UUID;
/**
* Represents an item in a player's mailbox.
*/
public class MailBoxItem {
private final UUID uuid;
private final ItemStack itemStack;
private final Date expiredAt;
private int id;
/**
* Constructs a new MailBoxItem.
*
* @param uuid the UUID of the player who owns the item
* @param itemStack the item stack stored in the mailbox
* @param expiredAt the expiration date of the item in the mailbox
*/
public MailBoxItem(UUID uuid, ItemStack itemStack, Date expiredAt) {
this.uuid = uuid;
this.itemStack = itemStack;
this.expiredAt = expiredAt;
}
/**
* Constructs a new MailBoxItem from a MailBoxDTO.
*
* @param mailBoxDTO the data transfer object containing mailbox item data
*/
public MailBoxItem(MailBoxDTO mailBoxDTO) {
this.id = mailBoxDTO.id();
this.uuid = mailBoxDTO.unique_id();
this.itemStack = ItemStackUtils.deserializeItemStack(mailBoxDTO.itemstack());
this.expiredAt = mailBoxDTO.expired_at();
}
/**
* Gets the ID of the mailbox item.
*
* @return the ID of the mailbox item
*/
public int getId() {
return id;
}
/**
* Sets the ID of the mailbox item.
*
* @param id the new ID of the mailbox item
*/
public void setId(int id) {
this.id = id;
}
/**
* Gets the UUID of the player who owns the item.
*
* @return the UUID of the player
*/
public UUID getUniqueId() {
return uuid;
}
/**
* Gets the item stack stored in the mailbox.
*
* @return the item stack
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* Gets the expiration date of the item in the mailbox.
*
* @return the expiration date
*/
public Date getExpiredAt() {
return expiredAt;
}
/**
* Checks if the item in the mailbox has expired.
*
* @return true if the item has expired, false otherwise
*/
public boolean isExpired() {
return System.currentTimeMillis() > this.expiredAt.getTime();
}
}