mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-05 02:10:24 +01:00
Added the InventoryCloseEvent event
This commit is contained in:
parent
db1e108464
commit
0782ee7fe5
@ -0,0 +1,19 @@
|
||||
package net.minestom.server.event;
|
||||
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
|
||||
public class InventoryCloseEvent extends Event {
|
||||
|
||||
private Inventory inventory;
|
||||
|
||||
public InventoryCloseEvent(Inventory inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the closed inventory, null if this is the player inventory
|
||||
*/
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.InventoryCloseEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
import net.minestom.server.inventory.InventoryClickHandler;
|
||||
import net.minestom.server.inventory.PlayerInventory;
|
||||
@ -88,6 +89,8 @@ public class WindowListener {
|
||||
|
||||
public static void closeWindowListener(ClientCloseWindow packet, Player player) {
|
||||
// if windowId == 0 then it is player's inventory, meaning that they hadn't been any open inventory packet
|
||||
InventoryCloseEvent inventoryCloseEvent = new InventoryCloseEvent(player.getOpenInventory());
|
||||
player.callEvent(InventoryCloseEvent.class, inventoryCloseEvent);
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user