mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2025-02-15 01:31:43 +01:00
add verbose logging for if an item is null
This commit is contained in:
parent
c9c1d7a2c3
commit
9b69fe1859
@ -9,7 +9,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Matcher;
|
||||
@ -80,8 +81,12 @@ public class Methods {
|
||||
return Base64.getEncoder().encodeToString(itemStack.serializeAsBytes());
|
||||
}
|
||||
|
||||
public static @NotNull ItemStack fromBase64(final String base64) {
|
||||
return ItemStack.deserializeBytes(Base64.getDecoder().decode(base64));
|
||||
public static @Nullable ItemStack fromBase64(final String base64) {
|
||||
if (base64 == null || base64.isEmpty()) return null;
|
||||
|
||||
final byte[] decoded = Base64.getDecoder().decode(base64);
|
||||
|
||||
return ItemStack.deserializeBytes(decoded);
|
||||
}
|
||||
|
||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||
|
@ -1109,7 +1109,11 @@ public class ItemBuilder {
|
||||
}
|
||||
|
||||
public static ItemBuilder convertItemStack(String item) {
|
||||
return new ItemBuilder(Methods.fromBase64(item));
|
||||
final ItemStack base64 = Methods.fromBase64(item);
|
||||
|
||||
if (base64 == null) return null;
|
||||
|
||||
return new ItemBuilder(base64);
|
||||
}
|
||||
|
||||
public static ItemBuilder convertItemStack(ItemStack item, Player player) {
|
||||
|
@ -436,6 +436,12 @@ public class AuctionsMenu extends Holder {
|
||||
|
||||
final ItemBuilder itemBuilder = ItemBuilder.convertItemStack(item);
|
||||
|
||||
if (itemBuilder == null) {
|
||||
this.plugin.getLogger().warning("The item with store id " + auction.getString("StoreID", "auctions_menu") + " obtained from your data.yml could not be converted!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.category != null && this.category != Category.NONE && !this.category.getItems().contains(itemBuilder.getMaterial())) return;
|
||||
|
||||
final long price = auction.getLong("Price");
|
||||
|
@ -205,6 +205,12 @@ public class CurrentMenu extends Holder {
|
||||
|
||||
final ItemBuilder itemBuilder = ItemBuilder.convertItemStack(item);
|
||||
|
||||
if (itemBuilder == null) {
|
||||
this.plugin.getLogger().warning("The item with store id " + auction.getString("StoreID", "current_menu") + " obtained from your data.yml could not be converted!");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
final long price = auction.getLong("Price");
|
||||
|
||||
final String priceFormat = String.format(Locale.ENGLISH, "%,d", price);
|
||||
|
@ -274,6 +274,12 @@ public class ExpiredMenu extends Holder {
|
||||
|
||||
final ItemBuilder itemBuilder = ItemBuilder.convertItemStack(item);
|
||||
|
||||
if (itemBuilder == null) {
|
||||
this.plugin.getLogger().warning("The item with store id " + auction.getString("StoreID", "expired_menu") + " obtained from your data.yml could not be converted!");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
final long price = auction.getLong("Price");
|
||||
|
||||
final String priceFormat = String.format(Locale.ENGLISH, "%,d", price);
|
||||
|
@ -105,6 +105,12 @@ public class BuyingMenu extends Holder {
|
||||
|
||||
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(this.data.getString("Items." + this.id + ".Item"));
|
||||
|
||||
if (itemBuilder == null) {
|
||||
this.plugin.getLogger().warning("The item with store id " + this.data.getString("Items." + this.id + ".StoreID", "buying_menu") + " obtained from your data.yml could not be converted!");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
List<String> lore = new ArrayList<>(itemBuilder.getUpdatedLore());
|
||||
|
||||
lore.add(" ");
|
||||
|
Loading…
Reference in New Issue
Block a user