Skip to content

Commit ad90aaa

Browse files
Adjust slot action handling
If it exists, handle slot actions, if it doesn't why bother?
1 parent 736e152 commit ad90aaa

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

core/src/main/java/me/flame/menus/menu/MenuListeners.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ public void onInventoryClick(@NotNull InventoryClickEvent event) {
8686
return;
8787
}
8888

89-
ItemResponse response = menu.slotActions[slot];
90-
if (response != null) response.apply(slot, clicked);
89+
if (menu.hasSlotActions()) {
90+
ItemResponse response = menu.slotActions[slot];
91+
if (response != null) response.apply(slot, clicked);
92+
}
9193

9294
if (modifierDetected(menu, action, clickedInventory.getType(), inventory.getType()))
9395
clicked.setResult(Event.Result.DENY);
@@ -171,18 +173,15 @@ private static boolean isDropItemEvent(InventoryAction action, InventoryType typ
171173
}
172174

173175
private static boolean isOtherEvent(InventoryAction action, InventoryType type) {
174-
return isOtherAction(action) && (type != PLAYER);
176+
return (action == InventoryAction.CLONE_STACK || action == InventoryAction.UNKNOWN) &&
177+
(type != PLAYER);
175178
}
176179

177180
private static boolean isDraggingOnGui(int size, @NotNull Iterable<Integer> rawSlots) {
178181
for (int slot : rawSlots) if (slot < size) return true;
179182
return false;
180183
}
181184

182-
private static boolean isOtherAction(final InventoryAction action) {
183-
return action == InventoryAction.CLONE_STACK || action == InventoryAction.UNKNOWN;
184-
}
185-
186185
private static void executeActions(ClickActionEvent event,
187186
InventoryView view,
188187
Menu menu,

0 commit comments

Comments
 (0)