From 0d382ac9c3fcde8497a9820a0e46452db2bdf9dc Mon Sep 17 00:00:00 2001
From: boy0001
Date: Fri, 20 Feb 2015 17:34:19 +1100
Subject: [PATCH] cleanup
---
.../jnbt/ByteArrayTag.java | 10 +-
.../intellectualcrafters/jnbt/ByteTag.java | 10 +-
.../jnbt/CompoundTag.java | 66 +-
.../jnbt/CompoundTagBuilder.java | 34 +-
.../intellectualcrafters/jnbt/DoubleTag.java | 10 +-
.../com/intellectualcrafters/jnbt/EndTag.java | 6 +-
.../intellectualcrafters/jnbt/FloatTag.java | 10 +-
.../jnbt/IntArrayTag.java | 10 +-
.../com/intellectualcrafters/jnbt/IntTag.java | 10 +-
.../intellectualcrafters/jnbt/ListTag.java | 66 +-
.../jnbt/ListTagBuilder.java | 19 +-
.../intellectualcrafters/jnbt/LongTag.java | 10 +-
.../jnbt/NBTConstants.java | 9 +-
.../jnbt/NBTInputStream.java | 17 +-
.../jnbt/NBTOutputStream.java | 39 +-
.../intellectualcrafters/jnbt/NBTUtils.java | 10 +-
.../intellectualcrafters/jnbt/ShortTag.java | 11 +-
.../intellectualcrafters/jnbt/StringTag.java | 10 +-
.../com/intellectualcrafters/jnbt/Tag.java | 11 +-
.../jnbt/WorldEditUtils.java | 3 -
.../com/intellectualcrafters/json/CDL.java | 27 +-
.../com/intellectualcrafters/json/Cookie.java | 9 +-
.../intellectualcrafters/json/CookieList.java | 3 +-
.../com/intellectualcrafters/json/HTTP.java | 14 +-
.../json/HTTPTokener.java | 7 +-
.../intellectualcrafters/json/JSONArray.java | 107 +--
.../json/JSONException.java | 6 +-
.../com/intellectualcrafters/json/JSONML.java | 44 +-
.../intellectualcrafters/json/JSONObject.java | 166 ++--
.../json/JSONStringer.java | 2 +-
.../json/JSONTokener.java | 52 +-
.../intellectualcrafters/json/JSONWriter.java | 29 +-
.../com/intellectualcrafters/json/Kim.java | 29 +-
.../intellectualcrafters/json/Property.java | 3 +-
.../com/intellectualcrafters/json/XML.java | 62 +-
.../intellectualcrafters/json/XMLTokener.java | 48 +-
.../intellectualcrafters/plot/BukkitMain.java | 95 +-
.../intellectualcrafters/plot/IPlotMain.java | 2 +-
.../plot/PlotSquared.java | 238 ++---
.../plot/commands/Auto.java | 79 +-
.../plot/commands/Ban.java | 3 +-
.../plot/commands/Buy.java | 28 +-
.../plot/commands/Claim.java | 19 +-
.../plot/commands/Clear.java | 8 +-
.../plot/commands/Clipboard.java | 9 +-
.../plot/commands/Cluster.java | 166 ++--
.../plot/commands/Command.java | 21 +-
.../plot/commands/CommandPermission.java | 6 +-
.../plot/commands/Comment.java | 7 +-
.../plot/commands/Condense.java | 60 +-
.../plot/commands/Copy.java | 4 +-
.../plot/commands/CreateRoadSchematic.java | 12 +-
.../plot/commands/DEOP.java | 3 +-
.../plot/commands/Database.java | 15 +-
.../plot/commands/Debug.java | 8 +-
.../plot/commands/DebugClaimTest.java | 26 +-
.../plot/commands/DebugClear.java | 20 +-
.../plot/commands/DebugExec.java | 193 ++--
.../plot/commands/DebugFixFlags.java | 21 +-
.../plot/commands/DebugLoadTest.java | 4 +-
.../plot/commands/DebugRoadRegen.java | 15 +-
.../plot/commands/DebugSaveTest.java | 4 +-
.../plot/commands/Delete.java | 4 +-
.../plot/commands/Denied.java | 8 +-
.../plot/commands/FlagCmd.java | 54 +-
.../plot/commands/Help.java | 3 +-
.../plot/commands/Helpers.java | 4 +-
.../plot/commands/Home.java | 13 +-
.../plot/commands/Inbox.java | 66 +-
.../plot/commands/Info.java | 32 +-
.../plot/commands/Inventory.java | 6 +-
.../plot/commands/Kick.java | 7 +-
.../plot/commands/MainCommand.java | 42 +-
.../plot/commands/Merge.java | 36 +-
.../plot/commands/Move.java | 15 +-
.../plot/commands/MusicSubcommand.java | 3 +-
.../plot/commands/OP.java | 3 +-
.../plot/commands/Paste.java | 5 +-
.../plot/commands/Purge.java | 71 +-
.../plot/commands/Rate.java | 9 +-
.../plot/commands/RegenAllRoads.java | 32 +-
.../plot/commands/Reload.java | 5 +-
.../plot/commands/Schematic.java | 25 +-
.../plot/commands/Set.java | 82 +-
.../plot/commands/SetOwner.java | 18 +-
.../plot/commands/Setup.java | 123 +--
.../plot/commands/SubCommand.java | 24 +-
.../plot/commands/Swap.java | 6 +-
.../plot/commands/TP.java | 10 +-
.../plot/commands/Target.java | 8 +-
.../plot/commands/Template.java | 21 +-
.../plot/commands/Trim.java | 164 ++--
.../plot/commands/Trusted.java | 8 +-
.../plot/commands/Unban.java | 3 +-
.../plot/commands/Unclaim.java | 8 +-
.../plot/commands/Unlink.java | 27 +-
.../plot/commands/Visit.java | 5 +-
.../plot/commands/WE_Anywhere.java | 8 +-
.../plot/commands/list.java | 30 +-
.../plot/commands/plugin.java | 13 +-
.../intellectualcrafters/plot/config/C.java | 28 +-
.../plot/config/Configuration.java | 51 +-
.../plot/config/ConfigurationNode.java | 27 +-
.../plot/config/Settings.java | 31 +-
.../plot/database/AbstractDB.java | 69 +-
.../plot/database/DBFunc.java | 76 +-
.../plot/database/Database.java | 16 +-
.../plot/database/MySQL.java | 24 +-
.../plot/database/PlotMeConverter.java | 54 +-
.../plot/database/SQLManager.java | 597 ++++++------
.../plot/database/SQLite.java | 20 +-
.../plot/events/PlayerClaimPlotEvent.java | 18 +-
.../plot/events/PlayerEnterPlotEvent.java | 12 +-
.../plot/events/PlayerLeavePlotEvent.java | 10 +-
.../plot/events/PlayerPlotDeniedEvent.java | 16 +-
.../plot/events/PlayerPlotHelperEvent.java | 16 +-
.../plot/events/PlayerPlotTrustedEvent.java | 16 +-
.../events/PlayerTeleportToPlotEvent.java | 17 +-
.../plot/events/PlotClearEvent.java | 15 +-
.../plot/events/PlotDeleteEvent.java | 15 +-
.../plot/events/PlotFlagAddEvent.java | 15 +-
.../plot/events/PlotFlagRemoveEvent.java | 15 +-
.../plot/events/PlotMergeEvent.java | 17 +-
.../plot/events/PlotUnlinkEvent.java | 15 +-
.../plot/flag/AbstractFlag.java | 17 +-
.../intellectualcrafters/plot/flag/Flag.java | 27 +-
.../plot/flag/FlagManager.java | 113 ++-
.../plot/flag/FlagValue.java | 321 +++----
.../plot/generator/AugmentedPopulator.java | 267 +++---
.../plot/generator/ClassicPlotManager.java | 118 +--
.../plot/generator/ClassicPlotWorld.java | 6 +-
.../plot/generator/GridPlotManager.java | 1 -
.../plot/generator/GridPlotWorld.java | 3 +-
.../plot/generator/HybridGen.java | 131 +--
.../plot/generator/HybridPlotManager.java | 368 +++----
.../plot/generator/HybridPlotWorld.java | 125 +--
.../plot/generator/HybridPop.java | 117 +--
.../plot/generator/SquarePlotManager.java | 25 +-
.../plot/generator/SquarePlotWorld.java | 4 +-
.../plot/listeners/ForceFieldListener.java | 8 +-
.../plot/listeners/InventoryListener.java | 7 +-
.../plot/listeners/PlayerEvents.java | 374 ++++----
.../plot/listeners/PlayerEvents_1_8.java | 8 +-
.../plot/listeners/PlotListener.java | 76 +-
.../plot/listeners/PlotPlusListener.java | 44 +-
.../plot/listeners/WorldEditListener.java | 24 +-
.../plot/listeners/WorldGuardListener.java | 60 +-
.../plot/object/BlockLoc.java | 10 +-
.../plot/object/BlockWrapper.java | 16 +-
.../plot/object/ChunkLoc.java | 9 +-
.../plot/object/InfoInventory.java | 15 +-
.../plot/object/Location.java | 137 ++-
.../plot/object/Plot.java | 42 +-
.../plot/object/PlotBlock.java | 11 +-
.../plot/object/PlotCluster.java | 116 ++-
.../plot/object/PlotClusterId.java | 15 +-
.../plot/object/PlotComment.java | 3 +-
.../plot/object/PlotGenerator.java | 6 +-
.../plot/object/PlotId.java | 12 +-
.../plot/object/PlotLoc.java | 6 +-
.../plot/object/PlotManager.java | 38 +-
.../plot/object/PlotSettings.java | 50 +-
.../plot/object/PlotWorld.java | 43 +-
.../plot/object/RegionWrapper.java | 3 +-
.../plot/object/StringWrapper.java | 12 +-
.../plot/object/entity/AgeableStats.java | 2 -
.../plot/object/entity/EntityWrapper.java | 78 +-
.../plot/object/entity/HorseStats.java | 1 -
.../plot/object/entity/LivingEntityStats.java | 4 -
.../plot/object/entity/TameableStats.java | 2 -
.../plot/titles/AbstractTitle.java | 6 +-
.../plot/titles/DefaultTitle.java | 25 +-
.../plot/titles/DefaultTitleManager.java | 773 ++++++++-------
.../plot/titles/HackTitle.java | 27 +-
.../plot/titles/HackTitleManager.java | 907 +++++++++---------
.../plot/util/AChunkManager.java | 7 +-
.../plot/util/BlockManager.java | 29 +-
.../plot/util/ClusterManager.java | 470 +++++----
.../plot/util/ConsoleColors.java | 19 +-
.../plot/util/EconHandler.java | 1 -
.../plot/util/ExpireManager.java | 109 +--
.../plot/util/LSetCube.java | 23 +-
.../intellectualcrafters/plot/util/Lag.java | 14 +-
.../plot/util/Logger.java | 16 +-
.../plot/util/PlotHelper.java | 334 +++----
.../plot/util/PlotSquaredException.java | 10 +-
.../plot/util/RUtils.java | 25 +-
.../plot/util/ReflectionUtils.java | 112 ++-
.../plot/util/SchematicHandler.java | 122 +--
.../plot/util/StringComparison.java | 24 +-
.../plot/util/TaskManager.java | 24 +-
.../plot/util/bukkit/BukkitTaskManager.java | 13 +-
.../plot/util/bukkit/BukkitUtil.java | 81 +-
.../plot/util/bukkit/ChunkManager.java | 488 +++++-----
.../plot/util/bukkit/Metrics.java | 66 +-
.../plot/util/bukkit/PWE.java | 24 +-
.../plot/util/bukkit/PlayerFunctions.java | 73 +-
.../plot/util/bukkit/SendChunk.java | 23 +-
.../plot/util/bukkit/SetBlockFast.java | 16 +-
.../plot/util/bukkit/SetBlockFast_1_8.java | 26 +-
.../plot/util/bukkit/SetBlockSlow.java | 11 +-
.../plot/util/bukkit/UUIDHandler.java | 91 +-
.../plot/uuid/DefaultUUIDWrapper.java | 12 +-
.../plot/uuid/OfflineUUIDWrapper.java | 38 +-
.../plot/uuid/UUIDWrapper.java | 6 +-
.../translation/Translation.java | 6 +-
.../translation/TranslationAsset.java | 9 +-
.../translation/TranslationFile.java | 8 +-
.../translation/TranslationLanguage.java | 15 +-
.../translation/TranslationManager.java | 41 +-
.../translation/TranslationObject.java | 13 +-
.../translation/YamlTranslationFile.java | 19 +-
.../translation/bukkit/BukkitTranslation.java | 7 +-
.../translation/bukkit/TranslationPlugin.java | 9 +-
PlotSquared/src/main/resources/LICENSE | 121 ---
215 files changed, 4930 insertions(+), 6474 deletions(-)
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java
index 32cdf131b..a73ecb9ba 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java
@@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt;
* The {@code TAG_Byte_Array} tag.
*/
public final class ByteArrayTag extends Tag {
-
private final byte[] value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -16,7 +15,7 @@ public final class ByteArrayTag extends Tag {
super();
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -27,12 +26,12 @@ public final class ByteArrayTag extends Tag {
super(name);
this.value = value;
}
-
+
@Override
public byte[] getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final StringBuilder hex = new StringBuilder();
@@ -50,5 +49,4 @@ public final class ByteArrayTag extends Tag {
}
return "TAG_Byte_Array" + append + ": " + hex;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java
index 8e2ad5638..388ed82e2 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java
@@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt;
* The {@code TAG_Byte} tag.
*/
public final class ByteTag extends Tag {
-
private final byte value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -16,7 +15,7 @@ public final class ByteTag extends Tag {
super();
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -27,12 +26,12 @@ public final class ByteTag extends Tag {
super(name);
this.value = value;
}
-
+
@Override
public Byte getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -42,5 +41,4 @@ public final class ByteTag extends Tag {
}
return "TAG_Byte" + append + ": " + this.value;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java
index a8d0b052b..10c11b32c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java
@@ -9,9 +9,8 @@ import java.util.Map;
* The {@code TAG_Compound} tag.
*/
public final class CompoundTag extends Tag {
-
private final Map value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -21,7 +20,7 @@ public final class CompoundTag extends Tag {
super();
this.value = Collections.unmodifiableMap(value);
}
-
+
/**
* Creates the tag.
*
@@ -32,7 +31,7 @@ public final class CompoundTag extends Tag {
super(name);
this.value = Collections.unmodifiableMap(value);
}
-
+
/**
* Returns whether this compound tag contains the given key.
*
@@ -43,12 +42,12 @@ public final class CompoundTag extends Tag {
public boolean containsKey(final String key) {
return this.value.containsKey(key);
}
-
+
@Override
public Map getValue() {
return this.value;
}
-
+
/**
* Return a new compound tag with the given values.
*
@@ -59,7 +58,7 @@ public final class CompoundTag extends Tag {
public CompoundTag setValue(final Map value) {
return new CompoundTag(getName(), value);
}
-
+
/**
* Create a compound tag builder.
*
@@ -68,7 +67,7 @@ public final class CompoundTag extends Tag {
public CompoundTagBuilder createBuilder() {
return new CompoundTagBuilder(new HashMap(this.value));
}
-
+
/**
* Get a byte array named with the given key.
If the key does not exist or its value is not a byte array
* tag, then an empty byte array will be returned.
@@ -85,7 +84,7 @@ public final class CompoundTag extends Tag {
return new byte[0];
}
}
-
+
/**
* Get a byte named with the given key.
If the key does not exist or its value is not a byte tag, then
* {@code 0} will be returned.
@@ -102,7 +101,7 @@ public final class CompoundTag extends Tag {
return (byte) 0;
}
}
-
+
/**
* Get a double named with the given key.
If the key does not exist or its value is not a double tag, then
* {@code 0} will be returned.
@@ -119,7 +118,7 @@ public final class CompoundTag extends Tag {
return 0;
}
}
-
+
/**
* Get a double named with the given key, even if it's another type of number.
If the key does not exist or
* its value is not a number, then {@code 0} will be returned.
@@ -132,27 +131,21 @@ public final class CompoundTag extends Tag {
final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
-
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
-
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
-
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
-
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
-
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
-
} else {
return 0;
}
}
-
+
/**
* Get a float named with the given key.
If the key does not exist or its value is not a float tag, then
* {@code 0} will be returned.
@@ -169,7 +162,7 @@ public final class CompoundTag extends Tag {
return 0;
}
}
-
+
/**
* Get a {@code int[]} named with the given key.
If the key does not exist or its value is not an int array
* tag, then an empty array will be returned.
@@ -186,7 +179,7 @@ public final class CompoundTag extends Tag {
return new int[0];
}
}
-
+
/**
* Get an int named with the given key.
If the key does not exist or its value is not an int tag, then
* {@code 0} will be returned.
@@ -203,7 +196,7 @@ public final class CompoundTag extends Tag {
return 0;
}
}
-
+
/**
* Get an int named with the given key, even if it's another type of number.
If the key does not exist or
* its value is not a number, then {@code 0} will be returned.
@@ -216,27 +209,21 @@ public final class CompoundTag extends Tag {
final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
-
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
-
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
-
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
-
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
-
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
-
} else {
return 0;
}
}
-
+
/**
* Get a list of tags named with the given key.
If the key does not exist or its value is not a list tag,
* then an empty list will be returned.
@@ -253,7 +240,7 @@ public final class CompoundTag extends Tag {
return Collections.emptyList();
}
}
-
+
/**
* Get a {@code TagList} named with the given key.
If the key does not exist or its value is not a list
* tag, then an empty tag list will be returned.
@@ -267,10 +254,10 @@ public final class CompoundTag extends Tag {
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
- return new ListTag(key, StringTag.class, Collections.emptyList());
+ return new ListTag(key, StringTag.class, Collections. emptyList());
}
}
-
+
/**
* Get a list of tags named with the given key.
If the key does not exist or its value is not a list tag,
* then an empty list will be returned. If the given key references a list but the list of of a different type, then
@@ -296,7 +283,7 @@ public final class CompoundTag extends Tag {
return Collections.emptyList();
}
}
-
+
/**
* Get a long named with the given key.
If the key does not exist or its value is not a long tag, then
* {@code 0} will be returned.
@@ -313,7 +300,7 @@ public final class CompoundTag extends Tag {
return 0L;
}
}
-
+
/**
* Get a long named with the given key, even if it's another type of number.
If the key does not exist or
* its value is not a number, then {@code 0} will be returned.
@@ -326,27 +313,21 @@ public final class CompoundTag extends Tag {
final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
-
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
-
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
-
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
-
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
-
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
-
} else {
return 0L;
}
}
-
+
/**
* Get a short named with the given key.
If the key does not exist or its value is not a short tag, then
* {@code 0} will be returned.
@@ -363,7 +344,7 @@ public final class CompoundTag extends Tag {
return 0;
}
}
-
+
/**
* Get a string named with the given key.
If the key does not exist or its value is not a string tag, then
* {@code ""} will be returned.
@@ -380,7 +361,7 @@ public final class CompoundTag extends Tag {
return "";
}
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -396,5 +377,4 @@ public final class CompoundTag extends Tag {
bldr.append("}");
return bldr.toString();
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java
index 365b7322a..86e04e2fd 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java
@@ -9,16 +9,15 @@ import java.util.Map;
* Helps create compound tags.
*/
public class CompoundTagBuilder {
-
private final Map entries;
-
+
/**
* Create a new instance.
*/
CompoundTagBuilder() {
this.entries = new HashMap();
}
-
+
/**
* Create a new instance and use the given map (which will be modified).
*
@@ -28,7 +27,7 @@ public class CompoundTagBuilder {
checkNotNull(value);
this.entries = value;
}
-
+
/**
* Create a new builder instance.
*
@@ -37,7 +36,7 @@ public class CompoundTagBuilder {
public static CompoundTagBuilder create() {
return new CompoundTagBuilder();
}
-
+
/**
* Put the given key and tag into the compound tag.
*
@@ -52,7 +51,7 @@ public class CompoundTagBuilder {
this.entries.put(key, value);
return this;
}
-
+
/**
* Put the given key and value into the compound tag as a {@code ByteArrayTag}.
*
@@ -64,7 +63,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putByteArray(final String key, final byte[] value) {
return put(key, new ByteArrayTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as a {@code ByteTag}.
*
@@ -76,7 +75,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putByte(final String key, final byte value) {
return put(key, new ByteTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as a {@code DoubleTag}.
*
@@ -88,7 +87,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putDouble(final String key, final double value) {
return put(key, new DoubleTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as a {@code FloatTag}.
*
@@ -100,7 +99,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putFloat(final String key, final float value) {
return put(key, new FloatTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as a {@code IntArrayTag}.
*
@@ -112,7 +111,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putIntArray(final String key, final int[] value) {
return put(key, new IntArrayTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as an {@code IntTag}.
*
@@ -124,7 +123,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putInt(final String key, final int value) {
return put(key, new IntTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as a {@code LongTag}.
*
@@ -136,7 +135,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putLong(final String key, final long value) {
return put(key, new LongTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as a {@code ShortTag}.
*
@@ -148,7 +147,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putShort(final String key, final short value) {
return put(key, new ShortTag(key, value));
}
-
+
/**
* Put the given key and value into the compound tag as a {@code StringTag}.
*
@@ -160,7 +159,7 @@ public class CompoundTagBuilder {
public CompoundTagBuilder putString(final String key, final String value) {
return put(key, new StringTag(key, value));
}
-
+
/**
* Put all the entries from the given map into this map.
*
@@ -175,7 +174,7 @@ public class CompoundTagBuilder {
}
return this;
}
-
+
/**
* Build an unnamed compound tag with this builder's entries.
*
@@ -184,7 +183,7 @@ public class CompoundTagBuilder {
public CompoundTag build() {
return new CompoundTag(new HashMap(this.entries));
}
-
+
/**
* Build a new compound tag with this builder's entries.
*
@@ -195,5 +194,4 @@ public class CompoundTagBuilder {
public CompoundTag build(final String name) {
return new CompoundTag(name, new HashMap(this.entries));
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java
index 2a4c52448..d85fd6135 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java
@@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt;
* The {@code TAG_Double} tag.
*/
public final class DoubleTag extends Tag {
-
private final double value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -16,7 +15,7 @@ public final class DoubleTag extends Tag {
super();
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -27,12 +26,12 @@ public final class DoubleTag extends Tag {
super(name);
this.value = value;
}
-
+
@Override
public Double getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -42,5 +41,4 @@ public final class DoubleTag extends Tag {
}
return "TAG_Double" + append + ": " + this.value;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java
index 408206b1b..981925184 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java
@@ -4,22 +4,20 @@ package com.intellectualcrafters.jnbt;
* The {@code TAG_End} tag.
*/
public final class EndTag extends Tag {
-
/**
* Creates the tag.
*/
public EndTag() {
super();
}
-
+
@Override
public Object getValue() {
return null;
}
-
+
@Override
public String toString() {
return "TAG_End";
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java
index a9701340a..2dea1766f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java
@@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt;
* The {@code TAG_Float} tag.
*/
public final class FloatTag extends Tag {
-
private final float value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -16,7 +15,7 @@ public final class FloatTag extends Tag {
super();
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -27,12 +26,12 @@ public final class FloatTag extends Tag {
super(name);
this.value = value;
}
-
+
@Override
public Float getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -42,5 +41,4 @@ public final class FloatTag extends Tag {
}
return "TAG_Float" + append + ": " + this.value;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java
index 9439f051b..c4349f89e 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java
@@ -6,9 +6,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
* The {@code TAG_Int_Array} tag.
*/
public final class IntArrayTag extends Tag {
-
private final int[] value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -19,7 +18,7 @@ public final class IntArrayTag extends Tag {
checkNotNull(value);
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -31,12 +30,12 @@ public final class IntArrayTag extends Tag {
checkNotNull(value);
this.value = value;
}
-
+
@Override
public int[] getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final StringBuilder hex = new StringBuilder();
@@ -54,5 +53,4 @@ public final class IntArrayTag extends Tag {
}
return "TAG_Int_Array" + append + ": " + hex;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java
index 7e5328f37..bee6eb7d7 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java
@@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt;
* The {@code TAG_Int} tag.
*/
public final class IntTag extends Tag {
-
private final int value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -16,7 +15,7 @@ public final class IntTag extends Tag {
super();
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -27,12 +26,12 @@ public final class IntTag extends Tag {
super(name);
this.value = value;
}
-
+
@Override
public Integer getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -42,5 +41,4 @@ public final class IntTag extends Tag {
}
return "TAG_Int" + append + ": " + this.value;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java
index 434f1a95a..415721c30 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java
@@ -12,10 +12,9 @@ import javax.annotation.Nullable;
* The {@code TAG_List} tag.
*/
public final class ListTag extends Tag {
-
private final Class extends Tag> type;
private final List value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -28,7 +27,7 @@ public final class ListTag extends Tag {
this.type = type;
this.value = Collections.unmodifiableList(value);
}
-
+
/**
* Creates the tag.
*
@@ -42,7 +41,7 @@ public final class ListTag extends Tag {
this.type = type;
this.value = Collections.unmodifiableList(value);
}
-
+
/**
* Gets the type of item in this list.
*
@@ -51,12 +50,12 @@ public final class ListTag extends Tag {
public Class extends Tag> getType() {
return this.type;
}
-
+
@Override
public List getValue() {
return this.value;
}
-
+
/**
* Create a new list tag with this tag's name and type.
*
@@ -67,7 +66,7 @@ public final class ListTag extends Tag {
public ListTag setValue(final List list) {
return new ListTag(getName(), getType(), list);
}
-
+
/**
* Get the tag if it exists at the given index.
*
@@ -83,7 +82,7 @@ public final class ListTag extends Tag {
return null;
}
}
-
+
/**
* Get a byte array named with the given index.
If the index does not exist or its value is not a byte
* array tag, then an empty byte array will be returned.
@@ -100,7 +99,7 @@ public final class ListTag extends Tag {
return new byte[0];
}
}
-
+
/**
* Get a byte named with the given index.
If the index does not exist or its value is not a byte tag, then
* {@code 0} will be returned.
@@ -117,7 +116,7 @@ public final class ListTag extends Tag {
return (byte) 0;
}
}
-
+
/**
* Get a double named with the given index.
If the index does not exist or its value is not a double tag,
* then {@code 0} will be returned.
@@ -134,7 +133,7 @@ public final class ListTag extends Tag {
return 0;
}
}
-
+
/**
* Get a double named with the given index, even if it's another type of number.
If the index does not
* exist or its value is not a number, then {@code 0} will be returned.
@@ -147,27 +146,21 @@ public final class ListTag extends Tag {
final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
-
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
-
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
-
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
-
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
-
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
-
} else {
return 0;
}
}
-
+
/**
* Get a float named with the given index.
If the index does not exist or its value is not a float tag,
* then {@code 0} will be returned.
@@ -184,7 +177,7 @@ public final class ListTag extends Tag {
return 0;
}
}
-
+
/**
* Get a {@code int[]} named with the given index.
If the index does not exist or its value is not an int
* array tag, then an empty array will be returned.
@@ -201,7 +194,7 @@ public final class ListTag extends Tag {
return new int[0];
}
}
-
+
/**
* Get an int named with the given index.
If the index does not exist or its value is not an int tag, then
* {@code 0} will be returned.
@@ -218,7 +211,7 @@ public final class ListTag extends Tag {
return 0;
}
}
-
+
/**
* Get an int named with the given index, even if it's another type of number.
If the index does not exist
* or its value is not a number, then {@code 0} will be returned.
@@ -231,27 +224,21 @@ public final class ListTag extends Tag {
final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
-
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
-
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
-
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
-
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
-
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
-
} else {
return 0;
}
}
-
+
/**
* Get a list of tags named with the given index.
If the index does not exist or its value is not a list
* tag, then an empty list will be returned.
@@ -268,7 +255,7 @@ public final class ListTag extends Tag {
return Collections.emptyList();
}
}
-
+
/**
* Get a {@code TagList} named with the given index.
If the index does not exist or its value is not a list
* tag, then an empty tag list will be returned.
@@ -282,10 +269,10 @@ public final class ListTag extends Tag {
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
- return new ListTag(StringTag.class, Collections.emptyList());
+ return new ListTag(StringTag.class, Collections. emptyList());
}
}
-
+
/**
* Get a list of tags named with the given index.
If the index does not exist or its value is not a list
* tag, then an empty list will be returned. If the given index references a list but the list of of a different
@@ -311,7 +298,7 @@ public final class ListTag extends Tag {
return Collections.emptyList();
}
}
-
+
/**
* Get a long named with the given index.
If the index does not exist or its value is not a long tag, then
* {@code 0} will be returned.
@@ -328,7 +315,7 @@ public final class ListTag extends Tag {
return 0L;
}
}
-
+
/**
* Get a long named with the given index, even if it's another type of number.
If the index does not exist
* or its value is not a number, then {@code 0} will be returned.
@@ -341,27 +328,21 @@ public final class ListTag extends Tag {
final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
-
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
-
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
-
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
-
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
-
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
-
} else {
return 0;
}
}
-
+
/**
* Get a short named with the given index.
If the index does not exist or its value is not a short tag,
* then {@code 0} will be returned.
@@ -378,7 +359,7 @@ public final class ListTag extends Tag {
return 0;
}
}
-
+
/**
* Get a string named with the given index.
If the index does not exist or its value is not a string tag,
* then {@code ""} will be returned.
@@ -395,7 +376,7 @@ public final class ListTag extends Tag {
return "";
}
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -411,5 +392,4 @@ public final class ListTag extends Tag {
bldr.append("}");
return bldr.toString();
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java
index 42992d2e6..a050599c5 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java
@@ -11,10 +11,9 @@ import java.util.List;
* Helps create list tags.
*/
public class ListTagBuilder {
-
private final Class extends Tag> type;
private final List entries;
-
+
/**
* Create a new instance.
*
@@ -25,7 +24,7 @@ public class ListTagBuilder {
this.type = type;
this.entries = new ArrayList();
}
-
+
/**
* Create a new builder instance.
*
@@ -34,7 +33,7 @@ public class ListTagBuilder {
public static ListTagBuilder create(final Class extends Tag> type) {
return new ListTagBuilder(type);
}
-
+
/**
* Create a new builder instance.
*
@@ -43,23 +42,20 @@ public class ListTagBuilder {
@SafeVarargs
public static ListTagBuilder createWith(final T... entries) {
checkNotNull(entries);
-
if (entries.length == 0) {
throw new IllegalArgumentException("This method needs an array of at least one entry");
}
-
final Class extends Tag> type = entries[0].getClass();
for (int i = 1; i < entries.length; i++) {
if (!type.isInstance(entries[i])) {
throw new IllegalArgumentException("An array of different tag types was provided");
}
}
-
final ListTagBuilder builder = new ListTagBuilder(type);
builder.addAll(Arrays.asList(entries));
return builder;
}
-
+
/**
* Add the given tag.
*
@@ -75,7 +71,7 @@ public class ListTagBuilder {
this.entries.add(value);
return this;
}
-
+
/**
* Add all the tags in the given list.
*
@@ -90,7 +86,7 @@ public class ListTagBuilder {
}
return this;
}
-
+
/**
* Build an unnamed list tag with this builder's entries.
*
@@ -99,7 +95,7 @@ public class ListTagBuilder {
public ListTag build() {
return new ListTag(this.type, new ArrayList(this.entries));
}
-
+
/**
* Build a new list tag with this builder's entries.
*
@@ -110,5 +106,4 @@ public class ListTagBuilder {
public ListTag build(final String name) {
return new ListTag(name, this.type, new ArrayList(this.entries));
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java
index a8d22218c..974a4d199 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java
@@ -4,9 +4,8 @@ package com.intellectualcrafters.jnbt;
* The {@code TAG_Long} tag.
*/
public final class LongTag extends Tag {
-
private final long value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -16,7 +15,7 @@ public final class LongTag extends Tag {
super();
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -27,12 +26,12 @@ public final class LongTag extends Tag {
super(name);
this.value = value;
}
-
+
@Override
public Long getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -42,5 +41,4 @@ public final class LongTag extends Tag {
}
return "TAG_Long" + append + ": " + this.value;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java
index 65a13f4ec..604859fff 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.jnbt;
import java.nio.charset.Charset;
@@ -27,18 +26,15 @@ import java.nio.charset.Charset;
* A class which holds constant values.
*/
public final class NBTConstants {
-
public static final Charset CHARSET = Charset.forName("UTF-8");
-
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
-
+
/**
* Default private constructor.
*/
private NBTConstants() {
-
}
-
+
/**
* Convert a type ID to its corresponding {@link Tag} class.
*
@@ -78,5 +74,4 @@ public final class NBTConstants {
throw new IllegalArgumentException("Unknown tag type ID of " + id);
}
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java
index 7aa319759..2c9a6610d 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java
@@ -15,9 +15,8 @@ import java.util.Map;
* may be found at http://www.minecraft.net/docs/NBT.txt .
*/
public final class NBTInputStream implements Closeable {
-
private final DataInputStream is;
-
+
/**
* Creates a new {@code NBTInputStream}, which will source its data from the specified input stream.
*
@@ -28,7 +27,7 @@ public final class NBTInputStream implements Closeable {
public NBTInputStream(final InputStream is) throws IOException {
this.is = new DataInputStream(is);
}
-
+
/**
* Reads an NBT tag from the stream.
*
@@ -39,7 +38,7 @@ public final class NBTInputStream implements Closeable {
public Tag readTag() throws IOException {
return readTag(0);
}
-
+
/**
* Reads an NBT from the stream.
*
@@ -51,7 +50,6 @@ public final class NBTInputStream implements Closeable {
*/
private Tag readTag(final int depth) throws IOException {
final int type = this.is.readByte() & 0xFF;
-
String name;
if (type != NBTConstants.TYPE_END) {
final int nameLength = this.is.readShort() & 0xFFFF;
@@ -61,10 +59,9 @@ public final class NBTInputStream implements Closeable {
} else {
name = "";
}
-
return readTagPayload(type, name, depth);
}
-
+
/**
* Reads the payload of a tag, given the name and type.
*
@@ -109,7 +106,6 @@ public final class NBTInputStream implements Closeable {
case NBTConstants.TYPE_LIST:
final int childType = this.is.readByte();
length = this.is.readInt();
-
final List tagList = new ArrayList();
for (int i = 0; i < length; ++i) {
final Tag tag = readTagPayload(childType, "", depth + 1);
@@ -118,7 +114,6 @@ public final class NBTInputStream implements Closeable {
}
tagList.add(tag);
}
-
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
case NBTConstants.TYPE_COMPOUND:
final Map tagMap = new HashMap();
@@ -130,7 +125,6 @@ public final class NBTInputStream implements Closeable {
tagMap.put(tag.getName(), tag);
}
}
-
return new CompoundTag(name, tagMap);
case NBTConstants.TYPE_INT_ARRAY:
length = this.is.readInt();
@@ -143,10 +137,9 @@ public final class NBTInputStream implements Closeable {
throw new IOException("Invalid tag type: " + type + ".");
}
}
-
+
@Override
public void close() throws IOException {
this.is.close();
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java
index 65e3426e5..a4deec5a3 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.jnbt;
import java.io.Closeable;
@@ -36,12 +35,11 @@ import java.util.List;
* @author Graham Edgecombe
*/
public final class NBTOutputStream implements Closeable {
-
/**
* The output stream.
*/
private final DataOutputStream os;
-
+
/**
* Creates a new NBTOutputStream
, which will write data to the specified underlying output stream.
*
@@ -52,7 +50,7 @@ public final class NBTOutputStream implements Closeable {
public NBTOutputStream(final OutputStream os) throws IOException {
this.os = new DataOutputStream(os);
}
-
+
/**
* Writes a tag.
*
@@ -64,18 +62,15 @@ public final class NBTOutputStream implements Closeable {
final int type = NBTUtils.getTypeCode(tag.getClass());
final String name = tag.getName();
final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
-
this.os.writeByte(type);
this.os.writeShort(nameBytes.length);
this.os.write(nameBytes);
-
if (type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted.");
}
-
writeTagPayload(tag);
}
-
+
/**
* Writes tag payload.
*
@@ -126,7 +121,7 @@ public final class NBTOutputStream implements Closeable {
throw new IOException("Invalid tag type: " + type + ".");
}
}
-
+
/**
* Writes a TAG_Byte
tag.
*
@@ -137,7 +132,7 @@ public final class NBTOutputStream implements Closeable {
private void writeByteTagPayload(final ByteTag tag) throws IOException {
this.os.writeByte(tag.getValue());
}
-
+
/**
* Writes a TAG_Byte_Array
tag.
*
@@ -150,7 +145,7 @@ public final class NBTOutputStream implements Closeable {
this.os.writeInt(bytes.length);
this.os.write(bytes);
}
-
+
/**
* Writes a TAG_Compound
tag.
*
@@ -164,7 +159,7 @@ public final class NBTOutputStream implements Closeable {
}
this.os.writeByte((byte) 0); // end tag - better way?
}
-
+
/**
* Writes a TAG_List
tag.
*
@@ -176,14 +171,13 @@ public final class NBTOutputStream implements Closeable {
final Class extends Tag> clazz = tag.getType();
final List tags = tag.getValue();
final int size = tags.size();
-
this.os.writeByte(NBTUtils.getTypeCode(clazz));
this.os.writeInt(size);
for (final Tag tag1 : tags) {
writeTagPayload(tag1);
}
}
-
+
/**
* Writes a TAG_String
tag.
*
@@ -196,7 +190,7 @@ public final class NBTOutputStream implements Closeable {
this.os.writeShort(bytes.length);
this.os.write(bytes);
}
-
+
/**
* Writes a TAG_Double
tag.
*
@@ -207,7 +201,7 @@ public final class NBTOutputStream implements Closeable {
private void writeDoubleTagPayload(final DoubleTag tag) throws IOException {
this.os.writeDouble(tag.getValue());
}
-
+
/**
* Writes a TAG_Float
tag.
*
@@ -218,7 +212,7 @@ public final class NBTOutputStream implements Closeable {
private void writeFloatTagPayload(final FloatTag tag) throws IOException {
this.os.writeFloat(tag.getValue());
}
-
+
/**
* Writes a TAG_Long
tag.
*
@@ -229,7 +223,7 @@ public final class NBTOutputStream implements Closeable {
private void writeLongTagPayload(final LongTag tag) throws IOException {
this.os.writeLong(tag.getValue());
}
-
+
/**
* Writes a TAG_Int
tag.
*
@@ -240,7 +234,7 @@ public final class NBTOutputStream implements Closeable {
private void writeIntTagPayload(final IntTag tag) throws IOException {
this.os.writeInt(tag.getValue());
}
-
+
/**
* Writes a TAG_Short
tag.
*
@@ -251,7 +245,7 @@ public final class NBTOutputStream implements Closeable {
private void writeShortTagPayload(final ShortTag tag) throws IOException {
this.os.writeShort(tag.getValue());
}
-
+
/**
* Writes a TAG_Empty
tag.
*
@@ -262,7 +256,7 @@ public final class NBTOutputStream implements Closeable {
private void writeEndTagPayload(final EndTag tag) {
/* empty */
}
-
+
private void writeIntArrayTagPayload(final IntArrayTag tag) throws IOException {
final int[] data = tag.getValue();
this.os.writeInt(data.length);
@@ -270,10 +264,9 @@ public final class NBTOutputStream implements Closeable {
this.os.writeInt(element);
}
}
-
+
@Override
public void close() throws IOException {
this.os.close();
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java
index fb7b85698..741fdf2ac 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java
@@ -6,13 +6,12 @@ import java.util.Map;
* A class which contains NBT-related utility methods.
*/
public final class NBTUtils {
-
/**
* Default private constructor.
*/
private NBTUtils() {
}
-
+
/**
* Gets the type name of a tag.
*
@@ -49,7 +48,7 @@ public final class NBTUtils {
throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
-
+
/**
* Gets the type code of a tag class.
*
@@ -88,7 +87,7 @@ public final class NBTUtils {
throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
-
+
/**
* Gets the class of a type of tag.
*
@@ -128,7 +127,7 @@ public final class NBTUtils {
throw new IllegalArgumentException("Invalid tag type : " + type + ".");
}
}
-
+
/**
* Get child tag of a NBT structure.
*
@@ -148,5 +147,4 @@ public final class NBTUtils {
}
return expected.cast(tag);
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java
index b4fb7e2a8..df4ceb57e 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java
@@ -18,16 +18,14 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.jnbt;
/**
* The {@code TAG_Short} tag.
*/
public final class ShortTag extends Tag {
-
private final short value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -37,7 +35,7 @@ public final class ShortTag extends Tag {
super();
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -48,12 +46,12 @@ public final class ShortTag extends Tag {
super(name);
this.value = value;
}
-
+
@Override
public Short getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -63,5 +61,4 @@ public final class ShortTag extends Tag {
}
return "TAG_Short" + append + ": " + this.value;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java
index 708331cec..8c0756e63 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java
@@ -6,9 +6,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
* The {@code TAG_String} tag.
*/
public final class StringTag extends Tag {
-
private final String value;
-
+
/**
* Creates the tag with an empty name.
*
@@ -19,7 +18,7 @@ public final class StringTag extends Tag {
checkNotNull(value);
this.value = value;
}
-
+
/**
* Creates the tag.
*
@@ -31,12 +30,12 @@ public final class StringTag extends Tag {
checkNotNull(value);
this.value = value;
}
-
+
@Override
public String getValue() {
return this.value;
}
-
+
@Override
public String toString() {
final String name = getName();
@@ -46,5 +45,4 @@ public final class StringTag extends Tag {
}
return "TAG_String" + append + ": " + this.value;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java
index aa060c18e..395333e13 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java
@@ -18,23 +18,21 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.jnbt;
/**
* Represents a NBT tag.
*/
public abstract class Tag {
-
private final String name;
-
+
/**
* Create a new tag with an empty name.
*/
Tag() {
this("");
}
-
+
/**
* Creates the tag with the specified name.
*
@@ -46,7 +44,7 @@ public abstract class Tag {
}
this.name = name;
}
-
+
/**
* Gets the name of this tag.
*
@@ -55,12 +53,11 @@ public abstract class Tag {
public final String getName() {
return this.name;
}
-
+
/**
* Gets the value of this tag.
*
* @return the value
*/
public abstract Object getValue();
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java
index 30123a5ac..3f86f897a 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java
@@ -4,11 +4,8 @@ import org.bukkit.World;
public class WorldEditUtils {
public static void setNBT(final World world, final short id, final byte data, final int x, final int y, final int z, final com.intellectualcrafters.jnbt.CompoundTag tag) {
-
// final LocalWorld bukkitWorld = BukkitUtil.getLocalWorld(world);
-
// I need to somehow convert our CompoundTag to WorldEdit's
-
// final BaseBlock block = new BaseBlock(5, 5, (CompoundTag) tag);
// final Vector vector = new Vector(x, y, z);
// try {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java
index 7e2f3f847..9514eea56 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java
@@ -18,7 +18,6 @@ package com.intellectualcrafters.json;
* @version 2014-05-03
*/
public class CDL {
-
/**
* Get the next value. The value can be wrapped in quotes. The value can be empty.
*
@@ -42,7 +41,7 @@ public class CDL {
case '\'':
q = c;
sb = new StringBuffer();
- for (; ; ) {
+ for (;;) {
c = x.next();
if (c == q) {
break;
@@ -61,7 +60,7 @@ public class CDL {
return x.nextTo(',');
}
}
-
+
/**
* Produce a JSONArray of strings from a row of comma delimited values.
*
@@ -73,14 +72,14 @@ public class CDL {
*/
public static JSONArray rowToJSONArray(final JSONTokener x) throws JSONException {
final JSONArray ja = new JSONArray();
- for (; ; ) {
+ for (;;) {
final String value = getValue(x);
char c = x.next();
if ((value == null) || ((ja.length() == 0) && (value.length() == 0) && (c != ','))) {
return null;
}
ja.put(value);
- for (; ; ) {
+ for (;;) {
if (c == ',') {
break;
}
@@ -94,7 +93,7 @@ public class CDL {
}
}
}
-
+
/**
* Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings to provides the
* names of the elements.
@@ -111,7 +110,7 @@ public class CDL {
final JSONArray ja = rowToJSONArray(x);
return ja != null ? ja.toJSONObject(names) : null;
}
-
+
/**
* Produce a comma delimited text row from a JSONArray. Values containing the comma character will be quoted.
* Troublesome characters may be removed.
@@ -147,7 +146,7 @@ public class CDL {
sb.append('\n');
return sb.toString();
}
-
+
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.
*
@@ -160,7 +159,7 @@ public class CDL {
public static JSONArray toJSONArray(final String string) throws JSONException {
return toJSONArray(new JSONTokener(string));
}
-
+
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.
*
@@ -173,7 +172,7 @@ public class CDL {
public static JSONArray toJSONArray(final JSONTokener x) throws JSONException {
return toJSONArray(rowToJSONArray(x), x);
}
-
+
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of
* element names.
@@ -188,7 +187,7 @@ public class CDL {
public static JSONArray toJSONArray(final JSONArray names, final String string) throws JSONException {
return toJSONArray(names, new JSONTokener(string));
}
-
+
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of
* element names.
@@ -205,7 +204,7 @@ public class CDL {
return null;
}
final JSONArray ja = new JSONArray();
- for (; ; ) {
+ for (;;) {
final JSONObject jo = rowToJSONObject(names, x);
if (jo == null) {
break;
@@ -217,7 +216,7 @@ public class CDL {
}
return ja;
}
-
+
/**
* Produce a comma delimited text from a JSONArray of JSONObjects. The first row will be a list of names obtained by
* inspecting the first JSONObject.
@@ -238,7 +237,7 @@ public class CDL {
}
return null;
}
-
+
/**
* Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names. The list of names
* is not included in the output.
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java
index b5efcbd2d..ee4def328 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.json;
/**
@@ -29,7 +28,6 @@ package com.intellectualcrafters.json;
* @version 2014-05-03
*/
public class Cookie {
-
/**
* Produce a copy of a string in which the characters '+', '%', '=', ';' and control characters are replaced with
* "%hh". This is a gentle form of URL encoding, attempting to cause as little distortion to the string as possible.
@@ -58,7 +56,7 @@ public class Cookie {
}
return sb.toString();
}
-
+
/**
* Convert a cookie specification string into a JSONObject. The string will contain a name value pair separated by
* '='. The name and the value will be unescaped, possibly converting '+' and '%' sequences. The cookie properties
@@ -98,7 +96,7 @@ public class Cookie {
}
return jo;
}
-
+
/**
* Convert a JSONObject into a cookie specification string. The JSONObject must contain "name" and "value" members.
* If the JSONObject contains "expires", "domain", "path", or "secure" members, they will be appended to the cookie
@@ -112,7 +110,6 @@ public class Cookie {
*/
public static String toString(final JSONObject jo) throws JSONException {
final StringBuilder sb = new StringBuilder();
-
sb.append(escape(jo.getString("name")));
sb.append("=");
sb.append(escape(jo.getString("value")));
@@ -133,7 +130,7 @@ public class Cookie {
}
return sb.toString();
}
-
+
/**
* Convert %
hh sequences to single characters, and convert plus to space.
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java
index 99437329f..01eba0b85 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java
@@ -9,7 +9,6 @@ import java.util.Iterator;
* @version 2014-05-03
*/
public class CookieList {
-
/**
* Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The names are separated
* from the values by '='. The pairs are separated by ';'. The names and the values will be unescaped, possibly
@@ -35,7 +34,7 @@ public class CookieList {
}
return jo;
}
-
+
/**
* Convert a JSONObject into a cookie list. A cookie list is a sequence of name/value pairs. The names are separated
* from the values by '='. The pairs are separated by ';'. The characters '%', '+', '=', and ';' in the names and
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java
index 786fbf38e..8bc44d340 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.json;
import java.util.Iterator;
@@ -30,12 +29,11 @@ import java.util.Iterator;
* @version 2014-05-03
*/
public class HTTP {
-
/**
* Carriage return/line feed.
*/
public static final String CRLF = "\r\n";
-
+
/**
* Convert an HTTP header string into a JSONObject. It can be a request header or a response header. A request
* header will contain
@@ -93,28 +91,20 @@ public class HTTP {
final JSONObject jo = new JSONObject();
final HTTPTokener x = new HTTPTokener(string);
String token;
-
token = x.nextToken();
if (token.toUpperCase().startsWith("HTTP")) {
-
// Response
-
jo.put("HTTP-Version", token);
jo.put("Status-Code", x.nextToken());
jo.put("Reason-Phrase", x.nextTo('\0'));
x.next();
-
} else {
-
// Request
-
jo.put("Method", token);
jo.put("Request-URI", x.nextToken());
jo.put("HTTP-Version", x.nextToken());
}
-
// Fields
-
while (x.more()) {
final String name = x.nextTo(':');
x.next(':');
@@ -123,7 +113,7 @@ public class HTTP {
}
return jo;
}
-
+
/**
* Convert a JSONObject into an HTTP header. A request header must contain
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java
index 09cc1af60..5a3fb1e56 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java
@@ -7,7 +7,6 @@ package com.intellectualcrafters.json;
* @version 2014-05-03
*/
public class HTTPTokener extends JSONTokener {
-
/**
* Construct an HTTPTokener from a string.
*
@@ -16,7 +15,7 @@ public class HTTPTokener extends JSONTokener {
public HTTPTokener(final String string) {
super(string);
}
-
+
/**
* Get the next token or string. This is used in parsing HTTP headers.
*
@@ -33,7 +32,7 @@ public class HTTPTokener extends JSONTokener {
} while (Character.isWhitespace(c));
if ((c == '"') || (c == '\'')) {
q = c;
- for (; ; ) {
+ for (;;) {
c = next();
if (c < ' ') {
throw syntaxError("Unterminated string.");
@@ -44,7 +43,7 @@ public class HTTPTokener extends JSONTokener {
sb.append(c);
}
}
- for (; ; ) {
+ for (;;) {
if ((c == 0) || Character.isWhitespace(c)) {
return sb.toString();
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java
index d82e9c6a8..4725eec68 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.json;
import java.io.IOException;
@@ -58,19 +57,18 @@ import java.util.Map;
* @version 2014-05-03
*/
public class JSONArray {
-
/**
* The arrayList where the JSONArray's properties are kept.
*/
private final ArrayList myArrayList;
-
+
/**
* Construct an empty JSONArray.
*/
public JSONArray() {
this.myArrayList = new ArrayList();
}
-
+
/**
* Construct a JSONArray from a JSONTokener.
*
@@ -85,7 +83,7 @@ public class JSONArray {
}
if (x.nextClean() != ']') {
x.back();
- for (; ; ) {
+ for (;;) {
if (x.nextClean() == ',') {
x.back();
this.myArrayList.add(JSONObject.NULL);
@@ -108,7 +106,7 @@ public class JSONArray {
}
}
}
-
+
/**
* Construct a JSONArray from a source JSON text.
*
@@ -120,7 +118,7 @@ public class JSONArray {
public JSONArray(final String source) throws JSONException {
this(new JSONTokener(source));
}
-
+
/**
* Construct a JSONArray from a Collection.
*
@@ -134,7 +132,7 @@ public class JSONArray {
}
}
}
-
+
/**
* Construct a JSONArray from an array
*
@@ -151,7 +149,7 @@ public class JSONArray {
throw new JSONException("JSONArray initial value should be a string or collection or array.");
}
}
-
+
/**
* Get the object value associated with an index.
*
@@ -168,7 +166,7 @@ public class JSONArray {
}
return object;
}
-
+
/**
* Get the boolean value associated with an index. The string values "true" and "false" are converted to boolean.
*
@@ -187,7 +185,7 @@ public class JSONArray {
}
throw new JSONException("JSONArray[" + index + "] is not a boolean.");
}
-
+
/**
* Get the double value associated with an index.
*
@@ -205,7 +203,7 @@ public class JSONArray {
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
-
+
/**
* Get the int value associated with an index.
*
@@ -223,7 +221,7 @@ public class JSONArray {
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
-
+
/**
* Get the JSONArray associated with an index.
*
@@ -240,7 +238,7 @@ public class JSONArray {
}
throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
}
-
+
/**
* Get the JSONObject associated with an index.
*
@@ -257,7 +255,7 @@ public class JSONArray {
}
throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
}
-
+
/**
* Get the long value associated with an index.
*
@@ -275,7 +273,7 @@ public class JSONArray {
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
-
+
/**
* Get the string associated with an index.
*
@@ -292,7 +290,7 @@ public class JSONArray {
}
throw new JSONException("JSONArray[" + index + "] not a string.");
}
-
+
/**
* Determine if the value is null.
*
@@ -303,7 +301,7 @@ public class JSONArray {
public boolean isNull(final int index) {
return JSONObject.NULL.equals(this.opt(index));
}
-
+
/**
* Make a string from the contents of this JSONArray. The separator
string is inserted between each
* element. Warning: This method assumes that the data structure is acyclical.
@@ -317,7 +315,6 @@ public class JSONArray {
public String join(final String separator) throws JSONException {
final int len = this.length();
final StringBuilder sb = new StringBuilder();
-
for (int i = 0; i < len; i += 1) {
if (i > 0) {
sb.append(separator);
@@ -326,7 +323,7 @@ public class JSONArray {
}
return sb.toString();
}
-
+
/**
* Get the number of elements in the JSONArray, included nulls.
*
@@ -335,7 +332,7 @@ public class JSONArray {
public int length() {
return this.myArrayList.size();
}
-
+
/**
* Get the optional object value associated with an index.
*
@@ -346,7 +343,7 @@ public class JSONArray {
public Object opt(final int index) {
return ((index < 0) || (index >= this.length())) ? null : this.myArrayList.get(index);
}
-
+
/**
* Get the optional boolean value associated with an index. It returns false if there is no value at that index, or
* if the value is not Boolean.TRUE or the String "true".
@@ -358,7 +355,7 @@ public class JSONArray {
public boolean optBoolean(final int index) {
return this.optBoolean(index, false);
}
-
+
/**
* Get the optional boolean value associated with an index. It returns the defaultValue if there is no value at that
* index or if it is not a Boolean or the String "true" or "false" (case insensitive).
@@ -375,7 +372,7 @@ public class JSONArray {
return defaultValue;
}
}
-
+
/**
* Get the optional double value associated with an index. NaN is returned if there is no value for the index, or if
* the value is not a number and cannot be converted to a number.
@@ -387,7 +384,7 @@ public class JSONArray {
public double optDouble(final int index) {
return this.optDouble(index, Double.NaN);
}
-
+
/**
* Get the optional double value associated with an index. The defaultValue is returned if there is no value for the
* index, or if the value is not a number and cannot be converted to a number.
@@ -404,7 +401,7 @@ public class JSONArray {
return defaultValue;
}
}
-
+
/**
* Get the optional int value associated with an index. Zero is returned if there is no value for the index, or if
* the value is not a number and cannot be converted to a number.
@@ -416,7 +413,7 @@ public class JSONArray {
public int optInt(final int index) {
return this.optInt(index, 0);
}
-
+
/**
* Get the optional int value associated with an index. The defaultValue is returned if there is no value for the
* index, or if the value is not a number and cannot be converted to a number.
@@ -433,7 +430,7 @@ public class JSONArray {
return defaultValue;
}
}
-
+
/**
* Get the optional JSONArray associated with an index.
*
@@ -445,7 +442,7 @@ public class JSONArray {
final Object o = this.opt(index);
return o instanceof JSONArray ? (JSONArray) o : null;
}
-
+
/**
* Get the optional JSONObject associated with an index. Null is returned if the key is not found, or null if the
* index has no value, or if the value is not a JSONObject.
@@ -458,7 +455,7 @@ public class JSONArray {
final Object o = this.opt(index);
return o instanceof JSONObject ? (JSONObject) o : null;
}
-
+
/**
* Get the optional long value associated with an index. Zero is returned if there is no value for the index, or if
* the value is not a number and cannot be converted to a number.
@@ -470,7 +467,7 @@ public class JSONArray {
public long optLong(final int index) {
return this.optLong(index, 0);
}
-
+
/**
* Get the optional long value associated with an index. The defaultValue is returned if there is no value for the
* index, or if the value is not a number and cannot be converted to a number.
@@ -487,7 +484,7 @@ public class JSONArray {
return defaultValue;
}
}
-
+
/**
* Get the optional string value associated with an index. It returns an empty string if there is no value at that
* index. If the value is not a string and is not null, then it is coverted to a string.
@@ -499,7 +496,7 @@ public class JSONArray {
public String optString(final int index) {
return this.optString(index, "");
}
-
+
/**
* Get the optional string associated with an index. The defaultValue is returned if the key is not found.
*
@@ -512,7 +509,7 @@ public class JSONArray {
final Object object = this.opt(index);
return JSONObject.NULL.equals(object) ? defaultValue : object.toString();
}
-
+
/**
* Append a boolean value. This increases the array's length by one.
*
@@ -524,7 +521,7 @@ public class JSONArray {
this.put(value ? Boolean.TRUE : Boolean.FALSE);
return this;
}
-
+
/**
* Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection.
*
@@ -536,7 +533,7 @@ public class JSONArray {
this.put(new JSONArray(value));
return this;
}
-
+
/**
* Append a double value. This increases the array's length by one.
*
@@ -552,7 +549,7 @@ public class JSONArray {
this.put(d);
return this;
}
-
+
/**
* Append an int value. This increases the array's length by one.
*
@@ -564,7 +561,7 @@ public class JSONArray {
this.put(new Integer(value));
return this;
}
-
+
/**
* Append an long value. This increases the array's length by one.
*
@@ -576,7 +573,7 @@ public class JSONArray {
this.put(new Long(value));
return this;
}
-
+
/**
* Put a value in the JSONArray, where the value will be a JSONObject which is produced from a Map.
*
@@ -588,7 +585,7 @@ public class JSONArray {
this.put(new JSONObject(value));
return this;
}
-
+
/**
* Append an object value. This increases the array's length by one.
*
@@ -601,7 +598,7 @@ public class JSONArray {
this.myArrayList.add(value);
return this;
}
-
+
/**
* Put or replace a boolean value in the JSONArray. If the index is greater than the length of the JSONArray, then
* null elements will be added as necessary to pad it out.
@@ -617,7 +614,7 @@ public class JSONArray {
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
return this;
}
-
+
/**
* Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection.
*
@@ -632,7 +629,7 @@ public class JSONArray {
this.put(index, new JSONArray(value));
return this;
}
-
+
/**
* Put or replace a double value. If the index is greater than the length of the JSONArray, then null elements will
* be added as necessary to pad it out.
@@ -648,7 +645,7 @@ public class JSONArray {
this.put(index, new Double(value));
return this;
}
-
+
/**
* Put or replace an int value. If the index is greater than the length of the JSONArray, then null elements will be
* added as necessary to pad it out.
@@ -664,7 +661,7 @@ public class JSONArray {
this.put(index, new Integer(value));
return this;
}
-
+
/**
* Put or replace a long value. If the index is greater than the length of the JSONArray, then null elements will be
* added as necessary to pad it out.
@@ -680,7 +677,7 @@ public class JSONArray {
this.put(index, new Long(value));
return this;
}
-
+
/**
* Put a value in the JSONArray, where the value will be a JSONObject that is produced from a Map.
*
@@ -695,7 +692,7 @@ public class JSONArray {
this.put(index, new JSONObject(value));
return this;
}
-
+
/**
* Put or replace an object value in the JSONArray. If the index is greater than the length of the JSONArray, then
* null elements will be added as necessary to pad it out.
@@ -723,7 +720,7 @@ public class JSONArray {
}
return this;
}
-
+
/**
* Remove an index and close the hole.
*
@@ -734,7 +731,7 @@ public class JSONArray {
public Object remove(final int index) {
return (index >= 0) && (index < this.length()) ? this.myArrayList.remove(index) : null;
}
-
+
/**
* Determine if two JSONArrays are similar. They must contain similar sequences.
*
@@ -767,7 +764,7 @@ public class JSONArray {
}
return true;
}
-
+
/**
* Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.
*
@@ -787,7 +784,7 @@ public class JSONArray {
}
return jo;
}
-
+
/**
* Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to
* produce a syntactically correct JSON text then null will be returned instead. This could occur if the array
@@ -805,7 +802,7 @@ public class JSONArray {
return null;
}
}
-
+
/**
* Make a prettyprinted JSON text of this JSONArray. Warning: This method assumes that the data structure is
* acyclical.
@@ -824,7 +821,7 @@ public class JSONArray {
return this.write(sw, indentFactor, 0).toString();
}
}
-
+
/**
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
*
@@ -837,7 +834,7 @@ public class JSONArray {
public Writer write(final Writer writer) throws JSONException {
return this.write(writer, 0, 0);
}
-
+
/**
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
*
@@ -855,12 +852,10 @@ public class JSONArray {
boolean commanate = false;
final int length = this.length();
writer.write('[');
-
if (length == 1) {
JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
} else if (length != 0) {
final int newindent = indent + indentFactor;
-
for (int i = 0; i < length; i += 1) {
if (commanate) {
writer.write(',');
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java
index 090d4e4f7..d15aae6d9 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java
@@ -9,7 +9,7 @@ package com.intellectualcrafters.json;
public class JSONException extends RuntimeException {
private static final long serialVersionUID = 0;
private Throwable cause;
-
+
/**
* Constructs a JSONException with an explanatory message.
*
@@ -18,7 +18,7 @@ public class JSONException extends RuntimeException {
public JSONException(final String message) {
super(message);
}
-
+
/**
* Constructs a new JSONException with the specified cause.
*
@@ -28,7 +28,7 @@ public class JSONException extends RuntimeException {
super(cause.getMessage());
this.cause = cause;
}
-
+
/**
* Returns the cause of this exception or null if the cause is nonexistent or unknown.
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java
index 307ac1bef..8d92ddf10 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java
@@ -10,7 +10,6 @@ import java.util.Iterator;
* @version 2014-05-03
*/
public class JSONML {
-
/**
* Parse XML values and store them in a JSONArray.
*
@@ -31,13 +30,11 @@ public class JSONML {
JSONObject newjo = null;
Object token;
String tagName = null;
-
// Test for and skip past these forms:
//
//
//
// ... ?>
-
while (true) {
if (!x.more()) {
throw x.syntaxError("Bad XML");
@@ -47,9 +44,7 @@ public class JSONML {
token = x.nextToken();
if (token instanceof Character) {
if (token == XML.SLASH) {
-
// Close tag
-
token = x.nextToken();
if (!(token instanceof String)) {
throw new JSONException("Expected a closing name instead of '" + token + "'.");
@@ -59,9 +54,7 @@ public class JSONML {
}
return token;
} else if (token == XML.BANG) {
-
// 0);
}
} else if (token == XML.QUEST) {
-
//
-
x.skipPast("?>");
} else {
throw x.syntaxError("Misshaped tag");
}
-
// Open tag <
-
} else {
if (!(token instanceof String)) {
throw x.syntaxError("Bad tagName '" + token + "'.");
@@ -121,7 +110,7 @@ public class JSONML {
}
}
token = null;
- for (; ; ) {
+ for (;;) {
if (token == null) {
token = x.nextToken();
}
@@ -131,9 +120,7 @@ public class JSONML {
if (!(token instanceof String)) {
break;
}
-
// attribute = value
-
attribute = (String) token;
if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) {
throw x.syntaxError("Reserved attribute.");
@@ -153,9 +140,7 @@ public class JSONML {
if (arrayForm && (newjo.length() > 0)) {
newja.put(newjo);
}
-
// Empty tag <.../>
-
if (token == XML.SLASH) {
if (x.nextToken() != XML.GT) {
throw x.syntaxError("Misshaped tag");
@@ -167,9 +152,7 @@ public class JSONML {
return newjo;
}
}
-
// Content, between <...> and
-
} else {
if (token != XML.GT) {
throw x.syntaxError("Misshaped tag");
@@ -200,7 +183,7 @@ public class JSONML {
}
}
}
-
+
/**
* Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each
* XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then
@@ -216,7 +199,7 @@ public class JSONML {
public static JSONArray toJSONArray(final String string) throws JSONException {
return toJSONArray(new XMLTokener(string));
}
-
+
/**
* Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each
* XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then
@@ -233,7 +216,7 @@ public class JSONML {
public static JSONArray toJSONArray(final XMLTokener x) throws JSONException {
return (JSONArray) parse(x, true, null);
}
-
+
/**
* Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each
* XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
@@ -251,7 +234,7 @@ public class JSONML {
public static JSONObject toJSONObject(final XMLTokener x) throws JSONException {
return (JSONObject) parse(x, false, null);
}
-
+
/**
* Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each
* XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
@@ -269,7 +252,7 @@ public class JSONML {
public static JSONObject toJSONObject(final String string) throws JSONException {
return toJSONObject(new XMLTokener(string));
}
-
+
/**
* Reverse the JSONML transformation, making an XML text from a JSONArray.
*
@@ -289,22 +272,17 @@ public class JSONML {
final StringBuilder sb = new StringBuilder();
String tagName;
String value;
-
// Emit = length) {
sb.append('/');
@@ -351,7 +327,7 @@ public class JSONML {
}
return sb.toString();
}
-
+
/**
* Reverse the JSONML transformation, making an XML text from a JSONObject. The JSONObject must contain a "tagName"
* property. If it has children, then it must have a "childNodes" property containing an array of objects. The other
@@ -373,9 +349,7 @@ public class JSONML {
Object object;
String tagName;
String value;
-
// Emit map;
-
+
/**
* Construct an empty JSONObject.
*/
public JSONObject() {
this.map = new HashMap();
}
-
+
/**
* Construct a JSONObject from a subset of another JSONObject. An array of strings is used to identify the keys that
* should be copied. Missing keys are ignored.
@@ -91,7 +91,7 @@ public class JSONObject {
}
}
}
-
+
/**
* Construct a JSONObject from a JSONTokener.
*
@@ -103,11 +103,10 @@ public class JSONObject {
this();
char c;
String key;
-
if (x.nextClean() != '{') {
throw x.syntaxError("A JSONObject text must begin with '{'");
}
- for (; ; ) {
+ for (;;) {
c = x.nextClean();
switch (c) {
case 0:
@@ -118,17 +117,13 @@ public class JSONObject {
x.back();
key = x.nextValue().toString();
}
-
// The key is followed by ':'.
-
c = x.nextClean();
if (c != ':') {
throw x.syntaxError("Expected a ':' after a key");
}
this.putOnce(key, x.nextValue());
-
// Pairs are separated by ','.
-
switch (x.nextClean()) {
case ';':
case ',':
@@ -144,7 +139,7 @@ public class JSONObject {
}
}
}
-
+
/**
* Construct a JSONObject from a Map.
*
@@ -163,7 +158,7 @@ public class JSONObject {
}
}
}
-
+
/**
* Construct a JSONObject from an Object using bean getters. It reflects on all of the public methods of the object.
* For each of the methods with no parameters and a name starting with "get"
or "is"
@@ -183,7 +178,7 @@ public class JSONObject {
this();
this.populateMap(bean);
}
-
+
/**
* Construct a JSONObject from an Object, using reflection to find the public members. The resulting JSONObject's
* keys will be the strings from the names array, and the values will be the field values associated with those keys
@@ -202,7 +197,7 @@ public class JSONObject {
}
}
}
-
+
/**
* Construct a JSONObject from a source JSON text string. This is the most commonly used JSONObject constructor.
*
@@ -214,7 +209,7 @@ public class JSONObject {
public JSONObject(final String source) throws JSONException {
this(new JSONTokener(source));
}
-
+
/**
* Construct a JSONObject from a ResourceBundle.
*
@@ -226,20 +221,16 @@ public class JSONObject {
public JSONObject(final String baseName, final Locale locale) throws JSONException {
this();
final ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader());
-
// Iterate through the keys in the bundle.
-
final Enumeration keys = bundle.getKeys();
while (keys.hasMoreElements()) {
final Object key = keys.nextElement();
if (key != null) {
-
// Go through the path, ensuring that there is a nested
// JSONObject for each
// segment except the last. Add the value using the last
// segment's name into
// the deepest nested JSONObject.
-
final String[] path = ((String) key).split("\\.");
final int last = path.length - 1;
JSONObject target = this;
@@ -256,7 +247,7 @@ public class JSONObject {
}
}
}
-
+
/**
* Produce a string from a double. The string "null" will be returned if the number is not finite.
*
@@ -268,9 +259,7 @@ public class JSONObject {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
-
// Shave off trailing zeros and decimal point, if possible.
-
String string = Double.toString(d);
if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) {
while (string.endsWith("0")) {
@@ -282,7 +271,7 @@ public class JSONObject {
}
return string;
}
-
+
/**
* Get an array of field names from a JSONObject.
*
@@ -302,7 +291,7 @@ public class JSONObject {
}
return names;
}
-
+
/**
* Get an array of field names from an Object.
*
@@ -324,7 +313,7 @@ public class JSONObject {
}
return names;
}
-
+
/**
* Produce a string from a Number.
*
@@ -339,9 +328,7 @@ public class JSONObject {
throw new JSONException("Null pointer");
}
testValidity(number);
-
// Shave off trailing zeros and decimal point, if possible.
-
String string = number.toString();
if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) {
while (string.endsWith("0")) {
@@ -353,7 +340,7 @@ public class JSONObject {
}
return string;
}
-
+
/**
* Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted
* within , producing <\/, allowing JSON text to be delivered in HTML. In JSON text, a string cannot contain a
@@ -374,19 +361,17 @@ public class JSONObject {
}
}
}
-
+
public static Writer quote(final String string, final Writer w) throws IOException {
if ((string == null) || (string.length() == 0)) {
w.write("\"\"");
return w;
}
-
char b;
char c = 0;
String hhhh;
int i;
final int len = string.length();
-
w.write('"');
for (i = 0; i < len; i += 1) {
b = c;
@@ -432,7 +417,7 @@ public class JSONObject {
w.write('"');
return w;
}
-
+
/**
* Try to convert a string into a number, boolean, or null. If the string can't be converted, return the string.
*
@@ -454,12 +439,10 @@ public class JSONObject {
if (string.equalsIgnoreCase("null")) {
return JSONObject.NULL;
}
-
/*
* If it might be a number, try converting it. If a number cannot be
* produced, then the value will just be a string.
*/
-
final char b = string.charAt(0);
if (((b >= '0') && (b <= '9')) || (b == '-')) {
try {
@@ -483,7 +466,7 @@ public class JSONObject {
}
return string;
}
-
+
/**
* Throw an exception if the object is a NaN or infinite number.
*
@@ -504,7 +487,7 @@ public class JSONObject {
}
}
}
-
+
/**
* Make a JSON text of an Object value. If the object has an value.toJSONString() method, then that method will be
* used to produce the JSON text. The method is required to produce a strictly conforming text. If the object does
@@ -557,7 +540,7 @@ public class JSONObject {
}
return quote(value.toString());
}
-
+
/**
* Wrap an object, if necessary. If the object is null, return the NULL object. If it is an array or collection,
* wrap it in a JSONArray. If it is a map, wrap it in a JSONObject. If it is a standard property (Double, String, et
@@ -576,7 +559,6 @@ public class JSONObject {
if ((object instanceof JSONObject) || (object instanceof JSONArray) || NULL.equals(object) || (object instanceof JSONString) || (object instanceof Byte) || (object instanceof Character) || (object instanceof Short) || (object instanceof Integer) || (object instanceof Long) || (object instanceof Boolean) || (object instanceof Float) || (object instanceof Double) || (object instanceof String)) {
return object;
}
-
if (object instanceof Collection) {
return new JSONArray((Collection) object);
}
@@ -596,7 +578,7 @@ public class JSONObject {
return null;
}
}
-
+
static final Writer writeValue(final Writer writer, final Object value, final int indentFactor, final int indent) throws JSONException, IOException {
if ((value == null) || value.equals(null)) {
writer.write("null");
@@ -627,13 +609,13 @@ public class JSONObject {
}
return writer;
}
-
+
static final void indent(final Writer writer, final int indent) throws IOException {
for (int i = 0; i < indent; i += 1) {
writer.write(' ');
}
}
-
+
/**
* Accumulate values under a key. It is similar to the put method except that if there is already an object stored
* under the key then a JSONArray is stored under the key to hold all of the accumulated values. If there is already
@@ -661,7 +643,7 @@ public class JSONObject {
}
return this;
}
-
+
/**
* Append values to the array under a key. If the key does not exist in the JSONObject, then the key is put in the
* JSONObject with its value being a JSONArray containing the value parameter. If the key was already associated
@@ -686,7 +668,7 @@ public class JSONObject {
}
return this;
}
-
+
/**
* Get the value object associated with a key.
*
@@ -706,7 +688,7 @@ public class JSONObject {
}
return object;
}
-
+
/**
* Get the boolean value associated with a key.
*
@@ -725,7 +707,7 @@ public class JSONObject {
}
throw new JSONException("JSONObject[" + quote(key) + "] is not a Boolean.");
}
-
+
/**
* Get the double value associated with a key.
*
@@ -744,7 +726,7 @@ public class JSONObject {
throw new JSONException("JSONObject[" + quote(key) + "] is not a number.");
}
}
-
+
/**
* Get the int value associated with a key.
*
@@ -762,7 +744,7 @@ public class JSONObject {
throw new JSONException("JSONObject[" + quote(key) + "] is not an int.");
}
}
-
+
/**
* Get the JSONArray value associated with a key.
*
@@ -779,7 +761,7 @@ public class JSONObject {
}
throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONArray.");
}
-
+
/**
* Get the JSONObject value associated with a key.
*
@@ -796,7 +778,7 @@ public class JSONObject {
}
throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONObject.");
}
-
+
/**
* Get the long value associated with a key.
*
@@ -814,7 +796,7 @@ public class JSONObject {
throw new JSONException("JSONObject[" + quote(key) + "] is not a long.");
}
}
-
+
/**
* Get the string associated with a key.
*
@@ -831,7 +813,7 @@ public class JSONObject {
}
throw new JSONException("JSONObject[" + quote(key) + "] not a string.");
}
-
+
/**
* Determine if the JSONObject contains a specific key.
*
@@ -842,7 +824,7 @@ public class JSONObject {
public boolean has(final String key) {
return this.map.containsKey(key);
}
-
+
/**
* Increment a property of a JSONObject. If there is no such property, create one with a value of 1. If there is
* such a property, and if it is an Integer, Long, Double, or Float, then add one to it.
@@ -871,7 +853,7 @@ public class JSONObject {
}
return this;
}
-
+
/**
* Determine if the value associated with the key is null or if there is no value.
*
@@ -882,7 +864,7 @@ public class JSONObject {
public boolean isNull(final String key) {
return JSONObject.NULL.equals(this.opt(key));
}
-
+
/**
* Get an enumeration of the keys of the JSONObject.
*
@@ -891,7 +873,7 @@ public class JSONObject {
public Iterator keys() {
return this.keySet().iterator();
}
-
+
/**
* Get a set of keys of the JSONObject.
*
@@ -900,7 +882,7 @@ public class JSONObject {
public Set keySet() {
return this.map.keySet();
}
-
+
/**
* Get the number of keys stored in the JSONObject.
*
@@ -909,7 +891,7 @@ public class JSONObject {
public int length() {
return this.map.size();
}
-
+
/**
* Produce a JSONArray containing the names of the elements of this JSONObject.
*
@@ -923,7 +905,7 @@ public class JSONObject {
}
return ja.length() == 0 ? null : ja;
}
-
+
/**
* Get an optional value associated with a key.
*
@@ -934,7 +916,7 @@ public class JSONObject {
public Object opt(final String key) {
return key == null ? null : this.map.get(key);
}
-
+
/**
* Get an optional boolean associated with a key. It returns false if there is no such key, or if the value is not
* Boolean.TRUE or the String "true".
@@ -946,7 +928,7 @@ public class JSONObject {
public boolean optBoolean(final String key) {
return this.optBoolean(key, false);
}
-
+
/**
* Get an optional boolean associated with a key. It returns the defaultValue if there is no such key, or if it is
* not a Boolean or the String "true" or "false" (case insensitive).
@@ -963,7 +945,7 @@ public class JSONObject {
return defaultValue;
}
}
-
+
/**
* Get an optional double associated with a key, or NaN if there is no such key or if its value is not a number. If
* the value is a string, an attempt will be made to evaluate it as a number.
@@ -975,7 +957,7 @@ public class JSONObject {
public double optDouble(final String key) {
return this.optDouble(key, Double.NaN);
}
-
+
/**
* Get an optional double associated with a key, or the defaultValue if there is no such key or if its value is not
* a number. If the value is a string, an attempt will be made to evaluate it as a number.
@@ -992,7 +974,7 @@ public class JSONObject {
return defaultValue;
}
}
-
+
/**
* Get an optional int value associated with a key, or zero if there is no such key or if the value is not a number.
* If the value is a string, an attempt will be made to evaluate it as a number.
@@ -1004,7 +986,7 @@ public class JSONObject {
public int optInt(final String key) {
return this.optInt(key, 0);
}
-
+
/**
* Get an optional int value associated with a key, or the default if there is no such key or if the value is not a
* number. If the value is a string, an attempt will be made to evaluate it as a number.
@@ -1021,7 +1003,7 @@ public class JSONObject {
return defaultValue;
}
}
-
+
/**
* Get an optional JSONArray associated with a key. It returns null if there is no such key, or if its value is not
* a JSONArray.
@@ -1034,7 +1016,7 @@ public class JSONObject {
final Object o = this.opt(key);
return o instanceof JSONArray ? (JSONArray) o : null;
}
-
+
/**
* Get an optional JSONObject associated with a key. It returns null if there is no such key, or if its value is not
* a JSONObject.
@@ -1047,7 +1029,7 @@ public class JSONObject {
final Object object = this.opt(key);
return object instanceof JSONObject ? (JSONObject) object : null;
}
-
+
/**
* Get an optional long value associated with a key, or zero if there is no such key or if the value is not a
* number. If the value is a string, an attempt will be made to evaluate it as a number.
@@ -1059,7 +1041,7 @@ public class JSONObject {
public long optLong(final String key) {
return this.optLong(key, 0);
}
-
+
/**
* Get an optional long value associated with a key, or the default if there is no such key or if the value is not a
* number. If the value is a string, an attempt will be made to evaluate it as a number.
@@ -1076,7 +1058,7 @@ public class JSONObject {
return defaultValue;
}
}
-
+
/**
* Get an optional string associated with a key. It returns an empty string if there is no such key. If the value is
* not a string and is not null, then it is converted to a string.
@@ -1088,7 +1070,7 @@ public class JSONObject {
public String optString(final String key) {
return this.optString(key, "");
}
-
+
/**
* Get an optional string associated with a key. It returns the defaultValue if there is no such key.
*
@@ -1101,14 +1083,11 @@ public class JSONObject {
final Object object = this.opt(key);
return NULL.equals(object) ? defaultValue : object.toString();
}
-
+
private void populateMap(final Object bean) {
final Class klass = bean.getClass();
-
// If klass is a System class then set includeSuperClass to false.
-
final boolean includeSuperClass = klass.getClassLoader() != null;
-
final Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
for (final Method method : methods) {
try {
@@ -1130,7 +1109,6 @@ public class JSONObject {
} else if (!Character.isUpperCase(key.charAt(1))) {
key = key.substring(0, 1).toLowerCase() + key.substring(1);
}
-
final Object result = method.invoke(bean, (Object[]) null);
if (result != null) {
this.map.put(key, wrap(result));
@@ -1141,7 +1119,7 @@ public class JSONObject {
}
}
}
-
+
/**
* Put a key/boolean pair in the JSONObject.
*
@@ -1156,7 +1134,7 @@ public class JSONObject {
this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
return this;
}
-
+
/**
* Put a key/value pair in the JSONObject, where the value will be a JSONArray which is produced from a Collection.
*
@@ -1171,7 +1149,7 @@ public class JSONObject {
this.put(key, new JSONArray(value));
return this;
}
-
+
/**
* Put a key/double pair in the JSONObject.
*
@@ -1186,7 +1164,7 @@ public class JSONObject {
this.put(key, new Double(value));
return this;
}
-
+
/**
* Put a key/int pair in the JSONObject.
*
@@ -1201,7 +1179,7 @@ public class JSONObject {
this.put(key, new Integer(value));
return this;
}
-
+
/**
* Put a key/long pair in the JSONObject.
*
@@ -1216,7 +1194,7 @@ public class JSONObject {
this.put(key, new Long(value));
return this;
}
-
+
/**
* Put a key/value pair in the JSONObject, where the value will be a JSONObject which is produced from a Map.
*
@@ -1231,7 +1209,7 @@ public class JSONObject {
this.put(key, new JSONObject(value));
return this;
}
-
+
/**
* Put a key/value pair in the JSONObject. If the value is null, then the key will be removed from the JSONObject if
* it is present.
@@ -1256,7 +1234,7 @@ public class JSONObject {
}
return this;
}
-
+
/**
* Put a key/value pair in the JSONObject, but only if the key and the value are both non-null, and only if there is
* not already a member with that name.
@@ -1277,7 +1255,7 @@ public class JSONObject {
}
return this;
}
-
+
/**
* Put a key/value pair in the JSONObject, but only if the key and the value are both non-null.
*
@@ -1295,7 +1273,7 @@ public class JSONObject {
}
return this;
}
-
+
/**
* Remove a name and its value, if present.
*
@@ -1306,7 +1284,7 @@ public class JSONObject {
public Object remove(final String key) {
return this.map.remove(key);
}
-
+
/**
* Determine if two JSONObjects are similar. They must contain the same set of names which must be associated with
* similar values.
@@ -1344,7 +1322,7 @@ public class JSONObject {
return false;
}
}
-
+
/**
* Produce a JSONArray containing the values of the members of this JSONObject.
*
@@ -1365,7 +1343,7 @@ public class JSONObject {
}
return ja;
}
-
+
/**
* Make a JSON text of this JSONObject. For compactness, no whitespace is added. If this would not result in a
* syntactically correct JSON text, then null will be returned instead.
@@ -1384,7 +1362,7 @@ public class JSONObject {
return null;
}
}
-
+
/**
* Make a prettyprinted JSON text of this JSONObject.
*
@@ -1404,7 +1382,7 @@ public class JSONObject {
return this.write(w, indentFactor, 0).toString();
}
}
-
+
/**
* Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added.
*
@@ -1417,7 +1395,7 @@ public class JSONObject {
public Writer write(final Writer writer) throws JSONException {
return this.write(writer, 0, 0);
}
-
+
/**
* Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added.
*
@@ -1433,7 +1411,6 @@ public class JSONObject {
final int length = this.length();
final Iterator keys = this.keys();
writer.write('{');
-
if (length == 1) {
final Object key = keys.next();
writer.write(quote(key.toString()));
@@ -1472,13 +1449,12 @@ public class JSONObject {
throw new JSONException(exception);
}
}
-
+
/**
* JSONObject.NULL is equivalent to the value that JavaScript calls null, whilst Java's null is equivalent to the
* value that JavaScript calls undefined.
*/
private static final class Null {
-
/**
* There is only intended to be a single instance of the NULL object, so the clone method returns itself.
*
@@ -1492,7 +1468,7 @@ public class JSONObject {
return this;
}
}
-
+
/**
* A Null object is equal to the null value and to itself.
*
@@ -1504,7 +1480,7 @@ public class JSONObject {
public boolean equals(final Object object) {
return (object == null) || (object == this);
}
-
+
/**
* Get the "null" string value.
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java
index 053001408..d29ae0e46 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java
@@ -40,7 +40,7 @@ public class JSONStringer extends JSONWriter {
public JSONStringer() {
super(new StringWriter());
}
-
+
/**
* Return the JSON text. This method is used to obtain the product of the JSONStringer instance. It will return
* null
if there was a problem in the construction of the JSON text (such as the calls to
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java
index 7c465319a..62f0fa135 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java
@@ -15,7 +15,6 @@ import java.io.StringReader;
* @version 2014-05-03
*/
public class JSONTokener {
-
private final Reader reader;
private long character;
private boolean eof;
@@ -23,7 +22,7 @@ public class JSONTokener {
private long line;
private char previous;
private boolean usePrevious;
-
+
/**
* Construct a JSONTokener from a Reader.
*
@@ -38,7 +37,7 @@ public class JSONTokener {
this.character = 1;
this.line = 1;
}
-
+
/**
* Construct a JSONTokener from an InputStream.
*
@@ -47,7 +46,7 @@ public class JSONTokener {
public JSONTokener(final InputStream inputStream) throws JSONException {
this(new InputStreamReader(inputStream));
}
-
+
/**
* Construct a JSONTokener from a string.
*
@@ -56,7 +55,7 @@ public class JSONTokener {
public JSONTokener(final String s) {
this(new StringReader(s));
}
-
+
/**
* Get the hex value of a character (base16).
*
@@ -76,7 +75,7 @@ public class JSONTokener {
}
return -1;
}
-
+
/**
* Back up one character. This provides a sort of lookahead capability, so that you can test for a digit or letter
* before attempting to parse the next number or identifier.
@@ -90,11 +89,11 @@ public class JSONTokener {
this.usePrevious = true;
this.eof = false;
}
-
+
public boolean end() {
return this.eof && !this.usePrevious;
}
-
+
/**
* Determine if the source string still contains characters that next() can consume.
*
@@ -108,7 +107,7 @@ public class JSONTokener {
this.back();
return true;
}
-
+
/**
* Get the next character in the source string.
*
@@ -125,7 +124,6 @@ public class JSONTokener {
} catch (final IOException exception) {
throw new JSONException(exception);
}
-
if (c <= 0) { // End of stream
this.eof = true;
c = 0;
@@ -144,7 +142,7 @@ public class JSONTokener {
this.previous = (char) c;
return this.previous;
}
-
+
/**
* Consume the next character, and check that it matches a specified character.
*
@@ -161,7 +159,7 @@ public class JSONTokener {
}
return n;
}
-
+
/**
* Get the next n characters.
*
@@ -175,10 +173,8 @@ public class JSONTokener {
if (n == 0) {
return "";
}
-
final char[] chars = new char[n];
int pos = 0;
-
while (pos < n) {
chars[pos] = this.next();
if (this.end()) {
@@ -188,7 +184,7 @@ public class JSONTokener {
}
return new String(chars);
}
-
+
/**
* Get the next char in the string, skipping whitespace.
*
@@ -197,14 +193,14 @@ public class JSONTokener {
* @throws JSONException
*/
public char nextClean() throws JSONException {
- for (; ; ) {
+ for (;;) {
final char c = this.next();
if ((c == 0) || (c > ' ')) {
return c;
}
}
}
-
+
/**
* Return the characters up to the next close quote character. Backslash processing is done. The formal JSON format
* does not allow strings in single quotes, but an implementation is allowed to accept them.
@@ -219,7 +215,7 @@ public class JSONTokener {
public String nextString(final char quote) throws JSONException {
char c;
final StringBuilder sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
c = this.next();
switch (c) {
case 0:
@@ -265,7 +261,7 @@ public class JSONTokener {
}
}
}
-
+
/**
* Get the text up but not including the specified character or the end of line, whichever comes first.
*
@@ -275,7 +271,7 @@ public class JSONTokener {
*/
public String nextTo(final char delimiter) throws JSONException {
final StringBuilder sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
final char c = this.next();
if ((c == delimiter) || (c == 0) || (c == '\n') || (c == '\r')) {
if (c != 0) {
@@ -286,7 +282,7 @@ public class JSONTokener {
sb.append(c);
}
}
-
+
/**
* Get the text up but not including one of the specified delimiter characters or the end of line, whichever comes
* first.
@@ -298,7 +294,7 @@ public class JSONTokener {
public String nextTo(final String delimiters) throws JSONException {
char c;
final StringBuilder sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
c = this.next();
if ((delimiters.indexOf(c) >= 0) || (c == 0) || (c == '\n') || (c == '\r')) {
if (c != 0) {
@@ -309,7 +305,7 @@ public class JSONTokener {
sb.append(c);
}
}
-
+
/**
* Get the next value. The value can be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object.
@@ -321,7 +317,6 @@ public class JSONTokener {
public Object nextValue() throws JSONException {
char c = this.nextClean();
String string;
-
switch (c) {
case '"':
case '\'':
@@ -333,7 +328,6 @@ public class JSONTokener {
this.back();
return new JSONArray(this);
}
-
/*
* Handle unquoted text. This could be the values true, false, or
* null, or it can be a number. An implementation (such as this one)
@@ -341,21 +335,19 @@ public class JSONTokener {
* Accumulate characters until we reach the end of the text or a
* formatting character.
*/
-
final StringBuilder sb = new StringBuilder();
while ((c >= ' ') && (",:]}/\\\"[{;=#".indexOf(c) < 0)) {
sb.append(c);
c = this.next();
}
this.back();
-
string = sb.toString().trim();
if ("".equals(string)) {
throw this.syntaxError("Missing value");
}
return JSONObject.stringToValue(string);
}
-
+
/**
* Skip characters until the next character is the requested character. If the requested character is not found, no
* characters are skipped.
@@ -387,7 +379,7 @@ public class JSONTokener {
this.back();
return c;
}
-
+
/**
* Make a JSONException to signal a syntax error.
*
@@ -398,7 +390,7 @@ public class JSONTokener {
public JSONException syntaxError(final String message) {
return new JSONException(message + this.toString());
}
-
+
/**
* Make a printable string of this JSONTokener.
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java
index 7017db3d5..a332af1f8 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java
@@ -55,7 +55,7 @@ public class JSONWriter {
* The stack top index. A value of 0 indicates that the stack is empty.
*/
private int top;
-
+
/**
* Make a fresh JSONWriter. It can be used to build one JSON text.
*/
@@ -66,7 +66,7 @@ public class JSONWriter {
this.top = 0;
this.writer = w;
}
-
+
/**
* Append a value.
*
@@ -97,7 +97,7 @@ public class JSONWriter {
}
throw new JSONException("Value out of sequence.");
}
-
+
/**
* Begin appending a new array. All values until the balancing endArray
will be appended to this array.
* The endArray
method must be called to mark the array's end.
@@ -116,7 +116,7 @@ public class JSONWriter {
}
throw new JSONException("Misplaced array.");
}
-
+
/**
* End something.
*
@@ -140,7 +140,7 @@ public class JSONWriter {
this.comma = true;
return this;
}
-
+
/**
* End an array. This method most be called to balance calls to array
.
*
@@ -151,7 +151,7 @@ public class JSONWriter {
public JSONWriter endArray() throws JSONException {
return this.end('a', ']');
}
-
+
/**
* End an object. This method most be called to balance calls to object
.
*
@@ -162,7 +162,7 @@ public class JSONWriter {
public JSONWriter endObject() throws JSONException {
return this.end('k', '}');
}
-
+
/**
* Append a key. The key will be associated with the next value. In an object, every value must be preceded by a
* key.
@@ -195,7 +195,7 @@ public class JSONWriter {
}
throw new JSONException("Misplaced key.");
}
-
+
/**
* Begin appending a new object. All keys and values until the balancing endObject
will be appended to
* this object. The endObject
method must be called to mark the object's end.
@@ -216,9 +216,8 @@ public class JSONWriter {
return this;
}
throw new JSONException("Misplaced object.");
-
}
-
+
/**
* Pop an array or object scope.
*
@@ -237,7 +236,7 @@ public class JSONWriter {
this.top -= 1;
this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ? 'a' : 'k';
}
-
+
/**
* Push an array or object scope.
*
@@ -253,7 +252,7 @@ public class JSONWriter {
this.mode = jo == null ? 'a' : 'k';
this.top += 1;
}
-
+
/**
* Append either the value true
or the value false
.
*
@@ -266,7 +265,7 @@ public class JSONWriter {
public JSONWriter value(final boolean b) throws JSONException {
return this.append(b ? "true" : "false");
}
-
+
/**
* Append a double value.
*
@@ -279,7 +278,7 @@ public class JSONWriter {
public JSONWriter value(final double d) throws JSONException {
return this.value(new Double(d));
}
-
+
/**
* Append a long value.
*
@@ -292,7 +291,7 @@ public class JSONWriter {
public JSONWriter value(final long l) throws JSONException {
return this.append(Long.toString(l));
}
-
+
/**
* Append an object value.
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java
index 332b0083e..03520de0d 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java
@@ -27,7 +27,6 @@ package com.intellectualcrafters.json;
* @version 2013-04-18
*/
public class Kim {
-
/**
* The number of bytes in the kim. The number of bytes can be as much as three times the number of characters.
*/
@@ -44,7 +43,7 @@ public class Kim {
* The memoization of toString().
*/
private String string = null;
-
+
/**
* Make a kim from a portion of a byte array.
*
@@ -53,11 +52,9 @@ public class Kim {
* @param thru The index of the last byte plus one.
*/
public Kim(final byte[] bytes, final int from, final int thru) {
-
// As the bytes are copied into the new kim, a hashcode is computed
// using a
// modified Fletcher code.
-
int sum = 1;
int value;
this.hashcode = 0;
@@ -73,7 +70,7 @@ public class Kim {
this.hashcode += sum << 16;
}
}
-
+
/**
* Make a kim from a byte array.
*
@@ -83,7 +80,7 @@ public class Kim {
public Kim(final byte[] bytes, final int length) {
this(bytes, 0, length);
}
-
+
/**
* Make a new kim from a substring of an existing kim. The coordinates are in byte units, not character units.
*
@@ -94,7 +91,7 @@ public class Kim {
public Kim(final Kim kim, final int from, final int thru) {
this(kim.bytes, from, thru);
}
-
+
/**
* Make a kim from a string.
*
@@ -106,10 +103,8 @@ public class Kim {
final int stringLength = string.length();
this.hashcode = 0;
this.length = 0;
-
// First pass: Determine the length of the kim, allowing for the UTF-16
// to UTF-32 conversion, and then the UTF-32 to Kim conversion.
-
if (stringLength > 0) {
for (int i = 0; i < stringLength; i += 1) {
final int c = string.charAt(i);
@@ -128,11 +123,9 @@ public class Kim {
this.length += 3;
}
}
-
// Second pass: Allocate a byte array and fill that array with the
// conversion
// while computing the hashcode.
-
this.bytes = new byte[this.length];
int at = 0;
int b;
@@ -180,7 +173,7 @@ public class Kim {
this.hashcode += sum << 16;
}
}
-
+
/**
* Returns the number of bytes needed to contain the character in Kim format.
*
@@ -196,7 +189,7 @@ public class Kim {
}
return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3;
}
-
+
/**
* Returns the character at the specified index. The index refers to byte values and ranges from 0 to length - 1.
* The index of the next character is at index + Kim.characterSize(kim.characterAt(index)).
@@ -227,7 +220,7 @@ public class Kim {
}
throw new JSONException("Bad character at " + at);
}
-
+
/**
* Copy the contents of this kim to a byte array.
*
@@ -240,7 +233,7 @@ public class Kim {
System.arraycopy(this.bytes, 0, bytes, at, this.length);
return at + this.length;
}
-
+
/**
* Two kim objects containing exactly the same bytes in the same order are equal to each other.
*
@@ -262,7 +255,7 @@ public class Kim {
}
return java.util.Arrays.equals(this.bytes, that.bytes);
}
-
+
/**
* Get a byte from a kim.
*
@@ -278,7 +271,7 @@ public class Kim {
}
return (this.bytes[at]) & 0xFF;
}
-
+
/**
* Returns a hash code value for the kim.
*/
@@ -286,7 +279,7 @@ public class Kim {
public int hashCode() {
return this.hashcode;
}
-
+
/**
* Produce a UTF-16 String from this kim. The number of codepoints in the string will not be greater than the number
* of bytes in the kim, although it could be less.
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java
index d846ff117..a177df954 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.json;
import java.util.Enumeration;
@@ -52,7 +51,7 @@ public class Property {
}
return jo;
}
-
+
/**
* Converts the JSONObject into a property file object.
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java
index cd6ce153f..c14748a1c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java
@@ -9,52 +9,43 @@ import java.util.Iterator;
* @version 2014-05-03
*/
public class XML {
-
/**
* The Character '&'.
*/
public static final Character AMP = '&';
-
/**
* The Character '''.
*/
public static final Character APOS = '\'';
-
/**
* The Character '!'.
*/
public static final Character BANG = '!';
-
/**
* The Character '='.
*/
public static final Character EQ = '=';
-
/**
* The Character '>'.
*/
public static final Character GT = '>';
-
/**
* The Character '<'.
*/
public static final Character LT = '<';
-
/**
* The Character '?'.
*/
public static final Character QUEST = '?';
-
/**
* The Character '"'.
*/
public static final Character QUOT = '"';
-
/**
* The Character '/'.
*/
public static final Character SLASH = '/';
-
+
/**
* Replace special characters with XML escapes:
*
@@ -96,7 +87,7 @@ public class XML {
}
return sb.toString();
}
-
+
/**
* Throw an exception if the string contains whitespace. Whitespace is not allowed in tagNames and attributes.
*
@@ -116,7 +107,7 @@ public class XML {
}
}
}
-
+
/**
* Scan the content following the named tag, attaching it to the context.
*
@@ -135,7 +126,6 @@ public class XML {
String string;
String tagName;
Object token;
-
// Test for and skip past these forms:
//
//
@@ -145,11 +135,8 @@ public class XML {
// <>
// <=
// <<
-
token = x.nextToken();
-
// 0);
return false;
} else if (token == QUEST) {
-
//
-
x.skipPast("?>");
return false;
} else if (token == SLASH) {
-
// Close tag
-
token = x.nextToken();
if (name == null) {
throw x.syntaxError("Mismatched close tag " + token);
@@ -204,23 +187,18 @@ public class XML {
throw x.syntaxError("Misshaped close tag");
}
return true;
-
} else if (token instanceof Character) {
throw x.syntaxError("Misshaped tag");
-
// Open tag <
-
} else {
tagName = (String) token;
token = null;
jsonobject = new JSONObject();
- for (; ; ) {
+ for (;;) {
if (token == null) {
token = x.nextToken();
}
-
// attribute = value
-
if (token instanceof String) {
string = (String) token;
token = x.nextToken();
@@ -234,9 +212,7 @@ public class XML {
} else {
jsonobject.accumulate(string, "");
}
-
// Empty tag <.../>
-
} else if (token == SLASH) {
if (x.nextToken() != GT) {
throw x.syntaxError("Misshaped tag");
@@ -247,11 +223,9 @@ public class XML {
context.accumulate(tagName, "");
}
return false;
-
// Content, between <...> and
-
} else if (token == GT) {
- for (; ; ) {
+ for (;;) {
token = x.nextContent();
if (token == null) {
if (tagName != null) {
@@ -263,9 +237,7 @@ public class XML {
if (string.length() > 0) {
jsonobject.accumulate("content", XML.stringToValue(string));
}
-
// Nested element
-
} else if (token == LT) {
if (parse(x, jsonobject, tagName)) {
if (jsonobject.length() == 0) {
@@ -285,7 +257,7 @@ public class XML {
}
}
}
-
+
/**
* Try to convert a string into a number, boolean, or null. If the string can't be converted, return the string.
* This is much less ambitious than JSONObject.stringToValue, especially because it does not attempt to convert plus
@@ -305,11 +277,9 @@ public class XML {
if ("null".equalsIgnoreCase(string)) {
return JSONObject.NULL;
}
-
// If it might be a number, try converting it, first as a Long, and then
// as a
// Double. If that doesn't work, return the string.
-
try {
final char initial = string.charAt(0);
if ((initial == '-') || ((initial >= '0') && (initial <= '9'))) {
@@ -329,7 +299,7 @@ public class XML {
}
return string;
}
-
+
/**
* Convert a well-formed (but not necessarily valid) XML string into a JSONObject. Some information may be lost in
* this transformation because JSON is a data format and XML is a document format. XML uses elements, attributes,
@@ -352,7 +322,7 @@ public class XML {
}
return jo;
}
-
+
/**
* Convert a JSONObject into a well-formed, element-normal XML string.
*
@@ -365,7 +335,7 @@ public class XML {
public static String toString(final Object object) throws JSONException {
return toString(object, null);
}
-
+
/**
* Convert a JSONObject into a well-formed, element-normal XML string.
*
@@ -387,17 +357,13 @@ public class XML {
String string;
Object value;
if (object instanceof JSONObject) {
-
// Emit
-
if (tagName != null) {
sb.append('<');
sb.append(tagName);
sb.append('>');
}
-
// Loop thru the keys.
-
jo = (JSONObject) object;
keys = jo.keys();
while (keys.hasNext()) {
@@ -407,9 +373,7 @@ public class XML {
value = "";
}
string = value instanceof String ? (String) value : null;
-
// Emit content in body
-
if ("content".equals(key)) {
if (value instanceof JSONArray) {
ja = (JSONArray) value;
@@ -423,9 +387,7 @@ public class XML {
} else {
sb.append(escape(value.toString()));
}
-
// Emit an array of similar keys
-
} else if (value instanceof JSONArray) {
ja = (JSONArray) value;
length = ja.length();
@@ -447,27 +409,21 @@ public class XML {
sb.append('<');
sb.append(key);
sb.append("/>");
-
// Emit a new tag
-
} else {
sb.append(toString(value, key));
}
}
if (tagName != null) {
-
// Emit the close tag
-
sb.append("");
sb.append(tagName);
sb.append('>');
}
return sb.toString();
-
// XML does not have good support for arrays. If an array appears in
// a place
// where XML is lacking, synthesize an element.
-
} else {
if (object.getClass().isArray()) {
object = new JSONArray(object);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java
index ab1513a72..1431939c7 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java
@@ -7,12 +7,10 @@ package com.intellectualcrafters.json;
* @version 2014-05-03
*/
public class XMLTokener extends JSONTokener {
-
/**
* The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot.
*/
public static final java.util.HashMap entity;
-
static {
entity = new java.util.HashMap(8);
entity.put("amp", XML.AMP);
@@ -21,7 +19,7 @@ public class XMLTokener extends JSONTokener {
entity.put("lt", XML.LT);
entity.put("quot", XML.QUOT);
}
-
+
/**
* Construct an XMLTokener from a string.
*
@@ -30,7 +28,7 @@ public class XMLTokener extends JSONTokener {
public XMLTokener(final String s) {
super(s);
}
-
+
/**
* Get the text in the CDATA block.
*
@@ -42,7 +40,7 @@ public class XMLTokener extends JSONTokener {
char c;
int i;
final StringBuilder sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
c = next();
if (end()) {
throw syntaxError("Unclosed CDATA");
@@ -55,7 +53,7 @@ public class XMLTokener extends JSONTokener {
}
}
}
-
+
/**
* Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins
* a markup tag, and the content text between markup tags.
@@ -77,7 +75,7 @@ public class XMLTokener extends JSONTokener {
return XML.LT;
}
sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
if ((c == '<') || (c == 0)) {
back();
return sb.toString().trim();
@@ -90,7 +88,7 @@ public class XMLTokener extends JSONTokener {
c = next();
}
}
-
+
/**
* Return the next entity. These entities are translated to Characters: & ' > <
* "
.
@@ -103,7 +101,7 @@ public class XMLTokener extends JSONTokener {
*/
public Object nextEntity(final char ampersand) throws JSONException {
final StringBuilder sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
final char c = next();
if (Character.isLetterOrDigit(c) || (c == '#')) {
sb.append(Character.toLowerCase(c));
@@ -117,7 +115,7 @@ public class XMLTokener extends JSONTokener {
final Object object = entity.get(string);
return object != null ? object : ampersand + string + ";";
}
-
+
/**
* Returns the next XML meta token. This is used for skipping over and ...?> structures.
*
@@ -150,7 +148,7 @@ public class XMLTokener extends JSONTokener {
case '"':
case '\'':
q = c;
- for (; ; ) {
+ for (;;) {
c = next();
if (c == 0) {
throw syntaxError("Unterminated string");
@@ -160,7 +158,7 @@ public class XMLTokener extends JSONTokener {
}
}
default:
- for (; ; ) {
+ for (;;) {
c = next();
if (Character.isWhitespace(c)) {
return Boolean.TRUE;
@@ -181,7 +179,7 @@ public class XMLTokener extends JSONTokener {
}
}
}
-
+
/**
* Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these characters:
* / > = ! ?
or it may be a string wrapped in single quotes or double quotes, or it may be a name.
@@ -212,14 +210,12 @@ public class XMLTokener extends JSONTokener {
return XML.BANG;
case '?':
return XML.QUEST;
-
- // Quoted string
-
+ // Quoted string
case '"':
case '\'':
q = c;
sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
c = next();
if (c == 0) {
throw syntaxError("Unterminated string");
@@ -234,11 +230,9 @@ public class XMLTokener extends JSONTokener {
}
}
default:
-
// Name
-
sb = new StringBuilder();
- for (; ; ) {
+ for (;;) {
sb.append(c);
c = next();
if (Character.isWhitespace(c)) {
@@ -264,7 +258,7 @@ public class XMLTokener extends JSONTokener {
}
}
}
-
+
/**
* Skip characters until past the requested string. If it is not found, we are left at the end of the source with a
* result of false.
@@ -281,12 +275,10 @@ public class XMLTokener extends JSONTokener {
int offset = 0;
final int length = to.length();
final char[] circle = new char[length];
-
/*
* First fill the circle buffer with as many characters as are in the
* to string. If we reach an early end, bail.
*/
-
for (i = 0; i < length; i += 1) {
c = next();
if (c == 0) {
@@ -294,15 +286,11 @@ public class XMLTokener extends JSONTokener {
}
circle[i] = c;
}
-
/* We will loop, possibly for all of the remaining characters. */
-
- for (; ; ) {
+ for (;;) {
j = offset;
b = true;
-
/* Compare the circle buffer with the to string. */
-
for (i = 0; i < length; i += 1) {
if (circle[j] != to.charAt(i)) {
b = false;
@@ -313,15 +301,11 @@ public class XMLTokener extends JSONTokener {
j -= length;
}
}
-
/* If we exit the loop with b intact, then victory is ours. */
-
if (b) {
return true;
}
-
/* Get the next character. If there isn't one, then defeat is ours. */
-
c = next();
if (c == 0) {
return false;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
index deca2ddb5..4c690bbf6 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
@@ -2,9 +2,7 @@ package com.intellectualcrafters.plot;
import java.io.File;
import java.util.Arrays;
-
import net.milkbowl.vault.economy.Economy;
-
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@@ -20,7 +18,6 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
-
import com.intellectualcrafters.plot.commands.Buy;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.WE_Anywhere;
@@ -55,11 +52,10 @@ import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
-public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
-
+public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public static BukkitMain THIS = null;
public static PlotSquared MAIN = null;
-
+
// TODO restructure this
public static boolean hasPermission(final Player player, final String perm) {
if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) {
@@ -97,21 +93,18 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
// TODO restructure this
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
- Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot);
+ final Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot);
final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, bot);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
final Location location = PlotHelper.getPlotHome(bot.world, bot);
-
- int x = location.getX();
- int z = location.getZ();
-
-
+ final int x = location.getX();
+ final int z = location.getZ();
if ((x >= 29999999) || (x <= -29999999) || (z >= 299999999) || (z <= -29999999)) {
event.setCancelled(true);
return false;
}
- if (Settings.TELEPORT_DELAY == 0 || hasPermission(player, "plots.teleport.delay.bypass")) {
+ if ((Settings.TELEPORT_DELAY == 0) || hasPermission(player, "plots.teleport.delay.bypass")) {
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
BukkitUtil.teleportPlayer(player, location);
return true;
@@ -140,17 +133,17 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
}
@EventHandler
- public static void worldLoad(WorldLoadEvent event) {
+ public static void worldLoad(final WorldLoadEvent event) {
UUIDHandler.cacheAll();
}
-
+
@EventHandler
- public void PlayerCommand(PlayerCommandPreprocessEvent event) {
- String message = event.getMessage();
+ public void PlayerCommand(final PlayerCommandPreprocessEvent event) {
+ final String message = event.getMessage();
if (message.toLowerCase().startsWith("/plotme")) {
- Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe");
+ final Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe");
if (plotme == null) {
- Player player = event.getPlayer();
+ final Player player = event.getPlayer();
if (Settings.USE_PLOTME_ALIAS) {
player.performCommand(message.replace("/plotme", "plots"));
} else {
@@ -165,7 +158,6 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
public void onEnable() {
MAIN = new PlotSquared(this);
THIS = this;
-
if (Settings.METRICS) {
try {
final Metrics metrics = new Metrics(this);
@@ -177,7 +169,6 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
} else {
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
}
-
getServer().getPluginManager().registerEvents(this, this);
}
@@ -187,10 +178,10 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
MAIN = null;
THIS = null;
}
-
+
@Override
public void log(String message) {
- if (THIS == null || Bukkit.getServer().getConsoleSender() == null) {
+ if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) {
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message)));
} else {
message = ChatColor.translateAlternateColorCodes('&', message);
@@ -200,12 +191,12 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
Bukkit.getServer().getConsoleSender().sendMessage(message);
}
}
-
+
@Override
public void disable() {
onDisable();
}
-
+
@Override
public String getVersion() {
return this.getDescription().getVersion();
@@ -219,17 +210,17 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
plotCommand.setTabCompleter(command);
}
-
+
@Override
public File getDirectory() {
return getDataFolder();
}
-
+
@Override
public TaskManager getTaskManager() {
return new BukkitTaskManager();
}
-
+
@Override
public void runEntityTask() {
log(C.PREFIX.s() + "KillAllEntities started.");
@@ -279,24 +270,24 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
return new HybridGen(world);
}
- public static boolean checkVersion(int major, int minor, int minor2) {
+ public static boolean checkVersion(final int major, final int minor, final int minor2) {
try {
- String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
- int a = Integer.parseInt(version[0]);
- int b = Integer.parseInt(version[1]);
+ final String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
+ final int a = Integer.parseInt(version[0]);
+ final int b = Integer.parseInt(version[1]);
int c = 0;
if (version.length == 3) {
c = Integer.parseInt(version[2]);
}
- if (a > major || (a == major && b > minor) || (a == major && b == minor && c >= minor2)) {
+ if ((a > major) || ((a == major) && (b > minor)) || ((a == major) && (b == minor) && (c >= minor2))) {
return true;
}
return false;
- } catch (Exception e) {
+ } catch (final Exception e) {
return false;
}
}
-
+
@Override
public void registerPlayerEvents() {
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
@@ -304,23 +295,23 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
}
}
-
+
@Override
public void registerInventoryEvents() {
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
}
-
+
@Override
public void registerPlotPlusEvents() {
PlotPlusListener.startRunnable(this);
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
}
-
+
@Override
public void registerForceFieldEvents() {
getServer().getPluginManager().registerEvents(new ForceFieldListener(), this);
}
-
+
@Override
public void registerWorldEditEvents() {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
@@ -336,7 +327,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
}
}
}
-
+
@Override
public Economy getEconomy() {
if ((getServer().getPluginManager().getPlugin("Vault") != null) && getServer().getPluginManager().getPlugin("Vault").isEnabled()) {
@@ -348,22 +339,20 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
}
return null;
}
-
+
@Override
public void initSetBlockManager() {
if (checkVersion(1, 8, 0)) {
try {
SetBlockManager.setBlockManager = new SetBlockFast_1_8();
- }
- catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
SetBlockManager.setBlockManager = new SetBlockSlow();
}
- }
- else {
+ } else {
try {
SetBlockManager.setBlockManager = new SetBlockFast();
- } catch (Throwable e) {
+ } catch (final Throwable e) {
SetBlockManager.setBlockManager = new SetBlockSlow();
}
}
@@ -374,7 +363,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
PlotHelper.canSendChunk = false;
}
}
-
+
@Override
public boolean initPlotMeConverter() {
try {
@@ -387,19 +376,19 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
}
return false;
}
-
+
@Override
- public void getGenerator(String world, String name) {
- Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
- if (gen_plugin != null && gen_plugin.isEnabled()) {
+ public void getGenerator(final String world, final String name) {
+ final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
+ if ((gen_plugin != null) && gen_plugin.isEnabled()) {
gen_plugin.getDefaultWorldGenerator(world, "");
} else {
new HybridGen(world);
}
}
-
+
@Override
- public boolean callRemovePlot(String world, PlotId id) {
+ public boolean callRemovePlot(final String world, final PlotId id) {
final PlotDeleteEvent event = new PlotDeleteEvent(world, id);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java
index 3129a48ec..dba352914 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java
@@ -41,4 +41,4 @@ public interface IPlotMain {
public void getGenerator(String world, String name);
public boolean callRemovePlot(String world, PlotId id);
-}
\ No newline at end of file
+}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java
index 18c9daee5..17998101c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java
@@ -36,9 +36,11 @@ import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.FlagValue;
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
+import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.SquarePlotManager;
+import com.intellectualcrafters.plot.generator.SquarePlotWorld;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotCluster;
@@ -56,19 +58,14 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
public class PlotSquared {
-
public static final String MAIN_PERMISSION = "plots.use";
public static final String ADMIN_PERMISSION = "plots.admin";
-
public static File styleFile;
public static YamlConfiguration style;
-
public static File configFile;
public static YamlConfiguration config;
-
public static File storageFile;
public static YamlConfiguration storage;
-
public static PlotSquared THIS = null; // This class
public static IPlotMain IMP = null; // Specific implementation of PlotSquared
public static String VERSION = null;
@@ -76,11 +73,9 @@ public class PlotSquared {
private static boolean LOADING_WORLD = false;
public static Economy economy = null;
public static WorldEditPlugin worldEdit = null;
-
private final static HashMap plotworlds = new HashMap<>();
private final static HashMap plotmanagers = new HashMap<>();
private static LinkedHashMap> plots;
-
private static MySQL mySQL;
public static Connection connection;
@@ -190,10 +185,9 @@ public class PlotSquared {
}
plots.get(world).remove(id);
if (PlotHelper.lastPlot.containsKey(world)) {
- PlotId last = PlotHelper.lastPlot.get(world);
- int last_max = Math.max(last.x, last.y);
- int this_max = Math.max(id.x, id.y);
-
+ final PlotId last = PlotHelper.lastPlot.get(world);
+ final int last_max = Math.max(last.x, last.y);
+ final int this_max = Math.max(id.x, id.y);
if (this_max < last_max) {
PlotHelper.lastPlot.put(world, id);
}
@@ -205,16 +199,13 @@ public class PlotSquared {
if (getWorldSettings(world) != null) {
return;
}
-
final Set worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet());
-
final PlotWorld plotWorld;
final PlotGenerator plotGenerator;
final PlotManager plotManager;
final String path = "worlds." + world;
-
if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) {
- plotGenerator = (PlotGenerator) generator;
+ plotGenerator = generator;
plotWorld = plotGenerator.getNewPlotWorld(world);
plotManager = plotGenerator.getPlotManager();
if (!world.equals("CheckingPlotSquaredGenerator")) {
@@ -243,14 +234,13 @@ public class PlotSquared {
if (!LOADING_WORLD) {
LOADING_WORLD = true;
try {
- String gen_string = config.getString("worlds." + world + "." + "generator.plugin");
+ final String gen_string = config.getString("worlds." + world + "." + "generator.plugin");
if (gen_string == null) {
new HybridGen(world);
- }
- else {
+ } else {
IMP.getGenerator(world, gen_string);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
log("&d=== Oh no! Please set the generator for the " + world + " ===");
e.printStackTrace();
LOADING_WORLD = false;
@@ -259,7 +249,7 @@ public class PlotSquared {
LOADING_WORLD = false;
}
} else {
- PlotGenerator gen_class = (PlotGenerator) generator;
+ final PlotGenerator gen_class = generator;
plotWorld = gen_class.getNewPlotWorld(world);
plotManager = gen_class.getPlotManager();
if (!config.contains(path)) {
@@ -274,14 +264,14 @@ public class PlotSquared {
} catch (final IOException e) {
e.printStackTrace();
}
- if ((plotWorld.TYPE == 2 && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) {
+ if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) {
log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!");
return;
}
addPlotWorld(world, plotWorld, plotManager);
if (plotWorld.TYPE == 2) {
if (ClusterManager.getClusters(world).size() > 0) {
- for (PlotCluster cluster : ClusterManager.getClusters(world)) {
+ for (final PlotCluster cluster : ClusterManager.getClusters(world)) {
new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
}
}
@@ -292,65 +282,63 @@ public class PlotSquared {
}
}
- public static boolean setupPlotWorld(String world, String id) {
- if (id != null && id.length() > 0) {
+ public static boolean setupPlotWorld(final String world, final String id) {
+ if ((id != null) && (id.length() > 0)) {
// save configuration
- String[] split = id.split(",");
- HybridPlotWorld plotworld = new HybridPlotWorld(world);
-
- int width = HybridPlotWorld.PLOT_WIDTH_DEFAULT;
- int gap = HybridPlotWorld.ROAD_WIDTH_DEFAULT;
- int height = HybridPlotWorld.PLOT_HEIGHT_DEFAULT;
- PlotBlock[] floor = HybridPlotWorld.TOP_BLOCK_DEFAULT;
- PlotBlock[] main = HybridPlotWorld.MAIN_BLOCK_DEFAULT;
- PlotBlock wall = HybridPlotWorld.WALL_FILLING_DEFAULT;
- PlotBlock border = HybridPlotWorld.WALL_BLOCK_DEFAULT;
-
- for (String element : split) {
- String[] pair = element.split("=");
+ final String[] split = id.split(",");
+ final HybridPlotWorld plotworld = new HybridPlotWorld(world);
+ final int width = SquarePlotWorld.PLOT_WIDTH_DEFAULT;
+ final int gap = SquarePlotWorld.ROAD_WIDTH_DEFAULT;
+ final int height = ClassicPlotWorld.PLOT_HEIGHT_DEFAULT;
+ final PlotBlock[] floor = ClassicPlotWorld.TOP_BLOCK_DEFAULT;
+ final PlotBlock[] main = ClassicPlotWorld.MAIN_BLOCK_DEFAULT;
+ final PlotBlock wall = ClassicPlotWorld.WALL_FILLING_DEFAULT;
+ final PlotBlock border = ClassicPlotWorld.WALL_BLOCK_DEFAULT;
+ for (final String element : split) {
+ final String[] pair = element.split("=");
if (pair.length != 2) {
log("&cNo value provided for: &7" + element);
return false;
}
- String key = pair[0].toLowerCase();
- String value = pair[1];
+ final String key = pair[0].toLowerCase();
+ final String value = pair[1];
try {
switch (key) {
case "s":
case "size": {
- HybridPlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
+ SquarePlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
break;
}
case "g":
case "gap": {
- HybridPlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
+ SquarePlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
break;
}
case "h":
case "height": {
- HybridPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
- HybridPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
- HybridPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
+ ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
+ ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
+ ClassicPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
break;
}
case "f":
case "floor": {
- HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
+ ClassicPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
break;
}
case "m":
case "main": {
- HybridPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
+ ClassicPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
break;
}
case "w":
case "wall": {
- HybridPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
+ ClassicPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
break;
}
case "b":
case "border": {
- HybridPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
+ ClassicPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
break;
}
default: {
@@ -358,30 +346,28 @@ public class PlotSquared {
return false;
}
}
- }
- catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
log("&cInvalid value: &7" + value + " in arg " + element);
return false;
}
}
try {
- String root = "worlds." + world;
+ final String root = "worlds." + world;
if (!config.contains(root)) {
config.createSection(root);
}
plotworld.saveConfiguration(config.getConfigurationSection(root));
- HybridPlotWorld.PLOT_HEIGHT_DEFAULT = height;
- HybridPlotWorld.ROAD_HEIGHT_DEFAULT = height;
- HybridPlotWorld.WALL_HEIGHT_DEFAULT = height;
- HybridPlotWorld.TOP_BLOCK_DEFAULT = floor;
- HybridPlotWorld.MAIN_BLOCK_DEFAULT = main;
- HybridPlotWorld.WALL_BLOCK_DEFAULT = border;
- HybridPlotWorld.WALL_FILLING_DEFAULT = wall;
- HybridPlotWorld.PLOT_WIDTH_DEFAULT = width;
- HybridPlotWorld.ROAD_WIDTH_DEFAULT = gap;
- }
- catch (Exception e) {
+ ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = height;
+ ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = height;
+ ClassicPlotWorld.WALL_HEIGHT_DEFAULT = height;
+ ClassicPlotWorld.TOP_BLOCK_DEFAULT = floor;
+ ClassicPlotWorld.MAIN_BLOCK_DEFAULT = main;
+ ClassicPlotWorld.WALL_BLOCK_DEFAULT = border;
+ ClassicPlotWorld.WALL_FILLING_DEFAULT = wall;
+ SquarePlotWorld.PLOT_WIDTH_DEFAULT = width;
+ SquarePlotWorld.ROAD_WIDTH_DEFAULT = gap;
+ } catch (final Exception e) {
e.printStackTrace();
}
}
@@ -392,14 +378,12 @@ public class PlotSquared {
return connection;
}
- public PlotSquared(IPlotMain imp_class) {
+ public PlotSquared(final IPlotMain imp_class) {
THIS = this;
IMP = imp_class;
VERSION = IMP.getVersion();
-
C.setupTranslations();
C.saveTranslations();
-
if (getJavaVersion() < 1.7) {
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
// Didn't know of any other link :D
@@ -410,7 +394,6 @@ public class PlotSquared {
if (getJavaVersion() < 1.8) {
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
}
-
TASK = IMP.getTaskManager();
if (Settings.KILL_ROAD_MOBS) {
IMP.runEntityTask();
@@ -418,11 +401,9 @@ public class PlotSquared {
if (C.ENABLED.s().length() > 0) {
log(C.ENABLED.s());
}
-
setupConfigs();
setupDefaultFlags();
setupDatabase();
-
// Events
IMP.registerCommands();
IMP.registerPlayerEvents();
@@ -430,10 +411,8 @@ public class PlotSquared {
IMP.registerPlotPlusEvents();
IMP.registerForceFieldEvents();
IMP.registerWorldEditEvents();
-
// Set block
IMP.initSetBlockManager();
-
// PlotMe
TaskManager.runTaskLater(new Runnable() {
@Override
@@ -447,11 +426,9 @@ public class PlotSquared {
}
}
}, 200);
-
if (Settings.AUTO_CLEAR) {
ExpireManager.runTask();
}
-
economy = IMP.getEconomy();
}
@@ -466,7 +443,7 @@ public class PlotSquared {
}
}
- public static void log(String message) {
+ public static void log(final String message) {
IMP.log(message);
}
@@ -474,10 +451,9 @@ public class PlotSquared {
final String[] tables;
if (Settings.ENABLE_CLUSTERS) {
MainCommand.subCommands.add(new Cluster());
- tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments", "cluster"};
- }
- else {
- tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"};
+ tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments", "cluster" };
+ } else {
+ tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" };
}
if (Settings.DB.USE_MYSQL) {
try {
@@ -515,12 +491,10 @@ public class PlotSquared {
if (Settings.ENABLE_CLUSTERS) {
ClusterManager.clusters = DBFunc.getClusters();
}
- }
- else if (Settings.DB.USE_MONGO) {
+ } else if (Settings.DB.USE_MONGO) {
// DBFunc.dbManager = new MongoManager();
log(C.PREFIX.s() + "MongoDB is not yet implemented");
- }
- else if (Settings.DB.USE_SQLITE) {
+ } else if (Settings.DB.USE_SQLITE) {
try {
connection = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection();
{
@@ -554,8 +528,7 @@ public class PlotSquared {
IMP.disable();
return;
}
-
- }
+ }
public static void setupDefaultFlags() {
final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit");
@@ -571,31 +544,22 @@ public class PlotSquared {
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
}
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("hostile-attack", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("animal-interact", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("hanging-place", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("hanging-break", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("vehicle-use", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("vehicle-place", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("vehicle-break", new FlagValue.BooleanValue()));
-
FlagManager.addFlag(new AbstractFlag("place", new FlagValue.PlotBlockListValue()));
FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue()));
FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue()));
-
FlagManager.addFlag(new AbstractFlag("gamemode") {
@Override
public String parseValueRaw(final String value) {
@@ -616,17 +580,14 @@ public class PlotSquared {
return null;
}
}
-
+
@Override
public String getValueDesc() {
return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'";
}
});
-
FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue()));
-
FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue()));
-
FlagManager.addFlag(new AbstractFlag("weather") {
@Override
public String parseValueRaw(final String value) {
@@ -643,7 +604,7 @@ public class PlotSquared {
return null;
}
}
-
+
@Override
public String getValueDesc() {
return "Flag value must be weather type: 'clear' or 'rain'";
@@ -676,7 +637,6 @@ public class PlotSquared {
options.put("titles", Settings.TITLES);
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION);
-
for (final Entry node : options.entrySet()) {
if (!config.contains(node.getKey())) {
config.set(node.getKey(), node.getValue());
@@ -693,8 +653,7 @@ public class PlotSquared {
Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias");
Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled");
Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs");
- Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf"
- + "inding");
+ Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding");
Settings.METRICS = config.getBoolean("metrics");
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk");
@@ -707,13 +666,11 @@ public class PlotSquared {
Settings.MAX_PLOTS = 32767;
}
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
-
Settings.OFFLINE_MODE = config.getBoolean("UUID.offline");
Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk");
-
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
}
-
+
public static void setupConfigs() {
final File folder = new File(IMP.getDirectory() + File.separator + "config");
if (!folder.exists() && !folder.mkdirs()) {
@@ -788,44 +745,43 @@ public class PlotSquared {
}
public static void showDebug() {
- Settings.DB.USE_MYSQL = storage.getBoolean("mysql.use");
- Settings.DB.USER = storage.getString("mysql.user");
- Settings.DB.PASSWORD = storage.getString("mysql.password");
- Settings.DB.HOST_NAME = storage.getString("mysql.host");
- Settings.DB.PORT = storage.getString("mysql.port");
- Settings.DB.DATABASE = storage.getString("mysql.database");
- Settings.DB.USE_SQLITE = storage.getBoolean("sqlite.use");
- Settings.DB.SQLITE_DB = storage.getString("sqlite.db");
- Settings.DB.PREFIX = storage.getString("prefix");
- Settings.METRICS = config.getBoolean("metrics");
- Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
- Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
- Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
- Settings.API_URL = config.getString("uuid.api.location");
- Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
- Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
-
- C.COLOR_1 = ChatColor.getByChar(style.getString("color.1"));
- C.COLOR_2 = ChatColor.getByChar(style.getString("color.2"));
- C.COLOR_3 = ChatColor.getByChar(style.getString("color.3"));
- C.COLOR_4 = ChatColor.getByChar(style.getString("color.4"));
- if (Settings.DEBUG) {
- final Map settings = new HashMap<>();
- settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS);
- settings.put("Use Metrics", "" + Settings.METRICS);
- settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN);
- settings.put("Mob Pathfinding", "" + Settings.MOB_PATHFINDING);
- settings.put("DB Mysql Enabled", "" + Settings.DB.USE_MYSQL);
- settings.put("DB SQLite Enabled", "" + Settings.DB.USE_SQLITE);
- settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
- settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS);
- settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
- settings.put("API Location", "" + Settings.API_URL);
- for (final Entry setting : settings.entrySet()) {
- log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
+ Settings.DB.USE_MYSQL = storage.getBoolean("mysql.use");
+ Settings.DB.USER = storage.getString("mysql.user");
+ Settings.DB.PASSWORD = storage.getString("mysql.password");
+ Settings.DB.HOST_NAME = storage.getString("mysql.host");
+ Settings.DB.PORT = storage.getString("mysql.port");
+ Settings.DB.DATABASE = storage.getString("mysql.database");
+ Settings.DB.USE_SQLITE = storage.getBoolean("sqlite.use");
+ Settings.DB.SQLITE_DB = storage.getString("sqlite.db");
+ Settings.DB.PREFIX = storage.getString("prefix");
+ Settings.METRICS = config.getBoolean("metrics");
+ Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
+ Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
+ Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
+ Settings.API_URL = config.getString("uuid.api.location");
+ Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
+ Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
+ C.COLOR_1 = ChatColor.getByChar(style.getString("color.1"));
+ C.COLOR_2 = ChatColor.getByChar(style.getString("color.2"));
+ C.COLOR_3 = ChatColor.getByChar(style.getString("color.3"));
+ C.COLOR_4 = ChatColor.getByChar(style.getString("color.4"));
+ if (Settings.DEBUG) {
+ final Map settings = new HashMap<>();
+ settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS);
+ settings.put("Use Metrics", "" + Settings.METRICS);
+ settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN);
+ settings.put("Mob Pathfinding", "" + Settings.MOB_PATHFINDING);
+ settings.put("DB Mysql Enabled", "" + Settings.DB.USE_MYSQL);
+ settings.put("DB SQLite Enabled", "" + Settings.DB.USE_SQLITE);
+ settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
+ settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS);
+ settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
+ settings.put("API Location", "" + Settings.API_URL);
+ for (final Entry setting : settings.entrySet()) {
+ log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
+ }
}
}
- }
private static void setupStyle() {
style.set("version", VERSION);
@@ -840,11 +796,11 @@ public class PlotSquared {
}
}
}
-
+
public static double getJavaVersion() {
return Double.parseDouble(System.getProperty("java.specification.version"));
}
-
+
public static Set getPlotWorlds() {
return plotworlds.keySet();
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java
index a49188996..8fdceb51d 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import net.milkbowl.vault.economy.Economy;
@@ -45,7 +44,7 @@ public class Auto extends SubCommand {
public Auto() {
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true);
}
-
+
public static PlotId getNextPlot(final PlotId id, final int step) {
final int absX = Math.abs(id.x);
final int absY = Math.abs(id.y);
@@ -74,7 +73,7 @@ public class Auto extends SubCommand {
return new PlotId(id.x + 1, id.y);
}
}
-
+
// TODO auto claim a mega plot with schematic
@Override
public boolean execute(final Player plr, final String... args) {
@@ -121,7 +120,6 @@ public class Auto extends SubCommand {
// return false;
}
}
-
if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) {
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
return false;
@@ -161,42 +159,40 @@ public class Auto extends SubCommand {
}
// }
}
- String worldname = world.getName();
- PlotWorld plotworld = PlotSquared.getWorldSettings(worldname);
+ final String worldname = world.getName();
+ final PlotWorld plotworld = PlotSquared.getWorldSettings(worldname);
if (plotworld.TYPE == 2) {
- Location loc = BukkitUtil.getLocation(plr);
- Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
- if (plot == null) {
- return sendMessage(plr, C.NOT_IN_PLOT);
- }
- PlotCluster cluster = ClusterManager.getCluster(loc);
- // Must be standing in a cluster
- if (cluster == null) {
+ final Location loc = BukkitUtil.getLocation(plr);
+ final Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
+ if (plot == null) {
+ return sendMessage(plr, C.NOT_IN_PLOT);
+ }
+ final PlotCluster cluster = ClusterManager.getCluster(loc);
+ // Must be standing in a cluster
+ if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
}
- PlotId bot = cluster.getP1();
- PlotId top = cluster.getP2();
- PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
- PlotId id = new PlotId(0, 0);
- int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
- int max = width * width;
- //
- for (int i = 0; i <= max; i++) {
- PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
- Plot current = PlotHelper.getPlot(worldname, currentId);
- if (current != null && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
- Claim.claimPlot(plr, current, true, true);
- return true;
- }
- id = getNextPlot(id, 1);
- }
-
- // no free plots
- PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS);
- return false;
+ final PlotId bot = cluster.getP1();
+ final PlotId top = cluster.getP2();
+ 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 max = width * width;
+ //
+ for (int i = 0; i <= max; i++) {
+ final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
+ final Plot current = PlotHelper.getPlot(worldname, currentId);
+ if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
+ Claim.claimPlot(plr, current, true, true);
+ return true;
+ }
+ id = getNextPlot(id, 1);
+ }
+ // no free plots
+ PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS);
+ return false;
}
-
boolean br = false;
if ((size_x == 1) && (size_z == 1)) {
while (!br) {
@@ -239,12 +235,11 @@ public class Auto extends SubCommand {
PlotHelper.lastPlot.put(worldname, new PlotId(0, 0));
return true;
}
-
- public PlotId getLastPlot(String world) {
- if (PlotHelper.lastPlot == null || !PlotHelper.lastPlot.containsKey(world)) {
- PlotHelper.lastPlot.put(world, new PlotId(0,0));
- }
- return PlotHelper.lastPlot.get(world);
- }
+ public PlotId getLastPlot(final String world) {
+ if ((PlotHelper.lastPlot == null) || !PlotHelper.lastPlot.containsKey(world)) {
+ PlotHelper.lastPlot.put(world, new PlotId(0, 0));
+ }
+ return PlotHelper.lastPlot.get(world);
+ }
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java
index b55153375..31c43dcef 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Ban.java
@@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class Ban extends SubCommand {
-
public Ban() {
super(Command.BAN, "Alias for /plot denied add", "/plot ban [player]", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java
index 67a0d5798..c4d31f562 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import net.milkbowl.vault.economy.Economy;
@@ -42,32 +41,29 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class Buy extends SubCommand {
-
public Buy() {
super(Command.BUY, "Buy the plot you are standing on", "b", CommandCategory.CLAIMING, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlotSquared.useEconomy) {
return sendMessage(plr, C.ECON_DISABLED);
}
- World world = plr.getWorld();
+ final World world = plr.getWorld();
if (!PlotSquared.isPlotWorld(world)) {
return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
}
Plot plot;
if (args.length > 0) {
try {
- String[] split = args[0].split(";");
- PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
+ final String[] split = args[0].split(";");
+ final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
plot = PlotHelper.getPlot(world, id);
- }
- catch (Exception e) {
+ } catch (final Exception e) {
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
}
- }
- else {
+ } else {
plot = PlayerFunctions.getCurrentPlot(plr);
}
if (plot == null) {
@@ -82,16 +78,16 @@ public class Buy extends SubCommand {
if (plot.owner.equals(UUIDHandler.getUUID(plr))) {
return sendMessage(plr, C.CANNOT_BUY_OWN);
}
- Flag flag = FlagManager.getPlotFlag(plot, "price");
+ final Flag flag = FlagManager.getPlotFlag(plot, "price");
if (flag == null) {
return sendMessage(plr, C.NOT_FOR_SALE);
}
double initPrice = (double) flag.getValue();
double price = initPrice;
- PlotId id = plot.id;
- PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id;
- int size = PlayerFunctions.getPlotSelectionIds(id, id2).size();
- PlotWorld plotworld = PlotSquared.getWorldSettings(world);
+ final PlotId id = plot.id;
+ final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id;
+ final int size = PlayerFunctions.getPlotSelectionIds(id, id2).size();
+ final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
if (plotworld.USE_ECONOMY) {
price += plotworld.PLOT_PRICE * size;
initPrice += plotworld.SELL_PRICE * size;
@@ -104,7 +100,7 @@ public class Buy extends SubCommand {
economy.withdrawPlayer(plr, price);
sendMessage(plr, C.REMOVED_BALANCE, price + "");
economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
- Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
+ final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
if (owner != null) {
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java
index a33e0bf26..82ac5733c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import net.milkbowl.vault.economy.Economy;
@@ -41,19 +40,18 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class Claim extends SubCommand {
-
public Claim() {
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true);
}
-
+
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final boolean auto) {
return claimPlot(player, plot, teleport, "", auto);
}
-
+
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
- if (plot.hasOwner() || plot.settings.isMerged()) {
- return false;
- }
+ if (plot.hasOwner() || plot.settings.isMerged()) {
+ return false;
+ }
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
@@ -63,11 +61,9 @@ public class Claim extends SubCommand {
if (teleport) {
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
}
- World world = plot.world;
+ final World world = plot.world;
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
-
final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id);
-
if (plotworld.SCHEMATIC_ON_CLAIM) {
SchematicHandler.Schematic sch;
if (schematic.equals("")) {
@@ -85,7 +81,7 @@ public class Claim extends SubCommand {
}
return event.isCancelled();
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
String schematic = "";
@@ -124,7 +120,6 @@ public class Claim extends SubCommand {
}
}
}
-
return !claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java
index a1a4a127f..82e63b284 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.Bukkit;
@@ -34,11 +33,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Clear extends SubCommand {
-
public Clear() {
super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
@@ -66,7 +64,6 @@ public class Clear extends SubCommand {
}
return true;
}
-
if (!PlayerFunctions.isInPlot(plr)) {
return sendMessage(plr, C.NOT_IN_PLOT);
}
@@ -79,11 +76,8 @@ public class Clear extends SubCommand {
}
assert plot != null;
plot.clear(plr, false);
-
// sign
-
// wall
-
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java
index 1ba785605..5b25afe0c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clipboard.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -28,28 +27,22 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Clipboard extends SubCommand {
-
public Clipboard() {
super(Command.CLIPBOARD, "View information about your current copy", "clipboard", CommandCategory.INFO, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!currentSelection.containsKey(plr.getName())) {
return sendMessage(plr, C.NO_CLIPBOARD);
}
final PlotSelection selection = currentSelection.get(plr.getName());
-
final PlotId plotId = selection.getPlot().getId();
final int width = selection.getWidth();
final int total = selection.getBlocks().length;
-
String message = C.CLIPBOARD_INFO.s();
-
message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + "");
-
PlayerFunctions.sendMessage(plr, message);
-
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java
index b4753d0dd..7a5ee1227 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -47,21 +46,19 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Cluster extends SubCommand {
-
public Cluster() {
super(Command.CLUSTER, "Manage a plot cluster", "cluster", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
-
if (args.length == 0) {
// return arguments
PlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
return false;
}
- String sub = args[0].toLowerCase();
+ final String sub = args[0].toLowerCase();
switch (sub) {
case "l":
case "list": {
@@ -73,21 +70,18 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list");
return false;
}
- HashSet clusters = ClusterManager.getClusters(plr.getWorld());
+ final HashSet clusters = ClusterManager.getClusters(plr.getWorld());
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + "");
- for (PlotCluster cluster : clusters) {
+ for (final PlotCluster cluster : clusters) {
// Ignore unmanaged clusters
- String name = "'" + cluster.getName() + "' : " + cluster.toString();
+ final String name = "'" + cluster.getName() + "' : " + cluster.toString();
if (UUIDHandler.getUUID(plr).equals(cluster.owner)) {
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name);
- }
- else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) {
+ } else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) {
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name);
- }
- else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) {
+ } else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) {
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name);
- }
- else {
+ } else {
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString());
}
}
@@ -100,36 +94,36 @@ public class Cluster extends SubCommand {
return false;
}
if (args.length != 4) {
- PlotId id = ClusterManager.estimatePlotId(plr.getLocation());
+ final PlotId id = ClusterManager.estimatePlotId(plr.getLocation());
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create ");
PlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id);
return false;
}
// check pos1 / pos2
- PlotId pos1 = PlotHelper.parseId(args[2]);
- PlotId pos2 = PlotHelper.parseId(args[3]);
- if (pos1 == null || pos2 == null) {
+ final PlotId pos1 = PlotHelper.parseId(args[2]);
+ final PlotId pos2 = PlotHelper.parseId(args[3]);
+ if ((pos1 == null) || (pos2 == null)) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
return false;
}
// check if name is taken
- String name = args[1];
- for (PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) {
+ final String name = args[1];
+ for (final PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) {
if (name.equals(cluster.getName())) {
PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN);
- return false;
+ return false;
}
}
//check if overlap
- PlotClusterId id = new PlotClusterId(pos1, pos2);
- HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
- if (intersects.size() > 0 || pos2.x < pos1.x || pos2.y < pos1.y) {
+ final PlotClusterId id = new PlotClusterId(pos1, pos2);
+ final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
+ if ((intersects.size() > 0) || (pos2.x < pos1.x) || (pos2.y < pos1.y)) {
PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + "");
- return false;
+ return false;
}
// create cluster
- String world = plr.getWorld().getName();
- PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr));
+ final String world = plr.getWorld().getName();
+ final PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr));
cluster.settings.setAlias(name);
DBFunc.createCluster(world, cluster);
if (!ClusterManager.clusters.containsKey(world)) {
@@ -137,8 +131,8 @@ public class Cluster extends SubCommand {
}
ClusterManager.clusters.get(world).add(cluster);
// Add any existing plots to the current cluster
- for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
- PlotCluster current = ClusterManager.getCluster(plot);
+ for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
+ final PlotCluster current = ClusterManager.getCluster(plot);
if (cluster.equals(current) && !cluster.hasRights(plot.owner)) {
cluster.invited.add(plot.owner);
DBFunc.setInvited(world, cluster, plot.owner);
@@ -158,7 +152,7 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
return false;
}
- if (args.length != 1 && args.length != 2) {
+ if ((args.length != 1) && (args.length != 2)) {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
return false;
}
@@ -169,8 +163,7 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
return false;
}
- }
- else {
+ } else {
cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
@@ -183,23 +176,23 @@ public class Cluster extends SubCommand {
return false;
}
}
- PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld());
+ final PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld());
if (plotworld.TYPE == 2) {
- ArrayList toRemove = new ArrayList<>();
- for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
- PlotCluster other = ClusterManager.getCluster(plot);
+ final ArrayList toRemove = new ArrayList<>();
+ for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
+ final PlotCluster other = ClusterManager.getCluster(plot);
if (cluster.equals(other)) {
toRemove.add(plot);
}
}
- for (Plot plot : toRemove) {
+ for (final Plot plot : toRemove) {
DBFunc.delete(plot.world, plot);
}
}
DBFunc.delete(cluster);
if (plotworld.TYPE == 2) {
- for (Iterator iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) {
- BlockPopulator populator = iterator.next();
+ for (final Iterator iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) {
+ final BlockPopulator populator = iterator.next();
if (populator instanceof AugmentedPopulator) {
if (((AugmentedPopulator) populator).cluster.equals(cluster)) {
iterator.remove();
@@ -207,7 +200,7 @@ public class Cluster extends SubCommand {
}
}
}
- for (String set : ClusterManager.clusters.keySet()) {
+ for (final String set : ClusterManager.clusters.keySet()) {
}
ClusterManager.last = null;
ClusterManager.clusters.get(cluster.world).remove(cluster);
@@ -226,14 +219,14 @@ public class Cluster extends SubCommand {
return false;
}
// check pos1 / pos2
- PlotId pos1 = PlotHelper.parseId(args[1]);
- PlotId pos2 = PlotHelper.parseId(args[2]);
- if (pos1 == null || pos2 == null) {
+ final PlotId pos1 = PlotHelper.parseId(args[1]);
+ final PlotId pos2 = PlotHelper.parseId(args[2]);
+ if ((pos1 == null) || (pos2 == null)) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
return false;
}
// check if in cluster
- PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
+ final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
@@ -245,11 +238,11 @@ public class Cluster extends SubCommand {
}
}
//check if overlap
- PlotClusterId id = new PlotClusterId(pos1, pos2);
- HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
+ final PlotClusterId id = new PlotClusterId(pos1, pos2);
+ final HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
if (intersects.size() > 1) {
PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + "");
- return false;
+ return false;
}
// resize cluster
DBFunc.resizeCluster(cluster, id);
@@ -263,7 +256,7 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen");
return false;
}
- if (args.length != 1 && args.length != 2) {
+ if ((args.length != 1) && (args.length != 2)) {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]");
return false;
}
@@ -274,8 +267,7 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
return false;
}
- }
- else {
+ } else {
cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
@@ -292,8 +284,8 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.CLUSTER_REGENERATED);
return true;
}
- case "add":
- case "inv":
+ case "add":
+ case "inv":
case "invite": {
if (!BukkitMain.hasPermission(plr, "plots.cluster.invite")) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite");
@@ -304,7 +296,7 @@ public class Cluster extends SubCommand {
return false;
}
// check if in cluster
- PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
+ final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
@@ -316,7 +308,7 @@ public class Cluster extends SubCommand {
}
}
// check uuid
- UUID uuid = UUIDHandler.getUUID(args[1]);
+ final UUID uuid = UUIDHandler.getUUID(args[1]);
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
return false;
@@ -324,9 +316,9 @@ public class Cluster extends SubCommand {
if (!cluster.hasRights(uuid)) {
// add the user if not added
cluster.invited.add(uuid);
- String world = plr.getWorld().getName();
+ final String world = plr.getWorld().getName();
DBFunc.setInvited(world, cluster, uuid);
- Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
+ final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
if (player != null) {
PlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName());
}
@@ -345,7 +337,7 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick ");
return false;
}
- PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
+ final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
@@ -357,7 +349,7 @@ public class Cluster extends SubCommand {
}
}
// check uuid
- UUID uuid = UUIDHandler.getUUID(args[1]);
+ final UUID uuid = UUIDHandler.getUUID(args[1]);
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
return false;
@@ -373,14 +365,14 @@ public class Cluster extends SubCommand {
}
cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid);
- Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
+ final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
if (player != null) {
PlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
}
- for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
- PlotCluster current = ClusterManager.getCluster(plot);
- if (current != null && current.equals(cluster)) {
- String world = plr.getWorld().getName();
+ for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
+ final PlotCluster current = ClusterManager.getCluster(plot);
+ if ((current != null) && current.equals(cluster)) {
+ final String world = plr.getWorld().getName();
DBFunc.delete(world, plot);
}
}
@@ -393,7 +385,7 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
return false;
}
- if (args.length != 1 && args.length != 2) {
+ if ((args.length != 1) && (args.length != 2)) {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
return false;
}
@@ -404,15 +396,14 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
return false;
}
- }
- else {
+ } else {
cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
}
}
- UUID uuid = UUIDHandler.getUUID(plr);
+ final UUID uuid = UUIDHandler.getUUID(plr);
if (!cluster.hasRights(uuid)) {
PlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED);
return false;
@@ -428,10 +419,10 @@ public class Cluster extends SubCommand {
cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid);
PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
- for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
- PlotCluster current = ClusterManager.getCluster(plot);
- if (current != null && current.equals(cluster)) {
- String world = plr.getWorld().getName();
+ for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
+ final PlotCluster current = ClusterManager.getCluster(plot);
+ if ((current != null) && current.equals(cluster)) {
+ final String world = plr.getWorld().getName();
DBFunc.delete(world, plot);
}
}
@@ -448,12 +439,12 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers ");
return false;
}
- PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
+ final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
}
- UUID uuid = UUIDHandler.getUUID(args[2]);
+ final UUID uuid = UUIDHandler.getUUID(args[2]);
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
return false;
@@ -480,12 +471,12 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp ");
return false;
}
- PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]);
+ final PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]);
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
return false;
}
- UUID uuid = UUIDHandler.getUUID(plr);
+ final UUID uuid = UUIDHandler.getUUID(plr);
if (!cluster.hasRights(uuid)) {
if (!BukkitMain.hasPermission(plr, "plots.cluster.tp.other")) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
@@ -503,7 +494,7 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
return false;
}
- if (args.length != 1 && args.length != 2) {
+ if ((args.length != 1) && (args.length != 2)) {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]");
return false;
}
@@ -514,30 +505,27 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
return false;
}
- }
- else {
+ } else {
cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
}
}
- String id = cluster.toString();
+ final String id = cluster.toString();
String owner = UUIDHandler.getName(cluster.owner);
if (owner == null) {
owner = "unknown";
}
- String name = cluster.getName();
- String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1);
- String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + "";
-
+ 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 rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + "";
String message = C.CLUSTER_INFO.s();
message = message.replaceAll("%id%", id);
message = message.replaceAll("%owner%", owner);
message = message.replaceAll("%name%", name);
message = message.replaceAll("%size%", size);
message = message.replaceAll("%rights%", rights);
-
PlayerFunctions.sendMessage(plr, message);
return true;
}
@@ -548,11 +536,11 @@ public class Cluster extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
return false;
}
- if (args.length != 1 && args.length != 2) {
+ if ((args.length != 1) && (args.length != 2)) {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome");
return false;
}
- PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
+ final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
if (cluster == null) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
return false;
@@ -563,10 +551,10 @@ public class Cluster extends SubCommand {
return false;
}
}
- Location base = ClusterManager.getClusterBottom(cluster);
+ final Location base = ClusterManager.getClusterBottom(cluster);
base.setY(0);
- Location relative = plr.getLocation().subtract(base);
- BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
+ final Location relative = plr.getLocation().subtract(base);
+ final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
cluster.settings.setPosition(blockloc);
DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ());
return PlayerFunctions.sendMessage(plr, C.POSITION_SET);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java
index 48c3b8a8c..5ed37a89b 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
/**
@@ -28,7 +27,6 @@ package com.intellectualcrafters.plot.commands;
* @author Empire92
*/
public enum Command {
-
// TODO new commands
// (economy)
// - /plot buy
@@ -39,7 +37,7 @@ public enum Command {
FLAG("flag", "f"),
TARGET("target"),
CLUSTER("cluster", "clusters"),
- BUY("buy","b"),
+ BUY("buy", "b"),
CREATEROADSCHEMATIC("createroadschematic"),
DEBUGROADREGEN("debugroadregen"),
DEBUGFIXFLAGS("debugfixflags"),
@@ -77,22 +75,19 @@ public enum Command {
UNBAN("unban", "unblock"),
DATABASE("database", "convert"),
TP("tp", "tp");
-
/**
* Command
*/
private final String command;
-
/**
* Alias
*/
private final String alias;
-
/**
* Permission Node
*/
private final CommandPermission permission;
-
+
/**
* @param command Command "name" (/plot [cmd])
*/
@@ -101,7 +96,7 @@ public enum Command {
this.alias = command;
this.permission = new CommandPermission("plots." + command);
}
-
+
/**
* @param command Command "name" (/plot [cmd])
* @param permission Command Permission Node
@@ -111,7 +106,7 @@ public enum Command {
this.permission = permission;
this.alias = command;
}
-
+
/**
* @param command Command "name" (/plot [cmd])
* @param alias Command Alias
@@ -121,7 +116,7 @@ public enum Command {
this.alias = alias;
this.permission = new CommandPermission("plots." + command);
}
-
+
/**
* @param command Command "name" (/plot [cmd])
* @param alias Command Alias
@@ -132,21 +127,21 @@ public enum Command {
this.alias = alias;
this.permission = permission;
}
-
+
/**
* @return command
*/
public String getCommand() {
return this.command;
}
-
+
/**
* @return alias
*/
public String getAlias() {
return this.alias;
}
-
+
/**
* @return permission object
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java
index f104798a3..b93041ab4 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -31,19 +30,18 @@ import com.intellectualcrafters.plot.BukkitMain;
* @author Citymonstret
*/
public class CommandPermission {
-
/**
* Permission Node
*/
public final String permission;
-
+
/**
* @param permission Command Permission
*/
public CommandPermission(final String permission) {
this.permission = permission.toLowerCase();
}
-
+
/**
* @param player Does the player have the permission?
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java
index f05d92945..927a5f2db 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
@@ -35,11 +34,10 @@ import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Comment extends SubCommand {
-
public Comment() {
super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
@@ -49,11 +47,8 @@ public class Comment extends SubCommand {
if (!plot.hasOwner()) {
return sendMessage(plr, C.NOT_IN_PLOT);
}
-
final List recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone");
-
if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) {
-
if (BukkitMain.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) {
final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " ");
final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase()));
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java
index db047b480..8927ac563 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -40,27 +39,25 @@ import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Condense extends SubCommand {
-
public static boolean TASK = false;
- private static int TASK_ID = 0;
public Condense() {
super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr != null) {
PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE));
return false;
}
- if (args.length != 2 && args.length != 3) {
+ if ((args.length != 2) && (args.length != 3)) {
PlayerFunctions.sendMessage(plr, "/plot condense [radius]");
return false;
}
- String worldname = args[0];
+ final String worldname = args[0];
final World world = Bukkit.getWorld(worldname);
- if (world == null || !PlotSquared.isPlotWorld(worldname)) {
+ if ((world == null) || !PlotSquared.isPlotWorld(worldname)) {
PlayerFunctions.sendMessage(plr, "INVALID WORLD");
return false;
}
@@ -82,19 +79,19 @@ public class Condense extends SubCommand {
PlayerFunctions.sendMessage(plr, "INVALID RADIUS");
return false;
}
- int radius = Integer.parseInt(args[2]);
- Collection plots = PlotSquared.getPlots(worldname).values();
- int size = plots.size();
- int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1);
+ final int radius = Integer.parseInt(args[2]);
+ final Collection plots = PlotSquared.getPlots(worldname).values();
+ final int size = plots.size();
+ final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
if (radius < minimum_radius) {
PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL");
return false;
}
final List to_move = new ArrayList<>(getPlots(plots, radius));
final List free = new ArrayList<>();
- PlotId start = new PlotId(0,0);
- while (start.x <= minimum_radius && start.y <= minimum_radius) {
- Plot plot = PlotHelper.getPlot(world, start);
+ PlotId start = new PlotId(0, 0);
+ while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
+ final Plot plot = PlotHelper.getPlot(world, start);
if (!plot.hasOwner()) {
free.add(plot.id);
}
@@ -110,25 +107,25 @@ public class Condense extends SubCommand {
to_move.remove(0);
free.remove(0);
int index = 0;
- for (PlotId id : to_move) {
- Plot plot = PlotHelper.getPlot(world, id);
+ for (final PlotId id : to_move) {
+ final Plot plot = PlotHelper.getPlot(world, id);
if (plot.hasOwner()) {
break;
}
index++;
}
- for (int i = 0; i plots = PlotSquared.getPlots(worldname).values();
- int size = plots.size();
- int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1);
+ final int radius = Integer.parseInt(args[2]);
+ final Collection plots = PlotSquared.getPlots(worldname).values();
+ final int size = plots.size();
+ final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
if (radius < minimum_radius) {
PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL");
return false;
}
- int max_move = getPlots(plots, minimum_radius).size();
- int user_move = getPlots(plots, radius).size();
+ final int max_move = getPlots(plots, minimum_radius).size();
+ final int user_move = getPlots(plots, radius).size();
PlayerFunctions.sendMessage(plr, "=== DEFAULT EVAL ===");
PlayerFunctions.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius);
PlayerFunctions.sendMessage(plr, "MAXIMUM MOVES: " + max_move);
@@ -192,10 +189,10 @@ public class Condense extends SubCommand {
return false;
}
- public Set getPlots(Collection plots, int radius) {
- HashSet outside = new HashSet<>();
- for (Plot plot : plots) {
- if (plot.id.x > radius || plot.id.x < -radius || plot.id.y > radius || plot.id.y < -radius) {
+ public Set getPlots(final Collection plots, final int radius) {
+ final HashSet outside = new HashSet<>();
+ for (final Plot plot : plots) {
+ if ((plot.id.x > radius) || (plot.id.x < -radius) || (plot.id.y > radius) || (plot.id.y < -radius)) {
outside.add(plot.id);
}
}
@@ -205,5 +202,4 @@ public class Condense extends SubCommand {
public static void sendMessage(final String message) {
PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message);
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java
index f04c6138c..595b6ec72 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -31,11 +30,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Copy extends SubCommand {
-
public Copy() {
super(Command.COPY, "Copy a plot", "copy", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java
index 514c87d0f..24b37bf43 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -32,31 +31,24 @@ import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class CreateRoadSchematic extends SubCommand {
-
public CreateRoadSchematic() {
super(Command.CREATEROADSCHEMATIC, "Add a road schematic to your world using the road around your current plot", "crs", CommandCategory.DEBUG, true);
}
-
+
@Override
public boolean execute(final Player player, final String... args) {
-
if (!PlayerFunctions.isInPlot(player)) {
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
return false;
}
-
if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) {
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
}
-
final Plot plot = PlayerFunctions.getCurrentPlot(player);
-
- HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
-
+ final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
manager.setupRoadSchematic(plot);
PlotHelper.update(BukkitUtil.getLocation(entity));
PlayerFunctions.sendMessage(player, "&6Saved new road schematic");
-
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java
index 42e502f1f..884208be4 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DEOP.java
@@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class DEOP extends SubCommand {
-
public DEOP() {
super(Command.DEOP, "Alias for /plot trusted remove", "/plot deop [player]", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java
index 8f33c9a73..a610d6481 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java
@@ -24,13 +24,12 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class Database extends SubCommand {
-
- final String[] tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"};
-
+ final String[] tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" };
+
public Database() {
super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false);
}
-
+
private static boolean sendMessageU(final UUID uuid, final String msg) {
if (uuid == null) {
PlotSquared.log(msg);
@@ -44,7 +43,7 @@ public class Database extends SubCommand {
}
return true;
}
-
+
public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) {
final java.util.Set plots = PlotSquared.getPlots();
TaskManager.runTaskAsync(new Runnable() {
@@ -70,13 +69,13 @@ public class Database extends SubCommand {
}
});
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
return sendMessage(plr, "/plot database [sqlite/mysql]");
}
- final String type = new StringComparison(args[0], new String[]{"mysql", "sqlite"}).getBestMatch().toLowerCase();
+ final String type = new StringComparison(args[0], new String[] { "mysql", "sqlite" }).getBestMatch().toLowerCase();
switch (type) {
case "mysql":
if (args.length < 6) {
@@ -137,7 +136,7 @@ public class Database extends SubCommand {
}
return false;
}
-
+
private boolean sendMessage(final Player player, final String msg) {
if (player == null) {
PlotSquared.log(msg);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java
index 4e6b0bac1..12f78918c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.Bukkit;
@@ -33,11 +32,10 @@ import com.intellectualcrafters.plot.util.RUtils;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Debug extends SubCommand {
-
public Debug() {
super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
@@ -90,11 +88,11 @@ public class Debug extends SubCommand {
}
return true;
}
-
+
private String getSection(final String line, final String val) {
return line.replaceAll("%val%", val) + "\n";
}
-
+
private String getLine(final String line, final String var, final Object val) {
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n";
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java
index 0b71855b4..1e061579f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -50,16 +49,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class DebugClaimTest extends SubCommand {
-
public DebugClaimTest() {
super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false);
}
-
+
@SuppressWarnings("unused")
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
return claimPlot(player, plot, teleport, "");
}
-
+
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true);
Bukkit.getPluginManager().callEvent(event);
@@ -73,7 +71,7 @@ public class DebugClaimTest extends SubCommand {
}
return event.isCancelled();
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
@@ -84,13 +82,10 @@ public class DebugClaimTest extends SubCommand {
if ((world == null) || !PlotSquared.isPlotWorld(world)) {
return !PlayerFunctions.sendMessage(null, "&cInvalid plot world!");
}
-
PlotId min, max;
-
try {
final String[] split1 = args[1].split(";");
final String[] split2 = args[2].split(";");
-
min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]));
max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1]));
} catch (final Exception e) {
@@ -98,12 +93,9 @@ public class DebugClaimTest extends SubCommand {
}
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
-
final PlotManager manager = PlotSquared.getPlotManager(world);
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
-
final ArrayList plots = new ArrayList<>();
-
for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) {
final Plot plot = PlotHelper.getPlot(world, id);
final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id);
@@ -111,18 +103,14 @@ public class DebugClaimTest extends SubCommand {
PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id);
continue;
}
-
final Location loc = manager.getSignLoc(world, plotworld, plot);
-
final Chunk chunk = world.getChunkAt(loc);
-
if (!chunk.isLoaded()) {
final boolean result = chunk.load(false);
if (!result) {
continue;
}
}
-
final Block block = world.getBlockAt(loc);
if (block != null) {
if (block.getState() instanceof Sign) {
@@ -130,11 +118,8 @@ public class DebugClaimTest extends SubCommand {
String line = sign.getLine(2);
if ((line != null) && (line.length() > 2)) {
line = line.substring(2);
-
final BiMap map = UUIDHandler.getUuidMap();
-
UUID uuid = (map.get(new StringWrapper(line)));
-
if (uuid == null) {
for (final StringWrapper string : map.keySet()) {
if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
@@ -158,22 +143,17 @@ public class DebugClaimTest extends SubCommand {
}
}
}
-
if (plots.size() > 0) {
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
DBFunc.createPlots(plots);
DBFunc.createAllSettingsAndHelpers(plots);
-
for (final Plot plot : plots) {
PlotSquared.updatePlot(plot);
}
-
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
-
} else {
PlayerFunctions.sendMessage(null, "No plots were found for the given search.");
}
-
} else {
PlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.");
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java
index e4dc89bdf..214026a95 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.Bukkit;
@@ -38,11 +37,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class DebugClear extends SubCommand {
-
public DebugClear() {
super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
@@ -62,9 +60,9 @@ public class DebugClear extends SubCommand {
if (plot == null) {
PlotSquared.log("Could not find plot " + args[0] + " in world " + world);
} else {
- World bukkitWorld = Bukkit.getWorld(world);
- Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
- Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
+ final World bukkitWorld = Bukkit.getWorld(world);
+ final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
+ final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
if (PlotHelper.runners.containsKey(plot)) {
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
return false;
@@ -84,7 +82,6 @@ public class DebugClear extends SubCommand {
}
return true;
}
-
if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getWorldSettings(plr.getWorld()) instanceof SquarePlotWorld)) {
return sendMessage(plr, C.NOT_IN_PLOT);
}
@@ -96,9 +93,9 @@ public class DebugClear extends SubCommand {
return sendMessage(plr, C.NO_PLOT_PERMS);
}
assert plot != null;
- World bukkitWorld = plr.getWorld();
- Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
- Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
+ final World bukkitWorld = plr.getWorld();
+ final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
+ final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
if (PlotHelper.runners.containsKey(plot)) {
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
return false;
@@ -111,11 +108,8 @@ public class DebugClear extends SubCommand {
PlayerFunctions.sendMessage(plr, "&aDone!");
}
});
-
// sign
-
// wall
-
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
index e79c8edf4..dbccadcec 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.io.File;
@@ -46,100 +45,94 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class DebugExec extends SubCommand {
-
- private ArrayList chunks = null;
- private World world;
-
public DebugExec() {
- super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false);
+ super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player player, final String... args) {
- List allowed_params = Arrays.asList(new String[]{"stop-expire","start-expire", "show-expired", "update-expired", "seen", "trim-check"});
+ final List allowed_params = Arrays.asList(new String[] { "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check" });
if (args.length > 0) {
- String arg = args[0].toLowerCase();
- switch (arg) {
- case "stop-expire": {
- if (ExpireManager.task != -1) {
- Bukkit.getScheduler().cancelTask(ExpireManager.task);
- }
- else {
- return PlayerFunctions.sendMessage(null, "Task already halted");
- }
- ExpireManager.task = -1;
- return PlayerFunctions.sendMessage(null, "Cancelled task.");
- }
- case "start-expire": {
- if (ExpireManager.task == -1) {
- ExpireManager.runTask();
- }
- else {
- return PlayerFunctions.sendMessage(null, "Plot expiry task already started");
- }
- return PlayerFunctions.sendMessage(null, "Started plot expiry task");
- }
- case "update-expired": {
- if (args.length > 1) {
- World world = Bukkit.getWorld(args[1]);
- if (world == null) {
- return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]);
- }
- PlayerFunctions.sendMessage(null, "Updating expired plot list");
- ExpireManager.updateExpired(args[1]);
- return true;
- }
- return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired ");
- }
- case "show-expired": {
- if (args.length > 1) {
- World world = Bukkit.getWorld(args[1]);
- if (world == null || !ExpireManager.expiredPlots.containsKey(args[1])) {
- return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]);
- }
- PlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
- for (Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) {
- Plot plot = entry.getKey();
- Long stamp = entry.getValue();
- PlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) +" : " + stamp);
- }
- return true;
- }
- return PlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired ");
- }
- case "seen": {
- if (args.length != 2) {
- return PlayerFunctions.sendMessage(null, "Use /plot debugexec seen ");
- }
- UUID uuid = UUIDHandler.getUUID(args[1]);
- if (uuid == null) {
- return PlayerFunctions.sendMessage(null, "player not found: " + args[1]);
- }
- OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
- if (op == null || !op.hasPlayedBefore()) {
- return PlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]);
- }
- Timestamp stamp = new Timestamp(op.getLastPlayed());
- Date date = new Date(stamp.getTime());
- PlayerFunctions.sendMessage(null, "PLAYER: " + args[1]);
- PlayerFunctions.sendMessage(null, "UUID: " + uuid);
- PlayerFunctions.sendMessage(null, "Object: " + date.toGMTString());
- PlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString());
- PlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString());
- return true;
- }
- case "trim-check": {
- if (args.length != 2) {
- PlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check ");
- PlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim");
- return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run");
- }
- final World world = Bukkit.getWorld(args[1]);
- if (world == null || !PlotSquared.isPlotWorld(args[1])) {
- return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]);
+ final String arg = args[0].toLowerCase();
+ switch (arg) {
+ case "stop-expire": {
+ if (ExpireManager.task != -1) {
+ Bukkit.getScheduler().cancelTask(ExpireManager.task);
+ } else {
+ return PlayerFunctions.sendMessage(null, "Task already halted");
}
- final ArrayList empty = new ArrayList<>();
- boolean result = Trim.getTrimRegions(empty, world, new Runnable() {
+ ExpireManager.task = -1;
+ return PlayerFunctions.sendMessage(null, "Cancelled task.");
+ }
+ case "start-expire": {
+ if (ExpireManager.task == -1) {
+ ExpireManager.runTask();
+ } else {
+ return PlayerFunctions.sendMessage(null, "Plot expiry task already started");
+ }
+ return PlayerFunctions.sendMessage(null, "Started plot expiry task");
+ }
+ case "update-expired": {
+ if (args.length > 1) {
+ final World world = Bukkit.getWorld(args[1]);
+ if (world == null) {
+ return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]);
+ }
+ PlayerFunctions.sendMessage(null, "Updating expired plot list");
+ ExpireManager.updateExpired(args[1]);
+ return true;
+ }
+ return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired ");
+ }
+ case "show-expired": {
+ if (args.length > 1) {
+ final World world = Bukkit.getWorld(args[1]);
+ if ((world == null) || !ExpireManager.expiredPlots.containsKey(args[1])) {
+ return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]);
+ }
+ PlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
+ for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) {
+ final Plot plot = entry.getKey();
+ final Long stamp = entry.getValue();
+ PlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp);
+ }
+ return true;
+ }
+ return PlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired ");
+ }
+ case "seen": {
+ if (args.length != 2) {
+ return PlayerFunctions.sendMessage(null, "Use /plot debugexec seen ");
+ }
+ final UUID uuid = UUIDHandler.getUUID(args[1]);
+ if (uuid == null) {
+ return PlayerFunctions.sendMessage(null, "player not found: " + args[1]);
+ }
+ final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
+ if ((op == null) || !op.hasPlayedBefore()) {
+ return PlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]);
+ }
+ final Timestamp stamp = new Timestamp(op.getLastPlayed());
+ final Date date = new Date(stamp.getTime());
+ PlayerFunctions.sendMessage(null, "PLAYER: " + args[1]);
+ PlayerFunctions.sendMessage(null, "UUID: " + uuid);
+ PlayerFunctions.sendMessage(null, "Object: " + date.toGMTString());
+ PlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString());
+ PlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString());
+ return true;
+ }
+ case "trim-check": {
+ if (args.length != 2) {
+ PlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check ");
+ PlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim");
+ return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run");
+ }
+ final World world = Bukkit.getWorld(args[1]);
+ if ((world == null) || !PlotSquared.isPlotWorld(args[1])) {
+ return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]);
+ }
+ final ArrayList empty = new ArrayList<>();
+ final boolean result = Trim.getTrimRegions(empty, world, new Runnable() {
@Override
public void run() {
Trim.sendMessage("Processing is complete! Here's how many chunks would be deleted:");
@@ -150,13 +143,13 @@ public class DebugExec extends SubCommand {
PrintWriter writer;
try {
writer = new PrintWriter(file);
- String worldname = world.getName();
- for (ChunkLoc loc : empty) {
- writer.println(worldname +"/region/r." + loc.x + "." + loc.z +".mca" );
+ final String worldname = world.getName();
+ for (final ChunkLoc loc : empty) {
+ writer.println(worldname + "/region/r." + loc.x + "." + loc.z + ".mca");
}
writer.close();
Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'");
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
e.printStackTrace();
Trim.sendMessage("File failed to save! :(");
}
@@ -166,14 +159,14 @@ public class DebugExec extends SubCommand {
Trim.sendMessage(" - Add 31 to each number to get the end position");
}
});
- if (!result) {
- PlayerFunctions.sendMessage(null, "Trim task already started!");
- }
- return result;
- }
- }
+ if (!result) {
+ PlayerFunctions.sendMessage(null, "Trim task already started!");
+ }
+ return result;
+ }
+ }
}
- PlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">");
+ PlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">");
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java
index 86db84da9..8f740f6c1 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -38,11 +37,10 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class DebugFixFlags extends SubCommand {
-
public DebugFixFlags() {
super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr != null) {
@@ -53,22 +51,22 @@ public class DebugFixFlags extends SubCommand {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags ");
return false;
}
- World world = Bukkit.getWorld(args[0]);
- if (world == null || !PlotSquared.isPlotWorld(world)) {
+ final World world = Bukkit.getWorld(args[0]);
+ if ((world == null) || !PlotSquared.isPlotWorld(world)) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
return false;
}
PlayerFunctions.sendMessage(plr, "&8--- &6Starting task &8 ---");
- for (Plot plot : PlotSquared.getPlots(world).values()) {
- Set flags = plot.settings.flags;
- ArrayList toRemove = new ArrayList();
- for (Flag flag : flags) {
- AbstractFlag af = FlagManager.getFlag(flag.getKey());
+ for (final Plot plot : PlotSquared.getPlots(world).values()) {
+ final Set flags = plot.settings.flags;
+ final ArrayList toRemove = new ArrayList();
+ for (final Flag flag : flags) {
+ final AbstractFlag af = FlagManager.getFlag(flag.getKey());
if (af == null) {
toRemove.add(flag);
}
}
- for (Flag flag : toRemove) {
+ for (final Flag flag : toRemove) {
plot.settings.flags.remove(flag);
}
if (toRemove.size() > 0) {
@@ -76,7 +74,6 @@ public class DebugFixFlags extends SubCommand {
}
}
PlayerFunctions.sendMessage(plr, "&aDone!");
-
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java
index bcdcdbe9f..6c2ebfec8 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.lang.reflect.Field;
@@ -33,11 +32,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class DebugLoadTest extends SubCommand {
-
public DebugLoadTest() {
super(Command.DEBUGLOADTEST, "This debug command will force the reload of all plots in the DB", "debugloadtest", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java
index 512213e08..7d0af13c3 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
@@ -34,24 +33,22 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.SetBlockManager;
public class DebugRoadRegen extends SubCommand {
-
public DebugRoadRegen() {
super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true);
}
-
+
@Override
public boolean execute(final Player player, final String... args) {
if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) {
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
}
- HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
-
- Chunk chunk = BukkitUtil.getLocation(entity).getChunk();
- boolean result = manager.regenerateRoad(chunk);
+ final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
+ final Chunk chunk = BukkitUtil.getLocation(entity).getChunk();
+ final boolean result = manager.regenerateRoad(chunk);
if (result) {
- SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] {chunk}));
+ SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
}
- PlayerFunctions.sendMessage(player, "&6Regenerating chunk: "+chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
+ PlayerFunctions.sendMessage(player, "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java
index d9157f693..cfb5816ad 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -34,11 +33,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class DebugSaveTest extends SubCommand {
-
public DebugSaveTest() {
super(Command.DEBUGSAVETEST, "This debug command will force the recreation of all plots in the DB", "debugsavetest", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java
index 4165c9b7e..2fb966fa8 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import net.milkbowl.vault.economy.Economy;
@@ -35,11 +34,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Delete extends SubCommand {
-
public Delete() {
super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java
index 7f8de1f69..26a7980cc 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
@@ -34,12 +33,12 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
-@SuppressWarnings("deprecation") public class Denied extends SubCommand {
-
+@SuppressWarnings("deprecation")
+public class Denied extends SubCommand {
public Denied() {
super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 2) {
@@ -63,7 +62,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
UUID uuid;
if (args[1].equalsIgnoreCase("*")) {
uuid = DBFunc.everyone;
-
} else {
uuid = UUIDHandler.getUUID(args[1]);
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java
index 33094ce99..24165dfe2 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -40,11 +39,10 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class FlagCmd extends SubCommand {
-
public FlagCmd() {
super(Command.FLAG, "Manage plot flags", "f", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player player, final String... args) {
/*
@@ -58,7 +56,7 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag ");
return false;
}
- Plot plot = PlayerFunctions.getCurrentPlot(player);
+ final Plot plot = PlayerFunctions.getCurrentPlot(player);
if (plot == null) {
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
return false;
@@ -81,7 +79,7 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info ");
return false;
}
- AbstractFlag af = FlagManager.getFlag(args[1]);
+ final AbstractFlag af = FlagManager.getFlag(args[1]);
if (af == null) {
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info ");
@@ -104,7 +102,7 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set ");
return false;
}
- AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
+ final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
if (af == null) {
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
return false;
@@ -113,14 +111,14 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
return false;
}
- String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
- Object parsed = af.parseValueRaw(value);
+ final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
+ final Object parsed = af.parseValueRaw(value);
if (parsed == null) {
PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc());
return false;
}
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
- boolean result = FlagManager.addPlotFlag(plot, flag);
+ final boolean result = FlagManager.addPlotFlag(plot, flag);
if (!result) {
PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED);
return false;
@@ -134,11 +132,11 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove");
return false;
}
- if (args.length != 2 && args.length != 3) {
+ if ((args.length != 2) && (args.length != 3)) {
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove [values]");
return false;
}
- AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
+ final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
if (af == null) {
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
return false;
@@ -147,18 +145,17 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
return false;
}
- Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
+ final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
if (flag == null) {
PlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT);
return false;
}
- if (args.length == 3 && flag.getAbstractFlag().isList()) {
- String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
+ if ((args.length == 3) && flag.getAbstractFlag().isList()) {
+ final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
- }
- else {
- boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
+ } else {
+ final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
if (!result) {
PlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED);
return false;
@@ -177,7 +174,7 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add ");
return false;
}
- AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
+ final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
if (af == null) {
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
return false;
@@ -186,20 +183,19 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
return false;
}
- String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
- Object parsed = af.parseValueRaw(value);
+ final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
+ final Object parsed = af.parseValueRaw(value);
if (parsed == null) {
PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc());
return false;
}
Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase());
- if (flag == null || !flag.getAbstractFlag().isList()) {
+ if ((flag == null) || !flag.getAbstractFlag().isList()) {
flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
- }
- else {
+ } else {
((FlagValue.ListValue) flag.getAbstractFlag().value).add(flag.getValue(), value);
}
- boolean result = FlagManager.addPlotFlag(plot, flag);
+ final boolean result = FlagManager.addPlotFlag(plot, flag);
if (!result) {
PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED);
return false;
@@ -218,9 +214,9 @@ public class FlagCmd extends SubCommand {
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list");
return false;
}
- HashMap> flags = new HashMap<>();
- for (AbstractFlag af : FlagManager.getFlags()) {
- String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
+ final HashMap> flags = new HashMap<>();
+ for (final AbstractFlag af : FlagManager.getFlags()) {
+ final String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
if (!flags.containsKey(type)) {
flags.put(type, new ArrayList());
}
@@ -228,8 +224,8 @@ public class FlagCmd extends SubCommand {
}
String message = "";
String prefix = "";
- for (String flag : flags.keySet()) {
- message += prefix + "&6" + flag +": &7" + StringUtils.join(flags.get(flag), ", ");
+ for (final String flag : flags.keySet()) {
+ message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", ");
prefix = "\n";
}
PlayerFunctions.sendMessage(player, message);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java
index 439d630a5..e8dac809a 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java
@@ -5,7 +5,6 @@
*
* >> File = Help.java >> Generated by: Citymonstret at 2014-08-11 17:32
*/
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -14,7 +13,7 @@ public class Help extends SubCommand {
public Help() {
super("help", "", "Get this help menu", "help", "he", SubCommand.CommandCategory.INFO, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
return false;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java
index 134c233d0..997d847a8 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
@@ -35,11 +34,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Helpers extends SubCommand {
-
public Helpers() {
super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 2) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java
index 5e44c4d3a..54a9e19fa 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -33,11 +32,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class Home extends SubCommand {
-
public Home() {
super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT, true);
}
-
+
private Plot isAlias(final String a) {
for (final Plot p : PlotSquared.getPlots()) {
if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) {
@@ -46,7 +44,7 @@ public class Home extends SubCommand {
}
return null;
}
-
+
@Override
public boolean execute(final Player plr, String... args) {
final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]);
@@ -55,7 +53,7 @@ public class Home extends SubCommand {
return true;
} else if (plots.length > 1) {
if (args.length < 1) {
- args = new String[]{"1"};
+ args = new String[] { "1" };
}
int id = 0;
try {
@@ -87,8 +85,7 @@ public class Home extends SubCommand {
}
}
- public void teleportPlayer(Player player, Plot plot) {
- PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
+ public void teleportPlayer(final Player player, final Plot plot) {
+ PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java
index e89a9d953..3e204817b 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -39,51 +38,49 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Inbox extends SubCommand {
-
public Inbox() {
super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
- boolean report = false;
- if (args.length == 1){
- if (args[0].equalsIgnoreCase("reports")) {
- report = true;
- }
- }
+ boolean report = false;
+ if (args.length == 1) {
+ if (args[0].equalsIgnoreCase("reports")) {
+ report = true;
+ }
+ }
if (!PlayerFunctions.isInPlot(plr) && !report) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
return false;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
- if (plot != null && !plot.hasOwner()) {
+ if ((plot != null) && !plot.hasOwner()) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
return false;
}
-
Integer tier;
final UUID uuid = UUIDHandler.getUUID(plr);
if (BukkitMain.hasPermission(plr, "plots.comment.admin")) {
tier = 0;
- } else if (plot != null && plot.owner.equals(uuid)) {
+ } else if ((plot != null) && plot.owner.equals(uuid)) {
tier = 1;
- } else if (plot != null && plot.helpers.contains(uuid)) {
+ } else if ((plot != null) && plot.helpers.contains(uuid)) {
tier = 2;
- } else if (plot != null && plot.trusted.contains(uuid)) {
+ } else if ((plot != null) && plot.trusted.contains(uuid)) {
tier = 3;
} else {
tier = 4;
}
final boolean below;
if (args.length > 0) {
- below = false;
+ below = false;
switch (args[0].toLowerCase()) {
case "admin":
if (tier <= 0) {
tier = 0;
} else {
- PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
+ PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
return false;
}
break;
@@ -91,7 +88,7 @@ public class Inbox extends SubCommand {
if (tier <= 1) {
tier = 1;
} else {
- PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner");
+ PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner");
return false;
}
break;
@@ -99,7 +96,7 @@ public class Inbox extends SubCommand {
if (tier <= 2) {
tier = 2;
} else {
- PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper");
+ PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper");
return false;
}
break;
@@ -107,7 +104,7 @@ public class Inbox extends SubCommand {
if (tier <= 3) {
tier = 3;
} else {
- PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted");
+ PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted");
return false;
}
break;
@@ -115,45 +112,40 @@ public class Inbox extends SubCommand {
if (tier <= 4) {
tier = 4;
} else {
- PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone");
+ PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone");
return false;
}
break;
case "reports":
- if (tier <= 0) {
+ if (tier <= 0) {
tier = -1;
} else {
- PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
+ PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
return false;
}
- break;
+ break;
default:
- PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[]{"admin", "owner", "helper", "trusted", "everyone"}, Math.max(0, tier), 4));
+ PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4));
return false;
}
+ } else {
+ below = true;
}
- else {
- below = true;
- }
-
final String world = plr.getWorld().getName();
final int tier2 = tier;
-
Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() {
@Override
public void run() {
- ArrayList comments = null;
- if (tier2 == -1) {
- comments = DBFunc.getComments(world, null, 0, false);
- }
- else {
- comments = plot.settings.getComments(tier2);
- }
+ ArrayList comments = null;
+ if (tier2 == -1) {
+ comments = DBFunc.getComments(world, null, 0, false);
+ } else {
+ comments = plot.settings.getComments(tier2);
+ }
if (comments == null) {
comments = DBFunc.getComments(world, plot, tier2, below);
plot.settings.setComments(comments);
}
-
if (args.length == 2) {
final String[] split = args[1].toLowerCase().split(":");
if (!split[0].equals("clear")) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java
index 32dc175c4..225f17c5a 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -46,12 +45,12 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
/**
* @author Citymonstret
*/
-@SuppressWarnings({"javadoc"}) public class Info extends SubCommand {
-
+@SuppressWarnings({ "javadoc" })
+public class Info extends SubCommand {
public Info() {
super(Command.INFO, "Display plot info", "info", CommandCategory.INFO, false);
}
-
+
@Override
public boolean execute(final Player player, String... args) {
World world;
@@ -87,7 +86,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
}
world = Bukkit.getWorld(args[0]);
if (args.length == 3) {
- args = new String[]{args[2]};
+ args = new String[] { args[2] };
} else {
args = new String[0];
}
@@ -96,28 +95,23 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
return false;
}
}
-
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
new InfoInventory(plot, player).build().display();
return true;
}
-
final boolean hasOwner = plot.hasOwner();
boolean containsEveryone;
boolean trustedEveryone;
-
// Wildcard player {added}
{
containsEveryone = (plot.helpers != null) && plot.helpers.contains(DBFunc.everyone);
trustedEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone);
}
-
// Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) {
PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y));
return true;
}
-
String owner = "none";
if (plot.owner != null) {
owner = UUIDHandler.getName(plot.owner);
@@ -126,7 +120,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
owner = plot.owner.toString();
}
String info = C.PLOT_INFO.s();
-
if (args.length == 1) {
info = getCaption(args[0].toLowerCase());
if (info == null) {
@@ -134,13 +127,12 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
return false;
}
}
-
info = format(info, world, plot, player);
PlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER);
PlayerFunctions.sendMessage(player, info, false);
return true;
}
-
+
private String getCaption(final String string) {
switch (string) {
case "helpers":
@@ -167,9 +159,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
return null;
}
}
-
+
private String format(String info, final World world, final Plot plot, final Player player) {
-
final PlotId id = plot.id;
final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id;
final int num = PlayerFunctions.getPlotSelectionIds(id, id2).size();
@@ -181,7 +172,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
final String rating = String.format("%.1f", DBFunc.getRatings(plot));
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none");
final boolean build = (player == null) || plot.hasRights(player);
-
String owner = "none";
if (plot.owner != null) {
owner = UUIDHandler.getName(plot.owner);
@@ -189,7 +179,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
if (owner == null) {
owner = plot.owner.toString();
}
-
info = info.replaceAll("%alias%", alias);
info = info.replaceAll("%id%", id.toString());
info = info.replaceAll("%id2%", id2.toString());
@@ -203,10 +192,9 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
info = info.replaceAll("%flags%", flags);
info = info.replaceAll("%build%", build + "");
info = info.replaceAll("%desc%", "No description set.");
-
return info;
}
-
+
private String getPlayerList(final ArrayList l) {
if ((l == null) || (l.size() < 1)) {
return " none";
@@ -222,7 +210,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
}
return list.toString();
}
-
+
private String getPlayerName(final UUID uuid) {
if (uuid == null) {
return "unknown";
@@ -230,13 +218,13 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
return "everyone";
}
- String name = UUIDHandler.getName(uuid);
+ final String name = UUIDHandler.getName(uuid);
if (name == null) {
return "unknown";
}
return name;
}
-
+
private Biome getBiomeAt(final Plot plot) {
final World w = Bukkit.getWorld(plot.world);
final Location bl = PlotHelper.getPlotTopLoc(w, plot.id);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java
index 4921d16ac..119c75766 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -31,11 +30,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class Inventory extends SubCommand {
-
public Inventory() {
super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
final ArrayList cmds = new ArrayList<>();
@@ -52,7 +50,7 @@ public class Inventory extends SubCommand {
plr.openInventory(inventory);
return true;
}
-
+
private ItemStack getItem(final SubCommand cmd) {
final ItemStack stack = new ItemStack(Material.COMMAND);
final ItemMeta meta = stack.getItemMeta();
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java
index e7411639b..410c1c105 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.Bukkit;
@@ -30,12 +29,12 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
-@SuppressWarnings({"unused", "deprecation", "javadoc"}) public class Kick extends SubCommand {
-
+@SuppressWarnings({ "unused", "deprecation", "javadoc" })
+public class Kick extends SubCommand {
public Kick() {
super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
index b40fdb5b4..6b27b0e37 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -44,35 +43,33 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class MainCommand implements CommandExecutor, TabCompleter {
-
/**
* Main Permission Node
*/
- private final static SubCommand[] _subCommands = new SubCommand[]{new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense() };
-
+ private final static SubCommand[] _subCommands = new SubCommand[] { new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense() };
public final static ArrayList subCommands = new ArrayList() {
{
addAll(Arrays.asList(_subCommands));
}
};
-
+
public static boolean no_permission(final Player player, final String permission) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission);
return false;
}
-
+
public static List getCommands(final SubCommand.CommandCategory category, final Player player) {
final List cmds = new ArrayList<>();
for (final SubCommand c : subCommands) {
- if (!c.isPlayer || player != null) {
- if ((c.category.equals(category)) && c.permission.hasPermission(player)) {
- cmds.add(c);
- }
- }
+ if (!c.isPlayer || (player != null)) {
+ if ((c.category.equals(category)) && c.permission.hasPermission(player)) {
+ cmds.add(c);
+ }
+ }
}
return cmds;
}
-
+
public static List helpMenu(final Player player, final SubCommand.CommandCategory category, int page) {
List commands;
if (category != null) {
@@ -91,15 +88,11 @@ public class MainCommand implements CommandExecutor, TabCompleter {
if (max > commands.size()) {
max = commands.size();
}
-
final List help = new ArrayList<>();
-
help.add(C.HELP_HEADER.s());
// HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"),
help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size()));
-
SubCommand cmd;
-
final int start = page * perPage;
for (int x = start; x < max; x++) {
cmd = commands.get(x);
@@ -112,19 +105,17 @@ public class MainCommand implements CommandExecutor, TabCompleter {
}
return help;
}
-
+
private static String t(final String s) {
return ChatColor.translateAlternateColorCodes('&', s);
}
-
+
@Override
public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
final Player player = (sender instanceof Player) ? (Player) sender : null;
-
if (!BukkitMain.hasPermission(player, PlotSquared.MAIN_PERMISSION)) {
return no_permission(player, PlotSquared.MAIN_PERMISSION);
}
-
if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
if (args.length < 2) {
final StringBuilder builder = new StringBuilder();
@@ -143,7 +134,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
break;
}
}
- if (cato == null && !cat.equalsIgnoreCase("all")) {
+ if ((cato == null) && !cat.equalsIgnoreCase("all")) {
final StringBuilder builder = new StringBuilder();
builder.append(C.HELP_INFO.s());
for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
@@ -153,16 +144,13 @@ public class MainCommand implements CommandExecutor, TabCompleter {
}
final StringBuilder help = new StringBuilder();
int page = 0;
-
boolean digit = true;
-
String arg2;
if (args.length > 2) {
arg2 = args[2];
} else {
arg2 = "1";
}
-
for (final char c : arg2.toCharArray()) {
if (!Character.isDigit(c)) {
digit = false;
@@ -175,7 +163,6 @@ public class MainCommand implements CommandExecutor, TabCompleter {
page = 0;
}
}
-
for (final String string : helpMenu(player, cato, page)) {
help.append(string).append("\n");
}
@@ -198,12 +185,10 @@ public class MainCommand implements CommandExecutor, TabCompleter {
}
}
PlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
-
final String[] commands = new String[subCommands.size()];
for (int x = 0; x < subCommands.size(); x++) {
commands[x] = subCommands.get(x).cmd;
}
-
/* Let's try to get a proper usage string */
final String command = new StringComparison(args[0], commands).getBestMatch();
return PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
@@ -212,14 +197,13 @@ public class MainCommand implements CommandExecutor, TabCompleter {
}
return true;
}
-
+
@Override
public List onTabComplete(final CommandSender commandSender, final Command command, final String s, final String[] strings) {
if (!(commandSender instanceof Player)) {
return null;
}
final Player player = (Player) commandSender;
-
if (strings.length < 1) {
if ((strings.length == 0) || "plots".startsWith(s)) {
return Arrays.asList("plots");
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java
index 80aecf2c9..bc2432b4d 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -45,14 +44,13 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class Merge extends SubCommand {
-
- public final static String[] values = new String[]{"north", "east", "south", "west"};
- public final static String[] aliases = new String[]{"n", "e", "s", "w"};
-
+ public final static String[] values = new String[] { "north", "east", "south", "west" };
+ public final static String[] aliases = new String[] { "n", "e", "s", "w" };
+
public Merge() {
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true);
}
-
+
public static String direction(float yaw) {
yaw = yaw / 90;
final int i = Math.round(yaw);
@@ -74,7 +72,7 @@ public class Merge extends SubCommand {
return "";
}
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
@@ -86,7 +84,7 @@ public class Merge extends SubCommand {
PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED);
return false;
}
- boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge");
+ final boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge");
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
@@ -128,21 +126,15 @@ public class Merge extends SubCommand {
default:
return false;
}
-
- PlotId botId = plots.get(0);
- PlotId topId = plots.get(plots.size() - 1);
-
- PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id;
- PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id;
-
- PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id;
- PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id;
-
+ final PlotId botId = plots.get(0);
+ final PlotId topId = plots.get(plots.size() - 1);
+ final PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id;
+ final PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id;
+ final PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id;
+ final PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id;
bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
-
plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top);
-
for (final PlotId myid : plots) {
final Plot myplot = PlotSquared.getPlots(world).get(myid);
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) {
@@ -150,7 +142,6 @@ public class Merge extends SubCommand {
return false;
}
}
-
final PlotWorld plotWorld = PlotSquared.getWorldSettings(world);
if (PlotSquared.useEconomy && plotWorld.USE_ECONOMY) {
double cost = plotWorld.MERGE_PRICE;
@@ -165,9 +156,7 @@ public class Merge extends SubCommand {
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}
-
final PlotMergeEvent event = new PlotMergeEvent(world, plot, plots);
-
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
event.setCancelled(true);
@@ -176,7 +165,6 @@ public class Merge extends SubCommand {
}
PlayerFunctions.sendMessage(plr, "&cPlots have been merged");
PlotHelper.mergePlots(world, plots, true);
-
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
PlotHelper.update(plr.getLocation());
return true;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java
index 0689f9234..39d78be0c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.World;
@@ -34,11 +33,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Empire92
*/
public class Move extends SubCommand {
-
public Move() {
super("debugmove", "plots.admin", "plot moving debug test", "debugmove", "move", CommandCategory.DEBUG, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
@@ -48,10 +46,10 @@ public class Move extends SubCommand {
PlayerFunctions.sendMessage(plr, "/plot move ");
return false;
}
- World world = plr.getWorld();
- PlotId plot1 = PlotHelper.parseId(args[0]);
- PlotId plot2 = PlotHelper.parseId(args[1]);
- if (plot1 == null || plot2 == null) {
+ final World world = plr.getWorld();
+ final PlotId plot1 = PlotHelper.parseId(args[0]);
+ final PlotId plot2 = PlotHelper.parseId(args[1]);
+ if ((plot1 == null) || (plot2 == null)) {
PlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move ");
return false;
}
@@ -66,8 +64,7 @@ public class Move extends SubCommand {
}
})) {
return true;
- }
- else {
+ } else {
PlayerFunctions.sendMessage(plr, "MOVE FAILED");
return false;
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java
index a9462438c..bb8720c03 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
@@ -38,7 +37,7 @@ public class MusicSubcommand extends SubCommand {
public MusicSubcommand() {
super("music", "plots.music", "Play music in plot", "music", "mus", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player player, final String... args) {
if (!PlayerFunctions.isInPlot(player)) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java
index e383b0e1f..7a7f0f4ae 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/OP.java
@@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class OP extends SubCommand {
-
public OP() {
super(Command.OP, "Alias for /plot trusted add", "/plot op [player]", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java
index 1ec3d2395..16c27699f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -31,11 +30,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Paste extends SubCommand {
-
public Paste() {
super(Command.PASTE, "Paste a plot", "paste", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
@@ -53,7 +51,6 @@ public class Paste extends SubCommand {
}
assert plot != null;
final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
-
if (PlotSelection.currentSelection.containsKey(plr.getName())) {
final PlotSelection selection = PlotSelection.currentSelection.get(plr.getName());
if (size != selection.getWidth()) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java
index 22eed2844..94f078bf5 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.Collection;
@@ -38,18 +37,17 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
-@SuppressWarnings({"javadoc"}) public class Purge extends SubCommand {
-
+@SuppressWarnings({ "javadoc" })
+public class Purge extends SubCommand {
public Purge() {
super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false);
}
-
- public PlotId getId(String id) {
+
+ public PlotId getId(final String id) {
try {
- String[] split = id.split(";");
+ final String[] split = id.split(";");
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
- }
- catch (Exception e) {
+ } catch (final Exception e) {
return null;
}
}
@@ -61,15 +59,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
return false;
}
if (args.length == 1) {
- String arg = args[0].toLowerCase();
- PlotId id = getId(arg);
+ final String arg = args[0].toLowerCase();
+ final PlotId id = getId(arg);
if (id != null) {
PlayerFunctions.sendMessage(plr, "/plot purge x;z &l");
return false;
}
- UUID uuid = UUIDHandler.getUUID(args[0]);
+ final UUID uuid = UUIDHandler.getUUID(args[0]);
if (uuid != null) {
- PlayerFunctions.sendMessage(plr, "/plot purge "+args[0]+" &l");
+ PlayerFunctions.sendMessage(plr, "/plot purge " + args[0] + " &l");
return false;
}
if (arg.equals("player")) {
@@ -95,68 +93,68 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX);
return false;
}
- World world = Bukkit.getWorld(args[1]);
- if (world == null || !PlotSquared.isPlotWorld(world)) {
+ final World world = Bukkit.getWorld(args[1]);
+ if ((world == null) || !PlotSquared.isPlotWorld(world)) {
PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD);
return false;
}
- String worldname = world.getName();
- String arg = args[0].toLowerCase();
- PlotId id = getId(arg);
+ final String worldname = world.getName();
+ final String arg = args[0].toLowerCase();
+ final PlotId id = getId(arg);
if (id != null) {
- HashSet ids = new HashSet();
- int DBid = DBFunc.getId(worldname, id);
+ final HashSet ids = new HashSet();
+ final int DBid = DBFunc.getId(worldname, id);
if (DBid != Integer.MAX_VALUE) {
ids.add(DBid);
}
DBFunc.purgeIds(worldname, ids);
return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0);
}
- UUID uuid = UUIDHandler.getUUID(args[0]);
+ final UUID uuid = UUIDHandler.getUUID(args[0]);
if (uuid != null) {
- Set plots = PlotSquared.getPlots(world,uuid);
- Set ids = new HashSet<>();
- for (Plot plot : plots) {
+ final Set plots = PlotSquared.getPlots(world, uuid);
+ final Set ids = new HashSet<>();
+ for (final Plot plot : plots) {
ids.add(plot.id);
}
DBFunc.purge(worldname, ids);
return finishPurge(ids.size());
}
if (arg.equals("all")) {
- Set ids = PlotSquared.getPlots(world).keySet();
+ final Set ids = PlotSquared.getPlots(world).keySet();
if (ids.size() == 0) {
- return PlayerFunctions.sendMessage(null, "&cNo plots found");
+ return PlayerFunctions.sendMessage(null, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(ids.size());
}
if (arg.equals("unknown")) {
- Collection plots = PlotSquared.getPlots(world).values();
- Set ids = new HashSet<>();
- for (Plot plot : plots) {
+ final Collection plots = PlotSquared.getPlots(world).values();
+ final Set ids = new HashSet<>();
+ for (final Plot plot : plots) {
if (plot.owner != null) {
- String name = UUIDHandler.getName(plot.owner);
+ final String name = UUIDHandler.getName(plot.owner);
if (name == null) {
ids.add(plot.id);
}
}
}
if (ids.size() == 0) {
- return PlayerFunctions.sendMessage(null, "&cNo plots found");
+ return PlayerFunctions.sendMessage(null, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(ids.size());
}
if (arg.equals("unowned")) {
- Collection plots = PlotSquared.getPlots(world).values();
- Set ids = new HashSet<>();
- for (Plot plot : plots) {
+ final Collection plots = PlotSquared.getPlots(world).values();
+ final Set ids = new HashSet<>();
+ for (final Plot plot : plots) {
if (plot.owner == null) {
ids.add(plot.id);
}
}
if (ids.size() == 0) {
- return PlayerFunctions.sendMessage(null, "&cNo plots found");
+ return PlayerFunctions.sendMessage(null, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(ids.size());
@@ -164,10 +162,9 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX);
return false;
}
-
- private boolean finishPurge(int amount) {
+
+ private boolean finishPurge(final int amount) {
PlayerFunctions.sendMessage(null, C.PURGE_SUCCESS, amount + "");
return false;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java
index 3bb333161..a66ed1a45 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -29,17 +28,16 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
-@SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Rate extends SubCommand {
-
+@SuppressWarnings({ "unused", "deprecated", "javadoc" })
+public class Rate extends SubCommand {
/*
* String cmd, String permission, String description, String usage, String
* alias, CommandCategory category
*/
-
public Rate() {
super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
@@ -82,7 +80,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
} catch (final Exception e) {
rated = false;
}
-
if (rated) {
sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString());
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java
index f6ab45617..b93c3cfeb 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -35,49 +34,38 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
public class RegenAllRoads extends SubCommand {
-
public RegenAllRoads() {
super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "rgar", CommandCategory.DEBUG, false);
}
-
+
@Override
public boolean execute(final Player player, final String... args) {
-
if (player != null) {
sendMessage(player, C.NOT_CONSOLE);
return false;
}
-
if (args.length != 1) {
sendMessage(player, C.NEED_PLOT_WORLD);
return false;
}
-
- String name = args[0];
- PlotManager manager = PlotSquared.getPlotManager(name);
-
- if (manager == null || !(manager instanceof HybridPlotManager)) {
+ final String name = args[0];
+ final PlotManager manager = PlotSquared.getPlotManager(name);
+ if ((manager == null) || !(manager instanceof HybridPlotManager)) {
sendMessage(player, C.NOT_VALID_PLOT_WORLD);
return false;
}
-
- HybridPlotManager hpm = (HybridPlotManager) manager;
-
- World world = Bukkit.getWorld(name);
- ArrayList chunks = ChunkManager.getChunkChunks(world);
-
+ final HybridPlotManager hpm = (HybridPlotManager) manager;
+ final World world = Bukkit.getWorld(name);
+ final ArrayList chunks = ChunkManager.getChunkChunks(world);
PlotSquared.log("&cIf no schematic is set, the following will not do anything");
PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
- PlotSquared.log("&6Potential chunks to update: &7"+ (chunks.size() * 1024));
- PlotSquared.log("&6Estimated time: &7"+ (chunks.size()) + " seconds");
-
- boolean result = hpm.scheduleRoadUpdate(world);
-
+ PlotSquared.log("&6Potential chunks to update: &7" + (chunks.size() * 1024));
+ PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds");
+ final boolean result = hpm.scheduleRoadUpdate(world);
if (!result) {
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
return false;
}
-
return true;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java
index aa11a9d74..200e021d7 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -29,11 +28,10 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Reload extends SubCommand {
-
public Reload() {
super("reload", "plots.admin.command.reload", "Reload configurations", "", "reload", CommandCategory.INFO, false);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
try {
@@ -52,5 +50,4 @@ public class Reload extends SubCommand {
}
return true;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java
index 04d1fbc5c..4a134b7c8 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.Collection;
@@ -45,17 +44,16 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Schematic extends SubCommand {
-
private int counter = 0;
private boolean running = false;
private Plot[] plots;
private int task;
-
+
public Schematic() {
super("schematic", "plots.schematic", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false);
// TODO command to fetch schematic from worldedit directory
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
@@ -99,22 +97,17 @@ public class Schematic extends SubCommand {
Schematic.this.running = false;
return;
}
-
final int x;
final int z;
-
final Plot plot2 = PlayerFunctions.getCurrentPlot(plr);
-
final Dimension dem = schematic.getSchematicDimension();
final Location bot = PlotHelper.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1);
final int length2 = PlotHelper.getPlotWidth(plr.getWorld(), plot2.id);
-
if ((dem.getX() > length2) || (dem.getZ() > length2)) {
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2));
Schematic.this.running = false;
return;
}
-
if ((dem.getX() != length2) || (dem.getZ() != length2)) {
final Location loc = plr.getLocation();
x = Math.min(length2 - dem.getX(), loc.getBlockX() - bot.getBlockX());
@@ -123,7 +116,6 @@ public class Schematic extends SubCommand {
x = 0;
z = 0;
}
-
final World w = plot2.getWorld();
final DataCollection[] b = schematic.getBlockCollection();
final int sy = w.getHighestBlockYAt(bot.getBlockX(), bot.getBlockZ());
@@ -131,7 +123,6 @@ public class Schematic extends SubCommand {
final int WIDTH = schematic.getSchematicDimension().getX();
final int LENGTH = schematic.getSchematicDimension().getZ();
final int blen = b.length - 1;
-
Schematic.this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
@Override
public void run() {
@@ -173,13 +164,10 @@ public class Schematic extends SubCommand {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
break;
}
-
final int l1 = schematic.getSchematicDimension().getX();
final int l2 = schematic.getSchematicDimension().getZ();
-
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
final int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id);
-
if ((l1 < length) || (l2 < length)) {
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
break;
@@ -205,19 +193,15 @@ public class Schematic extends SubCommand {
PlayerFunctions.sendMessage(null, "&cTask is already running.");
return false;
}
-
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots...");
final World worldObj = Bukkit.getWorld(args[1]);
final String worldname = Bukkit.getWorld(args[1]).getName();
-
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
-
final Collection values = plotmap.values();
this.plots = values.toArray(new Plot[values.size()]);
this.running = true;
this.counter = 0;
-
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
@@ -295,13 +279,10 @@ public class Schematic extends SubCommand {
return false;
}
}
-
final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
-
- this.plots = new Plot[]{p2};
+ this.plots = new Plot[] { p2 };
this.running = true;
this.counter = 0;
-
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin2, new Runnable() {
@Override
public void run() {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java
index f2b1d314b..38625d8c8 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
@@ -56,14 +55,13 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class Set extends SubCommand {
-
- public final static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"};
- public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
-
+ public final static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "flag" };
+ public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" };
+
public Set() {
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true);
}
-
+
@SuppressWarnings("deprecation")
@Override
public boolean execute(final Player plr, final String... args) {
@@ -96,7 +94,6 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
return false;
}
-
if (args[0].equalsIgnoreCase("flag")) {
if (args.length < 2) {
String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6");
@@ -110,15 +107,12 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message));
return false;
}
-
AbstractFlag af;
-
try {
af = FlagManager.getFlag(args[1].toLowerCase());
} catch (final Exception e) {
af = new AbstractFlag(args[1].toLowerCase());
}
-
if (!FlagManager.getFlags().contains(af) && ((PlotSquared.worldGuardListener == null) || !PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
return false;
@@ -138,9 +132,7 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
return false;
}
-
- boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase());
-
+ final boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase());
if (!result) {
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
return false;
@@ -150,20 +142,18 @@ public class Set extends SubCommand {
return true;
}
try {
- String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
- Object parsed_value = af.parseValueRaw(value);
+ final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
+ final Object parsed_value = af.parseValueRaw(value);
if (parsed_value == null) {
PlayerFunctions.sendMessage(plr, af.getValueDesc());
return false;
}
-
if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotSquared.worldGuardListener != null)) {
PlotSquared.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], af.toString(parsed_value));
return false;
}
-
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed_value);
- boolean result = FlagManager.addPlotFlag(plot, flag);
+ final boolean result = FlagManager.addPlotFlag(plot, flag);
if (!result) {
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
return false;
@@ -176,7 +166,6 @@ public class Set extends SubCommand {
return false;
}
}
-
if (args[0].equalsIgnoreCase("home")) {
if (args.length > 1) {
if (args[1].equalsIgnoreCase("none")) {
@@ -187,16 +176,15 @@ public class Set extends SubCommand {
return PlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT);
}
//set to current location
- World world = plr.getWorld();
- Location base = PlotHelper.getPlotBottomLoc(world, plot.id);
+ final World world = plr.getWorld();
+ final Location base = PlotHelper.getPlotBottomLoc(world, plot.id);
base.setY(0);
- Location relative = plr.getLocation().subtract(base);
- BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
+ final Location relative = plr.getLocation().subtract(base);
+ final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
plot.settings.setPosition(blockloc);
DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ());
return PlayerFunctions.sendMessage(plr, C.POSITION_SET);
}
-
if (args[0].equalsIgnoreCase("alias")) {
if (args.length < 2) {
PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS);
@@ -230,7 +218,6 @@ public class Set extends SubCommand {
sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2");
return true;
}
-
final Biome biome = Biome.valueOf(new StringComparison(args[1], Biome.values()).getBestMatch());
/*
* for (Biome b : Biome.values()) {
@@ -240,7 +227,6 @@ public class Set extends SubCommand {
* }
* }
*/
-
if (biome == null) {
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
return true;
@@ -249,13 +235,12 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
return true;
}
-
// Get components
- World world = plr.getWorld();
+ final World world = plr.getWorld();
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
- PlotManager manager = PlotSquared.getPlotManager(world);
- String[] components = manager.getPlotComponents(world, plotworld, plot.id);
- for (String component : components) {
+ final PlotManager manager = PlotSquared.getPlotManager(world);
+ final String[] components = manager.getPlotComponents(world, plotworld, plot.id);
+ for (final String component : components) {
if (component.equalsIgnoreCase(args[0])) {
if (args.length < 2) {
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
@@ -264,14 +249,13 @@ public class Set extends SubCommand {
PlotBlock[] blocks;
try {
blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseObject(args[2]);
- }
- catch (Exception e) {
+ } catch (final Exception e) {
try {
- blocks = new PlotBlock[] {new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0)};
- } catch (Exception e2) {
- PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
- return false;
- }
+ blocks = new PlotBlock[] { new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0) };
+ } catch (final Exception e2) {
+ PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
+ return false;
+ }
}
manager.setComponent(world, plotworld, plot.id, component, blocks);
PlayerFunctions.sendMessage(plr, C.GENERATING_COMPONENT);
@@ -299,19 +283,19 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values));
return false;
}
-
+
private String getMaterial(final Material m) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase()));
}
-
+
private String getBiome(final Biome b) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase()));
}
-
+
private String getString(final String s) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
}
-
+
private String getArgumentList(final String[] strings) {
final StringBuilder builder = new StringBuilder();
for (final String s : strings) {
@@ -319,7 +303,7 @@ public class Set extends SubCommand {
}
return builder.toString().substring(1, builder.toString().length() - 1);
}
-
+
private String getBiomeList(final List biomes) {
final StringBuilder builder = new StringBuilder();
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
@@ -328,18 +312,8 @@ public class Set extends SubCommand {
}
return builder.toString().substring(1, builder.toString().length() - 1);
}
-
+
private Material getMaterial(final String input, final List blocks) {
return Material.valueOf(new StringComparison(input, blocks.toArray()).getBestMatch());
}
-
- private String getBlockList(final List blocks) {
- final StringBuilder builder = new StringBuilder();
- builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
- for (final Material b : blocks) {
- builder.append(getMaterial(b));
- }
- return builder.toString().substring(1, builder.toString().length() - 1);
- }
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java
index c4a829396..6f2266b24 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -38,25 +37,23 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class SetOwner extends SubCommand {
-
public SetOwner() {
super("setowner", "plots.set.owner", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true);
}
-
+
/*
* private UUID getUUID(String string) { OfflinePlayer player =
* Bukkit.getOfflinePlayer(string); return ((player != null) &&
* player.hasPlayedBefore()) ? UUIDHandler.getUUID(player) : null; }
*/
-
private UUID getUUID(final String string) {
return UUIDHandler.getUUID(string);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
- Plot plot = PlayerFunctions.getCurrentPlot(plr);
- if (plot == null || plot.owner == null) {
+ final Plot plot = PlayerFunctions.getCurrentPlot(plr);
+ if ((plot == null) || (plot.owner == null)) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
return false;
}
@@ -64,7 +61,6 @@ public class SetOwner extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NEED_USER);
return false;
}
-
if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.setowner")) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
return false;
@@ -75,18 +71,14 @@ public class SetOwner extends SubCommand {
final ArrayList plots = PlayerFunctions.getPlotSelectionIds(bot, top);
for (final PlotId id : plots) {
final Plot current = PlotSquared.getPlots(world).get(id);
-
- UUID uuid = getUUID(args[0]);
-
+ final UUID uuid = getUUID(args[0]);
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]);
return false;
}
-
current.owner = uuid;
PlotSquared.updatePlot(current);
DBFunc.setOwner(current, current.owner);
-
if (PlotSquared.worldGuardListener != null) {
PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current);
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java
index ea4e5fcaf..da4ff9416 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.io.IOException;
@@ -45,7 +44,6 @@ import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Setup extends SubCommand {
-
public final static Map setupMap = new HashMap<>();
public HashMap generators = new HashMap<>();
@@ -62,22 +60,22 @@ public class Setup extends SubCommand {
int terrain = 0;
ConfigurationNode[] step = null;
}
-
+
public void updateGenerators() {
- if (generators.size() > 0) {
+ if (this.generators.size() > 0) {
return;
}
- String testWorld = "CheckingPlotSquaredGenerator";
+ final String testWorld = "CheckingPlotSquaredGenerator";
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (plugin.isEnabled()) {
- ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
+ final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
if (generator != null) {
PlotSquared.removePlotWorld(testWorld);
final String name = plugin.getDescription().getName();
if (generator instanceof PlotGenerator) {
- PlotGenerator pgen = (PlotGenerator) generator;
+ final PlotGenerator pgen = (PlotGenerator) generator;
if (pgen.getPlotManager() instanceof SquarePlotManager) {
- generators.put(name, pgen);
+ this.generators.put(name, pgen);
}
}
}
@@ -88,15 +86,14 @@ public class Setup extends SubCommand {
@Override
public boolean execute(final Player plr, final String... args) {
// going through setup
-
- String name = plr.getName();
+ final String name = plr.getName();
if (!setupMap.containsKey(name)) {
- SetupObject object = new SetupObject();
+ final SetupObject object = new SetupObject();
setupMap.put(name, object);
updateGenerators();
- String prefix = "\n&8 - &7";
+ final String prefix = "\n&8 - &7";
sendMessage(plr, C.SETUP_INIT);
- PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
+ PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
return false;
}
if (args.length == 1) {
@@ -106,86 +103,70 @@ public class Setup extends SubCommand {
return false;
}
if (args[0].equalsIgnoreCase("back")) {
- SetupObject object = setupMap.get(plr.getName());
+ final SetupObject object = setupMap.get(plr.getName());
if (object.setup_index > 0) {
object.setup_index--;
- ConfigurationNode node = object.step[object.current];
+ final ConfigurationNode node = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + "");
return false;
- }
- else if (object.current > 0 ){
+ } else if (object.current > 0) {
object.current--;
}
}
}
- SetupObject object = setupMap.get(name);
- int index = object.current;
- switch(index) {
+ final SetupObject object = setupMap.get(name);
+ final int index = object.current;
+ switch (index) {
case 0: { // choose generator
- if (args.length != 1 || !generators.containsKey(args[0])) {
- String prefix = "\n&8 - &7";
- PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
+ if ((args.length != 1) || !this.generators.containsKey(args[0])) {
+ final String prefix = "\n&8 - &7";
+ PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
sendMessage(plr, C.SETUP_INIT);
return false;
}
object.generator = args[0];
object.current++;
-
- String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : "";
- PlayerFunctions.sendMessage(plr, "&6What world type do you want?"
- + "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
- + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
- + partial);
+ final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : "";
+ PlayerFunctions.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
break;
}
case 1: { // choose world type
List types;
if (Settings.ENABLE_CLUSTERS) {
- types = Arrays.asList(new String[] {"default", "augmented", "partial"});
+ types = Arrays.asList(new String[] { "default", "augmented", "partial" });
+ } else {
+ types = Arrays.asList(new String[] { "default", "augmented" });
}
- else {
- types = Arrays.asList(new String[] {"default", "augmented"});
- }
- if (args.length != 1 || !types.contains(args[0].toLowerCase())) {
- PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!"
- + "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
- + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
- + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
+ if ((args.length != 1) || !types.contains(args[0].toLowerCase())) {
+ PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
return false;
}
object.type = types.indexOf(args[0].toLowerCase());
if (object.type == 0) {
object.current++;
if (object.step == null) {
- object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
+ object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
}
- ConfigurationNode step = object.step[object.setup_index];
+ final ConfigurationNode step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
- }
- else {
- PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?"
- + "\n&8 - &2NONE&8 - &7No terrain at all"
- + "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
- + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
+ } else {
+ PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
}
object.current++;
break;
}
case 2: { // Choose terrain
- List terrain = Arrays.asList(new String[] {"none", "ore", "all"});
- if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) {
- PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!"
- + "\n&8 - &2NONE&8 - &7No terrain at all"
- + "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
- + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
+ final List terrain = Arrays.asList(new String[] { "none", "ore", "all" });
+ if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
+ PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
return false;
}
object.terrain = terrain.indexOf(args[0].toLowerCase());
object.current++;
if (object.step == null) {
- object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
+ object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
}
- ConfigurationNode step = object.step[object.setup_index];
+ final ConfigurationNode step = object.step[object.setup_index];
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
break;
}
@@ -229,11 +210,10 @@ public class Setup extends SubCommand {
}
object.world = args[0];
setupMap.remove(plr.getName());
- World world = setupWorld(object);
+ final World world = setupWorld(object);
try {
plr.teleport(world.getSpawnLocation());
- }
- catch (Exception e) {
+ } catch (final Exception e) {
plr.sendMessage("&cAn error occured. See console for more information");
e.printStackTrace();
}
@@ -252,20 +232,20 @@ public class Setup extends SubCommand {
* 2.2 augmented partial world with ore
* 2.3 augmented partial world with terrain
* 3.0 no generation + normal manager
- *
+ *
* generator.TYPE: PlotSquared, augmented, partial
* generator.TERRAIN
- *
+ *
* WORLD.TYPE: hybrid, augmented, partial
* if (augmented/partial)
- * WORLD.TERRAIN:
- *
- *
+ * WORLD.TERRAIN:
+ *
+ *
* types (0, 1, 2, 3)
* 0: no options
- * 1:
- *
- *
+ * 1:
+ *
+ *
* - return null
* - schedule task to create world later
* - externalize multiverse/world hooks to separate class
@@ -286,15 +266,15 @@ public class Setup extends SubCommand {
* = square generator
* = square plot generator (must have plot section and road section) (plot height, road height)
* = hybrid generator
- *
+ *
* - All will support whole world augmentation
* - Only grid will support partial plot worlds
- *
+ *
*/
return false;
}
- public World setupWorld(SetupObject object) {
+ public World setupWorld(final SetupObject object) {
// Configuration
final ConfigurationNode[] steps = object.step;
final String world = object.world;
@@ -318,14 +298,13 @@ public class Setup extends SubCommand {
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator);
} else {
- WorldCreator wc = new WorldCreator(object.world);
+ final WorldCreator wc = new WorldCreator(object.world);
wc.generator(object.generator);
wc.environment(Environment.NORMAL);
- World newWorld = Bukkit.createWorld(wc);
+ Bukkit.createWorld(wc);
}
}
- }
- else {
+ } else {
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
} else {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java
index 3f1485f27..742073d7c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -34,8 +33,8 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
*
* @author Citymonstret
*/
-@SuppressWarnings({"deprecation", "unused"}) public abstract class SubCommand {
-
+@SuppressWarnings({ "deprecation", "unused" })
+public abstract class SubCommand {
/**
* Command
*/
@@ -64,7 +63,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* Is this a player-online command?
*/
public final boolean isPlayer;
-
+
/**
* @param cmd Command /plot {cmd} <-- That!
* @param permission Permission Node
@@ -83,7 +82,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
this.category = category;
this.isPlayer = isPlayer;
}
-
+
/**
* @param cmd Command /plot {cmd} <-- That!
* @param permission Permission Node
@@ -102,7 +101,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
this.category = category;
this.isPlayer = isPlayer;
}
-
+
/**
* @param command Command /plot {cmd} <-- That!
* @param description Simple description
@@ -119,7 +118,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
this.category = category;
this.isPlayer = isPlayer;
}
-
+
/**
* Execute.
*
@@ -129,7 +128,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @return true on success, false on failure
*/
public abstract boolean execute(final Player plr, final String... args);
-
+
/**
* Execute the command as console
*
@@ -138,7 +137,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public void executeConsole(final String... args) {
this.execute(null, args);
}
-
+
/**
* Send a message
*
@@ -153,7 +152,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
PlayerFunctions.sendMessage(plr, c, args);
return true;
}
-
+
/**
* CommandCategory
*
@@ -191,12 +190,11 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* Such as: /plot debug
*/
DEBUG("Debug");
-
/**
* The category name (Readable)
*/
private final String name;
-
+
/**
* Constructor
*
@@ -205,7 +203,7 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
CommandCategory(final String name) {
this.name = name;
}
-
+
@Override
public String toString() {
return this.name;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java
index 8a05962db..291cc0e5d 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.World;
@@ -40,11 +39,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Empire92
*/
public class Swap extends SubCommand {
-
public Swap() {
super(Command.SWAP, "Swap two plots", "switch", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
@@ -87,11 +85,9 @@ public class Swap extends SubCommand {
return false;
}
PlotSelection.swap(world, plot.id, plotid);
-
// TODO Requires testing!!
DBFunc.dbManager.swapPlots(plot, PlotHelper.getPlot(world, plotid));
// TODO Requires testing!!
-
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
PlotHelper.update(plr.getLocation());
return true;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java
index 2a7c67c70..de091975e 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.apache.commons.lang.StringUtils;
@@ -37,11 +36,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class TP extends SubCommand {
-
public TP() {
super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
@@ -65,7 +63,6 @@ public class TP extends SubCommand {
PlotSquared.teleportPlayer(plr, plr.getLocation(), temp);
return true;
}
-
try {
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
PlotSquared.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
@@ -75,7 +72,7 @@ public class TP extends SubCommand {
}
return false;
}
-
+
private Plot isAlias(final World world, String a) {
int index = 0;
if (a.contains(";")) {
@@ -85,7 +82,8 @@ public class TP extends SubCommand {
}
a = split[0];
}
- @SuppressWarnings("deprecation") final Player player = Bukkit.getPlayer(a);
+ @SuppressWarnings("deprecation")
+ final Player player = Bukkit.getPlayer(a);
if (player != null) {
final java.util.Set plotMainPlots = PlotSquared.getPlots(world, player);
final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java
index f84d90866..5a1de4393 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.Location;
@@ -31,11 +30,10 @@ import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Target extends SubCommand {
-
public Target() {
super(Command.TARGET, "Target a plot with your compass", "target ", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlotSquared.isPlotWorld(plr.getWorld())) {
@@ -43,12 +41,12 @@ public class Target extends SubCommand {
return false;
}
if (args.length == 1) {
- PlotId id = PlotHelper.parseId(args[1]);
+ final PlotId id = PlotHelper.parseId(args[1]);
if (id == null) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
return false;
}
- Location loc = PlotHelper.getPlotHome(plr.getWorld(), id);
+ final Location loc = PlotHelper.getPlotHome(plr.getWorld(), id);
plr.setCompassTarget(loc);
PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET);
return true;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java
index 826c27ca4..607e395c3 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.io.FileInputStream;
@@ -36,7 +35,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Template extends SubCommand {
-
public Template() {
super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true);
}
@@ -47,9 +45,9 @@ public class Template extends SubCommand {
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template ");
return false;
}
- World world = Bukkit.getWorld(args[1]);
- PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]);
- if (world == null || plotworld == null) {
+ final World world = Bukkit.getWorld(args[1]);
+ final PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]);
+ if ((world == null) || (plotworld == null)) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
return false;
}
@@ -63,19 +61,16 @@ public class Template extends SubCommand {
PlayerFunctions.sendMessage(plr, "TODO");
}
}
-
// TODO allow world settings (including schematics to be packed into a single file)
-
// TODO allow world created based on these packaged files
-
return true;
}
- public void gzipIt(String output, String input) {
- byte[] buffer = new byte[1024];
+ public void gzipIt(final String output, final String input) {
+ final byte[] buffer = new byte[1024];
try {
- GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(output));
- FileInputStream in = new FileInputStream(input);
+ final GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(output));
+ final FileInputStream in = new FileInputStream(input);
int len;
while ((len = in.read(buffer)) > 0) {
gzos.write(buffer, 0, len);
@@ -83,7 +78,7 @@ public class Template extends SubCommand {
in.close();
gzos.finish();
gzos.close();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
ex.printStackTrace();
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java
index 5a1056a51..0d27ccf08 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.io.File;
@@ -40,25 +39,23 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PlotHelper;
-import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
+import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class Trim extends SubCommand {
-
public static boolean TASK = false;
private static int TASK_ID = 0;
public Trim() {
super("trim", "plots.admin", "Delete unmodified portions of your plotworld", "trim", "", CommandCategory.DEBUG, false);
}
-
- public PlotId getId(String id) {
+
+ public PlotId getId(final String id) {
try {
- String[] split = id.split(";");
+ final String[] split = id.split(";");
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
- }
- catch (Exception e) {
+ } catch (final Exception e) {
return null;
}
}
@@ -70,8 +67,8 @@ public class Trim extends SubCommand {
return false;
}
if (args.length == 1) {
- String arg = args[0].toLowerCase();
- PlotId id = getId(arg);
+ final String arg = args[0].toLowerCase();
+ final PlotId id = getId(arg);
if (id != null) {
PlayerFunctions.sendMessage(plr, "/plot trim x;z &l");
return false;
@@ -87,22 +84,20 @@ public class Trim extends SubCommand {
PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX);
return false;
}
- String arg = args[0].toLowerCase();
+ final String arg = args[0].toLowerCase();
if (!arg.equals("all")) {
PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX);
return false;
}
final World world = Bukkit.getWorld(args[1]);
- if (world == null || PlotSquared.getWorldSettings(world) == null) {
+ if ((world == null) || (PlotSquared.getWorldSettings(world) == null)) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD);
return false;
}
-
if (Trim.TASK) {
sendMessage(C.TRIM_IN_PROGRESS.s());
return false;
}
-
sendMessage(C.TRIM_START.s());
final ArrayList empty = new ArrayList<>();
getTrimRegions(empty, world, new Runnable() {
@@ -118,54 +113,50 @@ public class Trim extends SubCommand {
if (Trim.TASK) {
return false;
}
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
- String directory = world.getName() + File.separator + "region";
- File folder = new File(directory);
- File[] regionFiles = folder.listFiles();
- for (File file : regionFiles) {
- String name = file.getName();
+ final String directory = world.getName() + File.separator + "region";
+ final File folder = new File(directory);
+ final File[] regionFiles = folder.listFiles();
+ for (final File file : regionFiles) {
+ final String name = file.getName();
if (name.endsWith("mca")) {
if (file.getTotalSpace() <= 8192) {
try {
- String[] split = name.split("\\.");
- int x = Integer.parseInt(split[1]);
- int z = Integer.parseInt(split[2]);
- ChunkLoc loc = new ChunkLoc(x, z);
+ final String[] split = name.split("\\.");
+ final int x = Integer.parseInt(split[1]);
+ final int z = Integer.parseInt(split[2]);
+ final ChunkLoc loc = new ChunkLoc(x, z);
empty.add(loc);
- }
- catch (Exception e) {
+ } catch (final Exception e) {
System.out.print("INVALID MCA: " + name);
}
- }
- else {
- Path path = Paths.get(file.getPath());
+ } else {
+ final Path path = Paths.get(file.getPath());
try {
- BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
- long creation = attr.creationTime().toMillis();
- long modification = file.lastModified();
- long diff = Math.abs(creation - modification);
+ final BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
+ final long creation = attr.creationTime().toMillis();
+ final long modification = file.lastModified();
+ final long diff = Math.abs(creation - modification);
if (diff < 10000) {
try {
- String[] split = name.split("\\.");
- int x = Integer.parseInt(split[1]);
- int z = Integer.parseInt(split[2]);
- ChunkLoc loc = new ChunkLoc(x, z);
+ final String[] split = name.split("\\.");
+ final int x = Integer.parseInt(split[1]);
+ final int z = Integer.parseInt(split[2]);
+ final ChunkLoc loc = new ChunkLoc(x, z);
empty.add(loc);
- }
- catch (Exception e) {
+ } catch (final Exception e) {
System.out.print("INVALID MCA: " + name);
}
}
- } catch (Exception e) {
-
+ } catch (final Exception e) {
}
}
}
}
Trim.TASK = false;
- BukkitTaskManager.runTaskAsync(whenDone);
+ TaskManager.runTaskAsync(whenDone);
}
});
Trim.TASK = true;
@@ -182,29 +173,27 @@ public class Trim extends SubCommand {
plots.addAll(PlotSquared.getPlots(world).values());
final HashSet chunks = new HashSet<>(ChunkManager.getChunkChunks(world));
sendMessage(" - MCA #: " + chunks.size());
- sendMessage(" - CHUNKS: " + (chunks.size() * 1024) +" (max)");
- sendMessage(" - TIME ESTIMATE: " + (chunks.size()/1200) +" minutes");
+ sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
+ sendMessage(" - TIME ESTIMATE: " + (chunks.size() / 1200) + " minutes");
Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
@Override
public void run() {
- long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < 50) {
+ final long start = System.currentTimeMillis();
+ while ((System.currentTimeMillis() - start) < 50) {
if (plots.size() == 0) {
empty.addAll(chunks);
System.out.print("DONE!");
Trim.TASK = false;
- BukkitTaskManager.runTaskAsync(whenDone);
+ TaskManager.runTaskAsync(whenDone);
Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
return;
}
- Plot plot = plots.get(0);
+ final Plot plot = plots.get(0);
plots.remove(0);
- Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id);
- Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
-
- Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ());
- Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ());
-
+ final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id);
+ final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
+ final Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ());
+ final Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ());
chunks.remove(ChunkManager.getChunkChunk(pos1));
chunks.remove(ChunkManager.getChunkChunk(pos2));
chunks.remove(ChunkManager.getChunkChunk(pos3));
@@ -218,39 +207,39 @@ public class Trim extends SubCommand {
public static ArrayList expired = null;
-// public static void updateUnmodifiedPlots(final World world) {
-// final SquarePlotManager manager = (SquarePlotManager) PlotSquared.getPlotManager(world);
-// final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getWorldSettings(world);
-// final ArrayList expired = new ArrayList<>();
-// final Set plots = ExpireManager.getOldPlots(world.getName()).keySet();
-// sendMessage("Checking " + plots.size() +" plots! This may take a long time...");
-// Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
-// @Override
-// public void run() {
-// if (manager != null && plots.size() > 0) {
-// Plot plot = plots.iterator().next();
-// if (plot.hasOwner()) {
-// SquarePlotManager.checkModified(plot, 0);
-// }
-// if (plot.owner == null || !SquarePlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) {
-// expired.add(plot);
-// sendMessage("found expired: " + plot);
-// }
-// }
-// else {
-// Trim.expired = expired;
-// Trim.TASK = false;
-// sendMessage("Done!");
-// Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
-// return;
-// }
-// }
-// }, 1, 1);
-// }
-//
- public static void deleteChunks(World world, ArrayList chunks) {
- String worldname = world.getName();
- for (ChunkLoc loc : chunks) {
+ // public static void updateUnmodifiedPlots(final World world) {
+ // final SquarePlotManager manager = (SquarePlotManager) PlotSquared.getPlotManager(world);
+ // final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getWorldSettings(world);
+ // final ArrayList expired = new ArrayList<>();
+ // final Set plots = ExpireManager.getOldPlots(world.getName()).keySet();
+ // sendMessage("Checking " + plots.size() +" plots! This may take a long time...");
+ // Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
+ // @Override
+ // public void run() {
+ // if (manager != null && plots.size() > 0) {
+ // Plot plot = plots.iterator().next();
+ // if (plot.hasOwner()) {
+ // SquarePlotManager.checkModified(plot, 0);
+ // }
+ // if (plot.owner == null || !SquarePlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) {
+ // expired.add(plot);
+ // sendMessage("found expired: " + plot);
+ // }
+ // }
+ // else {
+ // Trim.expired = expired;
+ // Trim.TASK = false;
+ // sendMessage("Done!");
+ // Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
+ // return;
+ // }
+ // }
+ // }, 1, 1);
+ // }
+ //
+ public static void deleteChunks(final World world, final ArrayList chunks) {
+ final String worldname = world.getName();
+ for (final ChunkLoc loc : chunks) {
ChunkManager.deleteRegionFile(worldname, loc);
}
}
@@ -258,5 +247,4 @@ public class Trim extends SubCommand {
public static void sendMessage(final String message) {
PlotSquared.log("&3PlotSquared -> World trim&8: &7" + message);
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java
index 8fededa8d..2258308dc 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
@@ -34,12 +33,12 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
-@SuppressWarnings("deprecation") public class Trusted extends SubCommand {
-
+@SuppressWarnings("deprecation")
+public class Trusted extends SubCommand {
public Trusted() {
super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 2) {
@@ -63,7 +62,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
UUID uuid;
if (args[1].equalsIgnoreCase("*")) {
uuid = DBFunc.everyone;
-
} else {
uuid = UUIDHandler.getUUID(args[1]);
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java
index 8e869667c..0412ee321 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unban.java
@@ -12,11 +12,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
* @author Citymonstret
*/
public class Unban extends SubCommand {
-
public Unban() {
super(Command.UNBAN, "Alias for /plot denied remove", "/plot unban [player]", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java
index c98fefb5e..3ff765574 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import net.milkbowl.vault.economy.Economy;
@@ -36,11 +35,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Unclaim extends SubCommand {
-
public Unclaim() {
super(Command.UNCLAIM, "Unclaim a plot", "unclaim", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
@@ -65,8 +63,8 @@ public class Unclaim extends SubCommand {
}
final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true);
if (result) {
- World world = plr.getWorld();
- String worldname = world.getName();
+ final World world = plr.getWorld();
+ final String worldname = world.getName();
PlotSquared.getPlotManager(world).unclaimPlot(world, pWorld, plot);
DBFunc.delete(worldname, plot);
// TODO set wall block
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java
index e9e356d9e..2e9573215 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -46,11 +45,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class Unlink extends SubCommand {
-
public Unlink() {
super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
@@ -63,7 +61,6 @@ public class Unlink extends SubCommand {
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
}
-
final World world = plr.getWorld();
if (!unlinkPlot(world, plot)) {
PlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled");
@@ -83,31 +80,24 @@ public class Unlink extends SubCommand {
return true;
}
- public static boolean unlinkPlot(World world, Plot plot) {
+ public static boolean unlinkPlot(final World world, final Plot plot) {
final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id;
final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id;
final ArrayList ids = PlayerFunctions.getPlotSelectionIds(pos1, pos2);
-
final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids);
-
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
event.setCancelled(true);
return false;
}
-
final PlotManager manager = PlotSquared.getPlotManager(world);
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
-
manager.startPlotUnlink(world, plotworld, ids);
-
for (final PlotId id : ids) {
final Plot myplot = PlotSquared.getPlots(world).get(id);
-
if (plot == null) {
continue;
}
-
if (plot.helpers != null) {
myplot.helpers = plot.helpers;
}
@@ -115,25 +105,20 @@ public class Unlink extends SubCommand {
myplot.denied = plot.denied;
}
myplot.deny_entry = plot.deny_entry;
- myplot.settings.setMerged(new boolean[]{false, false, false, false});
+ myplot.settings.setMerged(new boolean[] { false, false, false, false });
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
}
-
for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) {
final boolean lx = x < pos2.x;
final boolean ly = y < pos2.y;
-
final Plot p = PlotHelper.getPlot(world, new PlotId(x, y));
-
if (lx) {
manager.createRoadEast(plotworld, p);
if (ly) {
manager.createRoadSouthEast(plotworld, p);
}
-
}
-
if (ly) {
manager.createRoadSouth(plotworld, p);
}
@@ -141,10 +126,10 @@ public class Unlink extends SubCommand {
}
}
manager.finishPlotUnlink(world, plotworld, ids);
- for (PlotId id : ids) {
- Plot myPlot = PlotHelper.getPlot(world, id);
+ for (final PlotId id : ids) {
+ final Plot myPlot = PlotHelper.getPlot(world, id);
if (plot.hasOwner()) {
- String name = UUIDHandler.getName(myPlot.owner);
+ final String name = UUIDHandler.getName(myPlot.owner);
if (name != null) {
PlotHelper.setSign(world, name, myPlot);
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java
index 0901ed1fc..46bf43db5 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
@@ -36,7 +35,7 @@ public class Visit extends SubCommand {
public Visit() {
super("visit", "plots.visit", "Visit someones plot", "visit {player} [#]", "v", CommandCategory.TELEPORT, true);
}
-
+
public List getPlots(final UUID uuid) {
final List plots = new ArrayList<>();
for (final Plot p : PlotSquared.getPlots()) {
@@ -46,7 +45,7 @@ public class Visit extends SubCommand {
}
return plots;
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java
index 6630ead8f..371d53149 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
@@ -29,23 +28,20 @@ import com.intellectualcrafters.plot.util.bukkit.PWE;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class WE_Anywhere extends SubCommand {
-
public WE_Anywhere() {
super("weanywhere", "plots.weanywhere", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (PlotSquared.worldEdit == null) {
PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server");
return false;
}
-
if (BukkitMain.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) {
PWE.removeMask(plr);
PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask");
- }
- else {
+ } else {
PWE.setMask(plr, plr.getLocation(), true);
PlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask");
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java
index 8697d8b41..6e0c93330 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.util.HashMap;
@@ -41,31 +40,30 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Citymonstret
*/
public class list extends SubCommand {
-
public list() {
super(Command.LIST, "List all plots", "list {mine|shared|all|world|forsale}", CommandCategory.INFO, false);
}
-
+
private static String getName(final UUID id) {
if (id == null) {
return "none";
}
- String name = UUIDHandler.getName(id);
+ final String name = UUIDHandler.getName(id);
if (name == null) {
return "unknown";
}
return name;
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
final StringBuilder builder = new StringBuilder();
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
if (plr != null) {
- builder.append(getArgumentList(new String[]{"mine", "shared", "world", "all", "forsale"}));
+ builder.append(getArgumentList(new String[] { "mine", "shared", "world", "all", "forsale" }));
} else {
- builder.append(getArgumentList(new String[]{"all"}));
+ builder.append(getArgumentList(new String[] { "all" }));
}
PlayerFunctions.sendMessage(plr, builder.toString());
return true;
@@ -78,7 +76,7 @@ public class list extends SubCommand {
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "buyable")).append("\n");
int idx = 0;
for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) {
- Flag price = FlagManager.getPlotFlag(p, "price");
+ final Flag price = FlagManager.getPlotFlag(p, "price");
if (price != null) {
string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", idx + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", price.getValueString()).replaceAll("%owner", getName(p.owner))).append("\n");
idx++;
@@ -121,7 +119,6 @@ public class list extends SubCommand {
} else if (args[0].equalsIgnoreCase("all")) {
// Current page
int page = 0;
-
// is a page specified? else use 0
if (args.length > 1) {
try {
@@ -134,34 +131,26 @@ public class list extends SubCommand {
page = 0;
}
}
-
// Get the total pages
// int totalPages = ((int) Math.ceil(12 *
// (PlotSquared.getPlotsSorted().size()) / 100));
final int totalPages = (int) Math.ceil(PlotSquared.getPlotsSorted().size() / 12);
-
if (page > totalPages) {
page = totalPages;
}
-
// Only display 12!
int max = (page * 12) + 12;
-
if (max > PlotSquared.getPlotsSorted().size()) {
max = PlotSquared.getPlotsSorted().size();
}
-
final StringBuilder string = new StringBuilder();
-
string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n");
Plot p;
-
// This might work xD
for (int x = (page * 12); x < max; x++) {
p = (Plot) PlotSquared.getPlotsSorted().toArray()[x];
string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n");
}
-
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots"));
PlayerFunctions.sendMessage(plr, string.toString());
return true;
@@ -177,11 +166,11 @@ public class list extends SubCommand {
return true;
} else {
// execute(plr);
- sendMessage(plr, C.DID_YOU_MEAN, new StringComparison(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
+ sendMessage(plr, C.DID_YOU_MEAN, new StringComparison(args[0], new String[] { "mine", "shared", "world", "all" }).getBestMatch());
return false;
}
}
-
+
private String getArgumentList(final String[] strings) {
final StringBuilder builder = new StringBuilder();
for (final String s : strings) {
@@ -189,9 +178,8 @@ public class list extends SubCommand {
}
return builder.toString().substring(1, builder.toString().length() - 1);
}
-
+
private String getString(final String s) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java
index 831fe4520..5a76e480c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.commands;
import java.io.BufferedReader;
@@ -35,13 +34,12 @@ import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
public class plugin extends SubCommand {
-
public static String downloads, version;
-
+
public plugin() {
super("plugin", "plots.use", "Show plugin information", "plugin", "version", CommandCategory.INFO, false);
}
-
+
public static void setup(final JavaPlugin plugin) {
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
@@ -65,7 +63,7 @@ public class plugin extends SubCommand {
}
}, 200l);
}
-
+
private static String convertToNumericString(final String str, final boolean dividers) {
final StringBuilder builder = new StringBuilder();
for (final char c : str.toCharArray()) {
@@ -77,7 +75,7 @@ public class plugin extends SubCommand {
}
return builder.toString();
}
-
+
private static String getInfo(final String link) throws Exception {
final URLConnection connection = new URL(link).openConnection();
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
@@ -89,7 +87,7 @@ public class plugin extends SubCommand {
reader.close();
return document;
}
-
+
@Override
public boolean execute(final Player plr, final String... args) {
Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() {
@@ -111,5 +109,4 @@ public class plugin extends SubCommand {
});
return true;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java
index 92d96cb37..ac5be71dd 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.config;
import org.bukkit.ChatColor;
@@ -201,7 +200,6 @@ public enum C {
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."),
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"),
YOU_BE_DENIED("$2You are not allowed to enter this plot"),
-
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"),
UNLINK_REQUIRED("$2An unlink is required to do this."),
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot"),
@@ -329,7 +327,6 @@ public enum C {
PLOT_INFO_ID("$1ID:$2 %id%"),
PLOT_INFO_ALIAS("$1Alias:$2 %alias%"),
PLOT_INFO_SIZE("$1Size:$2 %size%"),
-
PLOT_USER_LIST(" $1%user%$2,"),
INFO_SYNTAX_CONSOLE("$2/plot info X;Y"),
/*
@@ -389,7 +386,6 @@ public enum C {
FLAG_KEY("$2Key: %s"),
FLAG_TYPE("$2Type: %s"),
FLAG_DESC("$2Desc: %s"),
-
NEED_KEY("$2Possible values: $1%values%"),
NOT_VALID_FLAG("$2That is not a valid flag"),
NOT_VALID_VALUE("$2Flag values must be alphanumerical"),
@@ -442,7 +438,6 @@ public enum C {
* Custom
*/
CUSTOM_STRING("-");
-
/**
* Special Language
*
@@ -474,8 +469,7 @@ public enum C {
* Should the string be prefixed?
*/
private boolean prefix;
- private ChatColor[] sColors = null;
-
+
/**
* Constructor for custom strings.
*/
@@ -484,7 +478,7 @@ public enum C {
* use setCustomString();
*/
}
-
+
/**
* Constructor
*
@@ -498,7 +492,7 @@ public enum C {
}
this.prefix = prefix;
}
-
+
/**
* Constructor
*
@@ -507,7 +501,7 @@ public enum C {
C(final String d) {
this(d, true);
}
-
+
public static void setupTranslations() {
manager = new TranslationManager();
defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(), lang, "PlotSquared", manager).read();
@@ -516,15 +510,15 @@ public enum C {
manager.addTranslationObject(new TranslationObject(c.toString(), c.d, "", ""));
}
}
-
+
public static void saveTranslations() {
try {
manager.saveAll(defaultFile).saveFile(defaultFile);
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
}
-
+
/**
* Get the default string
*
@@ -533,14 +527,14 @@ public enum C {
public String d() {
return this.d;
}
-
+
/**
* Get translated if exists
*
* @return translated if exists else default
*/
public String s() {
- String s = manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n");
+ final String s = manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n");
return s.replace("$1", COLOR_1.toString()).replace("$2", COLOR_2.toString()).replace("$3", COLOR_3.toString()).replace("$4", COLOR_4.toString());
/*
* if (PlotSquared.translations != null) {
@@ -555,11 +549,11 @@ public enum C {
* return this.s.replace("\\n", "\n");
*/
}
-
+
public boolean usePrefix() {
return this.prefix;
}
-
+
/**
* @return translated and color decoded
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java
index f0b7b5b50..7d312e2e8 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.config;
import java.util.ArrayList;
@@ -32,32 +31,30 @@ import com.intellectualcrafters.plot.object.PlotBlock;
*
* @author Empire92
*/
-@SuppressWarnings("unused") public class Configuration {
-
+@SuppressWarnings("unused")
+public class Configuration {
public static final SettingValue STRING = new SettingValue("STRING") {
@Override
public boolean validateValue(final String string) {
return true;
}
-
+
@Override
public Object parseString(final String string) {
return string;
}
};
-
public static final SettingValue STRINGLIST = new SettingValue("STRINGLIST") {
@Override
public boolean validateValue(final String string) {
return true;
}
-
+
@Override
public Object parseString(final String string) {
return string.split(",");
}
};
-
public static final SettingValue INTEGER = new SettingValue("INTEGER") {
@Override
public boolean validateValue(final String string) {
@@ -68,13 +65,12 @@ import com.intellectualcrafters.plot.object.PlotBlock;
return false;
}
}
-
+
@Override
public Object parseString(final String string) {
return Integer.parseInt(string);
}
};
-
public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") {
@Override
public boolean validateValue(final String string) {
@@ -85,13 +81,12 @@ import com.intellectualcrafters.plot.object.PlotBlock;
return false;
}
}
-
+
@Override
public Object parseString(final String string) {
return Boolean.parseBoolean(string);
}
};
-
public static final SettingValue DOUBLE = new SettingValue("DOUBLE") {
@Override
public boolean validateValue(final String string) {
@@ -102,13 +97,12 @@ import com.intellectualcrafters.plot.object.PlotBlock;
return false;
}
}
-
+
@Override
public Object parseString(final String string) {
return Double.parseDouble(string);
}
};
-
public static final SettingValue BIOME = new SettingValue("BIOME") {
@Override
public boolean validateValue(final String string) {
@@ -119,7 +113,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
return false;
}
}
-
+
@Override
public Object parseString(final String string) {
for (final Biome biome : Biome.values()) {
@@ -129,13 +123,12 @@ import com.intellectualcrafters.plot.object.PlotBlock;
}
return Biome.FOREST;
}
-
+
@Override
public Object parseObject(final Object object) {
return (((Biome) object)).toString();
}
};
-
public static final SettingValue BLOCK = new SettingValue("BLOCK") {
@Override
public boolean validateValue(final String string) {
@@ -152,7 +145,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
return false;
}
}
-
+
@Override
public Object parseString(final String string) {
if (string.contains(":")) {
@@ -162,7 +155,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
return new PlotBlock(Short.parseShort(string), (byte) 0);
}
}
-
+
@Override
public Object parseObject(final Object object) {
return object;
@@ -191,12 +184,11 @@ import com.intellectualcrafters.plot.object.PlotBlock;
return false;
}
}
-
+
@Override
public Object parseString(final String string) {
final String[] blocks = string.split(",");
final ArrayList parsedvalues = new ArrayList<>();
-
final PlotBlock[] values = new PlotBlock[blocks.length];
final int[] counts = new int[blocks.length];
int min = 100;
@@ -229,23 +221,22 @@ import com.intellectualcrafters.plot.object.PlotBlock;
parsedvalues.add(values[i]);
}
}
-
return parsedvalues.toArray(new PlotBlock[parsedvalues.size()]);
}
-
+
@Override
public Object parseObject(final Object object) {
return object;
}
};
-
+
public static int gcd(final int a, final int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
-
+
private static int gcd(final int[] a) {
int result = a[0];
for (int i = 1; i < a.length; i++) {
@@ -253,27 +244,27 @@ import com.intellectualcrafters.plot.object.PlotBlock;
}
return result;
}
-
+
/**
* Create your own SettingValue object to make the management of plotworld configuration easier
*/
public static abstract class SettingValue {
private final String type;
-
+
public SettingValue(final String type) {
this.type = type;
}
-
+
public String getType() {
return this.type;
}
-
+
public Object parseObject(final Object object) {
return object;
}
-
+
public abstract Object parseString(final String string);
-
+
public abstract boolean validateValue(final String string);
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java
index 0c0fceca9..da13195e6 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.config;
import java.util.ArrayList;
@@ -41,7 +40,7 @@ public class ConfigurationNode {
private final String description;
private final SettingValue type;
private Object value;
-
+
public ConfigurationNode(final String constant, final Object default_value, final String description, final SettingValue type, final boolean required) {
this.constant = constant;
this.default_value = default_value;
@@ -49,11 +48,11 @@ public class ConfigurationNode {
this.value = default_value;
this.type = type;
}
-
+
public SettingValue getType() {
return this.type;
}
-
+
public boolean isValid(final String string) {
try {
final Object result = this.type.parseString(string);
@@ -62,7 +61,7 @@ public class ConfigurationNode {
return false;
}
}
-
+
public boolean setValue(final String string) {
if (!this.type.validateValue(string)) {
return false;
@@ -70,35 +69,33 @@ public class ConfigurationNode {
this.value = this.type.parseString(string);
return true;
}
-
+
public Object getValue() {
if (this.value instanceof String[]) {
return Arrays.asList((String[]) this.value);
- }
- else if (this.value instanceof Object[]) {
- List values = new ArrayList();
- for (Object value : (Object[]) this.value) {
+ } else if (this.value instanceof Object[]) {
+ final List values = new ArrayList();
+ for (final Object value : (Object[]) this.value) {
values.add(value.toString());
}
return values;
- }
- else if (this.value instanceof PlotBlock) {
+ } else if (this.value instanceof PlotBlock) {
return this.value.toString();
}
return this.value;
}
-
+
public String getConstant() {
return this.constant;
}
-
+
public Object getDefaultValue() {
if (this.default_value instanceof Object[]) {
return StringUtils.join((Object[]) this.default_value, ",");
}
return this.default_value;
}
-
+
public String getDescription() {
return this.description;
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java
index e9cd1f485..bc9d8e51f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java
@@ -18,10 +18,8 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.config;
-
/**
* Updater and DB settings
*
@@ -29,15 +27,15 @@ package com.intellectualcrafters.plot.config;
* @author Empire92
*/
public class Settings {
- public static boolean ENABLE_CLUSTERS = false;
+ public static boolean ENABLE_CLUSTERS = false;
/**
* Default UUID_FECTHING: false
*/
public static boolean UUID_FECTHING = false;
public static boolean UUID_FROM_DISK = false;
/**
- *
- */
+ *
+ */
public static boolean CONVERT_PLOTME = true;
public static boolean USE_PLOTME_ALIAS = false;
/**
@@ -63,11 +61,11 @@ public class Settings {
/**
* Mob Cap Enabled
*/
-// public static boolean MOB_CAP_ENABLED = false;
+ // public static boolean MOB_CAP_ENABLED = false;
/**
* The Mob Cap
*/
-// public static int MOB_CAP = 20;
+ // public static int MOB_CAP = 20;
/**
* Display titles
*/
@@ -104,7 +102,6 @@ public class Settings {
* Delete plots on ban?
*/
public static boolean DELETE_PLOTS_ON_BAN = false;
-
/**
* Verbose?
*/
@@ -113,7 +110,6 @@ public class Settings {
* Have colored console messages?
*/
public static boolean CONSOLE_COLOR = true;
-
/**
* The delay (in seconds) before teleportation commences
*/
@@ -122,30 +118,25 @@ public class Settings {
* Auto clear enabled
*/
public static boolean AUTO_CLEAR = false;
-
/**
* Days until a plot gets cleared
*/
public static int AUTO_CLEAR_DAYS = 360;
public static boolean AUTO_CLEAR_CHECK_DISK = false;
-
public static int MIN_BLOCKS_CHANGED = -1;
-
/**
* API Location
*/
public static String API_URL = "http://www.intellectualsites.com/minecraft.php";
-
/**
* Use the custom API
*/
public static boolean CUSTOM_API = true;
-
/**
* Use offline mode storage
*/
public static boolean OFFLINE_MODE = false;
-
+
/**
* Database settings
*
@@ -155,10 +146,10 @@ public class Settings {
/**
* MongoDB enabled?
*/
- public static boolean USE_MONGO = false; /*
- * TODO: Implement Mongo
- * @Brandon
- */
+ public static boolean USE_MONGO = false; /*
+ * TODO: Implement Mongo
+ * @Brandon
+ */
/**
* SQLite enabled?
*/
@@ -166,7 +157,7 @@ public class Settings {
/**
* MySQL Enabled?
*/
- public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */
+ public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */
/**
* SQLite Database name
*/
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java
index 37594fdfa..f898bd9af 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.database;
import java.sql.SQLException;
@@ -41,14 +40,12 @@ import com.intellectualcrafters.plot.object.PlotId;
* @author Empire92
*/
public interface AbstractDB {
-
// TODO MongoDB @Brandon
-
/**
* The UUID that will count as everyone
*/
public UUID everyone = UUID.fromString("1-1-3-3-7");
-
+
/**
* Set Plot owner
*
@@ -56,28 +53,28 @@ public interface AbstractDB {
* @param uuid The uuid of the new owner
*/
public void setOwner(final Plot plot, final UUID uuid);
-
+
/**
* Create all settings, and create default helpers, trusted + denied lists
*
* @param plots Plots for which the default table entries should be created
*/
public void createAllSettingsAndHelpers(final ArrayList plots);
-
+
/**
* Create a plot
*
* @param plots Plots that should be created
*/
public void createPlots(final ArrayList plots);
-
+
/**
* Create a plot
*
* @param plot That should be created
*/
public void createPlot(final Plot plot);
-
+
/**
* Create tables
*
@@ -86,7 +83,7 @@ public interface AbstractDB {
* @throws SQLException If the database manager is unable to create the tables
*/
public void createTables(final String database, final boolean add_constraint) throws Exception;
-
+
/**
* Delete a plot
*
@@ -95,7 +92,7 @@ public interface AbstractDB {
public void delete(final String world, final Plot plot);
public void delete(final PlotCluster cluster);
-
+
/**
* Create plot settings
*
@@ -103,7 +100,7 @@ public interface AbstractDB {
* @param plot Plot Object
*/
public void createPlotSettings(final int id, final Plot plot);
-
+
/**
* Get the table entry ID
*
@@ -118,7 +115,7 @@ public interface AbstractDB {
* Get the id of a given plot cluster
*
* @param world Which the plot is located in
- * @param pos1 bottom Plot ID
+ * @param pos1 bottom Plot ID
* @param pos2 top Plot ID
*
* @return Integer = Cluster Entry Id
@@ -129,7 +126,7 @@ public interface AbstractDB {
* @return A linked hashmap containing all plots
*/
public LinkedHashMap> getPlots();
-
+
/**
* @return A hashmap containing all plot clusters
*/
@@ -143,14 +140,14 @@ public interface AbstractDB {
* @param merged boolean[]
*/
public void setMerged(final String world, final Plot plot, final boolean[] merged);
-
+
/**
* Swap the settings, helpers etc. of two plots
* @param p1 Plot1
* @param p2 Plot2
*/
public void swapPlots(final Plot p1, final Plot p2);
-
+
/**
* Set plot flags
*
@@ -174,7 +171,6 @@ public interface AbstractDB {
*/
public void setClusterName(final PlotCluster cluster, final String name);
-
/**
* Set the plot alias
*
@@ -182,7 +178,7 @@ public interface AbstractDB {
* @param alias Plot Alias
*/
public void setAlias(final String world, final Plot plot, final String alias);
-
+
/**
* Purgle a plot
*
@@ -190,14 +186,14 @@ public interface AbstractDB {
* @param id Plot ID
*/
public void purgeIds(final String world, final Set uniqueIds);
-
+
/**
* Purge a whole world
*
* @param world World in which the plots should be purged
*/
public void purge(final String world, final Set plotIds);
-
+
/**
* Set Plot Home Position
*
@@ -207,12 +203,12 @@ public interface AbstractDB {
public void setPosition(final String world, final Plot plot, final String position);
/**
- *
+ *
* @param cluster
* @param position
*/
public void setPosition(final PlotCluster cluster, final String position);
-
+
/**
* @param id Plot Entry ID
*
@@ -221,12 +217,12 @@ public interface AbstractDB {
public HashMap getSettings(final int id);
/**
- *
+ *
* @param id
* @return
*/
public HashMap getClusterSettings(final int id);
-
+
/**
* @param plot Plot Object
* @param uuid Player that should be removed
@@ -238,18 +234,20 @@ public interface AbstractDB {
* @param uuid Player that should be removed
*/
public void removeHelper(final PlotCluster cluster, final UUID uuid);
-
+
/**
* @param plot Plot Object
* @param uuid Player that should be removed
*/
public void removeTrusted(final String world, final Plot plot, final UUID uuid);
+
/**
- *
+ *
* @param cluster
* @param uuid
*/
public void removeInvited(final PlotCluster cluster, final UUID uuid);
+
/**
* @param plot Plot Object
* @param uuid Player that should be removed
@@ -261,32 +259,33 @@ public interface AbstractDB {
* @param uuid Player that should be removed
*/
public void setHelper(final PlotCluster cluster, final UUID uuid);
-
+
/**
* @param plot Plot Object
* @param uuid Player that should be added
*/
public void setTrusted(final String world, final Plot plot, final UUID uuid);
+
/**
- *
+ *
* @param world
* @param cluster
* @param uuid
*/
public void setInvited(final String world, final PlotCluster cluster, final UUID uuid);
-
+
/**
* @param plot Plot Object
* @param player Player that should be added
*/
public void removeDenied(final String world, final Plot plot, final UUID uuid);
-
+
/**
* @param plot Plot Object
* @param player Player that should be added
*/
public void setDenied(final String world, final Plot plot, final UUID uuid);
-
+
/**
* Get Plots ratings
*
@@ -295,7 +294,7 @@ public interface AbstractDB {
* @return Plot Ratings (pre-calculated)
*/
public double getRatings(final Plot plot);
-
+
/**
* Remove a plot comment
*
@@ -304,7 +303,7 @@ public interface AbstractDB {
* @param comment Comment to remove
*/
public void removeComment(final String world, final Plot plot, final PlotComment comment);
-
+
/**
* Set a plot comment
*
@@ -313,7 +312,7 @@ public interface AbstractDB {
* @param comment Comment to add
*/
public void setComment(final String world, final Plot plot, final PlotComment comment);
-
+
/**
* Get Plot Comments
*
@@ -324,12 +323,12 @@ public interface AbstractDB {
* @return Plot Comments within the specified tier
*/
public ArrayList getComments(final String world, final Plot plot, final int tier, boolean below);
-
+
public void createPlotAndSettings(Plot plot);
public void createCluster(PlotCluster cluster);
public void resizeCluster(PlotCluster current, PlotClusterId resize);
-
+
public void movePlot(String world, PlotId originalPlot, PlotId newPlot);
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java
index 02cfb20c9..9f5ae964f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.database;
import java.util.ArrayList;
@@ -42,7 +41,6 @@ import com.intellectualcrafters.plot.object.PlotId;
* @author Citymonstret
*/
public class DBFunc {
-
/**
* The "global" uuid
*/
@@ -51,8 +49,8 @@ public class DBFunc {
* Abstract Database Manager
*/
public static AbstractDB dbManager;
-
- public static void movePlot(String world, PlotId originalPlot, PlotId newPlot) {
+
+ public static void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
dbManager.movePlot(world, originalPlot, newPlot);
}
@@ -65,7 +63,7 @@ public class DBFunc {
public static void setOwner(final Plot plot, final UUID uuid) {
dbManager.setOwner(plot, uuid);
}
-
+
/**
* Create all settings + (helpers, denied, trusted)
*
@@ -74,7 +72,7 @@ public class DBFunc {
public static void createAllSettingsAndHelpers(final ArrayList plots) {
dbManager.createAllSettingsAndHelpers(plots);
}
-
+
/**
* Create all plots
*
@@ -83,7 +81,7 @@ public class DBFunc {
public static void createPlots(final ArrayList plots) {
dbManager.createPlots(plots);
}
-
+
/**
* Create a plot
*
@@ -101,7 +99,7 @@ public class DBFunc {
public static void createPlotAndSettings(final Plot plot) {
dbManager.createPlotAndSettings(plot);
}
-
+
/**
* Create tables
*
@@ -110,7 +108,7 @@ public class DBFunc {
public static void createTables(final String database, final boolean add_constraint) throws Exception {
dbManager.createTables(database, add_constraint);
}
-
+
/**
* Delete a plot
*
@@ -123,7 +121,7 @@ public class DBFunc {
public static void delete(final PlotCluster toDelete) {
dbManager.delete(toDelete);
}
-
+
/**
* Create plot settings
*
@@ -133,7 +131,7 @@ public class DBFunc {
public static void createPlotSettings(final int id, final Plot plot) {
dbManager.createPlotSettings(id, plot);
}
-
+
/**
* Get a plot id
*
@@ -155,18 +153,18 @@ public class DBFunc {
public static int getId(final String world, final PlotId id2) {
return dbManager.getId(world, id2);
}
-
+
/**
* @return Plots
*/
public static LinkedHashMap> getPlots() {
return dbManager.getPlots();
}
-
+
public static void setMerged(final String world, final Plot plot, final boolean[] merged) {
dbManager.setMerged(world, plot, merged);
}
-
+
public static void setFlags(final String world, final Plot plot, final Set flags) {
dbManager.setFlags(world, plot, flags);
}
@@ -174,7 +172,7 @@ public class DBFunc {
public static void setFlags(final PlotCluster cluster, final Set flags) {
dbManager.setFlags(cluster, flags);
}
-
+
/**
* @param plot
* @param alias
@@ -182,15 +180,15 @@ public class DBFunc {
public static void setAlias(final String world, final Plot plot, final String alias) {
dbManager.setAlias(world, plot, alias);
}
-
+
public static void purgeIds(final String world, final Set uniqueIds) {
dbManager.purgeIds(world, uniqueIds);
}
-
+
public static void purge(final String world, final Set plotIds) {
dbManager.purge(world, plotIds);
}
-
+
/**
* @param plot
* @param position
@@ -198,7 +196,7 @@ public class DBFunc {
public static void setPosition(final String world, final Plot plot, final String position) {
dbManager.setPosition(world, plot, position);
}
-
+
/**
* @param id
*
@@ -207,7 +205,7 @@ public class DBFunc {
public static HashMap getSettings(final int id) {
return dbManager.getSettings(id);
}
-
+
/**
* @param plot
* @param comment
@@ -215,7 +213,7 @@ public class DBFunc {
public static void removeComment(final String world, final Plot plot, final PlotComment comment) {
dbManager.removeComment(world, plot, comment);
}
-
+
/**
* @param plot
* @param comment
@@ -223,14 +221,14 @@ public class DBFunc {
public static void setComment(final String world, final Plot plot, final PlotComment comment) {
dbManager.setComment(world, plot, comment);
}
-
+
/**
* @param plot
*/
public static ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) {
return dbManager.getComments(world, plot, tier, below);
}
-
+
/**
* @param plot
* @param player
@@ -246,25 +244,25 @@ public class DBFunc {
public static void removeHelper(final PlotCluster cluster, final UUID uuid) {
dbManager.removeHelper(cluster, uuid);
}
-
+
/**
* @param world
* @param cluster
* @param name
*/
- public static void createCluster(String world, PlotCluster cluster) {
- dbManager.createCluster(cluster);
+ public static void createCluster(final String world, final PlotCluster cluster) {
+ dbManager.createCluster(cluster);
}
-
+
/**
* @param world
* @param current
* @param resize
*/
- public static void resizeCluster(PlotCluster current, PlotClusterId resize) {
- dbManager.resizeCluster(current, resize);
+ public static void resizeCluster(final PlotCluster current, final PlotClusterId resize) {
+ dbManager.resizeCluster(current, resize);
}
-
+
/**
* @param plot
* @param player
@@ -274,7 +272,7 @@ public class DBFunc {
}
/**
- *
+ *
* @param world
* @param plot
* @param uuid
@@ -282,7 +280,7 @@ public class DBFunc {
public static void removeInvited(final PlotCluster cluster, final UUID uuid) {
dbManager.removeInvited(cluster, uuid);
}
-
+
/**
* @param plot
* @param player
@@ -294,7 +292,7 @@ public class DBFunc {
public static void setHelper(final PlotCluster cluster, final UUID uuid) {
dbManager.setHelper(cluster, uuid);
}
-
+
/**
* @param plot
* @param player
@@ -306,7 +304,7 @@ public class DBFunc {
public static void setInvited(final String world, final PlotCluster cluster, final UUID uuid) {
dbManager.setInvited(world, cluster, uuid);
}
-
+
/**
* @param plot
* @param player
@@ -314,7 +312,7 @@ public class DBFunc {
public static void removeDenied(final String world, final Plot plot, final UUID uuid) {
dbManager.removeDenied(world, plot, uuid);
}
-
+
/**
* @param plot
* @param player
@@ -328,14 +326,14 @@ public class DBFunc {
}
public static HashMap> getClusters() {
- return dbManager.getClusters();
+ return dbManager.getClusters();
}
- public static void setPosition(PlotCluster cluster, String position) {
- dbManager.setPosition(cluster, position);
+ public static void setPosition(final PlotCluster cluster, final String position) {
+ dbManager.setPosition(cluster, position);
}
- public static HashMap getClusterSettings(int id) {
+ public static HashMap getClusterSettings(final int id) {
return dbManager.getClusterSettings(id);
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java
index 0e3b503e9..fba75f6b3 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.database;
import java.sql.Connection;
@@ -34,12 +33,11 @@ import com.intellectualcrafters.plot.PlotSquared;
* @author tips48
*/
public abstract class Database {
-
/**
* Plugin instance, use for plugin.getDataFolder()
*/
protected final PlotSquared plotsquared;
-
+
/**
* Creates a new Database
*
@@ -48,7 +46,7 @@ public abstract class Database {
protected Database(final PlotSquared plotsquared) {
this.plotsquared = plotsquared;
}
-
+
/**
* Opens a connection with the database
*
@@ -58,7 +56,7 @@ public abstract class Database {
* @throws ClassNotFoundException if the driver cannot be found
*/
public abstract Connection openConnection() throws SQLException, ClassNotFoundException;
-
+
/**
* Checks if a connection is open with the database
*
@@ -67,14 +65,14 @@ public abstract class Database {
* @throws SQLException if the connection cannot be checked
*/
public abstract boolean checkConnection() throws SQLException;
-
+
/**
* Gets the connection with the database
*
* @return Connection with the database, null if none
*/
public abstract Connection getConnection();
-
+
/**
* Closes the connection with the database
*
@@ -83,7 +81,7 @@ public abstract class Database {
* @throws SQLException if the connection cannot be closed
*/
public abstract boolean closeConnection() throws SQLException;
-
+
/**
* Executes a SQL Query If the connection is closed, it will be opened
*
@@ -95,7 +93,7 @@ public abstract class Database {
* @throws ClassNotFoundException If the driver cannot be found; see {@link #openConnection()}
*/
public abstract ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException;
-
+
/**
* Executes an Update SQL Query See {@link java.sql.Statement#executeUpdate(String)} If the connection is
* closed, it will be opened
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java
index 6622a85c5..4f7856d70 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.database;
import java.sql.Connection;
@@ -41,9 +40,8 @@ public class MySQL extends Database {
private final String password;
private final String port;
private final String hostname;
-
private Connection connection;
-
+
/**
* Creates a new MySQL instance
*
@@ -63,14 +61,13 @@ public class MySQL extends Database {
this.password = password;
this.connection = null;
}
-
-
+
public Connection forceConnection() throws SQLException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
return this.connection;
}
-
+
@Override
public Connection openConnection() throws SQLException, ClassNotFoundException {
if (checkConnection()) {
@@ -80,17 +77,17 @@ public class MySQL extends Database {
this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
return this.connection;
}
-
+
@Override
public boolean checkConnection() throws SQLException {
return (this.connection != null) && !this.connection.isClosed();
}
-
+
@Override
public Connection getConnection() {
return this.connection;
}
-
+
@Override
public boolean closeConnection() throws SQLException {
if (this.connection == null) {
@@ -99,27 +96,22 @@ public class MySQL extends Database {
this.connection.close();
return true;
}
-
+
@Override
public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException {
if (checkConnection()) {
openConnection();
}
-
final Statement statement = this.connection.createStatement();
-
return statement.executeQuery(query);
}
-
+
@Override
public int updateSQL(final String query) throws SQLException, ClassNotFoundException {
if (checkConnection()) {
openConnection();
}
-
final Statement statement = this.connection.createStatement();
-
return statement.executeUpdate(query);
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java
index 6bfc55e3e..35ebaabf1 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java
@@ -18,12 +18,10 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.database;
import java.io.File;
import java.io.IOException;
-import java.nio.ByteBuffer;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
@@ -54,7 +52,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
* @author Empire92
*/
public class PlotMeConverter {
-
/**
* Constructor
*
@@ -80,7 +77,6 @@ public class PlotMeConverter {
sendMessage("Connecting to PlotMe DB");
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
int count = 0;
-
Connection connection;
if (plotConfig.getBoolean("usemySQL")) {
final String user = plotConfig.getString("mySQLuname");
@@ -97,7 +93,6 @@ public class PlotMeConverter {
final HashMap plotSize = new HashMap<>();
final HashMap> plots = new HashMap<>();
final Set worlds = plotConfig.getConfigurationSection("worlds").getKeys(false);
-
stmt = connection.createStatement();
r = stmt.executeQuery("SELECT * FROM `plotmePlots`");
while (r.next()) {
@@ -105,8 +100,6 @@ public class PlotMeConverter {
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
final String name = r.getString("owner");
final String world = getWorld(r.getString("world"));
-
-
if (!plotSize.containsKey(world)) {
final int size = r.getInt("topZ") - r.getInt("bottomZ");
plotSize.put(world, size);
@@ -116,9 +109,8 @@ public class PlotMeConverter {
if (owner == null) {
if (name.equals("*")) {
owner = DBFunc.everyone;
- }
- else {
- sendMessage("&cCould not identify owner for plot: " + id +" -> " + name);
+ } else {
+ sendMessage("&cCould not identify owner for plot: " + id + " -> " + name);
continue;
}
}
@@ -163,31 +155,23 @@ public class PlotMeConverter {
plots.get(world).get(id).denied.add(denied);
}
}
-
sendMessage("Collected " + count + " plots from PlotMe");
-
for (final String world : plots.keySet()) {
sendMessage("Copying config for: " + world);
try {
- String plotMeWorldName = world.toLowerCase();
+ final String plotMeWorldName = world.toLowerCase();
final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
-
final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
-
final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); //
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
-
final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); //
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
-
final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); //
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
-
final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId");
PlotSquared.config.set("worlds." + world + ".road.block", road);
-
Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
if (height == null) {
height = 64;
@@ -197,53 +181,46 @@ public class PlotMeConverter {
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
}
}
-
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
if (PLOTME_DG_FILE.exists()) {
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
try {
for (final String world : plots.keySet()) {
- String plotMeWorldName = world.toLowerCase();
+ final String plotMeWorldName = world.toLowerCase();
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
if (pathwidth == null) {
pathwidth = 7;
}
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
-
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
if (plotsize == null) {
plotsize = 32;
}
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
-
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
if (wallblock == null) {
wallblock = "44";
}
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
-
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
if (floor == null) {
floor = "2";
}
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
-
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
if (filling == null) {
filling = "3";
}
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
-
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
if (road == null) {
road = "5";
}
PlotSquared.config.set("worlds." + world + ".road.block", road);
-
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
- if (height == null || height == 0) {
+ if ((height == null) || (height == 0)) {
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
- if (height == null || height == 0) {
+ if ((height == null) || (height == 0)) {
height = 64;
}
}
@@ -252,7 +229,6 @@ public class PlotMeConverter {
PlotSquared.config.set("worlds." + world + ".wall.height", height);
}
} catch (final Exception e) {
-
}
}
for (final String world : plots.keySet()) {
@@ -268,7 +244,6 @@ public class PlotMeConverter {
PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
}
}
-
sendMessage("Creating plot DB");
Thread.sleep(1000);
DBFunc.createPlots(createdPlots);
@@ -286,20 +261,16 @@ public class PlotMeConverter {
try {
boolean MV = false;
boolean MW = false;
-
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
MV = true;
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
MW = true;
}
-
for (final String worldname : worlds) {
final World world = Bukkit.getWorld(getWorld(worldname));
final String actualWorldName = world.getName();
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
-
PlotSquared.removePlotWorld(actualWorldName);
-
if (MV) {
// unload
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
@@ -326,7 +297,6 @@ public class PlotMeConverter {
myworld.save();
}
}
-
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
sendMessage("Conversion has finished");
PlotSquared.log("&cPlease disable 'plotme-convert.enabled' in the settings.yml to indicate that you conversion is no longer required.");
@@ -336,25 +306,17 @@ public class PlotMeConverter {
}
});
} catch (final Exception e) {
-
}
}
}, 20);
}
- public String getWorld(String world) {
- for (World newworld : Bukkit.getWorlds()) {
+ public String getWorld(final String world) {
+ for (final World newworld : Bukkit.getWorlds()) {
if (newworld.getName().equalsIgnoreCase(world)) {
return newworld.getName();
}
}
return world;
}
-
- private UUID uuidFromBytes(byte[] byteArray) {
- ByteBuffer wrapped = ByteBuffer.wrap(byteArray);
- long minor = wrapped.getLong();
- long major = wrapped.getLong();
- return new UUID(major, minor);
- }
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
index 38201d4ce..c28886d01 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.database;
import java.sql.Connection;
@@ -49,13 +48,11 @@ import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.TaskManager;
-import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
/**
* @author Citymonstret
*/
public class SQLManager implements AbstractDB {
-
// Public final
public final String SET_OWNER;
public final String GET_ALL_PLOTS;
@@ -67,7 +64,7 @@ public class SQLManager implements AbstractDB {
private final String prefix;
// Private Final
private Connection connection;
-
+
/**
* Constructor
*
@@ -80,7 +77,6 @@ public class SQLManager implements AbstractDB {
this.prefix = p;
// Set timout
// setTimout();
-
// Public final
this.SET_OWNER = "UPDATE `" + this.prefix + "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ?";
this.GET_ALL_PLOTS = "SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `" + this.prefix + "plot`";
@@ -89,7 +85,6 @@ public class SQLManager implements AbstractDB {
this.CREATE_HELPERS = "INSERT INTO `" + this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) values ";
this.CREATE_PLOT = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)";
this.CREATE_CLUSTER = "INSERT INTO `" + this.prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)";
-
// schedule reconnect
if (PlotSquared.getMySQL() != null) {
TaskManager.runTaskRepeat(new Runnable() {
@@ -103,9 +98,8 @@ public class SQLManager implements AbstractDB {
}
}, 11000);
}
-
}
-
+
/**
* Set Plot owner
*
@@ -114,7 +108,7 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void setOwner(final Plot plot, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -126,25 +120,24 @@ public class SQLManager implements AbstractDB {
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"Could not set owner for plot " + plot.id);
+ PlotSquared.log("&c[ERROR] " + "Could not set owner for plot " + plot.id);
}
}
});
}
-
+
@Override
public void createAllSettingsAndHelpers(final ArrayList mylist) {
- int size = mylist.size();
+ final int size = mylist.size();
int packet;
if (PlotSquared.getMySQL() != null) {
packet = Math.min(size, 50000);
- }
- else {
+ } else {
packet = Math.min(size, 5000);
}
- int amount = size/packet;
- for (int j = 0; j <= amount;j++) {
- List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet));
+ final int amount = size / packet;
+ for (int j = 0; j <= amount; j++) {
+ final List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet));
final HashMap> stored = new HashMap<>();
final HashMap> helpers = new HashMap<>();
try {
@@ -155,7 +148,6 @@ public class SQLManager implements AbstractDB {
final int idx = result.getInt("plot_id_x");
final int idz = result.getInt("plot_id_z");
final String world = result.getString("world");
-
if (!stored.containsKey(world)) {
stored.put(world, new HashMap());
}
@@ -194,8 +186,8 @@ public class SQLManager implements AbstractDB {
stmt.executeUpdate();
stmt.close();
} catch (final SQLException e) {
- for (int i = 0; i < ids.length; i++) {
- createPlotSettings(ids[i], null);
+ for (final Integer id : ids) {
+ createPlotSettings(id, null);
}
}
// add plot helpers
@@ -215,7 +207,6 @@ public class SQLManager implements AbstractDB {
int counter = 0;
for (final Integer id : helpers.keySet()) {
for (final UUID helper : helpers.get(id)) {
-
stmt.setInt((counter * 2) + 1, id);
stmt.setString((counter * 2) + 2, helper.toString());
counter++;
@@ -230,13 +221,13 @@ public class SQLManager implements AbstractDB {
setHelper(id, helper);
}
}
+ } catch (final Exception e2) {
}
- catch (Exception e2) {}
- PlotSquared.log("&7[WARN] "+"Failed to set all helpers for plots");
+ PlotSquared.log("&7[WARN] " + "Failed to set all helpers for plots");
}
}
}
-
+
/**
* Create a plot
*
@@ -244,27 +235,24 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void createPlots(final ArrayList mylist) {
- int size = mylist.size();
+ final int size = mylist.size();
int packet;
if (PlotSquared.getMySQL() != null) {
packet = Math.min(size, 50000);
- }
- else {
+ } else {
packet = Math.min(size, 5000);
}
- int amount = size/packet;
- for (int j = 0; j <= amount;j++) {
- List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet));
+ final int amount = size / packet;
+ for (int j = 0; j <= amount; j++) {
+ final List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet));
if (plots.size() == 0) {
return;
}
final StringBuilder statement = new StringBuilder(this.CREATE_PLOTS);
-
for (int i = 0; i < (plots.size() - 1); i++) {
statement.append("(?,?,?,?),");
}
statement.append("(?,?,?,?)");
-
PreparedStatement stmt = null;
try {
stmt = this.connection.prepareStatement(statement.toString());
@@ -274,8 +262,7 @@ public class SQLManager implements AbstractDB {
stmt.setInt((i * 4) + 2, plot.id.y);
try {
stmt.setString((i * 4) + 3, plot.owner.toString());
- }
- catch (Exception e) {
+ } catch (final Exception e) {
stmt.setString((i * 4) + 3, DBFunc.everyone.toString());
}
stmt.setString((i * 4) + 4, plot.world);
@@ -284,25 +271,23 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final Exception e) {
e.printStackTrace();
- PlotSquared.log("&6[WARN] "+"Could not bulk save. Conversion may be slower...");
+ PlotSquared.log("&6[WARN] " + "Could not bulk save. Conversion may be slower...");
try {
- for (Plot plot : plots) {
+ for (final Plot plot : plots) {
try {
createPlot(plot);
- }
- catch (Exception e3) {
- PlotSquared.log("&c[ERROR] "+"Failed to save plot: "+plot.id);
+ } catch (final Exception e3) {
+ PlotSquared.log("&c[ERROR] " + "Failed to save plot: " + plot.id);
}
}
- }
- catch (Exception e2) {
+ } catch (final Exception e2) {
e2.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"Failed to save plots!");
+ PlotSquared.log("&c[ERROR] " + "Failed to save plots!");
}
}
}
}
-
+
/**
* Create a plot
*
@@ -310,7 +295,7 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void createPlot(final Plot plot) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -324,15 +309,15 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final Exception e) {
e.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"Failed to save plot " + plot.id);
+ PlotSquared.log("&c[ERROR] " + "Failed to save plot " + plot.id);
}
}
});
}
-
+
@Override
public void createPlotAndSettings(final Plot plot) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -344,20 +329,18 @@ public class SQLManager implements AbstractDB {
stmt.setString(4, plot.world);
stmt.executeUpdate();
stmt.close();
-
- int id = getId(plot.world, plot.id);
+ final int id = getId(plot.world, plot.id);
stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
stmt.setInt(1, id);
stmt.executeUpdate();
stmt.close();
} catch (final Exception e) {
e.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"Failed to save plot " + plot.id);
+ PlotSquared.log("&c[ERROR] " + "Failed to save plot " + plot.id);
}
}
});
}
-
/**
* Create tables
@@ -366,7 +349,6 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void createTables(final String database, final boolean add_constraint) throws SQLException {
-
final boolean mysql = database.equals("mysql");
final Statement stmt = this.connection.createStatement();
if (mysql) {
@@ -382,18 +364,16 @@ public class SQLManager implements AbstractDB {
}
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
- stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
-
} else {
- stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
+ stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`tier` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))");
-
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
@@ -403,7 +383,7 @@ public class SQLManager implements AbstractDB {
stmt.clearBatch();
stmt.close();
}
-
+
/**
* Delete a plot
*
@@ -412,7 +392,7 @@ public class SQLManager implements AbstractDB {
@Override
public void delete(final String world, final Plot plot) {
PlotSquared.removePlot(world, plot.id, false);
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -444,7 +424,7 @@ public class SQLManager implements AbstractDB {
}
});
}
-
+
/**
* Create plot settings
*
@@ -453,7 +433,7 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void createPlotSettings(final int id, final Plot plot) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -465,11 +445,10 @@ public class SQLManager implements AbstractDB {
} catch (final SQLException e) {
e.printStackTrace();
}
-
}
});
}
-
+
@Override
public int getId(final String world, final PlotId id2) {
PreparedStatement stmt = null;
@@ -491,7 +470,7 @@ public class SQLManager implements AbstractDB {
}
return Integer.MAX_VALUE;
}
-
+
/**
* Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap
*/
@@ -524,17 +503,14 @@ public class SQLManager implements AbstractDB {
e.printStackTrace();
}
final HashMap plots = new HashMap<>();
-
Statement stmt = null;
try {
-
Set worlds = new HashSet<>();
if (PlotSquared.config.contains("worlds")) {
worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false);
}
final HashMap uuids = new HashMap();
final HashMap noExist = new HashMap();
-
/*
* Getting plots
*/
@@ -562,10 +538,9 @@ public class SQLManager implements AbstractDB {
user = UUID.fromString(o);
uuids.put(o, user);
}
- p = new Plot(plot_id, user, new ArrayList(), new ArrayList(), new ArrayList(), "", null, null, worldname, new boolean[]{false, false, false, false});
+ p = new Plot(plot_id, user, new ArrayList(), new ArrayList(), new ArrayList(), "", null, null, worldname, new boolean[] { false, false, false, false });
plots.put(id, p);
}
-
/*
* Getting helpers
*/
@@ -628,7 +603,6 @@ public class SQLManager implements AbstractDB {
id = r.getInt("plot_plot_id");
final Plot plot = plots.get(id);
if (plot != null) {
-
final String b = r.getString("biome");
if (b != null) {
for (final Biome mybiome : Biome.values()) {
@@ -637,14 +611,11 @@ public class SQLManager implements AbstractDB {
}
}
}
-
final String alias = r.getString("alias");
if (alias != null) {
plot.settings.setAlias(alias);
}
-
final String pos = r.getString("position");
-
switch (pos.toLowerCase()) {
case "":
case "default":
@@ -653,11 +624,11 @@ public class SQLManager implements AbstractDB {
break;
default:
try {
- String[] split = pos.split(",");
- BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Integer.parseInt(split[2]));
+ final String[] split = pos.split(",");
+ final BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));
plot.settings.setPosition(loc);
+ } catch (final Exception e) {
}
- catch (Exception e) {}
}
final Integer m = r.getInt("merged");
if (m != null) {
@@ -667,19 +638,17 @@ public class SQLManager implements AbstractDB {
}
plot.settings.setMerged(merged);
} else {
- plot.settings.setMerged(new boolean[]{false, false, false, false});
+ plot.settings.setMerged(new boolean[] { false, false, false, false });
}
-
String[] flags_string;
final String myflags = r.getString("flags");
if (myflags == null) {
- flags_string = new String[]{};
+ flags_string = new String[] {};
} else {
if (myflags.length() > 0) {
flags_string = myflags.split(",");
- }
- else {
- flags_string = new String[]{};
+ } else {
+ flags_string = new String[] {};
}
}
final Set flags = new HashSet();
@@ -688,8 +657,8 @@ public class SQLManager implements AbstractDB {
if (element.contains(":")) {
final String[] split = element.split(":");
try {
- String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
- Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str);
+ final String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
+ final Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str);
flags.add(flag);
} catch (final Exception e) {
e.printStackTrace();
@@ -726,16 +695,16 @@ public class SQLManager implements AbstractDB {
PlotSquared.log("&c[WARNING] - Please create the world/s or remove the plots using the purge command");
}
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to load plots.");
+ PlotSquared.log("&7[WARN] " + "Failed to load plots.");
e.printStackTrace();
}
return newplots;
}
-
+
@Override
public void setMerged(final String world, final Plot plot, final boolean[] merged) {
plot.settings.setMerged(merged);
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -750,71 +719,67 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Could not set merged for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Could not set merged for plot " + plot.id);
}
}
});
}
-
+
@Override
public void swapPlots(final Plot p1, final Plot p2) {
- BukkitTaskManager.runTaskAsync(
- new Runnable() {
- @Override
- public void run() {
- /*
- * We don't need to actually swap all the rows
- * - Just switch the plot_id_x and plot_id_z
- * - The other tables reference the `id` so it will cascade
- */
- try {
- String world = p1.world;
- int id1 = getId(world, p1.id);
- int id2 = getId(world, p2.id);
- PlotId pos1 = p1.getId();
- PlotId pos2 = p2.getId();
- PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
- stmt.setInt(1, pos2.x);
- stmt.setInt(2, pos2.y);
- stmt.setInt(3, id1);
- stmt.executeUpdate();
- stmt.close();
- stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
- stmt.setInt(1, pos1.x);
- stmt.setInt(2, pos1.y);
- stmt.setInt(3, id2);
- stmt.executeUpdate();
- stmt.close();
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
+ TaskManager.runTaskAsync(new Runnable() {
+ @Override
+ public void run() {
+ /*
+ * We don't need to actually swap all the rows
+ * - Just switch the plot_id_x and plot_id_z
+ * - The other tables reference the `id` so it will cascade
+ */
+ try {
+ final String world = p1.world;
+ final int id1 = getId(world, p1.id);
+ final int id2 = getId(world, p2.id);
+ final PlotId pos1 = p1.getId();
+ final PlotId pos2 = p2.getId();
+ PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
+ stmt.setInt(1, pos2.x);
+ stmt.setInt(2, pos2.y);
+ stmt.setInt(3, id1);
+ stmt.executeUpdate();
+ stmt.close();
+ stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
+ stmt.setInt(1, pos1.x);
+ stmt.setInt(2, pos1.y);
+ stmt.setInt(3, id2);
+ stmt.executeUpdate();
+ stmt.close();
+ } catch (final Exception e) {
+ e.printStackTrace();
}
- );
+ }
+ });
}
@Override
public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
- BukkitTaskManager.runTaskAsync(
- new Runnable() {
- @Override
- public void run() {
- try {
- int id = getId(world, originalPlot);
- PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
- stmt.setInt(1, newPlot.x);
- stmt.setInt(2, newPlot.y);
- stmt.setInt(3, id);
- stmt.executeUpdate();
- stmt.close();
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
+ TaskManager.runTaskAsync(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ final int id = getId(world, originalPlot);
+ final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
+ stmt.setInt(1, newPlot.x);
+ stmt.setInt(2, newPlot.y);
+ stmt.setInt(3, id);
+ stmt.executeUpdate();
+ stmt.close();
+ } catch (final Exception e) {
+ e.printStackTrace();
}
- );
+ }
+ });
}
-
+
@Override
public void setFlags(final String world, final Plot plot, final Set flags) {
final StringBuilder flag_string = new StringBuilder();
@@ -826,7 +791,7 @@ public class SQLManager implements AbstractDB {
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
i++;
}
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -837,12 +802,12 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Could not set flag for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Could not set flag for plot " + plot.id);
}
}
});
}
-
+
public void setFlags(final int id, final Flag[] flags) {
final ArrayList newflags = new ArrayList();
for (final Flag flag : flags) {
@@ -851,7 +816,7 @@ public class SQLManager implements AbstractDB {
}
}
final String flag_string = StringUtils.join(newflags, ",");
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -862,12 +827,12 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Could not set flag for plot " + id);
+ PlotSquared.log("&7[WARN] " + "Could not set flag for plot " + id);
}
}
});
}
-
+
/**
* @param plot
* @param alias
@@ -875,7 +840,7 @@ public class SQLManager implements AbstractDB {
@Override
public void setAlias(final String world, final Plot plot, final String alias) {
plot.settings.setAlias(alias);
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -886,24 +851,22 @@ public class SQLManager implements AbstractDB {
stmt.executeUpdate();
stmt.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set alias for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to set alias for plot " + plot.id);
e.printStackTrace();
}
-
}
});
}
-
+
/**
* Purge all plots with the following database IDs
*/
+ @Override
public void purgeIds(final String world, final Set uniqueIds) {
if (uniqueIds.size() > 0) {
try {
-
String stmt_prefix = "";
final StringBuilder idstr = new StringBuilder("");
-
for (final Integer id : uniqueIds) {
idstr.append(stmt_prefix + id);
stmt_prefix = " OR `plot_plot_id` = ";
@@ -911,43 +874,40 @@ public class SQLManager implements AbstractDB {
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + "");
stmt.executeUpdate();
stmt.close();
-
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr + "");
stmt.executeUpdate();
stmt.close();
-
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr + "");
stmt.executeUpdate();
stmt.close();
-
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr + "");
stmt.executeUpdate();
stmt.close();
-
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot` WHERE `world` = ?");
stmt.setString(1, world);
stmt.executeUpdate();
stmt.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!");
+ PlotSquared.log("&c[ERROR] " + "FAILED TO PURGE WORLD '" + world + "'!");
return;
}
}
- PlotSquared.log("&6[INFO] "+"SUCCESSFULLY PURGED WORLD '" + world + "'!");
+ PlotSquared.log("&6[INFO] " + "SUCCESSFULLY PURGED WORLD '" + world + "'!");
}
+
@Override
- public void purge(final String world, Set plots) {
- for (PlotId id : plots) {
- PlotSquared.removePlot(world, id, true);
- }
+ public void purge(final String world, final Set plots) {
+ for (final PlotId id : plots) {
+ PlotSquared.removePlot(world, id, true);
+ }
PreparedStatement stmt;
try {
stmt = SQLManager.this.connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + this.prefix + "plot` WHERE `world` = ?");
stmt.setString(1, world);
- ResultSet r = stmt.executeQuery();
+ final ResultSet r = stmt.executeQuery();
PlotId plot_id;
- Set ids = new HashSet<>();
+ final Set ids = new HashSet<>();
while (r.next()) {
plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
if (plots.contains(plot_id)) {
@@ -957,9 +917,9 @@ public class SQLManager implements AbstractDB {
purgeIds(world, ids);
stmt.close();
r.close();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"FAILED TO PURGE WORLD '" + world + "'!");
+ PlotSquared.log("&c[ERROR] " + "FAILED TO PURGE WORLD '" + world + "'!");
}
}
@@ -969,7 +929,7 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void setPosition(final String world, final Plot plot, final String position) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -980,13 +940,13 @@ public class SQLManager implements AbstractDB {
stmt.executeUpdate();
stmt.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set position for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to set position for plot " + plot.id);
e.printStackTrace();
}
}
});
}
-
+
/**
* @param id
*
@@ -1034,55 +994,53 @@ public class SQLManager implements AbstractDB {
stmt.close();
r.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to load settings for plot: " + id);
+ PlotSquared.log("&7[WARN] " + "Failed to load settings for plot: " + id);
e.printStackTrace();
}
return h;
}
-
+
@Override
public void removeComment(final String world, final Plot plot, final PlotComment comment) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
- PreparedStatement statement;
- if (plot != null) {
- statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `tier` = ? AND `sender` = ?");
- statement.setInt(1, getId(world, plot.id));
- statement.setString(2, comment.comment);
- statement.setInt(3, comment.tier);
- statement.setString(4, comment.senderName);
- }
- else {
- statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `comment` = ? AND `tier` = ? AND `sender` = ?");
- statement.setString(1, comment.comment);
- statement.setInt(2, comment.tier);
- statement.setString(3, comment.senderName);
- }
+ PreparedStatement statement;
+ if (plot != null) {
+ statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `tier` = ? AND `sender` = ?");
+ statement.setInt(1, getId(world, plot.id));
+ statement.setString(2, comment.comment);
+ statement.setInt(3, comment.tier);
+ statement.setString(4, comment.senderName);
+ } else {
+ statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `comment` = ? AND `tier` = ? AND `sender` = ?");
+ statement.setString(1, comment.comment);
+ statement.setInt(2, comment.tier);
+ statement.setString(3, comment.senderName);
+ }
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Failed to remove helper for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to remove helper for plot " + plot.id);
}
}
});
}
-
+
@Override
- public ArrayList getComments(final String world, final Plot plot, final int tier, boolean below) {
+ public ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) {
final ArrayList comments = new ArrayList();
try {
final PreparedStatement statement;
- String comparison = below ? ">=" : "=";
+ final String comparison = below ? ">=" : "=";
if (plot != null) {
- statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?");
- statement.setInt(1, getId(plot.world, plot.id));
+ statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?");
+ statement.setInt(1, getId(plot.world, plot.id));
statement.setInt(2, tier);
- }
- else {
- statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `tier` " + comparison + " ?");
+ } else {
+ statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `tier` " + comparison + " ?");
statement.setInt(1, tier);
}
final ResultSet set = statement.executeQuery();
@@ -1096,15 +1054,15 @@ public class SQLManager implements AbstractDB {
statement.close();
set.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to fetch comment");
+ PlotSquared.log("&7[WARN] " + "Failed to fetch comment");
e.printStackTrace();
}
return comments;
}
-
+
@Override
public void setComment(final String world, final Plot plot, final PlotComment comment) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1117,20 +1075,19 @@ public class SQLManager implements AbstractDB {
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Failed to set comment for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to set comment for plot " + plot.id);
}
}
});
-
}
-
+
/**
* @param plot
* @param player
*/
@Override
public void removeHelper(final String world, final Plot plot, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1141,19 +1098,19 @@ public class SQLManager implements AbstractDB {
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Failed to remove helper for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to remove helper for plot " + plot.id);
}
}
});
}
-
+
/**
* @param plot
* @param player
*/
@Override
public void removeTrusted(final String world, final Plot plot, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1164,19 +1121,19 @@ public class SQLManager implements AbstractDB {
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Failed to remove trusted user for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to remove trusted user for plot " + plot.id);
}
}
});
}
-
+
/**
* @param plot
* @param player
*/
@Override
public void setHelper(final String world, final Plot plot, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1186,7 +1143,7 @@ public class SQLManager implements AbstractDB {
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set helper for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to set helper for plot " + plot.id);
e.printStackTrace();
}
}
@@ -1194,7 +1151,7 @@ public class SQLManager implements AbstractDB {
}
public void setHelper(final int id, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1204,7 +1161,7 @@ public class SQLManager implements AbstractDB {
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set helper for id " + id);
+ PlotSquared.log("&7[WARN] " + "Failed to set helper for id " + id);
e.printStackTrace();
}
}
@@ -1217,7 +1174,7 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void setTrusted(final String world, final Plot plot, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1227,20 +1184,20 @@ public class SQLManager implements AbstractDB {
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set plot trusted for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to set plot trusted for plot " + plot.id);
e.printStackTrace();
}
}
});
}
-
+
/**
* @param plot
* @param player
*/
@Override
public void removeDenied(final String world, final Plot plot, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1251,19 +1208,19 @@ public class SQLManager implements AbstractDB {
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Failed to remove denied for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to remove denied for plot " + plot.id);
}
}
});
}
-
+
/**
* @param plot
* @param player
*/
@Override
public void setDenied(final String world, final Plot plot, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1273,13 +1230,13 @@ public class SQLManager implements AbstractDB {
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set denied for plot " + plot.id);
+ PlotSquared.log("&7[WARN] " + "Failed to set denied for plot " + plot.id);
e.printStackTrace();
}
}
});
}
-
+
@Override
public double getRatings(final Plot plot) {
try {
@@ -1294,16 +1251,16 @@ public class SQLManager implements AbstractDB {
set.close();
return rating;
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to fetch rating for plot " + plot.getId().toString());
+ PlotSquared.log("&7[WARN] " + "Failed to fetch rating for plot " + plot.getId().toString());
e.printStackTrace();
}
return 0.0d;
}
-
- @Override
- public void delete(final PlotCluster cluster) {
- ClusterManager.removeCluster(cluster);
- BukkitTaskManager.runTaskAsync(new Runnable() {
+
+ @Override
+ public void delete(final PlotCluster cluster) {
+ ClusterManager.removeCluster(cluster);
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -1325,15 +1282,15 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2());
+ PlotSquared.log("&c[ERROR] " + "Failed to delete plot cluster: " + cluster.getP1() + ":" + cluster.getP2());
}
}
});
- }
-
- @Override
- public int getClusterId(String world, PlotClusterId id) {
- PreparedStatement stmt = null;
+ }
+
+ @Override
+ public int getClusterId(final String world, final PlotClusterId id) {
+ PreparedStatement stmt = null;
try {
stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC");
stmt.setInt(1, id.pos1.x);
@@ -1344,7 +1301,7 @@ public class SQLManager implements AbstractDB {
final ResultSet r = stmt.executeQuery();
int c_id = Integer.MAX_VALUE;
while (r.next()) {
- c_id = r.getInt("id");
+ c_id = r.getInt("id");
}
stmt.close();
r.close();
@@ -1353,22 +1310,20 @@ public class SQLManager implements AbstractDB {
e.printStackTrace();
}
return Integer.MAX_VALUE;
- }
-
- @Override
- public HashMap> getClusters() {
- final LinkedHashMap> newClusters = new LinkedHashMap<>();
+ }
+
+ @Override
+ public HashMap> getClusters() {
+ final LinkedHashMap> newClusters = new LinkedHashMap<>();
final HashMap clusters = new HashMap<>();
Statement stmt = null;
try {
-
Set worlds = new HashSet<>();
if (PlotSquared.config.contains("worlds")) {
worlds = PlotSquared.config.getConfigurationSection("worlds").getKeys(false);
}
final HashMap uuids = new HashMap();
final HashMap noExist = new HashMap();
-
/*
* Getting clusters
*/
@@ -1376,14 +1331,14 @@ public class SQLManager implements AbstractDB {
ResultSet r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster`");
PlotId pos1;
PlotId pos2;
- PlotCluster cluster;
+ PlotCluster cluster;
String owner;
String worldname;
UUID user;
int id;
while (r.next()) {
- pos1 = new PlotId(r.getInt("pos1_x"), r.getInt("pos1_z"));
- pos2 = new PlotId(r.getInt("pos2_x"), r.getInt("pos2_z"));
+ pos1 = new PlotId(r.getInt("pos1_x"), r.getInt("pos1_z"));
+ pos2 = new PlotId(r.getInt("pos2_x"), r.getInt("pos2_z"));
id = r.getInt("id");
worldname = r.getString("world");
if (!worlds.contains(worldname)) {
@@ -1402,7 +1357,6 @@ public class SQLManager implements AbstractDB {
cluster = new PlotCluster(worldname, pos1, pos2, user);
clusters.put(id, cluster);
}
-
/*
* Getting helpers
*/
@@ -1454,14 +1408,11 @@ public class SQLManager implements AbstractDB {
}
}
}
-
final String alias = r.getString("alias");
if (alias != null) {
cluster.settings.setAlias(alias);
}
-
final String pos = r.getString("position");
-
switch (pos.toLowerCase()) {
case "":
case "default":
@@ -1470,11 +1421,11 @@ public class SQLManager implements AbstractDB {
break;
default:
try {
- String[] split = pos.split(",");
- BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Integer.parseInt(split[2]));
+ final String[] split = pos.split(",");
+ final BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));
cluster.settings.setPosition(loc);
+ } catch (final Exception e) {
}
- catch (Exception e) {}
}
final Integer m = r.getInt("merged");
if (m != null) {
@@ -1484,19 +1435,17 @@ public class SQLManager implements AbstractDB {
}
cluster.settings.setMerged(merged);
} else {
- cluster.settings.setMerged(new boolean[]{false, false, false, false});
+ cluster.settings.setMerged(new boolean[] { false, false, false, false });
}
-
String[] flags_string;
final String myflags = r.getString("flags");
if (myflags == null) {
- flags_string = new String[]{};
+ flags_string = new String[] {};
} else {
if (myflags.length() > 0) {
flags_string = myflags.split(",");
- }
- else {
- flags_string = new String[]{};
+ } else {
+ flags_string = new String[] {};
}
}
final Set flags = new HashSet();
@@ -1505,8 +1454,8 @@ public class SQLManager implements AbstractDB {
if (element.contains(":")) {
final String[] split = element.split(":");
try {
- String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("�", ",");
- Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str);
+ final String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("�", ",");
+ final Flag flag = new Flag(FlagManager.getFlag(split[0], true), flag_str);
flags.add(flag);
} catch (final Exception e) {
e.printStackTrace();
@@ -1530,7 +1479,7 @@ public class SQLManager implements AbstractDB {
for (final PlotCluster c : clusters.values()) {
final String world = c.world;
if (!newClusters.containsKey(world)) {
- newClusters.put(world, new HashSet());
+ newClusters.put(world, new HashSet());
}
newClusters.get(world).add(c);
}
@@ -1543,15 +1492,15 @@ public class SQLManager implements AbstractDB {
PlotSquared.log("&c[WARNING] - Please create the world/s or remove the clusters using the purge command");
}
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to load clusters.");
+ PlotSquared.log("&7[WARN] " + "Failed to load clusters.");
e.printStackTrace();
}
return newClusters;
- }
-
- @Override
- public void setFlags(final PlotCluster cluster, Set flags) {
- final StringBuilder flag_string = new StringBuilder();
+ }
+
+ @Override
+ public void setFlags(final PlotCluster cluster, final Set flags) {
+ final StringBuilder flag_string = new StringBuilder();
int i = 0;
for (final Flag flag : flags) {
if (i != 0) {
@@ -1560,7 +1509,7 @@ public class SQLManager implements AbstractDB {
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
i++;
}
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1571,17 +1520,16 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Could not set flag for plot " + cluster);
+ PlotSquared.log("&7[WARN] " + "Could not set flag for plot " + cluster);
}
}
});
-
- }
-
- @Override
- public void setClusterName(final PlotCluster cluster, final String name) {
- cluster.settings.setAlias(name);
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ }
+
+ @Override
+ public void setClusterName(final PlotCluster cluster, final String name) {
+ cluster.settings.setAlias(name);
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -1592,17 +1540,16 @@ public class SQLManager implements AbstractDB {
stmt.executeUpdate();
stmt.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set alias for cluster " + cluster);
+ PlotSquared.log("&7[WARN] " + "Failed to set alias for cluster " + cluster);
e.printStackTrace();
}
-
}
});
- }
-
- @Override
- public void removeHelper(final PlotCluster cluster, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ }
+
+ @Override
+ public void removeHelper(final PlotCluster cluster, final UUID uuid) {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1613,15 +1560,15 @@ public class SQLManager implements AbstractDB {
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Failed to remove helper for cluster " + cluster);
+ PlotSquared.log("&7[WARN] " + "Failed to remove helper for cluster " + cluster);
}
}
});
- }
-
- @Override
- public void setHelper(final PlotCluster cluster, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ }
+
+ @Override
+ public void setHelper(final PlotCluster cluster, final UUID uuid) {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1631,16 +1578,16 @@ public class SQLManager implements AbstractDB {
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set helper for cluster " + cluster);
+ PlotSquared.log("&7[WARN] " + "Failed to set helper for cluster " + cluster);
e.printStackTrace();
}
}
});
- }
-
- @Override
- public void createCluster(final PlotCluster cluster) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ }
+
+ @Override
+ public void createCluster(final PlotCluster cluster) {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -1654,8 +1601,7 @@ public class SQLManager implements AbstractDB {
stmt.setString(6, cluster.world);
stmt.executeUpdate();
stmt.close();
-
- int id = getClusterId(cluster.world, ClusterManager.getClusterId(cluster));
+ final int id = getClusterId(cluster.world, ClusterManager.getClusterId(cluster));
stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "cluster_settings`(`cluster_id`, `alias`) VALUES(?, ?" + ")");
stmt.setInt(1, id);
stmt.setString(2, cluster.settings.getAlias());
@@ -1663,19 +1609,19 @@ public class SQLManager implements AbstractDB {
stmt.close();
} catch (final Exception e) {
e.printStackTrace();
- PlotSquared.log("&c[ERROR] "+"Failed to save cluster " + cluster);
+ PlotSquared.log("&c[ERROR] " + "Failed to save cluster " + cluster);
}
}
});
- }
-
- @Override
- public void resizeCluster(final PlotCluster current, final PlotClusterId resize) {
- final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y);
- final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y);
- current.setP1(resize.pos1);
- current.setP2(resize.pos2);
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ }
+
+ @Override
+ public void resizeCluster(final PlotCluster current, final PlotClusterId resize) {
+ final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y);
+ final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y);
+ current.setP1(resize.pos1);
+ current.setP2(resize.pos2);
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -1689,16 +1635,16 @@ public class SQLManager implements AbstractDB {
stmt.executeUpdate();
stmt.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to rezize cluster " + current);
+ PlotSquared.log("&7[WARN] " + "Failed to rezize cluster " + current);
e.printStackTrace();
}
}
- });
- }
-
- @Override
- public void setPosition(final PlotCluster cluster, final String position) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ });
+ }
+
+ @Override
+ public void setPosition(final PlotCluster cluster, final String position) {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PreparedStatement stmt = null;
@@ -1709,16 +1655,16 @@ public class SQLManager implements AbstractDB {
stmt.executeUpdate();
stmt.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set position for cluster " + cluster);
+ PlotSquared.log("&7[WARN] " + "Failed to set position for cluster " + cluster);
e.printStackTrace();
}
}
});
- }
-
- @Override
- public HashMap getClusterSettings(int id) {
- final HashMap h = new HashMap();
+ }
+
+ @Override
+ public HashMap getClusterSettings(final int id) {
+ final HashMap h = new HashMap();
PreparedStatement stmt = null;
try {
stmt = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "cluster_settings` WHERE `cluster_id` = ?");
@@ -1758,15 +1704,15 @@ public class SQLManager implements AbstractDB {
stmt.close();
r.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to load settings for cluster: " + id);
+ PlotSquared.log("&7[WARN] " + "Failed to load settings for cluster: " + id);
e.printStackTrace();
}
return h;
- }
-
+ }
+
@Override
public void removeInvited(final PlotCluster cluster, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1777,16 +1723,15 @@ public class SQLManager implements AbstractDB {
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
- PlotSquared.log("&7[WARN] "+"Failed to remove invited for cluster " + cluster);
+ PlotSquared.log("&7[WARN] " + "Failed to remove invited for cluster " + cluster);
}
}
});
-
}
-
+
@Override
- public void setInvited(String world, final PlotCluster cluster, final UUID uuid) {
- BukkitTaskManager.runTaskAsync(new Runnable() {
+ public void setInvited(final String world, final PlotCluster cluster, final UUID uuid) {
+ TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
@@ -1796,7 +1741,7 @@ public class SQLManager implements AbstractDB {
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
- PlotSquared.log("&7[WARN] "+"Failed to set helper for cluster " + cluster);
+ PlotSquared.log("&7[WARN] " + "Failed to set helper for cluster " + cluster);
e.printStackTrace();
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java
index 9f75cf13f..4c7ddde40 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.database;
import java.io.File;
@@ -38,10 +37,9 @@ import com.intellectualcrafters.plot.PlotSquared;
* @author tips48
*/
public class SQLite extends Database {
-
private final String dbLocation;
private Connection connection;
-
+
/**
* Creates a new SQLite instance
*
@@ -52,7 +50,7 @@ public class SQLite extends Database {
super(plotsquared);
this.dbLocation = dbLocation;
}
-
+
@Override
public Connection openConnection() throws SQLException, ClassNotFoundException {
if (checkConnection()) {
@@ -73,17 +71,17 @@ public class SQLite extends Database {
this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation);
return this.connection;
}
-
+
@Override
public boolean checkConnection() throws SQLException {
return (this.connection != null) && !this.connection.isClosed();
}
-
+
@Override
public Connection getConnection() {
return this.connection;
}
-
+
@Override
public boolean closeConnection() throws SQLException {
if (this.connection == null) {
@@ -92,26 +90,22 @@ public class SQLite extends Database {
this.connection.close();
return true;
}
-
+
@Override
public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException {
if (checkConnection()) {
openConnection();
}
-
final Statement statement = this.connection.createStatement();
-
return statement.executeQuery(query);
}
-
+
@Override
public int updateSQL(final String query) throws SQLException, ClassNotFoundException {
if (checkConnection()) {
openConnection();
}
-
final Statement statement = this.connection.createStatement();
-
return statement.executeUpdate(query);
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java
index 5939a8dab..548d28d1a 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.entity.Player;
@@ -32,12 +31,13 @@ import com.intellectualcrafters.plot.object.Plot;
* @author Citymonstret
* @author Empire92
*/
-@SuppressWarnings("unused") public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
+@SuppressWarnings("unused")
+public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
private static HandlerList handlers = new HandlerList();
private final Plot plot;
private final boolean auto;
private boolean cancelled;
-
+
/**
* PlayerClaimPlotEvent: Called when a plot is claimed
*
@@ -49,11 +49,11 @@ import com.intellectualcrafters.plot.object.Plot;
this.plot = plot;
this.auto = auto;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the plot involved
*
@@ -62,24 +62,24 @@ import com.intellectualcrafters.plot.object.Plot;
public Plot getPlot() {
return this.plot;
}
-
+
/**
* @return true if it was an automated claim, else false
*/
public boolean wasAuto() {
return this.auto;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
+
@Override
public boolean isCancelled() {
return this.cancelled;
}
-
+
@Override
public void setCancelled(final boolean b) {
this.cancelled = b;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java
index 6174a8812..cfb8ad5ea 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.entity.Player;
@@ -32,11 +31,9 @@ import com.intellectualcrafters.plot.object.Plot;
* @author Empire92
*/
public class PlayerEnterPlotEvent extends PlayerEvent {
-
private static HandlerList handlers = new HandlerList();
-
private final Plot plot;
-
+
/**
* PlayerEnterPlotEvent: Called when a player leaves a plot
*
@@ -47,11 +44,11 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
super(player);
this.plot = plot;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the plot involved
*
@@ -60,10 +57,9 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
public Plot getPlot() {
return this.plot;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java
index 6ae951dbf..21d217f46 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.entity.Player;
@@ -33,9 +32,8 @@ import com.intellectualcrafters.plot.object.Plot;
*/
public class PlayerLeavePlotEvent extends PlayerEvent {
private static HandlerList handlers = new HandlerList();
-
private final Plot plot;
-
+
/**
* PlayerLeavePlotEvent: Called when a player leaves a plot
*
@@ -46,11 +44,11 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
super(player);
this.plot = plot;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the plot involved
*
@@ -59,7 +57,7 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
public Plot getPlot() {
return this.plot;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java
index 5c751aeb0..35703c2cd 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import java.util.UUID;
@@ -35,12 +34,11 @@ import com.intellectualcrafters.plot.object.Plot;
*/
public class PlayerPlotDeniedEvent extends Event {
private static HandlerList handlers = new HandlerList();
-
private final Plot plot;
private final Player initiator;
private final boolean added;
private final UUID player;
-
+
/**
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot
*
@@ -55,11 +53,11 @@ public class PlayerPlotDeniedEvent extends Event {
this.added = added;
this.player = player;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* If a user was added
*
@@ -68,7 +66,7 @@ public class PlayerPlotDeniedEvent extends Event {
public boolean wasAdded() {
return this.added;
}
-
+
/**
* The player added/removed
*
@@ -77,7 +75,7 @@ public class PlayerPlotDeniedEvent extends Event {
public UUID getPlayer() {
return this.player;
}
-
+
/**
* The plot involved
*
@@ -86,7 +84,7 @@ public class PlayerPlotDeniedEvent extends Event {
public Plot getPlot() {
return this.plot;
}
-
+
/**
* The player initiating the action
*
@@ -95,7 +93,7 @@ public class PlayerPlotDeniedEvent extends Event {
public Player getInitiator() {
return this.initiator;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java
index d9378c3c9..e802e8123 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import java.util.UUID;
@@ -35,12 +34,11 @@ import com.intellectualcrafters.plot.object.Plot;
*/
public class PlayerPlotHelperEvent extends Event {
private static HandlerList handlers = new HandlerList();
-
private final Plot plot;
private final Player initiator;
private final boolean added;
private final UUID player;
-
+
/**
* PlayerPlotHelperEvent: Called when a plot helper is added/removed
*
@@ -55,11 +53,11 @@ public class PlayerPlotHelperEvent extends Event {
this.added = added;
this.player = player;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* If a player was added
*
@@ -68,7 +66,7 @@ public class PlayerPlotHelperEvent extends Event {
public boolean wasAdded() {
return this.added;
}
-
+
/**
* The UUID added/removed
*
@@ -77,7 +75,7 @@ public class PlayerPlotHelperEvent extends Event {
public UUID getPlayer() {
return this.player;
}
-
+
/**
* The plot involved
*
@@ -86,7 +84,7 @@ public class PlayerPlotHelperEvent extends Event {
public Plot getPlot() {
return this.plot;
}
-
+
/**
* The player initiating the action
*
@@ -95,7 +93,7 @@ public class PlayerPlotHelperEvent extends Event {
public Player getInitiator() {
return this.initiator;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java
index 6989b8e45..95333f704 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import java.util.UUID;
@@ -35,12 +34,11 @@ import com.intellectualcrafters.plot.object.Plot;
*/
public class PlayerPlotTrustedEvent extends Event {
private static HandlerList handlers = new HandlerList();
-
private final Plot plot;
private final Player initiator;
private final boolean added;
private final UUID player;
-
+
/**
* PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed
*
@@ -55,11 +53,11 @@ public class PlayerPlotTrustedEvent extends Event {
this.added = added;
this.player = player;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* If a player was added
*
@@ -68,7 +66,7 @@ public class PlayerPlotTrustedEvent extends Event {
public boolean wasAdded() {
return this.added;
}
-
+
/**
* The UUID added/removed
*
@@ -77,7 +75,7 @@ public class PlayerPlotTrustedEvent extends Event {
public UUID getPlayer() {
return this.player;
}
-
+
/**
* The plot involved
*
@@ -86,7 +84,7 @@ public class PlayerPlotTrustedEvent extends Event {
public Plot getPlot() {
return this.plot;
}
-
+
/**
* The player initiating the action
*
@@ -95,7 +93,7 @@ public class PlayerPlotTrustedEvent extends Event {
public Player getInitiator() {
return this.initiator;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java
index 032c5c384..45af3054e 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.entity.Player;
@@ -37,12 +36,10 @@ import com.intellectualcrafters.plot.object.Plot;
*/
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
-
private final Location from;
private final Plot plot;
-
private boolean cancelled;
-
+
/**
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
*
@@ -55,16 +52,16 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
this.from = from;
this.plot = plot;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
+
/**
* Get the from location
*
@@ -73,7 +70,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
public Location getFrom() {
return this.from;
}
-
+
/**
* Get the plot involved
*
@@ -82,12 +79,12 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
public Plot getPlot() {
return this.plot;
}
-
+
@Override
public boolean isCancelled() {
return this.cancelled;
}
-
+
@Override
public void setCancelled(final boolean cancelled) {
this.cancelled = cancelled;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java
index 7b238c46a..76d55fb20 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.event.Cancellable;
@@ -38,7 +37,7 @@ public class PlotClearEvent extends Event implements Cancellable {
private final PlotId id;
private final String world;
private boolean cancelled;
-
+
/**
* PlotDeleteEvent: Called when a plot is cleared
*
@@ -49,11 +48,11 @@ public class PlotClearEvent extends Event implements Cancellable {
this.id = id;
this.world = world;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the PlotId
*
@@ -62,7 +61,7 @@ public class PlotClearEvent extends Event implements Cancellable {
public PlotId getPlotId() {
return this.id;
}
-
+
/**
* Get the world name
*
@@ -71,17 +70,17 @@ public class PlotClearEvent extends Event implements Cancellable {
public String getWorld() {
return this.world;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
+
@Override
public boolean isCancelled() {
return this.cancelled;
}
-
+
@Override
public void setCancelled(final boolean b) {
this.cancelled = b;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java
index 5e17845be..9d6c1c067 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.event.Cancellable;
@@ -38,7 +37,7 @@ public class PlotDeleteEvent extends Event implements Cancellable {
private final PlotId id;
private final String world;
private boolean cancelled;
-
+
/**
* PlotDeleteEvent: Called when a plot is deleted
*
@@ -49,11 +48,11 @@ public class PlotDeleteEvent extends Event implements Cancellable {
this.id = id;
this.world = world;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the PlotId
*
@@ -62,7 +61,7 @@ public class PlotDeleteEvent extends Event implements Cancellable {
public PlotId getPlotId() {
return this.id;
}
-
+
/**
* Get the world name
*
@@ -71,17 +70,17 @@ public class PlotDeleteEvent extends Event implements Cancellable {
public String getWorld() {
return this.world;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
+
@Override
public boolean isCancelled() {
return this.cancelled;
}
-
+
@Override
public void setCancelled(final boolean b) {
this.cancelled = b;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java
index 3e5234cf0..35035e3f5 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.event.Cancellable;
@@ -39,7 +38,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
private final Plot plot;
private final Flag flag;
private boolean cancelled;
-
+
/**
* PlotFlagAddEvent: Called when a Flag is added to a plot
*
@@ -50,11 +49,11 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
this.plot = plot;
this.flag = flag;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the plot involved
*
@@ -63,7 +62,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
public Plot getPlot() {
return this.plot;
}
-
+
/**
* Get the flag involved
*
@@ -72,17 +71,17 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
public Flag getFlag() {
return this.flag;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
+
@Override
public boolean isCancelled() {
return this.cancelled;
}
-
+
@Override
public void setCancelled(final boolean b) {
this.cancelled = b;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java
index 3272fad58..5a0e5b22e 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import org.bukkit.event.Cancellable;
@@ -39,7 +38,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
private final Plot plot;
private final Flag flag;
private boolean cancelled;
-
+
/**
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
*
@@ -50,11 +49,11 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
this.plot = plot;
this.flag = flag;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the plot involved
*
@@ -63,7 +62,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
public Plot getPlot() {
return this.plot;
}
-
+
/**
* Get the flag involved
*
@@ -72,17 +71,17 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
public Flag getFlag() {
return this.flag;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
+
@Override
public boolean isCancelled() {
return this.cancelled;
}
-
+
@Override
public void setCancelled(final boolean b) {
this.cancelled = b;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java
index d810c5c73..61654ffbc 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import java.util.ArrayList;
@@ -40,7 +39,7 @@ public class PlotMergeEvent extends Event implements Cancellable {
private boolean cancelled;
private Plot plot;
private World world;
-
+
/**
* PlotMergeEvent: Called when plots are merged
*
@@ -51,11 +50,11 @@ public class PlotMergeEvent extends Event implements Cancellable {
public PlotMergeEvent(final World world, final Plot plot, final ArrayList plots) {
this.plots = plots;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the plots being added;
*
@@ -64,7 +63,7 @@ public class PlotMergeEvent extends Event implements Cancellable {
public ArrayList getPlots() {
return this.plots;
}
-
+
/**
* Get the main plot
*
@@ -73,21 +72,21 @@ public class PlotMergeEvent extends Event implements Cancellable {
public Plot getPlot() {
return this.plot;
}
-
+
public World getWorld() {
return this.world;
}
-
+
@Override
public HandlerList getHandlers() {
return handlers;
}
-
+
@Override
public boolean isCancelled() {
return this.cancelled;
}
-
+
@Override
public void setCancelled(final boolean b) {
this.cancelled = b;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java
index 6d03c61d5..8de7ab3a2 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java
@@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-
package com.intellectualcrafters.plot.events;
import java.util.ArrayList;
@@ -38,7 +37,7 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
private final ArrayList plots;
private final World world;
private boolean cancelled;
-
+
/**
* Called when a mega-plot is unlinked.
*
@@ -49,11 +48,11 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
this.plots = plots;
this.world = world;
}
-
+
public static HandlerList getHandlerList() {
return handlers;
}
-
+
/**
* Get the plots involved
*
@@ -62,21 +61,21 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
public ArrayList