From 6166c56f9ceb05c802959d7099052c3eea486201 Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Fri, 12 Jul 2013 09:14:36 -0400 Subject: [PATCH] blocked all sheep damage --- .../discosheep/BaaBaaBlockSheepEvents.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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