mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-18 21:32:56 +01:00
Dispatch InventoryCloseEvent after Player#closeInventory (#2415)
* feat: register multiple commands * misc: requested changes * fix: call close inventory before dispatching event
This commit is contained in:
parent
96bf14500a
commit
e8f34c317a
@ -87,11 +87,11 @@ public class WindowListener {
|
|||||||
|
|
||||||
public static void closeWindowListener(ClientCloseWindowPacket packet, Player player) {
|
public static void closeWindowListener(ClientCloseWindowPacket packet, Player player) {
|
||||||
// if windowId == 0 then it is player's inventory, meaning that they hadn't been any open inventory packet
|
// if windowId == 0 then it is player's inventory, meaning that they hadn't been any open inventory packet
|
||||||
|
player.closeInventory(true);
|
||||||
|
|
||||||
InventoryCloseEvent inventoryCloseEvent = new InventoryCloseEvent(player.getOpenInventory(), player);
|
InventoryCloseEvent inventoryCloseEvent = new InventoryCloseEvent(player.getOpenInventory(), player);
|
||||||
EventDispatcher.call(inventoryCloseEvent);
|
EventDispatcher.call(inventoryCloseEvent);
|
||||||
|
|
||||||
player.closeInventory(true);
|
|
||||||
|
|
||||||
Inventory newInventory = inventoryCloseEvent.getNewInventory();
|
Inventory newInventory = inventoryCloseEvent.getNewInventory();
|
||||||
if (newInventory != null)
|
if (newInventory != null)
|
||||||
player.openInventory(newInventory);
|
player.openInventory(newInventory);
|
||||||
|
Loading…
Reference in New Issue
Block a user