diff --git a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index 32405d01d..5105ae664 100644 --- a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -54,8 +54,7 @@ public class PlotAPI { * @deprecated Not needed */ @Deprecated - public PlotAPI(JavaPlugin plugin) { - } + public PlotAPI(JavaPlugin plugin) {} /** * Get all plots. diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 03b667983..3a51307c2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -141,9 +141,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain } this.getServer().getConsoleSender().sendMessage(message); return; - } catch (Throwable ignored) { - //ignored - } + } catch (Throwable ignored) {} System.out.println(ConsoleColors.fromString(message)); } @@ -401,14 +399,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain try { new SendChunk(); MainUtil.canSendChunk = true; - } catch (Throwable e) { + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { e.printStackTrace(); MainUtil.canSendChunk = false; } if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) { try { return new FastQueue_1_9(); - } catch (Throwable e) { + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { e.printStackTrace(); return new SlowQueue(); } @@ -416,11 +414,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) { try { return new FastQueue_1_8_3(); - } catch (Throwable e) { + } catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException e) { e.printStackTrace(); try { return new FastQueue_1_8(); - } catch (Throwable e2) { + } catch (NoSuchMethodException | NoSuchFieldException | ClassNotFoundException e2) { e2.printStackTrace(); return new SlowQueue(); } @@ -428,7 +426,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain } try { return new FastQueue_1_7(); - } catch (Throwable e) { + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { e.printStackTrace(); return new SlowQueue(); } @@ -657,7 +655,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain public List getPluginIds() { ArrayList names = new ArrayList<>(); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { - names.add(plugin.getName() + ";" + plugin.getDescription().getVersion() + ":" + plugin.isEnabled()); + names.add(plugin.getName() + ';' + plugin.getDescription().getVersion() + ':' + plugin.isEnabled()); } return names; } 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 716b37530..7e738bae2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java @@ -285,7 +285,7 @@ public class DebugUUID extends SubCommand { } try { PS.get().config.save(PS.get().configFile); - } catch (IOException e) { + } catch (IOException ignored) { MainUtil.sendMessage(player, "Could not save configuration. It will need to be manual set!"); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java index 3e6ee0184..d237706a4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java @@ -42,9 +42,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector { } else { return new SQLite(dataFolder + File.separator + "plots.db").openConnection(); } - } catch (SQLException | ClassNotFoundException ignored) { - //ignored - ignored.printStackTrace(); + } catch (SQLException | ClassNotFoundException e) { + e.printStackTrace(); } return null; } @@ -229,9 +228,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { resultSet.close(); statement.close(); - } catch (SQLException ignored) { - //ignored - } + } catch (SQLException ignored) {} return plots; } 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 205cd6eec..97ed3bc3f 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 @@ -200,9 +200,7 @@ public class LikePlotMeConverter { PS.get().config.set("worlds." + actualWorldName + ".wall.height", height); PS.get().config.save(PS.get().configFile); } - } catch (IOException ignored) { - //ignored - } + } catch (IOException ignored) {} } for (Entry> entry : plots.entrySet()) { String world = entry.getKey(); 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 f56473119..d4af8e08a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -233,7 +233,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap } catch (Exception e) { e.printStackTrace(); } - ArrayList toAdd = new ArrayList(); + ArrayList toAdd = new ArrayList<>(); List existing = world.getPopulators(); for (BlockPopulator populator : this.populators) { if (!existing.contains(populator)) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java index 4c154fdaa..45e2d5922 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java @@ -31,22 +31,21 @@ import java.util.Set; public class WEListener implements Listener { - public final HashSet rad1 = new HashSet<>( + public final Set other = new HashSet<>(Arrays.asList("undo", "redo")); + private final Set rad1 = new HashSet<>( Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size")); - public final HashSet rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove")); - public final HashSet rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl")); - public final HashSet rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid")); - public final Set rad2_3 = Collections.singleton("brush smooth"); - public final Set rad3_1 = Collections.singleton("brush gravity"); - public final HashSet rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder")); - - public final HashSet region = new HashSet<>( + private final Set rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove")); + private final Set rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl")); + private final Set rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid")); + private final Set rad2_3 = Collections.singleton("brush smooth"); + private final Set rad3_1 = Collections.singleton("brush gravity"); + private final Set rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder")); + private final Set region = new HashSet<>( Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr", "regen", "copy", "cut", "green", "setbiome")); - public final Set regionExtend = Collections.singleton("stack"); - public final Set restricted = Collections.singleton("up"); - public final HashSet other = new HashSet<>(Arrays.asList("undo", "redo")); + private final Set regionExtend = Collections.singleton("stack"); + private final Set restricted = Collections.singleton("up"); public String reduceCmd(String cmd, boolean single) { if (cmd.startsWith("/worldedit:/")) { @@ -75,14 +74,14 @@ public class WEListener implements Listener { } } return max; - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { return 0; } } public boolean checkVolume(PlotPlayer player, long volume, long max, Cancellable e) { if (volume > max) { - MainUtil.sendMessage(player, C.WORLDEDIT_VOLUME.s().replaceAll("%current%", volume + "").replaceAll("%max%", max + "")); + MainUtil.sendMessage(player, C.WORLDEDIT_VOLUME.s().replaceAll("%current%", String.valueOf(volume)).replaceAll("%max%", String.valueOf(max))); e.setCancelled(true); } if (Permissions.hasPermission(player, "plots.worldedit.bypass")) { @@ -181,7 +180,7 @@ public class WEListener implements Listener { boolean single = true; if (split.length >= 2) { String reduced = reduceCmd(split[0], single); - String reduced2 = reduceCmd(split[0] + " " + split[1], single); + String reduced2 = reduceCmd(split[0] + ' ' + split[1], single); if (this.rad1.contains(reduced)) { if (delay(p, message, false)) { e.setCancelled(true); @@ -234,7 +233,8 @@ public class WEListener implements Listener { int iterations = getInt(split[3]); if (iterations > maxIterations) { MainUtil.sendMessage(pp, - C.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", iterations + "").replaceAll("%max%", maxIterations + "")); + C.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", String.valueOf(iterations)).replaceAll("%max%", + String.valueOf(maxIterations))); e.setCancelled(true); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java index ba61f6c89..0ae98e8a1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java @@ -465,8 +465,7 @@ public class EntityWrapper { if (this.base.passenger != null) { try { entity.setPassenger(this.base.passenger.spawn(world, x_offset, z_offset)); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } if (this.base.fall != 0) { entity.setFallDistance(this.base.fall); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java index de5774cd4..a652be9f9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java @@ -143,8 +143,7 @@ public class HackTitleManager extends TitleManager { private Class getClass(String namespace) { try { return Class.forName(namespace); - } catch (ClassNotFoundException ignored) { - } + } catch (ClassNotFoundException ignored) {} return null; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index 7d1a89709..54769acc1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -58,6 +58,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -616,25 +617,25 @@ public class BukkitChunkManager extends ChunkManager { public static class ContentMap { - public final HashMap chestContents; - public final HashMap furnaceContents; - public final HashMap dispenserContents; - public final HashMap dropperContents; - public final HashMap brewingStandContents; - public final HashMap beaconContents; - public final HashMap hopperContents; - public final HashMap furnaceTime; - public final HashMap skullData; - public final HashMap jukeboxDisc; - public final HashMap brewTime; - public final HashMap spawnerData; - public final HashMap cmdData; - public final HashMap signContents; - public final HashMap noteBlockContents; - public final HashMap> bannerPatterns; - public final HashMap bannerBase; - public final HashSet entities; - public final HashMap allBlocks; + public final Map chestContents; + public final Map furnaceContents; + public final Map dispenserContents; + public final Map dropperContents; + public final Map brewingStandContents; + public final Map beaconContents; + public final Map hopperContents; + public final Map furnaceTime; + public final Map skullData; + public final Map jukeboxDisc; + public final Map brewTime; + public final Map spawnerData; + public final Map cmdData; + public final Map signContents; + public final Map noteBlockContents; + public final Map> bannerPatterns; + public final Map bannerBase; + public final Set entities; + public final Map allBlocks; public ContentMap() { this.chestContents = new HashMap<>(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java index 06a02fe56..3ce09c872 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java @@ -49,8 +49,7 @@ public class BukkitHybridUtils extends HybridUtils { } final BiomeGrid nullBiomeGrid = new BiomeGrid() { @Override - public void setBiome(int a, int b, Biome c) { - } + public void setBiome(int a, int b, Biome c) {} @Override public Biome getBiome(int a, int b) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java index a0cd0d70a..11872a8db 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java @@ -22,12 +22,10 @@ public class BukkitPlainChatManager extends ChatManager> { } @Override - public void tooltip(PlotMessage message, PlotMessage... tooltips) { - } + public void tooltip(PlotMessage message, PlotMessage... tooltips) {} @Override - public void command(PlotMessage message, String command) { - } + public void command(PlotMessage message, String command) {} @Override public void text(PlotMessage message, String text) { @@ -44,7 +42,6 @@ public class BukkitPlainChatManager extends ChatManager> { } @Override - public void suggest(PlotMessage plotMessage, String command) { - } + public void suggest(PlotMessage plotMessage, String command) {} } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index fff80fe74..a7b8990d6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -271,8 +271,7 @@ public class BukkitUtil extends WorldUtil { try { Material material = Material.valueOf(name.toUpperCase()); return new StringComparison().new ComparisonResult(0, new PlotBlock((short) material.getId(), (byte) 0)); - } catch (IllegalArgumentException ignored) { - } + } catch (IllegalArgumentException ignored) {} try { byte data; String[] split = name.split(":"); @@ -296,8 +295,7 @@ public class BukkitUtil extends WorldUtil { StringComparison outer = new StringComparison<>(); return outer.new ComparisonResult(match, block); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} return null; } 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 52afe43f7..151678f28 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java @@ -95,8 +95,7 @@ public class Metrics { if (gzos != null) { try { gzos.close(); - } catch (IOException ignore) { - } + } catch (IOException ignore) {} } } return baos.toByteArray(); @@ -117,7 +116,7 @@ public class Metrics { Double.parseDouble(value); isValueNumeric = true; } - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { isValueNumeric = false; } if (json.charAt(json.length() - 1) != '{') { @@ -446,7 +445,7 @@ public class Metrics { try { Class.forName("mineshafter.MineServer"); return true; - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException ignored) { return false; } } @@ -569,8 +568,7 @@ public class Metrics { /** * Called after the website graphs have been updated */ - public void reset() { - } + public void reset() {} @Override public int hashCode() { 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 4365998d6..b59d912e2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java @@ -42,7 +42,7 @@ public class SendChunk { /** * Constructor */ - public SendChunk() { + public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException { RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer"); this.methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle"); RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java index 7db7cfef8..b29f5826f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java @@ -38,7 +38,7 @@ public class FastQueue_1_7 extends SlowQueue { private final HashMap toUpdate = new HashMap<>(); - public FastQueue_1_7() throws RuntimeException { + public FastQueue_1_7() throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException { this.methodGetHandle = this.classCraftWorld.getMethod("getHandle"); this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class); this.methodA = this.classChunk.getMethod("a", int.class, int.class, int.class, this.classBlock, int.class); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java index b534ec3f4..139e14c24 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java @@ -41,7 +41,7 @@ public class FastQueue_1_8 extends SlowQueue { private final RefConstructor constructorBlockPosition; private final SendChunk sendChunk; - public FastQueue_1_8() throws RuntimeException { + public FastQueue_1_8() throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException { this.methodInitLighting = this.classChunk.getMethod("initLighting"); this.constructorBlockPosition = this.classBlockPosition.getConstructor(int.class, int.class, int.class); this.methodGetByCombinedId = this.classBlock.getMethod("getByCombinedId", int.class); @@ -56,7 +56,7 @@ public class FastQueue_1_8 extends SlowQueue { return; } int count = 0; - ArrayList chunks = new ArrayList(); + ArrayList chunks = new ArrayList<>(); Iterator> i = FastQueue_1_8.this.toUpdate.entrySet().iterator(); while (i.hasNext() && count < 128) { chunks.add(i.next().getValue()); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java index f679a01c2..ee0cb7eb1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java @@ -49,7 +49,7 @@ public class FastQueue_1_8_3 extends SlowQueue { private final RefMethod methodGetWorld; private final RefField tileEntityListTick; - public FastQueue_1_8_3() throws RuntimeException { + public FastQueue_1_8_3() throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException { RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); RefClass classCraftWorld = getRefClass("{cb}.CraftWorld"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java index c3e4ea506..79d30d56a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java @@ -53,7 +53,7 @@ public class FastQueue_1_9 extends SlowQueue { private final RefField tileEntityListTick; - public FastQueue_1_9() throws RuntimeException { + public FastQueue_1_9() throws NoSuchFieldException, NoSuchMethodException, ClassNotFoundException { RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); RefClass classChunk = getRefClass("{nms}.Chunk"); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflineUUIDWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflineUUIDWrapper.java index a33c506f6..273ff8fc1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflineUUIDWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/OfflineUUIDWrapper.java @@ -14,6 +14,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.entity.Player; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.UUID; @@ -48,11 +49,9 @@ public class OfflineUUIDWrapper extends UUIDWrapper { @Override public OfflinePlotPlayer getOfflinePlayer(UUID uuid) { BiMap map = UUIDHandler.getUuidMap().inverse(); - String name; - try { + String name = null; + if (map.containsKey(uuid)) { name = map.get(uuid).value; - } catch (NullPointerException e) { - name = null; } if (name != null) { OfflinePlayer op = Bukkit.getOfflinePlayer(name); @@ -81,7 +80,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper { @SuppressWarnings("unchecked") Collection p = (Collection) players; return p.toArray(new Player[p.size()]); } - } catch (Exception e) { + } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ignored) { PS.debug("Failed to resolve online players"); this.getOnline = null; Collection onlinePlayers = Bukkit.getOnlinePlayers(); diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java index 2c7766890..067493ee5 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java @@ -4,10 +4,10 @@ package com.intellectualcrafters.configuration; * Various settings for controlling the input and output of a {@link * Configuration} */ -public class ConfigurationOptions { +class ConfigurationOptions { + private final Configuration configuration; private char pathSeparator = '.'; private boolean copyDefaults = false; - private final Configuration configuration; protected ConfigurationOptions(final Configuration configuration) { this.configuration = configuration; diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java index b817358dd..70db80141 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java @@ -76,8 +76,7 @@ public class MemorySection implements ConfigurationSection { if (obj instanceof String) { try { return Double.parseDouble((String) obj); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (obj instanceof List) { List val = (List) obj; if (!val.isEmpty()) { @@ -94,8 +93,7 @@ public class MemorySection implements ConfigurationSection { if (obj instanceof String) { try { return Integer.parseInt((String) obj); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (obj instanceof List) { List val = (List) obj; if (!val.isEmpty()) { @@ -112,8 +110,7 @@ public class MemorySection implements ConfigurationSection { if (obj instanceof String) { try { return Long.parseLong((String) obj); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (obj instanceof List) { List val = (List) obj; if (!val.isEmpty()) { @@ -569,8 +566,7 @@ public class MemorySection implements ConfigurationSection { } else if (object instanceof String) { try { result.add(Integer.valueOf((String) object)); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (object instanceof Character) { result.add((int) (Character) object); } else if (object instanceof Number) { @@ -614,8 +610,7 @@ public class MemorySection implements ConfigurationSection { } else if (object instanceof String) { try { result.add(Double.valueOf((String) object)); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (object instanceof Character) { result.add((double) (Character) object); } else if (object instanceof Number) { @@ -638,8 +633,7 @@ public class MemorySection implements ConfigurationSection { } else if (object instanceof String) { try { result.add(Float.valueOf((String) object)); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (object instanceof Character) { result.add((float) (Character) object); } else if (object instanceof Number) { @@ -662,8 +656,7 @@ public class MemorySection implements ConfigurationSection { } else if (object instanceof String) { try { result.add(Long.valueOf((String) object)); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (object instanceof Character) { result.add((long) (Character) object); } else if (object instanceof Number) { @@ -686,8 +679,7 @@ public class MemorySection implements ConfigurationSection { } else if (object instanceof String) { try { result.add(Byte.valueOf((String) object)); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (object instanceof Character) { result.add((byte) ((Character) object).charValue()); } else if (object instanceof Number) { @@ -733,8 +725,7 @@ public class MemorySection implements ConfigurationSection { } else if (object instanceof String) { try { result.add(Short.valueOf((String) object)); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } else if (object instanceof Character) { result.add((short) ((Character) object).charValue()); } else if (object instanceof Number) { diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java index ff7fd88c8..dcdec3c34 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java @@ -25,8 +25,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { /** * Creates an empty {@link FileConfiguration} with no default values. */ - public FileConfiguration() { - } + FileConfiguration() {} /** * Creates an empty {@link FileConfiguration} using the specified {@link @@ -54,9 +53,6 @@ public abstract class FileConfiguration extends MemoryConfiguration { * @throws IllegalArgumentException Thrown when file is null. */ public void save(File file) throws IOException { - if (file == null) { - throw new NullPointerException("File cannot be null"); - } file.getParentFile().mkdirs(); String data = saveToString(); @@ -65,30 +61,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { writer.write(data); } } - - /** - * Saves this {@link FileConfiguration} to the specified location. - *

- * If the file does not exist, it will be created. If already exists, it - * will be overwritten. If it cannot be overwritten or created, an - * exception will be thrown. - *

- * This method will save using the system default encoding, or possibly - * using UTF8. - * - * @param file File to save to. - * @throws IOException Thrown when the given file cannot be written to for - * any reason. - * @throws IllegalArgumentException Thrown when file is null. - */ - public void save(String file) throws IOException { - if (file == null) { - throw new NullPointerException("File cannot be null"); - } - - save(new File(file)); - } - + /** * Saves this {@link FileConfiguration} to a string, and returns it. * diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java index f869b3eea..59ad896c1 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java @@ -21,8 +21,8 @@ import java.util.Map; * Note that this implementation is not synchronized. */ public class YamlConfiguration extends FileConfiguration { - protected static final String COMMENT_PREFIX = "# "; - protected static final String BLANK_CONFIG = "{}\n"; + private static final String COMMENT_PREFIX = "# "; + private static final String BLANK_CONFIG = "{}\n"; private final DumperOptions yamlOptions = new DumperOptions(); private final Representer yamlRepresenter = new YamlRepresenter(); private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions); @@ -40,7 +40,7 @@ public class YamlConfiguration extends FileConfiguration { * @return Resulting configuration * @throws IllegalArgumentException Thrown if file is null */ - public static YamlConfiguration loadConfiguration(final File file) { + public static YamlConfiguration loadConfiguration(File file) { if (file == null) { throw new NullPointerException("File cannot be null"); } @@ -163,7 +163,7 @@ public class YamlConfiguration extends FileConfiguration { if (line.startsWith(COMMENT_PREFIX)) { if (i > 0) { - result.append("\n"); + result.append('\n'); } if (line.length() > COMMENT_PREFIX.length()) { @@ -172,7 +172,7 @@ public class YamlConfiguration extends FileConfiguration { foundHeader = true; } else if (foundHeader && line.isEmpty()) { - result.append("\n"); + result.append('\n'); } else if (foundHeader) { readingHeader = false; } @@ -189,8 +189,8 @@ public class YamlConfiguration extends FileConfiguration { final Configuration def = getDefaults(); if (def instanceof FileConfiguration) { - final FileConfiguration filedefaults = (FileConfiguration) def; - final String defaultsHeader = filedefaults.buildHeader(); + final FileConfiguration fileDefaults = (FileConfiguration) def; + final String defaultsHeader = fileDefaults.buildHeader(); if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) { return defaultsHeader; @@ -207,7 +207,7 @@ public class YamlConfiguration extends FileConfiguration { boolean startedHeader = false; for (int i = lines.length - 1; i >= 0; i--) { - builder.insert(0, "\n"); + builder.insert(0, '\n'); if (startedHeader || !lines[i].isEmpty()) { builder.insert(0, lines[i]); diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfigurationOptions.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfigurationOptions.java index 236325ae0..d33416387 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfigurationOptions.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfigurationOptions.java @@ -7,7 +7,7 @@ package com.intellectualcrafters.configuration.file; public class YamlConfigurationOptions extends FileConfigurationOptions { private int indent = 2; - protected YamlConfigurationOptions(final YamlConfiguration configuration) { + YamlConfigurationOptions(final YamlConfiguration configuration) { super(configuration); } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConstructor.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConstructor.java index fad595c5b..c70ea67b7 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConstructor.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConstructor.java @@ -11,7 +11,7 @@ import java.util.Map; public class YamlConstructor extends SafeConstructor { - public YamlConstructor() { + YamlConstructor() { yamlConstructors.put(Tag.MAP, new ConstructCustomObject()); } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlRepresenter.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlRepresenter.java index e1077556e..61eecfa1c 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlRepresenter.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlRepresenter.java @@ -9,7 +9,7 @@ import org.yaml.snakeyaml.representer.Representer; import java.util.LinkedHashMap; import java.util.Map; -public class YamlRepresenter extends Representer { +class YamlRepresenter extends Representer { public YamlRepresenter() { this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection()); diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java b/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java index 3bb971376..92b7edfba 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java @@ -17,8 +17,7 @@ import java.util.logging.Logger; public class ConfigurationSerialization { public static final String SERIALIZED_TYPE_KEY = "=="; - private static final Map> aliases = - new HashMap>(); + private static final Map> aliases = new HashMap<>(); private final Class clazz; protected ConfigurationSerialization(Class clazz) { @@ -128,8 +127,7 @@ public class ConfigurationSerialization { * @param clazz Class to unregister */ public static void unregisterClass(Class clazz) { - while (aliases.values().remove(clazz)) { - } + while (aliases.values().remove(clazz)) {} } /** @@ -154,7 +152,7 @@ public class ConfigurationSerialization { DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class); if (delegate != null) { - if ((delegate.value() == null) || (delegate.value() == clazz)) { + if (delegate.value() == clazz) { delegate = null; } else { return getAlias(delegate.value()); @@ -182,9 +180,7 @@ public class ConfigurationSerialization { } return method; - } catch (NoSuchMethodException ex) { - return null; - } catch (SecurityException ex) { + } catch (NoSuchMethodException | SecurityException ignored) { return null; } } @@ -192,9 +188,7 @@ public class ConfigurationSerialization { protected Constructor getConstructor() { try { return this.clazz.getConstructor(Map.class); - } catch (NoSuchMethodException ex) { - return null; - } catch (SecurityException ex) { + } catch (NoSuchMethodException | SecurityException ignored) { return null; } } diff --git a/Core/src/main/java/com/intellectualcrafters/jnbt/EndTag.java b/Core/src/main/java/com/intellectualcrafters/jnbt/EndTag.java index d22efc989..8c7eba1e1 100644 --- a/Core/src/main/java/com/intellectualcrafters/jnbt/EndTag.java +++ b/Core/src/main/java/com/intellectualcrafters/jnbt/EndTag.java @@ -8,8 +8,7 @@ public final class EndTag extends Tag { /** * Creates the tag. */ - public EndTag() { - } + public EndTag() {} @Override public Object getValue() { diff --git a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java index add5b7498..43282b5ad 100644 --- a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java +++ b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java @@ -16,8 +16,7 @@ public final class NBTConstants { /** * Default private constructor. */ - private NBTConstants() { - } + private NBTConstants() {} /** * Convert a type ID to its corresponding {@link Tag} class. diff --git a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java index 3b8bba993..a0f2cabd7 100644 --- a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java @@ -10,8 +10,7 @@ public final class NBTUtils { /** * Default private constructor. */ - private NBTUtils() { - } + private NBTUtils() {} /** * Gets the type name of a tag. diff --git a/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java b/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java index 1cb9f55d8..cb7b79aa6 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java +++ b/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java @@ -88,8 +88,7 @@ public class JSONObject { for (String name : names) { try { putOnce(name, jo.opt(name)); - } catch (JSONException ignore) { - } + } catch (JSONException ignore) {} } } @@ -194,8 +193,7 @@ public class JSONObject { for (String name : names) { try { putOpt(name, c.getField(name).get(object)); - } catch (JSONException | SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignore) { - } + } catch (JSONException | SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignore) {} } } @@ -461,8 +459,7 @@ public class JSONObject { } } } - } catch (NumberFormatException ignore) { - } + } catch (NumberFormatException ignore) {} } return string; } @@ -586,7 +583,7 @@ public class JSONObject { return object.toString(); } return new JSONObject(object); - } catch (JSONException exception) { + } catch (JSONException ignored) { return null; } } @@ -734,7 +731,7 @@ public class JSONObject { Object object = get(key); try { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { throw new JSONException("JSONObject[" + quote(key) + "] is not a number."); } } @@ -752,7 +749,7 @@ public class JSONObject { Object object = get(key); try { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { throw new JSONException("JSONObject[" + quote(key) + "] is not an int."); } } @@ -804,7 +801,7 @@ public class JSONObject { Object object = get(key); try { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { throw new JSONException("JSONObject[" + quote(key) + "] is not a long."); } } @@ -953,7 +950,7 @@ public class JSONObject { public boolean optBoolean(String key, boolean defaultValue) { try { return getBoolean(key); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -982,7 +979,7 @@ public class JSONObject { public double optDouble(String key, double defaultValue) { try { return getDouble(key); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -1011,7 +1008,7 @@ public class JSONObject { public int optInt(String key, int defaultValue) { try { return getInt(key); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -1066,7 +1063,7 @@ public class JSONObject { public long optLong(String key, long defaultValue) { try { return getLong(key); - } catch (JSONException e) { + } catch (JSONException ignored) { return defaultValue; } } @@ -1127,8 +1124,7 @@ public class JSONObject { } } } - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) { - } + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) {} } } @@ -1330,7 +1326,7 @@ public class JSONObject { } } return true; - } catch (JSONException exception) { + } catch (JSONException ignored) { return false; } } @@ -1370,7 +1366,7 @@ public class JSONObject { public String toString() { try { return this.toString(0); - } catch (JSONException e) { + } catch (JSONException ignored) { return null; } } @@ -1476,7 +1472,7 @@ public class JSONObject { protected final Object clone() { try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch (CloneNotSupportedException ignored) { return this; } } diff --git a/Core/src/main/java/com/intellectualcrafters/json/XML.java b/Core/src/main/java/com/intellectualcrafters/json/XML.java index ad3a3e509..5386b0b62 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/XML.java +++ b/Core/src/main/java/com/intellectualcrafters/json/XML.java @@ -245,8 +245,7 @@ class XML { if (value.toString().equals(string)) { return value; } - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } return string; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 0007d967b..5d71d20df 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -829,7 +829,7 @@ public class PS { return result; } - public ArrayList sortPlotsByTemp(Collection plots) { + public List sortPlotsByTemp(Collection plots) { int max = 0; int overflowCount = 0; for (Plot plot : plots) { @@ -1761,7 +1761,7 @@ public class PS { // Close the connection DBFunc.close(); UUIDHandler.handleShutdown(); - } catch (NullPointerException e) { + } catch (NullPointerException ignored) { PS.log("&cCould not close database connection!"); } } @@ -2099,7 +2099,7 @@ public class PS { } this.config = YamlConfiguration.loadConfiguration(this.configFile); setupConfig(); - } catch (IOException err_trans) { + } catch (IOException ignored) { PS.log("Failed to save settings.yml"); } try { @@ -2111,7 +2111,7 @@ public class PS { } this.storage = YamlConfiguration.loadConfiguration(this.storageFile); setupStorage(); - } catch (IOException err_trans) { + } catch (IOException ignored) { PS.log("Failed to save storage.yml"); } try { @@ -2123,7 +2123,7 @@ public class PS { } this.commands = YamlConfiguration.loadConfiguration(this.commandsFile); setupStorage(); - } catch (IOException err_trans) { + } catch (IOException ignored) { PS.log("Failed to save commands.yml"); } try { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 8f603528d..54ea00d04 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -43,7 +43,7 @@ public class Buy extends SubCommand { return false; } plots = plot.getConnectedPlots(); - } catch (Exception e) { + } catch (Exception ignored) { return sendMessage(plr, C.NOT_VALID_PLOT_ID); } } else { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Continue.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Continue.java index dfb3a1060..afe6e71fc 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Continue.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Continue.java @@ -27,7 +27,7 @@ public class Continue extends SubCommand { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } - if (!plot.getFlags().containsKey("done")) { + if (!plot.hasFlag(Flags.DONE)) { MainUtil.sendMessage(plr, C.DONE_NOT_DONE); return false; } 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 9121de624..47ae56c09 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -80,8 +80,7 @@ public class DebugExec extends SubCommand { this.engine.eval(script, this.scope); } } - } catch (IOException | ScriptException ignored) { - } + } catch (IOException | ScriptException ignored) {} } public ScriptEngine getEngine() { @@ -360,12 +359,7 @@ public class DebugExec extends SubCommand { @Override public void run(Integer i, File file, PlotMessage message) { String name = file.getName(); - - message.text("[").color("$3") - .text(i + "").color("$1") - .text("]").color("$3") - .text(" " + name).color("$1"); - + message.text("[").color("$3").text(String.valueOf(i)).color("$1").text("]").color("$3").text(' ' + name).color("$1"); } }, "/plot debugexec list-scripts", "List of scripts"); return true; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index bb600c711..e1377b49a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -12,8 +12,6 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.general.commands.CommandDeclaration; -import java.util.HashSet; - @CommandDeclaration( command = "delete", permission = "plots.delete", @@ -40,7 +38,7 @@ public class Delete extends SubCommand { return !sendMessage(plr, C.NO_PLOT_PERMS); } final PlotArea plotworld = plot.getArea(); - final HashSet plots = plot.getConnectedPlots(); + final java.util.Set plots = plot.getConnectedPlots(); Runnable run = new Runnable() { @Override public void run() { @@ -57,7 +55,7 @@ public class Delete extends SubCommand { double value = plotworld.PRICES.get("sell") * plots.size(); if (value > 0d) { EconHandler.manager.depositMoney(plr, value); - sendMessage(plr, C.ADDED_BALANCE, value + ""); + sendMessage(plr, C.ADDED_BALANCE, String.valueOf(value)); } } MainUtil.sendMessage(plr, C.CLEARING_DONE, System.currentTimeMillis() - start); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java index d6354ee03..4df2939cc 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java @@ -2,8 +2,6 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.flag.Flag; -import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.Location; @@ -34,7 +32,7 @@ public class Done extends SubCommand { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } - if (plot.getFlags().containsKey("done")) { + if (plot.hasFlag(Flags.DONE)) { MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE); return false; } @@ -50,8 +48,7 @@ public class Done extends SubCommand { plot.removeRunning(); if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) { long flagValue = System.currentTimeMillis() / 1000; - Flag flag = Flags.DONE; - FlagManager.addPlotFlag(plot, flag, flagValue); + plot.setFlag(Flags.DONE,flagValue); MainUtil.sendMessage(plr, C.DONE_SUCCESS); } else { MainUtil.sendMessage(plr, C.DONE_INSUFFICIENT_COMPLEXITY); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/ListCmd.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/ListCmd.java index 69d1c5961..ebaa625e5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/ListCmd.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/ListCmd.java @@ -101,7 +101,7 @@ public class ListCmd extends SubCommand { if (page < 0) { page = 0; } - } catch (Exception e) { + } catch (NumberFormatException ignored) { page = -1; } } @@ -313,8 +313,7 @@ public class ListCmd extends SubCommand { if (uuid == null) { try { uuid = UUID.fromString(args[0]); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } if (uuid != null) { if (!Permissions.hasPermission(plr, "plots.list.player")) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java index d23f0ba48..7334a11f3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java @@ -68,14 +68,14 @@ public class Load extends SubCommand { String schematic; try { schematic = schematics.get(Integer.parseInt(args[0]) - 1); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { // use /plot load - MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ")"); + MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ')'); return false; } final URL url; try { - url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + "/" + schematic + ".schematic"); + url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + '/' + schematic + ".schematic"); } catch (MalformedURLException e) { e.printStackTrace(); MainUtil.sendMessage(plr, C.LOAD_FAILED); @@ -147,7 +147,7 @@ public class Load extends SubCommand { } String time = secToTime((System.currentTimeMillis() / 1000) - Long.parseLong(split[0])); String world = split[1]; - PlotId id = PlotId.fromString(split[2] + ";" + split[3]); + PlotId id = PlotId.fromString(split[2] + ';' + split[3]); String size = split[4]; String server = split[5].replaceAll(".schematic", ""); String color; @@ -157,7 +157,7 @@ public class Load extends SubCommand { color = "$1"; } MainUtil.sendMessage(player, - "$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ";" + id + "$3 | " + color + size + "x" + size); + "$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ';' + id + "$3 | " + color + size + 'x' + size); } catch (Exception e) { e.printStackTrace(); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java index 3e9b624df..08400128e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java @@ -11,7 +11,7 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.general.commands.CommandDeclaration; -import java.util.HashSet; +import java.util.Set; import java.util.UUID; @CommandDeclaration( @@ -27,15 +27,14 @@ public class Owner extends SetCommand { @Override public boolean set(final PlotPlayer plr, final Plot plot, String value) { - HashSet plots = plot.getConnectedPlots(); + Set plots = plot.getConnectedPlots(); UUID uuid = null; String name = null; if (value.length() == 36) { try { uuid = UUID.fromString(value); name = MainUtil.getName(uuid); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } else { uuid = UUIDHandler.getUUID(value, null); name = UUIDHandler.getName(uuid); @@ -43,7 +42,7 @@ public class Owner extends SetCommand { } if (uuid == null) { if (value.equalsIgnoreCase("none")) { - HashSet connected = plot.getConnectedPlots(); + Set connected = plot.getConnectedPlots(); plot.unlinkPlot(false, false); for (Plot current : connected) { current.unclaim(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index eb5070158..7a3e67176 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotInventory; import com.intellectualcrafters.plot.object.PlotItemStack; @@ -61,7 +62,7 @@ public class Rate extends SubCommand { }); UUID uuid = player.getUUID(); for (Plot p : plots) { - if ((!Settings.REQUIRE_DONE || p.getFlags().containsKey("done")) && p.isBasePlot() && (p.hasRatings() || !p.getRatings() + if ((!Settings.REQUIRE_DONE || p.hasFlag(Flags.DONE)) && p.isBasePlot() && (p.hasRatings() || !p.getRatings() .containsKey(uuid)) && !p.isAdded(uuid)) { p.teleportPlayer(player); MainUtil.sendMessage(player, C.RATE_THIS); @@ -84,7 +85,7 @@ public class Rate extends SubCommand { sendMessage(player, C.RATING_NOT_YOUR_OWN); return false; } - if (Settings.REQUIRE_DONE && !plot.getFlags().containsKey("done")) { + if (Settings.REQUIRE_DONE && !plot.hasFlag(Flags.DONE)) { sendMessage(player, C.RATING_NOT_DONE); return false; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index 6b9ceefc5..64da9db21 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.configuration.ConfigurationSection; +import com.intellectualcrafters.configuration.InvalidConfigurationException; import com.intellectualcrafters.configuration.MemorySection; import com.intellectualcrafters.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PS; @@ -11,6 +12,7 @@ import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.MainUtil; import com.plotsquared.general.commands.CommandDeclaration; +import java.io.IOException; import java.util.Objects; @CommandDeclaration(command = "reload", @@ -77,7 +79,7 @@ public class Reload extends SubCommand { }); PS.get().config.save(PS.get().configFile); MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); - } catch (Exception e) { + } catch (InvalidConfigurationException | IOException e) { e.printStackTrace(); MainUtil.sendMessage(plr, C.RELOAD_FAILED); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Trim.java index 94af9bdb8..ca83543bc 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -52,15 +52,7 @@ public class Trim extends SubCommand { String name = file.getName(); if (name.endsWith("mca")) { if (file.getTotalSpace() <= 8192) { - try { - String[] split = name.split("\\."); - int x = Integer.parseInt(split[1]); - int z = Integer.parseInt(split[2]); - ChunkLoc loc = new ChunkLoc(x, z); - empty.add(loc); - } catch (NumberFormatException e) { - PS.debug("INVALID MCA: " + name); - } + checkMca(name); } else { Path path = Paths.get(file.getPath()); try { @@ -69,24 +61,26 @@ public class Trim extends SubCommand { long modification = file.lastModified(); long diff = Math.abs(creation - modification); if (diff < 10000) { - try { - String[] split = name.split("\\."); - int x = Integer.parseInt(split[1]); - int z = Integer.parseInt(split[2]); - ChunkLoc loc = new ChunkLoc(x, z); - empty.add(loc); - } catch (Exception e) { - PS.debug("INVALID MCA: " + name); - } + checkMca(name); } - } catch (IOException ignored) { - } + } catch (IOException ignored) {} } } } Trim.TASK = false; TaskManager.runTaskAsync(whenDone); } + private void checkMca(String name) { + try { + String[] split = name.split("\\."); + int x = Integer.parseInt(split[1]); + int z = Integer.parseInt(split[2]); + ChunkLoc loc = new ChunkLoc(x, z); + empty.add(loc); + } catch (NumberFormatException ignored) { + PS.debug("INVALID MCA: " + name); + } + } }); Trim.TASK = true; return true; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java index e1545b98e..211821a55 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -162,8 +162,7 @@ public class Configuration { if (result != null && result.match < 2) { values[i] = result.best; } - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } int gcd = gcd(counts); for (int i = 0; i < counts.length; i++) { 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 eb9f1c904..dbe9c2231 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -182,16 +182,13 @@ public class SQLManager implements AbstractDB { } @Override - public void set(PreparedStatement stmt) { - } + public void set(PreparedStatement stmt) {} @Override - public void addBatch(PreparedStatement statement) { - } + public void addBatch(PreparedStatement statement) {} @Override - public void execute(PreparedStatement statement) { - } + public void execute(PreparedStatement statement) {} }; } @@ -216,16 +213,13 @@ public class SQLManager implements AbstractDB { } @Override - public void set(PreparedStatement stmt) { - } + public void set(PreparedStatement stmt) {} @Override - public void addBatch(PreparedStatement statement) { - } + public void addBatch(PreparedStatement statement) {} @Override - public void execute(PreparedStatement statement) { - } + public void execute(PreparedStatement statement) {} }; } @@ -247,16 +241,13 @@ public class SQLManager implements AbstractDB { } @Override - public void set(PreparedStatement stmt) { - } + public void set(PreparedStatement stmt) {} @Override - public void addBatch(PreparedStatement statement) { - } + public void addBatch(PreparedStatement statement) {} @Override - public void execute(PreparedStatement statement) { - } + public void execute(PreparedStatement statement) {} }; } @@ -990,8 +981,7 @@ public class SQLManager implements AbstractDB { } @Override - public void execute(PreparedStatement statement) { - } + public void execute(PreparedStatement statement) {} @Override public void addBatch(PreparedStatement statement) throws SQLException { @@ -1808,8 +1798,7 @@ public class SQLManager implements AbstractDB { default: try { plot.getSettings().setPosition(BlockLoc.fromString(pos)); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } Integer m = resultSet.getInt("merged"); boolean[] merged = new boolean[4]; @@ -1963,7 +1952,7 @@ public class SQLManager implements AbstractDB { @Override public void setFlags(final Plot plot, HashMap, Object> flags) { - final String flag_string = FlagManager.toString(flags); //todo MattBDev: Fix this for flags to work. + final String flag_string = FlagManager.toString(flags); addPlotTask(plot, new UniqueStatement("setFlags") { @Override public void set(PreparedStatement stmt) throws SQLException { @@ -2178,8 +2167,7 @@ public class SQLManager implements AbstractDB { } @Override - public void execute(PreparedStatement statement) { - } + public void execute(PreparedStatement statement) {} @Override public void addBatch(PreparedStatement statement) throws SQLException { @@ -2480,8 +2468,7 @@ public class SQLManager implements AbstractDB { } @Override - public void execute(PreparedStatement statement) { - } + public void execute(PreparedStatement statement) {} @Override public void addBatch(PreparedStatement statement) throws SQLException { @@ -2621,8 +2608,7 @@ public class SQLManager implements AbstractDB { try { BlockLoc loc = BlockLoc.fromString(pos); cluster.settings.setPosition(loc); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } Integer m = resultSet.getInt("merged"); boolean[] merged = new boolean[4]; @@ -2690,9 +2676,8 @@ public class SQLManager implements AbstractDB { if (i != 0) { flag_string.append(','); } - flag_string.append(flag.getKey().getName()).append(":") - .append(flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯").replaceAll(",", - "´")); + flag_string.append(flag.getKey().getName()).append(':') + .append(flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); i++; } addClusterTask(cluster, new UniqueStatement("setFlags") { @@ -2781,8 +2766,7 @@ public class SQLManager implements AbstractDB { } @Override - public void execute(PreparedStatement statement) { - } + public void execute(PreparedStatement statement) {} @Override public void addBatch(PreparedStatement statement) throws SQLException { 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 467fb99c8..c099af9b0 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -63,9 +63,8 @@ public class FlagManager { public static String toString(HashMap, Object> flags) { StringBuilder flag_string = new StringBuilder(); int i = 0; - Flag flag; for (Map.Entry, Object> entry : flags.entrySet()) { - flag = entry.getKey(); + Flag flag = entry.getKey(); if (i != 0) { flag_string.append(","); } @@ -132,7 +131,7 @@ public class FlagManager { * @param plot * @return set of flags */ - public static HashMap, Object> getPlotFlags(Plot plot) { + public static Map, Object> getPlotFlags(Plot plot) { if (!plot.hasOwner()) { return null; } @@ -158,7 +157,7 @@ public class FlagManager { return flags; } - public static HashMap, Object> getSettingFlags(PlotArea area, PlotSettings settings) { + public static Map, Object> getSettingFlags(PlotArea area, PlotSettings settings) { return getPlotFlags(area, settings, false); } @@ -227,7 +226,7 @@ public class FlagManager { * * @param player with permissions * - * @return List (AbstractFlag) + * @return List (Flag) */ public static List getFlags(PlotPlayer player) { List returnFlags = new ArrayList<>(); @@ -240,11 +239,11 @@ public class FlagManager { } /** - * Get an AbstractFlag by a string Returns null if flag does not exist + * Get an Flag by a String * - * @param string Flag Key + * @param string the flag name * - * @return AbstractFlag + * @return the flag or null if the flag the provided name does not exist */ public static Flag getFlag(String string) { for (Flag flag : Flags.getFlags()) { @@ -258,7 +257,7 @@ public class FlagManager { return null; } - public static HashMap, Object> parseFlags(List flagstrings) { + public static Map, Object> parseFlags(List flagstrings) { HashMap, Object> map = new HashMap<>(); for (String key : flagstrings) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/AugmentedUtils.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/AugmentedUtils.java index 15dd548b9..019b383ee 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/AugmentedUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/AugmentedUtils.java @@ -143,8 +143,7 @@ public class AugmentedUtils { } @Override - public void setBiome(int x, int z, int biome) { - } + public void setBiome(int x, int z, int biome) {} @Override public PlotChunk clone() { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java index 84fe328de..81ac2d5a5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java @@ -55,8 +55,7 @@ public abstract class IndependentPlotGenerator { * - e.g. If setup doesn't support some standard options * @param setup */ - public void processSetup(SetupObject setup) { - } + public void processSetup(SetupObject setup) {} /** * It is preferred for the PlotArea object to do most of the initialization necessary. diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java index 611a982cb..b60e0e0c5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -176,7 +176,7 @@ public abstract class SquarePlotManager extends GridPlotManager { return plot.getMerged(7) ? id : null; } PS.debug("invalid location: " + Arrays.toString(merged)); - } catch (Exception e) { + } catch (Exception ignored) { PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname); } return null; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java index 33d7d535d..13e6d37d0 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java @@ -87,12 +87,10 @@ public class ConsolePlayer extends PlotPlayer { } @Override - public void setCompassTarget(Location location) { - } + public void setCompassTarget(Location location) {} @Override - public void setAttribute(String key) { - } + public void setAttribute(String key) {} @Override public boolean getAttribute(String key) { @@ -100,8 +98,7 @@ public class ConsolePlayer extends PlotPlayer { } @Override - public void removeAttribute(String key) { - } + public void removeAttribute(String key) {} @Override public void setMeta(String key, Object value) { @@ -124,8 +121,7 @@ public class ConsolePlayer extends PlotPlayer { } @Override - public void setWeather(PlotWeather weather) { - } + public void setWeather(PlotWeather weather) {} @Override public PlotGameMode getGameMode() { @@ -133,24 +129,19 @@ public class ConsolePlayer extends PlotPlayer { } @Override - public void setGameMode(PlotGameMode gameMode) { - } + public void setGameMode(PlotGameMode gameMode) {} @Override - public void setTime(long time) { - } + public void setTime(long time) {} @Override - public void setFlight(boolean fly) { - } + public void setFlight(boolean fly) {} @Override - public void playMusic(Location location, int id) { - } + public void playMusic(Location location, int id) {} @Override - public void kick(String message) { - } + public void kick(String message) {} @Override public void stopSpectating() {} diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 3fe67531d..b781d5f1c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -335,7 +335,7 @@ public class Plot { if (!isMerged()) { return false; } - HashSet connected = getConnectedPlots(); + Set connected = getConnectedPlots(); for (Plot current : connected) { if (uuid.equals(current.owner)) { return true; @@ -350,14 +350,14 @@ public class Plot { /** * Get a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots). - * @return + * @return the Plot owners */ public Set getOwners() { if (this.owner == null) { - return new HashSet<>(); + return Collections.emptySet(); } if (isMerged()) { - HashSet plots = getConnectedPlots(); + Set plots = getConnectedPlots(); Plot[] array = plots.toArray(new Plot[plots.size()]); ImmutableSet.Builder owners = ImmutableSet.builder(); UUID last = this.owner; @@ -747,14 +747,11 @@ public class Plot { } public boolean clear(boolean checkRunning, final boolean isDelete, final Runnable whenDone) { - if (checkRunning && this.getRunning() != 0) { - return false; - } - if (!EventUtil.manager.callClear(this)) { + if (checkRunning && this.getRunning() != 0 || !EventUtil.manager.callClear(this)) { return false; } final HashSet regions = this.getRegions(); - final HashSet plots = this.getConnectedPlots(); + final Set plots = this.getConnectedPlots(); final ArrayDeque queue = new ArrayDeque<>(plots); if (isDelete) { this.removeSign(); @@ -841,7 +838,7 @@ public class Plot { } /** - * Unlink the plot and all connected plots + * Unlink the plot and all connected plots. * @param createSign * @param createRoad * @return @@ -850,7 +847,7 @@ public class Plot { if (!this.isMerged()) { return false; } - HashSet plots = this.getConnectedPlots(); + Set plots = this.getConnectedPlots(); ArrayList ids = new ArrayList<>(plots.size()); for (Plot current : plots) { current.setHome(null); @@ -982,7 +979,7 @@ public class Plot { if (!this.hasOwner()) { return false; } - final HashSet plots = this.getConnectedPlots(); + final Set plots = this.getConnectedPlots(); this.clear(false, true, new Runnable() { @Override public void run() { @@ -1062,9 +1059,8 @@ public class Plot { } /** - * Unclaim the plot (does not modify terrain)
- * - Changes made to this plot will not be reflected in unclaimed plot objects
- * @return + * Unclaim the plot (does not modify terrain). Changes made to this plot will not be reflected in unclaimed plot objects. + * @return false if the Plot has no owner, otherwise true. */ public boolean unclaim() { if (this.owner == null) { @@ -1264,9 +1260,7 @@ public class Plot { }); } - /** - * Remove the plot sign if it is set - */ + /** Remove the plot sign if it is set. */ public void removeSign() { PlotManager manager = this.area.getPlotManager(); if (!this.area.ALLOW_SIGNS) { @@ -1276,9 +1270,7 @@ public class Plot { SetQueue.IMP.setBlock(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), 0); } - /** - * Set the plot sign if plot signs are enabled. - */ + /** Set the plot sign if plot signs are enabled. */ public void setSign() { if (this.owner == null) { this.setSign("unknown"); @@ -2076,7 +2068,7 @@ public class Plot { } HashSet visited = new HashSet<>(); HashSet merged = new HashSet<>(); - HashSet connected = this.getConnectedPlots(); + Set connected = this.getConnectedPlots(); for (Plot current : connected) { merged.add(current.getId()); } @@ -2091,8 +2083,7 @@ public class Plot { Set plots; if ((dir == -1 || dir == 0) && !current.getMerged(0)) { Plot other = current.getRelative(0); - if (other != null - && other.isOwner(uuid) + if (other != null && other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) || (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) { current.mergePlot(other, removeRoads); @@ -2103,12 +2094,9 @@ public class Plot { } if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) { Plot other = current.getRelative(1); - if (other != null - && other.isOwner(uuid) + if (other != null && other.isOwner(uuid) && (other.getBasePlot(false).equals(current.getBasePlot(false)) - || (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && - - (max -= plots.size()) != -1)) { + || (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) { current.mergePlot(other, removeRoads); merged.add(current.getId()); merged.add(other.getId()); @@ -2243,14 +2231,14 @@ public class Plot { * - This result is cached globally * @return */ - public HashSet getConnectedPlots() { + public Set getConnectedPlots() { if (this.settings == null) { - return new HashSet<>(Collections.singletonList(this)); + return Collections.singleton(this); } boolean[] merged = this.getMerged(); int hash = MainUtil.hash(merged); if (hash == 0) { - return new HashSet<>(Collections.singletonList(this)); + return Collections.singleton(this); } if (connected_cache != null && connected_cache.contains(this)) { return connected_cache; @@ -2386,7 +2374,7 @@ public class Plot { regions_cache.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ())); return regions_cache; } - HashSet plots = this.getConnectedPlots(); + Set plots = this.getConnectedPlots(); HashSet regions = regions_cache = new HashSet<>(); HashSet visited = new HashSet<>(); for (Plot current : plots) { @@ -2712,7 +2700,7 @@ public class Plot { return false; } boolean occupied = false; - HashSet plots = this.getConnectedPlots(); + Set plots = this.getConnectedPlots(); for (Plot plot : plots) { Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y); if (other.hasOwner()) { @@ -2806,7 +2794,7 @@ public class Plot { TaskManager.runTaskLater(whenDone, 1); return false; } - HashSet plots = this.getConnectedPlots(); + Set plots = this.getConnectedPlots(); for (Plot plot : plots) { Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y); if (other.hasOwner()) { @@ -2873,7 +2861,6 @@ public class Plot { } public boolean hasFlag(Flag flag) { - //todo - return false; + return getFlags().containsKey(flag); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index 7a0eb8172..128576106 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -7,6 +7,7 @@ import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.generator.GridPlotWorld; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; import com.intellectualcrafters.plot.util.EconHandler; @@ -53,9 +54,9 @@ public abstract class PlotArea { public boolean SCHEMATIC_ON_CLAIM = false; public String SCHEMATIC_FILE = "null"; public List SCHEMATICS = null; - public HashMap, Object> DEFAULT_FLAGS; + public Map, Object> DEFAULT_FLAGS; public boolean USE_ECONOMY = false; - public HashMap PRICES = new HashMap<>(); + public Map PRICES = new HashMap<>(); public boolean SPAWN_EGGS = false; public boolean SPAWN_CUSTOM = true; public boolean SPAWN_BREEDING = false; @@ -165,10 +166,7 @@ public abstract class PlotArea { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } PlotArea plotarea = (PlotArea) obj; @@ -187,11 +185,8 @@ public abstract class PlotArea { public boolean isCompatible(PlotArea plotArea) { ConfigurationSection section = PS.get().config.getConfigurationSection("worlds"); for (ConfigurationNode setting : plotArea.getSettingNodes()) { - Object constant = section.get(plotArea.worldname + "." + setting.getConstant()); - if (constant == null) { - return false; - } - if (!constant.equals(section.get(this.worldname + "." + setting.getConstant()))) { + Object constant = section.get(plotArea.worldname + '.' + setting.getConstant()); + if (constant == null || !constant.equals(section.get(this.worldname + '.' + setting.getConstant()))) { return false; } } @@ -269,7 +264,7 @@ public abstract class PlotArea { try { String[] split = homeDefault.split(","); this.DEFAULT_HOME = new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { this.DEFAULT_HOME = null; } } @@ -283,7 +278,7 @@ public abstract class PlotArea { Set keys = section.getKeys(false); for (String key : keys) { if (!"default".equals(key)) { - flags.add(key + ";" + section.get(key)); + flags.add(key + ';' + section.get(key)); } } } @@ -475,8 +470,8 @@ public abstract class PlotArea { return myPlots; } - public Set getPlots(UUID uuid) { - HashSet myplots = new HashSet<>(); + public Set getPlots(final UUID uuid) { + final HashSet myplots = new HashSet<>(); for (Plot plot : getPlots()) { if (plot.isBasePlot()) { if (plot.isOwner(uuid)) { @@ -488,7 +483,7 @@ public abstract class PlotArea { } public Set getPlots(PlotPlayer player) { - return player != null ? getPlots(player.getUUID()) : new HashSet(); + return getPlots(player.getUUID()); } public Set getPlotsAbs(PlotPlayer player) { @@ -499,7 +494,7 @@ public abstract class PlotArea { int count = 0; if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) { for (Plot plot : getPlotsAbs(uuid)) { - if (!plot.getFlags().containsKey("done")) { + if (!plot.hasFlag(Flags.DONE)) { count++; } } @@ -617,7 +612,7 @@ public abstract class PlotArea { } } - + public void foreachBasePlot(RunnableVal run) { for (Plot plot : getPlots()) { if (plot.isBasePlot()) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotId.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotId.java index 6ebc38930..dfb6b791a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotId.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotId.java @@ -42,7 +42,7 @@ public class PlotId { try { x = Integer.parseInt(parts[0]); y = Integer.parseInt(parts[1]); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { return null; } return new PlotId(x, y); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index b8a60edc4..4675a357e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.Permissions; @@ -145,7 +146,7 @@ public abstract class PlotPlayer implements CommandCaller { public void run(PlotArea value) { if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) { for (Plot plot : value.getPlotsAbs(uuid)) { - if (!plot.getFlags().containsKey("done")) { + if (!plot.hasFlag(Flags.DONE)) { count.incrementAndGet(); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index c08db1ef7..ff93b902b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -222,8 +222,7 @@ public abstract class ChunkManager { int z = Integer.parseInt(split[2]); ChunkLoc loc = new ChunkLoc(x, z); chunks.add(loc); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } } return chunks; 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 0019882ca..b0f8c53a7 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -431,7 +431,7 @@ public class MainUtil { if (arg == null) { if (player == null) { if (message) { - MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD); + PS.log(C.NOT_VALID_PLOT_WORLD); } return null; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java b/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java index 9275179a8..62cbe04b0 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java @@ -70,8 +70,7 @@ public class ReflectionUtils { Object value = field.get(null); try { list.add((T) value); - } catch (ClassCastException ignored) { - } + } catch (ClassCastException ignored) {} } } catch (IllegalAccessException | IllegalArgumentException | SecurityException e) { e.printStackTrace(); @@ -92,12 +91,11 @@ public class ReflectionUtils { public static Class getUtilClass(String name) { try { return Class.forName(name); //Try before 1.8 first + } catch (ClassNotFoundException ignored) {} + try { + return Class.forName("net.minecraft.util." + name); //Not 1.8 } catch (ClassNotFoundException ignored) { - try { - return Class.forName("net.minecraft.util." + name); //Not 1.8 - } catch (ClassNotFoundException ignored2) { - return null; - } + return null; } } @@ -112,8 +110,6 @@ public class ReflectionUtils { return clazz.getDeclaredMethod(methodName, paramaters); } catch (NoSuchMethodException ignored) { return null; - } catch (SecurityException ex) { - throw new RuntimeException(ex); } } @@ -138,8 +134,6 @@ public class ReflectionUtils { return (Constructor) clazz.getConstructor(paramaterTypes); } catch (NoSuchMethodException ignored) { return null; - } catch (SecurityException ex) { - throw new RuntimeException(ex); } } @@ -162,8 +156,6 @@ public class ReflectionUtils { return clazz.getDeclaredField(name); } catch (NoSuchFieldException ignored) { return null; - } catch (SecurityException ex) { - throw new RuntimeException(ex); } } @@ -187,7 +179,7 @@ public class ReflectionUtils { field.setAccessible(true); try { field.set(instance, value); - } catch (Exception ex) { + } catch (IllegalAccessException | IllegalArgumentException ex) { throw new RuntimeException(ex); } } @@ -195,7 +187,7 @@ public class ReflectionUtils { public static Class getClass(String name) { try { return Class.forName(name); - } catch (ClassNotFoundException ex) { + } catch (ClassNotFoundException ignored) { return null; } } @@ -203,7 +195,7 @@ public class ReflectionUtils { public static Class getClass(String name, Class superClass) { try { return Class.forName(name).asSubclass(superClass); - } catch (ClassCastException | ClassNotFoundException ex) { + } catch (ClassCastException | ClassNotFoundException ignored) { return null; } } @@ -212,21 +204,15 @@ public class ReflectionUtils { * Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace * {nm} to net.minecraft * - * @param classes possible class paths + * @param className possible class paths * * @return RefClass object * - * @throws RuntimeException if no class found + * @throws ClassNotFoundException if no class found */ - public static RefClass getRefClass(String... classes) throws RuntimeException { - for (String className : classes) { - try { - className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"); - return getRefClass(Class.forName(className)); - } catch (ClassNotFoundException ignored) { - } - } - throw new RuntimeException("no class found"); + public static RefClass getRefClass(String className) throws ClassNotFoundException { + className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"); + return getRefClass(Class.forName(className)); } /** @@ -281,26 +267,22 @@ public class ReflectionUtils { * * @throws RuntimeException if method not found */ - public RefMethod getMethod(String name, Object... types) { + public RefMethod getMethod(String name, Object... types) throws NoSuchMethodException { + Class[] classes = new Class[types.length]; + int i = 0; + for (Object e : types) { + if (e instanceof Class) { + classes[i++] = (Class) e; + } else if (e instanceof RefClass) { + classes[i++] = ((RefClass) e).getRealClass(); + } else { + classes[i++] = e.getClass(); + } + } try { - Class[] classes = new Class[types.length]; - int i = 0; - for (Object e : types) { - if (e instanceof Class) { - classes[i++] = (Class) e; - } else if (e instanceof RefClass) { - classes[i++] = ((RefClass) e).getRealClass(); - } else { - classes[i++] = e.getClass(); - } - } - try { - return new RefMethod(this.clazz.getMethod(name, classes)); - } catch (NoSuchMethodException ignored) { - return new RefMethod(this.clazz.getDeclaredMethod(name, classes)); - } - } catch (NoSuchMethodException | SecurityException e) { - throw new RuntimeException(e); + return new RefMethod(this.clazz.getMethod(name, classes)); + } catch (NoSuchMethodException ignored) { + return new RefMethod(this.clazz.getDeclaredMethod(name, classes)); } } @@ -313,26 +295,22 @@ public class ReflectionUtils { * * @throws RuntimeException if constructor not found */ - public RefConstructor getConstructor(Object... types) { + public RefConstructor getConstructor(Object... types) throws NoSuchMethodException { + Class[] classes = new Class[types.length]; + int i = 0; + for (Object e : types) { + if (e instanceof Class) { + classes[i++] = (Class) e; + } else if (e instanceof RefClass) { + classes[i++] = ((RefClass) e).getRealClass(); + } else { + classes[i++] = e.getClass(); + } + } try { - Class[] classes = new Class[types.length]; - int i = 0; - for (Object e : types) { - if (e instanceof Class) { - classes[i++] = (Class) e; - } else if (e instanceof RefClass) { - classes[i++] = ((RefClass) e).getRealClass(); - } else { - classes[i++] = e.getClass(); - } - } - try { - return new RefConstructor(this.clazz.getConstructor(classes)); - } catch (NoSuchMethodException ignored) { - return new RefConstructor(this.clazz.getDeclaredConstructor(classes)); - } - } catch (NoSuchMethodException | SecurityException e) { - throw new RuntimeException(e); + return new RefConstructor(this.clazz.getConstructor(classes)); + } catch (NoSuchMethodException ignored) { + return new RefConstructor(this.clazz.getDeclaredConstructor(classes)); } } @@ -466,15 +444,11 @@ public class ReflectionUtils { * * @throws RuntimeException if field not found */ - public RefField getField(String name) { + public RefField getField(String name) throws NoSuchFieldException { try { - try { - return new RefField(this.clazz.getField(name)); - } catch (NoSuchFieldException ignored) { - return new RefField(this.clazz.getDeclaredField(name)); - } - } catch (Exception e) { - throw new RuntimeException(e); + return new RefField(this.clazz.getField(name)); + } catch (NoSuchFieldException ignored) { + return new RefField(this.clazz.getDeclaredField(name)); } } @@ -570,7 +544,7 @@ public class ReflectionUtils { public Object call(Object... params) { try { return this.method.invoke(null, params); - } catch (Exception e) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java index 2fdc8d0b1..2e52fb87c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java @@ -152,7 +152,7 @@ public abstract class UUIDHandlerImplementation { } return false; } - } catch (Exception e) { + } catch (Exception ignored) { BiMap inverse = this.uuidMap.inverse(); if (inverse.containsKey(uuid)) { if (this.uuidMap.containsKey(name)) { diff --git a/Core/src/main/java/com/plotsquared/general/commands/Argument.java b/Core/src/main/java/com/plotsquared/general/commands/Argument.java index f8a0249c5..f9696a7b6 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Argument.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Argument.java @@ -10,8 +10,7 @@ public abstract class Argument { Integer value = null; try { value = java.lang.Integer.parseInt(in); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} return value; } }; diff --git a/Core/src/main/java/com/plotsquared/general/commands/Command.java b/Core/src/main/java/com/plotsquared/general/commands/Command.java index 31acf7791..8290b0257 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Command.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Command.java @@ -298,8 +298,7 @@ public abstract class Command { MainCommand.getInstance().help.execute(player, args, null, null); return; } - } catch (IllegalArgumentException ignored) { - } + } catch (IllegalArgumentException ignored) {} // Command recommendation MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND); List commands = getCommands(player); diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index b8204ec5a..69fd48a63 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -43,7 +43,7 @@ public class PlotListener { pp.setMeta("lastplot", plot); EventUtil.manager.callEntry(pp, plot); if (plot.hasOwner()) { - HashMap, Object> flags = FlagManager.getPlotFlags(plot); + Map, Object> flags = FlagManager.getPlotFlags(plot); int size = flags.size(); boolean titles = Settings.TITLES; final String greeting; @@ -122,8 +122,7 @@ public class PlotListener { try { pp.setMeta("music", loc); pp.playMusic(loc, id); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } } } else { diff --git a/Core/src/main/java/com/plotsquared/listener/WESubscriber.java b/Core/src/main/java/com/plotsquared/listener/WESubscriber.java index ecda7b943..36ae2c632 100644 --- a/Core/src/main/java/com/plotsquared/listener/WESubscriber.java +++ b/Core/src/main/java/com/plotsquared/listener/WESubscriber.java @@ -84,8 +84,7 @@ public class WESubscriber { if (tool instanceof BrushTool) { hasMask = ((BrushTool) tool).getMask() != null; } - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } AbstractDelegateExtent extent = (AbstractDelegateExtent) event.getExtent(); ChangeSetExtent history = null; diff --git a/Core/src/test/java/com/intellectualcrafters/plot/database/AbstractDBTEst.java b/Core/src/test/java/com/intellectualcrafters/plot/database/AbstractDBTEst.java index c04f69238..9d5a6ec2c 100644 --- a/Core/src/test/java/com/intellectualcrafters/plot/database/AbstractDBTEst.java +++ b/Core/src/test/java/com/intellectualcrafters/plot/database/AbstractDBTEst.java @@ -17,53 +17,37 @@ import java.util.UUID; public class AbstractDBTest implements AbstractDB { - @Override public void setOwner(Plot plot, UUID uuid) { - } + @Override public void setOwner(Plot plot, UUID uuid) {} - @Override public void createPlotsAndData(ArrayList plots, Runnable whenDone) { - } + @Override public void createPlotsAndData(ArrayList plots, Runnable whenDone) {} - @Override public void createPlot(Plot plot) { - } + @Override public void createPlot(Plot plot) {} - @Override public void createTables() { - } + @Override public void createTables() {} - @Override public void delete(Plot plot) { - } + @Override public void delete(Plot plot) {} - @Override public void deleteSettings(Plot plot) { - } + @Override public void deleteSettings(Plot plot) {} - @Override public void deleteHelpers(Plot plot) { - } + @Override public void deleteHelpers(Plot plot) {} - @Override public void deleteTrusted(Plot plot) { - } + @Override public void deleteTrusted(Plot plot) {} - @Override public void deleteDenied(Plot plot) { - } + @Override public void deleteDenied(Plot plot) {} - @Override public void deleteComments(Plot plot) { - } + @Override public void deleteComments(Plot plot) {} - @Override public void deleteRatings(Plot plot) { - } + @Override public void deleteRatings(Plot plot) {} - @Override public void delete(PlotCluster cluster) { - } + @Override public void delete(PlotCluster cluster) {} - @Override public void addPersistentMeta(UUID uuid, String key, byte[] meta, boolean delete) { - } + @Override public void addPersistentMeta(UUID uuid, String key, byte[] meta, boolean delete) {} - @Override public void removePersistentMeta(UUID uuid, String key) { - } + @Override public void removePersistentMeta(UUID uuid, String key) {} - @Override public void getPersistentMeta(UUID uuid, RunnableVal> result) { - } + @Override public void getPersistentMeta(UUID uuid, RunnableVal> result) {} - @Override public void createPlotSettings(int id, Plot plot) { - } + @Override public void createPlotSettings(int id, Plot plot) {} @Override public int getId(Plot plot) { return 0; @@ -77,117 +61,83 @@ public class AbstractDBTest implements AbstractDB { return null; } - @Override public void validateAllPlots(Set toValidate) { - } + @Override public void validateAllPlots(Set toValidate) {} @Override public HashMap> getClusters() { return null; } - @Override public void setMerged(Plot plot, boolean[] merged) { - } + @Override public void setMerged(Plot plot, boolean[] merged) {} - @Override public void swapPlots(Plot plot1, Plot plot2) { - } + @Override public void swapPlots(Plot plot1, Plot plot2) {} - @Override public void setFlags(Plot plot, HashMap, Object> flags) { - } + @Override public void setFlags(Plot plot, HashMap, Object> flags) {} - @Override public void setFlags(PlotCluster cluster, HashMap, Object> flags) { - } + @Override public void setFlags(PlotCluster cluster, HashMap, Object> flags) {} - @Override public void setClusterName(PlotCluster cluster, String name) { - } + @Override public void setClusterName(PlotCluster cluster, String name) {} - @Override public void setAlias(Plot plot, String alias) { - } + @Override public void setAlias(Plot plot, String alias) {} - @Override public void purgeIds(Set uniqueIds) { - } + @Override public void purgeIds(Set uniqueIds) {} - @Override public void purge(PlotArea area, Set plotIds) { - } + @Override public void purge(PlotArea area, Set plotIds) {} - @Override public void setPosition(Plot plot, String position) { - } + @Override public void setPosition(Plot plot, String position) {} - @Override public void setPosition(PlotCluster cluster, String position) { - } + @Override public void setPosition(PlotCluster cluster, String position) {} - @Override public void removeTrusted(Plot plot, UUID uuid) { - } + @Override public void removeTrusted(Plot plot, UUID uuid) {} - @Override public void removeHelper(PlotCluster cluster, UUID uuid) { - } + @Override public void removeHelper(PlotCluster cluster, UUID uuid) {} - @Override public void removeMember(Plot plot, UUID uuid) { - } + @Override public void removeMember(Plot plot, UUID uuid) {} - @Override public void removeInvited(PlotCluster cluster, UUID uuid) { - } + @Override public void removeInvited(PlotCluster cluster, UUID uuid) {} - @Override public void setTrusted(Plot plot, UUID uuid) { - } + @Override public void setTrusted(Plot plot, UUID uuid) {} - @Override public void setHelper(PlotCluster cluster, UUID uuid) { - } + @Override public void setHelper(PlotCluster cluster, UUID uuid) {} - @Override public void setMember(Plot plot, UUID uuid) { - } + @Override public void setMember(Plot plot, UUID uuid) {} - @Override public void setInvited(PlotCluster cluster, UUID uuid) { - } + @Override public void setInvited(PlotCluster cluster, UUID uuid) {} - @Override public void removeDenied(Plot plot, UUID uuid) { - } + @Override public void removeDenied(Plot plot, UUID uuid) {} - @Override public void setDenied(Plot plot, UUID uuid) { - } + @Override public void setDenied(Plot plot, UUID uuid) {} @Override public HashMap getRatings(Plot plot) { return null; } - @Override public void setRating(Plot plot, UUID rater, int value) { - } + @Override public void setRating(Plot plot, UUID rater, int value) {} - @Override public void removeComment(Plot plot, PlotComment comment) { - } + @Override public void removeComment(Plot plot, PlotComment comment) {} - @Override public void clearInbox(Plot plot, String inbox) { - } + @Override public void clearInbox(Plot plot, String inbox) {} - @Override public void setComment(Plot plot, PlotComment comment) { - } + @Override public void setComment(Plot plot, PlotComment comment) {} - @Override public void getComments(Plot plot, String inbox, RunnableVal> whenDone) { - } + @Override public void getComments(Plot plot, String inbox, RunnableVal> whenDone) {} - @Override public void createPlotAndSettings(Plot plot, Runnable whenDone) { - } + @Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {} - @Override public void createCluster(PlotCluster cluster) { - } + @Override public void createCluster(PlotCluster cluster) {} - @Override public void resizeCluster(PlotCluster current, PlotId min, PlotId max) { - } + @Override public void resizeCluster(PlotCluster current, PlotId min, PlotId max) {} - @Override public void movePlot(Plot originalPlot, Plot newPlot) { - } + @Override public void movePlot(Plot originalPlot, Plot newPlot) {} - @Override public void replaceUUID(UUID old, UUID now) { - } + @Override public void replaceUUID(UUID old, UUID now) {} @Override public boolean deleteTables() { return false; } - @Override public void close() { - } + @Override public void close() {} - @Override public void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max) { - } + @Override public void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max) {} - @Override public void updateTables(int[] oldVersion) { - } + @Override public void updateTables(int[] oldVersion) {} } diff --git a/Core/src/test/java/com/intellectualcrafters/plot/util/EventUtilTest.java b/Core/src/test/java/com/intellectualcrafters/plot/util/EventUtilTest.java index 88d26c1ed..e093b9b9e 100644 --- a/Core/src/test/java/com/intellectualcrafters/plot/util/EventUtilTest.java +++ b/Core/src/test/java/com/intellectualcrafters/plot/util/EventUtilTest.java @@ -30,8 +30,7 @@ public class EventUtilTest extends EventUtil { return false; } - @Override public void callDelete(Plot plot) { - } + @Override public void callDelete(Plot plot) {} @Override public boolean callFlagAdd(Flag flag, Plot plot) { return true; @@ -53,18 +52,13 @@ public class EventUtilTest extends EventUtil { return false; } - @Override public void callEntry(PlotPlayer player, Plot plot) { - } + @Override public void callEntry(PlotPlayer player, Plot plot) {} - @Override public void callLeave(PlotPlayer player, Plot plot) { - } + @Override public void callLeave(PlotPlayer player, Plot plot) {} - @Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) { - } + @Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {} - @Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) { - } + @Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {} - @Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) { - } + @Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {} } \ No newline at end of file diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java index fad765e6d..00bc42d61 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -19,8 +19,7 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { private static SpongeAugmentedGenerator generator; - private SpongeAugmentedGenerator() { - } + private SpongeAugmentedGenerator() {} public static SpongeAugmentedGenerator get(World world) { WorldGenerator wg = world.getWorldGenerator(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index 961d12b7d..a750627a7 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -139,13 +139,14 @@ public class SpongeUtil extends WorldUtil { } }; } - + private static void initBlockCache() { try { PS.debug("Caching block id/data: Please wait..."); stateArray = new BlockState[Character.MAX_VALUE]; stateMap = new HashMap<>(); - Method methodGetByCombinedId = ReflectionUtils.findMethod(Class.forName("net.minecraft.block.Block"), true, Class.forName("net.minecraft.block.state.IBlockState"), int.class); + Method methodGetByCombinedId = ReflectionUtils + .findMethod(Class.forName("net.minecraft.block.Block"), true, Class.forName("net.minecraft.block.state.IBlockState"), int.class); for (int i = 0; i < Character.MAX_VALUE; i++) { try { BlockState state = (BlockState) methodGetByCombinedId.invoke(null, i); @@ -159,11 +160,11 @@ public class SpongeUtil extends WorldUtil { } } PS.debug("Done!"); - } catch (Throwable e) { + } catch (ClassNotFoundException e) { e.printStackTrace(); } } - + public static BlockState getBlockState(int id, int data) { return (BlockState) Block.getBlockById(id).getStateFromMeta(data); } @@ -251,15 +252,15 @@ public class SpongeUtil extends WorldUtil { } return new org.spongepowered.api.world.Location<>(world.get(), location.getX(), location.getY(), location.getZ()); } - + public static Location getLocation(String world, Vector3i position) { return new Location(world, position.getX(), position.getY(), position.getZ()); } - + public static Location getLocation(String world, Vector3d position) { return new Location(world, MathMan.roundInt(position.getX()), MathMan.roundInt(position.getY()), MathMan.roundInt(position.getZ())); } - + @Override public boolean isBlockSolid(PlotBlock block) { BlockState state = SpongeUtil.getBlockState(block.id, block.data); @@ -270,7 +271,7 @@ public class SpongeUtil extends WorldUtil { return false; } } - + @Override public StringComparison.ComparisonResult getClosestBlock(String name) { try { @@ -304,17 +305,16 @@ public class SpongeUtil extends WorldUtil { StringComparison outer = new StringComparison(); return outer.new ComparisonResult(match, block); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} return null; } - + @Override public String getClosestMatchingName(PlotBlock block) { // TODO Auto-generated method stub return null; } - + @Override public String[] getBiomeList() { if (biomes == null) { @@ -322,13 +322,13 @@ public class SpongeUtil extends WorldUtil { } return biomeMap.keySet().toArray(new String[biomeMap.size()]); } - + @Override public boolean addItems(String world, PlotItem items) { // TODO Auto-generated method stub throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } - + @Override public int getBiomeFromString(String biome) { if (biomes == null) { @@ -336,12 +336,12 @@ public class SpongeUtil extends WorldUtil { } return biomeMap.get(biome.toUpperCase()); } - + @Override public String getBiome(String world, int x, int z) { return SpongeUtil.getWorld(world).getBiome(x, z).getName().toUpperCase(); } - + @Override public PlotBlock getBlock(Location location) { BlockState state = SpongeUtil.getWorld(location.getWorld()).getBlock(location.getX(), location.getY(), location.getZ()); @@ -397,17 +397,17 @@ public class SpongeUtil extends WorldUtil { } return result; } - + @Override public boolean isWorld(String worldName) { return SpongeUtil.getWorld(worldName) != null; } - + @Override public String getMainWorld() { return Sponge.getServer().getWorlds().iterator().next().getName(); } - + @Override public int getHighestBlock(String worldName, int x, int z) { World world = SpongeUtil.getWorld(worldName); @@ -422,7 +422,7 @@ public class SpongeUtil extends WorldUtil { } return 64; } - + @Override public void setSign(String worldName, int x, int y, int z, String[] lines) { World world = SpongeUtil.getWorld(worldName); @@ -442,7 +442,7 @@ public class SpongeUtil extends WorldUtil { } sign.offer(Keys.SIGN_LINES, text); } - + @Override public void setBiomes(String worldName, RegionWrapper region, String biomename) { World world = SpongeUtil.getWorld(worldName);