diff --git a/src/gibstick/bukkit/discosheep/BaaBaaBlockSheepEvents.java b/src/gibstick/bukkit/discosheep/BaaBaaBlockSheepEvents.java index 2b9876a..aa00fa8 100644 --- a/src/gibstick/bukkit/discosheep/BaaBaaBlockSheepEvents.java +++ b/src/gibstick/bukkit/discosheep/BaaBaaBlockSheepEvents.java @@ -7,6 +7,7 @@ package gibstick.bukkit.discosheep; import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerShearEntityEvent; /** @@ -14,13 +15,13 @@ import org.bukkit.event.player.PlayerShearEntityEvent; * @author Mauve */ public class BaaBaaBlockSheepEvents implements Listener { - + DiscoSheep parent; - + public BaaBaaBlockSheepEvents(DiscoSheep parent) { this.parent = parent; } - + @EventHandler public void onPlayerShear(PlayerShearEntityEvent e) { if (e.getEntity() instanceof Sheep) { @@ -31,4 +32,19 @@ public class BaaBaaBlockSheepEvents implements Listener { } } } -} + + // actually make sheep invincible + @EventHandler + public void onEntityDamageEvent(EntityDamageEvent e) { + if (e.getEntity() instanceof Sheep) { + for (DiscoParty party : parent.getParties()) { + if (party.getSheep().contains((Sheep) e.getEntity())) { + { + party.jumpSheep((Sheep) e.getEntity()); + e.setCancelled(true); + } + } + } + } + } +} \ No newline at end of file