From 0ecea1105392a8314a9545b93056faeaabfab8e5 Mon Sep 17 00:00:00 2001 From: NichtStudioCode <51272202+NichtStudioCode@users.noreply.github.com> Date: Wed, 6 Oct 2021 16:51:50 +0200 Subject: [PATCH] Fixed ArrayIndexOutOfBoundsException when dragging items outside of GUIs --- .../java/de/studiocode/invui/window/impl/BaseWindow.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java b/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java index 7584d21..7b72c9f 100644 --- a/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java +++ b/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java @@ -124,7 +124,11 @@ public abstract class BaseWindow implements Window { } // Redraw all items after the event so there won't be any Items that aren't actually there - Bukkit.getScheduler().runTask(InvUI.getInstance().getPlugin(), () -> event.getRawSlots().forEach(this::redrawItem)); + Bukkit.getScheduler().runTask(InvUI.getInstance().getPlugin(), + () -> event.getRawSlots().forEach(rawSlot -> { + if (getGuiAt(rawSlot) != null) redrawItem(rawSlot); + }) + ); // update the amount on the cursor ItemStack cursorStack = event.getOldCursor();