From 630a8304e5e9314c78c6a3ffc09b4e16ccb45ed9 Mon Sep 17 00:00:00 2001 From: NonSwag Date: Mon, 2 Jan 2023 11:48:37 +0100 Subject: [PATCH] fixed enderchest block not closing --- .../tnl/enderchest/listeners/EnderChestListener.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/nonswag/tnl/enderchest/listeners/EnderChestListener.java b/src/main/java/net/nonswag/tnl/enderchest/listeners/EnderChestListener.java index 5f02c09..b639352 100644 --- a/src/main/java/net/nonswag/tnl/enderchest/listeners/EnderChestListener.java +++ b/src/main/java/net/nonswag/tnl/enderchest/listeners/EnderChestListener.java @@ -7,7 +7,6 @@ import org.bukkit.craftbukkit.v1_19_R2.entity.CraftHumanEntity; import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftInventory; import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.*; @@ -32,8 +31,7 @@ public void onInventoryOpen(InventoryOpenEvent event) { owner = enderchest.getBukkitOwner() instanceof HumanEntity human ? human : event.getPlayer(); } else owner = event.getPlayer(); event.setCancelled(true); - if (!(owner instanceof Player player)) return; - InventoryView view = event.getPlayer().openInventory(EnderChest.get(player)); + InventoryView view = event.getPlayer().openInventory(EnderChest.get(owner)); Reflection.Field.setByType(event, InventoryEvent.class, InventoryView.class, view); CHESTS.add(event.getPlayer().getUniqueId()); } @@ -51,6 +49,6 @@ public void onInventoryClose(InventoryCloseEvent event) { if (EnderChest.canModify(event.getPlayer())) EnderChest.save(owner, event.getInventory()); var human = ((CraftHumanEntity) event.getPlayer()).getHandle(); CHESTS.remove(event.getPlayer().getUniqueId()); - human.inventoryMenu.removed(human); + human.getEnderChestInventory().stopOpen(human); } }