Skip to content

Commit

Permalink
fixed enderchest block not closing
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSwag committed Jan 2, 2023
1 parent 7b3496f commit 630a830
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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());
}
Expand All @@ -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);
}
}

0 comments on commit 630a830

Please # to comment.