diff --git a/PlotSquared/.gitignore b/PlotSquared/.gitignore
new file mode 100644
index 000000000..ea8c4bf7f
--- /dev/null
+++ b/PlotSquared/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java
index 4d0d89322..1eea41719 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java
@@ -10,9 +10,10 @@ public final class ByteArrayTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public ByteArrayTag(byte[] value) {
+ public ByteArrayTag(final byte[] value) {
super();
this.value = value;
}
@@ -20,32 +21,34 @@ public final class ByteArrayTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public ByteArrayTag(String name, byte[] value) {
+ public ByteArrayTag(final String name, final byte[] value) {
super(name);
this.value = value;
}
@Override
public byte[] getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- StringBuilder hex = new StringBuilder();
- for (byte b : value) {
- String hexDigits = Integer.toHexString(b).toUpperCase();
+ final StringBuilder hex = new StringBuilder();
+ for (final byte b : this.value) {
+ final String hexDigits = Integer.toHexString(b).toUpperCase();
if (hexDigits.length() == 1) {
hex.append("0");
}
hex.append(hexDigits).append(" ");
}
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
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 46e247e63..15e355dfc 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java
@@ -10,9 +10,10 @@ public final class ByteTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public ByteTag(byte value) {
+ public ByteTag(final byte value) {
super();
this.value = value;
}
@@ -20,27 +21,29 @@ public final class ByteTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public ByteTag(String name, byte value) {
+ public ByteTag(final String name, final byte value) {
super(name);
this.value = value;
}
@Override
public Byte getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_Byte" + append + ": " + value;
+ 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 2052d65b3..24159bfcb 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java
@@ -15,9 +15,10 @@ public final class CompoundTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public CompoundTag(Map value) {
+ public CompoundTag(final Map value) {
super();
this.value = Collections.unmodifiableMap(value);
}
@@ -25,10 +26,12 @@ public final class CompoundTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public CompoundTag(String name, Map value) {
+ public CompoundTag(final String name, final Map value) {
super(name);
this.value = Collections.unmodifiableMap(value);
}
@@ -36,25 +39,27 @@ public final class CompoundTag extends Tag {
/**
* Returns whether this compound tag contains the given key.
*
- * @param key the given key
+ * @param key
+ * the given key
* @return true if the tag contains the given key
*/
- public boolean containsKey(String key) {
- return value.containsKey(key);
+ public boolean containsKey(final String key) {
+ return this.value.containsKey(key);
}
@Override
public Map getValue() {
- return value;
+ return this.value;
}
/**
* Return a new compound tag with the given values.
*
- * @param value the value
+ * @param value
+ * the value
* @return the new compound tag
*/
- public CompoundTag setValue(Map value) {
+ public CompoundTag setValue(final Map value) {
return new CompoundTag(getName(), value);
}
@@ -64,23 +69,27 @@ public final class CompoundTag extends Tag {
* @return the builder
*/
public CompoundTagBuilder createBuilder() {
- return new CompoundTagBuilder(new HashMap(value));
+ 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.
+ *
+ * If the key does not exist or its value is not a byte array tag, then an
+ * empty byte array will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a byte array
*/
- public byte[] getByteArray(String key) {
- Tag tag = value.get(key);
+ public byte[] getByteArray(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
- } else {
+ }
+ else {
return new byte[0];
}
}
@@ -88,17 +97,21 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not a byte tag, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a byte
*/
- public byte getByte(String key) {
- Tag tag = value.get(key);
+ public byte getByte(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else {
+ }
+ else {
return (byte) 0;
}
}
@@ -106,17 +119,21 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not a double tag, then
+ * {@code 0} will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a double
*/
- public double getDouble(String key) {
- Tag tag = value.get(key);
+ public double getDouble(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -125,33 +142,42 @@ public final class CompoundTag extends Tag {
* 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.
+ *
+ * If the key does not exist or its value is not a number, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a double
*/
- public double asDouble(String key) {
- Tag tag = value.get(key);
+ public double asDouble(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else if (tag instanceof ShortTag) {
+ }
+ else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else if (tag instanceof IntTag) {
+ }
+ else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else if (tag instanceof LongTag) {
+ }
+ else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
- } else if (tag instanceof FloatTag) {
+ }
+ else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
- } else if (tag instanceof DoubleTag) {
+ }
+ else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -159,17 +185,21 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not a float tag, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a float
*/
- public float getFloat(String key) {
- Tag tag = value.get(key);
+ public float getFloat(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -177,17 +207,21 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not an int array tag, then an
+ * empty array will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return an int array
*/
- public int[] getIntArray(String key) {
- Tag tag = value.get(key);
+ public int[] getIntArray(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
- } else {
+ }
+ else {
return new int[0];
}
}
@@ -195,17 +229,21 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not an int tag, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return an int
*/
- public int getInt(String key) {
- Tag tag = value.get(key);
+ public int getInt(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -214,33 +252,42 @@ public final class CompoundTag extends Tag {
* 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.
+ *
+ * If the key does not exist or its value is not a number, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return an int
*/
- public int asInt(String key) {
- Tag tag = value.get(key);
+ public int asInt(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else if (tag instanceof ShortTag) {
+ }
+ else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else if (tag instanceof IntTag) {
+ }
+ else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else if (tag instanceof LongTag) {
+ }
+ else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
- } else if (tag instanceof FloatTag) {
+ }
+ else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
- } else if (tag instanceof DoubleTag) {
+ }
+ else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -248,17 +295,21 @@ public final class CompoundTag extends Tag {
/**
* 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 key does not exist or its value is not a list tag, then an empty
+ * list will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a list of tags
*/
- public List getList(String key) {
- Tag tag = value.get(key);
+ public List getList(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
- } else {
+ }
+ else {
return Collections.emptyList();
}
}
@@ -266,45 +317,55 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not a list tag, then an empty
+ * tag list will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a tag list instance
*/
- public ListTag getListTag(String key) {
- Tag tag = value.get(key);
+ public ListTag getListTag(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ListTag) {
return (ListTag) tag;
- } else {
- return new ListTag(key, StringTag.class, Collections.emptyList());
+ }
+ else {
+ 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 an empty
- * list will also be returned.
+ *
+ * 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 an empty list will also be returned.
+ *
*
- * @param key the key
- * @param listType the class of the contained type
+ * @param key
+ * the key
+ * @param listType
+ * the class of the contained type
* @return a list of tags
- * @param the type of list
+ * @param
+ * the type of list
*/
@SuppressWarnings("unchecked")
- public List getList(String key, Class listType) {
- Tag tag = value.get(key);
+ public List getList(final String key, final Class listType) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ListTag) {
- ListTag listTag = (ListTag) tag;
+ final ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List) listTag.getValue();
- } else {
+ }
+ else {
return Collections.emptyList();
}
- } else {
+ }
+ else {
return Collections.emptyList();
}
}
@@ -312,17 +373,21 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not a long tag, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a long
*/
- public long getLong(String key) {
- Tag tag = value.get(key);
+ public long getLong(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
- } else {
+ }
+ else {
return 0L;
}
}
@@ -331,33 +396,42 @@ public final class CompoundTag extends Tag {
* 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.
+ *
+ * If the key does not exist or its value is not a number, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a long
*/
- public long asLong(String key) {
- Tag tag = value.get(key);
+ public long asLong(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else if (tag instanceof ShortTag) {
+ }
+ else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else if (tag instanceof IntTag) {
+ }
+ else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else if (tag instanceof LongTag) {
+ }
+ else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
- } else if (tag instanceof FloatTag) {
+ }
+ else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
- } else if (tag instanceof DoubleTag) {
+ }
+ else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
- } else {
+ }
+ else {
return 0L;
}
}
@@ -365,17 +439,21 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not a short tag, then {@code 0}
+ * will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a short
*/
- public short getShort(String key) {
- Tag tag = value.get(key);
+ public short getShort(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -383,31 +461,35 @@ public final class CompoundTag extends Tag {
/**
* 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.
+ *
+ * If the key does not exist or its value is not a string tag, then
+ * {@code ""} will be returned.
+ *
*
- * @param key the key
+ * @param key
+ * the key
* @return a string
*/
- public String getString(String key) {
- Tag tag = value.get(key);
+ public String getString(final String key) {
+ final Tag tag = this.value.get(key);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
- } else {
+ }
+ else {
return "";
}
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- StringBuilder bldr = new StringBuilder();
- bldr.append("TAG_Compound").append(append).append(": ").append(value.size()).append(" entries\r\n{\r\n");
- for (Map.Entry entry : value.entrySet()) {
+ final StringBuilder bldr = new StringBuilder();
+ bldr.append("TAG_Compound").append(append).append(": ").append(this.value.size()).append(" entries\r\n{\r\n");
+ for (final Map.Entry entry : this.value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java
index bdca78428..90b3812b9 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java
@@ -1,10 +1,10 @@
package com.intellectualcrafters.jnbt;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.HashMap;
import java.util.Map;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Helps create compound tags.
*/
@@ -22,9 +22,10 @@ public class CompoundTagBuilder {
/**
* Create a new instance and use the given map (which will be modified).
*
- * @param value the value
+ * @param value
+ * the value
*/
- CompoundTagBuilder(Map value) {
+ CompoundTagBuilder(final Map value) {
checkNotNull(value);
this.entries = value;
}
@@ -32,14 +33,16 @@ public class CompoundTagBuilder {
/**
* Put the given key and tag into the compound tag.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder put(String key, Tag value) {
+ public CompoundTagBuilder put(final String key, final Tag value) {
checkNotNull(key);
checkNotNull(value);
- entries.put(key, value);
+ this.entries.put(key, value);
return this;
}
@@ -47,47 +50,52 @@ public class CompoundTagBuilder {
* Put the given key and value into the compound tag as a
* {@code ByteArrayTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putByteArray(String key, byte[] value) {
+ 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}.
+ * Put the given key and value into the compound tag as a {@code ByteTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putByte(String key, byte value) {
+ 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}.
+ * Put the given key and value into the compound tag as a {@code DoubleTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putDouble(String key, double value) {
+ 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}.
+ * Put the given key and value into the compound tag as a {@code FloatTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putFloat(String key, float value) {
+ public CompoundTagBuilder putFloat(final String key, final float value) {
return put(key, new FloatTag(key, value));
}
@@ -95,70 +103,78 @@ public class CompoundTagBuilder {
* Put the given key and value into the compound tag as a
* {@code IntArrayTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putIntArray(String key, int[] value) {
+ 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}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putInt(String key, int value) {
+ 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}.
+ * Put the given key and value into the compound tag as a {@code LongTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putLong(String key, long value) {
+ 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}.
+ * Put the given key and value into the compound tag as a {@code ShortTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putShort(String key, short value) {
+ 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}.
+ * Put the given key and value into the compound tag as a {@code StringTag}.
*
- * @param key they key
- * @param value the value
+ * @param key
+ * they key
+ * @param value
+ * the value
* @return this object
*/
- public CompoundTagBuilder putString(String key, String value) {
+ 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.
*
- * @param value the map of tags
+ * @param value
+ * the map of tags
* @return this object
*/
- public CompoundTagBuilder putAll(Map value) {
+ public CompoundTagBuilder putAll(final Map value) {
checkNotNull(value);
- for (Map.Entry entry : value.entrySet()) {
+ for (final Map.Entry entry : value.entrySet()) {
put(entry.getKey(), entry.getValue());
}
return this;
@@ -170,17 +186,18 @@ public class CompoundTagBuilder {
* @return the new compound tag
*/
public CompoundTag build() {
- return new CompoundTag(new HashMap(entries));
+ return new CompoundTag(new HashMap(this.entries));
}
/**
* Build a new compound tag with this builder's entries.
*
- * @param name the name of the tag
+ * @param name
+ * the name of the tag
* @return the created compound tag
*/
- public CompoundTag build(String name) {
- return new CompoundTag(name, new HashMap(entries));
+ 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 b660eb681..d4ce6f75c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java
@@ -2,7 +2,7 @@ package com.intellectualcrafters.jnbt;
/**
* The {@code TAG_Double} tag.
- *
+ *
*/
public final class DoubleTag extends Tag {
@@ -11,9 +11,10 @@ public final class DoubleTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public DoubleTag(double value) {
+ public DoubleTag(final double value) {
super();
this.value = value;
}
@@ -21,27 +22,29 @@ public final class DoubleTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public DoubleTag(String name, double value) {
+ public DoubleTag(final String name, final double value) {
super(name);
this.value = value;
}
@Override
public Double getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_Double" + append + ": " + value;
+ return "TAG_Double" + append + ": " + this.value;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java
index ad333dad1..32dbe86ff 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java
@@ -10,9 +10,10 @@ public final class FloatTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public FloatTag(float value) {
+ public FloatTag(final float value) {
super();
this.value = value;
}
@@ -20,27 +21,29 @@ public final class FloatTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public FloatTag(String name, float value) {
+ public FloatTag(final String name, final float value) {
super(name);
this.value = value;
}
@Override
public Float getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_Float" + append + ": " + value;
+ 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 4c80b1cf7..bfca5e264 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java
@@ -12,9 +12,10 @@ public final class IntArrayTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public IntArrayTag(int[] value) {
+ public IntArrayTag(final int[] value) {
super();
checkNotNull(value);
this.value = value;
@@ -23,10 +24,12 @@ public final class IntArrayTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public IntArrayTag(String name, int[] value) {
+ public IntArrayTag(final String name, final int[] value) {
super(name);
checkNotNull(value);
this.value = value;
@@ -34,22 +37,22 @@ public final class IntArrayTag extends Tag {
@Override
public int[] getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- StringBuilder hex = new StringBuilder();
- for (int b : value) {
- String hexDigits = Integer.toHexString(b).toUpperCase();
+ final StringBuilder hex = new StringBuilder();
+ for (final int b : this.value) {
+ final String hexDigits = Integer.toHexString(b).toUpperCase();
if (hexDigits.length() == 1) {
hex.append("0");
}
hex.append(hexDigits).append(" ");
}
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
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 bea176238..334e347df 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java
@@ -10,9 +10,10 @@ public final class IntTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public IntTag(int value) {
+ public IntTag(final int value) {
super();
this.value = value;
}
@@ -20,27 +21,29 @@ public final class IntTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public IntTag(String name, int value) {
+ public IntTag(final String name, final int value) {
super(name);
this.value = value;
}
@Override
public Integer getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_Int" + append + ": " + value;
+ 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 bea5d8158..04272d8c0 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java
@@ -1,11 +1,12 @@
package com.intellectualcrafters.jnbt;
-import javax.annotation.Nullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
-import static com.google.common.base.Preconditions.checkNotNull;
+import javax.annotation.Nullable;
/**
* The {@code TAG_List} tag.
@@ -13,15 +14,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
public final class ListTag extends Tag {
private final Class extends Tag> type;
- private final List value;
+ private final List value;
/**
* Creates the tag with an empty name.
*
- * @param type the type of tag
- * @param value the value of the tag
+ * @param type
+ * the type of tag
+ * @param value
+ * the value of the tag
*/
- public ListTag(Class extends Tag> type, List extends Tag> value) {
+ public ListTag(final Class extends Tag> type, final List extends Tag> value) {
super();
checkNotNull(value);
this.type = type;
@@ -31,11 +34,14 @@ public final class ListTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param type the type of tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param type
+ * the type of tag
+ * @param value
+ * the value of the tag
*/
- public ListTag(String name, Class extends Tag> type, List extends Tag> value) {
+ public ListTag(final String name, final Class extends Tag> type, final List extends Tag> value) {
super(name);
checkNotNull(value);
this.type = type;
@@ -48,35 +54,38 @@ public final class ListTag extends Tag {
* @return The type of item in this list.
*/
public Class extends Tag> getType() {
- return type;
+ return this.type;
}
@Override
public List getValue() {
- return value;
+ return this.value;
}
/**
* Create a new list tag with this tag's name and type.
*
- * @param list the new list
+ * @param list
+ * the new list
* @return a new list tag
*/
- public ListTag setValue(List list) {
+ public ListTag setValue(final List list) {
return new ListTag(getName(), getType(), list);
}
/**
* Get the tag if it exists at the given index.
- *
- * @param index the index
+ *
+ * @param index
+ * the index
* @return the tag or null
*/
@Nullable
- public Tag getIfExists(int index) {
+ public Tag getIfExists(final int index) {
try {
- return value.get(index);
- } catch (NoSuchElementException e) {
+ return this.value.get(index);
+ }
+ catch (final NoSuchElementException e) {
return null;
}
}
@@ -84,17 +93,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a byte array tag, then an
+ * empty byte array will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a byte array
*/
- public byte[] getByteArray(int index) {
- Tag tag = getIfExists(index);
+ public byte[] getByteArray(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
- } else {
+ }
+ else {
return new byte[0];
}
}
@@ -102,17 +115,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a byte tag, then
+ * {@code 0} will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a byte
*/
- public byte getByte(int index) {
- Tag tag = getIfExists(index);
+ public byte getByte(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else {
+ }
+ else {
return (byte) 0;
}
}
@@ -120,17 +137,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a double tag, then
+ * {@code 0} will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a double
*/
- public double getDouble(int index) {
- Tag tag = getIfExists(index);
+ public double getDouble(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -139,33 +160,42 @@ public final class ListTag extends Tag {
* 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.
+ *
+ * If the index does not exist or its value is not a number, then {@code 0}
+ * will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a double
*/
- public double asDouble(int index) {
- Tag tag = getIfExists(index);
+ public double asDouble(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else if (tag instanceof ShortTag) {
+ }
+ else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else if (tag instanceof IntTag) {
+ }
+ else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else if (tag instanceof LongTag) {
+ }
+ else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
- } else if (tag instanceof FloatTag) {
+ }
+ else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
- } else if (tag instanceof DoubleTag) {
+ }
+ else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -173,17 +203,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a float tag, then
+ * {@code 0} will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a float
*/
- public float getFloat(int index) {
- Tag tag = getIfExists(index);
+ public float getFloat(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -191,17 +225,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not an int array tag, then an
+ * empty array will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return an int array
*/
- public int[] getIntArray(int index) {
- Tag tag = getIfExists(index);
+ public int[] getIntArray(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
- } else {
+ }
+ else {
return new int[0];
}
}
@@ -209,17 +247,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not an int tag, then
+ * {@code 0} will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return an int
*/
- public int getInt(int index) {
- Tag tag = getIfExists(index);
+ public int getInt(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -228,33 +270,42 @@ public final class ListTag extends Tag {
* 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.
+ *
+ * If the index does not exist or its value is not a number, then {@code 0}
+ * will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return an int
*/
- public int asInt(int index) {
- Tag tag = getIfExists(index);
+ public int asInt(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else if (tag instanceof ShortTag) {
+ }
+ else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else if (tag instanceof IntTag) {
+ }
+ else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else if (tag instanceof LongTag) {
+ }
+ else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
- } else if (tag instanceof FloatTag) {
+ }
+ else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
- } else if (tag instanceof DoubleTag) {
+ }
+ else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -262,17 +313,21 @@ public final class ListTag extends Tag {
/**
* 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 index does not exist or its value is not a list tag, then an empty
+ * list will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a list of tags
*/
- public List getList(int index) {
- Tag tag = getIfExists(index);
+ public List getList(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
- } else {
+ }
+ else {
return Collections.emptyList();
}
}
@@ -280,45 +335,55 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a list tag, then an empty
+ * tag list will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a tag list instance
*/
- public ListTag getListTag(int index) {
- Tag tag = getIfExists(index);
+ public ListTag getListTag(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return (ListTag) tag;
- } else {
- return new ListTag(StringTag.class, Collections.emptyList());
+ }
+ else {
+ 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 type, then an empty
- * list will also be returned.
+ *
+ * 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 type, then an empty list will also be returned.
+ *
*
- * @param index the index
- * @param listType the class of the contained type
+ * @param index
+ * the index
+ * @param listType
+ * the class of the contained type
* @return a list of tags
- * @param the NBT type
+ * @param
+ * the NBT type
*/
@SuppressWarnings("unchecked")
- public List getList(int index, Class listType) {
- Tag tag = getIfExists(index);
+ public List getList(final int index, final Class listType) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
- ListTag listTag = (ListTag) tag;
+ final ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List) listTag.getValue();
- } else {
+ }
+ else {
return Collections.emptyList();
}
- } else {
+ }
+ else {
return Collections.emptyList();
}
}
@@ -326,17 +391,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a long tag, then
+ * {@code 0} will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a long
*/
- public long getLong(int index) {
- Tag tag = getIfExists(index);
+ public long getLong(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
- } else {
+ }
+ else {
return 0L;
}
}
@@ -345,33 +414,42 @@ public final class ListTag extends Tag {
* 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.
+ *
+ * If the index does not exist or its value is not a number, then {@code 0}
+ * will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a long
*/
- public long asLong(int index) {
- Tag tag = getIfExists(index);
+ public long asLong(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
- } else if (tag instanceof ShortTag) {
+ }
+ else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else if (tag instanceof IntTag) {
+ }
+ else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
- } else if (tag instanceof LongTag) {
+ }
+ else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
- } else if (tag instanceof FloatTag) {
+ }
+ else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
- } else if (tag instanceof DoubleTag) {
+ }
+ else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -379,17 +457,21 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a short tag, then
+ * {@code 0} will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a short
*/
- public short getShort(int index) {
- Tag tag = getIfExists(index);
+ public short getShort(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
- } else {
+ }
+ else {
return 0;
}
}
@@ -397,31 +479,35 @@ public final class ListTag extends Tag {
/**
* 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.
+ *
+ * If the index does not exist or its value is not a string tag, then
+ * {@code ""} will be returned.
+ *
*
- * @param index the index
+ * @param index
+ * the index
* @return a string
*/
- public String getString(int index) {
- Tag tag = getIfExists(index);
+ public String getString(final int index) {
+ final Tag tag = getIfExists(index);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
- } else {
+ }
+ else {
return "";
}
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- StringBuilder bldr = new StringBuilder();
- bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
- for (Tag t : value) {
+ final StringBuilder bldr = new StringBuilder();
+ bldr.append("TAG_List").append(append).append(": ").append(this.value.size()).append(" entries of type ").append(NBTUtils.getTypeName(this.type)).append("\r\n{\r\n");
+ for (final Tag t : this.value) {
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java
index 758bc52eb..322bdf514 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java
@@ -1,26 +1,27 @@
package com.intellectualcrafters.jnbt;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Helps create list tags.
*/
public class ListTagBuilder {
private final Class extends Tag> type;
- private final List entries;
+ private final List entries;
/**
* Create a new instance.
*
- * @param type of tag contained in this list
+ * @param type
+ * of tag contained in this list
*/
- ListTagBuilder(Class extends Tag> type) {
+ ListTagBuilder(final Class extends Tag> type) {
checkNotNull(type);
this.type = type;
this.entries = new ArrayList();
@@ -29,27 +30,29 @@ public class ListTagBuilder {
/**
* Add the given tag.
*
- * @param value the tag
+ * @param value
+ * the tag
* @return this object
*/
- public ListTagBuilder add(Tag value) {
+ public ListTagBuilder add(final Tag value) {
checkNotNull(value);
- if (!type.isInstance(value)) {
- throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + type.getCanonicalName());
+ if (!this.type.isInstance(value)) {
+ throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + this.type.getCanonicalName());
}
- entries.add(value);
+ this.entries.add(value);
return this;
}
/**
* Add all the tags in the given list.
*
- * @param value a list of tags
+ * @param value
+ * a list of tags
* @return this object
*/
- public ListTagBuilder addAll(Collection extends Tag> value) {
+ public ListTagBuilder addAll(final Collection extends Tag> value) {
checkNotNull(value);
- for (Tag v : value) {
+ for (final Tag v : value) {
add(v);
}
return this;
@@ -61,17 +64,18 @@ public class ListTagBuilder {
* @return the new list tag
*/
public ListTag build() {
- return new ListTag(type, new ArrayList(entries));
+ return new ListTag(this.type, new ArrayList(this.entries));
}
/**
* Build a new list tag with this builder's entries.
*
- * @param name the name of the tag
+ * @param name
+ * the name of the tag
* @return the created list tag
*/
- public ListTag build(String name) {
- return new ListTag(name, type, new ArrayList(entries));
+ public ListTag build(final String name) {
+ return new ListTag(name, this.type, new ArrayList(this.entries));
}
/**
@@ -79,7 +83,7 @@ public class ListTagBuilder {
*
* @return a new builder
*/
- public static ListTagBuilder create(Class extends Tag> type) {
+ public static ListTagBuilder create(final Class extends Tag> type) {
return new ListTagBuilder(type);
}
@@ -88,21 +92,21 @@ public class ListTagBuilder {
*
* @return a new builder
*/
- public static ListTagBuilder createWith(T ... entries) {
+ 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");
}
- Class extends Tag> type = entries[0].getClass();
+ 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");
}
}
- ListTagBuilder builder = new ListTagBuilder(type);
+ final ListTagBuilder builder = new ListTagBuilder(type);
builder.addAll(Arrays.asList(entries));
return builder;
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java
index 19ab6b44f..bf48de965 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java
@@ -2,7 +2,7 @@ package com.intellectualcrafters.jnbt;
/**
* The {@code TAG_Long} tag.
- *
+ *
*/
public final class LongTag extends Tag {
@@ -11,9 +11,10 @@ public final class LongTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public LongTag(long value) {
+ public LongTag(final long value) {
super();
this.value = value;
}
@@ -21,27 +22,29 @@ public final class LongTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public LongTag(String name, long value) {
+ public LongTag(final String name, final long value) {
super(name);
this.value = value;
}
@Override
public Long getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_Long" + append + ": " + value;
+ 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 f1bef6d4f..ab2e6d557 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java
@@ -9,10 +9,7 @@ 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;
+ 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.
@@ -20,42 +17,44 @@ public final class NBTConstants {
private NBTConstants() {
}
-
+
/**
* Convert a type ID to its corresponding {@link Tag} class.
- *
- * @param id type ID
+ *
+ * @param id
+ * type ID
* @return tag class
- * @throws IllegalArgumentException thrown if the tag ID is not valid
+ * @throws IllegalArgumentException
+ * thrown if the tag ID is not valid
*/
- public static Class extends Tag> getClassFromType(int id) {
+ public static Class extends Tag> getClassFromType(final int id) {
switch (id) {
- case TYPE_END:
- return EndTag.class;
- case TYPE_BYTE:
- return ByteTag.class;
- case TYPE_SHORT:
- return ShortTag.class;
- case TYPE_INT:
- return IntTag.class;
- case TYPE_LONG:
- return LongTag.class;
- case TYPE_FLOAT:
- return FloatTag.class;
- case TYPE_DOUBLE:
- return DoubleTag.class;
- case TYPE_BYTE_ARRAY:
- return ByteArrayTag.class;
- case TYPE_STRING:
- return StringTag.class;
- case TYPE_LIST:
- return ListTag.class;
- case TYPE_COMPOUND:
- return CompoundTag.class;
- case TYPE_INT_ARRAY:
- return IntArrayTag.class;
- default:
- throw new IllegalArgumentException("Unknown tag type ID of " + id);
+ case TYPE_END:
+ return EndTag.class;
+ case TYPE_BYTE:
+ return ByteTag.class;
+ case TYPE_SHORT:
+ return ShortTag.class;
+ case TYPE_INT:
+ return IntTag.class;
+ case TYPE_LONG:
+ return LongTag.class;
+ case TYPE_FLOAT:
+ return FloatTag.class;
+ case TYPE_DOUBLE:
+ return DoubleTag.class;
+ case TYPE_BYTE_ARRAY:
+ return ByteArrayTag.class;
+ case TYPE_STRING:
+ return StringTag.class;
+ case TYPE_LIST:
+ return ListTag.class;
+ case TYPE_COMPOUND:
+ return CompoundTag.class;
+ case TYPE_INT_ARRAY:
+ return IntArrayTag.class;
+ default:
+ 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 fc6609f35..a6fe45b6c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java
@@ -13,10 +13,12 @@ import java.util.Map;
* This class reads NBT, or Named Binary Tag
* streams, and produces an object graph of subclasses of the {@code Tag}
* object.
- *
- *
The NBT format was created by Markus Persson, and the specification may be
+ *
+ *
*/
public final class NBTInputStream implements Closeable {
@@ -25,19 +27,22 @@ public final class NBTInputStream implements Closeable {
/**
* Creates a new {@code NBTInputStream}, which will source its data
* from the specified input stream.
- *
- * @param is the input stream
- * @throws IOException if an I/O error occurs
+ *
+ * @param is
+ * the input stream
+ * @throws IOException
+ * if an I/O error occurs
*/
- public NBTInputStream(InputStream is) throws IOException {
+ public NBTInputStream(final InputStream is) throws IOException {
this.is = new DataInputStream(is);
}
/**
* Reads an NBT tag from the stream.
- *
+ *
* @return The tag that was read.
- * @throws IOException if an I/O error occurs.
+ * @throws IOException
+ * if an I/O error occurs.
*/
public Tag readTag() throws IOException {
return readTag(0);
@@ -45,21 +50,24 @@ public final class NBTInputStream implements Closeable {
/**
* Reads an NBT from the stream.
- *
- * @param depth the depth of this tag
+ *
+ * @param depth
+ * the depth of this tag
* @return The tag that was read.
- * @throws IOException if an I/O error occurs.
+ * @throws IOException
+ * if an I/O error occurs.
*/
- private Tag readTag(int depth) throws IOException {
- int type = is.readByte() & 0xFF;
+ private Tag readTag(final int depth) throws IOException {
+ final int type = this.is.readByte() & 0xFF;
String name;
if (type != NBTConstants.TYPE_END) {
- int nameLength = is.readShort() & 0xFFFF;
- byte[] nameBytes = new byte[nameLength];
- is.readFully(nameBytes);
+ final int nameLength = this.is.readShort() & 0xFFFF;
+ final byte[] nameBytes = new byte[nameLength];
+ this.is.readFully(nameBytes);
name = new String(nameBytes, NBTConstants.CHARSET);
- } else {
+ }
+ else {
name = "";
}
@@ -68,85 +76,90 @@ public final class NBTInputStream implements Closeable {
/**
* Reads the payload of a tag, given the name and type.
- *
- * @param type the type
- * @param name the name
- * @param depth the depth
+ *
+ * @param type
+ * the type
+ * @param name
+ * the name
+ * @param depth
+ * the depth
* @return the tag
- * @throws IOException if an I/O error occurs.
+ * @throws IOException
+ * if an I/O error occurs.
*/
- private Tag readTagPayload(int type, String name, int depth) throws IOException {
+ private Tag readTagPayload(final int type, final String name, final int depth) throws IOException {
switch (type) {
- case NBTConstants.TYPE_END:
- if (depth == 0) {
- throw new IOException(
- "TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
- } else {
- return new EndTag();
- }
- case NBTConstants.TYPE_BYTE:
- return new ByteTag(name, is.readByte());
- case NBTConstants.TYPE_SHORT:
- return new ShortTag(name, is.readShort());
- case NBTConstants.TYPE_INT:
- return new IntTag(name, is.readInt());
- case NBTConstants.TYPE_LONG:
- return new LongTag(name, is.readLong());
- case NBTConstants.TYPE_FLOAT:
- return new FloatTag(name, is.readFloat());
- case NBTConstants.TYPE_DOUBLE:
- return new DoubleTag(name, is.readDouble());
- case NBTConstants.TYPE_BYTE_ARRAY:
- int length = is.readInt();
- byte[] bytes = new byte[length];
- is.readFully(bytes);
- return new ByteArrayTag(name, bytes);
- case NBTConstants.TYPE_STRING:
- length = is.readShort();
- bytes = new byte[length];
- is.readFully(bytes);
- return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
- case NBTConstants.TYPE_LIST:
- int childType = is.readByte();
- length = is.readInt();
-
- List tagList = new ArrayList();
- for (int i = 0; i < length; ++i) {
- Tag tag = readTagPayload(childType, "", depth + 1);
- if (tag instanceof EndTag) {
- throw new IOException("TAG_End not permitted in a list.");
+ case NBTConstants.TYPE_END:
+ if (depth == 0) {
+ throw new IOException("TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
}
- tagList.add(tag);
- }
-
- return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
- case NBTConstants.TYPE_COMPOUND:
- Map tagMap = new HashMap();
- while (true) {
- Tag tag = readTag(depth + 1);
- if (tag instanceof EndTag) {
- break;
- } else {
- tagMap.put(tag.getName(), tag);
+ else {
+ return new EndTag();
}
- }
+ case NBTConstants.TYPE_BYTE:
+ return new ByteTag(name, this.is.readByte());
+ case NBTConstants.TYPE_SHORT:
+ return new ShortTag(name, this.is.readShort());
+ case NBTConstants.TYPE_INT:
+ return new IntTag(name, this.is.readInt());
+ case NBTConstants.TYPE_LONG:
+ return new LongTag(name, this.is.readLong());
+ case NBTConstants.TYPE_FLOAT:
+ return new FloatTag(name, this.is.readFloat());
+ case NBTConstants.TYPE_DOUBLE:
+ return new DoubleTag(name, this.is.readDouble());
+ case NBTConstants.TYPE_BYTE_ARRAY:
+ int length = this.is.readInt();
+ byte[] bytes = new byte[length];
+ this.is.readFully(bytes);
+ return new ByteArrayTag(name, bytes);
+ case NBTConstants.TYPE_STRING:
+ length = this.is.readShort();
+ bytes = new byte[length];
+ this.is.readFully(bytes);
+ return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
+ case NBTConstants.TYPE_LIST:
+ final int childType = this.is.readByte();
+ length = this.is.readInt();
- return new CompoundTag(name, tagMap);
- case NBTConstants.TYPE_INT_ARRAY:
- length = is.readInt();
- int[] data = new int[length];
- for (int i = 0; i < length; i++) {
- data[i] = is.readInt();
- }
- return new IntArrayTag(name, data);
- default:
- throw new IOException("Invalid tag type: " + type + ".");
+ final List tagList = new ArrayList();
+ for (int i = 0; i < length; ++i) {
+ final Tag tag = readTagPayload(childType, "", depth + 1);
+ if (tag instanceof EndTag) {
+ throw new IOException("TAG_End not permitted in a list.");
+ }
+ tagList.add(tag);
+ }
+
+ return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
+ case NBTConstants.TYPE_COMPOUND:
+ final Map tagMap = new HashMap();
+ while (true) {
+ final Tag tag = readTag(depth + 1);
+ if (tag instanceof EndTag) {
+ break;
+ }
+ else {
+ tagMap.put(tag.getName(), tag);
+ }
+ }
+
+ return new CompoundTag(name, tagMap);
+ case NBTConstants.TYPE_INT_ARRAY:
+ length = this.is.readInt();
+ final int[] data = new int[length];
+ for (int i = 0; i < length; i++) {
+ data[i] = this.is.readInt();
+ }
+ return new IntArrayTag(name, data);
+ default:
+ throw new IOException("Invalid tag type: " + type + ".");
}
}
@Override
public void close() throws IOException {
- is.close();
+ 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 37a004268..acfe18a1c 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java
@@ -11,15 +11,15 @@ import java.util.List;
* This class writes NBT, or Named Binary Tag
* Tag objects to an underlying OutputStream.
*
- *
+ *
*
- *
+ *
* @author Graham Edgecombe
- *
+ *
*/
public final class NBTOutputStream implements Closeable {
@@ -31,32 +31,32 @@ public final class NBTOutputStream implements Closeable {
/**
* Creates a new NBTOutputStream, which will write data to the
* specified underlying output stream.
- *
+ *
* @param os
* The output stream.
* @throws IOException
* if an I/O error occurs.
*/
- public NBTOutputStream(OutputStream os) throws IOException {
+ public NBTOutputStream(final OutputStream os) throws IOException {
this.os = new DataOutputStream(os);
}
/**
* Writes a tag.
- *
+ *
* @param tag
* The tag to write.
* @throws IOException
* if an I/O error occurs.
*/
- public void writeTag(Tag tag) throws IOException {
- int type = NBTUtils.getTypeCode(tag.getClass());
- String name = tag.getName();
- byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
+ public void writeTag(final Tag tag) throws IOException {
+ final int type = NBTUtils.getTypeCode(tag.getClass());
+ final String name = tag.getName();
+ final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
- os.writeByte(type);
- os.writeShort(nameBytes.length);
- os.write(nameBytes);
+ 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.");
@@ -67,112 +67,112 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes tag payload.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeTagPayload(Tag tag) throws IOException {
- int type = NBTUtils.getTypeCode(tag.getClass());
+ private void writeTagPayload(final Tag tag) throws IOException {
+ final int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) {
- case NBTConstants.TYPE_END:
- writeEndTagPayload((EndTag) tag);
- break;
- case NBTConstants.TYPE_BYTE:
- writeByteTagPayload((ByteTag) tag);
- break;
- case NBTConstants.TYPE_SHORT:
- writeShortTagPayload((ShortTag) tag);
- break;
- case NBTConstants.TYPE_INT:
- writeIntTagPayload((IntTag) tag);
- break;
- case NBTConstants.TYPE_LONG:
- writeLongTagPayload((LongTag) tag);
- break;
- case NBTConstants.TYPE_FLOAT:
- writeFloatTagPayload((FloatTag) tag);
- break;
- case NBTConstants.TYPE_DOUBLE:
- writeDoubleTagPayload((DoubleTag) tag);
- break;
- case NBTConstants.TYPE_BYTE_ARRAY:
- writeByteArrayTagPayload((ByteArrayTag) tag);
- break;
- case NBTConstants.TYPE_STRING:
- writeStringTagPayload((StringTag) tag);
- break;
- case NBTConstants.TYPE_LIST:
- writeListTagPayload((ListTag) tag);
- break;
- case NBTConstants.TYPE_COMPOUND:
- writeCompoundTagPayload((CompoundTag) tag);
- break;
- case NBTConstants.TYPE_INT_ARRAY:
- writeIntArrayTagPayload((IntArrayTag) tag);
- break;
- default:
- throw new IOException("Invalid tag type: " + type + ".");
+ case NBTConstants.TYPE_END:
+ writeEndTagPayload((EndTag) tag);
+ break;
+ case NBTConstants.TYPE_BYTE:
+ writeByteTagPayload((ByteTag) tag);
+ break;
+ case NBTConstants.TYPE_SHORT:
+ writeShortTagPayload((ShortTag) tag);
+ break;
+ case NBTConstants.TYPE_INT:
+ writeIntTagPayload((IntTag) tag);
+ break;
+ case NBTConstants.TYPE_LONG:
+ writeLongTagPayload((LongTag) tag);
+ break;
+ case NBTConstants.TYPE_FLOAT:
+ writeFloatTagPayload((FloatTag) tag);
+ break;
+ case NBTConstants.TYPE_DOUBLE:
+ writeDoubleTagPayload((DoubleTag) tag);
+ break;
+ case NBTConstants.TYPE_BYTE_ARRAY:
+ writeByteArrayTagPayload((ByteArrayTag) tag);
+ break;
+ case NBTConstants.TYPE_STRING:
+ writeStringTagPayload((StringTag) tag);
+ break;
+ case NBTConstants.TYPE_LIST:
+ writeListTagPayload((ListTag) tag);
+ break;
+ case NBTConstants.TYPE_COMPOUND:
+ writeCompoundTagPayload((CompoundTag) tag);
+ break;
+ case NBTConstants.TYPE_INT_ARRAY:
+ writeIntArrayTagPayload((IntArrayTag) tag);
+ break;
+ default:
+ throw new IOException("Invalid tag type: " + type + ".");
}
}
/**
* Writes a TAG_Byte tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeByteTagPayload(ByteTag tag) throws IOException {
- os.writeByte(tag.getValue());
+ private void writeByteTagPayload(final ByteTag tag) throws IOException {
+ this.os.writeByte(tag.getValue());
}
/**
* Writes a TAG_Byte_Array tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
- byte[] bytes = tag.getValue();
- os.writeInt(bytes.length);
- os.write(bytes);
+ private void writeByteArrayTagPayload(final ByteArrayTag tag) throws IOException {
+ final byte[] bytes = tag.getValue();
+ this.os.writeInt(bytes.length);
+ this.os.write(bytes);
}
/**
* Writes a TAG_Compound tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
- for (Tag childTag : tag.getValue().values()) {
+ private void writeCompoundTagPayload(final CompoundTag tag) throws IOException {
+ for (final Tag childTag : tag.getValue().values()) {
writeTag(childTag);
}
- os.writeByte((byte) 0); // end tag - better way?
+ this.os.writeByte((byte) 0); // end tag - better way?
}
/**
* Writes a TAG_List tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeListTagPayload(ListTag tag) throws IOException {
- Class extends Tag> clazz = tag.getType();
- List tags = tag.getValue();
- int size = tags.size();
+ private void writeListTagPayload(final ListTag tag) throws IOException {
+ final Class extends Tag> clazz = tag.getType();
+ final List tags = tag.getValue();
+ final int size = tags.size();
- os.writeByte(NBTUtils.getTypeCode(clazz));
- os.writeInt(size);
+ this.os.writeByte(NBTUtils.getTypeCode(clazz));
+ this.os.writeInt(size);
for (int i = 0; i < size; ++i) {
writeTagPayload(tags.get(i));
}
@@ -180,100 +180,101 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a TAG_String tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeStringTagPayload(StringTag tag) throws IOException {
- byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
- os.writeShort(bytes.length);
- os.write(bytes);
+ private void writeStringTagPayload(final StringTag tag) throws IOException {
+ final byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
+ this.os.writeShort(bytes.length);
+ this.os.write(bytes);
}
/**
* Writes a TAG_Double tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
- os.writeDouble(tag.getValue());
+ private void writeDoubleTagPayload(final DoubleTag tag) throws IOException {
+ this.os.writeDouble(tag.getValue());
}
/**
* Writes a TAG_Float tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeFloatTagPayload(FloatTag tag) throws IOException {
- os.writeFloat(tag.getValue());
+ private void writeFloatTagPayload(final FloatTag tag) throws IOException {
+ this.os.writeFloat(tag.getValue());
}
/**
* Writes a TAG_Long tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeLongTagPayload(LongTag tag) throws IOException {
- os.writeLong(tag.getValue());
+ private void writeLongTagPayload(final LongTag tag) throws IOException {
+ this.os.writeLong(tag.getValue());
}
/**
* Writes a TAG_Int tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeIntTagPayload(IntTag tag) throws IOException {
- os.writeInt(tag.getValue());
+ private void writeIntTagPayload(final IntTag tag) throws IOException {
+ this.os.writeInt(tag.getValue());
}
/**
* Writes a TAG_Short tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeShortTagPayload(ShortTag tag) throws IOException {
- os.writeShort(tag.getValue());
+ private void writeShortTagPayload(final ShortTag tag) throws IOException {
+ this.os.writeShort(tag.getValue());
}
/**
* Writes a TAG_Empty tag.
- *
+ *
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
- private void writeEndTagPayload(EndTag tag) {
+ private void writeEndTagPayload(final EndTag tag) {
/* empty */
}
-
- private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
- int[] data = tag.getValue();
- os.writeInt(data.length);
- for (int i = 0; i < data.length; i++) {
- os.writeInt(data[i]);
- }
+
+ private void writeIntArrayTagPayload(final IntArrayTag tag) throws IOException {
+ final int[] data = tag.getValue();
+ this.os.writeInt(data.length);
+ for (final int element : data) {
+ this.os.writeInt(element);
+ }
}
+ @Override
public void close() throws IOException {
- os.close();
+ this.os.close();
}
-}
\ No newline at end of file
+}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java
index 611f109df..06dd71b4f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java
@@ -17,131 +17,160 @@ public final class NBTUtils {
/**
* Gets the type name of a tag.
*
- * @param clazz the tag class
+ * @param clazz
+ * the tag class
* @return The type name.
*/
- public static String getTypeName(Class extends Tag> clazz) {
+ public static String getTypeName(final Class extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return "TAG_Byte_Array";
- } else if (clazz.equals(ByteTag.class)) {
+ }
+ else if (clazz.equals(ByteTag.class)) {
return "TAG_Byte";
- } else if (clazz.equals(CompoundTag.class)) {
+ }
+ else if (clazz.equals(CompoundTag.class)) {
return "TAG_Compound";
- } else if (clazz.equals(DoubleTag.class)) {
+ }
+ else if (clazz.equals(DoubleTag.class)) {
return "TAG_Double";
- } else if (clazz.equals(EndTag.class)) {
+ }
+ else if (clazz.equals(EndTag.class)) {
return "TAG_End";
- } else if (clazz.equals(FloatTag.class)) {
+ }
+ else if (clazz.equals(FloatTag.class)) {
return "TAG_Float";
- } else if (clazz.equals(IntTag.class)) {
+ }
+ else if (clazz.equals(IntTag.class)) {
return "TAG_Int";
- } else if (clazz.equals(ListTag.class)) {
+ }
+ else if (clazz.equals(ListTag.class)) {
return "TAG_List";
- } else if (clazz.equals(LongTag.class)) {
+ }
+ else if (clazz.equals(LongTag.class)) {
return "TAG_Long";
- } else if (clazz.equals(ShortTag.class)) {
+ }
+ else if (clazz.equals(ShortTag.class)) {
return "TAG_Short";
- } else if (clazz.equals(StringTag.class)) {
+ }
+ else if (clazz.equals(StringTag.class)) {
return "TAG_String";
- } else if (clazz.equals(IntArrayTag.class)) {
+ }
+ else if (clazz.equals(IntArrayTag.class)) {
return "TAG_Int_Array";
- } else {
- throw new IllegalArgumentException("Invalid tag classs ("
- + clazz.getName() + ").");
+ }
+ else {
+ throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
/**
* Gets the type code of a tag class.
*
- * @param clazz the tag class
+ * @param clazz
+ * the tag class
* @return The type code.
- * @throws IllegalArgumentException if the tag class is invalid.
+ * @throws IllegalArgumentException
+ * if the tag class is invalid.
*/
- public static int getTypeCode(Class extends Tag> clazz) {
+ public static int getTypeCode(final Class extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return NBTConstants.TYPE_BYTE_ARRAY;
- } else if (clazz.equals(ByteTag.class)) {
+ }
+ else if (clazz.equals(ByteTag.class)) {
return NBTConstants.TYPE_BYTE;
- } else if (clazz.equals(CompoundTag.class)) {
+ }
+ else if (clazz.equals(CompoundTag.class)) {
return NBTConstants.TYPE_COMPOUND;
- } else if (clazz.equals(DoubleTag.class)) {
+ }
+ else if (clazz.equals(DoubleTag.class)) {
return NBTConstants.TYPE_DOUBLE;
- } else if (clazz.equals(EndTag.class)) {
+ }
+ else if (clazz.equals(EndTag.class)) {
return NBTConstants.TYPE_END;
- } else if (clazz.equals(FloatTag.class)) {
+ }
+ else if (clazz.equals(FloatTag.class)) {
return NBTConstants.TYPE_FLOAT;
- } else if (clazz.equals(IntTag.class)) {
+ }
+ else if (clazz.equals(IntTag.class)) {
return NBTConstants.TYPE_INT;
- } else if (clazz.equals(ListTag.class)) {
+ }
+ else if (clazz.equals(ListTag.class)) {
return NBTConstants.TYPE_LIST;
- } else if (clazz.equals(LongTag.class)) {
+ }
+ else if (clazz.equals(LongTag.class)) {
return NBTConstants.TYPE_LONG;
- } else if (clazz.equals(ShortTag.class)) {
+ }
+ else if (clazz.equals(ShortTag.class)) {
return NBTConstants.TYPE_SHORT;
- } else if (clazz.equals(StringTag.class)) {
+ }
+ else if (clazz.equals(StringTag.class)) {
return NBTConstants.TYPE_STRING;
- } else if (clazz.equals(IntArrayTag.class)) {
+ }
+ else if (clazz.equals(IntArrayTag.class)) {
return NBTConstants.TYPE_INT_ARRAY;
- } else {
- throw new IllegalArgumentException("Invalid tag classs ("
- + clazz.getName() + ").");
+ }
+ else {
+ throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
/**
* Gets the class of a type of tag.
*
- * @param type the type
+ * @param type
+ * the type
* @return The class.
- * @throws IllegalArgumentException if the tag type is invalid.
+ * @throws IllegalArgumentException
+ * if the tag type is invalid.
*/
- public static Class extends Tag> getTypeClass(int type) {
+ public static Class extends Tag> getTypeClass(final int type) {
switch (type) {
- case NBTConstants.TYPE_END:
- return EndTag.class;
- case NBTConstants.TYPE_BYTE:
- return ByteTag.class;
- case NBTConstants.TYPE_SHORT:
- return ShortTag.class;
- case NBTConstants.TYPE_INT:
- return IntTag.class;
- case NBTConstants.TYPE_LONG:
- return LongTag.class;
- case NBTConstants.TYPE_FLOAT:
- return FloatTag.class;
- case NBTConstants.TYPE_DOUBLE:
- return DoubleTag.class;
- case NBTConstants.TYPE_BYTE_ARRAY:
- return ByteArrayTag.class;
- case NBTConstants.TYPE_STRING:
- return StringTag.class;
- case NBTConstants.TYPE_LIST:
- return ListTag.class;
- case NBTConstants.TYPE_COMPOUND:
- return CompoundTag.class;
- case NBTConstants.TYPE_INT_ARRAY:
- return IntArrayTag.class;
- default:
- throw new IllegalArgumentException("Invalid tag type : " + type
- + ".");
+ case NBTConstants.TYPE_END:
+ return EndTag.class;
+ case NBTConstants.TYPE_BYTE:
+ return ByteTag.class;
+ case NBTConstants.TYPE_SHORT:
+ return ShortTag.class;
+ case NBTConstants.TYPE_INT:
+ return IntTag.class;
+ case NBTConstants.TYPE_LONG:
+ return LongTag.class;
+ case NBTConstants.TYPE_FLOAT:
+ return FloatTag.class;
+ case NBTConstants.TYPE_DOUBLE:
+ return DoubleTag.class;
+ case NBTConstants.TYPE_BYTE_ARRAY:
+ return ByteArrayTag.class;
+ case NBTConstants.TYPE_STRING:
+ return StringTag.class;
+ case NBTConstants.TYPE_LIST:
+ return ListTag.class;
+ case NBTConstants.TYPE_COMPOUND:
+ return CompoundTag.class;
+ case NBTConstants.TYPE_INT_ARRAY:
+ return IntArrayTag.class;
+ default:
+ throw new IllegalArgumentException("Invalid tag type : " + type + ".");
}
}
/**
* Get child tag of a NBT structure.
*
- * @param items the map to read from
- * @param key the key to look for
- * @param expected the expected NBT class type
+ * @param items
+ * the map to read from
+ * @param key
+ * the key to look for
+ * @param expected
+ * the expected NBT class type
* @return child tag
* @throws InvalidFormatException
*/
- public static T getChildTag(Map items, String key, Class expected) throws IllegalArgumentException {
+ public static T getChildTag(final Map items, final String key, final Class expected) throws IllegalArgumentException {
if (!items.containsKey(key)) {
throw new IllegalArgumentException("Missing a \"" + key + "\" tag");
}
- Tag tag = items.get(key);
+ final Tag tag = items.get(key);
if (!expected.isInstance(tag)) {
throw new IllegalArgumentException(key + " tag is not of tag type " + expected.getName());
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java
index e488968d1..1c4e48c29 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java
@@ -10,9 +10,10 @@ public final class ShortTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public ShortTag(short value) {
+ public ShortTag(final short value) {
super();
this.value = value;
}
@@ -20,27 +21,29 @@ public final class ShortTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public ShortTag(String name, short value) {
+ public ShortTag(final String name, final short value) {
super(name);
this.value = value;
}
@Override
public Short getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_Short" + append + ": " + value;
+ 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 6a66458eb..05069471a 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java
@@ -12,9 +12,10 @@ public final class StringTag extends Tag {
/**
* Creates the tag with an empty name.
*
- * @param value the value of the tag
+ * @param value
+ * the value of the tag
*/
- public StringTag(String value) {
+ public StringTag(final String value) {
super();
checkNotNull(value);
this.value = value;
@@ -23,10 +24,12 @@ public final class StringTag extends Tag {
/**
* Creates the tag.
*
- * @param name the name of the tag
- * @param value the value of the tag
+ * @param name
+ * the name of the tag
+ * @param value
+ * the value of the tag
*/
- public StringTag(String name, String value) {
+ public StringTag(final String name, final String value) {
super(name);
checkNotNull(value);
this.value = value;
@@ -34,17 +37,17 @@ public final class StringTag extends Tag {
@Override
public String getValue() {
- return value;
+ return this.value;
}
@Override
public String toString() {
- String name = getName();
+ final String name = getName();
String append = "";
- if (name != null && !name.equals("")) {
+ if ((name != null) && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
- return "TAG_String" + append + ": " + value;
+ 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 2fab21bd2..26ad12c8b 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java
@@ -16,8 +16,9 @@ public abstract class Tag {
/**
* Creates the tag with the specified name.
- *
- * @param name the name
+ *
+ * @param name
+ * the name
*/
Tag(String name) {
if (name == null) {
@@ -28,16 +29,16 @@ public abstract class Tag {
/**
* Gets the name of this tag.
- *
+ *
* @return the name of this tag
*/
public final String getName() {
- return name;
+ 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
new file mode 100644
index 000000000..6c393fad5
--- /dev/null
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/WorldEditUtils.java
@@ -0,0 +1,29 @@
+package com.intellectualcrafters.jnbt;
+
+import org.bukkit.World;
+
+import com.sk89q.jnbt.CompoundTag;
+import com.sk89q.worldedit.LocalWorld;
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.blocks.BaseBlock;
+import com.sk89q.worldedit.bukkit.BukkitUtil;
+
+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 {
+// bukkitWorld.setBlock(vector, block);
+// }
+// catch (final WorldEditException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+ }
+}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java
index 2dd1af8db..225df4ad1 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java
@@ -1,28 +1,28 @@
package com.intellectualcrafters.json;
/*
-Copyright (c) 2002 JSON.org
+ Copyright (c) 2002 JSON.org
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
-The Software shall be used for Good, not Evil.
+ The Software shall be used for Good, not Evil.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
/**
* This provides static methods to convert comma delimited text into a
@@ -30,16 +30,17 @@ SOFTWARE.
* delimited text is a very popular format for data interchange. It is
* understood by most database, spreadsheet, and organizer programs.
*
- * Each row of text represents a row in a table or a data record. Each row
- * ends with a NEWLINE character. Each row contains one or more values.
- * Values are separated by commas. A value can contain any character except
- * for comma, unless is is wrapped in single quotes or double quotes.
+ * Each row of text represents a row in a table or a data record. Each row ends
+ * with a NEWLINE character. Each row contains one or more values. Values are
+ * separated by commas. A value can contain any character except for comma,
+ * unless is is wrapped in single quotes or double quotes.
*
* The first row usually contains the names of the columns.
*
- * A comma delimited list can be converted into a JSONArray of JSONObjects.
- * The names for the elements in the JSONObjects can be taken from the names
- * in the first row.
+ * A comma delimited list can be converted into a JSONArray of JSONObjects. The
+ * names for the elements in the JSONObjects can be taken from the names in the
+ * first row.
+ *
* @author JSON.org
* @version 2014-05-03
*/
@@ -48,57 +49,62 @@ public class CDL {
/**
* Get the next value. The value can be wrapped in quotes. The value can
* be empty.
- * @param x A JSONTokener of the source text.
+ *
+ * @param x
+ * A JSONTokener of the source text.
* @return The value string, or null if empty.
- * @throws JSONException if the quoted string is badly formed.
+ * @throws JSONException
+ * if the quoted string is badly formed.
*/
- private static String getValue(JSONTokener x) throws JSONException {
+ private static String getValue(final JSONTokener x) throws JSONException {
char c;
char q;
StringBuffer sb;
do {
c = x.next();
- } while (c == ' ' || c == '\t');
+ }
+ while ((c == ' ') || (c == '\t'));
switch (c) {
- case 0:
- return null;
- case '"':
- case '\'':
- q = c;
- sb = new StringBuffer();
- for (;;) {
- c = x.next();
- if (c == q) {
- break;
+ case 0:
+ return null;
+ case '"':
+ case '\'':
+ q = c;
+ sb = new StringBuffer();
+ for (;;) {
+ c = x.next();
+ if (c == q) {
+ break;
+ }
+ if ((c == 0) || (c == '\n') || (c == '\r')) {
+ throw x.syntaxError("Missing close quote '" + q + "'.");
+ }
+ sb.append(c);
}
- if (c == 0 || c == '\n' || c == '\r') {
- throw x.syntaxError("Missing close quote '" + q + "'.");
- }
- sb.append(c);
- }
- return sb.toString();
- case ',':
- x.back();
- return "";
- default:
- x.back();
- return x.nextTo(',');
+ return sb.toString();
+ case ',':
+ x.back();
+ return "";
+ default:
+ x.back();
+ return x.nextTo(',');
}
}
/**
* Produce a JSONArray of strings from a row of comma delimited values.
- * @param x A JSONTokener of the source text.
+ *
+ * @param x
+ * A JSONTokener of the source text.
* @return A JSONArray of strings.
* @throws JSONException
*/
- public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
- JSONArray ja = new JSONArray();
+ public static JSONArray rowToJSONArray(final JSONTokener x) throws JSONException {
+ final JSONArray ja = new JSONArray();
for (;;) {
- String value = getValue(x);
+ final String value = getValue(x);
char c = x.next();
- if (value == null ||
- (ja.length() == 0 && value.length() == 0 && c != ',')) {
+ if ((value == null) || ((ja.length() == 0) && (value.length() == 0) && (c != ','))) {
return null;
}
ja.put(value);
@@ -107,11 +113,10 @@ public class CDL {
break;
}
if (c != ' ') {
- if (c == '\n' || c == '\r' || c == 0) {
+ if ((c == '\n') || (c == '\r') || (c == 0)) {
return ja;
}
- throw x.syntaxError("Bad character '" + c + "' (" +
- (int)c + ").");
+ throw x.syntaxError("Bad character '" + c + "' (" + (int) c + ").");
}
c = x.next();
}
@@ -121,48 +126,52 @@ 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.
- * @param names A JSONArray of names. This is commonly obtained from the
- * first row of a comma delimited text file using the rowToJSONArray
- * method.
- * @param x A JSONTokener of the source text.
+ *
+ * @param names
+ * A JSONArray of names. This is commonly obtained from the
+ * first row of a comma delimited text file using the
+ * rowToJSONArray
+ * method.
+ * @param x
+ * A JSONTokener of the source text.
* @return A JSONObject combining the names and values.
* @throws JSONException
*/
- public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
- throws JSONException {
- JSONArray ja = rowToJSONArray(x);
- return ja != null ? ja.toJSONObject(names) : null;
+ public static JSONObject rowToJSONObject(final JSONArray names, final JSONTokener x) throws JSONException {
+ 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.
- * @param ja A JSONArray of strings.
+ *
+ * @param ja
+ * A JSONArray of strings.
* @return A string ending in NEWLINE.
*/
- public static String rowToString(JSONArray ja) {
- StringBuilder sb = new StringBuilder();
+ public static String rowToString(final JSONArray ja) {
+ final StringBuilder sb = new StringBuilder();
for (int i = 0; i < ja.length(); i += 1) {
if (i > 0) {
sb.append(',');
}
- Object object = ja.opt(i);
+ final Object object = ja.opt(i);
if (object != null) {
- String string = object.toString();
- if (string.length() > 0 && (string.indexOf(',') >= 0 ||
- string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 ||
- string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
+ final String string = object.toString();
+ if ((string.length() > 0) && ((string.indexOf(',') >= 0) || (string.indexOf('\n') >= 0) || (string.indexOf('\r') >= 0) || (string.indexOf(0) >= 0) || (string.charAt(0) == '"'))) {
sb.append('"');
- int length = string.length();
+ final int length = string.length();
for (int j = 0; j < length; j += 1) {
- char c = string.charAt(j);
- if (c >= ' ' && c != '"') {
+ final char c = string.charAt(j);
+ if ((c >= ' ') && (c != '"')) {
sb.append(c);
}
}
sb.append('"');
- } else {
+ }
+ else {
sb.append(string);
}
}
@@ -174,54 +183,62 @@ public class CDL {
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
- * @param string The comma delimited text.
+ *
+ * @param string
+ * The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
- public static JSONArray toJSONArray(String string) throws JSONException {
+ 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.
- * @param x The JSONTokener containing the comma delimited text.
+ *
+ * @param x
+ * The JSONTokener containing the comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
- public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
+ 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.
- * @param names A JSONArray of strings.
- * @param string The comma delimited text.
+ *
+ * @param names
+ * A JSONArray of strings.
+ * @param string
+ * The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
- public static JSONArray toJSONArray(JSONArray names, String string)
- throws JSONException {
+ 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.
- * @param names A JSONArray of strings.
- * @param x A JSONTokener of the source text.
+ *
+ * @param names
+ * A JSONArray of strings.
+ * @param x
+ * A JSONTokener of the source text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
- public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
- throws JSONException {
- if (names == null || names.length() == 0) {
+ public static JSONArray toJSONArray(final JSONArray names, final JSONTokener x) throws JSONException {
+ if ((names == null) || (names.length() == 0)) {
return null;
}
- JSONArray ja = new JSONArray();
+ final JSONArray ja = new JSONArray();
for (;;) {
- JSONObject jo = rowToJSONObject(names, x);
+ final JSONObject jo = rowToJSONObject(names, x);
if (jo == null) {
break;
}
@@ -233,19 +250,20 @@ 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.
- * @param ja A JSONArray of JSONObjects.
+ *
+ * @param ja
+ * A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/
- public static String toString(JSONArray ja) throws JSONException {
- JSONObject jo = ja.optJSONObject(0);
+ public static String toString(final JSONArray ja) throws JSONException {
+ final JSONObject jo = ja.optJSONObject(0);
if (jo != null) {
- JSONArray names = jo.names();
+ final JSONArray names = jo.names();
if (names != null) {
return rowToString(names) + toString(names, ja);
}
@@ -257,19 +275,21 @@ public class CDL {
* 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.
- * @param names A JSONArray of strings.
- * @param ja A JSONArray of JSONObjects.
+ *
+ * @param names
+ * A JSONArray of strings.
+ * @param ja
+ * A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/
- public static String toString(JSONArray names, JSONArray ja)
- throws JSONException {
- if (names == null || names.length() == 0) {
+ public static String toString(final JSONArray names, final JSONArray ja) throws JSONException {
+ if ((names == null) || (names.length() == 0)) {
return null;
}
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
for (int i = 0; i < ja.length(); i += 1) {
- JSONObject jo = ja.optJSONObject(i);
+ final JSONObject jo = ja.optJSONObject(i);
if (jo != null) {
sb.append(rowToString(jo.toJSONArray(names)));
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java
index db32467b7..180997462 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java
@@ -1,31 +1,33 @@
package com.intellectualcrafters.json;
+
/*
-Copyright (c) 2002 JSON.org
+ Copyright (c) 2002 JSON.org
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
-The Software shall be used for Good, not Evil.
+ The Software shall be used for Good, not Evil.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
/**
* Convert a web browser cookie specification to a JSONObject and back.
* JSON and Cookies are both notations for name/value pairs.
+ *
* @author JSON.org
* @version 2014-05-03
*/
@@ -40,28 +42,30 @@ public class Cookie {
* only a convention, not a standard. Often, cookies are expected to have
* encoded values. We encode '=' and ';' because we must. We encode '%' and
* '+' because they are meta characters in URL encoding.
- * @param string The source string.
- * @return The escaped result.
+ *
+ * @param string
+ * The source string.
+ * @return The escaped result.
*/
- public static String escape(String string) {
- char c;
- String s = string.trim();
- int length = s.length();
- StringBuilder sb = new StringBuilder(length);
+ public static String escape(final String string) {
+ char c;
+ final String s = string.trim();
+ final int length = s.length();
+ final StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; i += 1) {
c = s.charAt(i);
- if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
+ if ((c < ' ') || (c == '+') || (c == '%') || (c == '=') || (c == ';')) {
sb.append('%');
- sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16));
- sb.append(Character.forDigit((char)(c & 0x0f), 16));
- } else {
+ sb.append(Character.forDigit((char) ((c >>> 4) & 0x0f), 16));
+ sb.append(Character.forDigit((char) (c & 0x0f), 16));
+ }
+ else {
sb.append(c);
}
}
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
@@ -72,16 +76,18 @@ public class Cookie {
* stored under the key "value". This method does not do checking or
* validation of the parameters. It only converts the cookie string into
* a JSONObject.
- * @param string The cookie specification string.
+ *
+ * @param string
+ * The cookie specification string.
* @return A JSONObject containing "name", "value", and possibly other
- * members.
+ * members.
* @throws JSONException
*/
- public static JSONObject toJSONObject(String string) throws JSONException {
- String name;
- JSONObject jo = new JSONObject();
- Object value;
- JSONTokener x = new JSONTokener(string);
+ public static JSONObject toJSONObject(final String string) throws JSONException {
+ String name;
+ final JSONObject jo = new JSONObject();
+ Object value;
+ final JSONTokener x = new JSONTokener(string);
jo.put("name", x.nextTo('='));
x.next('=');
jo.put("value", x.nextTo(';'));
@@ -91,10 +97,12 @@ public class Cookie {
if (x.next() != '=') {
if (name.equals("secure")) {
value = Boolean.TRUE;
- } else {
+ }
+ else {
throw x.syntaxError("Missing '=' in cookie parameter.");
}
- } else {
+ }
+ else {
value = unescape(x.nextTo(';'));
x.next();
}
@@ -103,19 +111,20 @@ 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 specification string.
* All other members are ignored.
- * @param jo A JSONObject
+ *
+ * @param jo
+ * A JSONObject
* @return A cookie specification string
* @throws JSONException
*/
- public static String toString(JSONObject jo) throws JSONException {
- StringBuilder sb = new StringBuilder();
+ public static String toString(final JSONObject jo) throws JSONException {
+ final StringBuilder sb = new StringBuilder();
sb.append(escape(jo.getString("name")));
sb.append("=");
@@ -141,23 +150,26 @@ public class Cookie {
/**
* Convert %hh sequences to single characters, and
* convert plus to space.
- * @param string A string that may contain
- * + (plus) and
- * %hh sequences.
+ *
+ * @param string
+ * A string that may contain +
+ * (plus) and %hh
+ * sequences.
* @return The unescaped string.
*/
- public static String unescape(String string) {
- int length = string.length();
- StringBuilder sb = new StringBuilder(length);
+ public static String unescape(final String string) {
+ final int length = string.length();
+ final StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; ++i) {
char c = string.charAt(i);
if (c == '+') {
c = ' ';
- } else if (c == '%' && i + 2 < length) {
- int d = JSONTokener.dehexchar(string.charAt(i + 1));
- int e = JSONTokener.dehexchar(string.charAt(i + 2));
- if (d >= 0 && e >= 0) {
- c = (char)(d * 16 + e);
+ }
+ else if ((c == '%') && ((i + 2) < length)) {
+ final int d = JSONTokener.dehexchar(string.charAt(i + 1));
+ final int e = JSONTokener.dehexchar(string.charAt(i + 2));
+ if ((d >= 0) && (e >= 0)) {
+ c = (char) ((d * 16) + e);
i += 2;
}
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java
index 5b7f13c8a..146cecbaa 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java
@@ -1,33 +1,34 @@
package com.intellectualcrafters.json;
/*
-Copyright (c) 2002 JSON.org
+ Copyright (c) 2002 JSON.org
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
-The Software shall be used for Good, not Evil.
+ The Software shall be used for Good, not Evil.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
import java.util.Iterator;
/**
* Convert a web browser cookie list string to a JSONObject and back.
+ *
* @author JSON.org
* @version 2014-05-03
*/
@@ -41,16 +42,18 @@ public class CookieList {
*
* To add a cookie to a cooklist,
* cookielistJSONObject.put(cookieJSONObject.getString("name"),
- * cookieJSONObject.getString("value"));
- * @param string A cookie list string
+ * cookieJSONObject.getString("value"));
+ *
+ * @param string
+ * A cookie list string
* @return A JSONObject
* @throws JSONException
*/
- public static JSONObject toJSONObject(String string) throws JSONException {
- JSONObject jo = new JSONObject();
- JSONTokener x = new JSONTokener(string);
+ public static JSONObject toJSONObject(final String string) throws JSONException {
+ final JSONObject jo = new JSONObject();
+ final JSONTokener x = new JSONTokener(string);
while (x.more()) {
- String name = Cookie.unescape(x.nextTo('='));
+ final String name = Cookie.unescape(x.nextTo('='));
x.next('=');
jo.put(name, Cookie.unescape(x.nextTo(';')));
x.next();
@@ -63,15 +66,17 @@ public class CookieList {
* of name/value pairs. The names are separated from the values by '='.
* The pairs are separated by ';'. The characters '%', '+', '=', and ';'
* in the names and values are replaced by "%hh".
- * @param jo A JSONObject
+ *
+ * @param jo
+ * A JSONObject
* @return A cookie list string
* @throws JSONException
*/
- public static String toString(JSONObject jo) throws JSONException {
- boolean b = false;
- Iterator keys = jo.keys();
- String string;
- StringBuilder sb = new StringBuilder();
+ public static String toString(final JSONObject jo) throws JSONException {
+ boolean b = false;
+ final Iterator keys = jo.keys();
+ String string;
+ final StringBuilder sb = new StringBuilder();
while (keys.hasNext()) {
string = keys.next();
if (!jo.isNull(string)) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java
index 2508ba760..7dfac0a04 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java
@@ -1,33 +1,34 @@
package com.intellectualcrafters.json;
/*
-Copyright (c) 2002 JSON.org
+ Copyright (c) 2002 JSON.org
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
-The Software shall be used for Good, not Evil.
+ The Software shall be used for Good, not Evil.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
import java.util.Iterator;
/**
* Convert an HTTP header to a JSONObject and back.
+ *
* @author JSON.org
* @version 2014-05-03
*/
@@ -39,63 +40,82 @@ public class HTTP {
/**
* Convert an HTTP header string into a JSONObject. It can be a request
* header or a response header. A request header will contain
- *
+ *
* It does no further checking or conversion. It does not parse dates.
* It does not do '%' transforms on URLs.
- * @param string An HTTP header string.
+ *
+ * @param string
+ * An HTTP header string.
* @return A JSONObject containing the elements and attributes
- * of the XML string.
+ * of the XML string.
* @throws JSONException
*/
- public static JSONObject toJSONObject(String string) throws JSONException {
- JSONObject jo = new JSONObject();
- HTTPTokener x = new HTTPTokener(string);
- String token;
+ public static JSONObject toJSONObject(final String string) throws JSONException {
+ final JSONObject jo = new JSONObject();
+ final HTTPTokener x = new HTTPTokener(string);
+ String token;
token = x.nextToken();
if (token.toUpperCase().startsWith("HTTP")) {
-// Response
+ // Response
jo.put("HTTP-Version", token);
jo.put("Status-Code", x.nextToken());
jo.put("Reason-Phrase", x.nextTo('\0'));
x.next();
- } else {
+ }
+ else {
-// Request
+ // Request
jo.put("Method", token);
jo.put("Request-URI", x.nextToken());
jo.put("HTTP-Version", x.nextToken());
}
-// Fields
+ // Fields
while (x.more()) {
- String name = x.nextTo(':');
+ final String name = x.nextTo(':');
x.next(':');
jo.put(name, x.nextTo('\0'));
x.next();
@@ -103,38 +123,49 @@ public class HTTP {
return jo;
}
-
/**
* Convert a JSONObject into an HTTP header. A request header must contain
- *
+ *
* Any other members of the JSONObject will be output as HTTP fields.
* The result will end with two CRLF pairs.
- * @param jo A JSONObject
+ *
+ * @param jo
+ * A JSONObject
* @return An HTTP header string.
- * @throws JSONException if the object does not contain enough
- * information.
+ * @throws JSONException
+ * if the object does not contain enough
+ * information.
*/
- public static String toString(JSONObject jo) throws JSONException {
- Iterator keys = jo.keys();
- String string;
- StringBuilder sb = new StringBuilder();
+ public static String toString(final JSONObject jo) throws JSONException {
+ final Iterator keys = jo.keys();
+ String string;
+ final StringBuilder sb = new StringBuilder();
if (jo.has("Status-Code") && jo.has("Reason-Phrase")) {
sb.append(jo.getString("HTTP-Version"));
sb.append(' ');
sb.append(jo.getString("Status-Code"));
sb.append(' ');
sb.append(jo.getString("Reason-Phrase"));
- } else if (jo.has("Method") && jo.has("Request-URI")) {
+ }
+ else if (jo.has("Method") && jo.has("Request-URI")) {
sb.append(jo.getString("Method"));
sb.append(' ');
sb.append('"');
@@ -142,15 +173,14 @@ public class HTTP {
sb.append('"');
sb.append(' ');
sb.append(jo.getString("HTTP-Version"));
- } else {
+ }
+ else {
throw new JSONException("Not enough material for an HTTP header.");
}
sb.append(CRLF);
while (keys.hasNext()) {
string = keys.next();
- if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string) &&
- !"Reason-Phrase".equals(string) && !"Method".equals(string) &&
- !"Request-URI".equals(string) && !jo.isNull(string)) {
+ if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string) && !"Reason-Phrase".equals(string) && !"Method".equals(string) && !"Request-URI".equals(string) && !jo.isNull(string)) {
sb.append(string);
sb.append(": ");
sb.append(jo.getString(string));
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java
index 513776f78..b232d404f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java
@@ -1,31 +1,33 @@
package com.intellectualcrafters.json;
+
/*
-Copyright (c) 2002 JSON.org
+ Copyright (c) 2002 JSON.org
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
-The Software shall be used for Good, not Evil.
+ The Software shall be used for Good, not Evil.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
/**
* The HTTPTokener extends the JSONTokener to provide additional methods
* for the parsing of HTTP headers.
+ *
* @author JSON.org
* @version 2014-05-03
*/
@@ -33,26 +35,29 @@ public class HTTPTokener extends JSONTokener {
/**
* Construct an HTTPTokener from a string.
- * @param string A source string.
+ *
+ * @param string
+ * A source string.
*/
- public HTTPTokener(String string) {
+ public HTTPTokener(final String string) {
super(string);
}
-
/**
* Get the next token or string. This is used in parsing HTTP headers.
+ *
* @throws JSONException
* @return A String.
*/
public String nextToken() throws JSONException {
char c;
char q;
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
do {
c = next();
- } while (Character.isWhitespace(c));
- if (c == '"' || c == '\'') {
+ }
+ while (Character.isWhitespace(c));
+ if ((c == '"') || (c == '\'')) {
q = c;
for (;;) {
c = next();
@@ -66,7 +71,7 @@ public class HTTPTokener extends JSONTokener {
}
}
for (;;) {
- if (c == 0 || Character.isWhitespace(c)) {
+ if ((c == 0) || Character.isWhitespace(c)) {
return sb.toString();
}
sb.append(c);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java
index 099984df5..4fc8ef03e 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java
@@ -69,8 +69,8 @@ import java.util.Map;
*
Strings do not need to be quoted at all if they do not begin with a quote
* or single quote, and if they do not contain leading or trailing spaces, and
* if they do not contain any of these characters:
- * { } [ ] / \ : , # and if they do not look like numbers and
- * if they are not the reserved words true, false, or
+ * { } [ ] / \ : , # and if they do not look like numbers and if
+ * they are not the reserved words true, false, or
* null.
*
*
@@ -99,7 +99,7 @@ public class JSONArray {
* @throws JSONException
* If there is a syntax error.
*/
- public JSONArray(JSONTokener x) throws JSONException {
+ public JSONArray(final JSONTokener x) throws JSONException {
this();
if (x.nextClean() != '[') {
throw x.syntaxError("A JSONArray text must start with '['");
@@ -110,21 +110,22 @@ public class JSONArray {
if (x.nextClean() == ',') {
x.back();
this.myArrayList.add(JSONObject.NULL);
- } else {
+ }
+ else {
x.back();
this.myArrayList.add(x.nextValue());
}
switch (x.nextClean()) {
- case ',':
- if (x.nextClean() == ']') {
+ case ',':
+ if (x.nextClean() == ']') {
+ return;
+ }
+ x.back();
+ break;
+ case ']':
return;
- }
- x.back();
- break;
- case ']':
- return;
- default:
- throw x.syntaxError("Expected a ',' or ']'");
+ default:
+ throw x.syntaxError("Expected a ',' or ']'");
}
}
}
@@ -140,7 +141,7 @@ public class JSONArray {
* @throws JSONException
* If there is a syntax error.
*/
- public JSONArray(String source) throws JSONException {
+ public JSONArray(final String source) throws JSONException {
this(new JSONTokener(source));
}
@@ -150,10 +151,10 @@ public class JSONArray {
* @param collection
* A Collection.
*/
- public JSONArray(Collection