diff --git a/src/main/java/pl/minecon724/giants/Main.java b/src/main/java/pl/minecon724/giants/Main.java index b4b2fbc..1f30fb4 100644 --- a/src/main/java/pl/minecon724/giants/Main.java +++ b/src/main/java/pl/minecon724/giants/Main.java @@ -22,6 +22,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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; @@ -119,7 +120,8 @@ public class Main extends JavaPlugin implements Listener { @EventHandler public void entityDamage(EntityDamageByEntityEvent e) { LivingEntity damager = (LivingEntity) e.getDamager(); - if (damager.getType() == EntityType.HUSK && damager.getCustomName() == "Giant") { + if (damager.hasMetadata("giant")) { + damager.setInvulnerable(false); damager.setHealth(0); e.setCancelled(true); } @@ -137,6 +139,7 @@ public class Main extends JavaPlugin implements Listener { passenger.setCustomNameVisible(false); passenger.setInvulnerable(true); passenger.setPersistent(true); + passenger.setMetadata("giant", new FixedMetadataValue(this, "y")); entity.addPassenger(passenger); } for (Entry t : effects.entrySet()) {