Skip to content

Commit

Permalink
use uuid from context for InputButton and OutputButton
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Mar 2, 2025
1 parent 1e80c6c commit f71e922
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ public class InputButton implements GUIElement, Function<@NotNull InventoryConte
return new ActionItem()
.setItem(displayItemFunction.apply(uuid, getInputItem(uuid)))
.setAction(BukkitClickEvent.class, event -> {
UUID viewerID = event.getViewerID();
InventoryClickEvent bukkitEvent = event.getEvent();
ItemStack cursorItem = Optional.ofNullable(bukkitEvent.getCursor())
.filter(itemStack -> itemStack.getType() != Material.AIR)
.map(ItemStack::clone)
.orElse(null);
ItemStack storeItem = getInputItem(viewerID);
ItemStack storeItem = getInputItem(uuid);
bukkitEvent.getWhoClicked().setItemOnCursor(storeItem);
setInputItem(viewerID, cursorItem);
setInputItem(uuid, cursorItem);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ public class OutputButton implements GUIElement, Function<@NotNull InventoryCont
return new ActionItem()
.setItem(displayItemFunction.apply(uuid, getOutputItem(uuid)))
.setAction(BukkitClickEvent.class, event -> {
UUID viewerID = event.getViewerID();
InventoryClickEvent bukkitEvent = event.getEvent();
ItemStack item = bukkitEvent.getCursor();
if (item != null && item.getType() != Material.AIR) {
return;
}
ItemStack storeItem = getOutputItem(viewerID);
ItemStack storeItem = getOutputItem(uuid);
bukkitEvent.getWhoClicked().setItemOnCursor(storeItem);
setOutputItem(viewerID, null);
setOutputItem(uuid, null);
});
}

Expand Down

0 comments on commit f71e922

Please sign in to comment.