NichtStudioCode / InvUI

A spigot library for creating custom inventory-based GUIs.
MIT License
242 stars 19 forks source link

Ghost items when hotkey-swapping to off-hand on Spigot #32

Closed HowanDev closed 12 months ago

HowanDev commented 1 year ago

I really love what this framework provides, so i hope youll keep on developing it.

Issue: Inventory click with offhand causes *possible item duplication, to replicate it: Create any GUI, for example like one in wiki:

Gui gui = Gui.normal()
        .setStructure(
                "# # # # # # # # #",
                "# . . . . . . . #",
                "# . . . . . . . #",
                "# # # # # # # # #")
        .addIngredient('#', new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE)))
        .build();

Window window = Window.single()
        .setViewer(player)
        .setTitle("InvUI")
        .setGui(gui)
        .build();

window.open();

open it in-game, and then press offhand switch (by default F key) while cursor is on any item.

Suggested resolution: In InventoryClickEvent: event.getPlayer().getInventory().setItemInOffHand(event.getPlayer().getInventory().getItemInOffHand()); Im not sure that event.getPlayer().updateInventory() works properly in this case