diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java index 7773a55a87..44b88b3237 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 314c7323a0..32c808bec9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -20,9 +20,9 @@ import org.bukkit.ChunkSnapshot; public class CraftChunk implements Chunk { private WeakReference 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/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index f11f7329e3..b024f54436 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/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 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.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 players = new HashSet(); - 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/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 33db5cebd8..eb6695b653 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/TextWrapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/TextWrapper.java index 61384ae156..8c748205e4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/TextWrapper.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 8164d7dd1b..e83eb3017e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java index b6d1747e1e..b2e7ca5ff0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java index 3fe70b4eed..b9905dbbe0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 9f055920e2..6f8bec6d67 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index 1612cc4be6..049d52ee85 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 7cfca808f6..8139077336 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 50c6875c80..ab81041a1f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/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 channels = new HashSet(); - private Map hiddenPlayers = new MapMaker().softValues().makeMap(); + private final ConversationTracker conversationTracker = new ConversationTracker(); + private final Set channels = new HashSet(); + private final Map hiddenPlayers = new MapMaker().softValues().makeMap(); private int hash = 0; public CraftPlayer(CraftServer server, EntityPlayer entity) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java index e5800d8fe4..e7338a6c5d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java index 058f6ca6f8..8431b5111f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomHelpTopic.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java index 5da8676c4d..538f9b11b4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java @@ -13,7 +13,7 @@ import java.util.List; */ public class CustomIndexHelpTopic extends IndexHelpTopic { private List futureTopics; - private HelpMap helpMap; + private final HelpMap helpMap; public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List futureTopics, String preamble) { super(name, shortText, permission, new HashSet(), preamble); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java index c9b88c7c0c..12c9dd7b8a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index dfc15a4aa5..c576c8c31b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index 92e1ae9f49..81bde2c783 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index 7299a16848..7256e9241c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/paper-server/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 viewers; - private String title; + private final List 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/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java index a10bd76403..0459f41ffa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java index 61e83a84d2..55df2197a7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index f2dbfbadd6..bc0cd8761b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -286,9 +286,7 @@ public class CraftScheduler implements BukkitScheduler { } final ArrayList pending = new ArrayList(); - final Iterator 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/paper-server/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java b/paper-server/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java index c54359d388..f0279008c9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java +++ b/paper-server/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; diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterServiceTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterServiceTest.java index 9f69de0c90..342949b78b 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterServiceTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterServiceTest.java @@ -11,21 +11,21 @@ import org.junit.Test; @Ignore ("useful tests, but not necessary to run on each compile") public class BukkitDLUpdaterServiceTest { @Test(expected=IOException.class) - public void testHostNotFound() throws UnsupportedEncodingException, IOException { + public void testHostNotFound() throws IOException { BukkitDLUpdaterService service = new BukkitDLUpdaterService("404.example.org"); service.fetchArtifact("rb"); } @Test(expected=FileNotFoundException.class) - public void testArtifactNotFound() throws UnsupportedEncodingException, IOException { + public void testArtifactNotFound() throws IOException { BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org"); service.fetchArtifact("meep"); } @Test - public void testArtifactExists() throws UnsupportedEncodingException, IOException { + public void testArtifactExists() throws IOException { BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org"); assertNotNull(service.fetchArtifact("latest-dev"));