From 710ed9f4ae7eead69fba98a829118f44c0c9ef4d Mon Sep 17 00:00:00 2001 From: uku Date: Tue, 20 Aug 2024 19:00:24 +0200 Subject: [PATCH] Avoid saving a GuiItem's UUID if it doesn't have an action --- .../stefvanschie/inventoryframework/gui/GuiItem.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/gui/GuiItem.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/gui/GuiItem.java index 3c63c120..5759f9d6 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/gui/GuiItem.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/gui/GuiItem.java @@ -90,7 +90,7 @@ public GuiItem(@NotNull ItemStack item, @Nullable Consumer * @since 0.10.8 */ public GuiItem(@NotNull ItemStack item, @NotNull Plugin plugin) { - this(item, event -> {}, plugin); + this(item, null, plugin); } /** @@ -109,7 +109,7 @@ public GuiItem(@NotNull ItemStack item, @Nullable Consumer * @param item the item stack */ public GuiItem(@NotNull ItemStack item) { - this(item, event -> {}); + this(item, (Consumer) null); } /** @@ -153,7 +153,7 @@ public GuiItem copy() { guiItem.properties = new ArrayList<>(properties); ItemMeta meta = guiItem.item.getItemMeta(); - if (meta != null) { + if (meta != null && action != null) { meta.getPersistentDataContainer().set(keyUUID, UUIDTagType.INSTANCE, guiItem.uuid); guiItem.item.setItemMeta(meta); } @@ -185,14 +185,14 @@ public void callAction(@NotNull InventoryClickEvent event) { /** * Sets the internal UUID of this gui item onto the underlying item. Previously set UUID will be overwritten by the - * current UUID. If the underlying item does not have an item meta, this method will silently do nothing. + * current UUID. If the underlying item does not have an item meta or a defined action, this method will silently do nothing. * * @since 0.9.3 */ public void applyUUID() { ItemMeta meta = item.getItemMeta(); - if (meta != null) { + if (meta != null && action != null) { meta.getPersistentDataContainer().set(this.keyUUID, UUIDTagType.INSTANCE, uuid); item.setItemMeta(meta); }