From b7a83e1c29298f375383cffddf071c3c724d8404 Mon Sep 17 00:00:00 2001 From: Gibstick Date: Sun, 28 Jul 2013 14:29:29 -0400 Subject: [PATCH] use Entity instead of LivingEntity --- src/ca/gibstick/discosheep/DiscoParty.java | 14 +++++++------- src/ca/gibstick/discosheep/DiscoSheep.java | 2 +- src/ca/gibstick/discosheep/PartyEvents.java | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/ca/gibstick/discosheep/DiscoParty.java b/src/ca/gibstick/discosheep/DiscoParty.java index 6566cd2..b1b5427 100644 --- a/src/ca/gibstick/discosheep/DiscoParty.java +++ b/src/ca/gibstick/discosheep/DiscoParty.java @@ -15,7 +15,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Builder; -import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.util.Vector; @@ -29,7 +29,7 @@ public class DiscoParty { private DiscoSheep parent; private Player player; private ArrayList sheepList = new ArrayList(); - private ArrayList guestList = new ArrayList(); + private ArrayList guestList = new ArrayList(); static int defaultDuration = 300; // ticks for entire party static int defaultPeriod = 10; // ticks per state change static int defaultRadius = 5; @@ -107,7 +107,7 @@ public class DiscoParty { return sheepList; } - ArrayList getGuestList() { + ArrayList getGuestList() { return guestList; } @@ -267,7 +267,7 @@ public class DiscoParty { } void spawnGuest(World world, Location loc, EntityType type) { - LivingEntity newGuest = (LivingEntity) world.spawnEntity(loc, type); + Entity newGuest = world.spawnEntity(loc, type); getGuestList().add(newGuest); } @@ -276,7 +276,7 @@ public class DiscoParty { for (Sheep sheeple : getSheepList()) { sheeple.remove(); } - for (LivingEntity guest : getGuestList()) { + for (Entity guest : getGuestList()) { guest.remove(); } getSheepList().clear(); @@ -288,7 +288,7 @@ public class DiscoParty { sheep.setColor(discoColours[(r.nextInt(discoColours.length))]); } - void jump(LivingEntity entity) { + void jump(Entity entity) { Vector orgVel = entity.getVelocity(); Vector newVel = (new Vector()).copy(orgVel); newVel.add(new Vector(0, defaultSheepJump, 0)); @@ -370,7 +370,7 @@ public class DiscoParty { } } - for (LivingEntity guest : getGuestList()) { + for (Entity guest : getGuestList()) { if (doJump) { if (state % 2 == 0 && r.nextDouble() < 0.5) { jump(guest); diff --git a/src/ca/gibstick/discosheep/DiscoSheep.java b/src/ca/gibstick/discosheep/DiscoSheep.java index c16263d..babee07 100644 --- a/src/ca/gibstick/discosheep/DiscoSheep.java +++ b/src/ca/gibstick/discosheep/DiscoSheep.java @@ -130,7 +130,7 @@ public final class DiscoSheep extends JavaPlugin { } public synchronized ArrayList getParties() { - return new ArrayList(this.getPartyMap().values()); + return new ArrayList(this.getPartyMap().values()); } public void stopParty(String name) { diff --git a/src/ca/gibstick/discosheep/PartyEvents.java b/src/ca/gibstick/discosheep/PartyEvents.java index cc1ef9d..9893e18 100644 --- a/src/ca/gibstick/discosheep/PartyEvents.java +++ b/src/ca/gibstick/discosheep/PartyEvents.java @@ -1,6 +1,5 @@ package ca.gibstick.discosheep; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -47,7 +46,7 @@ public class PartyEvents implements Listener { if (e.getEntity() instanceof Sheep) { if (party.getSheepList().contains((Sheep) e.getEntity())) { { - party.jump((LivingEntity) e.getEntity()); // for kicks + party.jump(e.getEntity()); // for kicks e.setCancelled(true); } } @@ -56,7 +55,7 @@ public class PartyEvents implements Listener { if (party.getGuestList().contains(e.getEntity())) { - party.jump((LivingEntity) e.getEntity()); + party.jump(e.getEntity()); e.setCancelled(true); } } @@ -65,7 +64,7 @@ public class PartyEvents implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityTargetLivingEntityEvent(EntityTargetEvent e) { - if (party.getGuestList().contains(e.getEntity())) { // safe; event is only triggered by LivingEntity targetting LivingEntity + if (party.getGuestList().contains(e.getEntity())) { e.setCancelled(true); }