diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 8925bb2bd..a753a0931 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -139,7 +139,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void log(String message) { - if ((THIS != null) && (Bukkit.getServer().getConsoleSender() != null)) { + if (THIS != null && Bukkit.getServer().getConsoleSender() != null) { try { message = C.color(message); if (!Settings.CONSOLE_COLOR) { @@ -377,7 +377,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); final String version = BukkitMain.worldEdit.getDescription().getVersion(); - if ((version != null) && version.startsWith("5.")) { + if (version != null && version.startsWith("5.")) { log("&cThis version of WorldEdit does not support PlotSquared."); log("&cPlease use WorldEdit 6+ for masking support"); log("&c - http://builds.enginehub.org/job/worldedit"); @@ -461,7 +461,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } } }, 20); - return (Bukkit.getPluginManager().getPlugin("PlotMe") != null) || (Bukkit.getPluginManager().getPlugin("AthionPlots") != null); + return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null; } @Override @@ -470,7 +470,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { return null; } final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name); - if ((gen_plugin != null) && gen_plugin.isEnabled()) { + if (gen_plugin != null && gen_plugin.isEnabled()) { ChunkGenerator gen = gen_plugin.getDefaultWorldGenerator(world, ""); if (gen instanceof GeneratorWrapper) { return (GeneratorWrapper) gen; @@ -497,19 +497,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { UUIDWrapper wrapper; if (Settings.OFFLINE_MODE) { if (Settings.UUID_LOWERCASE) { - wrapper = (new LowerOfflineUUIDWrapper()); + wrapper = new LowerOfflineUUIDWrapper(); } else { - wrapper = (new OfflineUUIDWrapper()); + wrapper = new OfflineUUIDWrapper(); } Settings.OFFLINE_MODE = true; } else if (checkVersion) { - wrapper = (new DefaultUUIDWrapper()); + wrapper = new DefaultUUIDWrapper(); Settings.OFFLINE_MODE = false; } else { if (Settings.UUID_LOWERCASE) { - wrapper = (new LowerOfflineUUIDWrapper()); + wrapper = new LowerOfflineUUIDWrapper(); } else { - wrapper = (new OfflineUUIDWrapper()); + wrapper = new OfflineUUIDWrapper(); } Settings.OFFLINE_MODE = true; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java index e4a985d83..cda63a8d7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java @@ -47,6 +47,12 @@ import java.util.logging.Level; *

*/ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable, ConfigurationSerializable { + + private static final JsonParser _stringParser = new JsonParser(); + private static Constructor nmsPacketPlayOutChatConstructor; + // The ChatSerializer's instance of Gson + private static Object nmsChatSerializerGsonInstance; + private static Method fromJsonMethod; static { ConfigurationSerialization.registerClass(FancyMessage.class); @@ -56,20 +62,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< private String jsonString; private boolean dirty; - private static Constructor nmsPacketPlayOutChatConstructor; - - @Override - public FancyMessage clone() throws CloneNotSupportedException { - final FancyMessage instance = (FancyMessage) super.clone(); - instance.messageParts = new ArrayList<>(messageParts.size()); - for (int i = 0; i < messageParts.size(); i++) { - instance.messageParts.add(i, messageParts.get(i).clone()); - } - instance.dirty = false; - instance.jsonString = null; - return instance; - } - /** * Creates a JSON message with text. * @param firstPartText The existing text in the message. @@ -83,7 +75,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< messageParts.add(new MessagePart(firstPartText)); jsonString = null; dirty = false; - + if (nmsPacketPlayOutChatConstructor == null) { try { nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent")); @@ -103,6 +95,105 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< this((TextualComponent) null); } + /** + * Deserialize a JSON-represented message from a mapping of key-value pairs. + * This is called by the Bukkit serialization API. + * It is not intended for direct public API consumption. + * @param serialized The key-value mapping which represents a fancy message. + */ + @SuppressWarnings("unchecked") + public static FancyMessage deserialize(final Map serialized) { + final FancyMessage msg = new FancyMessage(); + msg.messageParts = (List) serialized.get("messageParts"); + msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null; + msg.dirty = !serialized.containsKey("JSON"); + return msg; + } + + /** + * Deserialize a fancy message from its JSON representation. This JSON representation is of the format of + * that returned by {@link #toJSONString()}, and is compatible with vanilla inputs. + * @param json The JSON string which represents a fancy message. + * @return A {@code FancyMessage} representing the parametrized JSON message. + */ + public static FancyMessage deserialize(final String json) { + final JsonObject serialized = _stringParser.parse(json).getAsJsonObject(); + final JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component + final FancyMessage returnVal = new FancyMessage(); + returnVal.messageParts.clear(); + for (final JsonElement mPrt : extra) { + final MessagePart component = new MessagePart(); + final JsonObject messagePart = mPrt.getAsJsonObject(); + for (final Map.Entry entry : messagePart.entrySet()) { + // Deserialize text + if (TextualComponent.isTextKey(entry.getKey())) { + // The map mimics the YAML serialization, which has a "key" field and one or more "value" fields + final Map serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance + serializedMapForm.put("key", entry.getKey()); + if (entry.getValue().isJsonPrimitive()) { + // Assume string + serializedMapForm.put("value", entry.getValue().getAsString()); + } else { + // Composite object, but we assume each element is a string + for (final Map.Entry compositeNestedElement : entry.getValue().getAsJsonObject().entrySet()) { + serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString()); + } + } + component.text = TextualComponent.deserialize(serializedMapForm); + } else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) { + if (entry.getValue().getAsBoolean()) { + component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey())); + } + } else if (entry.getKey().equals("color")) { + component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase()); + } else if (entry.getKey().equals("clickEvent")) { + final JsonObject object = entry.getValue().getAsJsonObject(); + component.clickActionName = object.get("action").getAsString(); + component.clickActionData = object.get("value").getAsString(); + } else if (entry.getKey().equals("hoverEvent")) { + final JsonObject object = entry.getValue().getAsJsonObject(); + component.hoverActionName = object.get("action").getAsString(); + if (object.get("value").isJsonPrimitive()) { + // Assume string + component.hoverActionData = new JsonString(object.get("value").getAsString()); + } else { + // Assume composite type + // The only composite type we currently store is another FancyMessage + // Therefore, recursion time! + component.hoverActionData = + deserialize(object.get("value").toString() /* This should properly serialize the JSON object as a JSON string */); + } + } else if (entry.getKey().equals("insertion")) { + component.insertionData = entry.getValue().getAsString(); + } else if (entry.getKey().equals("with")) { + for (final JsonElement object : entry.getValue().getAsJsonArray()) { + if (object.isJsonPrimitive()) { + component.translationReplacements.add(new JsonString(object.getAsString())); + } else { + // Only composite type stored in this array is - again - FancyMessages + // Recurse within this function to parse this as a translation replacement + component.translationReplacements.add(deserialize(object.toString())); + } + } + } + } + returnVal.messageParts.add(component); + } + return returnVal; + } + + @Override + public FancyMessage clone() throws CloneNotSupportedException { + final FancyMessage instance = (FancyMessage) super.clone(); + instance.messageParts = new ArrayList<>(messageParts.size()); + for (int i = 0; i < messageParts.size(); i++) { + instance.messageParts.add(i, messageParts.get(i).clone()); + } + instance.dirty = false; + instance.jsonString = null; + return instance; + } + /** * Sets the text of the current editing component to a value. * @param text The new text of the current editing component. @@ -283,7 +374,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< if (type == Type.UNTYPED) { throw new IllegalArgumentException("That statistic needs no additional parameter!"); } - if (((type == Type.BLOCK) && item.isBlock()) || (type == Type.ENTITY)) { + if (type == Type.BLOCK && item.isBlock() || type == Type.ENTITY) { throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); } try { @@ -382,6 +473,24 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< return this; } + /* + + /** + * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the + * message. + * @param replacements The replacements, in order, that will be used in the language-specific message. + * @return This builder instance. + *//* ------------ + public FancyMessage translationReplacements(final Iterable replacements){ + for(CharSequence str : replacements){ + latest().translationReplacements.add(new JsonString(str)); + } + + return this; + } + + */ + /** * Set the behavior of the current editing component to display raw text when the client hovers over the text. *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

@@ -392,7 +501,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< final StringBuilder builder = new StringBuilder(); for (int i = 0; i < lines.length; i++) { builder.append(lines[i]); - if (i != (lines.length - 1)) { + if (i != lines.length - 1) { builder.append('\n'); } } @@ -408,9 +517,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< */ public FancyMessage formattedTooltip(final FancyMessage text) { for (final MessagePart component : text.messageParts) { - if ((component.clickActionData != null) && (component.clickActionName != null)) { + if (component.clickActionData != null && component.clickActionName != null) { throw new IllegalArgumentException("The tooltip text cannot have click data."); - } else if ((component.hoverActionData != null) && (component.hoverActionName != null)) { + } else if (component.hoverActionData != null && component.hoverActionName != null) { throw new IllegalArgumentException("The tooltip text cannot have a tooltip."); } } @@ -429,23 +538,23 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< onHover(null, null); // Clear tooltip return this; } - + final FancyMessage result = new FancyMessage(); result.messageParts.clear(); // Remove the one existing text component that exists by default, which destabilizes the object - + for (int i = 0; i < lines.length; i++) { try { for (final MessagePart component : lines[i]) { - if ((component.clickActionData != null) && (component.clickActionName != null)) { + if (component.clickActionData != null && component.clickActionName != null) { throw new IllegalArgumentException("The tooltip text cannot have click data."); - } else if ((component.hoverActionData != null) && (component.hoverActionName != null)) { + } else if (component.hoverActionData != null && component.hoverActionName != null) { throw new IllegalArgumentException("The tooltip text cannot have a tooltip."); } if (component.hasText()) { result.messageParts.add(component.clone()); } } - if (i != (lines.length - 1)) { + if (i != lines.length - 1) { result.messageParts.add(new MessagePart(rawText("\n"))); } } catch (final CloneNotSupportedException e) { @@ -476,27 +585,10 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< latest().translationReplacements.add(new JsonString(str)); } dirty = true; - + return this; } - /* - - /** - * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message. - * @param replacements The replacements, in order, that will be used in the language-specific message. - * @return This builder instance. - *//* ------------ - public FancyMessage translationReplacements(final Iterable replacements){ - for(CharSequence str : replacements){ - latest().translationReplacements.add(new JsonString(str)); - } - - return this; - } - - */ - /** * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message. * @param replacements The replacements, in order, that will be used in the language-specific message. @@ -504,9 +596,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< */ public FancyMessage translationReplacements(final FancyMessage... replacements) { Collections.addAll(latest().translationReplacements, replacements); - + dirty = true; - + return this; } @@ -557,7 +649,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< dirty = true; return this; } - + @Override public void writeJson(final JsonWriter writer) throws IOException { if (messageParts.size() == 1) { @@ -577,7 +669,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< * @return The JSON string representing this object. */ public String toJSONString() { - if (!dirty && (jsonString != null)) { + if (!dirty && jsonString != null) { return jsonString; } final StringWriter string = new StringWriter(); @@ -626,30 +718,26 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } } - // The ChatSerializer's instance of Gson - private static Object nmsChatSerializerGsonInstance; - private static Method fromJsonMethod; - private Object createChatPacket(final String json) throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { if (nmsChatSerializerGsonInstance == null) { // Find the field and its value, completely bypassing obfuscation Class chatSerializerClazz; - + final String version = Reflection.getVersion(); final double majorVersion = Double.parseDouble(version.replace('_', '.').substring(1, 4)); final int lesserVersion = Integer.parseInt(version.substring(6, 7)); - - if ((majorVersion < 1.8) || ((majorVersion == 1.8) && (lesserVersion == 1))) { + + if (majorVersion < 1.8 || majorVersion == 1.8 && lesserVersion == 1) { chatSerializerClazz = Reflection.getNMSClass("ChatSerializer"); } else { chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer"); } - + if (chatSerializerClazz == null) { throw new ClassNotFoundException("Can't find the ChatSerializer class"); } - + for (final Field declaredField : chatSerializerClazz.getDeclaredFields()) { if (Modifier.isFinal(declaredField.getModifiers()) && Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType().getName().endsWith("Gson")) { // We've found our field @@ -660,14 +748,14 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } } } - + /* Since the method is so simple, and all the obfuscated methods have the same name, it's easier to reimplement 'IChatBaseComponent a(String)' than to reflectively call it Of course, the implementation may change, but fuzzy matches might break with signature changes */ final Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, Reflection.getNMSClass("IChatBaseComponent")); - + return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent); } @@ -749,21 +837,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< return map; } - /** - * Deserialize a JSON-represented message from a mapping of key-value pairs. - * This is called by the Bukkit serialization API. - * It is not intended for direct public API consumption. - * @param serialized The key-value mapping which represents a fancy message. - */ - @SuppressWarnings("unchecked") - public static FancyMessage deserialize(final Map serialized) { - final FancyMessage msg = new FancyMessage(); - msg.messageParts = (List) serialized.get("messageParts"); - msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null; - msg.dirty = !serialized.containsKey("JSON"); - return msg; - } - /** * Internally called method. Not for API consumption. */ @@ -771,77 +844,4 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< public Iterator iterator() { return messageParts.iterator(); } - - private static JsonParser _stringParser = new JsonParser(); - - /** - * Deserialize a fancy message from its JSON representation. This JSON representation is of the format of - * that returned by {@link #toJSONString()}, and is compatible with vanilla inputs. - * @param json The JSON string which represents a fancy message. - * @return A {@code FancyMessage} representing the parametrized JSON message. - */ - public static FancyMessage deserialize(final String json) { - final JsonObject serialized = _stringParser.parse(json).getAsJsonObject(); - final JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component - final FancyMessage returnVal = new FancyMessage(); - returnVal.messageParts.clear(); - for (final JsonElement mPrt : extra) { - final MessagePart component = new MessagePart(); - final JsonObject messagePart = mPrt.getAsJsonObject(); - for (final Map.Entry entry : messagePart.entrySet()) { - // Deserialize text - if (TextualComponent.isTextKey(entry.getKey())) { - // The map mimics the YAML serialization, which has a "key" field and one or more "value" fields - final Map serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance - serializedMapForm.put("key", entry.getKey()); - if (entry.getValue().isJsonPrimitive()) { - // Assume string - serializedMapForm.put("value", entry.getValue().getAsString()); - } else { - // Composite object, but we assume each element is a string - for (final Map.Entry compositeNestedElement : entry.getValue().getAsJsonObject().entrySet()) { - serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString()); - } - } - component.text = TextualComponent.deserialize(serializedMapForm); - } else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) { - if (entry.getValue().getAsBoolean()) { - component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey())); - } - } else if (entry.getKey().equals("color")) { - component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase()); - } else if (entry.getKey().equals("clickEvent")) { - final JsonObject object = entry.getValue().getAsJsonObject(); - component.clickActionName = object.get("action").getAsString(); - component.clickActionData = object.get("value").getAsString(); - } else if (entry.getKey().equals("hoverEvent")) { - final JsonObject object = entry.getValue().getAsJsonObject(); - component.hoverActionName = object.get("action").getAsString(); - if (object.get("value").isJsonPrimitive()) { - // Assume string - component.hoverActionData = new JsonString(object.get("value").getAsString()); - } else { - // Assume composite type - // The only composite type we currently store is another FancyMessage - // Therefore, recursion time! - component.hoverActionData = deserialize(object.get("value").toString() /* This should properly serialize the JSON object as a JSON string */); - } - } else if (entry.getKey().equals("insertion")) { - component.insertionData = entry.getValue().getAsString(); - } else if (entry.getKey().equals("with")) { - for (final JsonElement object : entry.getValue().getAsJsonArray()) { - if (object.isJsonPrimitive()) { - component.translationReplacements.add(new JsonString(object.getAsString())); - } else { - // Only composite type stored in this array is - again - FancyMessages - // Recurse within this function to parse this as a translation replacement - component.translationReplacements.add(deserialize(object.toString())); - } - } - } - } - returnVal.messageParts.add(component); - } - return returnVal; - } } 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 cfd359f18..6f1cb7c2b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -259,7 +259,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap loaded = true; } // Set random seed - this.random.state = (cx << 16) | (cz & 0xFFFF); + this.random.state = cx << 16 | cz & 0xFFFF; // Process the chunk if (ChunkManager.preProcessChunk(result)) { return; @@ -267,7 +267,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap PlotArea area = PS.get().getPlotArea(world.getName(), null); plotGenerator.generateChunk(chunkSetter, area, this.random); ChunkManager.postProcessChunk(result); - return; } @Override @@ -316,6 +315,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap if (obj == null) { return false; } - return (toString().equals(obj.toString()) || toString().equals(obj.getClass().getName())); + return toString().equals(obj.toString()) || toString().equals(obj.getClass().getName()); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java index dd8342307..23fa3e7a9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java @@ -45,6 +45,5 @@ public class PlayerEvents_1_8_3 implements Listener { iter.remove(); } } - return; } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java index f24dbd247..b52c88566 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java @@ -73,7 +73,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { } final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender); if (strings.length < 1) { - if ((strings.length == 0) || "plots".startsWith(s)) { + if (strings.length == 0 || "plots".startsWith(s)) { return Collections.singletonList("plots"); } } 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 eccd69cda..0bc8cf713 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java @@ -1,18 +1,5 @@ package com.plotsquared.bukkit.util; -import java.util.HashSet; -import java.util.Random; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.generator.ChunkGenerator.BiomeGrid; -import org.bukkit.material.Directional; -import org.bukkit.material.MaterialData; - import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotAnalysis; @@ -23,6 +10,18 @@ import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.TaskManager; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.block.Block; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.generator.ChunkGenerator.BiomeGrid; +import org.bukkit.material.Directional; +import org.bukkit.material.MaterialData; + +import java.util.HashSet; +import java.util.Random; public class BukkitHybridUtils extends HybridUtils { @@ -72,8 +71,8 @@ public class BukkitHybridUtils extends HybridUtils { final int ctz = tz >> 4; final Random r = new Random(); MainUtil.initCache(); - final int width = (tx - bx) + 1; - final int length = (tz - bz) + 1; + final int width = tx - bx + 1; + final int length = tz - bz + 1; System.gc(); System.gc(); @@ -90,17 +89,17 @@ public class BukkitHybridUtils extends HybridUtils { final int X = value[0]; final int Z = value[1]; final short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid); - final int xb = ((X) << 4) - bx; - final int zb = ((Z) << 4) - bz; + final int xb = (X << 4) - bx; + final int zb = (Z << 4) - bz; for (int i = 0; i < result.length; i++) { if (result[i] == null) { for (int j = 0; j < 4096; j++) { final int x = MainUtil.x_loc[i][j] + xb; - if ((x < 0) || (x >= width)) { + if (x < 0 || x >= width) { continue; } final int z = MainUtil.z_loc[i][j] + zb; - if ((z < 0) || (z >= length)) { + if (z < 0 || z >= length) { continue; } final int y = MainUtil.y_loc[i][j]; @@ -110,11 +109,11 @@ public class BukkitHybridUtils extends HybridUtils { } for (int j = 0; j < result[i].length; j++) { final int x = MainUtil.x_loc[i][j] + xb; - if ((x < 0) || (x >= width)) { + if (x < 0 || x >= width) { continue; } final int z = MainUtil.z_loc[i][j] + zb; - if ((z < 0) || (z >= length)) { + if (z < 0 || z >= length) { continue; } final int y = MainUtil.y_loc[i][j]; @@ -150,7 +149,7 @@ public class BukkitHybridUtils extends HybridUtils { } else { // check vertices // modifications_adjacent - if ((x > 0) && (z > 0) && (y > 0) && (x < (width - 1)) && (z < (length - 1)) && (y < 255)) { + if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 && y < 255) { if (newblocks[y - 1][x][z] == 0) { faces[i]++; } @@ -196,11 +195,11 @@ public class BukkitHybridUtils extends HybridUtils { analysis.air = (int) (MathMan.getMean(air) * 100); analysis.variety = (int) (MathMan.getMean(variety) * 100); - analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes)); - analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces)); - analysis.data_sd = (int) (MathMan.getSD(data, analysis.data)); - analysis.air_sd = (int) (MathMan.getSD(air, analysis.air)); - analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety)); + analysis.changes_sd = (int) MathMan.getSD(changes, analysis.changes); + analysis.faces_sd = (int) MathMan.getSD(faces, analysis.faces); + analysis.data_sd = (int) MathMan.getSD(data, analysis.data); + analysis.air_sd = (int) MathMan.getSD(air, analysis.air); + analysis.variety_sd = (int) MathMan.getSD(variety, analysis.variety); System.gc(); System.gc(); whenDone.value = analysis; @@ -222,24 +221,24 @@ public class BukkitHybridUtils extends HybridUtils { final int Z = value[1]; worldObj.loadChunk(X, Z); int minX; - int minZ; - int maxX; - int maxZ; if (X == cbx) { minX = bx & 15; } else { minX = 0; } + int minZ; if (Z == cbz) { minZ = bz & 15; } else { minZ = 0; } + int maxX; if (X == ctx) { maxX = tx & 15; } else { maxX = 16; } + int maxZ; if (Z == ctz) { maxZ = tz & 15; } else { @@ -249,8 +248,8 @@ public class BukkitHybridUtils extends HybridUtils { final int cbx = X << 4; final int cbz = Z << 4; - final int xb = (cbx) - bx; - final int zb = (cbz) - bz; + final int xb = cbx - bx; + final int zb = cbz - bz; for (int x = minX; x <= maxX; x++) { final int xx = cbx + x; for (int z = minZ; z <= maxZ; z++) { @@ -311,7 +310,7 @@ public class BukkitHybridUtils extends HybridUtils { for (int y = sy; y < maxY; y++) { if (y > ey) { final Block block = world.getBlockAt(x, y, z); - if (block.getTypeId() != 0) { + if (!block.getType().equals(Material.AIR)) { ey = y; } } 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 e4bcafbd5..db0807f80 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 @@ -85,7 +85,7 @@ public class FastQueue_1_9 extends SlowQueue { int count = 0; final ArrayList chunks = new ArrayList<>(); final Iterator> i = toUpdate.entrySet().iterator(); - while (i.hasNext() && (count < 128)) { + while (i.hasNext() && count < 128) { chunks.add(i.next().getValue()); i.remove(); count++; @@ -180,7 +180,7 @@ public class FastQueue_1_9 extends SlowQueue { // Trim entities for (int i = 0; i < 16; i++) { - if ((entities[i] != null) && (fs.getCount(i) >= 4096)) { + if (entities[i] != null && fs.getCount(i) >= 4096) { entities[i].clear(); } } @@ -195,7 +195,7 @@ public class FastQueue_1_9 extends SlowQueue { continue; } Object section = sections[j]; - if ((section == null) || (fs.getCount(j) >= 4096)) { + if (section == null || fs.getCount(j) >= 4096) { char[] array = new char[4096]; for (int i = 0; i < newArray.length; i++) { int combined = newArray[i]; @@ -317,7 +317,7 @@ public class FastQueue_1_9 extends SlowQueue { methodInitLighting.of(c).call(); - if ((bc.getTotalRelight() == 0 && !fixAll)) { + if (bc.getTotalRelight() == 0 && !fixAll) { return true; } @@ -333,7 +333,7 @@ public class FastQueue_1_9 extends SlowQueue { if (section == null) { continue; } - if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) { + if (bc.getRelight(j) == 0 && !fixAll || bc.getCount(j) == 0 || bc.getCount(j) >= 4096 && bc.getAir(j) == 0) { continue; } final int[] array = bc.getIdArray(j); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 79277a56e..fc530ecab 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -208,7 +208,7 @@ public class PS { @Override public void run() { for (final Plot plot : getPlots()) { - if (plot.hasOwner() && (plot.temp != -1)) { + if (plot.hasOwner() && plot.temp != -1) { if (UUIDHandler.getName(plot.owner) == null) { UUIDHandler.implementation.unknown.add(plot.owner); } @@ -376,8 +376,8 @@ public class PS { * @return true if `version` is >= `version2` */ public boolean checkVersion(final int[] version, int... version2) { - return (version[0] > version2[0]) || ((version[0] == version2[0]) && (version[1] > version2[1])) || ((version[0] == version2[0]) && (version[1] == version2[1]) && ( - version[2] >= version2[2])); + return version[0] > version2[0] || version[0] == version2[0] && version[1] > version2[1] || version[0] == version2[0] + && version[1] == version2[1] && version[2] >= version2[2]; } /** @@ -518,7 +518,7 @@ public class PS { if (areas == null) { for (PlotArea area : plotareas) { if (area.worldname.equalsIgnoreCase(split[0])) { - if (area.id == null || (split.length == 2 && area.id.equalsIgnoreCase(split[1]))) { + if (area.id == null || split.length == 2 && area.id.equalsIgnoreCase(split[1])) { return area; } } @@ -902,7 +902,7 @@ public class PS { } else { extra.add(plot); } - } else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) { + } else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) { extra.add(plot); } else { overflow.add(plot); @@ -950,7 +950,7 @@ public class PS { } else { extra.add(plot); } - } else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) { + } else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) { extra.add(plot); } else { overflow.add(plot); @@ -1011,7 +1011,7 @@ public class PS { for (final Plot i : input) { int tmp = MathMan.getPositiveId(i.hashCode()) / placement; bucket[tmp & 31].add(i); - if (maxLength && (tmp > 0)) { + if (maxLength && tmp > 0) { maxLength = false; } } @@ -1062,7 +1062,7 @@ public class PS { Collections.sort(areas, new Comparator() { @Override public int compare(final PlotArea a, final PlotArea b) { - if ((priorityArea != null) && StringMan.isEqual(a.toString(), b.toString())) { + if (priorityArea != null && StringMan.isEqual(a.toString(), b.toString())) { return -1; } return a.hashCode() - b.hashCode(); @@ -1229,7 +1229,7 @@ public class PS { } public Plot getPlot(PlotArea area, final PlotId id) { - return area == null ? null : (id == null ? null : area.getPlot(id)); + return area == null ? null : id == null ? null : area.getPlot(id); } /** @@ -1338,7 +1338,7 @@ public class PS { if (!plotareaHasCollision && !plotareaHashCheck.add(world.hashCode())) { plotareaHasCollision = true; } - final Set worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet()); + final Set worlds = config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet(); final String path = "worlds." + world; ConfigurationSection worldSection = config.getConfigurationSection(path); int type = worldSection != null ? worldSection.getInt("generator.type") : 0; @@ -1543,7 +1543,7 @@ public class PS { * @return boolean | if valid arguments were provided */ public boolean setupPlotWorld(final String world, final String args, IndependentPlotGenerator generator) { - if ((args != null) && (!args.isEmpty())) { + if (args != null && !args.isEmpty()) { // save configuration final String[] split = args.split(","); final HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, null, null); @@ -1869,7 +1869,7 @@ public class PS { case "false": return false; default: - return (MainUtil.timeToSec(value) * 1000) + System.currentTimeMillis(); + return MainUtil.timeToSec(value) * 1000 + System.currentTimeMillis(); } } @Override @@ -1999,7 +1999,7 @@ public class PS { final int keep = config.getInt("clear.keep-if-modified"); final int ignore = config.getInt("clear.ignore-if-modified"); - if ((keep > 0) || (ignore > 0)) { + if (keep > 0 || ignore > 0) { options.put("clear.auto.threshold", 1); options.put("clear.auto.enabled", false); log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java index 72baa1387..0862f0393 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -80,8 +80,8 @@ public class Area extends SubCommand { Location pos2 = plr.getMeta("area_pos1"); int dx = Math.abs(pos1.getX() - pos2.getX()); int dz = Math.abs(pos1.getZ() - pos2.getZ()); - int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE); - int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE); + int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE); + int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE); final int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH); final int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH); int bx = Math.min(pos1.getX(), pos2.getX()) + ddx; @@ -318,7 +318,7 @@ public class Area extends SubCommand { region = area.getRegion().toString(); } else { name = area.worldname; - percent = claimed == 0 ? 0 : (100d * claimed) / (Integer.MAX_VALUE); + percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE; region = "N/A"; } String value = "&r$1NAME: " + name diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 7d2bef836..e8549367e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -52,7 +52,7 @@ public class Auto extends SubCommand { return new PlotId(id.x + 1, id.y); } } else { - if (id.x == id.y && (id.x > 0)) { + if (id.x == id.y && id.x > 0) { return new PlotId(id.x, id.y + step); } if (id.x == absX) { @@ -81,7 +81,7 @@ public class Auto extends SubCommand { final String[] split = args[0].split(",|;"); size_x = Integer.parseInt(split[0]); size_z = Integer.parseInt(split[1]); - if ((size_x < 1) || (size_z < 1)) { + if (size_x < 1 || size_z < 1) { MainUtil.sendMessage(plr, "&cError: size<=0"); } if (args.length > 1) { @@ -101,15 +101,15 @@ public class Auto extends SubCommand { // return false; } } - if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) { + if (size_x * size_z > Settings.MAX_AUTO_SIZE) { MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); return false; } final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname); final int diff = currentPlots - plr.getAllowedPlots(); - if ((diff + (size_x * size_z)) > 0) { + if (diff + size_x * size_z > 0) { if (diff < 0) { - MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); + MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + ""); return false; } else if (plr.hasPersistentMeta("grantedPlots")) { int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots")); @@ -117,11 +117,10 @@ public class Auto extends SubCommand { plr.removePersistentMeta("grantedPlots"); return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } else { - int left = grantedPlots - diff - (size_x * size_z); + int left = grantedPlots - diff - size_x * size_z; if (left == 0) { plr.removePersistentMeta("grantedPlots"); - } - else { + } else { plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(left)); } sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + left, "" + (grantedPlots - left)); @@ -131,7 +130,7 @@ public class Auto extends SubCommand { return false; } } - if ((EconHandler.manager != null) && plotarea.USE_ECONOMY) { + if (EconHandler.manager != null && plotarea.USE_ECONOMY) { double cost = plotarea.PRICES.get("claim"); cost = (size_x * size_z) * cost; if (cost > 0d) { @@ -159,7 +158,7 @@ public class Auto extends SubCommand { final PlotId top = plotarea.getMax(); final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); PlotId id = new PlotId(0, 0); - final int width = Math.max((top.x - bot.x) + 1, (top.y - bot.y) + 1); + final int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1); final int max = width * width; // for (int i = 0; i <= max; i++) { @@ -179,17 +178,17 @@ public class Auto extends SubCommand { boolean br = false; while (true) { final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1); - final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1); + final PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1); plotarea.setMeta("lastPlot", start); if (plotarea.canClaim(plr, start, end)) { for (int i = start.x; i <= end.x; i++) { for (int j = start.y; j <= end.y; j++) { Plot plot = plotarea.getPlotAbs(new PlotId(i, j)); - final boolean teleport = ((i == end.x) && (j == end.y)); + final boolean teleport = i == end.x && j == end.y; plot.claim(plr, teleport, null); } } - if ((size_x != 1) || (size_z != 1)) { + if (size_x != 1 || size_z != 1) { if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) { return false; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 0fe24c8d9..f5ff6050b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -102,7 +102,7 @@ public class Cluster extends SubCommand { // check pos1 / pos2 PlotId pos1 = PlotId.fromString(args[2]); PlotId pos2 = PlotId.fromString(args[3]); - if ((pos1 == null) || (pos2 == null)) { + if (pos1 == null || pos2 == null) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } @@ -112,7 +112,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } - if ((pos2.x < pos1.x) || (pos2.y < pos1.y)) { + if (pos2.x < pos1.x || pos2.y < pos1.y) { PlotId tmp = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y)); pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y)); pos1 = tmp; @@ -145,7 +145,7 @@ public class Cluster extends SubCommand { current = plr.getPlayerClusterCount(plr.getLocation().getWorld()); } final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS); - if ((current + cluster.getArea()) > allowed) { + if (current + cluster.getArea() > allowed) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea())); return false; } @@ -172,7 +172,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); return false; } - if ((args.length != 1) && (args.length != 2)) { + if (args.length != 1 && args.length != 2) { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); return false; } @@ -218,11 +218,11 @@ public class Cluster extends SubCommand { // check pos1 / pos2 PlotId pos1 = PlotId.fromString(args[1]); PlotId pos2 = PlotId.fromString(args[2]); - if ((pos1 == null) || (pos2 == null)) { + if (pos1 == null || pos2 == null) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } - if ((pos2.x < pos1.x) || (pos2.y < pos1.y)) { + if (pos2.x < pos1.x || pos2.y < pos1.y) { pos1 = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y)); pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y)); } @@ -251,7 +251,7 @@ public class Cluster extends SubCommand { } final HashSet existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2()); final HashSet newplots = area.getPlotSelectionOwned(pos1, pos2); - final HashSet removed = ((HashSet) existing.clone()); + final HashSet removed = (HashSet) existing.clone(); removed.removeAll(newplots); // Check expand / shrink if (!removed.isEmpty()) { @@ -274,9 +274,9 @@ public class Cluster extends SubCommand { } else { current = plr.getPlayerClusterCount(plr.getLocation().getWorld()); } - current -= cluster.getArea() + (((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y)); + current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS); - if ((current + cluster.getArea()) > allowed) { + if (current + cluster.getArea() > allowed) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea())); return false; } @@ -379,7 +379,7 @@ public class Cluster extends SubCommand { } for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) { final PlotCluster current = plot.getCluster(); - if ((current != null) && current.equals(cluster)) { + if (current != null && current.equals(cluster)) { plot.unclaim(); } } @@ -392,7 +392,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave"); return false; } - if ((args.length != 1) && (args.length != 2)) { + if (args.length != 1 && args.length != 2) { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); return false; } @@ -432,7 +432,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) { final PlotCluster current = plot.getCluster(); - if ((current != null) && current.equals(cluster)) { + if (current != null && current.equals(cluster)) { plr.getLocation().getWorld(); plot.unclaim(); } @@ -515,7 +515,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info"); return false; } - if ((args.length != 1) && (args.length != 2)) { + if (args.length != 1 && args.length != 2) { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); return false; } @@ -543,7 +543,7 @@ public class Cluster extends SubCommand { owner = "unknown"; } final String name = cluster.getName(); - final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1); + final String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1); final String rights = cluster.isAdded(plr.getUUID()) + ""; String message = C.CLUSTER_INFO.s(); message = message.replaceAll("%id%", id); @@ -561,7 +561,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); return false; } - if ((args.length != 1) && (args.length != 2)) { + if (args.length != 1 && args.length != 2) { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); return false; } 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 7a0b40d18..dc6ef9625 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -126,13 +126,13 @@ public class Configuration { @Override public boolean validateValue(final String string) { final StringComparison.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string); - return !((value == null) || (value.match > 1)); + return !(value == null || value.match > 1); } @Override public PlotBlock parseString(final String string) { final StringComparison.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string); - if ((value == null) || (value.match > 1)) { + if (value == null || value.match > 1) { return null; } return value.best; @@ -149,7 +149,7 @@ public class Configuration { block = split[1]; } final StringComparison.ComparisonResult value = WorldUtil.IMP.getClosestBlock(block); - if ((value == null) || (value.match > 1)) { + if (value == null || value.match > 1) { return false; } } @@ -183,7 +183,7 @@ public class Configuration { } } final StringComparison.ComparisonResult result = WorldUtil.IMP.getClosestBlock(blocks[i]); - if ((result != null) && (result.match < 2)) { + if (result != null && result.match < 2) { values[i] = result.best; } } catch (NumberFormatException e) { @@ -192,7 +192,7 @@ public class Configuration { final int gcd = gcd(counts); for (int i = 0; i < counts.length; i++) { final int num = counts[i]; - for (int j = 0; j < (num / gcd); j++) { + for (int j = 0; j < num / gcd; j++) { parsedvalues.add(values[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 0c571995b..317c5f0d6 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -136,7 +136,7 @@ public class SQLManager implements AbstractDB { break; } // schedule reconnect - if (MYSQL && ((System.currentTimeMillis() - last) > 550000)) { + if (MYSQL && System.currentTimeMillis() - last > 550000) { last = System.currentTimeMillis(); try { close(); @@ -573,14 +573,14 @@ public class SQLManager implements AbstractDB { @Override public void setMySQL(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException { - stmt.setInt((i * 2) + 1, pair.id); - stmt.setString((i * 2) + 2, pair.uuid.toString()); + stmt.setInt(i * 2 + 1, pair.id); + stmt.setString(i * 2 + 2, pair.uuid.toString()); } @Override public void setSQLite(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException { - stmt.setInt((i * 2) + 1, pair.id); - stmt.setString((i * 2) + 2, pair.uuid.toString()); + stmt.setInt(i * 2 + 1, pair.id); + stmt.setString(i * 2 + 2, pair.uuid.toString()); } @Override @@ -617,29 +617,29 @@ public class SQLManager implements AbstractDB { @Override public void setMySQL(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException { - stmt.setInt((i * 5) + 1, plot.getId().x); - stmt.setInt((i * 5) + 2, plot.getId().y); + stmt.setInt(i * 5 + 1, plot.getId().x); + stmt.setInt(i * 5 + 2, plot.getId().y); try { - stmt.setString((i * 5) + 3, plot.owner.toString()); + stmt.setString(i * 5 + 3, plot.owner.toString()); } catch (SQLException e) { - stmt.setString((i * 5) + 3, everyone.toString()); + stmt.setString(i * 5 + 3, everyone.toString()); } - stmt.setString((i * 5) + 4, plot.getArea().toString()); - stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp())); + stmt.setString(i * 5 + 4, plot.getArea().toString()); + stmt.setTimestamp(i * 5 + 5, new Timestamp(plot.getTimestamp())); } @Override public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException { - stmt.setNull((i * 6) + 1, 4); - stmt.setInt((i * 6) + 2, plot.getId().x); - stmt.setInt((i * 6) + 3, plot.getId().y); + stmt.setNull(i * 6 + 1, 4); + stmt.setInt(i * 6 + 2, plot.getId().x); + stmt.setInt(i * 6 + 3, plot.getId().y); try { - stmt.setString((i * 6) + 4, plot.owner.toString()); + stmt.setString(i * 6 + 4, plot.owner.toString()); } catch (SQLException e1) { - stmt.setString((i * 6) + 4, everyone.toString()); + stmt.setString(i * 6 + 4, everyone.toString()); } - stmt.setString((i * 6) + 5, plot.getArea().toString()); - stmt.setTimestamp((i * 6) + 6, new Timestamp(plot.getTimestamp())); + stmt.setString(i * 6 + 5, plot.getArea().toString()); + stmt.setTimestamp(i * 6 + 6, new Timestamp(plot.getTimestamp())); } @Override @@ -685,7 +685,7 @@ public class SQLManager implements AbstractDB { statement = mod.getCreateMySQL(subList.size()); preparedStmt = connection.prepareStatement(statement); } - if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) { + if (subList.size() != last || count % 5000 == 0 && count > 0) { preparedStmt.executeBatch(); preparedStmt.close(); statement = mod.getCreateMySQL(subList.size()); @@ -728,7 +728,7 @@ public class SQLManager implements AbstractDB { statement = mod.getCreateSQLite(subList.size()); preparedStmt = connection.prepareStatement(statement); } - if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) { + if (subList.size() != last || count % 5000 == 0 && count > 0) { preparedStmt.executeBatch(); preparedStmt.clearParameters(); statement = mod.getCreateSQLite(subList.size()); @@ -799,16 +799,16 @@ public class SQLManager implements AbstractDB { @Override public void setMySQL(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException { - stmt.setInt((i * 10) + 1, pair.id); // id - stmt.setNull((i * 10) + 2, 4); // biome - stmt.setNull((i * 10) + 3, 4); // rain - stmt.setNull((i * 10) + 4, 4); // custom_time - stmt.setNull((i * 10) + 5, 4); // time - stmt.setNull((i * 10) + 6, 4); // deny_entry + stmt.setInt(i * 10 + 1, pair.id); // id + stmt.setNull(i * 10 + 2, 4); // biome + stmt.setNull(i * 10 + 3, 4); // rain + stmt.setNull(i * 10 + 4, 4); // custom_time + stmt.setNull(i * 10 + 5, 4); // time + stmt.setNull(i * 10 + 6, 4); // deny_entry if (pair.settings.getAlias().isEmpty()) { - stmt.setNull((i * 10) + 7, 4); + stmt.setNull(i * 10 + 7, 4); } else { - stmt.setString((i * 10) + 7, pair.settings.getAlias()); + stmt.setString(i * 10 + 7, pair.settings.getAlias()); } final StringBuilder flag_string = new StringBuilder(); int k = 0; @@ -819,10 +819,10 @@ public class SQLManager implements AbstractDB { flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4")); k++; } - stmt.setString((i * 10) + 8, flag_string.toString()); + stmt.setString(i * 10 + 8, flag_string.toString()); final boolean[] merged = pair.settings.getMerged(); int hash = MainUtil.hash(merged); - stmt.setInt((i * 10) + 9, hash); + stmt.setInt(i * 10 + 9, hash); final BlockLoc loc = pair.settings.getPosition(); String position; if (loc.y == 0) { @@ -830,21 +830,21 @@ public class SQLManager implements AbstractDB { } else { position = loc.x + "," + loc.y + "," + loc.z; } - stmt.setString((i * 10) + 10, position); + stmt.setString(i * 10 + 10, position); } @Override public void setSQLite(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException { - stmt.setInt((i * 10) + 1, pair.id); // id - stmt.setNull((i * 10) + 2, 4); // biome - stmt.setNull((i * 10) + 3, 4); // rain - stmt.setNull((i * 10) + 4, 4); // custom_time - stmt.setNull((i * 10) + 5, 4); // time - stmt.setNull((i * 10) + 6, 4); // deny_entry - if (pair.settings.getAlias().equals("")) { - stmt.setNull((i * 10) + 7, 4); + stmt.setInt(i * 10 + 1, pair.id); // id + stmt.setNull(i * 10 + 2, 4); // biome + stmt.setNull(i * 10 + 3, 4); // rain + stmt.setNull(i * 10 + 4, 4); // custom_time + stmt.setNull(i * 10 + 5, 4); // time + stmt.setNull(i * 10 + 6, 4); // deny_entry + if (pair.settings.getAlias().isEmpty()) { + stmt.setNull(i * 10 + 7, 4); } else { - stmt.setString((i * 10) + 7, pair.settings.getAlias()); + stmt.setString(i * 10 + 7, pair.settings.getAlias()); } final StringBuilder flag_string = new StringBuilder(); int k = 0; @@ -855,13 +855,13 @@ public class SQLManager implements AbstractDB { flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4")); k++; } - stmt.setString((i * 10) + 8, flag_string.toString()); + stmt.setString(i * 10 + 8, flag_string.toString()); final boolean[] merged = pair.settings.getMerged(); int n = 0; for (int j = 0; j < 4; ++j) { n = (n << 1) + (merged[j] ? 1 : 0); } - stmt.setInt((i * 10) + 9, n); + stmt.setInt(i * 10 + 9, n); final BlockLoc loc = pair.settings.getPosition(); String position; if (loc.y == 0) { @@ -869,7 +869,7 @@ public class SQLManager implements AbstractDB { } else { position = loc.x + "," + loc.y + "," + loc.z; } - stmt.setString((i * 10) + 10, position); + stmt.setString(i * 10 + 10, position); } @Override @@ -909,21 +909,21 @@ public class SQLManager implements AbstractDB { @Override public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException { - stmt.setInt((i) + 1, id); + stmt.setInt(i + 1, id); } @Override public void setSQLite(final PreparedStatement stmt, final int i, final Integer id) throws SQLException { - stmt.setInt((i * 10) + 1, id); - stmt.setNull((i * 10) + 2, 4); - stmt.setNull((i * 10) + 3, 4); - stmt.setNull((i * 10) + 4, 4); - stmt.setNull((i * 10) + 5, 4); - stmt.setNull((i * 10) + 6, 4); - stmt.setNull((i * 10) + 7, 4); - stmt.setNull((i * 10) + 8, 4); - stmt.setNull((i * 10) + 9, 4); - stmt.setString((i * 10) + 10, "DEFAULT"); + stmt.setInt(i * 10 + 1, id); + stmt.setNull(i * 10 + 2, 4); + stmt.setNull(i * 10 + 3, 4); + stmt.setNull(i * 10 + 4, 4); + stmt.setNull(i * 10 + 5, 4); + stmt.setNull(i * 10 + 6, 4); + stmt.setNull(i * 10 + 7, 4); + stmt.setNull(i * 10 + 8, 4); + stmt.setNull(i * 10 + 9, 4); + stmt.setString(i * 10 + 10, "DEFAULT"); } @Override @@ -1417,7 +1417,7 @@ public class SQLManager implements AbstractDB { } stmt.close(); r.close(); - if ((c_id == Integer.MAX_VALUE) || (c_id == 0)) { + if (c_id == Integer.MAX_VALUE || c_id == 0) { if (cluster.temp > 0) { return cluster.temp; } @@ -1453,7 +1453,7 @@ public class SQLManager implements AbstractDB { } r.close(); stmt.close(); - if ((id == Integer.MAX_VALUE) || (id == 0)) { + if (id == Integer.MAX_VALUE || id == 0) { if (plot.temp > 0) { return plot.temp; } @@ -1575,12 +1575,12 @@ public class SQLManager implements AbstractDB { @Override public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException { - stmt.setInt((i) + 1, obj); + stmt.setInt(i + 1, obj); } @Override public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException { - stmt.setInt((i) + 1, obj); + stmt.setInt(i + 1, obj); } @Override @@ -1801,7 +1801,7 @@ public class SQLManager implements AbstractDB { final Integer m = r.getInt("merged"); final boolean[] merged = new boolean[4]; for (int i = 0; i < 4; i++) { - merged[3 - i] = (m & (1 << i)) != 0; + merged[3 - i] = (m & 1 << i) != 0; } plot.getSettings().setMerged(merged); String[] flags_string; @@ -2584,7 +2584,7 @@ public class SQLManager implements AbstractDB { final Integer m = r.getInt("merged"); final boolean[] merged = new boolean[4]; for (int i = 0; i < 4; i++) { - merged[3 - i] = ((m) & (1 << i)) != 0; + merged[3 - i] = (m & 1 << i) != 0; } cluster.settings.setMerged(merged); String[] flags_string; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index 881a14bc6..1e0754668 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -1,7 +1,5 @@ package com.intellectualcrafters.plot.generator; -import java.util.ArrayList; - import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotArea; @@ -12,6 +10,8 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SetQueue; +import java.util.ArrayList; + /** * A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot) */ @@ -57,9 +57,9 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean unclaimPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) { - final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld); + final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; setWallFilling(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_FILLING }); - if ((dpw.WALL_BLOCK.id != 0) || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) { + if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) { setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK }); } SetQueue.IMP.addTask(whenDone); @@ -142,7 +142,7 @@ public class ClassicPlotManager extends SquarePlotManager { final PseudoRandom random = new PseudoRandom(); if (!plot.getMerged(0)) { int z = bottom.getZ(); - for (int x = bottom.getX(); x <= (top.getX()); x++) { + for (int x = bottom.getX(); x <= top.getX(); x++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -150,7 +150,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(3)) { int x = bottom.getX(); - for (int z = bottom.getZ(); z <= (top.getZ()); z++) { + for (int z = bottom.getZ(); z <= top.getZ(); z++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -159,7 +159,7 @@ public class ClassicPlotManager extends SquarePlotManager { if (!plot.getMerged(2)) { int z = top.getZ(); - for (int x = bottom.getX(); x <= (top.getX()); x++) { + for (int x = bottom.getX(); x <= top.getX(); x++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -167,7 +167,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(1)) { int x = top.getX(); - for (int z = bottom.getZ(); z <= (top.getZ()); z++) { + for (int z = bottom.getZ(); z <= top.getZ(); z++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -194,7 +194,7 @@ public class ClassicPlotManager extends SquarePlotManager { final PseudoRandom random = new PseudoRandom(); if (!plot.getMerged(0)) { int z = bot.getZ(); - for (int x = bot.getX(); x < (top.getX()); x++) { + for (int x = bot.getX(); x < top.getX(); x++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -202,7 +202,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(3)) { int x = bot.getX(); - for (int z = bot.getZ(); z < (top.getZ()); z++) { + for (int z = bot.getZ(); z < top.getZ(); z++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -210,7 +210,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(2)) { int z = top.getZ(); - for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) { + for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -218,7 +218,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(1)) { int x = top.getX(); - for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) { + for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -239,25 +239,25 @@ public class ClassicPlotManager extends SquarePlotManager { final int y = dpw.WALL_HEIGHT + 1; if (!plot.getMerged(0)) { int z = bot.getZ(); - for (int x = bot.getX(); x < (top.getX()); x++) { + for (int x = bot.getX(); x < top.getX(); x++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } } if (!plot.getMerged(3)) { int x = bot.getX(); - for (int z = bot.getZ(); z < (top.getZ()); z++) { + for (int z = bot.getZ(); z < top.getZ(); z++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } } if (!plot.getMerged(2)) { int z = top.getZ(); - for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) { + for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } } if (!plot.getMerged(1)) { int x = top.getX(); - for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) { + for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } } @@ -273,7 +273,7 @@ public class ClassicPlotManager extends SquarePlotManager { final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId()); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); final int sx = pos2.getX() + 1; - final int ex = (sx + dpw.ROAD_WIDTH) - 1; + final int ex = sx + dpw.ROAD_WIDTH - 1; final int sz = pos1.getZ() - 2; final int ez = pos2.getZ() + 2; MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0)); @@ -295,7 +295,7 @@ public class ClassicPlotManager extends SquarePlotManager { final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId()); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); final int sz = pos2.getZ() + 1; - final int ez = (sz + dpw.ROAD_WIDTH) - 1; + final int ez = sz + dpw.ROAD_WIDTH - 1; final int sx = pos1.getX() - 2; final int ex = pos2.getX() + 2; MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0)); @@ -315,9 +315,9 @@ public class ClassicPlotManager extends SquarePlotManager { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); final int sx = pos2.getX() + 1; - final int ex = (sx + dpw.ROAD_WIDTH) - 1; + final int ex = sx + dpw.ROAD_WIDTH - 1; final int sz = pos2.getZ() + 1; - final int ez = (sz + dpw.ROAD_WIDTH) - 1; + final int ez = sz + dpw.ROAD_WIDTH - 1; MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock( (short) 0, (byte) 0)); MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), new Location(plotworld.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0)); @@ -331,7 +331,7 @@ public class ClassicPlotManager extends SquarePlotManager { final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId()); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); final int sx = pos2.getX() + 1; - final int ex = (sx + dpw.ROAD_WIDTH) - 1; + final int ex = sx + dpw.ROAD_WIDTH - 1; final int sz = pos1.getZ() - 1; final int ez = pos2.getZ() + 1; MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); @@ -346,7 +346,7 @@ public class ClassicPlotManager extends SquarePlotManager { final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId()); final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId()); final int sz = pos2.getZ() + 1; - final int ez = (sz + dpw.ROAD_WIDTH) - 1; + final int ez = sz + dpw.ROAD_WIDTH - 1; final int sx = pos1.getX() - 1; final int ex = pos2.getX() + 1; MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); @@ -360,9 +360,9 @@ public class ClassicPlotManager extends SquarePlotManager { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location loc = getPlotTopLocAbs(dpw, plot.getId()); final int sx = loc.getX() + 1; - final int ex = (sx + dpw.ROAD_WIDTH) - 1; + final int ex = sx + dpw.ROAD_WIDTH - 1; final int sz = loc.getZ() + 1; - final int ez = (sz + dpw.ROAD_WIDTH) - 1; + final int ez = sz + dpw.ROAD_WIDTH - 1; MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK); MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK); @@ -376,7 +376,7 @@ public class ClassicPlotManager extends SquarePlotManager { public boolean finishPlotMerge(final PlotArea plotworld, final ArrayList plotIds) { final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; - if ((block.id != 0) || !block.equals(unclaim)) { + if (block.id != 0 || !block.equals(unclaim)) { for (final PlotId id : plotIds) { setWall(plotworld, id, new PlotBlock[] { block }); } @@ -389,7 +389,7 @@ public class ClassicPlotManager extends SquarePlotManager { final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; for (final PlotId id : plotIds) { - if ((block.id != 0) || !block.equals(unclaim)) { + if (block.id != 0 || !block.equals(unclaim)) { setWall(plotworld, id, new PlotBlock[] { block }); } } @@ -410,7 +410,7 @@ public class ClassicPlotManager extends SquarePlotManager { public boolean claimPlot(final PlotArea plotworld, final Plot plot) { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; - if ((claim.id != 0) || !claim.equals(unclaim)) { + if (claim.id != 0 || !claim.equals(unclaim)) { setWall(plotworld, plot.getId(), new PlotBlock[] { claim }); } return true; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index a9772792d..9297f163f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -5,12 +5,32 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.*; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotAnalysis; +import com.intellectualcrafters.plot.object.PlotArea; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MathMan; +import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.SetQueue; +import com.intellectualcrafters.plot.util.TaskManager; import java.io.File; -import java.util.*; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; public abstract class HybridUtils { @@ -95,8 +115,8 @@ public abstract class HybridUtils { final ArrayList chunks = new ArrayList<>(); final int sx = region.x << 5; final int sz = region.z << 5; - for (int x = sx; x < (sx + 32); x++) { - for (int z = sz; z < (sz + 32); z++) { + for (int x = sx; x < sx + 32; x++) { + for (int z = sz; z < sz + 32; z++) { chunks.add(new ChunkLoc(x, z)); } } @@ -185,10 +205,10 @@ public abstract class HybridUtils { return; } count.incrementAndGet(); - if ((count.intValue() % 20) == 0) { - PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%"); + if (count.intValue() % 20 == 0) { + PS.debug("PROGRESS: " + 100 * (2048 - chunks.size()) / 2048 + "%"); } - if ((regions.isEmpty()) && (chunks.isEmpty())) { + if (regions.isEmpty() && chunks.isEmpty()) { HybridUtils.UPDATE = false; PS.debug(C.PREFIX.s() + "Finished road conversion"); // CANCEL TASK @@ -214,7 +234,7 @@ public abstract class HybridUtils { } if (!chunks.isEmpty()) { final long diff = System.currentTimeMillis() + 1; - if (((System.currentTimeMillis() - baseTime - last.get()) > 2000) && (last.get() != 0)) { + if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) { last.set(0); PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s"); Iterator iter = chunks.iterator(); @@ -230,8 +250,8 @@ public abstract class HybridUtils { TaskManager.runTaskLater(task, 600); return; } - if ((((System.currentTimeMillis() - baseTime) - last.get()) < 1500) && (last.get() != 0)) { - while ((System.currentTimeMillis() < diff) && (!chunks.isEmpty())) { + if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) { + while (System.currentTimeMillis() < diff && !chunks.isEmpty()) { Iterator iter = chunks.iterator(); final ChunkLoc chunk = iter.next(); iter.remove(); @@ -253,8 +273,8 @@ public abstract class HybridUtils { PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); final int sx = loc.x << 5; final int sz = loc.z << 5; - for (int x = sx; x < (sx + 32); x++) { - for (int z = sz; z < (sz + 32); z++) { + for (int x = sx; x < sx + 32; x++) { + for (int z = sz; z < sz + 32; z++) { ChunkManager.manager.unloadChunk(area.worldname, new ChunkLoc(x, z), true, true); } } @@ -280,7 +300,7 @@ public abstract class HybridUtils { final Location bot = plot.getBottomAbs().subtract(1, 0, 1); final Location top = plot.getTopAbs(); final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea(); - final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1; + final int sx = bot.getX() - plotworld.ROAD_WIDTH + 1; final int sz = bot.getZ() + 1; final int sy = plotworld.ROAD_HEIGHT; final int ex = bot.getX(); @@ -339,18 +359,18 @@ public abstract class HybridUtils { final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez); x -= plotworld.ROAD_OFFSET_X; z -= plotworld.ROAD_OFFSET_Z; - if ((id1 == null) || (id2 == null) || (id1 != id2)) { + if (id1 == null || id2 == null || id1 != id2) { final boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false); if (result) { if (id1 != null) { final Plot p1 = area.getPlotAbs(id1); - if ((p1 != null) && p1.hasOwner() && p1.isMerged()) { + if (p1 != null && p1.hasOwner() && p1.isMerged()) { toCheck = true; } } - if ((id2 != null) && !toCheck) { + if (id2 != null && !toCheck) { final Plot p2 = area.getPlotAbs(id2); - if ((p2 != null) && p2.hasOwner() && p2.isMerged()) { + if (p2 != null && p2.hasOwner() && p2.isMerged()) { toCheck = true; } } @@ -374,12 +394,11 @@ public abstract class HybridUtils { final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; final boolean lx = absX < plotworld.PATH_WIDTH_UPPER; final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; - condition = (!gx || !gz || !lx || !lz); + condition = !gx || !gz || !lx || !lz; } if (condition) { - final int sy = plotworld.ROAD_HEIGHT; final HashMap blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ)); - for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend); y++) { + for (short y = (short) plotworld.ROAD_HEIGHT; y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend; y++) { SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0); } if (blocks != null) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java b/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java index 66b733c36..34dc57847 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/BO3.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.object; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.util.MainUtil; + import java.io.File; public class BO3 { @@ -59,6 +60,6 @@ public class BO3 { } public String getFilename() { - return name + (((chunk.x == 0) && (chunk.z == 0)) ? "" : ("_" + chunk.x + "_" + chunk.z)) + ".bo3"; + return name + (chunk.x == 0 && chunk.z == 0 ? "" : "_" + chunk.x + "_" + chunk.z) + ".bo3"; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java b/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java index cc0f02611..94df25558 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java @@ -19,14 +19,35 @@ public class BlockLoc { public BlockLoc(final int x, final int y, final int z) { this(x, y, z, 0f, 0f); } + + public static BlockLoc fromString(final String string) { + final String[] parts = string.split(","); + + float yaw, pitch; + if (parts.length == 3) { + yaw = 0f; + pitch = 0f; + } + if (parts.length == 5) { + yaw = Float.parseFloat(parts[3]); + pitch = Float.parseFloat(parts[4]); + } else { + return new BlockLoc(0, 0, 0); + } + final int x = Integer.parseInt(parts[0]); + final int y = Integer.parseInt(parts[1]); + final int z = Integer.parseInt(parts[2]); + + return new BlockLoc(x, y, z, yaw, pitch); + } @Override public int hashCode() { final int prime = 31; int result = 1; - result = (prime * result) + x; - result = (prime * result) + y; - result = (prime * result) + z; + result = prime * result + x; + result = prime * result + y; + result = prime * result + z; return result; } @@ -42,7 +63,7 @@ public class BlockLoc { return false; } final BlockLoc other = (BlockLoc) obj; - return ((x == other.x) && (y == other.y) && (z == other.z)); + return x == other.x && y == other.y && z == other.z; } @Override @@ -53,25 +74,4 @@ public class BlockLoc { return x + "," + y + "," + z + "," + yaw + "," + pitch; } - - public static BlockLoc fromString(final String string) { - final String[] parts = string.split(","); - - float yaw, pitch; - if (parts.length == 3) { - yaw = 0f; - pitch = 0f; - } - if (parts.length == 5) { - yaw = Float.parseFloat(parts[3]); - pitch = Float.parseFloat(parts[4]); - } else { - return new BlockLoc(0, 0, 0); - } - final int x = Integer.parseInt(parts[0]); - final int y = Integer.parseInt(parts[1]); - final int z = Integer.parseInt(parts[2]); - - return new BlockLoc(x, y, z, yaw, pitch); - } } 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 f90ad70e9..cc79417c2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -70,6 +70,7 @@ import java.util.concurrent.atomic.AtomicInteger; */ @SuppressWarnings("javadoc") public class Plot { + /** * @deprecated raw access is deprecated */ @@ -138,7 +139,7 @@ public class Plot { * - The origin plot is used for plot grouping and relational data */ private Plot origin; - + /** * Constructor for a new plot
* (Only changes after plot.create() will be properly set in the database) @@ -154,7 +155,7 @@ public class Plot { this.id = id; this.owner = owner; } - + /** * Constructor for an unowned plot
* (Only changes after plot.create() will be properly set in the database) @@ -168,7 +169,7 @@ public class Plot { this.area = area; this.id = id; } - + /** * Constructor for a temporary plot (use -1 for temp)
* The database will ignore any queries regarding temporary plots. @@ -187,7 +188,7 @@ public class Plot { this.owner = owner; this.temp = temp; } - + /** * Constructor for a saved plots (Used by the database manager when plots are fetched) * @@ -199,8 +200,9 @@ public class Plot { * @param denied * @param merged */ - public Plot(final PlotId id, final UUID owner, final HashSet trusted, final HashSet members, final HashSet denied, final String alias, final BlockLoc position, - final Collection flags, final PlotArea area, final boolean[] merged, final long timestamp, final int temp) { + public Plot(final PlotId id, final UUID owner, final HashSet trusted, final HashSet members, final HashSet denied, + final String alias, final BlockLoc position, + final Collection flags, final PlotArea area, final boolean[] merged, final long timestamp, final int temp) { this.id = id; this.area = area; this.owner = owner; @@ -248,7 +250,7 @@ public class Plot { } return null; } - + /** * Return a new/cached plot object at a given location * @@ -264,7 +266,7 @@ public class Plot { } return null; } - + /** * Session only plot metadata (session is until the server stops)
*
@@ -279,7 +281,7 @@ public class Plot { } this.meta.put(key, value); } - + /** * Get the metadata for a key
*
@@ -293,7 +295,7 @@ public class Plot { } return null; } - + /** * Delete the metadata for a key
* - metadata is session only @@ -305,7 +307,7 @@ public class Plot { this.meta.remove(key); } } - + /** * Get the cluster this plot is associated with * @return the PlotCluster object, or null @@ -313,7 +315,7 @@ public class Plot { public PlotCluster getCluster() { return this.getArea().getCluster(this.id); } - + /** * Efficiently get the players currently inside this plot
* - Will return an empty list if no players are in the plot
@@ -330,7 +332,7 @@ public class Plot { } return players; } - + /** * Check if the plot has a set owner * @@ -339,7 +341,7 @@ public class Plot { public boolean hasOwner() { return this.owner != null; } - + /** * Check if a UUID is a plot owner (merged plots may have multiple owners) * @param uuid @@ -360,7 +362,7 @@ public class Plot { } return false; } - + public boolean isOwnerAbs(final UUID uuid) { return uuid.equals(owner); } @@ -389,7 +391,7 @@ public class Plot { } return new HashSet<>(Collections.singletonList(owner)); } - + /** * Check if the player is either the owner or on the trusted/added list * @@ -417,7 +419,7 @@ public class Plot { } return false; } - + /** * Should the player be denied from entering? * @@ -426,16 +428,17 @@ public class Plot { * @return boolean false if the player is allowed to enter */ public boolean isDenied(final UUID uuid) { - return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); + return this.denied != null && (this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid) || + !this.isAdded(uuid) && this.denied.contains(uuid)); } - + /** * Get the plot ID */ public PlotId getId() { return this.id; } - + /** * Get the plot world object for this plot
* - The generic PlotArea object can be casted to its respective class for more control (e.g. HybridPlotWorld) @@ -461,7 +464,7 @@ public class Plot { this.area = area; area.addPlot(this); } - + /** * Get the plot manager object for this plot
* - The generic PlotManager object can be casted to its respective class for more control (e.g. HybridPlotManager) @@ -470,7 +473,7 @@ public class Plot { public PlotManager getManager() { return this.area.getPlotManager(); } - + /** * Get or create plot settings * @return PlotSettings @@ -483,7 +486,7 @@ public class Plot { } return this.settings; } - + /** * Returns true if the plot is not merged, or it is the base plot of multiple merged plots * @return @@ -491,7 +494,7 @@ public class Plot { public boolean isBasePlot() { return !this.isMerged() || this.equals(this.getBasePlot(false)); } - + /** * The base plot is an arbitrary but specific connected plot. It is useful for the following:
* - Merged plots need to be treated as a single plot for most purposes
@@ -501,7 +504,7 @@ public class Plot { * @return base Plot */ public Plot getBasePlot(final boolean recalculate) { - if ((this.origin != null) && !recalculate) { + if (this.origin != null && !recalculate) { if (this.equals(this.origin)) { return this; } @@ -514,7 +517,7 @@ public class Plot { this.origin = this; PlotId min = this.id; for (final Plot plot : this.getConnectedPlots()) { - if ((plot.id.y < min.y) || (plot.id.y == min.y && plot.id.x < min.x)) { + if (plot.id.y < min.y || plot.id.y == min.y && plot.id.x < min.x) { this.origin = plot; min = plot.id; } @@ -524,7 +527,7 @@ public class Plot { } return this.origin; } - + /** * Check if the plot is merged in any direction * @return @@ -532,7 +535,7 @@ public class Plot { public boolean isMerged() { return getSettings().getMerged(0) || getSettings().getMerged(2) || getSettings().getMerged(1) || getSettings().getMerged(3); } - + /** * Get the timestamp of when the plot was created (unreliable)
* - not accurate if the plot was created before this was implemented
@@ -545,7 +548,7 @@ public class Plot { } return this.timestamp; } - + /** * Get if the plot is merged in a direction
* ------- Actual -------
@@ -610,7 +613,7 @@ public class Plot { } return this.denied; } - + /** * Set the denied users for this plot * @param uuids @@ -629,7 +632,7 @@ public class Plot { addDenied(uuid); } } - + /** * Get the trusted users * @return @@ -640,7 +643,7 @@ public class Plot { } return this.trusted; } - + /** * Set the trusted users for this plot * @param uuids @@ -659,7 +662,7 @@ public class Plot { addTrusted(uuid); } } - + /** * Get the members * @return @@ -670,7 +673,7 @@ public class Plot { } return this.members; } - + /** * Set the members for this plot * @param uuids @@ -689,7 +692,7 @@ public class Plot { addMember(uuid); } } - + /** * Deny someone (updates database as well) * @param uuid @@ -701,7 +704,7 @@ public class Plot { } } } - + /** * Add someone as a helper (updates database as well) * @@ -714,7 +717,7 @@ public class Plot { } } } - + /** * Add someone as a trusted user (updates database as well) * @@ -727,7 +730,7 @@ public class Plot { } } } - + /** * Set the plot owner (and update the database) * @param owner @@ -752,7 +755,7 @@ public class Plot { } } } - + /** * Clear a plot * @see this#clear(Runnable) @@ -763,9 +766,9 @@ public class Plot { public void clear(final Runnable whenDone) { this.clear(false, false, whenDone); } - + public boolean clear(final boolean checkRunning, final boolean isDelete, final Runnable whenDone) { - if (checkRunning && (this.getRunning() != 0)) { + if (checkRunning && this.getRunning() != 0) { return false; } if (!EventUtil.manager.callClear(this)) { @@ -814,7 +817,7 @@ public class Plot { return; } final Plot current = queue.poll(); - if ((Plot.this.area.TERRAIN != 0) || Settings.FAST_CLEAR) { + if (Plot.this.area.TERRAIN != 0 || Settings.FAST_CLEAR) { ChunkManager.manager.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false, this); return; } @@ -824,7 +827,7 @@ public class Plot { run.run(); return true; } - + /** * Set the biome for a plot asynchronously * @param biome The biome e.g. "forest" @@ -852,12 +855,12 @@ public class Plot { ChunkManager.manager.unloadChunk(Plot.this.area.worldname, loc, true, true); } }, this, 5); - + } }; run.run(); } - + /** * Unlink the plot and all connected plots * @param createSign @@ -886,7 +889,7 @@ public class Plot { if (createRoad) { manager.startPlotUnlink(this.area, ids); } - if ((this.area.TERRAIN != 3) && createRoad) { + if (this.area.TERRAIN != 3 && createRoad) { for (final Plot current : plots) { if (current.getMerged(1)) { manager.createRoadEast(current.area, current); @@ -902,7 +905,7 @@ public class Plot { } } for (final Plot current : plots) { - final boolean[] merged = new boolean[] { false, false, false, false }; + final boolean[] merged = new boolean[]{false, false, false, false}; current.setMerged(merged); if (createSign) { current.setSign(MainUtil.getName(current.owner)); @@ -913,7 +916,7 @@ public class Plot { } return true; } - + /** * Set the sign for a plot to a specific name * @param name @@ -932,15 +935,15 @@ public class Plot { if (this.area.ALLOW_SIGNS) { final Location loc = manager.getSignLoc(this.area, this); final String id = this.id.x + ";" + this.id.y; - final String[] lines = new String[] { - C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id), - C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", name), - C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", name), - C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", name) }; + final String[] lines = new String[]{ + C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id), + C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", name), + C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", name), + C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", name)}; WorldUtil.IMP.setSign(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), lines); } } - + /** * This will return null if the plot hasn't been analyzed * @return analysis of plot @@ -948,11 +951,11 @@ public class Plot { public PlotAnalysis getComplexity() { return PlotAnalysis.getAnalysis(this); } - + public void analyze(final RunnableVal whenDone) { PlotAnalysis.analyzePlot(this, whenDone); } - + /** * Set a flag for this plot * @param flag @@ -961,7 +964,7 @@ public class Plot { public void setFlag(final String flag, final Object value) { FlagManager.addPlotFlag(this, new Flag(FlagManager.getFlag(flag), value)); } - + /** * Remove a flag from this plot * @param flag @@ -969,7 +972,7 @@ public class Plot { public void removeFlag(final String flag) { FlagManager.removePlotFlag(this, flag); } - + /** * Get the flag for a given key * @param key @@ -977,7 +980,7 @@ public class Plot { public Flag getFlag(final String key) { return FlagManager.getPlotFlagRaw(this, key); } - + /** * Delete a plot (use null for the runnable if you don't need to be notified on completion) * @see PS#removePlot(Plot, boolean) @@ -999,7 +1002,7 @@ public class Plot { }); return true; } - + /** * Count the entities in a plot * @see ChunkManager#countEntities(Plot) @@ -1024,7 +1027,7 @@ public class Plot { } return count; } - + /** * Returns true if a previous task was running * @return @@ -1086,7 +1089,7 @@ public class Plot { } return true; } - + /** * Unlink a plot and remove the roads * @see this#unlinkPlot(boolean, boolean) @@ -1095,7 +1098,7 @@ public class Plot { public boolean unlink() { return this.unlinkPlot(true, true); } - + public Location getCenter() { Location[] corners = getCorners(); final Location top = corners[0]; @@ -1104,14 +1107,14 @@ public class Plot { loc.setY(1 + Math.max(WorldUtil.IMP.getHighestBlock(area.worldname, loc.getX(), loc.getZ()), getManager().getSignLoc(area, this).getY())); return loc; } - + /** * Return the home location for the plot * @return Home location */ public Location getHome() { final BlockLoc home = this.getPosition(); - if ((home == null) || ((home.x == 0) && (home.z == 0))) { + if (home == null || home.x == 0 && home.z == 0) { return this.getDefaultHome(); } else { final Location bot = this.getBottomAbs(); @@ -1122,7 +1125,7 @@ public class Plot { return loc; } } - + /** * Set the home location * @param loc @@ -1136,7 +1139,7 @@ public class Plot { plot.getSettings().setPosition(loc); DBFunc.setPosition(plot, plot.getSettings().getPosition().toString()); } - + /** * Get the default home location for a plot
* - Ignores any home location set for that specific plot @@ -1147,11 +1150,11 @@ public class Plot { if (this.area.DEFAULT_HOME != null) { final int x; final int z; - if ((this.area.DEFAULT_HOME.x == Integer.MAX_VALUE) && (this.area.DEFAULT_HOME.z == Integer.MAX_VALUE)) { + if (this.area.DEFAULT_HOME.x == Integer.MAX_VALUE && this.area.DEFAULT_HOME.z == Integer.MAX_VALUE) { // center final RegionWrapper largest = plot.getLargestRegion(); - x = ((largest.maxX - largest.minX) / 2) + largest.minX; - z = ((largest.maxZ - largest.minZ) / 2) + largest.minZ; + x = (largest.maxX - largest.minX) / 2 + largest.minX; + z = (largest.maxZ - largest.minZ) / 2 + largest.minZ; } else { // specific final Location bot = plot.getBottomAbs(); @@ -1163,13 +1166,13 @@ public class Plot { } // Side final RegionWrapper largest = plot.getLargestRegion(); - final int x = ((largest.maxX - largest.minX) / 2) + largest.minX; + final int x = (largest.maxX - largest.minX) / 2 + largest.minX; final int z = largest.minZ - 1; final PlotManager manager = plot.getManager(); final int y = Math.max(WorldUtil.IMP.getHighestBlock(plot.area.worldname, x, z), manager.getSignLoc(plot.area, plot).getY()); return new Location(plot.area.worldname, x, y + 1, z); } - + /** * Get the average rating of the plot. This is the value displayed in /plot info * @return average rating as double @@ -1182,7 +1185,7 @@ public class Plot { } return sum / ratings.size(); } - + /** * Set a rating for a user
* - If the user has already rated, the following will return false @@ -1201,19 +1204,19 @@ public class Plot { DBFunc.setRating(base, uuid, aggregate); return true; } - + /** * Clear the ratings for this plot */ public void clearRatings() { final Plot base = this.getBasePlot(false); final PlotSettings baseSettings = base.getSettings(); - if ((baseSettings.ratings != null) && !baseSettings.getRatings().isEmpty()) { + if (baseSettings.ratings != null && !baseSettings.getRatings().isEmpty()) { DBFunc.deleteRatings(base); baseSettings.ratings = null; } } - + /** * Get the ratings associated with a plot
* - The rating object may contain multiple categories @@ -1230,7 +1233,7 @@ public class Plot { } return map; } - + public boolean hasRatings() { Plot base = this.getBasePlot(false); return base.settings != null && base.settings.ratings != null; @@ -1246,8 +1249,8 @@ public class Plot { public void run() { final HashSet chunks = new HashSet<>(); for (final RegionWrapper region : Plot.this.getRegions()) { - for (int x = region.minX >> 4; x <= (region.maxX >> 4); x++) { - for (int z = region.minZ >> 4; z <= (region.maxZ >> 4); z++) { + for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) { + for (int z = region.minZ >> 4; z <= region.maxZ >> 4; z++) { chunks.add(new ChunkLoc(x, z)); } } @@ -1256,7 +1259,7 @@ public class Plot { } }); } - + /** * Remove the plot sign if it is set */ @@ -1268,7 +1271,7 @@ public class Plot { final Location loc = manager.getSignLoc(this.area, this); SetQueue.IMP.setBlock(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), 0); } - + /** * Set the plot sign if plot signs are enabled */ @@ -1279,11 +1282,12 @@ public class Plot { } this.setSign(UUIDHandler.getName(this.owner)); } - + /** * Register a plot and create it in the database
* - The plot will not be created if the owner is null
- * - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation. + * - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot + * creation. * @return true if plot was created successfully */ public boolean create() { @@ -1328,11 +1332,12 @@ public class Plot { plotworld.getPlotManager().claimPlot(plotworld, this); return true; } - + /** * Register a plot and create it in the database
* - The plot will not be created if the owner is null
- * - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation. + * - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot + * creation. * @return true if plot was created successfully */ public boolean create(final UUID uuid, final boolean notify) { @@ -1370,19 +1375,16 @@ public class Plot { } return false; } - + /** * Set components such as border, wall, floor * (components are generator specific) */ public boolean setComponent(final String component, final String blocks) { final PlotBlock[] parsed = Configuration.BLOCKLIST.parseString(blocks); - if ((parsed == null) || (parsed.length == 0)) { - return false; - } - return this.setComponent(component, parsed); + return !(parsed == null || parsed.length == 0) && this.setComponent(component, parsed); } - + /** * Get the biome (String) */ @@ -1390,7 +1392,7 @@ public class Plot { final Location loc = this.getBottomAbs(); return WorldUtil.IMP.getBiome(loc.getWorld(), loc.getX(), loc.getZ()); } - + /** * Return the top location for the plot * @return @@ -1398,7 +1400,7 @@ public class Plot { public Location getTopAbs() { return this.area.getPlotManager().getPlotTopLocAbs(this.area, this.id); } - + /** * Return the bottom location for the plot * @return @@ -1406,7 +1408,7 @@ public class Plot { public Location getBottomAbs() { return this.area.getPlotManager().getPlotBottomLocAbs(this.area, this.id); } - + /** * Swap the settings for two plots * @param p2 @@ -1415,13 +1417,13 @@ public class Plot { */ public boolean swapData(final Plot p2, final Runnable whenDone) { if (this.owner == null) { - if ((p2 != null) && p2.hasOwner()) { + if (p2 != null && p2.hasOwner()) { p2.moveData(this, whenDone); return true; } return false; } - if ((p2 == null) || (p2.owner == null)) { + if (p2 == null || p2.owner == null) { this.moveData(p2, whenDone); return true; } @@ -1442,7 +1444,7 @@ public class Plot { TaskManager.runTaskLater(whenDone, 1); return true; } - + /** * Move the settings for a plot * @param pos2 @@ -1469,7 +1471,7 @@ public class Plot { TaskManager.runTaskLater(whenDone, 1); return true; } - + /** * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as * a small plot use getPlotTopLocAbs(...) @@ -1489,7 +1491,7 @@ public class Plot { } return top; } - + /** * Gets the bottom location for a plot.
* - Does not respect mega plots
@@ -1510,7 +1512,7 @@ public class Plot { } return bot; } - + /** * Returns the top and bottom location.
* - If the plot is not connected, it will return its own corners
@@ -1521,17 +1523,17 @@ public class Plot { @Deprecated public Location[] getCorners() { if (!this.isMerged()) { - return new Location[] { this.getBottomAbs(), this.getTopAbs() }; + return new Location[]{this.getBottomAbs(), this.getTopAbs()}; } return MainUtil.getCorners(this.area.worldname, this.getRegions()); } - + /** * Remove the east road section of a plot
* - Used when a plot is merged
*/ public void removeRoadEast() { - if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) { + if (this.area.TYPE != 0 && this.area.TERRAIN > 1) { if (this.area.TERRAIN == 3) { return; } @@ -1545,7 +1547,7 @@ public class Plot { this.area.getPlotManager().removeRoadEast(this.area, this); } } - + /** * Returns the top and bottom plot id.
* - If the plot is not connected, it will return itself for the top/bottom
@@ -1556,7 +1558,7 @@ public class Plot { @Deprecated public PlotId[] getCornerIds() { if (!this.isMerged()) { - return new PlotId[] { this.getId(), this.getId() }; + return new PlotId[]{this.getId(), this.getId()}; } final PlotId min = new PlotId(this.getId().x, this.getId().y); final PlotId max = new PlotId(this.getId().x, this.getId().y); @@ -1572,9 +1574,9 @@ public class Plot { max.y = current.getId().y; } } - return new PlotId[] { min, max }; + return new PlotId[]{min, max}; } - + /** * @deprecated in favor of getCorners()[0];
* @return @@ -1583,7 +1585,7 @@ public class Plot { public Location getBottom() { return this.getCorners()[0]; } - + /** * @deprecated in favor of getCorners()[1]; * @return @@ -1592,7 +1594,7 @@ public class Plot { public Location getTop() { return this.getCorners()[1]; } - + /** * Swap the plot contents and settings with another location
* - The destination must correspond to a valid plot of equal dimensions @@ -1606,7 +1608,7 @@ public class Plot { public boolean swap(final Plot destination, final Runnable whenDone) { return this.move(destination, whenDone, true); } - + /** * Move the plot to an empty location
* - The location must be empty @@ -1617,7 +1619,7 @@ public class Plot { public boolean move(final Plot destination, final Runnable whenDone) { return this.move(destination, whenDone, false); } - + /** * Get plot display name * @@ -1625,12 +1627,12 @@ public class Plot { */ @Override public String toString() { - if ((this.settings != null) && (this.settings.getAlias().length() > 1)) { + if (this.settings != null && this.settings.getAlias().length() > 1) { return this.settings.getAlias(); } return this.area + ";" + this.id.x + ";" + this.id.y; } - + /** * Remove a denied player (use DBFunc as well)
* Using the * uuid will remove all users @@ -1657,6 +1659,7 @@ public class Plot { } return true; } + /** * Remove a helper (use DBFunc as well)
* Using the * uuid will remove all users @@ -1732,7 +1735,8 @@ public class Plot { @Override public void run() { final String name = Plot.this.id + "," + Plot.this.area + "," + MainUtil.getName(Plot.this.owner); - final boolean result = SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic"); + final boolean result = + SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic"); if (whenDone != null) { whenDone.value = result; TaskManager.runTask(whenDone); @@ -1743,7 +1747,7 @@ public class Plot { } }); } - + /** * Export the plot as a BO3 object
* - bedrock, floor and main block are ignored in their respective sections @@ -1758,7 +1762,7 @@ public class Plot { } TaskManager.runTask(whenDone); } - + /** * Upload the plot as a schematic to the configured web interface
* @param whenDone value will be null if uploading fails @@ -1806,9 +1810,9 @@ public class Plot { return false; } final Plot other = (Plot) obj; - return (this.hashCode() == other.hashCode()) && this.id.equals(other.id) && (this.area == other.area); + return this.hashCode() == other.hashCode() && this.id.equals(other.id) && this.area == other.area; } - + /** * Get the plot hashcode
* Note: The hashcode is unique if:
@@ -1820,7 +1824,7 @@ public class Plot { public int hashCode() { return this.id.hashCode(); } - + /** * Get the flags specific to this plot
* - Does not take default flags into account
@@ -1832,7 +1836,7 @@ public class Plot { } return this.settings.flags; } - + /** * Set a flag for this plot * @param flags @@ -1840,7 +1844,7 @@ public class Plot { public void setFlags(final Set flags) { FlagManager.setPlotFlags(this, flags); } - + /** * Get the plot Alias
* - Returns an empty string if no alias is set @@ -1852,7 +1856,7 @@ public class Plot { } return this.settings.getAlias(); } - + /** * Set the plot alias * @param alias @@ -1870,7 +1874,7 @@ public class Plot { DBFunc.setAlias(current, alias); } } - + /** * Set the raw merge data
* - Updates DB
@@ -1889,7 +1893,7 @@ public class Plot { if (value) { final Plot other = this.getRelative(direction).getBasePlot(false); if (!other.equals(this.getBasePlot(false))) { - final Plot base = (other.id.y < this.id.y) || (other.id.y == this.id.y && (other.id.x < this.id.x)) ? other : this.origin; + final Plot base = other.id.y < this.id.y || other.id.y == this.id.y && other.id.x < this.id.x ? other : this.origin; this.origin.origin = base; other.origin = base; this.origin = base; @@ -1906,7 +1910,7 @@ public class Plot { regions_cache = null; } } - + /** * Get the merged array * @return boolean [ north, east, south, west ] @@ -1914,7 +1918,7 @@ public class Plot { public boolean[] getMerged() { return this.getSettings().getMerged(); } - + /** * Set the raw merge data
* - Updates DB
@@ -1939,7 +1943,7 @@ public class Plot { this.origin = null; } } - + /** * Get the set home location or 0,0,0 if no location is set
* - Does not take the default home location into account @@ -1986,7 +1990,8 @@ public class Plot { if (lines == null) { return null; } - loop: for (int i = 4; i > 0; i--) { + loop: + for (int i = 4; i > 0; i--) { final String caption = C.valueOf("OWNER_SIGN_LINE_" + i).s(); final int index = caption.indexOf("%plr%"); if (index == -1) { @@ -1994,7 +1999,7 @@ public class Plot { } else if (index < -1) { PS.debug("This should NEVER happen. Seriously, it's impossible."); } - String line = lines[i-1]; + String line = lines[i - 1]; if (line.length() <= index) { return null; } @@ -2011,7 +2016,7 @@ public class Plot { final BiMap map = UUIDHandler.getUuidMap(); for (final Entry entry : map.entrySet()) { final String key = entry.getKey().value; - if ((key.length() > name.length()) && key.startsWith(name)) { + if (key.length() > name.length() && key.startsWith(name)) { this.owner = entry.getValue(); break loop; } @@ -2028,13 +2033,13 @@ public class Plot { return null; } } - + /** * Remove the south road section of a plot
* - Used when a plot is merged
*/ public void removeRoadSouth() { - if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) { + if (this.area.TYPE != 0 && this.area.TERRAIN > 1) { if (this.area.TERRAIN == 3) { return; } @@ -2048,7 +2053,7 @@ public class Plot { this.getManager().removeRoadSouth(this.area, this); } } - + /** * Auto merge a plot in a specific direction
* @param dir The direction to merge
@@ -2075,50 +2080,54 @@ public class Plot { final ArrayDeque frontier = new ArrayDeque<>(connected); Plot current; boolean toReturn = false; - while (((current = frontier.poll()) != null) && (max >= 0)) { + while ((current = frontier.poll()) != null && max >= 0) { if (visited.contains(current)) { continue; } visited.add(current); Set plots; - if ((dir == -1 || (dir == 0)) && !current.getMerged(0)) { + if ((dir == -1 || dir == 0) && !current.getMerged(0)) { final Plot other = current.getRelative(0); - 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)))) { + 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); merged.add(current.getId()); merged.add(other.getId()); toReturn = true; } } - if ((max >= 0) && ((dir == -1) || (dir == 1)) && !current.getMerged(1)) { + if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) { final Plot other = current.getRelative(1); - 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)))) { + 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); merged.add(current.getId()); merged.add(other.getId()); toReturn = true; } } - if ((max >= 0) && ((dir == -1) || (dir == 2)) && !current.getMerged(2)) { + if (max >= 0 && (dir == -1 || dir == 2) && !current.getMerged(2)) { final Plot other = current.getRelative(2); - 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)))) { + 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); merged.add(current.getId()); merged.add(other.getId()); toReturn = true; } } - if ((max >= 0) && ((dir == -1) || (dir == 3)) && !current.getMerged(3)) { + if (max >= 0 && (dir == -1 || dir == 3) && !current.getMerged(3)) { final Plot other = current.getRelative(3); - 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)))) { + 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); merged.add(current.getId()); merged.add(other.getId()); @@ -2132,7 +2141,7 @@ public class Plot { } return toReturn; } - + /** * Merge the plot settings
* - Used when a plot is merged
@@ -2169,7 +2178,7 @@ public class Plot { for (final UUID uuid : b.getMembers()) { this.addMember(uuid); } - + for (final UUID uuid : this.getDenied()) { b.addDenied(uuid); } @@ -2182,7 +2191,7 @@ public class Plot { * Remove the SE road (only effects terrain) */ public void removeRoadSouthEast() { - if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) { + if (this.area.TYPE != 0 && this.area.TERRAIN > 1) { if (this.area.TERRAIN == 3) { return; } @@ -2221,7 +2230,7 @@ public class Plot { public Plot getRelative(final int direction) { return this.area.getPlotAbs(this.id.getRelative(direction)); } - + /** * Get a set of plots connected (and including) this plot
* - This result is cached globally @@ -2236,7 +2245,7 @@ public class Plot { if (hash == 0) { return new HashSet<>(Collections.singletonList(this)); } - if ((connected_cache != null) && connected_cache.contains(this)) { + if (connected_cache != null && connected_cache.contains(this)) { return connected_cache; } regions_cache = null; @@ -2311,7 +2320,7 @@ public class Plot { } Plot current; while ((current = frontier.poll()) != null) { - if ((current.owner == null) || (current.settings == null)) { + if (current.owner == null || current.settings == null) { // Invalid plot // merged onto unclaimed plot PS.debug("Ignoring invalid merged plot: " + current + " | " + current.owner); @@ -2322,28 +2331,28 @@ public class Plot { merged = current.getMerged(); if (merged[0]) { tmp = current.area.getPlotAbs(current.id.getRelative(0)); - if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { + if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { queuecache.add(tmp); frontier.add(tmp); } } if (merged[1]) { tmp = current.area.getPlotAbs(current.id.getRelative(1)); - if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { + if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { queuecache.add(tmp); frontier.add(tmp); } } if (merged[2]) { tmp = current.area.getPlotAbs(current.id.getRelative(2)); - if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { + if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { queuecache.add(tmp); frontier.add(tmp); } } if (merged[3]) { tmp = current.area.getPlotAbs(current.id.getRelative(3)); - if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { + if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { queuecache.add(tmp); frontier.add(tmp); } @@ -2351,7 +2360,7 @@ public class Plot { } return connected_cache; } - + /** * This will combine each plot into effective rectangular regions
* - This result is cached globally
@@ -2359,7 +2368,7 @@ public class Plot { * @return */ public HashSet getRegions() { - if ((regions_cache != null) && (connected_cache != null) && connected_cache.contains(this)) { + if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) { return regions_cache; } if (!this.isMerged()) { @@ -2386,7 +2395,7 @@ public class Plot { boolean tmp = true; for (final PlotId id : ids) { final Plot plot = this.area.getPlotAbs(id); - if ((plot == null) || !plot.getMerged(2) || visited.contains(plot.getId())) { + if (plot == null || !plot.getMerged(2) || visited.contains(plot.getId())) { tmp = false; } } @@ -2398,7 +2407,7 @@ public class Plot { tmp = true; for (final PlotId id : ids) { final Plot plot = this.area.getPlotAbs(id); - if ((plot == null) || !plot.getMerged(3) || visited.contains(plot.getId())) { + if (plot == null || !plot.getMerged(3) || visited.contains(plot.getId())) { tmp = false; } } @@ -2410,7 +2419,7 @@ public class Plot { tmp = true; for (final PlotId id : ids) { final Plot plot = this.area.getPlotAbs(id); - if ((plot == null) || !plot.getMerged(0) || visited.contains(plot.getId())) { + if (plot == null || !plot.getMerged(0) || visited.contains(plot.getId())) { tmp = false; } } @@ -2422,7 +2431,7 @@ public class Plot { tmp = true; for (final PlotId id : ids) { final Plot plot = this.area.getPlotAbs(id); - if ((plot == null) || !plot.getMerged(1) || visited.contains(plot.getId())) { + if (plot == null || !plot.getMerged(1) || visited.contains(plot.getId())) { tmp = false; } } @@ -2450,7 +2459,7 @@ public class Plot { } } } - + for (int y = bot.y; y <= top.y; y++) { final Plot plot = this.area.getPlotAbs(new PlotId(top.x, y)); if (plot.getMerged(1)) { @@ -2469,7 +2478,7 @@ public class Plot { } return regions_cache; } - + /** * Attempt to find the largest rectangular region in a plot (as plots can form non rectangular shapes) * @return @@ -2479,7 +2488,7 @@ public class Plot { RegionWrapper max = null; int area = 0; for (final RegionWrapper region : regions) { - final int current = ((region.maxX - region.minX) + 1) * ((region.maxZ - region.minZ) + 1); + final int current = (region.maxX - region.minX + 1) * (region.maxZ - region.minZ + 1); if (current > area) { max = region; area = current; @@ -2503,7 +2512,7 @@ public class Plot { } }, 1); } - + /** * Get all the corners of the plot (supports non-rectangular shapes)
* @return @@ -2526,7 +2535,7 @@ public class Plot { } return locs; } - + /** * Teleport a player to a plot and send them the teleport message. * @param player @@ -2542,7 +2551,7 @@ public class Plot { } else { location = this.getDefaultHome(); } - if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) { + if (Settings.TELEPORT_DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) { MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT); player.teleport(location); return true; @@ -2569,7 +2578,7 @@ public class Plot { } return result; } - + public boolean isOnline() { if (owner == null) { return false; @@ -2596,7 +2605,7 @@ public class Plot { public boolean setComponent(final String component, final PlotBlock[] blocks) { return this.getManager().setComponent(this.area, this.getId(), component, blocks); } - + /** * Expand the world border to include the provided plot (if applicable) */ @@ -2619,7 +2628,7 @@ public class Plot { this.area.setMeta("worldBorder", max); } } - + /** * Merges 2 plots Removes the road inbetween
- Assumes plots are directly next to each other
- saves to DB * @@ -2678,7 +2687,7 @@ public class Plot { } } } - + /** * Move a plot physically, as well as the corresponding settings. * @param destination @@ -2759,7 +2768,7 @@ public class Plot { } return true; } - + /** * Copy a plot to a location, both physically and the settings * @param destination @@ -2797,19 +2806,19 @@ public class Plot { if (plot.isMerged()) { other.setMerged(plot.getMerged()); } - if ((plot.members != null) && !plot.members.isEmpty()) { + if (plot.members != null && !plot.members.isEmpty()) { other.members = plot.members; for (final UUID member : plot.members) { DBFunc.setMember(other, member); } } - if ((plot.trusted != null) && !plot.trusted.isEmpty()) { + if (plot.trusted != null && !plot.trusted.isEmpty()) { other.trusted = plot.trusted; for (final UUID trusted : plot.trusted) { DBFunc.setTrusted(other, trusted); } } - if ((plot.denied != null) && !plot.denied.isEmpty()) { + if (plot.denied != null && !plot.denied.isEmpty()) { other.denied = plot.denied; for (final UUID denied : plot.denied) { DBFunc.setDenied(other, denied); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java index 3c34bdf13..06bc9b5fb 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java @@ -70,7 +70,7 @@ public class PlotAnalysis { PS.debug("Calibration task already in progress!"); return; } - if ((threshold <= 0) || (threshold >= 1)) { + if (threshold <= 0 || threshold >= 1) { PS.debug("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point calibrating)"); return; } @@ -84,7 +84,7 @@ public class PlotAnalysis { PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data"); while (iter.hasNext()) { final Plot plot = iter.next(); - if ((plot.getSettings().ratings == null) || (plot.getSettings().getRatings().isEmpty())) { + if (plot.getSettings().ratings == null || plot.getSettings().getRatings().isEmpty()) { iter.remove(); } else { plot.addRunning(); @@ -126,7 +126,7 @@ public class PlotAnalysis { final int i = mi.intValue(); final Plot plot = plots.get(i); ratings[i] = (int) ((plot.getAverageRating() + plot.getSettings().getRatings().size()) * 100); - PS.debug(" | " + plot + " (rating) " + (ratings[i])); + PS.debug(" | " + plot + " (rating) " + ratings[i]); } } }); @@ -170,7 +170,7 @@ public class PlotAnalysis { } } - PS.debug(" - $1Waiting on plot rating thread: " + ((mi.intValue() * 100) / plots.size()) + "%"); + PS.debug(" - $1Waiting on plot rating thread: " + mi.intValue() * 100 / plots.size() + "%"); try { ratingAnalysis.join(); } catch (final InterruptedException e) { @@ -212,7 +212,7 @@ public class PlotAnalysis { final int[] variance_changes = square(sd_changes); final int sum_changes = sum(variance_changes); final double factor_changes = getCC(n, sum_changes); - PlotAnalysis.MODIFIERS.changes = factor_changes == 1 ? 0 : (int) ((factor_changes * 1000) / MathMan.getMean(changes)); + PlotAnalysis.MODIFIERS.changes = factor_changes == 1 ? 0 : (int) (factor_changes * 1000 / MathMan.getMean(changes)); PS.debug(" - | changes " + factor_changes); final int[] rank_faces = rank(faces); @@ -220,7 +220,7 @@ public class PlotAnalysis { final int[] variance_faces = square(sd_faces); final int sum_faces = sum(variance_faces); final double factor_faces = getCC(n, sum_faces); - PlotAnalysis.MODIFIERS.faces = factor_faces == 1 ? 0 : (int) ((factor_faces * 1000) / MathMan.getMean(faces)); + PlotAnalysis.MODIFIERS.faces = factor_faces == 1 ? 0 : (int) (factor_faces * 1000 / MathMan.getMean(faces)); PS.debug(" - | faces " + factor_faces); final int[] rank_data = rank(data); @@ -228,7 +228,7 @@ public class PlotAnalysis { final int[] variance_data = square(sd_data); final int sum_data = sum(variance_data); final double factor_data = getCC(n, sum_data); - PlotAnalysis.MODIFIERS.data = factor_data == 1 ? 0 : (int) ((factor_data * 1000) / MathMan.getMean(data)); + PlotAnalysis.MODIFIERS.data = factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data)); PS.debug(" - | data " + factor_data); final int[] rank_air = rank(air); @@ -236,7 +236,7 @@ public class PlotAnalysis { final int[] variance_air = square(sd_air); final int sum_air = sum(variance_air); final double factor_air = getCC(n, sum_air); - PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) ((factor_air * 1000) / MathMan.getMean(air)); + PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air)); PS.debug(" - | air " + factor_air); final int[] rank_variety = rank(variety); @@ -244,7 +244,7 @@ public class PlotAnalysis { final int[] variance_variety = square(sd_variety); final int sum_variety = sum(variance_variety); final double factor_variety = getCC(n, sum_variety); - PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) ((factor_variety * 1000) / MathMan.getMean(variety)); + PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) (factor_variety * 1000 / MathMan.getMean(variety)); PS.debug(" - | variety " + factor_variety); final int[] rank_changes_sd = rank(changes_sd); @@ -252,7 +252,7 @@ public class PlotAnalysis { final int[] variance_changes_sd = square(sd_changes_sd); final int sum_changes_sd = sum(variance_changes_sd); final double factor_changes_sd = getCC(n, sum_changes_sd); - PlotAnalysis.MODIFIERS.changes_sd = factor_changes_sd == 1 ? 0 : (int) ((factor_changes_sd * 1000) / MathMan.getMean(changes_sd)); + PlotAnalysis.MODIFIERS.changes_sd = factor_changes_sd == 1 ? 0 : (int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd)); PS.debug(" - | changes_sd " + factor_changes_sd); final int[] rank_faces_sd = rank(faces_sd); @@ -260,7 +260,7 @@ public class PlotAnalysis { final int[] variance_faces_sd = square(sd_faces_sd); final int sum_faces_sd = sum(variance_faces_sd); final double factor_faces_sd = getCC(n, sum_faces_sd); - PlotAnalysis.MODIFIERS.faces_sd = factor_faces_sd == 1 ? 0 : (int) ((factor_faces_sd * 1000) / MathMan.getMean(faces_sd)); + PlotAnalysis.MODIFIERS.faces_sd = factor_faces_sd == 1 ? 0 : (int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd)); PS.debug(" - | faces_sd " + factor_faces_sd); final int[] rank_data_sd = rank(data_sd); @@ -268,7 +268,7 @@ public class PlotAnalysis { final int[] variance_data_sd = square(sd_data_sd); final int sum_data_sd = sum(variance_data_sd); final double factor_data_sd = getCC(n, sum_data_sd); - PlotAnalysis.MODIFIERS.data_sd = factor_data_sd == 1 ? 0 : (int) ((factor_data_sd * 1000) / MathMan.getMean(data_sd)); + PlotAnalysis.MODIFIERS.data_sd = factor_data_sd == 1 ? 0 : (int) (factor_data_sd * 1000 / MathMan.getMean(data_sd)); PS.debug(" - | data_sd " + factor_data_sd); final int[] rank_air_sd = rank(air_sd); @@ -276,7 +276,7 @@ public class PlotAnalysis { final int[] variance_air_sd = square(sd_air_sd); final int sum_air_sd = sum(variance_air_sd); final double factor_air_sd = getCC(n, sum_air_sd); - PlotAnalysis.MODIFIERS.air_sd = factor_air_sd == 1 ? 0 : (int) ((factor_air_sd * 1000) / MathMan.getMean(air_sd)); + PlotAnalysis.MODIFIERS.air_sd = factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd)); PS.debug(" - | air_sd " + factor_air_sd); final int[] rank_variety_sd = rank(variety_sd); @@ -284,7 +284,7 @@ public class PlotAnalysis { final int[] variance_variety_sd = square(sd_variety_sd); final int sum_variety_sd = sum(variance_variety_sd); final double factor_variety_sd = getCC(n, sum_variety_sd); - PlotAnalysis.MODIFIERS.variety_sd = factor_variety_sd == 1 ? 0 : (int) ((factor_variety_sd * 1000) / MathMan.getMean(variety_sd)); + PlotAnalysis.MODIFIERS.variety_sd = factor_variety_sd == 1 ? 0 : (int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd)); PS.debug(" - | variety_sd " + factor_variety_sd); final int[] complexity = new int[n]; @@ -303,7 +303,7 @@ public class PlotAnalysis { } } int optimal_complexity = Integer.MAX_VALUE; - if ((min > 0) && (max < 102400)) { // If low size, use my fast ranking algorithm + if (min > 0 && max < 102400) { // If low size, use my fast ranking algorithm final int[] rank_complexity = rank(complexity, max + 1); for (int i = 0; i < n; i++) { if (rank_complexity[i] == optimal_index) { @@ -396,7 +396,7 @@ public class PlotAnalysis { * @return */ public static double getCC(final int n, final int sum) { - return 1 - ((6 * (double) sum) / (n * ((n * n) - 1))); + return 1 - 6 * (double) sum / (n * (n * n - 1)); } /** @@ -519,7 +519,7 @@ public class PlotAnalysis { for (final Integer i : input) { tmp = i / placement; bucket[tmp % SIZE].add(i); - if (maxLength && (tmp > 0)) { + if (maxLength && tmp > 0) { maxLength = false; } } @@ -542,16 +542,16 @@ public class PlotAnalysis { if (complexity != 0) { return complexity; } - complexity = ((changes) * MODIFIERS.changes) - + ((faces) * MODIFIERS.faces) - + ((data) * MODIFIERS.data) - + ((air) * MODIFIERS.air) - + ((variety) * MODIFIERS.variety) - + ((changes_sd) * MODIFIERS.changes_sd) - + ((faces_sd) * MODIFIERS.faces_sd) - + ((data_sd) * MODIFIERS.data_sd) - + ((air_sd) * MODIFIERS.air_sd) - + ((variety_sd) * MODIFIERS.variety_sd); + complexity = changes * MODIFIERS.changes + + faces * MODIFIERS.faces + + data * MODIFIERS.data + + air * MODIFIERS.air + + variety * MODIFIERS.variety + + changes_sd * MODIFIERS.changes_sd + + faces_sd * MODIFIERS.faces_sd + + data_sd * MODIFIERS.data_sd + + air_sd * MODIFIERS.air_sd + + variety_sd * MODIFIERS.variety_sd; return complexity; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java index 041536b79..dc1e116c5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java @@ -64,11 +64,12 @@ public class PlotCluster { } public boolean isAdded(final UUID uuid) { - return (owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone)); + return owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers + .contains(DBFunc.everyone); } public boolean hasHelperRights(final UUID uuid) { - return (owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone)); + return owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone); } public String getName() { @@ -80,7 +81,7 @@ public class PlotCluster { * @return */ public int getArea() { - return ((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y); + return (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); } public void setArea(PlotArea plotarea) { @@ -159,10 +160,10 @@ public class PlotCluster { } public boolean intersects(PlotId pos1, PlotId pos2) { - return (pos1.x <= this.pos2.x) && (pos2.x >= this.pos1.x) && (pos1.y <= this.pos2.y) && (pos2.y >= this.pos1.y); + return pos1.x <= this.pos2.x && pos2.x >= this.pos1.x && pos1.y <= this.pos2.y && pos2.y >= this.pos1.y; } public boolean contains(final PlotId id) { - return (pos1.x <= id.x) && (pos1.y <= id.y) && (pos2.x >= id.x) && (pos2.y >= id.y); + return pos1.x <= id.x && pos1.y <= id.y && pos2.x >= id.x && pos2.y >= id.y; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java b/Core/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java index 03ca8a4f2..5ec25e0bd 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java @@ -27,15 +27,15 @@ public class RegionWrapper { } public boolean isIn(final int x, final int y, final int z) { - return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ) && (y >= minY) && (y <= maxY)); + return x >= minX && x <= maxX && z >= minZ && z <= maxZ && y >= minY && y <= maxY; } public boolean isIn(final int x, final int z) { - return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ)); + return x >= minX && x <= maxX && z >= minZ && z <= maxZ; } public boolean intersects(RegionWrapper other) { - return (other.minX <= this.maxX) && (other.maxX >= this.minX) && (other.minY <= this.maxY) && (other.maxY >= this.minY); + return other.minX <= this.maxX && other.maxX >= this.minX && other.minY <= this.maxY && other.maxY >= this.minY; } @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/AbstractTitle.java b/Core/src/main/java/com/intellectualcrafters/plot/util/AbstractTitle.java index 93cc9e938..5e90c7184 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/AbstractTitle.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/AbstractTitle.java @@ -10,7 +10,7 @@ public abstract class AbstractTitle { if (ConsolePlayer.isConsole(player)) { return; } - if ((TITLE_CLASS != null) && !player.getAttribute("disabletitles")) { + if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) { TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java index 6ce0a9a9d..1808ff035 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java @@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -72,7 +73,7 @@ public class BO3Handler { throw new IllegalArgumentException("Save task cannot be null!"); } final PlotArea plotworld = plot.getArea(); - if (!(plotworld instanceof ClassicPlotWorld) || (plotworld.TYPE != 0)) { + if (!(plotworld instanceof ClassicPlotWorld) || plotworld.TYPE != 0) { MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation."); return false; } @@ -106,10 +107,10 @@ public class BO3Handler { Location pos1 = new Location(plotworld.worldname, region.minX, region.minY, region.minZ); Location pos2 = new Location(plotworld.worldname, region.maxX, region.maxY, region.maxZ); for (int x = pos1.getX(); x <= pos2.getX(); x++) { - final int X = ((x + 7) - cx) >> 4; + final int X = x + 7 - cx >> 4; final int xx = (x - cx) % 16; for (int z = pos1.getZ(); z <= pos2.getZ(); z++) { - final int Z = ((z + 7) - cz) >> 4; + final int Z = z + 7 - cz >> 4; final int zz = (z - cz) % 16; final ChunkLoc loc = new ChunkLoc(X, Z); BO3 bo3 = map.get(loc); @@ -156,7 +157,7 @@ public class BO3Handler { for (final Entry entry : map.entrySet()) { final ChunkLoc chunk = entry.getKey(); final BO3 bo3 = entry.getValue(); - if ((chunk.x == 0) && (chunk.z == 0)) { + if (chunk.x == 0 && chunk.z == 0) { continue; } int x = chunk.x; @@ -171,7 +172,7 @@ public class BO3Handler { parentLoc = null; for (final Entry entry2 : map.entrySet()) { final ChunkLoc other = entry2.getKey(); - if (((other.x == (chunk.x - 1)) && (other.z == chunk.z)) || ((other.z == (chunk.z - 1)) && (other.x == chunk.x))) { + if (other.x == chunk.x - 1 && other.z == chunk.z || other.z == chunk.z - 1 && other.x == chunk.x) { parentLoc = other; } } @@ -268,7 +269,7 @@ public class BO3Handler { } } File bo3File; - if ((bo3.getLoc().x == 0) && (bo3.getLoc().z == 0)) { + if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) { bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3"); } else { bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3"); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 12e36ead1..fe1357820 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -140,7 +140,7 @@ public class SpongeMain implements IPlotMain { if (!Settings.CONSOLE_COLOR) { message = message.replaceAll('\u00a7' + "[a-z|0-9]", ""); } - if ((server == null) || (server.getConsole() == null)) { + if (server == null || server.getConsole() == null) { logger.info(message); return; } @@ -168,7 +168,7 @@ public class SpongeMain implements IPlotMain { PluginContainer plugin = game.getPluginManager().fromInstance(this).get(); String version = plugin.getVersion().get(); final String[] split = version.split("\\."); - return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 }; + return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0}; } @Override @@ -176,7 +176,7 @@ public class SpongeMain implements IPlotMain { log("Checking minecraft version: Sponge: "); final String version = game.getPlatform().getMinecraftVersion().getName(); final String[] split = version.split("\\."); - return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 }; + return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0}; } @Override @@ -337,12 +337,8 @@ public class SpongeMain implements IPlotMain { GenerationPopulator gen = wg.getBaseGenerationPopulator(); if (gen instanceof SpongePlotGenerator) { PS.get().loadWorld(worldname, (SpongePlotGenerator) gen); - } else if (gen != null) { - throw new UnsupportedOperationException("NOT IMPLEMENTED YET!"); } else { - if (PS.get().config.contains("worlds." + worldname)) { - PS.get().loadWorld(worldname, null); - } + throw new UnsupportedOperationException("NOT IMPLEMENTED YET!"); } }