From 2759809ecba4e5f2d8c8ae51f5781a0c1a96b0c1 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 29 Nov 2011 21:22:35 +1100 Subject: [PATCH] Fix Craft Entity constructors and toStrings. Also, standardise getHandle and clean up in general. getHandle is now using the 'entity' member variable instead of super.getHandle, as this reduces the number of chained calls needed. --- .../net/minecraft/server/EntityMinecart.java | 35 ++++++-- .../net/minecraft/server/EntityPotion.java | 87 +++++++++++++++++++ .../craftbukkit/entity/CraftAnimals.java | 20 ++--- .../bukkit/craftbukkit/entity/CraftArrow.java | 24 +++-- .../bukkit/craftbukkit/entity/CraftBlaze.java | 13 ++- .../bukkit/craftbukkit/entity/CraftBoat.java | 23 ++--- .../craftbukkit/entity/CraftCaveSpider.java | 2 +- .../craftbukkit/entity/CraftChicken.java | 5 ++ .../entity/CraftComplexLivingEntity.java | 9 +- .../craftbukkit/entity/CraftComplexPart.java | 11 ++- .../bukkit/craftbukkit/entity/CraftCow.java | 5 ++ .../craftbukkit/entity/CraftCreeper.java | 19 ++-- .../bukkit/craftbukkit/entity/CraftEgg.java | 5 ++ .../craftbukkit/entity/CraftEnderCrystal.java | 11 ++- .../craftbukkit/entity/CraftEnderDragon.java | 15 ++-- .../entity/CraftEnderDragonPart.java | 16 +++- .../craftbukkit/entity/CraftEnderPearl.java | 9 +- .../craftbukkit/entity/CraftEnderSignal.java | 9 +- .../craftbukkit/entity/CraftEnderman.java | 20 ++--- .../craftbukkit/entity/CraftEntity.java | 71 +++++++-------- .../entity/CraftExperienceOrb.java | 15 ++-- .../craftbukkit/entity/CraftFallingSand.java | 5 ++ .../craftbukkit/entity/CraftFireball.java | 34 ++++---- .../bukkit/craftbukkit/entity/CraftFish.java | 21 +++-- .../craftbukkit/entity/CraftFlying.java | 6 +- .../bukkit/craftbukkit/entity/CraftGhast.java | 6 +- .../bukkit/craftbukkit/entity/CraftGiant.java | 6 +- .../craftbukkit/entity/CraftHumanEntity.java | 31 ++++--- .../bukkit/craftbukkit/entity/CraftItem.java | 5 ++ .../entity/CraftLightningStrike.java | 15 ++-- .../craftbukkit/entity/CraftLivingEntity.java | 29 +++---- .../craftbukkit/entity/CraftMagmaCube.java | 8 +- .../craftbukkit/entity/CraftMinecart.java | 33 ++++--- .../craftbukkit/entity/CraftMonster.java | 10 +-- .../craftbukkit/entity/CraftMushroomCow.java | 14 ++- .../craftbukkit/entity/CraftPainting.java | 20 ++--- .../bukkit/craftbukkit/entity/CraftPig.java | 2 +- .../craftbukkit/entity/CraftPigZombie.java | 19 ++-- .../craftbukkit/entity/CraftPlayer.java | 47 +++++----- .../entity/CraftPoweredMinecart.java | 1 - .../craftbukkit/entity/CraftProjectile.java | 7 +- .../bukkit/craftbukkit/entity/CraftSheep.java | 20 ++--- .../craftbukkit/entity/CraftSilverfish.java | 2 +- .../craftbukkit/entity/CraftSkeleton.java | 6 +- .../bukkit/craftbukkit/entity/CraftSlime.java | 19 ++-- .../entity/CraftSmallFireball.java | 15 +++- .../craftbukkit/entity/CraftSnowball.java | 5 ++ .../craftbukkit/entity/CraftSnowman.java | 14 ++- .../craftbukkit/entity/CraftSpider.java | 6 +- .../bukkit/craftbukkit/entity/CraftSquid.java | 6 +- .../craftbukkit/entity/CraftTNTPrimed.java | 20 ++--- .../craftbukkit/entity/CraftThrownPotion.java | 9 +- .../craftbukkit/entity/CraftVillager.java | 8 +- .../craftbukkit/entity/CraftWaterMob.java | 6 +- .../craftbukkit/entity/CraftWeather.java | 7 +- .../bukkit/craftbukkit/entity/CraftWolf.java | 2 +- .../craftbukkit/entity/CraftZombie.java | 5 ++ 57 files changed, 588 insertions(+), 305 deletions(-) create mode 100644 src/main/java/net/minecraft/server/EntityPotion.java diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index 74aafbebb5..ff9e9c69e2 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -12,6 +12,7 @@ import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.vehicle.VehicleUpdateEvent; +import org.bukkit.util.Vector; // CraftBukkit end public class EntityMinecart extends Entity implements IInventory { @@ -32,12 +33,12 @@ public class EntityMinecart extends Entity implements IInventory { // CraftBukkit start public boolean slowWhenEmpty = true; - public double derailedX = 0.5; - public double derailedY = 0.5; - public double derailedZ = 0.5; - public double flyingX = 0.95; - public double flyingY = 0.95; - public double flyingZ = 0.95; + private double derailedX = 0.5; + private double derailedY = 0.5; + private double derailedZ = 0.5; + private double flyingX = 0.95; + private double flyingY = 0.95; + private double flyingZ = 0.95; public double maxSpeed = 0.4D; public ItemStack[] getContents() { @@ -934,4 +935,26 @@ public class EntityMinecart extends Entity implements IInventory { public int m() { return this.datawatcher.getInt(18); } + + // CraftBukkit start - methods for getting and setting flying and derailed velocity modifiers + public Vector getFlyingVelocityMod() { + return new Vector(flyingX, flyingY, flyingZ); + } + + public void setFlyingVelocityMod(Vector flying) { + flyingX = flying.getX(); + flyingY = flying.getY(); + flyingZ = flying.getZ(); + } + + public Vector getDerailedVelocityMod() { + return new Vector(derailedX, derailedY, derailedZ); + } + + public void setDerailedVelocityMod(Vector derailed) { + derailedX = derailed.getX(); + derailedY = derailed.getY(); + derailedZ = derailed.getZ(); + } + // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/EntityPotion.java b/src/main/java/net/minecraft/server/EntityPotion.java new file mode 100644 index 0000000000..41247f5125 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityPotion.java @@ -0,0 +1,87 @@ +package net.minecraft.server; + +import java.util.Iterator; +import java.util.List; + +public class EntityPotion extends EntityProjectile { + + private int d; + + public EntityPotion(World world) { + super(world); + } + + public EntityPotion(World world, EntityLiving entityliving, int i) { + super(world, entityliving); + this.d = i; + } + + public EntityPotion(World world, double d0, double d1, double d2, int i) { + super(world, d0, d1, d2); + this.d = i; + } + + protected float e() { + return 0.05F; + } + + protected float c() { + return 0.5F; + } + + protected float d() { + return -20.0F; + } + + public int f() { + return this.d; + } + + protected void a(MovingObjectPosition movingobjectposition) { + if (!this.world.isStatic) { + List list = Item.POTION.b(this.d); + + if (list != null && !list.isEmpty()) { + AxisAlignedBB axisalignedbb = this.boundingBox.b(4.0D, 2.0D, 4.0D); + List list1 = this.world.a(EntityLiving.class, axisalignedbb); + + if (list1 != null && !list1.isEmpty()) { + Iterator iterator = list1.iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + double d0 = this.i(entity); + + if (d0 < 16.0D) { + double d1 = 1.0D - Math.sqrt(d0) / 4.0D; + + if (entity == movingobjectposition.entity) { + d1 = 1.0D; + } + + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator1.next(); + int i = mobeffect.getEffectId(); + + if (MobEffectList.byId[i].b()) { + MobEffectList.byId[i].a(this.shooter, (EntityLiving) entity, mobeffect.getAmplifier(), d1); + } else { + int j = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); + + if (j > 20) { + ((EntityLiving) entity).addEffect(new MobEffect(i, j, mobeffect.getAmplifier())); + } + } + } + } + } + } + } + + this.world.f(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), this.d); + this.die(); + } + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java index e4b51ec870..5211bbb017 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -10,16 +10,6 @@ public class CraftAnimals extends CraftCreature implements Animals { super(server, entity); } - @Override - public String toString() { - return "CraftAnimals"; - } - - @Override - public EntityAnimal getHandle() { - return (EntityAnimal) entity; - } - public int getAge() { return getHandle().getAge(); } @@ -27,4 +17,14 @@ public class CraftAnimals extends CraftCreature implements Animals { public void setAge(int age) { getHandle().setAge(age); } + + @Override + public EntityAnimal getHandle() { + return (EntityAnimal) entity; + } + + @Override + public String toString() { + return "CraftAnimals"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index b23cdc4a49..275e849e75 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -7,29 +7,35 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; +import javax.swing.text.html.parser.Entity; + public class CraftArrow extends AbstractProjectile implements Arrow { public CraftArrow(CraftServer server, EntityArrow entity) { super(server, entity); } - @Override - public String toString() { - return "CraftArrow"; - } - public LivingEntity getShooter() { - if (((EntityArrow) getHandle()).shooter != null) { - return (LivingEntity) ((EntityArrow) getHandle()).shooter.getBukkitEntity(); + if (getHandle().shooter != null) { + return (LivingEntity) getHandle().shooter.getBukkitEntity(); } return null; - } public void setShooter(LivingEntity shooter) { if (shooter instanceof CraftLivingEntity) { - ((EntityArrow) getHandle()).shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; + getHandle().shooter = ((CraftLivingEntity) shooter).getHandle(); } } + + @Override + public EntityArrow getHandle(){ + return (EntityArrow) entity; + } + + @Override + public String toString() { + return "CraftArrow"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java index 94e03c5bcf..94c9901640 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java @@ -1,11 +1,22 @@ package org.bukkit.craftbukkit.entity; +import net.minecraft.server.EntityBlaze; import net.minecraft.server.EntityMonster; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Blaze; public class CraftBlaze extends CraftMonster implements Blaze { - public CraftBlaze(CraftServer server, EntityMonster entity) { + public CraftBlaze(CraftServer server, EntityBlaze entity) { super(server, entity); } + + @Override + public EntityBlaze getHandle() { + return (EntityBlaze) entity; + } + + @Override + public String toString() { + return "CraftBlaze"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index 721b653e3e..4e7a922d46 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -5,47 +5,50 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Boat; public class CraftBoat extends CraftVehicle implements Boat { - protected EntityBoat boat; public CraftBoat(CraftServer server, EntityBoat entity) { super(server, entity); - boat = entity; } public double getMaxSpeed() { - return boat.maxSpeed; + return getHandle().maxSpeed; } public void setMaxSpeed(double speed) { if (speed >= 0D) { - boat.maxSpeed = speed; + getHandle().maxSpeed = speed; } } public double getOccupiedDeceleration() { - return boat.occupiedDeceleration; + return getHandle().occupiedDeceleration; } public void setOccupiedDeceleration(double speed) { if (speed >= 0D) { - boat.occupiedDeceleration = speed; + getHandle().occupiedDeceleration = speed; } } public double getUnoccupiedDeceleration() { - return boat.unoccupiedDeceleration; + return getHandle().unoccupiedDeceleration; } public void setUnoccupiedDeceleration(double speed) { - boat.unoccupiedDeceleration = speed; + getHandle().unoccupiedDeceleration = speed; } public boolean getWorkOnLand() { - return boat.landBoats; + return getHandle().landBoats; } public void setWorkOnLand(boolean workOnLand) { - boat.landBoats = workOnLand; + getHandle().landBoats = workOnLand; + } + + @Override + public EntityBoat getHandle() { + return (EntityBoat) entity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java index 5f3bfe94ab..da099d8318 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java @@ -11,7 +11,7 @@ public class CraftCaveSpider extends CraftSpider implements CaveSpider { @Override public EntityCaveSpider getHandle() { - return (EntityCaveSpider) super.getHandle(); + return (EntityCaveSpider) entity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java index 84d01e1259..2a66fc7c06 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -10,6 +10,11 @@ public class CraftChicken extends CraftAnimals implements Chicken { super(server, entity); } + @Override + public EntityChicken getHandle() { + return (EntityChicken) entity; + } + @Override public String toString() { return "CraftChicken"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java index a0c8d7e7d4..549c0dfb96 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java @@ -6,12 +6,17 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ComplexLivingEntity; public abstract class CraftComplexLivingEntity extends CraftLivingEntity implements ComplexLivingEntity { - public CraftComplexLivingEntity(CraftServer server, EntityLiving entity) { + public CraftComplexLivingEntity(CraftServer server, EntityComplex entity) { super(server, entity); } @Override public EntityComplex getHandle() { - return (EntityComplex)super.getHandle(); + return (EntityComplex) entity; + } + + @Override + public String toString() { + return "CraftComplexLivingEntity"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java index fc5264b5af..13ebd70b9b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -7,16 +7,21 @@ import org.bukkit.entity.ComplexEntityPart; import org.bukkit.entity.ComplexLivingEntity; public class CraftComplexPart extends CraftEntity implements ComplexEntityPart { - public CraftComplexPart(CraftServer server, Entity entity) { + public CraftComplexPart(CraftServer server, EntityComplexPart entity) { super(server, entity); } public ComplexLivingEntity getParent() { - return (ComplexLivingEntity)getHandle().a.getBukkitEntity(); + return (ComplexLivingEntity) getHandle().a.getBukkitEntity(); } @Override public EntityComplexPart getHandle() { - return (EntityComplexPart)super.getHandle(); + return (EntityComplexPart) entity; + } + + @Override + public String toString() { + return "CraftComplexPart"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java index 4136c99340..c078004505 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -10,6 +10,11 @@ public class CraftCow extends CraftAnimals implements Cow { super(server, entity); } + @Override + public EntityCow getHandle() { + return (EntityCow) entity; + } + @Override public String toString() { return "CraftCow"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java index 8e24c096d6..722b49785f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java @@ -12,16 +12,6 @@ public class CraftCreeper extends CraftMonster implements Creeper { super(server, entity); } - @Override - public EntityCreeper getHandle() { - return (EntityCreeper) super.getHandle(); - } - - @Override - public String toString() { - return "CraftCreeper"; - } - public boolean isPowered() { return getHandle().isPowered(); } @@ -51,4 +41,13 @@ public class CraftCreeper extends CraftMonster implements Creeper { } + @Override + public EntityCreeper getHandle() { + return (EntityCreeper) entity; + } + + @Override + public String toString() { + return "CraftCreeper"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java index 2af6781663..c20739f83f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java @@ -9,6 +9,11 @@ public class CraftEgg extends CraftProjectile implements Egg { super(server, entity); } + @Override + public EntityEgg getHandle() { + return (EntityEgg) entity; + } + @Override public String toString() { return "CraftEgg"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java index c27b3a5daf..6acc07b648 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java @@ -1,16 +1,21 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.Entity; +import net.minecraft.server.EntityEnderCrystal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderSignal; public class CraftEnderCrystal extends CraftEntity implements EnderSignal { - public CraftEnderCrystal(CraftServer server, Entity entity) { + public CraftEnderCrystal(CraftServer server, EntityEnderCrystal entity) { super(server, entity); } + @Override + public EntityEnderCrystal getHandle() { + return (EntityEnderCrystal) entity; + } + @Override public String toString() { - return "CraftEnderSignal"; + return "CraftEnderCrystal"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java index 320d17dd99..0c595ea106 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -11,22 +11,27 @@ import org.bukkit.entity.ComplexEntityPart; import org.bukkit.entity.EnderDragon; public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderDragon { - public CraftEnderDragon(CraftServer server, EntityLiving entity) { + public CraftEnderDragon(CraftServer server, EntityEnderDragon entity) { super(server, entity); } public Set getParts() { Builder builder = ImmutableSet.builder(); - + for (EntityComplexPart part : getHandle().f) { - builder.add((ComplexEntityPart)part.getBukkitEntity()); + builder.add((ComplexEntityPart) part.getBukkitEntity()); } - + return builder.build(); } @Override public EntityEnderDragon getHandle() { - return (EntityEnderDragon)super.getHandle(); + return (EntityEnderDragon) entity; + } + + @Override + public String toString() { + return "CraftEnderDragon"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java index 10d77a2cd2..b62c909ec8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java @@ -1,17 +1,27 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.Entity; +import net.minecraft.server.EntityComplexPart; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.EnderDragonPart; public class CraftEnderDragonPart extends CraftComplexPart implements EnderDragonPart { - public CraftEnderDragonPart(CraftServer server, Entity entity) { + public CraftEnderDragonPart(CraftServer server, EntityComplexPart entity) { super(server, entity); } @Override public EnderDragon getParent() { - return (EnderDragon)super.getParent(); + return (EnderDragon) super.getParent(); + } + + @Override + public EntityComplexPart getHandle() { + return (EntityComplexPart) entity; + } + + @Override + public String toString() { + return "CraftEnderDragonPart"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java index 4b42c10203..1dd0042336 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java @@ -1,14 +1,19 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.Entity; +import net.minecraft.server.EntityEnderPearl; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderPearl; public class CraftEnderPearl extends CraftProjectile implements EnderPearl { - public CraftEnderPearl(CraftServer server, Entity entity) { + public CraftEnderPearl(CraftServer server, EntityEnderPearl entity) { super(server, entity); } + @Override + public EntityEnderPearl getHandle() { + return (EntityEnderPearl) entity; + } + @Override public String toString() { return "CraftEnderPearl"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index 6627dd0663..1a1f899bc9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -1,14 +1,19 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.Entity; +import net.minecraft.server.EntityEnderSignal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderSignal; public class CraftEnderSignal extends CraftEntity implements EnderSignal { - public CraftEnderSignal(CraftServer server, Entity entity) { + public CraftEnderSignal(CraftServer server, EntityEnderSignal entity) { super(server, entity); } + @Override + public EntityEnderSignal getHandle() { + return (EntityEnderSignal) entity; + } + @Override public String toString() { return "CraftEnderSignal"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java index 229885be4c..20464076d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -12,16 +12,6 @@ public class CraftEnderman extends CraftMonster implements Enderman { super(server, entity); } - @Override - public EntityEnderman getHandle() { - return (EntityEnderman) super.getHandle(); - } - - @Override - public String toString() { - return "CraftEnderman"; - } - public MaterialData getCarriedMaterial() { return Material.getMaterial(getHandle().getCarriedId()).getNewData((byte) getHandle().getCarriedData()); } @@ -30,4 +20,14 @@ public class CraftEnderman extends CraftMonster implements Enderman { getHandle().setCarriedId(data.getItemTypeId()); getHandle().setCarriedData(data.getData()); } + + @Override + public EntityEnderman getHandle() { + return (EntityEnderman) entity; + } + + @Override + public String toString() { + return "CraftEnderman"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 2cf8e8a0e0..61b65f0c4b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -35,7 +35,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntityLiving) { // Players if (entity instanceof EntityHuman) { - if (entity instanceof EntityPlayer) { return getPlayer((EntityPlayer)entity); } + if (entity instanceof EntityPlayer) { return getPlayer((EntityPlayer) entity); } else { return new CraftHumanEntity(server, (EntityHuman) entity); } } else if (entity instanceof EntityCreature) { @@ -75,7 +75,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntitySquid) { return new CraftSquid(server, (EntitySquid) entity); } else { return new CraftWaterMob(server, (EntityWaterAnimal) entity); } } - else if (entity instanceof EntitySnowman) { return new CraftSnowman(server, (EntityCreature) entity); } + else if (entity instanceof EntitySnowman) { return new CraftSnowman(server, (EntitySnowman) entity); } else if (entity instanceof EntityVillager) { return new CraftVillager(server, (EntityVillager) entity); } else { return new CraftCreature(server, (EntityCreature) entity); } } @@ -95,8 +95,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftLivingEntity(server, (EntityLiving) entity); } } else if (entity instanceof EntityComplexPart) { - EntityComplexPart part = (EntityComplexPart)entity; - if (part.a instanceof EntityEnderDragon) { return new CraftEnderDragonPart(server, (EntityComplexPart)entity); } + EntityComplexPart part = (EntityComplexPart) entity; + if (part.a instanceof EntityEnderDragon) { return new CraftEnderDragonPart(server, (EntityComplexPart) entity); } else { return new CraftComplexPart(server, (EntityComplexPart) entity); } } else if (entity instanceof EntityExperienceOrb) { return new CraftExperienceOrb(server, (EntityExperienceOrb) entity); } @@ -118,21 +118,14 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityFishingHook) { return new CraftFish(server, (EntityFishingHook) entity); } else if (entity instanceof EntityItem) { return new CraftItem(server, (EntityItem) entity); } else if (entity instanceof EntityWeather) { - if (entity instanceof EntityWeatherStorm) { - return new CraftLightningStrike(server, (EntityWeatherStorm)entity); - } else { - return new CraftWeather(server, (EntityWeather)entity); - } + if (entity instanceof EntityWeatherStorm) { return new CraftLightningStrike(server, (EntityWeatherStorm) entity); } + else { return new CraftWeather(server, (EntityWeather) entity); } } else if (entity instanceof EntityMinecart) { EntityMinecart mc = (EntityMinecart) entity; - if (mc.type == CraftMinecart.Type.StorageMinecart.getId()) { - return new CraftStorageMinecart(server, mc); - } else if (mc.type == CraftMinecart.Type.PoweredMinecart.getId()) { - return new CraftPoweredMinecart(server, mc); - } else { - return new CraftMinecart(server, mc); - } + if (mc.type == CraftMinecart.Type.StorageMinecart.getId()) { return new CraftStorageMinecart(server, mc); } + else if (mc.type == CraftMinecart.Type.PoweredMinecart.getId()) { return new CraftPoweredMinecart(server, mc); } + else { return new CraftMinecart(server, mc); } } else if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); } else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); } @@ -205,14 +198,6 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return !entity.aj(); } - public Entity getHandle() { - return entity; - } - - public void setHandle(final Entity entity) { - this.entity = entity; - } - @Override public boolean equals(Object obj) { if (obj == null) { @@ -231,19 +216,6 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return true; } - @Override - public int hashCode() { - int hash = 7; - hash = 89 * hash + (this.server != null ? this.server.hashCode() : 0); - hash = 89 * hash + (this.entity != null ? this.entity.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - return "CraftEntity{" + "id=" + getEntityId() + '}'; - } - public Server getServer() { return server; } @@ -314,15 +286,36 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return result; } - + public int getTicksLived() { return getHandle().ticksLived; } - + public void setTicksLived(int value) { if (value <= 0) { throw new IllegalArgumentException("Age must be at least 1 tick"); } getHandle().ticksLived = value; } + + public Entity getHandle() { + return entity; + } + + public void setHandle(final Entity entity) { + this.entity = entity; + } + + @Override + public String toString() { + return "CraftEntity{" + "id=" + getEntityId() + '}'; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 89 * hash + (this.server != null ? this.server.hashCode() : 0); + hash = 89 * hash + (this.entity != null ? this.entity.hashCode() : 0); + return hash; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java index 8e8b6fe7ab..df9a657e2a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java @@ -10,11 +10,6 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb { super(server, entity); } - @Override - public EntityExperienceOrb getHandle() { - return (EntityExperienceOrb) super.getHandle(); - } - public int getExperience() { return getHandle().value; } @@ -22,4 +17,14 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb { public void setExperience(int value) { getHandle().value = value; } + + @Override + public EntityExperienceOrb getHandle() { + return (EntityExperienceOrb) entity; + } + + @Override + public String toString() { + return "CraftExperienceOrb"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java index 8af8d5397d..8a0ba9d26e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java @@ -12,6 +12,11 @@ public class CraftFallingSand extends CraftEntity implements FallingSand { super(server, entity); } + @Override + public EntityFallingSand getHandle() { + return (EntityFallingSand) entity; + } + @Override public String toString() { return "CraftFallingSand"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 1de19a62fc..27e00aaa31 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -13,47 +13,51 @@ public class CraftFireball extends AbstractProjectile implements Fireball { super(server, entity); } - @Override - public String toString() { - return "CraftFireball"; - } - public float getYield() { - return ((EntityFireball) getHandle()).yield; + return getHandle().yield; } public boolean isIncendiary() { - return ((EntityFireball) getHandle()).isIncendiary; + return getHandle().isIncendiary; } public void setIsIncendiary(boolean isIncendiary) { - ((EntityFireball) getHandle()).isIncendiary = isIncendiary; + getHandle().isIncendiary = isIncendiary; } public void setYield(float yield) { - ((EntityFireball) getHandle()).yield = yield; + getHandle().yield = yield; } public LivingEntity getShooter() { - if (((EntityFireball) getHandle()).shooter != null) { - return (LivingEntity) ((EntityFireball) getHandle()).shooter.getBukkitEntity(); + if (getHandle().shooter != null) { + return (LivingEntity) getHandle().shooter.getBukkitEntity(); } return null; - } public void setShooter(LivingEntity shooter) { if (shooter instanceof CraftLivingEntity) { - ((EntityFireball) getHandle()).shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; + getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; } } public Vector getDirection() { - return new Vector(((EntityFireball) getHandle()).dirX, ((EntityFireball) getHandle()).dirY, ((EntityFireball) getHandle()).dirZ); + return new Vector(getHandle().dirX, getHandle().dirY, getHandle().dirZ); } public void setDirection(Vector direction) { - ((EntityFireball) getHandle()).setDirection(direction.getX(), direction.getY(), direction.getZ()); + getHandle().setDirection(direction.getX(), direction.getY(), direction.getZ()); + } + + @Override + public EntityFireball getHandle() { + return (EntityFireball) entity; + } + + @Override + public String toString() { + return "CraftFireball"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java index cff09a8053..b8453e9304 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -12,24 +12,27 @@ public class CraftFish extends AbstractProjectile implements Fish { super(server, entity); } - @Override - public String toString() { - return "CraftFish"; - } - public LivingEntity getShooter() { - if (((EntityFishingHook) getHandle()).owner != null) { - return (LivingEntity) ((EntityFishingHook) getHandle()).owner.getBukkitEntity(); + if (getHandle().owner != null) { + return (LivingEntity) getHandle().owner.getBukkitEntity(); } return null; - } public void setShooter(LivingEntity shooter) { if (shooter instanceof CraftHumanEntity) { - ((EntityFishingHook) getHandle()).owner = (EntityHuman) ((CraftHumanEntity) shooter).entity; + getHandle().owner = (EntityHuman) ((CraftHumanEntity) shooter).entity; } } + @Override + public EntityFishingHook getHandle() { + return (EntityFishingHook) entity; + } + + @Override + public String toString() { + return "CraftFish"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java index 3426590a4a..f374c7b880 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java @@ -10,9 +10,13 @@ public class CraftFlying extends CraftLivingEntity implements Flying { super(server, entity); } + @Override + public EntityFlying getHandle() { + return (EntityFlying) entity; + } + @Override public String toString() { return "CraftFlying"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java index 3d0e70f67b..532b16f9d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java @@ -10,9 +10,13 @@ public class CraftGhast extends CraftFlying implements Ghast { super(server, entity); } + @Override + public EntityGhast getHandle() { + return (EntityGhast) entity; + } + @Override public String toString() { return "CraftGhast"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java index 8e324c6c79..50e0ffb16c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java @@ -11,9 +11,13 @@ public class CraftGiant extends CraftMonster implements Giant { super(server, entity); } + @Override + public EntityGiantZombie getHandle() { + return (EntityGiantZombie) entity; + } + @Override public String toString() { return "CraftGiant"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index a46ec12233..a5256e206d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -31,17 +31,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return getHandle().name; } - @Override - public EntityHuman getHandle() { - return (EntityHuman) entity; - } - - public void setHandle(final EntityHuman entity) { - super.setHandle((EntityHuman) entity); - this.entity = entity; - this.inventory = new CraftInventoryPlayer(entity.inventory); - } - public PlayerInventory getInventory() { return inventory; } @@ -54,11 +43,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { getInventory().setItemInHand(item); } - @Override - public String toString() { - return "CraftHumanEntity{" + "id=" + getEntityId() + "name=" + getName() + '}'; - } - public boolean isSleeping() { return getHandle().sleeping; } @@ -131,4 +115,19 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { this.mode = mode; } + + @Override + public EntityHuman getHandle() { + return (EntityHuman) entity; + } + + public void setHandle(final EntityHuman entity) { + super.setHandle(entity); + this.inventory = new CraftInventoryPlayer(entity.inventory); + } + + @Override + public String toString() { + return "CraftHumanEntity{" + "id=" + getEntityId() + "name=" + getName() + '}'; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index 52458f19bc..a01976cf17 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -30,6 +30,11 @@ public class CraftItem extends CraftEntity implements Item { item.pickupDelay = delay; } + @Override + public EntityItem getHandle() { + return (EntityItem) entity; + } + @Override public String toString() { return "CraftItem"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java index 7e37b39b61..2a5ba28c32 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java @@ -9,12 +9,17 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike super(server, entity); } - @Override - public EntityWeatherStorm getHandle() { - return (EntityWeatherStorm) super.getHandle(); - } - public boolean isEffect() { return ((EntityWeatherStorm) super.getHandle()).isEffect; } + + @Override + public EntityWeatherStorm getHandle() { + return (EntityWeatherStorm) entity; + } + + @Override + public String toString() { + return "CraftLightningStrik"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 6d7d3f2100..cf6c0b26df 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -51,21 +51,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { return getHandle().getMaxHealth(); } - @Override - public EntityLiving getHandle() { - return (EntityLiving) entity; - } - - public void setHandle(final EntityLiving entity) { - super.setHandle((Entity) entity); - this.entity = entity; - } - - @Override - public String toString() { - return "CraftLivingEntity{" + "id=" + getEntityId() + '}'; - } - public Egg throwEgg() { net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle(); EntityEgg egg = new EntityEgg(world, getHandle()); @@ -224,4 +209,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void setNoDamageTicks(int ticks) { getHandle().noDamageTicks = ticks; } + + @Override + public EntityLiving getHandle() { + return (EntityLiving) entity; + } + + public void setHandle(final EntityLiving entity) { + super.setHandle(entity); + } + + @Override + public String toString() { + return "CraftLivingEntity{" + "id=" + getEntityId() + '}'; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java index 4b68370248..dd95ae32a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java @@ -11,12 +11,12 @@ public class CraftMagmaCube extends CraftSlime implements MagmaCube { super(server, entity); } + public EntityLavaSlime getHandle() { + return (EntityLavaSlime) entity; + } + @Override public String toString() { return "CraftMagmaCube"; } - - public EntityLavaSlime getHandle() { - return (EntityLavaSlime) super.getHandle(); - } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 8381aeae9d..d4420bd580 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -26,62 +26,59 @@ public class CraftMinecart extends CraftVehicle implements Minecart { } } - protected EntityMinecart minecart; - public CraftMinecart(CraftServer server, EntityMinecart entity) { super(server, entity); - minecart = entity; } public void setDamage(int damage) { - minecart.setDamage(damage); + getHandle().setDamage(damage); } public int getDamage() { - return minecart.getDamage(); + return getHandle().getDamage(); } public double getMaxSpeed() { - return minecart.maxSpeed; + return getHandle().maxSpeed; } public void setMaxSpeed(double speed) { if (speed >= 0D) { - minecart.maxSpeed = speed; + getHandle().maxSpeed = speed; } } public boolean isSlowWhenEmpty() { - return minecart.slowWhenEmpty; + return getHandle().slowWhenEmpty; } public void setSlowWhenEmpty(boolean slow) { - minecart.slowWhenEmpty = slow; + getHandle().slowWhenEmpty = slow; } public Vector getFlyingVelocityMod() { - return new Vector(minecart.flyingX, minecart.flyingY, minecart.flyingZ); + return getHandle().getFlyingVelocityMod(); } public void setFlyingVelocityMod(Vector flying) { - minecart.flyingX = flying.getX(); - minecart.flyingY = flying.getY(); - minecart.flyingZ = flying.getZ(); + getHandle().setFlyingVelocityMod(flying); } public Vector getDerailedVelocityMod() { - return new Vector(minecart.derailedX, minecart.derailedY, minecart.derailedZ); + return getHandle().getDerailedVelocityMod(); } public void setDerailedVelocityMod(Vector derailed) { - minecart.derailedX = derailed.getX(); - minecart.derailedY = derailed.getY(); - minecart.derailedZ = derailed.getZ(); + getHandle().setDerailedVelocityMod(derailed); + } + + @Override + public EntityMinecart getHandle() { + return (EntityMinecart) entity; } @Override public String toString() { return "CraftMinecart"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java index 2736c26d53..72dedbc8f4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java @@ -11,13 +11,13 @@ public class CraftMonster extends CraftCreature implements Monster { super(server, entity); } - @Override - public String toString() { - return "CraftMonster"; - } - @Override public EntityMonster getHandle() { return (EntityMonster) entity; } + + @Override + public String toString() { + return "CraftMonster"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java index 2a076f2976..8173d893f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -1,11 +1,21 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.EntityCow; +import net.minecraft.server.EntityMushroomCow; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.MushroomCow; public class CraftMushroomCow extends CraftCow implements MushroomCow { - public CraftMushroomCow(CraftServer server, EntityCow entity) { + public CraftMushroomCow(CraftServer server, EntityMushroomCow entity) { super(server, entity); } + + @Override + public EntityMushroomCow getHandle() { + return (EntityMushroomCow) entity; + } + + @Override + public String toString() { + return "CraftMushroomCow"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 9a37c5ff18..640cb86248 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -20,16 +20,6 @@ public class CraftPainting extends CraftEntity implements Painting { super(server, entity); } - @Override - public EntityPainting getHandle() { - return (EntityPainting) super.getHandle(); - } - - @Override - public String toString() { - return "CraftPainting[art=" + getArt() + "]"; - } - public Art getArt() { EnumArt art = getHandle().e; return CraftArt.NotchToBukkit(art); @@ -124,4 +114,14 @@ public class CraftPainting extends CraftEntity implements Painting { world.addEntity(painting); this.entity = painting; } + + @Override + public EntityPainting getHandle() { + return (EntityPainting) entity; + } + + @Override + public String toString() { + return "CraftPainting{art=" + getArt() + "}"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 78d5b87712..fc2eb9e0ef 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -18,7 +18,7 @@ public class CraftPig extends CraftAnimals implements Pig { } public EntityPig getHandle() { - return (EntityPig) super.getHandle(); + return (EntityPig) entity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java index f3087eba4a..3a129434bb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -11,16 +11,6 @@ public class CraftPigZombie extends CraftZombie implements PigZombie { super(server, entity); } - @Override - public EntityPigZombie getHandle() { - return (EntityPigZombie) super.getHandle(); - } - - @Override - public String toString() { - return "CraftPigZombie"; - } - public int getAnger() { return getHandle().angerLevel; } @@ -37,4 +27,13 @@ public class CraftPigZombie extends CraftZombie implements PigZombie { return getAnger() > 0; } + @Override + public EntityPigZombie getHandle() { + return (EntityPigZombie) entity; + } + + @Override + public String toString() { + return "CraftPigZombie"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index bf404b4ac5..01b8740a1a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -86,11 +86,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - @Override - public EntityPlayer getHandle() { - return (EntityPlayer) entity; - } - public double getEyeHeight() { return getEyeHeight(false); } @@ -107,11 +102,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - public void setHandle(final EntityPlayer entity) { - super.setHandle((EntityHuman) entity); - this.entity = entity; - } - public void sendRawMessage(String message) { if (getHandle().netServerHandler == null) return; @@ -163,11 +153,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { server.getHandle().sendAll(new Packet201PlayerInfo(name, true, getHandle().i)); } - @Override - public String toString() { - return "CraftPlayer{" + "name=" + getName() + '}'; - } - @Override public boolean equals(Object obj) { if (obj == null) { @@ -183,13 +168,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return true; } - @Override - public int hashCode() { - int hash = 5; - hash = 97 * hash + (this.getName() != null ? this.getName().hashCode() : 0); - return hash; - } - public void kickPlayer(String message) { if (getHandle().netServerHandler == null) return; @@ -543,13 +521,34 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public Map serialize() { Map result = new LinkedHashMap(); - + result.put("name", getName()); - + return result; } public Player getPlayer() { return this; } + + @Override + public EntityPlayer getHandle() { + return (EntityPlayer) entity; + } + + public void setHandle(final EntityPlayer entity) { + super.setHandle(entity); + } + + @Override + public String toString() { + return "CraftPlayer{" + "name=" + getName() + '}'; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 97 * hash + (this.getName() != null ? this.getName().hashCode() : 0); + return hash; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPoweredMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPoweredMinecart.java index 668bc4af9c..b261a0f137 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPoweredMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPoweredMinecart.java @@ -14,5 +14,4 @@ public class CraftPoweredMinecart extends CraftMinecart implements PoweredMineca public String toString() { return "CraftPoweredMinecart"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index 240b9e9466..7fea15e5c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -27,6 +27,11 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj @Override public EntityProjectile getHandle() { - return (EntityProjectile)entity; + return (EntityProjectile) entity; + } + + @Override + public String toString() { + return "CraftProjectile"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java index 2fe42935d9..ecc58c3d46 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java @@ -11,16 +11,6 @@ public class CraftSheep extends CraftAnimals implements Sheep { super(server, entity); } - @Override - public EntitySheep getHandle() { - return (EntitySheep) entity; - } - - @Override - public String toString() { - return "CraftSheep"; - } - public DyeColor getColor() { return DyeColor.getByData((byte) getHandle().getColor()); } @@ -37,4 +27,14 @@ public class CraftSheep extends CraftAnimals implements Sheep { getHandle().setSheared(flag); } + @Override + public EntitySheep getHandle() { + return (EntitySheep) entity; + } + + @Override + public String toString() { + return "CraftSheep"; + } + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java index 8296feaef7..5e608d2f37 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java @@ -11,7 +11,7 @@ public class CraftSilverfish extends CraftMonster implements Silverfish { @Override public EntitySilverfish getHandle() { - return (EntitySilverfish) super.getHandle(); + return (EntitySilverfish) entity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index c4bd5e9eed..0eab7074e0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -11,9 +11,13 @@ public class CraftSkeleton extends CraftMonster implements Skeleton { super(server, entity); } + @Override + public EntitySkeleton getHandle() { + return (EntitySkeleton) entity; + } + @Override public String toString() { return "CraftSkeleton"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java index 0dc57f63d8..27a596a772 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java @@ -11,15 +11,6 @@ public class CraftSlime extends CraftLivingEntity implements Slime { super(server, entity); } - @Override - public String toString() { - return "CraftSlime"; - } - - public EntitySlime getHandle() { - return (EntitySlime) super.getHandle(); - } - public int getSize() { return getHandle().getSize(); } @@ -27,4 +18,14 @@ public class CraftSlime extends CraftLivingEntity implements Slime { public void setSize(int size) { getHandle().setSize(size); } + + @Override + public EntitySlime getHandle() { + return (EntitySlime) entity; + } + + @Override + public String toString() { + return "CraftSlime"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java index 4677502435..9902661ea5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java @@ -1,12 +1,21 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.EntityFireball; +import net.minecraft.server.EntitySmallFireball; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.SmallFireball; public class CraftSmallFireball extends CraftFireball implements SmallFireball { - public CraftSmallFireball(CraftServer server, EntityFireball entity) { + public CraftSmallFireball(CraftServer server, EntitySmallFireball entity) { super(server, entity); } - + + @Override + public EntitySmallFireball getHandle() { + return (EntitySmallFireball) entity; + } + + @Override + public String toString() { + return "CraftSmallFireball"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java index cb52b2dc6f..006502e411 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -9,6 +9,11 @@ public class CraftSnowball extends CraftProjectile implements Snowball { super(server, entity); } + @Override + public EntitySnowball getHandle() { + return (EntitySnowball) entity; + } + @Override public String toString() { return "CraftSnowball"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java index acfc05215c..f0bb1bb8bf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -1,11 +1,21 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.EntityCreature; +import net.minecraft.server.EntitySnowman; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Snowman; public class CraftSnowman extends CraftCreature implements Snowman { - public CraftSnowman(CraftServer server, EntityCreature entity) { + public CraftSnowman(CraftServer server, EntitySnowman entity) { super(server, entity); } + + @Override + public EntitySnowman getHandle() { + return (EntitySnowman) entity; + } + + @Override + public String toString() { + return "CraftSnowman"; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java index ad30881af6..32b0a11d2b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java @@ -11,9 +11,13 @@ public class CraftSpider extends CraftMonster implements Spider { super(server, entity); } + @Override + public EntitySpider getHandle() { + return (EntitySpider) entity; + } + @Override public String toString() { return "CraftSpider"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java index 9b7427a826..b13fb2259e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java @@ -11,9 +11,13 @@ public class CraftSquid extends CraftWaterMob implements Squid { super(server, entity); } + @Override + public EntitySquid getHandle() { + return (EntitySquid) entity; + } + @Override public String toString() { return "CraftSquid"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java index bbbc58b1df..58cb04bfca 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java @@ -11,16 +11,6 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { super(server, entity); } - @Override - public String toString() { - return "CraftTNTPrimed"; - } - - @Override - public EntityTNTPrimed getHandle() { - return (EntityTNTPrimed) super.getHandle(); - } - public float getYield() { return getHandle().yield; } @@ -45,4 +35,14 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { getHandle().fuseTicks = fuseTicks; } + @Override + public EntityTNTPrimed getHandle() { + return (EntityTNTPrimed) entity; + } + + @Override + public String toString() { + return "CraftTNTPrimed"; + } + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java index 3faf054160..81dca041ff 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -1,14 +1,19 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.Entity; +import net.minecraft.server.EntityPotion; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ThrownPotion; public class CraftThrownPotion extends CraftProjectile implements ThrownPotion { - public CraftThrownPotion(CraftServer server, Entity entity) { + public CraftThrownPotion(CraftServer server, EntityPotion entity) { super(server, entity); } + @Override + public EntityPotion getHandle() { + return (EntityPotion) entity; + } + @Override public String toString() { return "CraftThrownPotion"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index 35b7e1a8e1..8b1c300a65 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -1,6 +1,5 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.EntityCreature; import net.minecraft.server.EntityVillager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Villager; @@ -12,6 +11,11 @@ public class CraftVillager extends CraftCreature implements Villager { @Override public EntityVillager getHandle() { - return (EntityVillager)super.getHandle(); + return (EntityVillager) entity; + } + + @Override + public String toString() { + return "CraftVillager"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java index 62fa9bb981..39e8d89bf4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java @@ -11,9 +11,13 @@ public class CraftWaterMob extends CraftCreature implements WaterMob { super(server, entity); } + @Override + public EntityWaterAnimal getHandle() { + return (EntityWaterAnimal) entity; + } + @Override public String toString() { return "CraftWaterMob"; } - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java index 671394e64e..c937aac956 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java @@ -12,6 +12,11 @@ public class CraftWeather extends CraftEntity implements Weather { @Override public EntityWeather getHandle() { - return (EntityWeather) super.getHandle(); + return (EntityWeather) entity; + } + + @Override + public String toString() { + return "CraftWeather"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index fc00141f61..6aa91b2af7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -110,6 +110,6 @@ public class CraftWolf extends CraftAnimals implements Wolf { @Override public String toString() { - return "CraftWolf[anger=" + isAngry() + ",owner=" + getOwner() + ",tame=" + isTamed() + ",sitting=" + isSitting() + "]"; + return "CraftWolf{anger=" + isAngry() + ",owner=" + getOwner() + ",tame=" + isTamed() + ",sitting=" + isSitting() + "}"; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index bb32d3c923..6212e1730d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -11,6 +11,11 @@ public class CraftZombie extends CraftMonster implements Zombie { super(server, entity); } + @Override + public EntityZombie getHandle() { + return (EntityZombie) entity; + } + @Override public String toString() { return "CraftZombie";