diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/FishingTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/FishingTrait.java index faede51285..11e333c9a9 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/FishingTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/FishingTrait.java @@ -12,6 +12,7 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; +import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; import java.util.ArrayList; @@ -73,7 +74,7 @@ public void run() { reelCount++; castCount++; if(fish != null) { - if (fish.getBukkitEntity().getLocation().distance(npc.getBukkitEntity().getLocation()) < 3) { + if (fish.getBukkitEntity().getLocation().distance(npc.getEntity().getLocation()) < 3) { try { fish.getBukkitEntity().remove(); } catch (Exception e) { @@ -96,8 +97,8 @@ public void run() { @Override public void onSpawn() { - eh = ((CraftPlayer) npc.getBukkitEntity()).getHandle(); - nmsworld = ((CraftWorld) npc.getBukkitEntity().getWorld()).getHandle(); + eh = ((CraftPlayer) npc.getEntity()).getHandle(); + nmsworld = ((CraftWorld) npc.getEntity().getWorld()).getHandle(); } // <--[action] @@ -153,7 +154,7 @@ public void stopFishing() { */ public void startFishing() { fishing = true; - fishingLocation = npc.getBukkitEntity().getLocation(); + fishingLocation = npc.getEntity().getLocation(); } // <--[action] @@ -181,7 +182,7 @@ private void cast() { fishHook = new EntityFishingHook(nmsworld, eh); nmsworld.addEntity(fishHook); - from = npc.getBukkitEntity().getLocation(); + from = npc.getEntity().getLocation(); from = from.add(0,.33,0); to = fishingLocation; @@ -208,10 +209,10 @@ private void cast() { victor = victor.multiply(v / 20.0); Projectile theHook = (Projectile) fishHook.getBukkitEntity(); - theHook.setShooter(npc.getBukkitEntity()); + theHook.setShooter((ProjectileSource) npc.getEntity()); theHook.setVelocity(victor); - PlayerAnimation.ARM_SWING.play((Player) npc.getBukkitEntity()); + PlayerAnimation.ARM_SWING.play((Player) npc.getEntity()); } // <--[action] @@ -238,9 +239,9 @@ private void reel() { fish.getBukkitEntity().remove(); } catch(Exception e) {} fish = new EntityItem(nmsworld, fishHook.locX, fishHook.locY, fishHook.locZ, getFishingResult()); - double d5 = npc.getBukkitEntity().getLocation().getX() - fishHook.locX; - double d6 = npc.getBukkitEntity().getLocation().getY() - fishHook.locY; - double d7 = npc.getBukkitEntity().getLocation().getZ() - fishHook.locZ; + double d5 = npc.getEntity().getLocation().getX() - fishHook.locX; + double d6 = npc.getEntity().getLocation().getY() - fishHook.locY; + double d7 = npc.getEntity().getLocation().getZ() - fishHook.locZ; double d8 = (double) MathHelper.sqrt(d5 * d5 + d6 * d6 + d7 * d7); double d9 = 0.1D; @@ -251,7 +252,7 @@ private void reel() { DenizenAPI.getDenizenNPC(npc).action("catch fish", null); } - PlayerAnimation.ARM_SWING.play((Player) npc.getBukkitEntity()); + PlayerAnimation.ARM_SWING.play((Player) npc.getEntity()); } public ItemStack getFishingResult() { diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/HealthTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/HealthTrait.java index 2125fccf42..e984ad1415 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/HealthTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/HealthTrait.java @@ -156,10 +156,10 @@ public void run() { Bukkit.getScheduler().cancelTask(void_watcher_task); return; } - if (npc.getBukkitEntity().getLocation().getY() < -1000) { + if (npc.getEntity().getLocation().getY() < -1000) { npc.despawn(DespawnReason.DEATH); if (respawn) { - if (npc.isSpawned()) npc.getBukkitEntity().teleport(getRespawnLocation()); + if (npc.isSpawned()) npc.getEntity().teleport(getRespawnLocation()); else npc.spawn(getRespawnLocation()); } } @@ -180,7 +180,7 @@ public HealthTrait() { */ public double getHealth() { if (!npc.isSpawned()) return 0; - else return npc.getBukkitEntity().getHealth(); + else return ((LivingEntity) npc.getEntity()).getHealth(); } /** @@ -190,7 +190,7 @@ public double getHealth() { * */ public void setMaxhealth(int newMax) { - npc.getBukkitEntity().setMaxHealth(newMax); + ((LivingEntity) npc.getEntity()).setMaxHealth(newMax); } /** @@ -199,7 +199,7 @@ public void setMaxhealth(int newMax) { * @return maximum health */ public double getMaxhealth() { - return npc.getBukkitEntity().getMaxHealth(); + return ((LivingEntity) npc.getEntity()).getMaxHealth(); } /** @@ -216,7 +216,7 @@ public void heal(int health) { * */ public void setHealth() { - setHealth(npc.getBukkitEntity().getMaxHealth()); + setHealth(((LivingEntity) npc.getEntity()).getMaxHealth()); } /** @@ -225,12 +225,12 @@ public void setHealth() { * @param health total health points */ public void setHealth(double health) { - if (npc.getBukkitEntity() != null) - npc.getBukkitEntity().setHealth(health); + if (npc.getEntity() != null) + ((LivingEntity) npc.getEntity()).setHealth(health); } public void die() { - npc.getBukkitEntity().damage(npc.getBukkitEntity().getHealth()); + ((LivingEntity) npc.getEntity()).damage(((LivingEntity) npc.getEntity()).getHealth()); } // Listen for deaths to clear drops @@ -262,7 +262,7 @@ public void onDamage(EntityDamageEvent event) { // Don't use NPCDamageEvent because it doesn't work well // Check if the event pertains to this NPC - if (event.getEntity() != npc.getBukkitEntity() || dying) return; + if (event.getEntity() != npc.getEntity() || dying) return; // Make sure this is a killing blow if (this.getHealth() - event.getDamage() > 0) @@ -272,7 +272,7 @@ public void onDamage(EntityDamageEvent event) { player = null; // Save entityId for EntityDeath event - entityId = npc.getBukkitEntity().getEntityId(); + entityId = npc.getEntity().getEntityId(); String deathCause = event.getCause().toString().toLowerCase().replace('_', ' '); Map context = new HashMap(); @@ -331,13 +331,13 @@ else if (event instanceof EntityDamageByBlockEvent) // One of the actions above may have removed the NPC, so check if the // NPC's entity still exists before proceeding - if (npc.getBukkitEntity() == null) + if (npc.getEntity() == null) return; loc = dLocation.valueOf(TagManager.tag(respawnLocation, // TODO: debug option? new BukkitTagContext(null, DenizenAPI.getDenizenNPC(npc), false, null, true, null))); - if (loc == null) loc = npc.getBukkitEntity().getLocation(); + if (loc == null) loc = npc.getEntity().getLocation(); if (animatedeath) { // Cancel navigation to keep the NPC from damaging players @@ -346,7 +346,7 @@ else if (event instanceof EntityDamageByBlockEvent) // Reset health now to avoid the death from happening instantly //setHealth(); // Play animation (TODO) - // playDeathAnimation(npc.getBukkitEntity()); + // playDeathAnimation(npc.getEntity()); } diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/HungerTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/HungerTrait.java index 585d6512fc..426b83485f 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/HungerTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/HungerTrait.java @@ -42,9 +42,9 @@ public void run() { if (count >= 20) { // Reset counter count = 0; - double td = getDistance(npc.getBukkitEntity().getLocation()); + double td = getDistance(npc.getEntity().getLocation()); if (td > 0) { - location = npc.getBukkitEntity().getLocation().clone(); + location = npc.getEntity().getLocation().clone(); currenthunger = currenthunger - (td * 0.01 * multiplier); } } @@ -89,7 +89,7 @@ public void onMove(NavigationBeginEvent event) { } } - location = npc.getBukkitEntity().getLocation(); + location = npc.getEntity().getLocation(); listening = true; } @@ -223,9 +223,9 @@ public boolean isHungry() { // Used internally private double getDistance(Location location) { - if (!npc.getBukkitEntity().getWorld().equals(location.getWorld())) { + if (!npc.getEntity().getWorld().equals(location.getWorld())) { // World change, update location - this.location = npc.getBukkitEntity().getLocation(); + this.location = npc.getEntity().getLocation(); return 0; } return location.distance(this.location); diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/MobproxTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/MobproxTrait.java index a5c0544b98..c7fc5b8000 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/MobproxTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/MobproxTrait.java @@ -128,7 +128,7 @@ public void onTraitAttachEvent(NPCTraitCommandAttachEvent event) { } @Override public void onSpawn() { - liveEnt = getNPC().getBukkitEntity(); + liveEnt = (LivingEntity) getNPC().getEntity(); dnpc = dNPC.mirrorCitizensNPC(getNPC()); frange = DenizenAPI.getCurrentInstance().flagManager().getNPCFlag(dnpc.getId(), "mobprox_range"); if (frange.isEmpty()) { diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/ParticlesTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/ParticlesTrait.java index 2fbc405f86..b5408e3f49 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/ParticlesTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/ParticlesTrait.java @@ -109,19 +109,19 @@ public void run() { @Override public void onSpawn() { - //el = ((CraftLivingEntity)npc.getBukkitEntity()).getHandle(); + //el = ((CraftLivingEntity)npc.getEntity()).getHandle(); //dw = el.getDataWatcher(); - world = npc.getBukkitEntity().getWorld(); + world = npc.getEntity().getWorld(); } public void playFlameEffect() { - Location location = npc.getBukkitEntity().getLocation(); + Location location = npc.getEntity().getLocation(); world.playEffect(location, Effect.MOBSPAWNER_FLAMES, 0); if (dense) world.playEffect(location.add(0, 1, 0), Effect.MOBSPAWNER_FLAMES, 0); } public void playEnderEffect() { - Location location = npc.getBukkitEntity().getLocation(); + Location location = npc.getEntity().getLocation(); world.playEffect(location, Effect.ENDER_SIGNAL, 0); if (dense) world.playEffect(location.add(0, 1, 0), Effect.ENDER_SIGNAL, 0); } @@ -131,13 +131,13 @@ public void playPotionEffect() { // TODO: Implement? } public void playPotionBreakEffect() { - Location location = npc.getBukkitEntity().getLocation(); + Location location = npc.getEntity().getLocation(); world.playEffect(location, Effect.POTION_BREAK, 0); if (dense) world.playEffect(location.add(0, 1, 0), Effect.POTION_BREAK, 0); } public void playHeartEffect() { - Location location = npc.getBukkitEntity().getLocation(); + Location location = npc.getEntity().getLocation(); Wolf tempWolf = world.spawn(location, Wolf.class); ((CraftWolf) tempWolf).getHandle().setInvisible(true); tempWolf.playEffect(EntityEffect.WOLF_HEARTS); @@ -146,7 +146,7 @@ public void playHeartEffect() { } public void playSmokeEffect() { - Location location = npc.getBukkitEntity().getLocation(); + Location location = npc.getEntity().getLocation(); world.playEffect(location, Effect.SMOKE, 0); world.playEffect(location, Effect.SMOKE, 1); world.playEffect(location, Effect.SMOKE, 2); @@ -170,7 +170,7 @@ public void playSmokeEffect() { } public void playExplosionEffect() { - Location location = npc.getBukkitEntity().getLocation(); + Location location = npc.getEntity().getLocation(); world.createExplosion(location, 0); } diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/SittingTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/SittingTrait.java index d4db15cb59..61905e5190 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/SittingTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/SittingTrait.java @@ -11,6 +11,7 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; @@ -30,7 +31,7 @@ public class SittingTrait extends Trait implements Listener { @Override public void run() { if (!npc.isSpawned() || chairLocation == null) return; - if (!Utilities.checkLocation(npc.getBukkitEntity(), chairLocation, 1)) { + if (!Utilities.checkLocation((LivingEntity) npc.getEntity(), chairLocation, 1)) { stand(); } } @@ -63,12 +64,12 @@ public void onDespawn() { public void sit() { DenizenAPI.getDenizenNPC(npc).action("sit", null); - if (npc.getBukkitEntity().getType() != EntityType.PLAYER) { + if (npc.getEntity().getType() != EntityType.PLAYER) { return; } sitInternal(); - chairLocation = npc.getBukkitEntity().getLocation().clone(); + chairLocation = npc.getEntity().getLocation().clone(); } private void sitInternal() { diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/SleepingTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/SleepingTrait.java index bcc469bd66..138259b8d3 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/SleepingTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/SleepingTrait.java @@ -6,6 +6,7 @@ import net.citizensnpcs.util.PlayerAnimation; import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; @@ -22,9 +23,9 @@ public class SleepingTrait extends Trait { public void run() { if (npc == null || bedLocation == null) return; - //if (npc.getBukkitEntity().getPassenger() == null && sitting) eh.mount(eh); + //if (npc.getEntity().getPassenger() == null && sitting) eh.mount(eh); - if (!Utilities.checkLocation(npc.getBukkitEntity(), bedLocation, 1)) wakeUp(); + if (!Utilities.checkLocation((LivingEntity) npc.getEntity(), bedLocation, 1)) wakeUp(); } /** @@ -35,10 +36,10 @@ public void toSleep() { return; } - PlayerAnimation.SLEEP.play((Player) npc.getBukkitEntity()); + PlayerAnimation.SLEEP.play((Player) npc.getEntity()); sleeping = true; - bedLocation = npc.getBukkitEntity().getLocation(); + bedLocation = npc.getEntity().getLocation(); } /** @@ -56,9 +57,9 @@ public void toSleep(Location location) { * playing sleep animation. */ //TODO Adjust the .add() - npc.getBukkitEntity().teleport(location.add(0.5, 0, 0.5)); + npc.getEntity().teleport(location.add(0.5, 0, 0.5)); - PlayerAnimation.SLEEP.play((Player) npc.getBukkitEntity()); + PlayerAnimation.SLEEP.play((Player) npc.getEntity()); sleeping = true; bedLocation = location; @@ -72,7 +73,7 @@ public void wakeUp() { return; } - PlayerAnimation.STOP_SLEEPING.play((Player) npc.getBukkitEntity()); + PlayerAnimation.STOP_SLEEPING.play((Player) npc.getEntity()); bedLocation = null; sleeping = false; diff --git a/src/main/java/net/aufdemrand/denizen/npc/traits/SneakingTrait.java b/src/main/java/net/aufdemrand/denizen/npc/traits/SneakingTrait.java index 8e83e2248b..92e5a63a13 100644 --- a/src/main/java/net/aufdemrand/denizen/npc/traits/SneakingTrait.java +++ b/src/main/java/net/aufdemrand/denizen/npc/traits/SneakingTrait.java @@ -18,7 +18,7 @@ public class SneakingTrait extends Trait implements Listener { @Override public void onSpawn() { - eh = ((CraftPlayer) npc.getBukkitEntity()).getHandle(); + eh = ((CraftPlayer) npc.getEntity()).getHandle(); if (sneaking) sneak(); } @@ -38,7 +38,7 @@ public void onSpawn() { public void sneak() { DenizenAPI.getDenizenNPC(npc).action("sneak", null); - if (npc.getBukkitEntity().getType() != EntityType.PLAYER) { + if (npc.getEntity().getType() != EntityType.PLAYER) { return; }