From 3e183bb48ed563fb160ca0266c4faecb237f75f0 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sat, 29 Jan 2022 18:05:54 +0100 Subject: [PATCH] im so dumb --- src/main/java/pl/minecon724/giants/Main.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/pl/minecon724/giants/Main.java b/src/main/java/pl/minecon724/giants/Main.java index cedaa79..15bfb70 100644 --- a/src/main/java/pl/minecon724/giants/Main.java +++ b/src/main/java/pl/minecon724/giants/Main.java @@ -20,10 +20,9 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -118,12 +117,10 @@ public class Main extends JavaPlugin implements Listener { } @EventHandler - public void entityDamage(EntityDamageByEntityEvent e) { - LivingEntity damager = (LivingEntity) e.getDamager(); - if (damager.hasMetadata("giant")) { - damager.setInvulnerable(false); - damager.setHealth(0); - e.setCancelled(true); + public void entityDeath(EntityDeathEvent e) { + Entity entity = e.getEntity(); + if (entity.getType() == EntityType.GIANT) { + for (Entity p : entity.getPassengers()) ((LivingEntity) p).setHealth(0); } }