mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-03 21:52:05 -07:00
InventoryCloseEvent Reason API
Allows you to determine why an inventory was closed, enabling plugin developers to "confirm" things based on if it was player triggered close or not.
This commit is contained in:
@@ -617,7 +617,7 @@
|
||||
+ for (net.minecraft.world.level.block.entity.BlockEntity tileentity : chunk.getBlockEntities().values()) {
|
||||
+ if (tileentity instanceof net.minecraft.world.Container) {
|
||||
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) {
|
||||
+ h.closeInventory();
|
||||
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -976,7 +976,7 @@
|
||||
+ // Spigot Start
|
||||
+ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
|
||||
+ h.closeInventory();
|
||||
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
Reference in New Issue
Block a user