Skip to content

Commit

Permalink
Caches player's top inventory on ChestOpenEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoismysign authored and Redned235 committed Aug 1, 2024
1 parent 061004d commit dbacf5d
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
Expand Down Expand Up @@ -144,11 +145,12 @@ public static boolean loot(Block block, Player player, boolean autoSpill) {
if (flagToBreak) {
plChest.breakChest(player, plChest.getResetTime(phatLoots));
} else {
Inventory inventory = player.getOpenInventory().getTopInventory();
if (inventory.getType() == InventoryType.PLAYER)
return true;
ChestOpenEvent event = new ChestOpenEvent(plChest,
player.getOpenInventory().getTopInventory(),
inventory,
player);
if (event.getInventory().getType() == InventoryType.PLAYER)
return true;
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
player.closeInventory();
Expand Down

0 comments on commit dbacf5d

Please sign in to comment.