mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 20:43:11 +00:00
Add notify-player-of-mail-cooldown
config option.
This feature allows for the ability to specify a cooldown for how often individual players are notified of their outstanding unread mails.
This commit is contained in:
parent
3831464665
commit
11a03bbce9
6 changed files with 26 additions and 5 deletions
|
@ -28,6 +28,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
@ -60,6 +61,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||
private String afkMessage;
|
||||
private long afkSince;
|
||||
private Map<User, BigDecimal> confirmingPayments = new WeakHashMap<>();
|
||||
private long lastNotifiedAboutMailsMs;
|
||||
|
||||
public User(final Player base, final IEssentials ess) {
|
||||
super(base, ess);
|
||||
|
@ -855,4 +857,15 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||
return inventory.getItemInMainHand() != null ? inventory.getItemInMainHand() : inventory.getItemInOffHand();
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyOfMail() {
|
||||
List<String> mails = getMails();
|
||||
if (mails != null && !mails.isEmpty()) {
|
||||
int notifyPlayerOfMailCooldown = ess.getSettings().getNotifyPlayerOfMailCooldown() * 1000;
|
||||
if (System.currentTimeMillis() - lastNotifiedAboutMailsMs >= notifyPlayerOfMailCooldown) {
|
||||
sendMessage(tl("youHaveNewMail", mails.size()));
|
||||
lastNotifiedAboutMailsMs = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue