Skip to content

Commit

Permalink
Fix expired mails showing as unread on join (EssentialsX#6063)
Browse files Browse the repository at this point in the history
  • Loading branch information
JRoy authored Feb 23, 2025
1 parent bad79b7 commit 5458241
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Essentials/src/main/java/com/earth2me/essentials/UserData.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,17 @@ public void setMails(List<String> mails) {
}

public int getMailAmount() {
return holder.mail() == null ? 0 : holder.mail().size();
if (holder.mail() == null) {
return 0;
}

int amount = 0;
for (MailMessage element : holder.mail()) {
if (!element.isExpired()) {
amount++;
}
}
return amount;
}

public int getUnreadMailAmount() {
Expand All @@ -358,7 +368,7 @@ public int getUnreadMailAmount() {

int unread = 0;
for (MailMessage element : holder.mail()) {
if (!element.isRead()) {
if (!element.isRead() && !element.isExpired()) {
unread++;
}
}
Expand Down

0 comments on commit 5458241

Please sign in to comment.