diff --git a/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/ChestLootManager.java b/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/ChestLootManager.java index 9c9a918f..edc532d3 100644 --- a/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/ChestLootManager.java +++ b/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/ChestLootManager.java @@ -190,7 +190,7 @@ public void onPlayerInteract(PlayerInteractEvent e) { return; } - ChestFillEvent event = new ChestFillEvent(e.getClickedBlock(), lootTable, ChestType.ENDERCHEST); + ChestFillEvent event = new ChestFillEvent(e.getClickedBlock(), lootTable, ChestType.ENDERCHEST, clearOldItems); Bukkit.getServer().getPluginManager().callEvent(event); @@ -202,7 +202,7 @@ public void onPlayerInteract(PlayerInteractEvent e) { lootTable = event.getLootTable(); } - if (clearOldItems) { + if (event.isClearOldItems()) { inventory.clear(); } @@ -262,7 +262,7 @@ private void fillChest(Block block, boolean clearOldItems) { Inventory inventory = chest.getBlockInventory(); - ChestFillEvent event = new ChestFillEvent(block, lootTable, ChestType.CHEST); + ChestFillEvent event = new ChestFillEvent(block, lootTable, ChestType.CHEST, clearOldItems); Bukkit.getServer().getPluginManager().callEvent(event); @@ -274,7 +274,7 @@ private void fillChest(Block block, boolean clearOldItems) { lootTable = event.getLootTable(); } - if (clearOldItems) { + if (event.isClearOldItems()) { inventory.clear(); } @@ -301,7 +301,7 @@ private void fillChest(Block block, boolean clearOldItems) { if (nextBlock.getType() == Material.CHEST || nextBlock.getType() == Material.TRAPPED_CHEST) { if (!chests.contains(nextBlock.getLocation())) { Log.trace("Executing recursive fill to chest at location " + nextBlock.getLocation().toString()); - this.fillChest(nextBlock, clearOldItems); + this.fillChest(nextBlock, event.isClearOldItems()); } } } diff --git a/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/events/ChestFillEvent.java b/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/events/ChestFillEvent.java index dbbc6651..a89ed378 100644 --- a/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/events/ChestFillEvent.java +++ b/NovaCore-Spigot/src/main/java/net/zeeraa/novacore/spigot/module/modules/chestloot/events/ChestFillEvent.java @@ -26,14 +26,18 @@ public static HandlerList getHandlerList() { private boolean cancelled; private boolean lootTableChanged; + + private boolean clearOldItems; - public ChestFillEvent(Block block, LootTable lootTable, ChestType chestType) { + public ChestFillEvent(Block block, LootTable lootTable, ChestType chestType, boolean clearOldItems) { this.block = block; this.lootTable = lootTable; this.chestType = chestType; this.cancelled = false; this.lootTableChanged = false; + + this.clearOldItems = clearOldItems; } public Block getBlock() { @@ -60,6 +64,14 @@ public boolean isCancelled() { public boolean hasLootTableChanged() { return lootTableChanged; } + + public boolean isClearOldItems() { + return clearOldItems; + } + + public void setClearOldItems(boolean clearOldItems) { + this.clearOldItems = clearOldItems; + } public void setLootTable(LootTable lootTable) { this.lootTable = lootTable;