diff options
Diffstat (limited to 'src/main/java/org')
40 files changed, 111 insertions, 139 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index c3b9113a..79c38938 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -228,13 +228,13 @@ public class CraftChunk implements Chunk { if (includeBiomeTempRain) { biomeTemp = new double[256]; biomeRain = new double[256]; - float[] dat = wcm.getTemperatures((float[]) null, getX() << 4, getZ() << 4, 16, 16); + float[] dat = wcm.getTemperatures(null, getX() << 4, getZ() << 4, 16, 16); for (int i = 0; i < 256; i++) { biomeTemp[i] = dat[i]; } - dat = wcm.getWetness((float[]) null, getX() << 4, getZ() << 4, 16, 16); + dat = wcm.getWetness(null, getX() << 4, getZ() << 4, 16, 16); for (int i = 0; i < 256; i++) { biomeRain[i] = dat[i]; @@ -264,13 +264,13 @@ public class CraftChunk implements Chunk { if (includeBiomeTempRain) { biomeTemp = new double[256]; biomeRain = new double[256]; - float[] dat = wcm.getTemperatures((float[]) null, x << 4, z << 4, 16, 16); + float[] dat = wcm.getTemperatures(null, x << 4, z << 4, 16, 16); for (int i = 0; i < 256; i++) { biomeTemp[i] = dat[i]; } - dat = wcm.getWetness((float[]) null, x << 4, z << 4, 16, 16); + dat = wcm.getWetness(null, x << 4, z << 4, 16, 16); for (int i = 0; i < 256; i++) { biomeRain[i] = dat[i]; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 6b3b9fec..7b9c7877 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -723,7 +723,7 @@ public final class CraftServer implements Server { internal.worldMaps = console.worlds.get(0).worldMaps; internal.tracker = new EntityTracker(internal); // CraftBukkit - internal.addIWorldAccess((IWorldAccess) new WorldManager(console, internal)); + internal.addIWorldAccess(new WorldManager(console, internal)); internal.difficulty = 1; internal.setSpawnFlags(true, true); console.worlds.add(internal); @@ -795,7 +795,7 @@ public final class CraftServer implements Server { if (save) { try { - handle.save(true, (IProgressUpdate) null); + handle.save(true, null); handle.saveLevel(); WorldSaveEvent event = new WorldSaveEvent(handle.getWorld()); getPluginManager().callEvent(event); @@ -936,12 +936,12 @@ public final class CraftServer implements Server { if (section != null) { for (String key : section.getKeys(false)) { - List<String> commands = null; + List<String> commands; if (section.isList(key)) { commands = section.getStringList(key); } else { - commands = ImmutableList.<String>of(section.getString(key)); + commands = ImmutableList.of(section.getString(key)); } result.put(key, commands.toArray(new String[commands.size()])); @@ -1247,9 +1247,9 @@ public final class CraftServer implements Server { public void onPlayerJoin(Player player) { if ((updater.isEnabled()) && (updater.getCurrent() != null) && (player.hasPermission(Server.BROADCAST_CHANNEL_ADMINISTRATIVE))) { - if ((updater.getCurrent().isBroken()) && (updater.getOnBroken().contains(updater.WARN_OPERATORS))) { + if ((updater.getCurrent().isBroken()) && (updater.getOnBroken().contains(AutoUpdater.WARN_OPERATORS))) { player.sendMessage(ChatColor.DARK_RED + "The version of CraftBukkit that this server is running is known to be broken. Please consider updating to the latest version at dl.bukkit.org."); - } else if ((updater.isUpdateAvailable()) && (updater.getOnUpdate().contains(updater.WARN_OPERATORS))) { + } else if ((updater.isUpdateAvailable()) && (updater.getOnUpdate().contains(AutoUpdater.WARN_OPERATORS))) { player.sendMessage(ChatColor.DARK_PURPLE + "The version of CraftBukkit that this server is running is out of date. Please consider updating to the latest version at dl.bukkit.org."); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index ee30dcd1..1190ff13 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -6,7 +6,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Sound; public class CraftSound { - private static String[] sounds = new String[Sound.values().length]; + private static final String[] sounds = new String[Sound.values().length]; static { sounds[AMBIENCE_CAVE.ordinal()] = "ambient.cave.cave"; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 41cb825e..b5a68af1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -244,7 +244,7 @@ public class CraftWorld implements World { } world.chunkProviderServer.unloadQueue.remove(x, z); - net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) world.chunkProviderServer.chunks.get(LongHash.toLong(x, z)); + net.minecraft.server.Chunk chunk = world.chunkProviderServer.chunks.get(LongHash.toLong(x, z)); if (chunk == null) { chunk = world.chunkProviderServer.loadChunk(x, z); @@ -681,7 +681,7 @@ public class CraftWorld implements World { public void setStorm(boolean hasStorm) { CraftServer server = world.getServer(); - WeatherChangeEvent weather = new WeatherChangeEvent((org.bukkit.World) this, hasStorm); + WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm); server.getPluginManager().callEvent(weather); if (!weather.isCancelled()) { world.worldData.setStorm(hasStorm); @@ -711,7 +711,7 @@ public class CraftWorld implements World { if (thundering && !hasStorm()) setStorm(true); CraftServer server = world.getServer(); - ThunderChangeEvent thunder = new ThunderChangeEvent((org.bukkit.World) this, thundering); + ThunderChangeEvent thunder = new ThunderChangeEvent(this, thundering); server.getPluginManager().callEvent(thunder); if (!thunder.isCancelled()) { world.worldData.setThundering(thundering); @@ -858,7 +858,7 @@ public class CraftWorld implements World { } else { entity = new EntityLargeFireball(world); } - ((EntityFireball) entity).setPositionRotation(x, y, z, yaw, pitch); + entity.setPositionRotation(x, y, z, yaw, pitch); Vector direction = location.getDirection().multiply(10); ((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ()); } @@ -1265,9 +1265,7 @@ public class CraftWorld implements World { } ChunkProviderServer cps = world.chunkProviderServer; - Iterator<net.minecraft.server.Chunk> iter = cps.chunks.values().iterator(); - while (iter.hasNext()) { - net.minecraft.server.Chunk chunk = iter.next(); + for (net.minecraft.server.Chunk chunk : cps.chunks.values()) { // If in use, skip it if (isChunkInUse(chunk.x, chunk.z)) { continue; @@ -1279,7 +1277,7 @@ public class CraftWorld implements World { } // Add unload request - cps.queueUnload(chunk.x, chunk.z); + cps.queueUnload(chunk.x, chunk.z); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index f1c0e419..2334fb62 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -340,7 +340,7 @@ public class CraftBlock implements Block { public int getBlockPower(BlockFace face) { int power = 0; - BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE; + BlockRedstoneWire wire = net.minecraft.server.Block.REDSTONE_WIRE; net.minecraft.server.World world = chunk.getHandle().world; if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(x, y - 1, z, 0)) power = wire.getPower(world, x, y - 1, z, power); if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(x, y + 1, z, 1)) power = wire.getPower(world, x, y + 1, z, power); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 05296898..d2350452 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -115,19 +115,17 @@ public class CraftBlockState implements BlockState { public boolean update(boolean force) { Block block = getBlock(); - synchronized (block) { - if (block.getType() != this.getType()) { - if (force) { - block.setTypeId(this.getTypeId()); - } else { - return false; - } + if (block.getType() != this.getType()) { + if (force) { + block.setTypeId(this.getTypeId()); + } else { + return false; } - - block.setData(getRawData()); - world.getHandle().notify(x, y, z); } + block.setData(getRawData()); + world.getHandle().notify(x, y, z); + return true; } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java index 6a697cd3..074473cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java @@ -8,14 +8,12 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer; import org.bukkit.inventory.BrewerInventory; public class CraftBrewingStand extends CraftBlockState implements BrewingStand { - private final CraftWorld world; private final TileEntityBrewingStand brewingStand; public CraftBrewingStand(Block block) { super(block); - world = (CraftWorld) block.getWorld(); - brewingStand = (TileEntityBrewingStand) world.getTileEntityAt(getX(), getY(), getZ()); + brewingStand = (TileEntityBrewingStand) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ()); } public BrewerInventory getInventory() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 554eee9c..86839ad9 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -9,14 +9,12 @@ import org.bukkit.entity.CreatureType; import org.bukkit.entity.EntityType; public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpawner { - private final CraftWorld world; private final TileEntityMobSpawner spawner; public CraftCreatureSpawner(final Block block) { super(block); - world = (CraftWorld) block.getWorld(); - spawner = (TileEntityMobSpawner) world.getTileEntityAt(getX(), getY(), getZ()); + spawner = (TileEntityMobSpawner) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ()); } @Deprecated diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java b/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java index c94b43d1..9561ea9b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java @@ -28,15 +28,13 @@ public class CraftDispenser extends CraftBlockState implements Dispenser { public boolean dispense() { Block block = getBlock(); - synchronized (block) { - if (block.getType() == Material.DISPENSER) { - BlockDispenser dispense = (BlockDispenser) net.minecraft.server.Block.DISPENSER; - - dispense.dispense(world.getHandle(), getX(), getY(), getZ()); - return true; - } else { - return false; - } + if (block.getType() == Material.DISPENSER) { + BlockDispenser dispense = (BlockDispenser) net.minecraft.server.Block.DISPENSER; + + dispense.dispense(world.getHandle(), getX(), getY(), getZ()); + return true; + } else { + return false; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java b/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java index ace93e08..85b9af64 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java @@ -28,12 +28,10 @@ public class CraftDropper extends CraftBlockState implements Dropper { public void drop() { Block block = getBlock(); - synchronized (block) { - if (block.getType() == Material.DROPPER) { - BlockDropper drop = (BlockDropper) net.minecraft.server.Block.DROPPER; + if (block.getType() == Material.DROPPER) { + BlockDropper drop = (BlockDropper) net.minecraft.server.Block.DROPPER; - drop.dispense(world.getHandle(), getX(), getY(), getZ()); - } + drop.dispense(world.getHandle(), getX(), getY(), getZ()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index e4756dcd..d50604d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -8,14 +8,12 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; import org.bukkit.inventory.FurnaceInventory; public class CraftFurnace extends CraftBlockState implements Furnace { - private final CraftWorld world; private final TileEntityFurnace furnace; public CraftFurnace(final Block block) { super(block); - world = (CraftWorld) block.getWorld(); - furnace = (TileEntityFurnace) world.getTileEntityAt(getX(), getY(), getZ()); + furnace = (TileEntityFurnace) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ()); } public FurnaceInventory getInventory() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java b/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java index 6489e153..787b609f 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java @@ -8,14 +8,12 @@ import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.inventory.Inventory; public class CraftHopper extends CraftBlockState implements Hopper { - private final CraftWorld world; private final TileEntityHopper hopper; public CraftHopper(final Block block) { super(block); - world = (CraftWorld) block.getWorld(); - hopper = (TileEntityHopper) world.getTileEntityAt(getX(), getY(), getZ()); + hopper = (TileEntityHopper) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ()); } public Inventory getInventory() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java index 6beaa23b..0cfddf40 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java @@ -39,39 +39,33 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock { public boolean play() { Block block = getBlock(); - synchronized (block) { - if (block.getType() == Material.NOTE_BLOCK) { - note.play(world.getHandle(), getX(), getY(), getZ()); - return true; - } else { - return false; - } + if (block.getType() == Material.NOTE_BLOCK) { + note.play(world.getHandle(), getX(), getY(), getZ()); + return true; + } else { + return false; } } public boolean play(byte instrument, byte note) { Block block = getBlock(); - synchronized (block) { - if (block.getType() == Material.NOTE_BLOCK) { - world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument, note); - return true; - } else { - return false; - } + if (block.getType() == Material.NOTE_BLOCK) { + world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument, note); + return true; + } else { + return false; } } public boolean play(Instrument instrument, Note note) { Block block = getBlock(); - synchronized (block) { - if (block.getType() == Material.NOTE_BLOCK) { - world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument.getType(), note.getId()); - return true; - } else { - return false; - } + if (block.getType() == Material.NOTE_BLOCK) { + world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument.getType(), note.getId()); + return true; + } else { + return false; } } } diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java index 48cf5bac..c896ba26 100644 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java +++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java @@ -57,7 +57,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu if (server != null) { server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false)); } - + chunk.a(queuedChunk.provider, queuedChunk.provider, x, z); } diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java b/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java index 299b1d8a..77f56619 100644 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java @@ -6,10 +6,10 @@ import net.minecraft.server.NBTTagCompound; import net.minecraft.server.World; class QueuedChunk { - long coords; - ChunkRegionLoader loader; - World world; - ChunkProviderServer provider; + final long coords; + final ChunkRegionLoader loader; + final World world; + final ChunkProviderServer provider; NBTTagCompound compound; public QueuedChunk(long coords, ChunkRegionLoader loader, World world, ChunkProviderServer provider) { diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java index 3ab8f3b5..26a2fb89 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java @@ -2,25 +2,24 @@ package org.bukkit.craftbukkit.command; import java.util.EnumMap; import java.util.Map; + import org.fusesource.jansi.Ansi; import org.fusesource.jansi.Ansi.Attribute; -import jline.console.ConsoleReader; import jline.Terminal; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.craftbukkit.CraftServer; public class ColouredConsoleSender extends CraftConsoleCommandSender { - private final ConsoleReader reader; private final Terminal terminal; private final Map<ChatColor, String> replacements = new EnumMap<ChatColor, String>(ChatColor.class); private final ChatColor[] colors = ChatColor.values(); protected ColouredConsoleSender() { super(); - this.reader = ((CraftServer) getServer()).getReader(); - this.terminal = reader.getTerminal(); + this.terminal = ((CraftServer) getServer()).getReader().getTerminal(); replacements.put(ChatColor.BLACK, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLACK).boldOff().toString()); replacements.put(ChatColor.DARK_BLUE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLUE).boldOff().toString()); diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java index 1ccbbf01..832acd84 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java @@ -22,9 +22,6 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc public void sendMessage(String message) { } - public void sendRawMessage(String message) { - } - public void sendMessage(String[] messages) { } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java index b2e7ca5f..9abcf92d 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -21,7 +21,7 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co public void sendMessage(String message) { sendRawMessage(message); } - + public void sendRawMessage(String message) { System.out.println(ChatColor.stripColor(message)); } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java index d4b04712..fec7feeb 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java @@ -11,7 +11,7 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme public void sendMessage(String message) { RemoteControlCommandListener.instance.sendMessage(message + "\n"); // Send a newline after each message, to preserve formatting. } - + public void sendMessage(String[] messages) { for (String message : messages) { sendMessage(message); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java index ecd630c5..ce497001 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java @@ -54,12 +54,12 @@ public class CraftAgeable extends CraftCreature implements Ageable { setAge(6000); } } - + @Override public EntityAgeable getHandle() { return (EntityAgeable) entity; } - + @Override public String toString() { return "CraftAgeable"; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index d0510aff..97f3c1d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -187,7 +187,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } public World getWorld() { - return ((WorldServer) entity.world).getWorld(); + return entity.world.getWorld(); } public boolean teleport(Location location) { @@ -265,7 +265,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } public org.bukkit.entity.Entity getPassenger() { - return isEmpty() ? null : (CraftEntity) getHandle().passenger.getBukkitEntity(); + return isEmpty() ? null : getHandle().passenger.getBukkitEntity(); } public boolean setPassenger(org.bukkit.entity.Entity passenger) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java index 58c28b38..1e432ca0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -15,7 +15,7 @@ public class CraftFish extends AbstractProjectile implements Fish { public LivingEntity getShooter() { if (getHandle().owner != null) { - return (LivingEntity) getHandle().owner.getBukkitEntity(); + return getHandle().owner.getBukkitEntity(); } return null; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 70111e7a..d37d719a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -366,7 +366,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { // To = Players new Location if Teleport is Successful Location to = location; // Create & Call the Teleport Event. - PlayerTeleportEvent event = new PlayerTeleportEvent((Player) this, from, to, cause); + PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause); server.getPluginManager().callEvent(event); // Return False to inform the Plugin that the Teleport was unsuccessful/cancelled. diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index cd5e5932..b60d97b1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -12,7 +12,7 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj } public LivingEntity getShooter() { - if (getHandle().getShooter() instanceof EntityLiving) { + if (getHandle().getShooter() != null) { return (LivingEntity) getHandle().getShooter().getBukkitEntity(); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 4ea9c0c3..34942327 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -76,7 +76,7 @@ public class CraftEventFactory { ChunkCoordinates chunkcoordinates = worldServer.getSpawn(); - int distanceFromSpawn = (int) Math.max(Math.abs(x - chunkcoordinates.x), Math.abs(z - chunkcoordinates.z)); + int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.x), Math.abs(z - chunkcoordinates.z)); return distanceFromSpawn >= spawnSize; } @@ -89,8 +89,8 @@ public class CraftEventFactory { * Block place methods */ public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) { - CraftWorld craftWorld = ((WorldServer) world).getWorld(); - CraftServer craftServer = ((WorldServer) world).getServer(); + CraftWorld craftWorld = world.getWorld(); + CraftServer craftServer = world.getServer(); Player player = (who == null) ? null : (Player) who.getBukkitEntity(); @@ -236,7 +236,7 @@ public class CraftEventFactory { */ public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityHuman tamer) { org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); - org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? (AnimalTamer) tamer.getBukkitEntity() : null); + org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null); CraftServer craftServer = (CraftServer) bukkitEntity.getServer(); entity.persistent = true; @@ -267,7 +267,7 @@ public class CraftEventFactory { ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation()); - ((CraftServer) entity.getServer()).getPluginManager().callEvent(event); + entity.getServer().getPluginManager().callEvent(event); return event; } @@ -329,7 +329,7 @@ public class CraftEventFactory { } public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) { - CraftPlayer entity = (CraftPlayer) victim.getBukkitEntity(); + CraftPlayer entity = victim.getBukkitEntity(); PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage); org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); @@ -433,7 +433,7 @@ public class CraftEventFactory { } public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level) { - FoodLevelChangeEvent event = new FoodLevelChangeEvent((Player) entity.getBukkitEntity(), level); + FoodLevelChangeEvent event = new FoodLevelChangeEvent(entity.getBukkitEntity(), level); entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); return event; } @@ -498,8 +498,8 @@ public class CraftEventFactory { player.playerConnection.handleContainerClose(new Packet101CloseWindow(player.activeContainer.windowId)); } - CraftServer server = ((WorldServer) player.world).getServer(); - CraftPlayer craftPlayer = (CraftPlayer) player.getBukkitEntity(); + CraftServer server = player.world.getServer(); + CraftPlayer craftPlayer = player.getBukkitEntity(); player.activeContainer.transferTo(container, craftPlayer); InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView()); diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 36aa6f82..11e79f54 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -72,7 +72,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { continue; } byte[] secBlkID = new byte[4096]; // Allocate blk ID bytes - byte[] secExtBlkID = (byte[]) null; // Delay getting extended ID nibbles + byte[] secExtBlkID = null; // Delay getting extended ID nibbles short[] bdata = xbtypes[sec]; // Loop through data, 2 blocks at a time for (int i = 0, j = 0; i < bdata.length; i += 2, j++) { @@ -124,7 +124,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { // Loop through sections for (int sec = 0; sec < scnt; sec++) { ChunkSection cs = null; // Add sections when needed - byte[] csbytes = (byte[]) null; + byte[] csbytes = null; for (int cy = 0; cy < 16; cy++) { int cyoff = cy | (sec << 4); diff --git a/src/main/java/org/bukkit/craftbukkit/help/CommandAliasHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/CommandAliasHelpTopic.java index 4dcfef1c..9f2238c9 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/CommandAliasHelpTopic.java +++ b/src/main/java/org/bukkit/craftbukkit/help/CommandAliasHelpTopic.java @@ -8,8 +8,8 @@ import org.bukkit.help.HelpTopic; public class CommandAliasHelpTopic extends HelpTopic { - private String aliasFor; - private HelpMap helpMap; + private final String aliasFor; + private final HelpMap helpMap; public CommandAliasHelpTopic(String alias, String aliasFor, HelpMap helpMap) { this.aliasFor = aliasFor.startsWith("/") ? aliasFor : "/" + aliasFor; diff --git a/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java index 8431b511..6dee2296 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java +++ b/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java @@ -8,16 +8,15 @@ import org.bukkit.help.HelpTopic; * This is a help topic implementation for general topics registered in the help.yml file. */ public class CustomHelpTopic extends HelpTopic { - private final String permissionNode; - + public CustomHelpTopic(String name, String shortText, String fullText, String permissionNode) { this.permissionNode = permissionNode; this.name = name; this.shortText = shortText; this.fullText = shortText + "\n" + fullText; } - + public boolean canSee(CommandSender sender) { if (sender instanceof ConsoleCommandSender) { return true; diff --git a/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java index 538f9b11..2089a5f5 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java +++ b/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java @@ -14,7 +14,7 @@ import java.util.List; public class CustomIndexHelpTopic extends IndexHelpTopic { private List<String> futureTopics; private final HelpMap helpMap; - + public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) { super(name, shortText, permission, new HashSet<HelpTopic>(), preamble); this.helpMap = helpMap; @@ -34,7 +34,7 @@ public class CustomIndexHelpTopic extends IndexHelpTopic { setTopicsCollection(topics); futureTopics = null; } - + return super.getFullText(sender); } } diff --git a/src/main/java/org/bukkit/craftbukkit/help/HelpTopicAmendment.java b/src/main/java/org/bukkit/craftbukkit/help/HelpTopicAmendment.java index 922a3e9a..4f0e00ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/HelpTopicAmendment.java +++ b/src/main/java/org/bukkit/craftbukkit/help/HelpTopicAmendment.java @@ -4,10 +4,10 @@ package org.bukkit.craftbukkit.help; * A HelpTopicAmendment represents the contents of a topic amendment from the help.yml */ public class HelpTopicAmendment { - private String topicName; - private String shortText; - private String fullText; - private String permission; + private final String topicName; + private final String shortText; + private final String fullText; + private final String permission; public HelpTopicAmendment(String topicName, String shortText, String fullText, String permission) { this.fullText = fullText; diff --git a/src/main/java/org/bukkit/craftbukkit/help/MultipleCommandAliasHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/MultipleCommandAliasHelpTopic.java index bd21c233..6f4b22b9 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/MultipleCommandAliasHelpTopic.java +++ b/src/main/java/org/bukkit/craftbukkit/help/MultipleCommandAliasHelpTopic.java @@ -12,7 +12,7 @@ import org.bukkit.help.HelpTopic; */ public class MultipleCommandAliasHelpTopic extends HelpTopic { - private MultipleCommandAlias alias; + private final MultipleCommandAlias alias; public MultipleCommandAliasHelpTopic(MultipleCommandAlias alias) { this.alias = alias; diff --git a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java index d286b1c2..27f9ce9d 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java +++ b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java @@ -145,7 +145,7 @@ public class SimpleHelpMap implements HelpMap { } // Add alias sub-index - Collection<HelpTopic> filteredTopics = Collections2.<HelpTopic>filter(helpTopics.values(), Predicates.instanceOf(CommandAliasHelpTopic.class)); + Collection<HelpTopic> filteredTopics = Collections2.filter(helpTopics.values(), Predicates.instanceOf(CommandAliasHelpTopic.class)); if (!filteredTopics.isEmpty()) { addTopic(new IndexHelpTopic("Aliases", "Lists command aliases", null, filteredTopics)); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 9231bf70..31a29072 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -27,7 +27,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.Material; public class CraftInventory implements Inventory { - protected IInventory inventory; + protected final IInventory inventory; public CraftInventory(IInventory inventory) { this.inventory = inventory; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java index 757c9d44..612a630d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java @@ -127,7 +127,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage } public boolean hasStoredEnchant(Enchantment ench) { - return hasStoredEnchants() ? enchantments.containsKey(ench) : false; + return hasStoredEnchants() && enchantments.containsKey(ench); } public int getStoredEnchantLevel(Enchantment ench) { @@ -155,7 +155,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage } public boolean removeStoredEnchant(Enchantment ench) { - return hasStoredEnchants() ? enchantments.remove(ench) != null : false; + return hasStoredEnchants() && enchantments.remove(ench) != null; } public boolean hasStoredEnchants() { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 519d900e..30916f99 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -303,8 +303,8 @@ class CraftMetaItem implements ItemMeta, Repairable { } NBTTagList tagList = new NBTTagList(key.NBT); - for (int i = 0; i < list.size(); i++) { - tagList.add(new NBTTagString("", list.get(i))); + for (String value : list) { + tagList.add(new NBTTagString("", value)); } return tagList; @@ -370,7 +370,7 @@ class CraftMetaItem implements ItemMeta, Repairable { } public boolean hasEnchant(Enchantment ench) { - return hasEnchants() ? enchantments.containsKey(ench) : false; + return hasEnchants() && enchantments.containsKey(ench); } public int getEnchantLevel(Enchantment ench) { @@ -398,7 +398,7 @@ class CraftMetaItem implements ItemMeta, Repairable { } public boolean removeEnchant(Enchantment ench) { - return hasEnchants() ? enchantments.remove(ench) != null : false; + return hasEnchants() && enchantments.remove(ench) != null; } public boolean hasEnchants() { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java index 0f416a88..4e2e3931 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java @@ -11,11 +11,11 @@ import org.bukkit.inventory.ShapedRecipe; public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { // TODO: Could eventually use this to add a matches() method or some such private ShapedRecipes recipe; - + public CraftShapedRecipe(ItemStack result) { super(result); } - + public CraftShapedRecipe(ItemStack result, ShapedRecipes recipe) { this(result); this.recipe = recipe; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java index f8e864e4..52c9ba9b 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java @@ -10,8 +10,8 @@ import net.minecraft.server.IRecipe; import net.minecraft.server.RecipesFurnace; public class RecipeIterator implements Iterator<Recipe> { - private Iterator<IRecipe> recipes; - private Iterator<Integer> smelting; + private final Iterator<IRecipe> recipes; + private final Iterator<Integer> smelting; private Iterator<?> removeFrom = null; public RecipeIterator() { @@ -35,8 +35,8 @@ public class RecipeIterator implements Iterator<Recipe> { removeFrom = smelting; int id = smelting.next(); CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(id)); - CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(stack, new ItemStack(id, 1, (short) -1)); - return recipe; + + return new CraftFurnaceRecipe(stack, new ItemStack(id, 1, (short) -1)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index 81abeb55..22e00535 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -42,7 +42,7 @@ public class CraftMapRenderer extends MapRenderer { } WorldMapDecoration decoration = (WorldMapDecoration) worldMap.g.get(key); - cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), (byte) (decoration.type)); + cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), decoration.type); } } diff --git a/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java b/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java index 5b484d0d..6f7102f2 100644 --- a/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java +++ b/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java @@ -14,7 +14,7 @@ import java.util.List; */ public class BlockMetadataStore extends MetadataStoreBase<Block> implements MetadataStore<Block> { - private World owningWorld; + private final World owningWorld; /** * Initializes a BlockMetadataStore. diff --git a/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java b/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java index f0279008..8a1024e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java +++ b/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java @@ -77,9 +77,8 @@ public class BukkitDLUpdaterService { connection.setRequestProperty("User-Agent", getUserAgent()); reader = new InputStreamReader(connection.getInputStream()); Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); - ArtifactDetails.ChannelDetails fromJson = gson.fromJson(reader, ArtifactDetails.ChannelDetails.class); - return fromJson; + return gson.fromJson(reader, ArtifactDetails.ChannelDetails.class); } finally { if (reader != null) { reader.close(); |