diff options
Diffstat (limited to 'src/main/java/org')
23 files changed, 42 insertions, 49 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/src/main/java/org/bukkit/craftbukkit/CraftArt.java index 7773a55a..44b88b32 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -67,7 +67,7 @@ public class CraftArt { return null; } - { + static { assert (EnumArt.values().length == 25); assert (Art.values().length == 25); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 314c7323..32c808be 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -20,9 +20,9 @@ import org.bukkit.ChunkSnapshot; public class CraftChunk implements Chunk { private WeakReference<net.minecraft.server.Chunk> weakChunk; - private WorldServer worldServer; - private int x; - private int z; + private final WorldServer worldServer; + private final int x; + private final int z; private static final byte[] emptyData = new byte[2048]; private static final short[] emptyBlockIDs = new short[4096]; private static final byte[] emptySkyLight = new byte[2048]; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index f11f7329..b024f544 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -144,7 +144,7 @@ public final class CraftServer implements Server { private YamlConfiguration configuration; private final Yaml yaml = new Yaml(new SafeConstructor()); private final Map<String, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap(); - private AutoUpdater updater; + private final AutoUpdater updater; private final EntityMetadataStore entityMetadata = new EntityMetadataStore(); private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore(); private final WorldMetadataStore worldMetadata = new WorldMetadataStore(); @@ -353,7 +353,7 @@ public final class CraftServer implements Server { matchedPlayers.add(iterPlayer); break; } - if (iterPlayerName.toLowerCase().indexOf(partialName.toLowerCase()) != -1) { + if (iterPlayerName.toLowerCase().contains(partialName.toLowerCase())) { // Partial match matchedPlayers.add(iterPlayer); } @@ -911,7 +911,7 @@ public final class CraftServer implements Server { commands = ImmutableList.<String>of(section.getString(key)); } - result.put(key, commands.toArray(new String[0])); + result.put(key, commands.toArray(new String[commands.size()])); } } @@ -1146,8 +1146,8 @@ public final class CraftServer implements Server { String[] files = storage.getPlayerDir().list(new DatFileFilter()); Set<OfflinePlayer> players = new HashSet<OfflinePlayer>(); - for (int i = 0; i < files.length; i++) { - players.add(getOfflinePlayer(files[i].substring(0, files[i].length() - 4))); + for (String file : files) { + players.add(getOfflinePlayer(file.substring(0, file.length() - 4))); } players.addAll(Arrays.asList(getOnlinePlayers())); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 33db5ceb..eb6695b6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -437,7 +437,7 @@ public class CraftWorld implements World { } public boolean createExplosion(double x, double y, double z, float power, boolean setFire) { - return world.createExplosion(null, x, y, z, power, setFire).wasCanceled ? false : true; + return !world.createExplosion(null, x, y, z, power, setFire).wasCanceled; } public boolean createExplosion(Location loc, float power) { diff --git a/src/main/java/org/bukkit/craftbukkit/TextWrapper.java b/src/main/java/org/bukkit/craftbukkit/TextWrapper.java index 61384ae1..8c748205 100644 --- a/src/main/java/org/bukkit/craftbukkit/TextWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/TextWrapper.java @@ -10,8 +10,7 @@ public class TextWrapper { String[] lines = text.split("\n"); String lastColor = null; - for (int i = 0; i < lines.length; i++) { - String line = lines[i]; + for (String line : lines) { if (lastColor != null) { line = lastColor + line; } @@ -22,4 +21,4 @@ public class TextWrapper { return output; } -}
\ No newline at end of file +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 8164d7dd..e83eb301 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -22,7 +22,7 @@ public class CraftBlockState implements BlockState { private final int z; protected int type; protected MaterialData data; - protected byte light; + protected final byte light; public CraftBlockState(final Block block) { this.world = (CraftWorld) block.getWorld(); diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java index b6d1747e..b2e7ca5f 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.conversations.ConversationTracker; */ public class CraftConsoleCommandSender extends ServerCommandSender implements ConsoleCommandSender { - protected ConversationTracker conversationTracker = new ConversationTracker(); + protected final ConversationTracker conversationTracker = new ConversationTracker(); protected CraftConsoleCommandSender() { super(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java index 3fe70b4e..b9905dbb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java @@ -16,8 +16,7 @@ public class CraftCreature extends CraftLivingEntity implements Creature { if (target == null) { entity.target = null; } else if (target instanceof CraftLivingEntity) { - EntityLiving victim = ((CraftLivingEntity) target).getHandle(); - entity.target = victim; + entity.target = ((CraftLivingEntity) target).getHandle(); entity.pathEntity = entity.world.findPath(entity, entity.target, 16.0F, true, false, false, true); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 9f055920..6f8bec6d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -36,7 +36,7 @@ import org.bukkit.plugin.Plugin; public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { private CraftInventoryPlayer inventory; - private CraftInventory enderChest; + private final CraftInventory enderChest; protected final PermissibleBase perm = new PermissibleBase(this); private boolean op; private GameMode mode; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index 1612cc4b..049d52ee 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -10,7 +10,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.CraftServer; public class CraftItem extends CraftEntity implements Item { - private EntityItem item; + private final EntityItem item; public CraftItem(CraftServer server, Entity entity, EntityItem item) { super(server, entity); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 7cfca808..81390773 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -31,8 +31,7 @@ public class CraftPainting extends CraftEntity implements Painting { public boolean setArt(Art art, boolean force) { EntityPainting painting = this.getHandle(); EnumArt oldArt = painting.art; - EnumArt newArt = CraftArt.BukkitToNotch(art); - painting.art = newArt; + painting.art = CraftArt.BukkitToNotch(art); painting.setDirection(painting.direction); if (!force && !painting.survives()) { // Revert painting since it doesn't fit diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 50c6875c..ab81041a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -53,9 +53,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private long firstPlayed = 0; private long lastPlayed = 0; private boolean hasPlayedBefore = false; - private ConversationTracker conversationTracker = new ConversationTracker(); - private Set<String> channels = new HashSet<String>(); - private Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap(); + private final ConversationTracker conversationTracker = new ConversationTracker(); + private final Set<String> channels = new HashSet<String>(); + private final Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap(); private int hash = 0; public CraftPlayer(CraftServer server, EntityPlayer entity) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java index e5800d8f..e7338a6c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java @@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.StorageMinecart; public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart { - private CraftInventory inventory; + private final CraftInventory inventory; public CraftStorageMinecart(CraftServer server, EntityMinecart entity) { super(server, entity); diff --git a/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java index 058f6ca6..8431b511 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java +++ b/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java @@ -9,7 +9,7 @@ import org.bukkit.help.HelpTopic; */ public class CustomHelpTopic extends HelpTopic { - private String permissionNode; + private final String permissionNode; public CustomHelpTopic(String name, String shortText, String fullText, String permissionNode) { this.permissionNode = permissionNode; diff --git a/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java index 5da8676c..538f9b11 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java +++ b/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java @@ -13,7 +13,7 @@ import java.util.List; */ public class CustomIndexHelpTopic extends IndexHelpTopic { private List<String> futureTopics; - private HelpMap helpMap; + 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); diff --git a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java index c9b88c7c..12c9dd7b 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java +++ b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java @@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.help; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; -import org.bukkit.ChatColor; import org.bukkit.command.*; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.command.defaults.VanillaCommand; @@ -107,7 +106,7 @@ public class SimpleHelpMap implements HelpMap { // Initialize help topics from the server's command map outer: for (Command command : server.getCommandMap().getCommands()) { if (commandInIgnoredPlugin(command, ignoredPlugins)) { - continue outer; + continue; } // Register a topic diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index dfc15a4a..c576c8c3 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -13,10 +13,10 @@ import net.minecraft.server.Packet100OpenWindow; import net.minecraft.server.Slot; public class CraftContainer extends Container { - private InventoryView view; + private final InventoryView view; private InventoryType cachedType; private String cachedTitle; - private int cachedSize; + private final int cachedSize; public CraftContainer(InventoryView view, int id) { this.view = view; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index 92e1ae9f..81bde2c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -10,7 +10,7 @@ import org.bukkit.inventory.Recipe; import org.bukkit.util.Java15Compat; public class CraftInventoryCrafting extends CraftInventory implements CraftingInventory { - private IInventory resultInventory; + private final IInventory resultInventory; public CraftInventoryCrafting(InventoryCrafting inventory, IInventory resultInventory) { super(inventory); @@ -135,4 +135,4 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn IRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe; return recipe == null ? null : recipe.toBukkitRecipe(); } -}
\ No newline at end of file +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index 7299a168..7256e924 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -26,12 +26,12 @@ public class CraftInventoryCustom extends CraftInventory { } static class MinecraftInventory implements IInventory { - private ItemStack[] items; + private final ItemStack[] items; private int maxStack = MAX_STACK; - private List<HumanEntity> viewers; - private String title; + private final List<HumanEntity> viewers; + private final String title; private InventoryType type; - private InventoryHolder owner; + private final InventoryHolder owner; public MinecraftInventory(InventoryHolder owner, InventoryType type) { this(owner, type.getDefaultSize(), type.getDefaultTitle()); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java index a10bd764..0459f41f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java @@ -8,7 +8,8 @@ import org.bukkit.inventory.ItemStack; import net.minecraft.server.InventoryLargeChest; public class CraftInventoryDoubleChest extends CraftInventory implements DoubleChestInventory { - private CraftInventory left, right; + private final CraftInventory left; + private final CraftInventory right; public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) { super(new InventoryLargeChest("Large chest", left.getInventory(), right.getInventory())); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java index 61e83a84..55df2197 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java @@ -12,9 +12,9 @@ import org.bukkit.inventory.ItemStack; import net.minecraft.server.Container; public class CraftInventoryView extends InventoryView { - private Container container; - private CraftHumanEntity player; - private CraftInventory viewing; + private final Container container; + private final CraftHumanEntity player; + private final CraftInventory viewing; public CraftInventoryView(HumanEntity player, Inventory viewing, Container container) { // TODO: Should we make sure it really IS a CraftHumanEntity first? And a CraftInventory? diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index f2dbfbad..bc0cd876 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -286,9 +286,7 @@ public class CraftScheduler implements BukkitScheduler { } final ArrayList<BukkitTask> pending = new ArrayList<BukkitTask>(); - final Iterator<CraftTask> it = runners.values().iterator(); - while (it.hasNext()) { - final CraftTask task = it.next(); + for (CraftTask task : runners.values()) { if (task.getPeriod() >= -1l) { pending.add(task); } diff --git a/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java b/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java index c54359d3..f0279008 100644 --- a/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java +++ b/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java @@ -39,7 +39,7 @@ public class BukkitDLUpdaterService { return "CraftBukkit/" + BukkitDLUpdaterService.class.getPackage().getImplementationVersion() + "/" + System.getProperty("java.version"); } - public ArtifactDetails fetchArtifact(String slug) throws UnsupportedEncodingException, IOException { + public ArtifactDetails fetchArtifact(String slug) throws IOException { URL url = new URL("http", host, API_PREFIX_ARTIFACT + slug + "/"); InputStreamReader reader = null; @@ -48,9 +48,7 @@ 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 fromJson = gson.fromJson(reader, ArtifactDetails.class); - - return fromJson; + return gson.fromJson(reader, ArtifactDetails.class); } finally { if (reader != null) { reader.close(); @@ -70,7 +68,7 @@ public class BukkitDLUpdaterService { return null; } - public ArtifactDetails.ChannelDetails fetchChannel(String slug) throws UnsupportedEncodingException, IOException { + public ArtifactDetails.ChannelDetails fetchChannel(String slug) throws IOException { URL url = new URL("http", host, API_PREFIX_CHANNEL + slug + "/"); InputStreamReader reader = null; |