Generic cleanup of the org.bukkit.craftbukkit classes.

This commit is contained in:
Erik Broes
2011-06-12 01:12:43 +02:00
parent b042f48b24
commit 9adc03abab
34 changed files with 160 additions and 145 deletions

View File

@@ -4,7 +4,8 @@ import net.minecraft.server.EntityChicken;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Chicken;
public class CraftChicken extends CraftAnimals implements Chicken{
public class CraftChicken extends CraftAnimals implements Chicken {
public CraftChicken(CraftServer server, EntityChicken entity) {
super(server, entity);

View File

@@ -6,7 +6,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Creature;
import org.bukkit.entity.LivingEntity;
public class CraftCreature extends CraftLivingEntity implements Creature{
public class CraftCreature extends CraftLivingEntity implements Creature {
public CraftCreature(CraftServer server, EntityCreature entity) {
super(server, entity);
}

View File

@@ -32,14 +32,14 @@ public class CraftCreeper extends CraftMonster implements Creeper {
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
getHandle().Z().b(17, (byte)1);
getHandle().Z().b(17, (byte) 1);
}
} else {
CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_OFF);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
getHandle().Z().b(17, (byte)0);
getHandle().Z().b(17, (byte) 0);
}
}

View File

@@ -118,11 +118,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public World getWorld() {
return ((WorldServer)entity.world).getWorld();
return ((WorldServer) entity.world).getWorld();
}
public boolean teleport(Location location) {
entity.world = ((CraftWorld)location.getWorld()).getHandle();
entity.world = ((CraftWorld) location.getWorld()).getHandle();
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
// entity.setLocation() throws no event, and so cannot be cancelled
return true;
@@ -140,10 +140,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
teleport(destination);
}
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z){
List<Entity> notchEntityList = entity.world.b(entity, entity.boundingBox.b(x,y,z));
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
List<Entity> notchEntityList = entity.world.b(entity, entity.boundingBox.b(x, y, z));
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());
for (Entity e: notchEntityList){
for (Entity e: notchEntityList) {
bukkitEntityList.add(e.getBukkitEntity());
}
return bukkitEntityList;
@@ -229,7 +230,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public boolean setPassenger(org.bukkit.entity.Entity passenger) {
if (passenger instanceof CraftEntity){
if (passenger instanceof CraftEntity) {
((CraftEntity) passenger).getHandle().setPassengerOf(getHandle());
return true;
} else {

View File

@@ -26,7 +26,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
public void setHandle(final EntityHuman entity) {
super.setHandle((EntityHuman)entity);
super.setHandle((EntityHuman) entity);
this.entity = entity;
this.inventory = new CraftInventoryPlayer(entity.inventory);
}

View File

@@ -12,7 +12,7 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
@Override
public EntityWeatherStorm getHandle() {
return (EntityWeatherStorm)super.getHandle();
return (EntityWeatherStorm) super.getHandle();
}
public boolean isEffect() {

View File

@@ -40,7 +40,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
if (entity instanceof EntityPlayer && health == 0) {
((EntityPlayer)entity).a((Entity)null);
((EntityPlayer) entity).a((Entity) null);
}
getHandle().health = health;
@@ -52,7 +52,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public void setHandle(final EntityLiving entity) {
super.setHandle((Entity)entity);
super.setHandle((Entity) entity);
this.entity = entity;
}
@@ -62,15 +62,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public Egg throwEgg() {
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle();
EntityEgg egg = new EntityEgg(world, getHandle());
world.addEntity(egg);
return (Egg) egg.getBukkitEntity();
}
public Snowball throwSnowball() {
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle();
EntitySnowball snowball = new EntitySnowball(world, getHandle());
world.addEntity(snowball);
return (Snowball) snowball.getBukkitEntity();
}
@@ -101,7 +103,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
break;
}
} else {
if (!transparent.contains((byte)id)) {
if (!transparent.contains((byte) id)) {
break;
}
}
@@ -123,8 +125,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public Arrow shootArrow() {
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle();
EntityArrow arrow = new EntityArrow(world, getHandle());
world.addEntity(arrow);
return (Arrow) arrow.getBukkitEntity();
}

View File

@@ -147,8 +147,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void playNote(Location loc, byte instrument, byte note) {
getHandle().netServerHandler.sendPacket(
new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument, note));
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument, note));
}
public void playEffect(Location loc, Effect effect, int data) {
@@ -162,9 +161,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void sendBlockChange(Location loc, int material, byte data) {
Packet53BlockChange packet = new Packet53BlockChange(
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(),
((CraftWorld) loc.getWorld()).getHandle());
Packet53BlockChange packet = new Packet53BlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
packet.d = material;
packet.e = data;
getHandle().netServerHandler.sendPacket(packet);
@@ -219,8 +217,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();
// Grab the EntityPlayer
EntityPlayer entity = getHandle();
// Check if the fromWorld and toWorld are the same.
if (fromWorld == toWorld){
if (fromWorld == toWorld) {
entity.netServerHandler.teleport(to);
} else {
server.getHandle().a(entity, toWorld.dimension, to);

View File

@@ -12,6 +12,6 @@ public class CraftWeather extends CraftEntity implements Weather {
@Override
public EntityWeather getHandle() {
return (EntityWeather)super.getHandle();
return (EntityWeather) super.getHandle();
}
}

View File

@@ -5,7 +5,8 @@ import net.minecraft.server.EntityZombie;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Zombie;
public class CraftZombie extends CraftMonster implements Zombie{
public class CraftZombie extends CraftMonster implements Zombie {
public CraftZombie(CraftServer server, EntityZombie entity) {
super(server, entity);