Skip to content

Commit d031a9d

Browse files
authored
fix: ArrayIndexOutOfBoundsException in Bukkit container hasItem (#752)
1 parent d448997 commit d031a9d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

inventory-framework-platform-bukkit/src/main/java/me/devnatan/inventoryframework/BukkitViewContainer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ private void requireSupportedItem(Object item) {
108108

109109
@Override
110110
public boolean hasItem(int slot) {
111-
return inventory.getItem(slot) != null;
111+
try {
112+
return inventory.getItem(slot) != null;
113+
} catch (final ArrayIndexOutOfBoundsException ignored) {
114+
// just supress AIOOBE here, we cannot check if slot matches container constraints
115+
// by `size >= 0 && size <= getLastSlot()` because some containers are not aligned.
116+
// Aligned inventory types = perfect grid (NxN) like chest, workbench..
117+
return false;
118+
}
112119
}
113120

114121
@Override

0 commit comments

Comments
 (0)