From 0958b57e4663baf181139578bfdd0f38ea50b81a Mon Sep 17 00:00:00 2001 From: MattBDev Date: Thu, 12 May 2016 17:09:35 -0400 Subject: [PATCH] Tidy code. --- .../plotsquared/bukkit/chat/FancyMessage.java | 2 +- .../bukkit/chat/TextualComponent.java | 2 +- .../bukkit/commands/DebugUUID.java | 2 +- .../database/plotme/LikePlotMeConverter.java | 4 +-- .../database/plotme/PlotMeConnector_017.java | 7 ++-- .../bukkit/generator/BukkitPlotGenerator.java | 4 +-- .../bukkit/listeners/ChunkListener.java | 2 +- .../bukkit/listeners/ForceFieldListener.java | 2 +- .../bukkit/titles/DefaultTitle.java | 2 +- .../bukkit/titles/DefaultTitle_183.java | 2 +- .../bukkit/titles/DefaultTitle_19.java | 2 +- .../com/plotsquared/bukkit/util/Metrics.java | 5 +-- .../plotsquared/bukkit/util/NbtFactory.java | 17 ++++----- .../plotsquared/bukkit/util/SendChunk.java | 7 ++-- .../bukkit/uuid/SQLUUIDHandler.java | 6 ++-- .../configuration/ConfigurationOptions.java | 8 ++--- .../file/FileConfigurationOptions.java | 5 +-- .../intellectualcrafters/jnbt/ListTag.java | 2 +- .../jnbt/NBTInputStream.java | 2 +- .../jnbt/NBTOutputStream.java | 2 +- .../intellectualcrafters/json/JSONArray.java | 16 ++++----- .../com/intellectualcrafters/json/XML.java | 6 ++-- .../intellectualcrafters/json/XMLTokener.java | 36 +++++++++---------- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugExec.java | 2 +- .../plot/commands/DebugPaste.java | 16 ++++----- .../plot/commands/DebugRoadRegen.java | 4 +-- .../plot/commands/FlagCmd.java | 12 +++---- .../plot/commands/Inbox.java | 16 ++++----- .../plot/commands/RegenAllRoads.java | 2 +- .../plot/commands/Save.java | 2 +- .../plot/commands/Set.java | 2 +- .../plot/commands/SubCommand.java | 2 +- .../plot/commands/Update.java | 2 +- .../plot/commands/Visit.java | 2 +- .../plot/config/ConfigurationNode.java | 10 +++--- .../plot/database/DBFunc.java | 3 +- .../plot/database/Database.java | 5 +-- .../plot/database/MySQL.java | 6 ++-- .../plot/database/SQLManager.java | 4 +-- .../plot/flag/DoubleFlag.java | 2 +- .../plot/flag/FlagManager.java | 11 +++--- .../plot/flag/IntegerFlag.java | 2 +- .../plot/generator/SquarePlotWorld.java | 2 +- .../intellectualcrafters/plot/object/BO3.java | 10 +++--- .../plot/util/BO3Handler.java | 2 +- .../plot/util/EventUtil.java | 14 ++++---- .../plot/util/MainUtil.java | 25 +++++++------ .../plot/util/SchematicHandler.java | 4 +-- .../plot/util/UUIDHandler.java | 6 ++-- .../plot/util/WorldUtil.java | 2 +- .../plotsquared/listener/PlotListener.java | 17 ++++----- .../com/plotsquared/sponge/SpongeMain.java | 14 ++++---- .../sponge/util/SpongeCommand.java | 2 +- 54 files changed, 167 insertions(+), 181 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java index f3cd5454f..0c6a23eac 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java @@ -704,7 +704,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< try { writeJson(json); json.close(); - } catch (IOException e) { + } catch (IOException ignored) { throw new RuntimeException("invalid message"); } this.jsonString = string.toString(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java index 08a62255e..de71c473e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java @@ -284,7 +284,7 @@ public abstract class TextualComponent implements Cloneable { @Override @SuppressWarnings("serial") public Map serialize() { - return new java.util.HashMap() { + return new HashMap() { { put("key", getKey()); for (Map.Entry valEntry : getValue().entrySet()) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java b/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java index 7e738bae2..15bfafbb6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java @@ -67,7 +67,7 @@ public class DebugUUID extends SubCommand { try { Class clazz = Class.forName(args[0]); newWrapper = (UUIDWrapper) clazz.newInstance(); - } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { + } catch (ClassNotFoundException | IllegalAccessException | InstantiationException ignored) { MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert "); return false; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java index 97ed3bc3f..1194a573b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java @@ -94,9 +94,7 @@ public class LikePlotMeConverter { content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared"); content = content.replaceAll("PlotMe", "PlotSquared"); Files.write(path, content.getBytes(StandardCharsets.UTF_8)); - } catch (IOException ignored) { - //ignored - } + } catch (IOException ignored) {} } public boolean run(APlotMeConnector connector) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java index c7180127b..7388e9861 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java @@ -41,9 +41,8 @@ public class PlotMeConnector_017 extends APlotMeConnector { } return new SQLite(dataFolder + File.separator + "plots.db").openConnection(); } - } catch (SQLException | ClassNotFoundException ignored) { - //ignored - ignored.printStackTrace(); + } catch (SQLException | ClassNotFoundException e) { + e.printStackTrace(); } return null; } @@ -116,7 +115,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { } } if (owner == null) { - PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); + PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + '\''); continue; } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index d4af8e08a..bde42e9fc 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -143,9 +143,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap if (data != null) { return; } - } catch (Throwable e) { - //ignored - } + } catch (Throwable ignored) {} // Populator spillage short[][] tmp = cg.generateExtBlockSections(w, r, result.getX(), result.getZ(), grid); if (tmp != null) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java index 8a1db2547..cbf45c664 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java @@ -49,7 +49,7 @@ public class ChunkListener implements Listener { RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); this.mustSave = classChunk.getField("mustSave"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); - } catch (Throwable e) { + } catch (Throwable ignored) { PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc"); Settings.CHUNK_PROCESSOR_GC = false; Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE = false; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java index b6b89b17c..ed08bfa7e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java @@ -36,10 +36,10 @@ public class ForceFieldListener implements Listener { private PlotPlayer hasNearbyPermitted(Player player, Plot plot) { for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { - PlotPlayer pp; if (!(entity instanceof Player)) { continue; } + PlotPlayer pp; if ((pp = BukkitUtil.getPlayer((Player) entity)) == null) { continue; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle.java index d830f2fd6..8a0ead590 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle.java @@ -11,7 +11,7 @@ public class DefaultTitle extends AbstractTitle { try { DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out); title.send(((BukkitPlayer) player).player); - } catch (Throwable e) { + } catch (Exception ignored) { AbstractTitle.TITLE_CLASS = new DefaultTitle_183(); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java index 386fdb3ba..46a81a306 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java @@ -11,7 +11,7 @@ public class DefaultTitle_183 extends AbstractTitle { try { DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out); title.send(((BukkitPlayer) player).player); - } catch (Exception e) { + } catch (Exception ignored) { AbstractTitle.TITLE_CLASS = new HackTitle(); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java index d59c86556..d4e68b71f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java @@ -19,7 +19,7 @@ public class DefaultTitle_19 extends AbstractTitle { playerObj.sendTitle("", ""); } }, delay * 20); - } catch (Throwable e) { + } catch (Throwable ignored) { AbstractTitle.TITLE_CLASS = new DefaultTitle(); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java index 151678f28..aee5807e7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java @@ -255,8 +255,6 @@ public class Metrics { /** * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. - * - * @throws java.io.IOException */ public void enable() { // Enable Task, if it is not running @@ -267,7 +265,6 @@ public class Metrics { /** * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. - * */ public void disable() { // Disable Task, if it is running @@ -499,7 +496,7 @@ public class Metrics { /** * Gets an unmodifiable set of the plotter objects in the graph * - * @return an unmodifiable {@link java.util.Set} of the plotter objects + * @return an unmodifiable {@link Set} of the plotter objects */ public Set getPlotters() { return Collections.unmodifiableSet(this.plotters); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java index bf365ac73..66c5368ec 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java @@ -20,6 +20,7 @@ import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutput; import java.io.DataOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -160,7 +161,7 @@ public class NbtFactory { /** * Load the content of a file from a stream. * - * Use {@link Files#newInputStreamSupplier(java.io.File)} to provide a stream from a file. + * Use {@link Files#newInputStreamSupplier(File)} to provide a stream from a file. * @param stream - the stream supplier. * @param option - whether or not to decompress the input stream. * @return The decoded NBT compound. @@ -195,7 +196,7 @@ public class NbtFactory { /** * Save the content of a NBT compound to a stream. * - * Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a stream supplier to a file. + * Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file. * @param source - the NBT compound to save. * @param stream - the stream. * @param option - whether or not to compress the output. @@ -284,7 +285,7 @@ public class NbtFactory { Constructor caller = INSTANCE.CRAFT_STACK.getDeclaredConstructor(ItemStack.class); caller.setAccessible(true); return (ItemStack) caller.newInstance(stack); - } catch (Exception e) { + } catch (Exception ignored) { throw new IllegalStateException("Unable to convert " + stack + " + to a CraftItemStack."); } } @@ -396,9 +397,7 @@ public class NbtFactory { try { this.STREAM_TOOLS = loader.loadClass(nmsPackage + ".NBTCompressedStreamTools"); this.READ_LIMITER_CLASS = loader.loadClass(nmsPackage + ".NBTReadLimiter"); - } catch (ClassNotFoundException e) { - // Ignore - we will detect this later - } + } catch (ClassNotFoundException ignored) {} } private String getPackageName() { @@ -435,12 +434,10 @@ public class NbtFactory { if (value instanceof Wrapper) { return ((Wrapper) value).getHandle(); - } else if (value instanceof List) { throw new IllegalArgumentException("Can only insert a WrappedList."); } else if (value instanceof Map) { throw new IllegalArgumentException("Can only insert a WrappedCompound."); - } else { return createNbtTag(getPrimitiveType(value), value); } @@ -652,7 +649,7 @@ public class NbtFactory { * All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following: *
    *
  • Primitive types
  • - *
  • {@link java.lang.String String}
  • + *
  • {@link String String}
  • *
  • {@link NbtList}
  • *
  • {@link NbtCompound}
  • *
@@ -773,7 +770,7 @@ public class NbtFactory { /** * Save the content of a NBT compound to a stream. *

- * Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a stream supplier to a file. + * Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file. * @param stream - the output stream. * @param option - whether or not to compress the output. * @throws IOException If anything went wrong. diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java index d597ddf9f..a49ce95de 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java @@ -51,7 +51,6 @@ public class SendChunk { this.methodInitLighting = classChunk.getMethod("initLighting"); RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk"); //TODO in 1.7.10 this is PacketPlayOutMapChunk(Chunk chunk, boolean flag, int i, int version) - this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class); if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 4)) { this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class); } else { @@ -65,7 +64,7 @@ public class SendChunk { } public void sendChunk(Collection input) { - HashSet chunks = new HashSet(input); + HashSet chunks = new HashSet<>(input); HashMap> map = new HashMap<>(); int view = Bukkit.getServer().getViewDistance(); for (Chunk chunk : chunks) { @@ -126,9 +125,9 @@ public class SendChunk { public void run() { try { chunk.unload(true, false); - } catch (Throwable e) { + } catch (Throwable ignored) { String worldName = chunk.getWorld().getName(); - PS.debug("$4Could not save chunk: " + worldName + ";" + chunk.getX() + ";" + chunk.getZ()); + PS.debug("$4Could not save chunk: " + worldName + ';' + chunk.getX() + ";" + chunk.getZ()); PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)"); PS.debug("$3 - $4" + worldName + "/level.dat or " + worldName + "/level_old.dat may be corrupt (try repairing or removing these)"); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java index a7ec204c2..097196025 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java @@ -50,7 +50,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { try (PreparedStatement stmt = getConnection().prepareStatement( "CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username)" - + ")")) { + + ')')) { stmt.execute(); } catch (SQLException e) { e.printStackTrace(); @@ -176,7 +176,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { String id = (String) jsonProfile.get("id"); String name = (String) jsonProfile.get("name"); ifFetch.value = UUID.fromString( - id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id + id.substring(0, 8) + '-' + id.substring(8, 12) + '-' + id.substring(12, 16) + '-' + id.substring(16, 20) + '-' + id .substring(20, 32)); } catch (IOException | ParseException e) { e.printStackTrace(); @@ -231,7 +231,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { statement.setString(1, name.value); statement.setString(2, uuid.toString()); statement.execute(); - PS.debug(C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + "'"); + PS.debug(C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + '\''); } catch (SQLException e) { e.printStackTrace(); } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java index 067493ee5..4a594be0a 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java @@ -57,9 +57,9 @@ class ConfigurationOptions { * If this is true, all values in the default Configuration will be * directly copied, making it impossible to distinguish between values * that were set and values that are provided by default. As a result, - * {@link ConfigurationSection#contains(java.lang.String)} will always + * {@link ConfigurationSection#contains(String)} will always * return the same value as {@link - * ConfigurationSection#isSet(java.lang.String)}. The default value is + * ConfigurationSection#isSet(String)}. The default value is * false. * * @return Whether or not defaults are directly copied @@ -75,9 +75,9 @@ class ConfigurationOptions { * If this is true, all values in the default Configuration will be * directly copied, making it impossible to distinguish between values * that were set and values that are provided by default. As a result, - * {@link ConfigurationSection#contains(java.lang.String)} will always + * {@link ConfigurationSection#contains(String)} will always * return the same value as {@link - * ConfigurationSection#isSet(java.lang.String)}. The default value is + * ConfigurationSection#isSet(String)}. The default value is * false. * * @param value Whether or not defaults are directly copied diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java index 8c3d830a3..01eb1bf48 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java @@ -1,5 +1,6 @@ package com.intellectualcrafters.configuration.file; +import com.intellectualcrafters.configuration.Configuration; import com.intellectualcrafters.configuration.MemoryConfiguration; import com.intellectualcrafters.configuration.MemoryConfigurationOptions; @@ -75,7 +76,7 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { *

* If this is true, if a default {@link FileConfiguration} is passed to * {@link - * FileConfiguration#setDefaults(com.intellectualcrafters.configuration.Configuration)} + * FileConfiguration#setDefaults(Configuration)} * then upon saving it will use the header from that config, instead of * the one provided here. *

@@ -97,7 +98,7 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { *

* If this is true, if a default {@link FileConfiguration} is passed to * {@link - * FileConfiguration#setDefaults(com.intellectualcrafters.configuration.Configuration)} + * FileConfiguration#setDefaults(Configuration)} * then upon saving it will use the header from that config, instead of * the one provided here. *

diff --git a/Core/src/main/java/com/intellectualcrafters/jnbt/ListTag.java b/Core/src/main/java/com/intellectualcrafters/jnbt/ListTag.java index c81add4ec..a68144346 100644 --- a/Core/src/main/java/com/intellectualcrafters/jnbt/ListTag.java +++ b/Core/src/main/java/com/intellectualcrafters/jnbt/ListTag.java @@ -75,7 +75,7 @@ public final class ListTag extends Tag { public Tag getIfExists(int index) { try { return this.value.get(index); - } catch (NoSuchElementException e) { + } catch (NoSuchElementException ignored) { return null; } } diff --git a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java index 61bd3088c..622a1c5fd 100644 --- a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java +++ b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java @@ -181,7 +181,7 @@ public final class NBTInputStream implements Closeable { } return new IntArrayTag(name, data); default: - throw new IOException("Invalid tag type: " + type + "."); + throw new IOException("Invalid tag type: " + type + '.'); } } diff --git a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java index 7aa117761..d5a052778 100644 --- a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -100,7 +100,7 @@ public final class NBTOutputStream implements Closeable { writeIntArrayTagPayload((IntArrayTag) tag); break; default: - throw new IOException("Invalid tag type: " + type + "."); + throw new IOException("Invalid tag type: " + type + '.'); } } diff --git a/Core/src/main/java/com/intellectualcrafters/json/JSONArray.java b/Core/src/main/java/com/intellectualcrafters/json/JSONArray.java index 19130687a..d46fdc3d9 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/JSONArray.java +++ b/Core/src/main/java/com/intellectualcrafters/json/JSONArray.java @@ -179,7 +179,7 @@ public class JSONArray { Object object = get(index); try { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { throw new JSONException("JSONArray[" + index + "] is not a number."); } } @@ -197,7 +197,7 @@ public class JSONArray { Object object = get(index); try { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { throw new JSONException("JSONArray[" + index + "] is not a number."); } } @@ -249,7 +249,7 @@ public class JSONArray { Object object = get(index); try { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { throw new JSONException("JSONArray[" + index + "] is not a number."); } } @@ -348,7 +348,7 @@ public class JSONArray { public boolean optBoolean(int index, boolean defaultValue) { try { return getBoolean(index); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -377,7 +377,7 @@ public class JSONArray { public double optDouble(int index, double defaultValue) { try { return getDouble(index); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -406,7 +406,7 @@ public class JSONArray { public int optInt(int index, int defaultValue) { try { return getInt(index); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -460,7 +460,7 @@ public class JSONArray { public long optLong(int index, long defaultValue) { try { return getLong(index); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -778,7 +778,7 @@ public class JSONArray { public String toString() { try { return this.toString(0); - } catch (JSONException e) { + } catch (JSONException ignored) { return null; } } diff --git a/Core/src/main/java/com/intellectualcrafters/json/XML.java b/Core/src/main/java/com/intellectualcrafters/json/XML.java index 5386b0b62..58ecb4407 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/XML.java +++ b/Core/src/main/java/com/intellectualcrafters/json/XML.java @@ -61,7 +61,7 @@ class XML { } for (char c : string.toCharArray()) { if (Character.isWhitespace(c)) { - throw new JSONException("'" + string + "' contains a space character."); + throw new JSONException('\'' + string + "' contains a space character."); } } } @@ -369,8 +369,8 @@ class XML { return sb.toString(); } else { string = escape(object.toString()); - return (tagName == null) ? "\"" + string + "\"" : - string.isEmpty() ? "<" + tagName + "/>" : "<" + tagName + ">" + string + ""; + return (tagName == null) ? '"' + string + '"' : + string.isEmpty() ? '<' + tagName + "/>" : '<' + tagName + '>' + string + "'; } } } diff --git a/Core/src/main/java/com/intellectualcrafters/json/XMLTokener.java b/Core/src/main/java/com/intellectualcrafters/json/XMLTokener.java index c7751ebdd..51f7ff639 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/XMLTokener.java +++ b/Core/src/main/java/com/intellectualcrafters/json/XMLTokener.java @@ -1,5 +1,7 @@ package com.intellectualcrafters.json; +import java.util.HashMap; + /** * The XMLTokener extends the JSONTokener to provide additional methods for the parsing of XML texts. * @@ -10,9 +12,9 @@ public class XMLTokener extends JSONTokener { /** * The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot. */ - public static final java.util.HashMap entity; + public static final HashMap entity; static { - entity = new java.util.HashMap(8); + entity = new HashMap<>(8); entity.put("amp", XML.AMP); entity.put("apos", XML.APOS); entity.put("gt", XML.GT); @@ -37,16 +39,14 @@ public class XMLTokener extends JSONTokener { * @throws JSONException If the ]]> is not found. */ public String nextCDATA() throws JSONException { - char c; - int i; final StringBuilder sb = new StringBuilder(); for (;;) { - c = next(); + char c = next(); if (end()) { throw syntaxError("Unclosed CDATA"); } sb.append(c); - i = sb.length() - 3; + int i = sb.length() - 3; if ((i >= 0) && (sb.charAt(i) == ']') && (sb.charAt(i + 1) == ']') && (sb.charAt(i + 2) == '>')) { sb.setLength(i); return sb.toString(); @@ -64,7 +64,6 @@ public class XMLTokener extends JSONTokener { */ public Object nextContent() throws JSONException { char c; - StringBuilder sb; do { c = next(); } while (Character.isWhitespace(c)); @@ -74,14 +73,14 @@ public class XMLTokener extends JSONTokener { if (c == '<') { return XML.LT; } - sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); for (;;) { if ((c == '<') || (c == 0)) { back(); return sb.toString().trim(); } if (c == '&') { - sb.append(nextEntity(c)); + sb.append(nextEntity('&')); } else { sb.append(c); } @@ -113,7 +112,7 @@ public class XMLTokener extends JSONTokener { } final String string = sb.toString(); final Object object = entity.get(string); - return object != null ? object : ampersand + string + ";"; + return object != null ? object : ampersand + string + ';'; } /** @@ -126,10 +125,10 @@ public class XMLTokener extends JSONTokener { */ public Object nextMeta() throws JSONException { char c; - char q; do { c = next(); } while (Character.isWhitespace(c)); + char q; switch (c) { case 0: throw syntaxError("Misshaped meta tag"); @@ -190,11 +189,11 @@ public class XMLTokener extends JSONTokener { */ public Object nextToken() throws JSONException { char c; - char q; - StringBuilder sb; do { c = next(); } while (Character.isWhitespace(c)); + char q; + StringBuilder sb; switch (c) { case 0: throw syntaxError("Misshaped element"); @@ -224,7 +223,7 @@ public class XMLTokener extends JSONTokener { return sb.toString(); } if (c == '&') { - sb.append(nextEntity(c)); + sb.append(nextEntity('&')); } else { sb.append(c); } @@ -268,11 +267,8 @@ public class XMLTokener extends JSONTokener { * @throws JSONException */ public boolean skipPast(final String to) throws JSONException { - boolean b; char c; int i; - int j; - int offset = 0; final int length = to.length(); final char[] circle = new char[length]; /* @@ -287,9 +283,9 @@ public class XMLTokener extends JSONTokener { circle[i] = c; } /* We will loop, possibly for all of the remaining characters. */ - for (;;) { - j = offset; - b = true; + for (int offset = 0; ;) { + int j = offset; + boolean b = true; /* Compare the circle buffer with the to string. */ for (i = 0; i < length; i += 1) { if (circle[j] != to.charAt(i)) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 104920752..35b4591a8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -51,7 +51,7 @@ public class DebugClaimTest extends SubCommand { args[2].split(";"); min = PlotId.fromString(args[1]); max = PlotId.fromString(args[2]); - } catch (Exception e) { + } catch (Exception ignored) { return !MainUtil.sendMessage(plr, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion " + "will only check the plots in the selected area."); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 47ae56c09..85a4bf1e5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -187,7 +187,7 @@ public class DebugExec extends SubCommand { double threshold; try { threshold = Integer.parseInt(args[1]) / 100d; - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { MainUtil.sendMessage(player, "$2Invalid threshold: " + args[1]); MainUtil.sendMessage(player, "$1 $2= $1The percentage of plots you want to clear as a number between 0 - 100"); return false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java index 87f2cddfb..960998945 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java @@ -30,7 +30,7 @@ public class DebugPaste extends SubCommand { String latestLOG; try { latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log")); - } catch (IOException e) { + } catch (IOException ignored) { MainUtil.sendMessage(plr, "&clatest.log is too big to be pasted, will ignore"); latestLOG = "too big :("; } @@ -38,12 +38,12 @@ public class DebugPaste extends SubCommand { b.append( "# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your " + "problem\n\n# We will start with some informational files\n"); - b.append("links.settings_yml: ").append(settingsYML).append("\n"); - b.append("links.latest_log: ").append(latestLOG).append("\n"); + b.append("links.settings_yml: ").append(settingsYML).append('\n'); + b.append("links.latest_log: ").append(latestLOG).append('\n'); b.append("\n# Server Information\n"); int[] sVersion = PS.get().IMP.getServerVersion(); - b.append("version.server: ").append(sVersion[0]).append('.').append(sVersion[1]).append('.').append(sVersion[2]).append("\n"); - b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(";").append(!Settings.OFFLINE_MODE).append("\n"); + b.append("version.server: ").append(sVersion[0]).append('.').append(sVersion[1]).append('.').append(sVersion[2]).append('\n'); + b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';').append(!Settings.OFFLINE_MODE).append('\n'); b.append("plugins:"); for (String id : PS.get().IMP.getPluginIds()) { String[] split = id.split(":"); @@ -51,13 +51,13 @@ public class DebugPaste extends SubCommand { String enabled = split.length == 2 ? split[1] : "unknown"; String name = split2[0]; String version = split2.length == 2 ? split2[1] : "unknown"; - b.append("\n ").append(name).append(":\n ").append("version: '").append(version).append("'").append("\n enabled: ") + b.append("\n ").append(name).append(":\n ").append("version: '").append(version).append('\'').append("\n enabled: ") .append(enabled); } b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n"); Runtime runtime = Runtime.getRuntime(); - b.append("memory.free: ").append(runtime.freeMemory()).append("\n"); - b.append("memory.max: ").append(runtime.maxMemory()).append("\n"); + b.append("memory.free: ").append(runtime.freeMemory()).append('\n'); + b.append("memory.max: ").append(runtime.maxMemory()).append('\n'); b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n"); b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n"); b.append("java.version: '").append(System.getProperty("java.version")).append("'\n"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index 652c386c4..141f71315 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -37,7 +37,7 @@ public class DebugRoadRegen extends SubCommand { if (MathMan.isInteger(args[0])) { try { extend = Integer.parseInt(args[0]); - } catch (Exception e) { + } catch (NumberFormatException ignored) { C.NOT_VALID_NUMBER.send(player, "(0, )"); return false; } @@ -45,7 +45,7 @@ public class DebugRoadRegen extends SubCommand { } boolean result = HybridUtils.manager.regenerateRoad(plotworld, chunk, extend); MainUtil.sendMessage(player, - "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed")); + "&6Regenerating chunk: " + chunk.x + ',' + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed")); MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads"); } else { HybridPlotManager manager = (HybridPlotManager) plotworld.getPlotManager(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index d8dc726c4..8a187c314 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -95,8 +95,8 @@ public class FlagCmd extends SubCommand { return false; } String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " "); - if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase())) { - MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase()); + if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + value.toLowerCase())) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + value.toLowerCase()); return false; } Object parsed = flag.parseValue(value); @@ -127,8 +127,8 @@ public class FlagCmd extends SubCommand { return false; } for (String entry : args[2].split(",")) { - if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) { - MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry); + if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + entry)) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + entry); return false; } } @@ -167,8 +167,8 @@ public class FlagCmd extends SubCommand { return false; } for (String entry : args[2].split(",")) { - if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) { - MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry); + if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + entry)) { + MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + entry); return false; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index bac2b4a1c..a23cb965c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -47,7 +47,7 @@ public class Inbox extends SubCommand { StringBuilder string = new StringBuilder(); string.append(StringMan .replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") - + "\n"); + + '\n'); // This might work xD for (int x = page * 12; x < max; x++) { @@ -58,9 +58,8 @@ public class Inbox extends SubCommand { } else { color = "&7"; } - string.append( - "&8[&7#" + (x + 1) + "&8][&7" + comment.world + ";" + comment.id + "&8][&6" + comment.senderName + "&8]" + color + comment.comment - + "\n"); + string.append("&8[&7#").append(x + 1).append("&8][&7").append(comment.world).append(';').append(comment.id).append("&8][&6") + .append(comment.senderName).append("&8]").append(color).append(comment.comment).append('\n'); } MainUtil.sendMessage(player, string.toString()); } @@ -71,7 +70,8 @@ public class Inbox extends SubCommand { if (plot == null) { sendMessage(player, C.NOT_IN_PLOT); return false; - } else if (!plot.hasOwner()) { + } + if (!plot.hasOwner()) { sendMessage(player, C.PLOT_UNOWNED); return false; } @@ -98,7 +98,7 @@ public class Inbox extends SubCommand { } else { color = ""; } - sendMessage(player, C.INBOX_ITEM, color + inbox.toString() + " (" + total + "/" + unread + ")"); + sendMessage(player, C.INBOX_ITEM, color + inbox.toString() + " (" + total + '/' + unread + ')'); return; } } @@ -135,7 +135,7 @@ public class Inbox extends SubCommand { sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + ""); return false; } - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete "); return false; } @@ -171,7 +171,7 @@ public class Inbox extends SubCommand { default: try { page = Integer.parseInt(args[1]); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete |clear|page]"); return false; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index d33726f07..dd578c76f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -31,7 +31,7 @@ public class RegenAllRoads extends SubCommand { if (args.length == 2) { try { height = Integer.parseInt(args[1]); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads [height]"); return false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java index e19619a2f..828864d9c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java @@ -68,7 +68,7 @@ public class Save extends SubCommand { int size = (corners[1].getX() - corners[0].getX()) + 1; PlotId id = plot.getId(); String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", ""); - final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name; + final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size + '_' + name; UUID uuid = plr.getUUID(); SchematicHandler.manager.upload(value, uuid, file, new RunnableVal() { @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java index d982b77dc..bed827fd0 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -101,7 +101,7 @@ public class Set extends SubCommand { } } } - } catch (Exception e2) { + } catch (Exception ignored) { MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, material); return false; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 77a107fcb..aa7222719 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -9,7 +9,7 @@ import com.plotsquared.general.commands.Command; /** * SubCommand class - * @see com.plotsquared.general.commands.Command(com.plotsquared.general.commands.Command, boolean) + * @see Command(Command, boolean) * @Deprecated In favor of normal Command class */ public abstract class SubCommand extends Command { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java index f9dd378dc..2f1b5960a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java @@ -27,7 +27,7 @@ public class Update extends SubCommand { } else if (args.length == 1) { try { url = new URL(args[0]); - } catch (MalformedURLException e) { + } catch (MalformedURLException ignored) { MainUtil.sendMessage(plr, "&cInvalid URL: " + args[0]); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]"); return false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index b749580e6..b73867b71 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -89,7 +89,7 @@ public class Visit extends SubCommand { } } if (page < 1 || page > unsorted.size()) { - sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ")"); + sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ')'); return false; } List plots = PS.get().sortPlotsByTemp(unsorted); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java b/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java index 59197c9a7..5b5cc1456 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java @@ -35,7 +35,7 @@ public class ConfigurationNode { try { Object result = this.type.parseString(string); return result != null; - } catch (Exception e) { + } catch (Exception ignored) { return false; } } @@ -51,13 +51,15 @@ public class ConfigurationNode { public Object getValue() { if (this.value instanceof String[]) { return Arrays.asList((String[]) this.value); - } else if (this.value instanceof Object[]) { - List values = new ArrayList(); + } + if (this.value instanceof Object[]) { + List values = new ArrayList<>(); for (Object value : (Object[]) this.value) { values.add(value.toString()); } return values; - } else if (this.value instanceof PlotBlock) { + } + if (this.value instanceof PlotBlock) { return this.value.toString(); } return this.value; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/Core/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index fe57e3cc4..61351d08d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -11,7 +11,6 @@ import com.intellectualcrafters.plot.object.comment.PlotComment; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Set; @@ -58,7 +57,7 @@ public class DBFunc { } } return false; - } catch (SQLException e) { + } catch (SQLException ignored) { return false; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/Database.java b/Core/src/main/java/com/intellectualcrafters/plot/database/Database.java index d4d87b2ea..23982ede9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/Database.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/Database.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.database; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; /** * Abstract Database class, serves as a base for any connection method (MySQL, SQLite, etc.) @@ -64,12 +65,12 @@ public abstract class Database { /** * Executes an Update SQL Query. - * See {@link java.sql.Statement#executeUpdate(String)}. + * See {@link Statement#executeUpdate(String)}. * If the connection is closed, it will be opened. * * @param query Query to be run * - * @return Result Code, see {@link java.sql.Statement#executeUpdate(String)} + * @return Result Code, see {@link Statement#executeUpdate(String)} * * @throws SQLException If the query cannot be executed * @throws ClassNotFoundException If the driver cannot be found; see {@link #openConnection()} diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index 366e6c3cc..2163dc444 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -45,7 +45,7 @@ public class MySQL extends Database { public Connection forceConnection() throws SQLException, ClassNotFoundException { Class.forName("com.mysql.jdbc.Driver"); this.connection = - DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); + DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password); return this.connection; } @@ -55,9 +55,9 @@ public class MySQL extends Database { return this.connection; } Class.forName("com.mysql.jdbc.Driver"); - PS.debug("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database); + PS.debug("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database); this.connection = - DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); + DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password); return this.connection; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 400820b36..e148a613b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1467,9 +1467,7 @@ public class SQLManager implements AbstractDB { if (this.mySQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) { try (Statement stmt = this.connection.createStatement()) { stmt.executeUpdate("ALTER TABLE `" + this.prefix + "plots` DROP INDEX `unique_alias`"); - } catch (SQLException ignore) { - //ignored - } + } catch (SQLException ignored) {} } DatabaseMetaData data = this.connection.getMetaData(); ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/DoubleFlag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/DoubleFlag.java index 110bb7ad6..45598851a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/DoubleFlag.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/DoubleFlag.java @@ -13,7 +13,7 @@ public class DoubleFlag extends Flag { @Override public Double parseValue(String value) { try { return Double.parseDouble(value); - } catch (IllegalArgumentException e) { + } catch (NumberFormatException ignored) { return null; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index eb0a7fba7..4ebab9a64 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.Permissions; + import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; @@ -32,7 +33,7 @@ public class FlagManager { /** * Some events can be called millions of times each second (e.g. physics) and reusing is a lot faster. */ - private static Optional MUTABLE_OPTIONAL; + private static final Optional MUTABLE_OPTIONAL; private static Field MUTABLE_OPTIONAL_FIELD; static { MUTABLE_OPTIONAL = Optional.of(new Object()); @@ -51,7 +52,9 @@ public class FlagManager { try { MUTABLE_OPTIONAL_FIELD.set(MUTABLE_OPTIONAL, value); return MUTABLE_OPTIONAL; - } catch (IllegalAccessException e) {e.printStackTrace();} + } catch (IllegalAccessException e) { + e.printStackTrace(); + } } return Optional.of(value); } @@ -97,9 +100,9 @@ public class FlagManager { for (Map.Entry, Object> entry : flags.entrySet()) { Flag flag = entry.getKey(); if (i != 0) { - flag_string.append(","); + flag_string.append(','); } - flag_string.append(flag.getName() + ":" + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); + flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); i++; } return flag_string.toString(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/IntegerFlag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/IntegerFlag.java index a2755998f..0e06eef6d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/IntegerFlag.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/IntegerFlag.java @@ -17,7 +17,7 @@ public class IntegerFlag extends Flag { @Override public Integer parseValue(String value) { try { return Integer.parseInt(value); - } catch (IllegalArgumentException e) { + } catch (NumberFormatException ignored) { return null; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java index 9265b3dd1..19d2a9359 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java @@ -18,7 +18,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld { @Override public void loadConfiguration(ConfigurationSection config) { if (!config.contains("plot.height")) { - PS.debug(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); + PS.debug(" - &cConfiguration is null? (" + config.getCurrentPath() + ')'); } this.PLOT_WIDTH = config.getInt("plot.size"); this.ROAD_WIDTH = config.getInt("road.width"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java b/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java index 726255f04..f667e5ab6 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java @@ -24,8 +24,8 @@ public class BO3 { public void addChild(BO3 child) { ChunkLoc childloc = child.getLoc(); - this.children.append("Branch(").append(childloc.x - this.chunk.x).append(",0,").append(childloc.z - this.chunk.z).append(",") - .append(this.name).append("_").append(childloc.x).append("_").append(childloc.z).append(")\n"); + this.children.append("Branch(").append(childloc.x - this.chunk.x).append(",0,").append(childloc.z - this.chunk.z).append(',') + .append(this.name).append('_').append(childloc.x).append('_').append(childloc.z).append(")\n"); } public ChunkLoc getLoc() { @@ -43,9 +43,9 @@ public class BO3 { public void addBlock(int x, int y, int z, PlotBlock block) { if (block.data == 0) { // Block(-3,1,-2,AIR) - this.blocks.append("Block(").append(x).append(",").append(y).append(",").append(z).append(",").append(block.id).append(")\n"); + this.blocks.append("Block(").append(x).append(',').append(y).append(',').append(z).append(',').append(block.id).append(")\n"); } else { - this.blocks.append("Block(").append(x).append(",").append(y).append(",").append(z).append(",").append(block.id).append(":") + this.blocks.append("Block(").append(x).append(',').append(y).append(',').append(z).append(',').append(block.id).append(':') .append(block.data).append(")\n"); } } @@ -66,7 +66,7 @@ public class BO3 { if (this.chunk.x == 0 && this.chunk.z == 0) { return this.name + ".bo3"; } else { - return this.name + ("_" + this.chunk.x + "_" + this.chunk.z) + ".bo3"; + return this.name + ("_" + this.chunk.x + '_' + this.chunk.z) + ".bo3"; } } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java index 7930b6c24..604309166 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java @@ -276,7 +276,7 @@ public class BO3Handler { if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) { bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3"); } else { - bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3"); + bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + '_' + bo3.getLoc().x + '_' + bo3.getLoc().z + ".bo3"); } bo3File.createNewFile(); Files.write(bo3File.toPath(), StringMan.join(lines, System.getProperty("line.separator")).getBytes(), StandardOpenOption.WRITE); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java index f8bfec7c1..0efcbf848 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -137,7 +137,7 @@ public abstract class EventUtil { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { return true; } - return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_BREAK.s())); + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_BREAK.s())); case BREAK_HANGING: if (plot == null) { return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); @@ -261,7 +261,7 @@ public abstract class EventUtil { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { return true; } - return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_HANGING_INTERACT.s())); + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_HANGING_INTERACT.s())); } return true; } @@ -287,7 +287,7 @@ public abstract class EventUtil { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { return true; } - return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_MISC_INTERACT.s())); + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_MISC_INTERACT.s())); } return true; } @@ -312,7 +312,7 @@ public abstract class EventUtil { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { return true; } - return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_VEHICLE_USE.s())); + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_VEHICLE_USE.s())); } return true; } @@ -337,7 +337,7 @@ public abstract class EventUtil { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { return true; } - return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + "/" + C.FLAG_PLACE.s())); + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + '/' + C.FLAG_PLACE.s())); } return true; } @@ -364,7 +364,7 @@ public abstract class EventUtil { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { return true; } - return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + "/" + C.FLAG_PLACE.s())); + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + '/' + C.FLAG_PLACE.s())); } return true; @@ -390,7 +390,7 @@ public abstract class EventUtil { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { return true; } - return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + "/" + C.FLAG_PLACE.s())); + return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + '/' + C.FLAG_PLACE.s())); } return true; default: diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 4cdf40ebf..2f75a4435 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; + import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -152,7 +153,7 @@ public class MainUtil { String param = "value"; writer.append(CRLF).append(param).append(CRLF).flush(); writer.append("--" + boundary).append(CRLF); - writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + "\"").append(CRLF); + writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + '"').append(CRLF); writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(CRLF); writer.append("Content-Transfer-Encoding: binary").append(CRLF); writer.append(CRLF).flush(); @@ -737,16 +738,14 @@ public class MainUtil { String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get()); StringBuilder flags = new StringBuilder(); - { - HashMap, Object> flagMap = FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true); - if (flagMap.isEmpty()) { - flags.append(C.NONE.s()); - } else { - String prefix = ""; - for (Entry, Object> entry : flagMap.entrySet()) { - flags.append(prefix).append(C.PLOT_FLAG_LIST.f(entry.getKey().getName(), entry.getValue())); - prefix = ", "; - } + HashMap, Object> flagMap = FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true); + if (flagMap.isEmpty()) { + flags.append(C.NONE.s()); + } else { + String prefix = ""; + for (Entry, Object> entry : flagMap.entrySet()) { + flags.append(prefix).append(C.PLOT_FLAG_LIST.f(entry.getKey().getName(), entry.getValue())); + prefix = ", "; } } boolean build = plot.isAdded(player.getUUID()); @@ -755,7 +754,7 @@ public class MainUtil { info = info.replace("%id%", plot.getId().toString()); info = info.replace("%alias%", alias); - info = info.replace("%num%", num + ""); + info = info.replace("%num%", String.valueOf(num)); info = info.replace("%desc%", description); info = info.replace("%biome%", biome); info = info.replace("%owner%", owner); @@ -766,7 +765,7 @@ public class MainUtil { info = info.replace("%denied%", denied); info = info.replace("%expires%", expires); info = info.replace("%flags%", flags); - info = info.replace("%build%", build + ""); + info = info.replace("%build%", String.valueOf(build)); info = info.replace("%desc%", "No description set."); if (info.contains("%rating%")) { final String newInfo = info; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 572b17319..86bec79a8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -80,7 +80,7 @@ public abstract class SchematicHandler { } final String name; if (namingScheme == null) { - name = plot.getId().x + ";" + plot.getId().y + "," + plot.getArea() + "," + o; + name = plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + o; } else { name = namingScheme.replaceAll("%owner%", o).replaceAll("%id%", plot.getId().toString()).replaceAll("%idx%", plot.getId().x + "").replaceAll("%idy%", plot.getId().y + "") .replaceAll("%world%", plot.getArea().toString()); @@ -170,7 +170,7 @@ public abstract class SchematicHandler { if (((region.maxX - region.minX + xOffset + 1) < WIDTH) || ((region.maxZ - region.minZ + zOffset + 1) < LENGTH) || (HEIGHT > 256)) { PS.debug("Schematic is too large"); - PS.debug("(" + WIDTH + "," + LENGTH + "," + HEIGHT + ") is bigger than (" + (region.maxX - region.minX) + "," + (region.maxZ - region.minZ) + ",256)"); + PS.debug("(" + WIDTH + ',' + LENGTH + ',' + HEIGHT + ") is bigger than (" + (region.maxX - region.minX) + ',' + (region.maxZ - region.minZ) + ",256)"); TaskManager.runTask(whenDone); return; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index d2ccd505c..0a23aa828 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -26,7 +26,7 @@ public class UUIDHandler { * * @return map with names + uuids * - * @see com.google.common.collect.BiMap + * @see BiMap */ public static BiMap getUuidMap() { return implementation.getUUIDMap(); @@ -39,7 +39,7 @@ public class UUIDHandler { * * @return true of the uuid is cached * - * @see com.google.common.collect.BiMap#containsValue(Object) + * @see BiMap#containsValue(Object) */ public static boolean uuidExists(UUID uuid) { return implementation.uuidExists(uuid); @@ -52,7 +52,7 @@ public class UUIDHandler { * * @return true of the name is cached * - * @see com.google.common.collect.BiMap#containsKey(Object) + * @see BiMap#containsKey(Object) */ public static boolean nameExists(StringWrapper name) { return implementation.nameExists(name); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/WorldUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/WorldUtil.java index 04f57e68c..20ffd9228 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/WorldUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/WorldUtil.java @@ -124,7 +124,7 @@ public abstract class WorldUtil { } public File getMcr(String world, int x, int z) { - File file = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region" + File.separator + "r." + x + "." + z + ".mca"); + File file = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca"); if (file.exists()) { return file; } diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index 69fd48a63..8f0740bb1 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -44,11 +44,16 @@ public class PlotListener { EventUtil.manager.callEntry(pp, plot); if (plot.hasOwner()) { Map, Object> flags = FlagManager.getPlotFlags(plot); - int size = flags.size(); boolean titles = Settings.TITLES; final String greeting; - if (size != 0) { + if (flags.isEmpty()) { + if (titles) { + greeting = ""; + } else { + return true; + } + } else { Optional titleFlag = plot.getFlag(Flags.TITLES); if (titleFlag.isPresent()) { titles = titleFlag.get(); @@ -97,7 +102,7 @@ public class PlotListener { try { long time = timeFlag.get(); pp.setTime(time); - } catch (Exception e) { + } catch (Exception ignored) { FlagManager.removePlotFlag(plot, Flags.TIME); } } @@ -133,10 +138,6 @@ public class PlotListener { } } CommentManager.sendTitle(pp, plot); - } else if (titles) { - greeting = ""; - } else { - return true; } if (titles) { if (!C.TITLE_ENTERED_PLOT.s().isEmpty() || !C.TITLE_ENTERED_PLOT_SUB.s().isEmpty()) { @@ -146,7 +147,7 @@ public class PlotListener { Plot lastPlot = pp.getMeta("lastplot"); if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) { Map replacements = new HashMap<>(); - replacements.put("%x%", lastPlot.getId().x + ""); + replacements.put("%x%", String.valueOf(lastPlot.getId().x)); replacements.put("%z%", lastPlot.getId().y + ""); replacements.put("%world%", plot.getArea().toString()); replacements.put("%greeting%", greeting); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 616a1c4da..578dcbbfe 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -76,6 +76,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; @Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3") public class SpongeMain implements IPlotMain { @@ -258,7 +259,7 @@ public class SpongeMain implements IPlotMain { try { Class.forName("com.sk89q.worldedit.WorldEdit"); return true; - } catch (Throwable e) { + } catch (ClassNotFoundException ignored) { return false; } } @@ -306,7 +307,7 @@ public class SpongeMain implements IPlotMain { Metrics metrics = new Metrics(this.game, this.plugin); metrics.start(); log(C.PREFIX.s() + "&6Metrics enabled."); - } catch (IOException e) { + } catch (IOException ignored) { log(C.PREFIX.s() + "&cFailed to load up metrics."); } } @@ -376,7 +377,7 @@ public class SpongeMain implements IPlotMain { try { MainUtil.canSendChunk = true; return new FastQueue(); - } catch (Throwable e) { + } catch (RuntimeException e) { e.printStackTrace(); } } @@ -412,10 +413,7 @@ public class SpongeMain implements IPlotMain { @Override public List getPluginIds() { - ArrayList names = new ArrayList<>(); - for (PluginContainer plugin : this.game.getPluginManager().getPlugins()) { - names.add(plugin.getName() + ";" + plugin.getVersion() + ":" + true); - } - return names; + return this.game.getPluginManager().getPlugins().stream().map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true) + .collect(Collectors.toCollection(ArrayList::new)); } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java index 34c2eb32a..cb2e0e60c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java @@ -30,7 +30,7 @@ public class SpongeCommand implements CommandCallable { UUID uuid = UUID.fromString(id); Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get(); pp = SpongeUtil.getPlayer(player); - } catch (Exception e) { + } catch (Exception ignored) { pp = ConsolePlayer.getConsole(); } MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" "));