add more null checks

This commit is contained in:
Ryder Belserion 2024-10-31 11:41:46 -04:00
parent d7e3f775d6
commit a6d2169103
No known key found for this signature in database
3 changed files with 26 additions and 2 deletions

View File

@ -164,7 +164,11 @@ public class CurrentMenu extends Holder {
}
public void calculateItems() {
this.items = this.userManager.getAuctions().get(this.player.getUniqueId());
final UUID uuid = this.player.getUniqueId();
if (this.userManager.hasAuction(uuid)) {
this.items = this.userManager.getAuctions(uuid);
}
this.maxPages = getMaxPage(this.items);
}

View File

@ -51,7 +51,11 @@ public class ExpiredMenu extends Holder {
"WhatIsThis.Cancelled/ExpiredItems"
));
this.items = this.userManager.getExpiredItems().get(this.player.getUniqueId());
final UUID uuid = this.player.getUniqueId();
if (this.userManager.hasExpiredItem(uuid)) {
this.items = this.userManager.getExpiredItems(uuid);
}
this.maxPages = getExpiredMaxPages(this.items == null ? new ArrayList<>() : this.items);

View File

@ -152,6 +152,14 @@ public class UserManager {
return this.auctions;
}
public final boolean hasAuction(final UUID uuid) {
return this.auctions.containsKey(uuid);
}
public final List<AuctionItem> getAuctions(final UUID uuid) {
return this.auctions.get(uuid);
}
public final void updateExpiredCache() {
this.expired_items.clear();
@ -304,6 +312,14 @@ public class UserManager {
return this.expired_items;
}
public final boolean hasExpiredItem(final UUID uuid) {
return this.expired_items.containsKey(uuid);
}
public final List<ExpiredItem> getExpiredItems(final UUID uuid) {
return this.expired_items.get(uuid);
}
public void addActiveAuction(final String uuid, final ConfigurationSection section) {
final AuctionItem new_auction = new AuctionItem(uuid, section.getString("name"),
section.getName(),