Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid saving a GuiItem's UUID if it doesn't have an action #1361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public GuiItem(@NotNull ItemStack item, @Nullable Consumer<InventoryClickEvent>
* @since 0.10.8
*/
public GuiItem(@NotNull ItemStack item, @NotNull Plugin plugin) {
this(item, event -> {}, plugin);
this(item, null, plugin);
}

/**
Expand All @@ -109,7 +109,7 @@ public GuiItem(@NotNull ItemStack item, @Nullable Consumer<InventoryClickEvent>
* @param item the item stack
*/
public GuiItem(@NotNull ItemStack item) {
this(item, event -> {});
this(item, (Consumer<InventoryClickEvent>) null);
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Loading