From 32d4a08db1ac91599280e3425c0b77b2c71c561b Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 4 Mar 2016 19:53:31 -0500 Subject: [PATCH] Small cleanup --- .../bukkit/util/block/FastQueue_1_7.java | 22 +++++++++---------- .../bukkit/util/block/FastQueue_1_8.java | 4 ++-- .../bukkit/util/block/FastQueue_1_8_3.java | 21 +++++++++++++----- .../bukkit/util/block/FastQueue_1_9.java | 21 +++++++++++++----- .../plot/config/Configuration.java | 22 ++++++++----------- 5 files changed, 52 insertions(+), 38 deletions(-) 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 69e84301c..1fa2b00c0 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 @@ -25,19 +25,19 @@ import java.util.Map.Entry; public class FastQueue_1_7 extends SlowQueue { - public final RefClass classBlock = getRefClass("{nms}.Block"); - public final RefClass classChunk = getRefClass("{nms}.Chunk"); - public final RefClass classWorld = getRefClass("{nms}.World"); - public final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld"); - public final RefMethod methodGetHandle; - public final RefMethod methodGetChunkAt; - public final RefMethod methodA; - public final RefMethod methodGetById; - public final RefMethod methodInitLighting; + private final RefClass classBlock = getRefClass("{nms}.Block"); + private final RefClass classChunk = getRefClass("{nms}.Chunk"); + private final RefClass classWorld = getRefClass("{nms}.World"); + private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld"); + private final RefMethod methodGetHandle; + private final RefMethod methodGetChunkAt; + private final RefMethod methodA; + private final RefMethod methodGetById; + private final RefMethod methodInitLighting; - public final SendChunk chunksender; + private final SendChunk chunksender; - public HashMap toUpdate = new HashMap<>(); + private HashMap toUpdate = new HashMap<>(); public FastQueue_1_7() throws NoSuchMethodException, RuntimeException { methodGetHandle = classCraftWorld.getMethod("getHandle"); 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 78ae31f71..79e4e6dce 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 @@ -27,14 +27,14 @@ import java.util.Map.Entry; public class FastQueue_1_8 extends SlowQueue { - public final RefMethod methodInitLighting; + private final RefMethod methodInitLighting; private final RefClass classBlock = getRefClass("{nms}.Block"); private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); private final RefClass classIBlockData = getRefClass("{nms}.IBlockData"); private final RefClass classChunk = getRefClass("{nms}.Chunk"); private final RefClass classWorld = getRefClass("{nms}.World"); private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld"); - public HashMap toUpdate = new HashMap<>(); + private HashMap toUpdate = new HashMap<>(); private RefMethod methodGetHandle; private RefMethod methodGetChunkAt; private RefMethod methodA; 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 f0dcb1341..1003d9d4c 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 @@ -1,14 +1,20 @@ package com.plotsquared.bukkit.util.block; +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlotChunk; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; +import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; +import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.SendChunk; import org.bukkit.Chunk; @@ -20,14 +26,17 @@ import org.bukkit.block.Biome; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; - -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; +import java.util.Set; public class FastQueue_1_8_3 extends SlowQueue { - public final SendChunk chunksender; + private final SendChunk chunksender; private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer"); private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk"); private final RefClass classPacket = getRefClass("{nms}.Packet"); @@ -39,7 +48,7 @@ public class FastQueue_1_8_3 extends SlowQueue { private final RefField mustSave = classChunk.getField("mustSave"); private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection"); - public HashMap toUpdate = new HashMap<>(); + private HashMap toUpdate = new HashMap<>(); private RefMethod methodGetHandleChunk; private RefConstructor MapChunk; private RefMethod methodInitLighting; 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 194e3febc..ec19fece4 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 @@ -1,14 +1,20 @@ package com.plotsquared.bukkit.util.block; +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlotChunk; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; +import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; +import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.SendChunk; import org.bukkit.Chunk; @@ -20,14 +26,17 @@ import org.bukkit.block.Biome; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; - -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; +import java.util.Set; public class FastQueue_1_9 extends SlowQueue { - public final SendChunk chunksender; + private final SendChunk chunksender; private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer"); private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk"); private final RefClass classPacket = getRefClass("{nms}.Packet"); @@ -41,7 +50,7 @@ public class FastQueue_1_9 extends SlowQueue { private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection"); private final RefClass classBlock = getRefClass("{nms}.Block"); private final RefClass classIBlockData = getRefClass("{nms}.IBlockData"); - public HashMap toUpdate = new HashMap<>(); + private HashMap toUpdate = new HashMap<>(); private RefMethod methodGetHandleChunk; private RefConstructor MapChunk; private RefMethod methodInitLighting; 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 b3acb1c50..7a0b40d18 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -20,15 +20,16 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.config; -import java.util.ArrayList; - import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.WorldUtil; +import java.util.ArrayList; + /** * Main Configuration Utility - * + * + */ public class Configuration { @@ -124,14 +125,8 @@ public class Configuration { public static final SettingValue BLOCK = new SettingValue("BLOCK") { @Override public boolean validateValue(final String string) { - try { - final StringComparison.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string); - if ((value == null) || (value.match > 1)) { - return false; - } - return true; - } catch (final Exception e) {} - return false; + final StringComparison.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string); + return !((value == null) || (value.match > 1)); } @Override @@ -159,7 +154,7 @@ public class Configuration { } } return true; - } catch (final Exception e) { + } catch (NumberFormatException e) { return false; } } @@ -191,7 +186,8 @@ public class Configuration { if ((result != null) && (result.match < 2)) { values[i] = result.best; } - } catch (final Exception e) {} + } catch (NumberFormatException e) { + } } final int gcd = gcd(counts); for (int i = 0; i < counts.length; i++) {