From 77a426a85bd3517a0b7e17af88e053d89de67d0d Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Wed, 8 Jul 2020 14:34:38 -0500 Subject: [PATCH] Drop an ES System when the block gets broken. --- .../energeticstorage/listeners/BlockBreakListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java b/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java index 60315cd..914c68a 100644 --- a/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java +++ b/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java @@ -5,6 +5,7 @@ import net.seanomik.energeticstorage.Skulls; import net.seanomik.energeticstorage.files.PlayersFile; import net.seanomik.energeticstorage.objects.ESDrive; import net.seanomik.energeticstorage.objects.ESSystem; +import net.seanomik.energeticstorage.utils.ItemConstructor; import net.seanomik.energeticstorage.utils.PermissionChecks; import net.seanomik.energeticstorage.utils.Reference; import net.seanomik.energeticstorage.utils.Utils; @@ -34,7 +35,7 @@ public class BlockBreakListener implements Listener { if (esSystem != null) { if (esSystem.isPlayerTrusted(player) || esSystem.getOwner().equals(player.getUniqueId()) || PermissionChecks.canDestroyUntrustedSystems(player)) { for (ESDrive drive : esSystem.getESDrives()) { - block.getLocation().getWorld().dropItem(block.getLocation(), drive.getDriveItem()); + block.getLocation().getWorld().dropItemNaturally(block.getLocation(), drive.getDriveItem()); } // Remove the system from cache and storage @@ -43,6 +44,10 @@ public class BlockBreakListener implements Listener { List systems = new LinkedList<>(Reference.ES_SYSTEMS.get(player.getUniqueId())); systems.removeIf(esSystem::equals); Reference.ES_SYSTEMS.replace(player.getUniqueId(), systems); + + // Drop an ES System + event.setDropItems(false); + event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), ItemConstructor.createSystemBlock()); } else { event.setCancelled(true); player.sendMessage(Reference.PREFIX + ChatColor.RED + "You are not trusted to this system!");