From 089b702910103595c84e1b82262a5824b970fc55 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 18 May 2023 20:34:01 +0200 Subject: [PATCH] Spawn items on player block destruction Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/listener/Permanent.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index bfde552..3b1b606 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -37,6 +37,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.entity.EntityExplodeEvent; @@ -148,6 +149,14 @@ public class Permanent implements Listener { e.setCancelled(true); } + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBlockBreak(BlockBreakEvent e) { + Block block = e.getBlock(); + for(ItemStack stack : block.getDrops(e.getPlayer().getItemInHand())) + Config.world.dropItemNaturally(block.getLocation(), stack); + } + @EventHandler public void onDropPickup(PlayerPickupItemEvent e) { if(!(Config.ArenaRegion.inRegion(e.getItem().getLocation())))