use Entity instead of LivingEntity

This commit is contained in:
Gibstick 2013-07-28 14:29:29 -04:00
parent 7c640f1bc7
commit b7a83e1c29
3 changed files with 11 additions and 12 deletions

View File

@ -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<Sheep> sheepList = new ArrayList<Sheep>();
private ArrayList<LivingEntity> guestList = new ArrayList<LivingEntity>();
private ArrayList<Entity> guestList = new ArrayList<Entity>();
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<LivingEntity> getGuestList() {
ArrayList<Entity> 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);

View File

@ -130,7 +130,7 @@ public final class DiscoSheep extends JavaPlugin {
}
public synchronized ArrayList<DiscoParty> getParties() {
return new ArrayList(this.getPartyMap().values());
return new ArrayList<DiscoParty>(this.getPartyMap().values());
}
public void stopParty(String name) {

View File

@ -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);
}