From 78b44b32208e3ad563ce7623fd0a635e6a544ae0 Mon Sep 17 00:00:00 2001 From: NichtStudioCode <51272202+NichtStudioCode@users.noreply.github.com> Date: Mon, 4 Oct 2021 16:10:27 +0200 Subject: [PATCH] Redraw all affected slots after the InventoryDragEvent --- .../java/de/studiocode/invui/window/impl/BaseWindow.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 e7c63f2..7584d21 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 @@ -112,7 +112,7 @@ public abstract class BaseWindow implements Window { ItemStack currentStack = event.getView().getItem(rawSlot); if (currentStack != null && currentStack.getType() == Material.AIR) currentStack = null; - // get the GUI at that index and ask for permission to drag an Item there + // get the GUI at that slot and ask for permission to drag an Item there Pair pair = getGuiAt(rawSlot); if (pair != null && !pair.getFirst().handleItemDrag(updateReason, pair.getSecond(), currentStack, newItems.get(rawSlot))) { // the drag was cancelled @@ -120,12 +120,12 @@ public abstract class BaseWindow implements Window { int newAmount = newItems.get(rawSlot).getAmount(); itemsLeft += newAmount - currentAmount; - - // Redraw cancelled items after the event so there won't be any Items that aren't actually there - Bukkit.getScheduler().runTask(InvUI.getInstance().getPlugin(), () -> redrawItem(rawSlot)); } } + // 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)); + // update the amount on the cursor ItemStack cursorStack = event.getOldCursor(); cursorStack.setAmount(itemsLeft);