diff options
Diffstat (limited to 'src/main/java/org')
8 files changed, 52 insertions, 53 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java index eaae04ba..4f9264c4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -4,7 +4,7 @@ import net.minecraft.server.EntityAnimal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Animals; -public class CraftAnimals extends CraftCreature implements Animals{ +public class CraftAnimals extends CraftCreature implements Animals { public CraftAnimals(CraftServer server, EntityAnimal entity) { super(server, entity); @@ -15,4 +15,8 @@ public class CraftAnimals extends CraftCreature implements Animals{ return "CraftAnimals"; } + @Override + public EntityAnimal getHandle() { + return (EntityAnimal) entity; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java index d881c0e8..8749f131 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java @@ -7,34 +7,30 @@ import org.bukkit.entity.Creature; import org.bukkit.entity.LivingEntity; public class CraftCreature extends CraftLivingEntity implements Creature{ - private EntityCreature entity; - public CraftCreature(CraftServer server, EntityCreature entity) { super(server, entity); - this.entity = entity; } public void setTarget(LivingEntity target) { + EntityCreature entity = getHandle(); if (target == null) { entity.d = null; } else if (target instanceof CraftLivingEntity) { - EntityLiving victim = ((CraftLivingEntity)target).getHandle(); + EntityLiving victim = ((CraftLivingEntity) target).getHandle(); entity.d = victim; entity.a = entity.world.a(entity, entity.d, 16.0F); } } public CraftLivingEntity getTarget() { - if (entity.d == null) { - return null; - } else { - return (CraftLivingEntity)entity.d.getBukkitEntity(); - } + if (getHandle().d == null) return null; + + return (CraftLivingEntity) getHandle().d.getBukkitEntity(); } @Override public EntityCreature getHandle() { - return entity; + return (EntityCreature) entity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 63ffbb5c..aed3bd8e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -10,7 +10,7 @@ import org.bukkit.util.Vector; public abstract class CraftEntity implements org.bukkit.entity.Entity { protected final CraftServer server; - private Entity entity; + protected Entity entity; public CraftEntity(final CraftServer server, final Entity entity) { this.server = server; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 869e76a8..7b37b309 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -9,22 +9,20 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.CraftServer; public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { - private EntityHuman entity; private CraftInventoryPlayer inventory; public CraftHumanEntity(final CraftServer server, final EntityHuman entity) { super(server, entity); - this.entity = entity; this.inventory = new CraftInventoryPlayer( entity.inventory ); } public String getName() { - return entity.name; + return getHandle().name; } @Override public EntityHuman getHandle() { - return entity; + return (EntityHuman) entity; } public void setHandle(final EntityHuman entity) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0fc66e88..299102f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -23,15 +23,12 @@ import java.util.ArrayList; import java.util.Iterator; public class CraftLivingEntity extends CraftEntity implements LivingEntity { - private EntityLiving entity; - public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { super(server, entity); - this.entity = entity; } public int getHealth() { - return entity.health; + return getHandle().health; } public void setHealth(int health) { @@ -39,12 +36,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { throw new IllegalArgumentException("Health must be between 0 and 200"); } - entity.health = health; + getHandle().health = health; } @Override public EntityLiving getHandle() { - return entity; + return (EntityLiving) entity; } public void setHandle(final EntityLiving entity) { @@ -59,14 +56,14 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public Egg throwEgg() { net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle(); - EntityEgg egg = new EntityEgg(world, entity); + EntityEgg egg = new EntityEgg(world, getHandle()); world.a(egg); return (Egg) egg.getBukkitEntity(); } public Snowball throwSnowball() { net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle(); - EntitySnowball snowball = new EntitySnowball(world, entity); + EntitySnowball snowball = new EntitySnowball(world, getHandle()); world.a(snowball); return (Snowball) snowball.getBukkitEntity(); } @@ -120,30 +117,30 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public Arrow shootArrow() { net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle(); - EntityArrow arrow = new EntityArrow(world, entity); + EntityArrow arrow = new EntityArrow(world, getHandle()); world.a(arrow); return (Arrow) arrow.getBukkitEntity(); } public boolean isInsideVehicle() { - return entity.vehicle != null; + return getHandle().vehicle != null; } public boolean leaveVehicle() { - if (entity.vehicle == null) { + if (getHandle().vehicle == null) { return false; } - entity.setPassengerOf(null); + getHandle().setPassengerOf(null); return true; } public Vehicle getVehicle() { - if (entity.vehicle == null) { + if (getHandle().vehicle == null) { return null; } - org.bukkit.entity.Entity vehicle = (entity.vehicle.getBukkitEntity()); + org.bukkit.entity.Entity vehicle = (getHandle().vehicle.getBukkitEntity()); if (vehicle instanceof Vehicle) { return (Vehicle) vehicle; } @@ -152,18 +149,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public int getRemainingAir() { - return entity.airTicks; + return getHandle().airTicks; } public void setRemainingAir(int ticks) { - entity.airTicks = ticks; + getHandle().airTicks = ticks; } public int getMaximumAir() { - return entity.maxAirTicks; + return getHandle().maxAirTicks; } public void setMaximumAir(int ticks) { - entity.maxAirTicks = ticks; + getHandle().maxAirTicks = ticks; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java index c6ad41e9..2736c26d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java @@ -16,4 +16,8 @@ public class CraftMonster extends CraftCreature implements Monster { return "CraftMonster"; } + @Override + public EntityMonster getHandle() { + return (EntityMonster) entity; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 8a7826ba..c5658744 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -18,13 +18,10 @@ import org.bukkit.craftbukkit.TextWrapper; import org.bukkit.entity.Player; public class CraftPlayer extends CraftHumanEntity implements Player { - private EntityPlayer entity; private String name; public CraftPlayer(CraftServer server, EntityPlayer entity) { super(server, entity); - this.name = getName(); - this.entity = entity; } public boolean isOp() { @@ -46,7 +43,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public InetSocketAddress getAddress() { - SocketAddress addr = entity.a.b.b(); + SocketAddress addr = getHandle().a.b.b(); if (addr instanceof InetSocketAddress) { return (InetSocketAddress) addr; } else { @@ -56,7 +53,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public EntityPlayer getHandle() { - return entity; + return (EntityPlayer) entity; } public double getEyeHeight() { @@ -82,7 +79,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void sendMessage(String message) { for (final String line: TextWrapper.wrapText(message)) { - entity.a.b(new Packet3Chat(line)); + getHandle().a.b(new Packet3Chat(line)); } } @@ -122,15 +119,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void kickPlayer(String message) { - entity.a.a(message == null ? "" : message); + getHandle().a.a(message == null ? "" : message); } public void setCompassTarget(Location loc) { - entity.a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())))); + getHandle().a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())))); } public void chat(String msg) { - entity.a.chat(msg); + getHandle().a.chat(msg); } public boolean performCommand(String command) { @@ -142,6 +139,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { WorldServer oldWorld = ((CraftWorld)getWorld()).getHandle(); WorldServer newWorld = ((CraftWorld)location.getWorld()).getHandle(); ServerConfigurationManager manager = server.getHandle(); + EntityPlayer entity = getHandle(); if (oldWorld != newWorld) { manager.c.k.a(entity); @@ -168,21 +166,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { manager.b.add(newEntity); entity.a.e = newEntity; - entity = newEntity; + this.entity = newEntity; } else { entity.a.a(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } } public void setSneaking(boolean sneak) { - entity.b(sneak); + getHandle().b(sneak); } public boolean isSneaking() { - return entity.U(); + return getHandle().U(); } - + public void updateInventory() { - entity.l(); + getHandle().l(); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java index c8be38d6..fa23cf30 100755 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java @@ -7,24 +7,26 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Sheep; public class CraftSheep extends CraftAnimals implements Sheep { - public CraftSheep(CraftServer server, EntitySheep entity) { super(server, entity); } @Override + public EntitySheep getHandle() { + return (EntitySheep) entity; + } + + @Override public String toString() { return "CraftSheep"; } public DyeColor getColor() { - EntitySheep entity = (EntitySheep) getHandle(); - return DyeColor.getByData((byte) entity.n()); + return DyeColor.getByData((byte) getHandle().n()); } public void setColor(DyeColor color) { - EntitySheep entity = (EntitySheep) getHandle(); - entity.a_(color.getData()); + getHandle().a_(color.getData()); } } |