commit b031652d5ed107c0f324252729dbe204aeb54d23 parent 7f8be5249322c1ce91f8627545f51ef3ca88e710 Author: luca-luca <reisingerluca@gmail.com> Date: Wed, 24 Feb 2021 20:05:31 +0100 Added item drop to ArmorStand Diffstat:
M | src/de/typable/minecrafthub/event/EventListener.java | | | 20 | ++++++++++++++++++-- |
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/de/typable/minecrafthub/event/EventListener.java b/src/de/typable/minecrafthub/event/EventListener.java @@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; @@ -86,9 +87,23 @@ public class EventListener implements Listener armorstand.setArms(true); event.setCancelled(true); - + item.setAmount(item.getAmount() - 2); } } } -} + + @EventHandler + public void onArmorStandDestroy(EntityDeathEvent event) + { + if(event.getEntity() instanceof ArmorStand) + { + ArmorStand armorstand = (ArmorStand) event.getEntity(); + + if(armorstand.hasArms()) + { + event.getDrops().add(new ItemStack(Material.STICK, 2)); + } + } + } +} +\ No newline at end of file