add null checks

This commit is contained in:
Ryder Belserion 2024-10-12 19:58:48 -04:00
parent 50ddae0157
commit 514afb3f0d
No known key found for this signature in database

View File

@ -177,9 +177,15 @@ public class ExpiredMenu extends Holder {
break;
} else {
player.getInventory().addItem(Methods.fromBase64(data.getString("OutOfTime/Cancelled." + i + ".Item")));
final ItemStack yoink = Methods.fromBase64(data.getString("OutOfTime/Cancelled." + i + ".Item", ""));
if (yoink != null) {
player.getInventory().addItem(yoink);
data.set("OutOfTime/Cancelled." + i, null);
} else {
this.plugin.getLogger().warning("The player " + player.getName() + " tried to redeem an invalid item in the expired menu.");
}
}
}
}
@ -225,7 +231,10 @@ public class ExpiredMenu extends Holder {
player.sendMessage(Messages.GOT_ITEM_BACK.getMessage(player));
player.getInventory().addItem(Methods.fromBase64(auction.getString("Item")));
final ItemStack yoink = Methods.fromBase64(auction.getString("Item"));
if (yoink != null) {
player.getInventory().addItem(yoink);
data.set("OutOfTime/Cancelled." + key, null);
@ -234,6 +243,9 @@ public class ExpiredMenu extends Holder {
menu.click(player);
GuiManager.openPlayersExpiredList(player, 1);
} else {
this.plugin.getLogger().warning("The player " + player.getName() + " tried to redeem an invalid item in the expired menu.");
}
return;
}