use Entity instead of LivingEntity
This commit is contained in:
parent
7c640f1bc7
commit
b7a83e1c29
@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.Sheep;
|
import org.bukkit.entity.Sheep;
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
import org.bukkit.FireworkEffect.Builder;
|
import org.bukkit.FireworkEffect.Builder;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -29,7 +29,7 @@ public class DiscoParty {
|
|||||||
private DiscoSheep parent;
|
private DiscoSheep parent;
|
||||||
private Player player;
|
private Player player;
|
||||||
private ArrayList<Sheep> sheepList = new ArrayList<Sheep>();
|
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 defaultDuration = 300; // ticks for entire party
|
||||||
static int defaultPeriod = 10; // ticks per state change
|
static int defaultPeriod = 10; // ticks per state change
|
||||||
static int defaultRadius = 5;
|
static int defaultRadius = 5;
|
||||||
@ -107,7 +107,7 @@ public class DiscoParty {
|
|||||||
return sheepList;
|
return sheepList;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<LivingEntity> getGuestList() {
|
ArrayList<Entity> getGuestList() {
|
||||||
return guestList;
|
return guestList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void spawnGuest(World world, Location loc, EntityType type) {
|
void spawnGuest(World world, Location loc, EntityType type) {
|
||||||
LivingEntity newGuest = (LivingEntity) world.spawnEntity(loc, type);
|
Entity newGuest = world.spawnEntity(loc, type);
|
||||||
getGuestList().add(newGuest);
|
getGuestList().add(newGuest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public class DiscoParty {
|
|||||||
for (Sheep sheeple : getSheepList()) {
|
for (Sheep sheeple : getSheepList()) {
|
||||||
sheeple.remove();
|
sheeple.remove();
|
||||||
}
|
}
|
||||||
for (LivingEntity guest : getGuestList()) {
|
for (Entity guest : getGuestList()) {
|
||||||
guest.remove();
|
guest.remove();
|
||||||
}
|
}
|
||||||
getSheepList().clear();
|
getSheepList().clear();
|
||||||
@ -288,7 +288,7 @@ public class DiscoParty {
|
|||||||
sheep.setColor(discoColours[(r.nextInt(discoColours.length))]);
|
sheep.setColor(discoColours[(r.nextInt(discoColours.length))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jump(LivingEntity entity) {
|
void jump(Entity entity) {
|
||||||
Vector orgVel = entity.getVelocity();
|
Vector orgVel = entity.getVelocity();
|
||||||
Vector newVel = (new Vector()).copy(orgVel);
|
Vector newVel = (new Vector()).copy(orgVel);
|
||||||
newVel.add(new Vector(0, defaultSheepJump, 0));
|
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 (doJump) {
|
||||||
if (state % 2 == 0 && r.nextDouble() < 0.5) {
|
if (state % 2 == 0 && r.nextDouble() < 0.5) {
|
||||||
jump(guest);
|
jump(guest);
|
||||||
|
@ -130,7 +130,7 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ArrayList<DiscoParty> getParties() {
|
public synchronized ArrayList<DiscoParty> getParties() {
|
||||||
return new ArrayList(this.getPartyMap().values());
|
return new ArrayList<DiscoParty>(this.getPartyMap().values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopParty(String name) {
|
public void stopParty(String name) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ca.gibstick.discosheep;
|
package ca.gibstick.discosheep;
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Sheep;
|
import org.bukkit.entity.Sheep;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -47,7 +46,7 @@ public class PartyEvents implements Listener {
|
|||||||
if (e.getEntity() instanceof Sheep) {
|
if (e.getEntity() instanceof Sheep) {
|
||||||
if (party.getSheepList().contains((Sheep) e.getEntity())) {
|
if (party.getSheepList().contains((Sheep) e.getEntity())) {
|
||||||
{
|
{
|
||||||
party.jump((LivingEntity) e.getEntity()); // for kicks
|
party.jump(e.getEntity()); // for kicks
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +55,7 @@ public class PartyEvents implements Listener {
|
|||||||
|
|
||||||
|
|
||||||
if (party.getGuestList().contains(e.getEntity())) {
|
if (party.getGuestList().contains(e.getEntity())) {
|
||||||
party.jump((LivingEntity) e.getEntity());
|
party.jump(e.getEntity());
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +64,7 @@ public class PartyEvents implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityTargetLivingEntityEvent(EntityTargetEvent e) {
|
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);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user