diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java index a73ecb9ba..67fc3d9b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteArrayTag.java @@ -5,7 +5,7 @@ package com.intellectualcrafters.jnbt; */ public final class ByteArrayTag extends Tag { private final byte[] value; - + /** * Creates the tag with an empty name. * @@ -15,7 +15,7 @@ public final class ByteArrayTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -26,12 +26,12 @@ public final class ByteArrayTag extends Tag { super(name); this.value = value; } - + @Override public byte[] getValue() { return this.value; } - + @Override public String toString() { final StringBuilder hex = new StringBuilder(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java index 388ed82e2..6ee42254c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ByteTag.java @@ -5,7 +5,7 @@ package com.intellectualcrafters.jnbt; */ public final class ByteTag extends Tag { private final byte value; - + /** * Creates the tag with an empty name. * @@ -15,7 +15,7 @@ public final class ByteTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -26,12 +26,12 @@ public final class ByteTag extends Tag { super(name); this.value = value; } - + @Override public Byte getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java index 10c11b32c..88f642d6f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java @@ -10,7 +10,7 @@ import java.util.Map; */ public final class CompoundTag extends Tag { private final Map value; - + /** * Creates the tag with an empty name. * @@ -20,7 +20,7 @@ public final class CompoundTag extends Tag { super(); this.value = Collections.unmodifiableMap(value); } - + /** * Creates the tag. * @@ -31,7 +31,7 @@ public final class CompoundTag extends Tag { super(name); this.value = Collections.unmodifiableMap(value); } - + /** * Returns whether this compound tag contains the given key. * @@ -42,12 +42,12 @@ public final class CompoundTag extends Tag { public boolean containsKey(final String key) { return this.value.containsKey(key); } - + @Override public Map getValue() { return this.value; } - + /** * Return a new compound tag with the given values. * @@ -58,7 +58,7 @@ public final class CompoundTag extends Tag { public CompoundTag setValue(final Map value) { return new CompoundTag(getName(), value); } - + /** * Create a compound tag builder. * @@ -67,7 +67,7 @@ public final class CompoundTag extends Tag { public CompoundTagBuilder createBuilder() { return new CompoundTagBuilder(new HashMap(this.value)); } - + /** * Get a byte array named with the given key.

If the key does not exist or its value is not a byte array * tag, then an empty byte array will be returned.

@@ -84,7 +84,7 @@ public final class CompoundTag extends Tag { return new byte[0]; } } - + /** * Get a byte named with the given key.

If the key does not exist or its value is not a byte tag, then * {@code 0} will be returned.

@@ -101,7 +101,7 @@ public final class CompoundTag extends Tag { return (byte) 0; } } - + /** * Get a double named with the given key.

If the key does not exist or its value is not a double tag, then * {@code 0} will be returned.

@@ -118,7 +118,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a double named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

@@ -145,7 +145,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a float named with the given key.

If the key does not exist or its value is not a float tag, then * {@code 0} will be returned.

@@ -162,7 +162,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a {@code int[]} named with the given key.

If the key does not exist or its value is not an int array * tag, then an empty array will be returned.

@@ -179,7 +179,7 @@ public final class CompoundTag extends Tag { return new int[0]; } } - + /** * Get an int named with the given key.

If the key does not exist or its value is not an int tag, then * {@code 0} will be returned.

@@ -196,7 +196,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get an int named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

@@ -223,7 +223,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a list of tags named with the given key.

If the key does not exist or its value is not a list tag, * then an empty list will be returned.

@@ -240,7 +240,7 @@ public final class CompoundTag extends Tag { return Collections.emptyList(); } } - + /** * Get a {@code TagList} named with the given key.

If the key does not exist or its value is not a list * tag, then an empty tag list will be returned.

@@ -257,7 +257,7 @@ public final class CompoundTag extends Tag { 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 @@ -283,7 +283,7 @@ public final class CompoundTag extends Tag { return Collections.emptyList(); } } - + /** * Get a long named with the given key.

If the key does not exist or its value is not a long tag, then * {@code 0} will be returned.

@@ -300,7 +300,7 @@ public final class CompoundTag extends Tag { return 0L; } } - + /** * Get a long named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

@@ -327,7 +327,7 @@ public final class CompoundTag extends Tag { return 0L; } } - + /** * Get a short named with the given key.

If the key does not exist or its value is not a short tag, then * {@code 0} will be returned.

@@ -344,7 +344,7 @@ public final class CompoundTag extends Tag { return 0; } } - + /** * Get a string named with the given key.

If the key does not exist or its value is not a string tag, then * {@code ""} will be returned.

@@ -361,7 +361,7 @@ public final class CompoundTag extends Tag { return ""; } } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java index 86e04e2fd..3036481f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTagBuilder.java @@ -10,14 +10,14 @@ import java.util.Map; */ public class CompoundTagBuilder { private final Map entries; - + /** * Create a new instance. */ CompoundTagBuilder() { this.entries = new HashMap(); } - + /** * Create a new instance and use the given map (which will be modified). * @@ -27,7 +27,7 @@ public class CompoundTagBuilder { checkNotNull(value); this.entries = value; } - + /** * Create a new builder instance. * @@ -36,7 +36,7 @@ public class CompoundTagBuilder { public static CompoundTagBuilder create() { return new CompoundTagBuilder(); } - + /** * Put the given key and tag into the compound tag. * @@ -51,7 +51,7 @@ public class CompoundTagBuilder { this.entries.put(key, value); return this; } - + /** * Put the given key and value into the compound tag as a {@code ByteArrayTag}. * @@ -63,7 +63,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putByteArray(final String key, final byte[] value) { return put(key, new ByteArrayTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code ByteTag}. * @@ -75,7 +75,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putByte(final String key, final byte value) { return put(key, new ByteTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code DoubleTag}. * @@ -87,7 +87,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putDouble(final String key, final double value) { return put(key, new DoubleTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code FloatTag}. * @@ -99,7 +99,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putFloat(final String key, final float value) { return put(key, new FloatTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code IntArrayTag}. * @@ -111,7 +111,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putIntArray(final String key, final int[] value) { return put(key, new IntArrayTag(key, value)); } - + /** * Put the given key and value into the compound tag as an {@code IntTag}. * @@ -123,7 +123,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putInt(final String key, final int value) { return put(key, new IntTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code LongTag}. * @@ -135,7 +135,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putLong(final String key, final long value) { return put(key, new LongTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code ShortTag}. * @@ -147,7 +147,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putShort(final String key, final short value) { return put(key, new ShortTag(key, value)); } - + /** * Put the given key and value into the compound tag as a {@code StringTag}. * @@ -159,7 +159,7 @@ public class CompoundTagBuilder { public CompoundTagBuilder putString(final String key, final String value) { return put(key, new StringTag(key, value)); } - + /** * Put all the entries from the given map into this map. * @@ -174,7 +174,7 @@ public class CompoundTagBuilder { } return this; } - + /** * Build an unnamed compound tag with this builder's entries. * @@ -183,7 +183,7 @@ public class CompoundTagBuilder { public CompoundTag build() { return new CompoundTag(new HashMap(this.entries)); } - + /** * Build a new compound tag with this builder's entries. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java index d85fd6135..f7db525b3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/DoubleTag.java @@ -5,7 +5,7 @@ package com.intellectualcrafters.jnbt; */ public final class DoubleTag extends Tag { private final double value; - + /** * Creates the tag with an empty name. * @@ -15,7 +15,7 @@ public final class DoubleTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -26,12 +26,12 @@ public final class DoubleTag extends Tag { super(name); this.value = value; } - + @Override public Double getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java index 981925184..70ffaa488 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/EndTag.java @@ -10,12 +10,12 @@ public final class EndTag extends Tag { public EndTag() { super(); } - + @Override public Object getValue() { return null; } - + @Override public String toString() { return "TAG_End"; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java index 2dea1766f..02649fbad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/FloatTag.java @@ -5,7 +5,7 @@ package com.intellectualcrafters.jnbt; */ public final class FloatTag extends Tag { private final float value; - + /** * Creates the tag with an empty name. * @@ -15,7 +15,7 @@ public final class FloatTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -26,12 +26,12 @@ public final class FloatTag extends Tag { super(name); this.value = value; } - + @Override public Float getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java index c4349f89e..372002f05 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntArrayTag.java @@ -7,7 +7,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public final class IntArrayTag extends Tag { private final int[] value; - + /** * Creates the tag with an empty name. * @@ -18,7 +18,7 @@ public final class IntArrayTag extends Tag { checkNotNull(value); this.value = value; } - + /** * Creates the tag. * @@ -30,12 +30,12 @@ public final class IntArrayTag extends Tag { checkNotNull(value); this.value = value; } - + @Override public int[] getValue() { return this.value; } - + @Override public String toString() { final StringBuilder hex = new StringBuilder(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java index bee6eb7d7..abffe3825 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/IntTag.java @@ -5,7 +5,7 @@ package com.intellectualcrafters.jnbt; */ public final class IntTag extends Tag { private final int value; - + /** * Creates the tag with an empty name. * @@ -15,7 +15,7 @@ public final class IntTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -26,12 +26,12 @@ public final class IntTag extends Tag { super(name); this.value = value; } - + @Override public Integer getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java index 415721c30..2f517ef77 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java @@ -14,7 +14,7 @@ import javax.annotation.Nullable; public final class ListTag extends Tag { private final Class type; private final List value; - + /** * Creates the tag with an empty name. * @@ -27,7 +27,7 @@ public final class ListTag extends Tag { this.type = type; this.value = Collections.unmodifiableList(value); } - + /** * Creates the tag. * @@ -41,7 +41,7 @@ public final class ListTag extends Tag { this.type = type; this.value = Collections.unmodifiableList(value); } - + /** * Gets the type of item in this list. * @@ -50,12 +50,12 @@ public final class ListTag extends Tag { public Class getType() { return this.type; } - + @Override public List getValue() { return this.value; } - + /** * Create a new list tag with this tag's name and type. * @@ -66,7 +66,7 @@ public final class ListTag extends Tag { public ListTag setValue(final List list) { return new ListTag(getName(), getType(), list); } - + /** * Get the tag if it exists at the given index. * @@ -82,7 +82,7 @@ public final class ListTag extends Tag { return null; } } - + /** * Get a byte array named with the given index.

If the index does not exist or its value is not a byte * array tag, then an empty byte array will be returned.

@@ -99,7 +99,7 @@ public final class ListTag extends Tag { return new byte[0]; } } - + /** * Get a byte named with the given index.

If the index does not exist or its value is not a byte tag, then * {@code 0} will be returned.

@@ -116,7 +116,7 @@ public final class ListTag extends Tag { return (byte) 0; } } - + /** * Get a double named with the given index.

If the index does not exist or its value is not a double tag, * then {@code 0} will be returned.

@@ -133,7 +133,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a double named with the given index, even if it's another type of number.

If the index does not * exist or its value is not a number, then {@code 0} will be returned.

@@ -160,7 +160,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a float named with the given index.

If the index does not exist or its value is not a float tag, * then {@code 0} will be returned.

@@ -177,7 +177,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a {@code int[]} named with the given index.

If the index does not exist or its value is not an int * array tag, then an empty array will be returned.

@@ -194,7 +194,7 @@ public final class ListTag extends Tag { return new int[0]; } } - + /** * Get an int named with the given index.

If the index does not exist or its value is not an int tag, then * {@code 0} will be returned.

@@ -211,7 +211,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get an int named with the given index, even if it's another type of number.

If the index does not exist * or its value is not a number, then {@code 0} will be returned.

@@ -238,7 +238,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a list of tags named with the given index.

If the index does not exist or its value is not a list * tag, then an empty list will be returned.

@@ -255,7 +255,7 @@ public final class ListTag extends Tag { return Collections.emptyList(); } } - + /** * Get a {@code TagList} named with the given index.

If the index does not exist or its value is not a list * tag, then an empty tag list will be returned.

@@ -272,7 +272,7 @@ public final class ListTag extends Tag { 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 @@ -298,7 +298,7 @@ public final class ListTag extends Tag { return Collections.emptyList(); } } - + /** * Get a long named with the given index.

If the index does not exist or its value is not a long tag, then * {@code 0} will be returned.

@@ -315,7 +315,7 @@ public final class ListTag extends Tag { return 0L; } } - + /** * Get a long named with the given index, even if it's another type of number.

If the index does not exist * or its value is not a number, then {@code 0} will be returned.

@@ -342,7 +342,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a short named with the given index.

If the index does not exist or its value is not a short tag, * then {@code 0} will be returned.

@@ -359,7 +359,7 @@ public final class ListTag extends Tag { return 0; } } - + /** * Get a string named with the given index.

If the index does not exist or its value is not a string tag, * then {@code ""} will be returned.

@@ -376,7 +376,7 @@ public final class ListTag extends Tag { return ""; } } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java index a050599c5..c076aaf80 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java @@ -13,7 +13,7 @@ import java.util.List; public class ListTagBuilder { private final Class type; private final List entries; - + /** * Create a new instance. * @@ -24,7 +24,7 @@ public class ListTagBuilder { this.type = type; this.entries = new ArrayList(); } - + /** * Create a new builder instance. * @@ -33,7 +33,7 @@ public class ListTagBuilder { public static ListTagBuilder create(final Class type) { return new ListTagBuilder(type); } - + /** * Create a new builder instance. * @@ -55,7 +55,7 @@ public class ListTagBuilder { builder.addAll(Arrays.asList(entries)); return builder; } - + /** * Add the given tag. * @@ -71,7 +71,7 @@ public class ListTagBuilder { this.entries.add(value); return this; } - + /** * Add all the tags in the given list. * @@ -86,7 +86,7 @@ public class ListTagBuilder { } return this; } - + /** * Build an unnamed list tag with this builder's entries. * @@ -95,7 +95,7 @@ public class ListTagBuilder { public ListTag build() { return new ListTag(this.type, new ArrayList(this.entries)); } - + /** * Build a new list tag with this builder's entries. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java index 974a4d199..0473c075d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/LongTag.java @@ -5,7 +5,7 @@ package com.intellectualcrafters.jnbt; */ public final class LongTag extends Tag { private final long value; - + /** * Creates the tag with an empty name. * @@ -15,7 +15,7 @@ public final class LongTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -26,12 +26,12 @@ public final class LongTag extends Tag { super(name); this.value = value; } - + @Override public Long getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java index 604859fff..891345802 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTConstants.java @@ -28,13 +28,13 @@ import java.nio.charset.Charset; public final class NBTConstants { public static final Charset CHARSET = Charset.forName("UTF-8"); public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11; - + /** * Default private constructor. */ private NBTConstants() { } - + /** * Convert a type ID to its corresponding {@link Tag} class. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java index 2c9a6610d..be6702d6b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java @@ -16,7 +16,7 @@ import java.util.Map; */ public final class NBTInputStream implements Closeable { private final DataInputStream is; - + /** * Creates a new {@code NBTInputStream}, which will source its data from the specified input stream. * @@ -27,7 +27,7 @@ public final class NBTInputStream implements Closeable { public NBTInputStream(final InputStream is) throws IOException { this.is = new DataInputStream(is); } - + /** * Reads an NBT tag from the stream. * @@ -38,7 +38,7 @@ public final class NBTInputStream implements Closeable { public Tag readTag() throws IOException { return readTag(0); } - + /** * Reads an NBT from the stream. * @@ -61,7 +61,7 @@ public final class NBTInputStream implements Closeable { } return readTagPayload(type, name, depth); } - + /** * Reads the payload of a tag, given the name and type. * @@ -137,7 +137,7 @@ public final class NBTInputStream implements Closeable { throw new IOException("Invalid tag type: " + type + "."); } } - + @Override public void close() throws IOException { this.is.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java index a4deec5a3..884366100 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -39,7 +39,7 @@ public final class NBTOutputStream implements Closeable { * The output stream. */ private final DataOutputStream os; - + /** * Creates a new NBTOutputStream, which will write data to the specified underlying output stream. * @@ -50,7 +50,7 @@ public final class NBTOutputStream implements Closeable { public NBTOutputStream(final OutputStream os) throws IOException { this.os = new DataOutputStream(os); } - + /** * Writes a tag. * @@ -70,7 +70,7 @@ public final class NBTOutputStream implements Closeable { } writeTagPayload(tag); } - + /** * Writes tag payload. * @@ -121,7 +121,7 @@ public final class NBTOutputStream implements Closeable { throw new IOException("Invalid tag type: " + type + "."); } } - + /** * Writes a TAG_Byte tag. * @@ -132,7 +132,7 @@ public final class NBTOutputStream implements Closeable { private void writeByteTagPayload(final ByteTag tag) throws IOException { this.os.writeByte(tag.getValue()); } - + /** * Writes a TAG_Byte_Array tag. * @@ -145,7 +145,7 @@ public final class NBTOutputStream implements Closeable { this.os.writeInt(bytes.length); this.os.write(bytes); } - + /** * Writes a TAG_Compound tag. * @@ -159,7 +159,7 @@ public final class NBTOutputStream implements Closeable { } this.os.writeByte((byte) 0); // end tag - better way? } - + /** * Writes a TAG_List tag. * @@ -177,7 +177,7 @@ public final class NBTOutputStream implements Closeable { writeTagPayload(tag1); } } - + /** * Writes a TAG_String tag. * @@ -190,7 +190,7 @@ public final class NBTOutputStream implements Closeable { this.os.writeShort(bytes.length); this.os.write(bytes); } - + /** * Writes a TAG_Double tag. * @@ -201,7 +201,7 @@ public final class NBTOutputStream implements Closeable { private void writeDoubleTagPayload(final DoubleTag tag) throws IOException { this.os.writeDouble(tag.getValue()); } - + /** * Writes a TAG_Float tag. * @@ -212,7 +212,7 @@ public final class NBTOutputStream implements Closeable { private void writeFloatTagPayload(final FloatTag tag) throws IOException { this.os.writeFloat(tag.getValue()); } - + /** * Writes a TAG_Long tag. * @@ -223,7 +223,7 @@ public final class NBTOutputStream implements Closeable { private void writeLongTagPayload(final LongTag tag) throws IOException { this.os.writeLong(tag.getValue()); } - + /** * Writes a TAG_Int tag. * @@ -234,7 +234,7 @@ public final class NBTOutputStream implements Closeable { private void writeIntTagPayload(final IntTag tag) throws IOException { this.os.writeInt(tag.getValue()); } - + /** * Writes a TAG_Short tag. * @@ -245,7 +245,7 @@ public final class NBTOutputStream implements Closeable { private void writeShortTagPayload(final ShortTag tag) throws IOException { this.os.writeShort(tag.getValue()); } - + /** * Writes a TAG_Empty tag. * @@ -256,7 +256,7 @@ public final class NBTOutputStream implements Closeable { private void writeEndTagPayload(final EndTag tag) { /* empty */ } - + private void writeIntArrayTagPayload(final IntArrayTag tag) throws IOException { final int[] data = tag.getValue(); this.os.writeInt(data.length); @@ -264,7 +264,7 @@ public final class NBTOutputStream implements Closeable { this.os.writeInt(element); } } - + @Override public void close() throws IOException { this.os.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java index 741fdf2ac..d56c9808e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java @@ -11,7 +11,7 @@ public final class NBTUtils { */ private NBTUtils() { } - + /** * Gets the type name of a tag. * @@ -48,7 +48,7 @@ public final class NBTUtils { throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ")."); } } - + /** * Gets the type code of a tag class. * @@ -87,7 +87,7 @@ public final class NBTUtils { throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ")."); } } - + /** * Gets the class of a type of tag. * @@ -127,7 +127,7 @@ public final class NBTUtils { throw new IllegalArgumentException("Invalid tag type : " + type + "."); } } - + /** * Get child tag of a NBT structure. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java index df4ceb57e..5f3b7ec6d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ShortTag.java @@ -25,7 +25,7 @@ package com.intellectualcrafters.jnbt; */ public final class ShortTag extends Tag { private final short value; - + /** * Creates the tag with an empty name. * @@ -35,7 +35,7 @@ public final class ShortTag extends Tag { super(); this.value = value; } - + /** * Creates the tag. * @@ -46,12 +46,12 @@ public final class ShortTag extends Tag { super(name); this.value = value; } - + @Override public Short getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java index 8c0756e63..cb50376a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/StringTag.java @@ -7,7 +7,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public final class StringTag extends Tag { private final String value; - + /** * Creates the tag with an empty name. * @@ -18,7 +18,7 @@ public final class StringTag extends Tag { checkNotNull(value); this.value = value; } - + /** * Creates the tag. * @@ -30,12 +30,12 @@ public final class StringTag extends Tag { checkNotNull(value); this.value = value; } - + @Override public String getValue() { return this.value; } - + @Override public String toString() { final String name = getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java index 395333e13..6fce19169 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/Tag.java @@ -25,14 +25,14 @@ package com.intellectualcrafters.jnbt; */ public abstract class Tag { private final String name; - + /** * Create a new tag with an empty name. */ Tag() { this(""); } - + /** * Creates the tag with the specified name. * @@ -44,7 +44,7 @@ public abstract class Tag { } this.name = name; } - + /** * Gets the name of this tag. * @@ -53,7 +53,7 @@ public abstract class Tag { public final String getName() { return this.name; } - + /** * Gets the value of this tag. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java index 9514eea56..fde894749 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java @@ -60,7 +60,7 @@ public class CDL { return x.nextTo(','); } } - + /** * Produce a JSONArray of strings from a row of comma delimited values. * @@ -93,7 +93,7 @@ public class CDL { } } } - + /** * Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings to provides the * names of the elements. @@ -110,7 +110,7 @@ public class CDL { final JSONArray ja = rowToJSONArray(x); return ja != null ? ja.toJSONObject(names) : null; } - + /** * Produce a comma delimited text row from a JSONArray. Values containing the comma character will be quoted. * Troublesome characters may be removed. @@ -146,7 +146,7 @@ public class CDL { sb.append('\n'); return sb.toString(); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names. * @@ -159,7 +159,7 @@ public class CDL { public static JSONArray toJSONArray(final String string) throws JSONException { return toJSONArray(new JSONTokener(string)); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names. * @@ -172,7 +172,7 @@ public class CDL { public static JSONArray toJSONArray(final JSONTokener x) throws JSONException { return toJSONArray(rowToJSONArray(x), x); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of * element names. @@ -187,7 +187,7 @@ public class CDL { public static JSONArray toJSONArray(final JSONArray names, final String string) throws JSONException { return toJSONArray(names, new JSONTokener(string)); } - + /** * Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of * element names. @@ -216,7 +216,7 @@ public class CDL { } return ja; } - + /** * Produce a comma delimited text from a JSONArray of JSONObjects. The first row will be a list of names obtained by * inspecting the first JSONObject. @@ -237,7 +237,7 @@ public class CDL { } return null; } - + /** * Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names. The list of names * is not included in the output. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java index ee4def328..13a11c597 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Cookie.java @@ -56,7 +56,7 @@ public class Cookie { } return sb.toString(); } - + /** * Convert a cookie specification string into a JSONObject. The string will contain a name value pair separated by * '='. The name and the value will be unescaped, possibly converting '+' and '%' sequences. The cookie properties @@ -96,7 +96,7 @@ public class Cookie { } return jo; } - + /** * Convert a JSONObject into a cookie specification string. The JSONObject must contain "name" and "value" members. * If the JSONObject contains "expires", "domain", "path", or "secure" members, they will be appended to the cookie @@ -130,7 +130,7 @@ public class Cookie { } return sb.toString(); } - + /** * Convert %hh sequences to single characters, and convert plus to space. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java index 01eba0b85..c8ee0136d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java @@ -34,7 +34,7 @@ public class CookieList { } return jo; } - + /** * Convert a JSONObject into a cookie list. A cookie list is a sequence of name/value pairs. The names are separated * from the values by '='. The pairs are separated by ';'. The characters '%', '+', '=', and ';' in the names and diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java index 8bc44d340..c78f24d61 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java @@ -33,7 +33,7 @@ public class HTTP { * Carriage return/line feed. */ public static final String CRLF = "\r\n"; - + /** * Convert an HTTP header string into a JSONObject. It can be a request header or a response header. A request * header will contain @@ -113,7 +113,7 @@ public class HTTP { } return jo; } - + /** * Convert a JSONObject into an HTTP header. A request header must contain *

diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java index 5a3fb1e56..d6bb2cf1e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTPTokener.java @@ -15,7 +15,7 @@ public class HTTPTokener extends JSONTokener { public HTTPTokener(final String string) { super(string); } - + /** * Get the next token or string. This is used in parsing HTTP headers. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java index 4725eec68..026613a2b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java @@ -61,14 +61,14 @@ public class JSONArray { * The arrayList where the JSONArray's properties are kept. */ private final ArrayList myArrayList; - + /** * Construct an empty JSONArray. */ public JSONArray() { this.myArrayList = new ArrayList(); } - + /** * Construct a JSONArray from a JSONTokener. * @@ -106,7 +106,7 @@ public class JSONArray { } } } - + /** * Construct a JSONArray from a source JSON text. * @@ -118,7 +118,7 @@ public class JSONArray { public JSONArray(final String source) throws JSONException { this(new JSONTokener(source)); } - + /** * Construct a JSONArray from a Collection. * @@ -132,7 +132,7 @@ public class JSONArray { } } } - + /** * Construct a JSONArray from an array * @@ -149,7 +149,7 @@ public class JSONArray { throw new JSONException("JSONArray initial value should be a string or collection or array."); } } - + /** * Get the object value associated with an index. * @@ -166,7 +166,7 @@ public class JSONArray { } return object; } - + /** * Get the boolean value associated with an index. The string values "true" and "false" are converted to boolean. * @@ -185,7 +185,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] is not a boolean."); } - + /** * Get the double value associated with an index. * @@ -203,7 +203,7 @@ public class JSONArray { throw new JSONException("JSONArray[" + index + "] is not a number."); } } - + /** * Get the int value associated with an index. * @@ -221,7 +221,7 @@ public class JSONArray { throw new JSONException("JSONArray[" + index + "] is not a number."); } } - + /** * Get the JSONArray associated with an index. * @@ -238,7 +238,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] is not a JSONArray."); } - + /** * Get the JSONObject associated with an index. * @@ -255,7 +255,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] is not a JSONObject."); } - + /** * Get the long value associated with an index. * @@ -273,7 +273,7 @@ public class JSONArray { throw new JSONException("JSONArray[" + index + "] is not a number."); } } - + /** * Get the string associated with an index. * @@ -290,7 +290,7 @@ public class JSONArray { } throw new JSONException("JSONArray[" + index + "] not a string."); } - + /** * Determine if the value is null. * @@ -301,7 +301,7 @@ public class JSONArray { public boolean isNull(final int index) { return JSONObject.NULL.equals(this.opt(index)); } - + /** * Make a string from the contents of this JSONArray. The separator string is inserted between each * element. Warning: This method assumes that the data structure is acyclical. @@ -323,7 +323,7 @@ public class JSONArray { } return sb.toString(); } - + /** * Get the number of elements in the JSONArray, included nulls. * @@ -332,7 +332,7 @@ public class JSONArray { public int length() { return this.myArrayList.size(); } - + /** * Get the optional object value associated with an index. * @@ -343,7 +343,7 @@ public class JSONArray { public Object opt(final int index) { return ((index < 0) || (index >= this.length())) ? null : this.myArrayList.get(index); } - + /** * Get the optional boolean value associated with an index. It returns false if there is no value at that index, or * if the value is not Boolean.TRUE or the String "true". @@ -355,7 +355,7 @@ public class JSONArray { public boolean optBoolean(final int index) { return this.optBoolean(index, false); } - + /** * Get the optional boolean value associated with an index. It returns the defaultValue if there is no value at that * index or if it is not a Boolean or the String "true" or "false" (case insensitive). @@ -372,7 +372,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional double value associated with an index. NaN is returned if there is no value for the index, or if * the value is not a number and cannot be converted to a number. @@ -384,7 +384,7 @@ public class JSONArray { public double optDouble(final int index) { return this.optDouble(index, Double.NaN); } - + /** * Get the optional double value associated with an index. The defaultValue is returned if there is no value for the * index, or if the value is not a number and cannot be converted to a number. @@ -401,7 +401,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional int value associated with an index. Zero is returned if there is no value for the index, or if * the value is not a number and cannot be converted to a number. @@ -413,7 +413,7 @@ public class JSONArray { public int optInt(final int index) { return this.optInt(index, 0); } - + /** * Get the optional int value associated with an index. The defaultValue is returned if there is no value for the * index, or if the value is not a number and cannot be converted to a number. @@ -430,7 +430,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional JSONArray associated with an index. * @@ -442,7 +442,7 @@ public class JSONArray { final Object o = this.opt(index); return o instanceof JSONArray ? (JSONArray) o : null; } - + /** * Get the optional JSONObject associated with an index. Null is returned if the key is not found, or null if the * index has no value, or if the value is not a JSONObject. @@ -455,7 +455,7 @@ public class JSONArray { final Object o = this.opt(index); return o instanceof JSONObject ? (JSONObject) o : null; } - + /** * Get the optional long value associated with an index. Zero is returned if there is no value for the index, or if * the value is not a number and cannot be converted to a number. @@ -467,7 +467,7 @@ public class JSONArray { public long optLong(final int index) { return this.optLong(index, 0); } - + /** * Get the optional long value associated with an index. The defaultValue is returned if there is no value for the * index, or if the value is not a number and cannot be converted to a number. @@ -484,7 +484,7 @@ public class JSONArray { return defaultValue; } } - + /** * Get the optional string value associated with an index. It returns an empty string if there is no value at that * index. If the value is not a string and is not null, then it is coverted to a string. @@ -496,7 +496,7 @@ public class JSONArray { public String optString(final int index) { return this.optString(index, ""); } - + /** * Get the optional string associated with an index. The defaultValue is returned if the key is not found. * @@ -509,7 +509,7 @@ public class JSONArray { final Object object = this.opt(index); return JSONObject.NULL.equals(object) ? defaultValue : object.toString(); } - + /** * Append a boolean value. This increases the array's length by one. * @@ -521,7 +521,7 @@ public class JSONArray { this.put(value ? Boolean.TRUE : Boolean.FALSE); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection. * @@ -533,7 +533,7 @@ public class JSONArray { this.put(new JSONArray(value)); return this; } - + /** * Append a double value. This increases the array's length by one. * @@ -549,7 +549,7 @@ public class JSONArray { this.put(d); return this; } - + /** * Append an int value. This increases the array's length by one. * @@ -561,7 +561,7 @@ public class JSONArray { this.put(new Integer(value)); return this; } - + /** * Append an long value. This increases the array's length by one. * @@ -573,7 +573,7 @@ public class JSONArray { this.put(new Long(value)); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONObject which is produced from a Map. * @@ -585,7 +585,7 @@ public class JSONArray { this.put(new JSONObject(value)); return this; } - + /** * Append an object value. This increases the array's length by one. * @@ -598,7 +598,7 @@ public class JSONArray { this.myArrayList.add(value); return this; } - + /** * Put or replace a boolean value in the JSONArray. If the index is greater than the length of the JSONArray, then * null elements will be added as necessary to pad it out. @@ -614,7 +614,7 @@ public class JSONArray { this.put(index, value ? Boolean.TRUE : Boolean.FALSE); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection. * @@ -629,7 +629,7 @@ public class JSONArray { this.put(index, new JSONArray(value)); return this; } - + /** * Put or replace a double value. If the index is greater than the length of the JSONArray, then null elements will * be added as necessary to pad it out. @@ -645,7 +645,7 @@ public class JSONArray { this.put(index, new Double(value)); return this; } - + /** * Put or replace an int value. If the index is greater than the length of the JSONArray, then null elements will be * added as necessary to pad it out. @@ -661,7 +661,7 @@ public class JSONArray { this.put(index, new Integer(value)); return this; } - + /** * Put or replace a long value. If the index is greater than the length of the JSONArray, then null elements will be * added as necessary to pad it out. @@ -677,7 +677,7 @@ public class JSONArray { this.put(index, new Long(value)); return this; } - + /** * Put a value in the JSONArray, where the value will be a JSONObject that is produced from a Map. * @@ -692,7 +692,7 @@ public class JSONArray { this.put(index, new JSONObject(value)); return this; } - + /** * Put or replace an object value in the JSONArray. If the index is greater than the length of the JSONArray, then * null elements will be added as necessary to pad it out. @@ -720,7 +720,7 @@ public class JSONArray { } return this; } - + /** * Remove an index and close the hole. * @@ -731,7 +731,7 @@ public class JSONArray { public Object remove(final int index) { return (index >= 0) && (index < this.length()) ? this.myArrayList.remove(index) : null; } - + /** * Determine if two JSONArrays are similar. They must contain similar sequences. * @@ -764,7 +764,7 @@ public class JSONArray { } return true; } - + /** * Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray. * @@ -784,7 +784,7 @@ public class JSONArray { } return jo; } - + /** * Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to * produce a syntactically correct JSON text then null will be returned instead. This could occur if the array @@ -802,7 +802,7 @@ public class JSONArray { return null; } } - + /** * Make a prettyprinted JSON text of this JSONArray. Warning: This method assumes that the data structure is * acyclical. @@ -821,7 +821,7 @@ public class JSONArray { return this.write(sw, indentFactor, 0).toString(); } } - + /** * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added. *

@@ -834,7 +834,7 @@ public class JSONArray { public Writer write(final Writer writer) throws JSONException { return this.write(writer, 0, 0); } - + /** * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added. *

diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java index d15aae6d9..090d4e4f7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONException.java @@ -9,7 +9,7 @@ package com.intellectualcrafters.json; public class JSONException extends RuntimeException { private static final long serialVersionUID = 0; private Throwable cause; - + /** * Constructs a JSONException with an explanatory message. * @@ -18,7 +18,7 @@ public class JSONException extends RuntimeException { public JSONException(final String message) { super(message); } - + /** * Constructs a new JSONException with the specified cause. * @@ -28,7 +28,7 @@ public class JSONException extends RuntimeException { super(cause.getMessage()); this.cause = cause; } - + /** * Returns the cause of this exception or null if the cause is nonexistent or unknown. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java index 8d92ddf10..73c5b0b35 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java @@ -183,7 +183,7 @@ public class JSONML { } } } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each * XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then @@ -199,7 +199,7 @@ public class JSONML { public static JSONArray toJSONArray(final String string) throws JSONException { return toJSONArray(new XMLTokener(string)); } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each * XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then @@ -216,7 +216,7 @@ public class JSONML { public static JSONArray toJSONArray(final XMLTokener x) throws JSONException { return (JSONArray) parse(x, true, null); } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes @@ -234,7 +234,7 @@ public class JSONML { public static JSONObject toJSONObject(final XMLTokener x) throws JSONException { return (JSONObject) parse(x, false, null); } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes @@ -252,7 +252,7 @@ public class JSONML { public static JSONObject toJSONObject(final String string) throws JSONException { return toJSONObject(new XMLTokener(string)); } - + /** * Reverse the JSONML transformation, making an XML text from a JSONArray. * @@ -327,7 +327,7 @@ public class JSONML { } return sb.toString(); } - + /** * Reverse the JSONML transformation, making an XML text from a JSONObject. The JSONObject must contain a "tagName" * property. If it has children, then it must have a "childNodes" property containing an array of objects. The other diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java index 6dd084455..7d830b2e5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java @@ -64,14 +64,14 @@ public class JSONObject { * The map where the JSONObject's properties are kept. */ private final Map map; - + /** * Construct an empty JSONObject. */ public JSONObject() { this.map = new HashMap(); } - + /** * Construct a JSONObject from a subset of another JSONObject. An array of strings is used to identify the keys that * should be copied. Missing keys are ignored. @@ -91,7 +91,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from a JSONTokener. * @@ -139,7 +139,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from a Map. * @@ -158,7 +158,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from an Object using bean getters. It reflects on all of the public methods of the object. * For each of the methods with no parameters and a name starting with "get" or "is" @@ -178,7 +178,7 @@ public class JSONObject { this(); this.populateMap(bean); } - + /** * Construct a JSONObject from an Object, using reflection to find the public members. The resulting JSONObject's * keys will be the strings from the names array, and the values will be the field values associated with those keys @@ -197,7 +197,7 @@ public class JSONObject { } } } - + /** * Construct a JSONObject from a source JSON text string. This is the most commonly used JSONObject constructor. * @@ -209,7 +209,7 @@ public class JSONObject { public JSONObject(final String source) throws JSONException { this(new JSONTokener(source)); } - + /** * Construct a JSONObject from a ResourceBundle. * @@ -247,7 +247,7 @@ public class JSONObject { } } } - + /** * Produce a string from a double. The string "null" will be returned if the number is not finite. * @@ -271,7 +271,7 @@ public class JSONObject { } return string; } - + /** * Get an array of field names from a JSONObject. * @@ -291,7 +291,7 @@ public class JSONObject { } return names; } - + /** * Get an array of field names from an Object. * @@ -313,7 +313,7 @@ public class JSONObject { } return names; } - + /** * Produce a string from a Number. * @@ -340,7 +340,7 @@ public class JSONObject { } return string; } - + /** * Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted * within keys() { return this.keySet().iterator(); } - + /** * Get a set of keys of the JSONObject. * @@ -882,7 +882,7 @@ public class JSONObject { public Set keySet() { return this.map.keySet(); } - + /** * Get the number of keys stored in the JSONObject. * @@ -891,7 +891,7 @@ public class JSONObject { public int length() { return this.map.size(); } - + /** * Produce a JSONArray containing the names of the elements of this JSONObject. * @@ -905,7 +905,7 @@ public class JSONObject { } return ja.length() == 0 ? null : ja; } - + /** * Get an optional value associated with a key. * @@ -916,7 +916,7 @@ public class JSONObject { public Object opt(final String key) { return key == null ? null : this.map.get(key); } - + /** * Get an optional boolean associated with a key. It returns false if there is no such key, or if the value is not * Boolean.TRUE or the String "true". @@ -928,7 +928,7 @@ public class JSONObject { public boolean optBoolean(final String key) { return this.optBoolean(key, false); } - + /** * Get an optional boolean associated with a key. It returns the defaultValue if there is no such key, or if it is * not a Boolean or the String "true" or "false" (case insensitive). @@ -945,7 +945,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional double associated with a key, or NaN if there is no such key or if its value is not a number. If * the value is a string, an attempt will be made to evaluate it as a number. @@ -957,7 +957,7 @@ public class JSONObject { public double optDouble(final String key) { return this.optDouble(key, Double.NaN); } - + /** * Get an optional double associated with a key, or the defaultValue if there is no such key or if its value is not * a number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -974,7 +974,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional int value associated with a key, or zero if there is no such key or if the value is not a number. * If the value is a string, an attempt will be made to evaluate it as a number. @@ -986,7 +986,7 @@ public class JSONObject { public int optInt(final String key) { return this.optInt(key, 0); } - + /** * Get an optional int value associated with a key, or the default if there is no such key or if the value is not a * number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -1003,7 +1003,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional JSONArray associated with a key. It returns null if there is no such key, or if its value is not * a JSONArray. @@ -1016,7 +1016,7 @@ public class JSONObject { final Object o = this.opt(key); return o instanceof JSONArray ? (JSONArray) o : null; } - + /** * Get an optional JSONObject associated with a key. It returns null if there is no such key, or if its value is not * a JSONObject. @@ -1029,7 +1029,7 @@ public class JSONObject { final Object object = this.opt(key); return object instanceof JSONObject ? (JSONObject) object : null; } - + /** * Get an optional long value associated with a key, or zero if there is no such key or if the value is not a * number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -1041,7 +1041,7 @@ public class JSONObject { public long optLong(final String key) { return this.optLong(key, 0); } - + /** * Get an optional long value associated with a key, or the default if there is no such key or if the value is not a * number. If the value is a string, an attempt will be made to evaluate it as a number. @@ -1058,7 +1058,7 @@ public class JSONObject { return defaultValue; } } - + /** * Get an optional string associated with a key. It returns an empty string if there is no such key. If the value is * not a string and is not null, then it is converted to a string. @@ -1070,7 +1070,7 @@ public class JSONObject { public String optString(final String key) { return this.optString(key, ""); } - + /** * Get an optional string associated with a key. It returns the defaultValue if there is no such key. * @@ -1083,7 +1083,7 @@ public class JSONObject { final Object object = this.opt(key); return NULL.equals(object) ? defaultValue : object.toString(); } - + private void populateMap(final Object bean) { final Class klass = bean.getClass(); // If klass is a System class then set includeSuperClass to false. @@ -1119,7 +1119,7 @@ public class JSONObject { } } } - + /** * Put a key/boolean pair in the JSONObject. * @@ -1134,7 +1134,7 @@ public class JSONObject { this.put(key, value ? Boolean.TRUE : Boolean.FALSE); return this; } - + /** * Put a key/value pair in the JSONObject, where the value will be a JSONArray which is produced from a Collection. * @@ -1149,7 +1149,7 @@ public class JSONObject { this.put(key, new JSONArray(value)); return this; } - + /** * Put a key/double pair in the JSONObject. * @@ -1164,7 +1164,7 @@ public class JSONObject { this.put(key, new Double(value)); return this; } - + /** * Put a key/int pair in the JSONObject. * @@ -1179,7 +1179,7 @@ public class JSONObject { this.put(key, new Integer(value)); return this; } - + /** * Put a key/long pair in the JSONObject. * @@ -1194,7 +1194,7 @@ public class JSONObject { this.put(key, new Long(value)); return this; } - + /** * Put a key/value pair in the JSONObject, where the value will be a JSONObject which is produced from a Map. * @@ -1209,7 +1209,7 @@ public class JSONObject { this.put(key, new JSONObject(value)); return this; } - + /** * Put a key/value pair in the JSONObject. If the value is null, then the key will be removed from the JSONObject if * it is present. @@ -1234,7 +1234,7 @@ public class JSONObject { } return this; } - + /** * Put a key/value pair in the JSONObject, but only if the key and the value are both non-null, and only if there is * not already a member with that name. @@ -1255,7 +1255,7 @@ public class JSONObject { } return this; } - + /** * Put a key/value pair in the JSONObject, but only if the key and the value are both non-null. * @@ -1273,7 +1273,7 @@ public class JSONObject { } return this; } - + /** * Remove a name and its value, if present. * @@ -1284,7 +1284,7 @@ public class JSONObject { public Object remove(final String key) { return this.map.remove(key); } - + /** * Determine if two JSONObjects are similar. They must contain the same set of names which must be associated with * similar values. @@ -1322,7 +1322,7 @@ public class JSONObject { return false; } } - + /** * Produce a JSONArray containing the values of the members of this JSONObject. * @@ -1343,7 +1343,7 @@ public class JSONObject { } return ja; } - + /** * Make a JSON text of this JSONObject. For compactness, no whitespace is added. If this would not result in a * syntactically correct JSON text, then null will be returned instead. @@ -1362,7 +1362,7 @@ public class JSONObject { return null; } } - + /** * Make a prettyprinted JSON text of this JSONObject. *

@@ -1382,7 +1382,7 @@ public class JSONObject { return this.write(w, indentFactor, 0).toString(); } } - + /** * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added. *

@@ -1395,7 +1395,7 @@ public class JSONObject { public Writer write(final Writer writer) throws JSONException { return this.write(writer, 0, 0); } - + /** * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added. *

@@ -1449,7 +1449,7 @@ public class JSONObject { throw new JSONException(exception); } } - + /** * JSONObject.NULL is equivalent to the value that JavaScript calls null, whilst Java's null is equivalent to the * value that JavaScript calls undefined. @@ -1468,7 +1468,7 @@ public class JSONObject { return this; } } - + /** * A Null object is equal to the null value and to itself. * @@ -1480,7 +1480,7 @@ public class JSONObject { public boolean equals(final Object object) { return (object == null) || (object == this); } - + /** * Get the "null" string value. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java index d29ae0e46..053001408 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java @@ -40,7 +40,7 @@ public class JSONStringer extends JSONWriter { public JSONStringer() { super(new StringWriter()); } - + /** * Return the JSON text. This method is used to obtain the product of the JSONStringer instance. It will return * null if there was a problem in the construction of the JSON text (such as the calls to diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java index 62f0fa135..0c86068ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONTokener.java @@ -22,7 +22,7 @@ public class JSONTokener { private long line; private char previous; private boolean usePrevious; - + /** * Construct a JSONTokener from a Reader. * @@ -37,7 +37,7 @@ public class JSONTokener { this.character = 1; this.line = 1; } - + /** * Construct a JSONTokener from an InputStream. * @@ -46,7 +46,7 @@ public class JSONTokener { public JSONTokener(final InputStream inputStream) throws JSONException { this(new InputStreamReader(inputStream)); } - + /** * Construct a JSONTokener from a string. * @@ -55,7 +55,7 @@ public class JSONTokener { public JSONTokener(final String s) { this(new StringReader(s)); } - + /** * Get the hex value of a character (base16). * @@ -75,7 +75,7 @@ public class JSONTokener { } return -1; } - + /** * Back up one character. This provides a sort of lookahead capability, so that you can test for a digit or letter * before attempting to parse the next number or identifier. @@ -89,11 +89,11 @@ public class JSONTokener { this.usePrevious = true; this.eof = false; } - + public boolean end() { return this.eof && !this.usePrevious; } - + /** * Determine if the source string still contains characters that next() can consume. * @@ -107,7 +107,7 @@ public class JSONTokener { this.back(); return true; } - + /** * Get the next character in the source string. * @@ -142,7 +142,7 @@ public class JSONTokener { this.previous = (char) c; return this.previous; } - + /** * Consume the next character, and check that it matches a specified character. * @@ -159,7 +159,7 @@ public class JSONTokener { } return n; } - + /** * Get the next n characters. * @@ -184,7 +184,7 @@ public class JSONTokener { } return new String(chars); } - + /** * Get the next char in the string, skipping whitespace. * @@ -200,7 +200,7 @@ public class JSONTokener { } } } - + /** * Return the characters up to the next close quote character. Backslash processing is done. The formal JSON format * does not allow strings in single quotes, but an implementation is allowed to accept them. @@ -261,7 +261,7 @@ public class JSONTokener { } } } - + /** * Get the text up but not including the specified character or the end of line, whichever comes first. * @@ -282,7 +282,7 @@ public class JSONTokener { sb.append(c); } } - + /** * Get the text up but not including one of the specified delimiter characters or the end of line, whichever comes * first. @@ -305,7 +305,7 @@ public class JSONTokener { sb.append(c); } } - + /** * Get the next value. The value can be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the * JSONObject.NULL object. @@ -347,7 +347,7 @@ public class JSONTokener { } return JSONObject.stringToValue(string); } - + /** * Skip characters until the next character is the requested character. If the requested character is not found, no * characters are skipped. @@ -379,7 +379,7 @@ public class JSONTokener { this.back(); return c; } - + /** * Make a JSONException to signal a syntax error. * @@ -390,7 +390,7 @@ public class JSONTokener { public JSONException syntaxError(final String message) { return new JSONException(message + this.toString()); } - + /** * Make a printable string of this JSONTokener. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java index a332af1f8..082d37e26 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java @@ -55,7 +55,7 @@ public class JSONWriter { * The stack top index. A value of 0 indicates that the stack is empty. */ private int top; - + /** * Make a fresh JSONWriter. It can be used to build one JSON text. */ @@ -66,7 +66,7 @@ public class JSONWriter { this.top = 0; this.writer = w; } - + /** * Append a value. * @@ -97,7 +97,7 @@ public class JSONWriter { } throw new JSONException("Value out of sequence."); } - + /** * Begin appending a new array. All values until the balancing endArray will be appended to this array. * The endArray method must be called to mark the array's end. @@ -116,7 +116,7 @@ public class JSONWriter { } throw new JSONException("Misplaced array."); } - + /** * End something. * @@ -140,7 +140,7 @@ public class JSONWriter { this.comma = true; return this; } - + /** * End an array. This method most be called to balance calls to array. * @@ -151,7 +151,7 @@ public class JSONWriter { public JSONWriter endArray() throws JSONException { return this.end('a', ']'); } - + /** * End an object. This method most be called to balance calls to object. * @@ -162,7 +162,7 @@ public class JSONWriter { public JSONWriter endObject() throws JSONException { return this.end('k', '}'); } - + /** * Append a key. The key will be associated with the next value. In an object, every value must be preceded by a * key. @@ -195,7 +195,7 @@ public class JSONWriter { } throw new JSONException("Misplaced key."); } - + /** * Begin appending a new object. All keys and values until the balancing endObject will be appended to * this object. The endObject method must be called to mark the object's end. @@ -217,7 +217,7 @@ public class JSONWriter { } throw new JSONException("Misplaced object."); } - + /** * Pop an array or object scope. * @@ -236,7 +236,7 @@ public class JSONWriter { this.top -= 1; this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ? 'a' : 'k'; } - + /** * Push an array or object scope. * @@ -252,7 +252,7 @@ public class JSONWriter { this.mode = jo == null ? 'a' : 'k'; this.top += 1; } - + /** * Append either the value true or the value false . * @@ -265,7 +265,7 @@ public class JSONWriter { public JSONWriter value(final boolean b) throws JSONException { return this.append(b ? "true" : "false"); } - + /** * Append a double value. * @@ -278,7 +278,7 @@ public class JSONWriter { public JSONWriter value(final double d) throws JSONException { return this.value(new Double(d)); } - + /** * Append a long value. * @@ -291,7 +291,7 @@ public class JSONWriter { public JSONWriter value(final long l) throws JSONException { return this.append(Long.toString(l)); } - + /** * Append an object value. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java index 03520de0d..facac85e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java @@ -43,7 +43,7 @@ public class Kim { * The memoization of toString(). */ private String string = null; - + /** * Make a kim from a portion of a byte array. * @@ -70,7 +70,7 @@ public class Kim { this.hashcode += sum << 16; } } - + /** * Make a kim from a byte array. * @@ -80,7 +80,7 @@ public class Kim { public Kim(final byte[] bytes, final int length) { this(bytes, 0, length); } - + /** * Make a new kim from a substring of an existing kim. The coordinates are in byte units, not character units. * @@ -91,7 +91,7 @@ public class Kim { public Kim(final Kim kim, final int from, final int thru) { this(kim.bytes, from, thru); } - + /** * Make a kim from a string. * @@ -173,7 +173,7 @@ public class Kim { this.hashcode += sum << 16; } } - + /** * Returns the number of bytes needed to contain the character in Kim format. * @@ -189,7 +189,7 @@ public class Kim { } return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3; } - + /** * Returns the character at the specified index. The index refers to byte values and ranges from 0 to length - 1. * The index of the next character is at index + Kim.characterSize(kim.characterAt(index)). @@ -220,7 +220,7 @@ public class Kim { } throw new JSONException("Bad character at " + at); } - + /** * Copy the contents of this kim to a byte array. * @@ -233,7 +233,7 @@ public class Kim { System.arraycopy(this.bytes, 0, bytes, at, this.length); return at + this.length; } - + /** * Two kim objects containing exactly the same bytes in the same order are equal to each other. * @@ -255,7 +255,7 @@ public class Kim { } return java.util.Arrays.equals(this.bytes, that.bytes); } - + /** * Get a byte from a kim. * @@ -271,7 +271,7 @@ public class Kim { } return (this.bytes[at]) & 0xFF; } - + /** * Returns a hash code value for the kim. */ @@ -279,7 +279,7 @@ public class Kim { public int hashCode() { return this.hashcode; } - + /** * Produce a UTF-16 String from this kim. The number of codepoints in the string will not be greater than the number * of bytes in the kim, although it could be less. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java index a177df954..cdbaba42d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Property.java @@ -51,7 +51,7 @@ public class Property { } return jo; } - + /** * Converts the JSONObject into a property file object. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java index c14748a1c..6e0d36127 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java @@ -45,7 +45,7 @@ public class XML { * The Character '/'. */ public static final Character SLASH = '/'; - + /** * Replace special characters with XML escapes: *

@@ -87,7 +87,7 @@ public class XML { } return sb.toString(); } - + /** * Throw an exception if the string contains whitespace. Whitespace is not allowed in tagNames and attributes. * @@ -107,7 +107,7 @@ public class XML { } } } - + /** * Scan the content following the named tag, attaching it to the context. * @@ -257,7 +257,7 @@ public class XML { } } } - + /** * Try to convert a string into a number, boolean, or null. If the string can't be converted, return the string. * This is much less ambitious than JSONObject.stringToValue, especially because it does not attempt to convert plus @@ -299,7 +299,7 @@ public class XML { } return string; } - + /** * Convert a well-formed (but not necessarily valid) XML string into a JSONObject. Some information may be lost in * this transformation because JSON is a data format and XML is a document format. XML uses elements, attributes, @@ -322,7 +322,7 @@ public class XML { } return jo; } - + /** * Convert a JSONObject into a well-formed, element-normal XML string. * @@ -335,7 +335,7 @@ public class XML { public static String toString(final Object object) throws JSONException { return toString(object, null); } - + /** * Convert a JSONObject into a well-formed, element-normal XML string. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java index 1431939c7..d0e39ad36 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java @@ -19,7 +19,7 @@ public class XMLTokener extends JSONTokener { entity.put("lt", XML.LT); entity.put("quot", XML.QUOT); } - + /** * Construct an XMLTokener from a string. * @@ -28,7 +28,7 @@ public class XMLTokener extends JSONTokener { public XMLTokener(final String s) { super(s); } - + /** * Get the text in the CDATA block. * @@ -53,7 +53,7 @@ public class XMLTokener extends JSONTokener { } } } - + /** * Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins * a markup tag, and the content text between markup tags. @@ -88,7 +88,7 @@ public class XMLTokener extends JSONTokener { c = next(); } } - + /** * Return the next entity. These entities are translated to Characters: & ' > < * ". @@ -115,7 +115,7 @@ public class XMLTokener extends JSONTokener { final Object object = entity.get(string); return object != null ? object : ampersand + string + ";"; } - + /** * Returns the next XML meta token. This is used for skipping over and structures. * @@ -179,7 +179,7 @@ public class XMLTokener extends JSONTokener { } } } - + /** * Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these characters: * / > = ! ? or it may be a string wrapped in single quotes or double quotes, or it may be a name. @@ -258,7 +258,7 @@ public class XMLTokener extends JSONTokener { } } } - + /** * Skip characters until past the requested string. If it is not found, we are left at the end of the source with a * result of false. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 2ea1385d1..7bae4e1dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -12,10 +12,7 @@ import org.bukkit.World; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; @@ -68,11 +65,6 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS = null; public static PlotSquared MAIN = null; - - @EventHandler - public static void worldLoad(final WorldLoadEvent event) { - UUIDHandler.cacheAll(event.getWorld().getName()); - } public static boolean checkVersion(final int major, final int minor, final int minor2) { try { @@ -91,24 +83,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { return false; } } - - @EventHandler - public void PlayerCommand(final PlayerCommandPreprocessEvent event) { - final String message = event.getMessage(); - if (message.toLowerCase().startsWith("/plotme")) { - final Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe"); - if (plotme == null) { - final Player player = event.getPlayer(); - if (Settings.USE_PLOTME_ALIAS) { - player.performCommand(message.replace("/plotme", "plots")); - } else { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME); - } - event.setCancelled(true); - } - } - } - + @Override public void onEnable() { THIS = this; @@ -124,16 +99,17 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } else { log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); } + System.out.print("REGISTERING EVENTS"); getServer().getPluginManager().registerEvents(this, this); } - + @Override public void onDisable() { MAIN.disable(); MAIN = null; THIS = null; } - + @Override public void log(String message) { message = message.replaceAll("\u00B2", "2"); @@ -147,43 +123,44 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { Bukkit.getServer().getConsoleSender().sendMessage(message); } } - + @Override public void disable() { onDisable(); } - + @Override public String getVersion() { return this.getDescription().getVersion(); } - + @Override public void registerCommands() { - final MainCommand command = new MainCommand(); + new MainCommand(); final BukkitCommand bcmd = new BukkitCommand(); final PluginCommand plotCommand = getCommand("plots"); plotCommand.setExecutor(bcmd); plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot")); plotCommand.setTabCompleter(bcmd); } - + @Override public File getDirectory() { return getDataFolder(); } - + @Override public TaskManager getTaskManager() { return new BukkitTaskManager(); } - + @Override public void runEntityTask() { log(C.PREFIX.s() + "KillAllEntities started."); TaskManager.runTaskRepeat(new Runnable() { long ticked = 0l; long error = 0l; + @Override public void run() { if (this.ticked > 36_000L) { @@ -218,7 +195,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } }, 20); } - + @Override final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { if (!PlotSquared.setupPlotWorld(world, id)) { @@ -226,7 +203,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return new HybridGen(world); } - + @Override public void registerPlayerEvents() { getServer().getPluginManager().registerEvents(new PlayerEvents(), this); @@ -234,23 +211,23 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); } } - + @Override public void registerInventoryEvents() { getServer().getPluginManager().registerEvents(new InventoryListener(), this); } - + @Override public void registerPlotPlusEvents() { PlotPlusListener.startRunnable(this); getServer().getPluginManager().registerEvents(new PlotPlusListener(), this); } - + @Override public void registerForceFieldEvents() { getServer().getPluginManager().registerEvents(new ForceFieldListener(), this); } - + @Override public void registerWorldEditEvents() { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { @@ -266,7 +243,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } } } - + @Override public Economy getEconomy() { if ((getServer().getPluginManager().getPlugin("Vault") != null) && getServer().getPluginManager().getPlugin("Vault").isEnabled()) { @@ -278,7 +255,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return null; } - + @Override public BlockManager initBlockManager() { if (checkVersion(1, 8, 0)) { @@ -295,7 +272,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { SetBlockManager.setBlockManager = new SetBlockSlow(); } } - AbstractSetBlock.setBlockManager = SetBlockManager.setBlockManager; + AbstractSetBlock.setBlockManager = SetBlockManager.setBlockManager; try { new SendChunk(); MainUtil.canSendChunk = true; @@ -304,7 +281,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return BlockManager.manager = new BukkitUtil(); } - + @Override public boolean initPlotMeConverter() { try { @@ -317,7 +294,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return false; } - + @Override public void getGenerator(final String world, final String name) { final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name); @@ -327,7 +304,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { new HybridGen(world); } } - + @Override public boolean callRemovePlot(final String world, final PlotId id) { final PlotDeleteEvent event = new PlotDeleteEvent(world, id); @@ -338,49 +315,45 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return true; } - + @Override public HybridUtils initHybridUtils() { return new BukkitHybridUtils(); } - + @Override public SetupUtils initSetupUtils() { return new BukkitSetupUtils(); } - + @Override public UUIDWrapper initUUIDHandler() { - boolean checkVersion = checkVersion(1, 7, 6); + final boolean checkVersion = checkVersion(1, 7, 6); if (!checkVersion) { - log(C.PREFIX.s()+" &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature."); + log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature."); Settings.TITLES = false; FlagManager.removeFlag(FlagManager.getFlag("titles")); - } - else { + } else { AbstractTitle.TITLE_CLASS = new DefaultTitle(); } if (Settings.OFFLINE_MODE) { UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); Settings.OFFLINE_MODE = true; - } - else if (checkVersion) { + } else if (checkVersion) { UUIDHandler.uuidWrapper = new DefaultUUIDWrapper(); Settings.OFFLINE_MODE = false; - } - else { + } else { UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); Settings.OFFLINE_MODE = true; } if (Settings.OFFLINE_MODE) { - log(C.PREFIX.s()+" &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit"); - } - else { - log(C.PREFIX.s()+" &6PlotSquared is using online UUIDs"); + log(C.PREFIX.s() + " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit"); + } else { + log(C.PREFIX.s() + " &6PlotSquared is using online UUIDs"); } return UUIDHandler.uuidWrapper; } - + @Override public AChunkManager initChunkManager() { return new ChunkManager(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index b95c5aeb0..eebc86696 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -14,44 +14,44 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; public interface IPlotMain { public void log(String message); - + public File getDirectory(); - + public void disable(); - + public String getVersion(); - + public TaskManager getTaskManager(); - + public void runEntityTask(); - + public void registerCommands(); - + public void registerPlayerEvents(); - + public void registerInventoryEvents(); - + public void registerPlotPlusEvents(); - + public void registerForceFieldEvents(); - + public void registerWorldEditEvents(); - + public Economy getEconomy(); - + public BlockManager initBlockManager(); - + public AChunkManager initChunkManager(); - + public SetupUtils initSetupUtils(); - + public HybridUtils initHybridUtils(); - + public UUIDWrapper initUUIDHandler(); - + public boolean initPlotMeConverter(); - + public void getGenerator(String world, String name); - + public boolean callRemovePlot(String world, PlotId id); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 9af49c7bc..97687329f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -82,11 +82,11 @@ public class PlotSquared { private static LinkedHashMap> plots; private static MySQL mySQL; public static Connection connection; - + public static MySQL getMySQL() { return mySQL; } - + public static void updatePlot(final Plot plot) { final String world = plot.world; if (!plots.containsKey(world)) { @@ -95,14 +95,14 @@ public class PlotSquared { plot.hasChanged = true; plots.get(world).put(plot.id, plot); } - + public static PlotWorld getPlotWorld(final String world) { if (plotworlds.containsKey(world)) { return plotworlds.get(world); } return null; } - + public static void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) { plotworlds.put(world, plotworld); plotmanagers.put(world, manager); @@ -110,21 +110,21 @@ public class PlotSquared { plots.put(world, new HashMap()); } } - + public static void removePlotWorld(final String world) { plots.remove(world); plotmanagers.remove(world); plotworlds.remove(world); } - + public static HashMap> getAllPlotsRaw() { return plots; } - + public static void setAllPlotsRaw(final LinkedHashMap> plots) { PlotSquared.plots = plots; } - + public static Set getPlots() { final ArrayList newplots = new ArrayList<>(); for (final HashMap world : plots.values()) { @@ -132,7 +132,7 @@ public class PlotSquared { } return new LinkedHashSet<>(newplots); } - + public static LinkedHashSet getPlotsSorted() { final ArrayList newplots = new ArrayList<>(); for (final HashMap world : plots.values()) { @@ -140,17 +140,17 @@ public class PlotSquared { } return new LinkedHashSet<>(newplots); } - + public static Set getPlots(final String world, final String player) { final UUID uuid = UUIDHandler.getUUID(player); return getPlots(world, uuid); } - + public static Set getPlots(final String world, final PlotPlayer player) { final UUID uuid = player.getUUID(); return getPlots(world, uuid); } - + public static Set getPlots(final String world, final UUID uuid) { final ArrayList myplots = new ArrayList<>(); for (final Plot plot : getPlots(world).values()) { @@ -162,30 +162,30 @@ public class PlotSquared { } return new HashSet<>(myplots); } - + public static boolean isPlotWorld(final String world) { return (plotworlds.containsKey(world)); } - + public static PlotManager getPlotManager(final String world) { if (plotmanagers.containsKey(world)) { return plotmanagers.get(world); } return null; } - + public static String[] getPlotWorldsString() { final Set strings = plots.keySet(); return strings.toArray(new String[strings.size()]); } - + public static HashMap getPlots(final String world) { if (plots.containsKey(world)) { return plots.get(world); } return new HashMap<>(); } - + public static Set getPlots(final PlotPlayer player) { final UUID uuid = player.getUUID(); final ArrayList myplots = new ArrayList<>(); @@ -202,7 +202,7 @@ public class PlotSquared { } return new HashSet<>(myplots); } - + public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) { // FIXME plot remove event plots.get(world).remove(id); @@ -216,7 +216,7 @@ public class PlotSquared { } return true; } - + public static void loadWorld(final String world, final PlotGenerator generator) { if (getPlotWorld(world) != null) { return; @@ -303,7 +303,7 @@ public class PlotSquared { } } } - + public static boolean setupPlotWorld(final String world, final String id) { if ((id != null) && (id.length() > 0)) { // save configuration @@ -395,11 +395,11 @@ public class PlotSquared { } return true; } - + public static Connection getConnection() { return connection; } - + public PlotSquared(final IPlotMain imp_class) { THIS = this; IMP = imp_class; @@ -461,7 +461,7 @@ public class PlotSquared { ExpireManager.runTask(); } } - + public void disable() { try { connection.close(); @@ -472,11 +472,11 @@ public class PlotSquared { } } } - + public static void log(final String message) { IMP.log(message); } - + public void setupDatabase() { final String[] tables; if (Settings.ENABLE_CLUSTERS) { @@ -559,7 +559,7 @@ public class PlotSquared { return; } } - + public static void setupDefaultFlags() { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); final List intervalFlags = Arrays.asList("feed", "heal"); @@ -610,7 +610,7 @@ public class PlotSquared { return null; } } - + @Override public String getValueDesc() { return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'"; @@ -634,14 +634,14 @@ public class PlotSquared { return null; } } - + @Override public String getValueDesc() { return "Flag value must be weather type: 'clear' or 'rain'"; } }); } - + public static void setupConfig() { config.set("version", VERSION); final Map options = new HashMap<>(); @@ -700,7 +700,7 @@ public class PlotSquared { Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk"); Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); } - + public static void setupConfigs() { final File folder = new File(IMP.getDirectory() + File.separator + "config"); if (!folder.exists() && !folder.mkdirs()) { @@ -754,7 +754,7 @@ public class PlotSquared { e.printStackTrace(); } } - + private static void setupStorage() { storage.set("version", VERSION); final Map options = new HashMap<>(); @@ -789,7 +789,7 @@ public class PlotSquared { Settings.CUSTOM_API = config.getBoolean("uuid.api.custom"); Settings.UUID_FECTHING = config.getBoolean("uuid.fetching"); } - + public static void showDebug() { C.COLOR_1 = "&" + (style.getString("color.1")); C.COLOR_2 = "&" + (style.getString("color.2")); @@ -812,7 +812,7 @@ public class PlotSquared { } } } - + private static void setupStyle() { style.set("version", VERSION); final Map o = new HashMap<>(); @@ -826,11 +826,11 @@ public class PlotSquared { } } } - + public static double getJavaVersion() { return Double.parseDouble(System.getProperty("java.specification.version")); } - + public static Set getPlotWorlds() { return plotworlds.keySet(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index e16129fcf..31cecb185 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -40,7 +40,7 @@ public class Auto extends SubCommand { public Auto() { super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true); } - + public static PlotId getNextPlot(final PlotId id, final int step) { final int absX = Math.abs(id.x); final int absY = Math.abs(id.y); @@ -69,7 +69,7 @@ public class Auto extends SubCommand { return new PlotId(id.x + 1, id.y); } } - + // TODO auto claim a mega plot with schematic @Override public boolean execute(final PlotPlayer plr, final String... args) { @@ -119,7 +119,7 @@ public class Auto extends SubCommand { MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); return false; } - int currentPlots = MainUtil.getPlayerPlotCount(world, plr); + final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); final int diff = currentPlots - MainUtil.getAllowedPlots(plr, currentPlots); if ((diff + (size_x * size_z)) > 0) { if (diff < 0) { @@ -231,7 +231,7 @@ public class Auto extends SubCommand { MainUtil.lastPlot.put(worldname, new PlotId(0, 0)); return true; } - + public PlotId getLastPlot(final String world) { if ((MainUtil.lastPlot == null) || !MainUtil.lastPlot.containsKey(world)) { MainUtil.lastPlot.put(world, new PlotId(0, 0)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java index b075772a3..0e05fefe0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java @@ -19,15 +19,15 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; * @author Citymonstret */ public class BukkitCommand implements CommandExecutor, TabCompleter { - + @Override - public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) { + public boolean onCommand(final CommandSender commandSender, final Command command, final String commandLabel, final String[] args) { if (commandSender instanceof Player) { return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args); } return MainCommand.onCommand(null, commandLabel, args); } - + @Override public List onTabComplete(final CommandSender commandSender, final Command command, final String s, final String[] strings) { if (!(commandSender instanceof Player)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 218876b4c..624ff89cf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -41,13 +41,13 @@ public class Buy extends SubCommand { public Buy() { super(Command.BUY, "Buy the plot you are standing on", "b", CommandCategory.CLAIMING, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (PlotSquared.economy == null) { return sendMessage(plr, C.ECON_DISABLED); } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final String world = loc.getWorld(); if (!PlotSquared.isPlotWorld(world)) { return sendMessage(plr, C.NOT_IN_PLOT_WORLD); @@ -67,7 +67,7 @@ public class Buy extends SubCommand { if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - int currentPlots = MainUtil.getPlayerPlotCount(world, plr); + final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } @@ -91,14 +91,14 @@ public class Buy extends SubCommand { price += plotworld.PLOT_PRICE * size; initPrice += plotworld.SELL_PRICE * size; } - if (PlotSquared.economy != null && price > 0d) { + if ((PlotSquared.economy != null) && (price > 0d)) { if (EconHandler.getBalance(plr) < price) { return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price); } EconHandler.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); - PlotPlayer owner = UUIDHandler.getPlayer(plot.owner); + final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner); if (owner != null) { sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index b6a7234f4..10b744d57 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import net.milkbowl.vault.economy.Economy; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; @@ -40,26 +38,26 @@ public class Claim extends SubCommand { public Claim() { super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true); } - + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final boolean auto) { return claimPlot(player, plot, teleport, "", auto); } - + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) { if (plot.hasOwner() || plot.settings.isMerged()) { return false; } // FIXME claim plot event -// final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); -// Bukkit.getPluginManager().callEvent(event); -// boolean result = event.isCancelled(); - boolean result = false; - + // final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); + // Bukkit.getPluginManager().callEvent(event); + // boolean result = event.isCancelled(); + final boolean result = false; + if (!result) { MainUtil.createPlot(player.getUUID(), plot); MainUtil.setSign(player.getName(), plot); MainUtil.sendMessage(player, C.CLAIMED); - Location loc = player.getLocation(); + final Location loc = player.getLocation(); if (teleport) { MainUtil.teleportPlayer(player, loc, plot); } @@ -83,19 +81,19 @@ public class Claim extends SubCommand { } return !result; } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { String schematic = ""; if (args.length >= 1) { schematic = args[0]; } - Location loc = plr.getLocation(); - Plot plot = MainUtil.getPlot(loc); + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr); + final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr); if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } @@ -103,7 +101,7 @@ public class Claim extends SubCommand { return sendMessage(plr, C.PLOT_IS_CLAIMED); } final PlotWorld world = PlotSquared.getPlotWorld(plot.world); - if (PlotSquared.economy != null && world.USE_ECONOMY) { + if ((PlotSquared.economy != null) && world.USE_ECONOMY) { final double cost = world.PLOT_PRICE; if (cost > 0d) { if (EconHandler.getBalance(plr) < cost) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 2afd14432..8978785a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -34,7 +34,7 @@ public class Clear extends SubCommand { public Clear() { super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { @@ -62,12 +62,12 @@ public class Clear extends SubCommand { } return true; } - Location loc = plr.getLocation(); - Plot plot = MainUtil.getPlot(loc); + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot( plot))) { + if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { @@ -75,7 +75,7 @@ public class Clear extends SubCommand { } assert plot != null; final long start = System.currentTimeMillis(); - boolean result = MainUtil.clearAsPlayer(plot, false, new Runnable() { + final boolean result = MainUtil.clearAsPlayer(plot, false, new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index a52b5a10e..89a5ee654 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -45,7 +45,7 @@ public class Cluster extends SubCommand { public Cluster() { super(Command.CLUSTER, "Manage a plot cluster", "cluster", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome @@ -307,7 +307,7 @@ public class Cluster extends SubCommand { cluster.invited.add(uuid); final String world = plr.getLocation().getWorld(); DBFunc.setInvited(world, cluster, uuid); - PlotPlayer player = UUIDHandler.getPlayer(uuid); + final PlotPlayer player = UUIDHandler.getPlayer(uuid); if (player != null) { MainUtil.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); } @@ -354,7 +354,7 @@ public class Cluster extends SubCommand { } cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); - PlotPlayer player = UUIDHandler.getPlayer(uuid); + final PlotPlayer player = UUIDHandler.getPlayer(uuid); if (player != null) { MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 5ed37a89b..3437e54ed 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -87,7 +87,7 @@ public enum Command { * Permission Node */ private final CommandPermission permission; - + /** * @param command Command "name" (/plot [cmd]) */ @@ -96,7 +96,7 @@ public enum Command { this.alias = command; this.permission = new CommandPermission("plots." + command); } - + /** * @param command Command "name" (/plot [cmd]) * @param permission Command Permission Node @@ -106,7 +106,7 @@ public enum Command { this.permission = permission; this.alias = command; } - + /** * @param command Command "name" (/plot [cmd]) * @param alias Command Alias @@ -116,7 +116,7 @@ public enum Command { this.alias = alias; this.permission = new CommandPermission("plots." + command); } - + /** * @param command Command "name" (/plot [cmd]) * @param alias Command Alias @@ -127,21 +127,21 @@ public enum Command { this.alias = alias; this.permission = permission; } - + /** * @return command */ public String getCommand() { return this.command; } - + /** * @return alias */ public String getAlias() { return this.alias; } - + /** * @return permission object * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java index 5bc566019..32f1901cf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -33,14 +33,14 @@ public class CommandPermission { * Permission Node */ public final String permission; - + /** * @param permission Command Permission */ public CommandPermission(final String permission) { this.permission = permission.toLowerCase(); } - + /** * @param player Does the player have the permission? * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index fb87864d3..80c96a598 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -38,11 +38,11 @@ public class Comment extends SubCommand { public Comment() { super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); - Plot plot = MainUtil.getPlot(loc); + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index eb47b126f..5312d57e1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -38,11 +38,11 @@ import com.intellectualcrafters.plot.util.MainUtil; public class Condense extends SubCommand { public static boolean TASK = false; - + public Condense() { super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { @@ -185,7 +185,7 @@ public class Condense extends SubCommand { MainUtil.sendMessage(plr, "/plot condense " + worldname + " [radius]"); return false; } - + public Set getPlots(final Collection plots, final int radius) { final HashSet outside = new HashSet<>(); for (final Plot plot : plots) { @@ -195,7 +195,7 @@ public class Condense extends SubCommand { } return outside; } - + public static void sendMessage(final String message) { PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java index 3818d7dbe..acc0b0fff 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -33,11 +33,11 @@ public class CreateRoadSchematic extends SubCommand { public CreateRoadSchematic() { super(Command.CREATEROADSCHEMATIC, "Add a road schematic to your world using the road around your current plot", "crs", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final PlotPlayer player, final String... args) { - Location loc = player.getLocation(); - Plot plot = MainUtil.getPlot(loc); + final Location loc = player.getLocation(); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return sendMessage(player, C.NOT_IN_PLOT); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 5f0300bcb..42a671435 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -24,11 +24,11 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; */ public class Database extends SubCommand { final String[] tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" }; - + public Database() { super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false); } - + private static boolean sendMessageU(final UUID uuid, final String msg) { if (uuid == null) { PlotSquared.log(msg); @@ -42,7 +42,7 @@ public class Database extends SubCommand { } return true; } - + public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) { final java.util.Set plots = PlotSquared.getPlots(); TaskManager.runTaskAsync(new Runnable() { @@ -68,7 +68,7 @@ public class Database extends SubCommand { } }); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { @@ -135,7 +135,7 @@ public class Database extends SubCommand { } return false; } - + private boolean sendMessage(final PlotPlayer player, final String msg) { if (player == null) { PlotSquared.log(msg); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index 8c9ed5e36..e14bfd1ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -31,7 +31,7 @@ public class Debug extends SubCommand { public Debug() { super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { @@ -55,9 +55,9 @@ public class Debug extends SubCommand { for (final String world : PlotSquared.getPlotWorlds()) { worlds.append(world).append(" "); } - + // FIXME not sure if we actually need any of this debug info as we should just do a timings report which is more detailed anyway - + information.append(header); information.append(getSection(section, "Lag / TPS")); information.append(getLine(line, "Ticks Per Second", Lag.getTPS())); @@ -78,11 +78,11 @@ public class Debug extends SubCommand { } return true; } - + private String getSection(final String line, final String val) { return line.replaceAll("%val%", val) + "\n"; } - + private String getLine(final String line, final String var, final Object val) { return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n"; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 387f53702..08b6b3303 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -47,16 +47,16 @@ public class DebugClaimTest extends SubCommand { public DebugClaimTest() { super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false); } - + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) { return claimPlot(player, plot, teleport, ""); } - + public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic) { // FIXME call claim event // boolean result = event result - boolean result = true; - + final boolean result = true; + if (!result) { MainUtil.createPlot(player.getUUID(), plot); MainUtil.setSign(player.getName(), plot); @@ -67,14 +67,14 @@ public class DebugClaimTest extends SubCommand { } return result; } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { if (args.length < 3) { return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}"); } - String world = args[0]; + final String world = args[0]; if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) { return !MainUtil.sendMessage(null, "&cInvalid plot world!"); } @@ -100,12 +100,12 @@ public class DebugClaimTest extends SubCommand { continue; } final Location loc = manager.getSignLoc(plotworld, plot); - ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); - boolean result = AChunkManager.manager.loadChunk(world, chunk); + final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); + final boolean result = AChunkManager.manager.loadChunk(world, chunk); if (!result) { continue; } - String[] lines = BlockManager.manager.getSign(loc); + final String[] lines = BlockManager.manager.getSign(loc); if (lines != null) { String line = lines[2]; if ((line != null) && (line.length() > 2)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index 27d416b44..1365ba7b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -27,16 +27,16 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugClear extends SubCommand { public DebugClear() { super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { @@ -63,7 +63,7 @@ public class DebugClear extends SubCommand { return false; } MainUtil.runners.put(plot, 1); - ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { + AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { MainUtil.runners.remove(plot); @@ -77,9 +77,9 @@ public class DebugClear extends SubCommand { } return true; } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); - if (plot == null || !(PlotSquared.getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) { + if ((plot == null) || !(PlotSquared.getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) { return sendMessage(plr, C.NOT_IN_PLOT); } if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { @@ -96,7 +96,7 @@ public class DebugClear extends SubCommand { return false; } MainUtil.runners.put(plot, 1); - ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { + AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { MainUtil.runners.remove(plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 66358b578..57ba394ab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -48,7 +48,7 @@ public class DebugExec extends SubCommand { public DebugExec() { super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer player, final String... args) { final List allowed_params = Arrays.asList(new String[] { "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check" }); @@ -111,8 +111,8 @@ public class DebugExec extends SubCommand { if (uuid == null) { return MainUtil.sendMessage(null, "player not found: " + args[1]); } - BukkitOfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if ((op == null) || op.getLastPlayed() == 0) { + final BukkitOfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); + if ((op == null) || (op.getLastPlayed() == 0)) { return MainUtil.sendMessage(null, "player hasn't connected before: " + args[1]); } final Timestamp stamp = new Timestamp(op.getLastPlayed()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java index d37f12a7d..bb6bbe244 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -38,7 +38,7 @@ public class DebugFixFlags extends SubCommand { public DebugFixFlags() { super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java index 3edf91893..12b79ecb3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -34,7 +34,7 @@ public class DebugLoadTest extends SubCommand { public DebugLoadTest() { super(Command.DEBUGLOADTEST, "This debug command will force the reload of all plots in the DB", "debugloadtest", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index e15ce7ce9..0c8c4ff4d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -33,16 +33,16 @@ public class DebugRoadRegen extends SubCommand { public DebugRoadRegen() { super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final PlotPlayer player, final String... args) { - Location loc = player.getLocation(); - String world = loc.getWorld(); + final Location loc = player.getLocation(); + final String world = loc.getWorld(); if (!(PlotSquared.getPlotWorld(world) instanceof HybridPlotWorld)) { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } - ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); - boolean result = HybridUtils.manager.regenerateRoad(world, chunk); + final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); + final boolean result = HybridUtils.manager.regenerateRoad(world, chunk); if (result) { MainUtil.update(loc); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java index 3391feb85..9a2af9c5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -35,7 +35,7 @@ public class DebugSaveTest extends SubCommand { public DebugSaveTest() { super(Command.DEBUGSAVETEST, "This debug command will force the recreation of all plots in the DB", "debugsavetest", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 2e5303972..68628ef36 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -36,10 +36,10 @@ public class Delete extends SubCommand { public Delete() { super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); @@ -52,7 +52,7 @@ public class Delete extends SubCommand { } assert plot != null; final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world); - if (PlotSquared.economy != null && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) { final double c = pWorld.SELL_PRICE; if (c > 0d) { EconHandler.depositPlayer(plr, c); @@ -66,7 +66,7 @@ public class Delete extends SubCommand { final boolean result = PlotSquared.removePlot(loc.getWorld(), plot.id, true); final long start = System.currentTimeMillis(); if (result) { - boolean result2 = MainUtil.clearAsPlayer(plot, true, new Runnable() { + final boolean result2 = MainUtil.clearAsPlayer(plot, true, new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 923b22deb..5153aad5a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -36,14 +36,14 @@ public class Denied extends SubCommand { public Denied() { super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { MainUtil.sendMessage(plr, C.DENIED_NEED_ARGUMENT); return true; } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 4c34cbd96..7a6f58fe2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -43,7 +43,7 @@ public class FlagCmd extends SubCommand { public FlagCmd() { super(Command.FLAG, "Manage plot flags", "f", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer player, final String... args) { /* @@ -57,7 +57,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); return false; } - Location loc = player.getLocation(); + final Location loc = player.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { MainUtil.sendMessage(player, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java index 978afa09b..0f4f72f9e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Help.java @@ -13,7 +13,7 @@ public class Help extends SubCommand { public Help() { super("help", "", "Get this help menu", "help", "he", SubCommand.CommandCategory.INFO, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 1640b2e18..32044c4e9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -35,14 +35,14 @@ public class Helpers extends SubCommand { public Helpers() { super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { MainUtil.sendMessage(plr, C.HELPER_NEED_ARGUMENT); return true; } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index e09b0e419..28c2b6a53 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -34,7 +34,7 @@ public class Home extends SubCommand { public Home() { super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT, true); } - + private Plot isAlias(final String a) { for (final Plot p : PlotSquared.getPlots()) { if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { @@ -43,7 +43,7 @@ public class Home extends SubCommand { } return null; } - + @Override public boolean execute(final PlotPlayer plr, String... args) { final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]); @@ -83,7 +83,7 @@ public class Home extends SubCommand { return true; } } - + public void teleportPlayer(final PlotPlayer player, final Plot plot) { MainUtil.teleportPlayer(player, player.getLocation(), plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 77bedefaf..144da8cbb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -40,7 +40,7 @@ public class Inbox extends SubCommand { public Inbox() { super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { boolean report = false; @@ -49,9 +49,9 @@ public class Inbox extends SubCommand { report = true; } } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); - if (plot == null && !report) { + if ((plot == null) && !report) { return !sendMessage(plr, C.NOT_IN_PLOT); } if ((plot != null) && !plot.hasOwner()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index a58797282..7e0268e0f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -47,13 +47,13 @@ public class Info extends SubCommand { public Info() { super(Command.INFO, "Display plot info", "info", CommandCategory.INFO, false); } - + @Override public boolean execute(final PlotPlayer player, String... args) { Plot plot; String world; if (player != null) { - Location loc = player.getLocation(); + final Location loc = player.getLocation(); world = loc.getWorld(); if (!PlotSquared.isPlotWorld(world)) { MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD); @@ -129,7 +129,7 @@ public class Info extends SubCommand { MainUtil.sendMessage(player, info, false); return true; } - + private String getCaption(final String string) { switch (string) { case "helpers": @@ -156,7 +156,7 @@ public class Info extends SubCommand { return null; } } - + private String format(String info, final String world, final Plot plot, final PlotPlayer player) { final PlotId id = plot.id; final PlotId id2 = MainUtil.getTopPlot(plot).id; @@ -191,7 +191,7 @@ public class Info extends SubCommand { info = info.replaceAll("%desc%", "No description set."); return info; } - + private String getPlayerList(final ArrayList l) { if ((l == null) || (l.size() < 1)) { return " none"; @@ -207,7 +207,7 @@ public class Info extends SubCommand { } return list.toString(); } - + private String getPlayerName(final UUID uuid) { if (uuid == null) { return "unknown"; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java index 785217c9c..da6f47752 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inventory.java @@ -35,7 +35,7 @@ public class Inventory extends SubCommand { public Inventory() { super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { final ArrayList cmds = new ArrayList<>(); @@ -53,7 +53,7 @@ public class Inventory extends SubCommand { ((BukkitPlayer) plr).player.openInventory(inventory); return true; } - + private ItemStack getItem(final SubCommand cmd) { final ItemStack stack = new ItemStack(Material.COMMAND); final ItemMeta meta = stack.getItemMeta(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 0e5fc4394..0540bf88e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -34,10 +34,10 @@ public class Kick extends SubCommand { public Kick() { super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); @@ -50,7 +50,7 @@ public class Kick extends SubCommand { MainUtil.sendMessage(plr, "&c/plot kick "); return false; } - PlotPlayer player = UUIDHandler.getPlayer(args[0]); + final PlotPlayer player = UUIDHandler.getPlayer(args[0]); if (player == null) { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index e0119163e..6106562e1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -46,12 +46,12 @@ public class MainCommand { addAll(Arrays.asList(_subCommands)); } }; - + public static boolean no_permission(final PlotPlayer player, final String permission) { MainUtil.sendMessage(player, C.NO_PERMISSION, permission); return false; } - + public static List getCommands(final SubCommand.CommandCategory category, final PlotPlayer player) { final List cmds = new ArrayList<>(); for (final SubCommand c : subCommands) { @@ -63,7 +63,7 @@ public class MainCommand { } return cmds; } - + public static List helpMenu(final PlotPlayer player, final SubCommand.CommandCategory category, int page) { List commands; if (category != null) { @@ -99,11 +99,11 @@ public class MainCommand { } return help; } - + private static String t(final String s) { return MainUtil.colorise('&', s); } - + public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { if (!Permissions.hasPermission(player, PlotSquared.MAIN_PERMISSION)) { return no_permission(player, PlotSquared.MAIN_PERMISSION); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 8e36e9c69..54b7df308 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -22,8 +22,6 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import net.milkbowl.vault.economy.Economy; - import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.PlotSquared; @@ -44,11 +42,11 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Merge extends SubCommand { public final static String[] values = new String[] { "north", "east", "south", "west" }; public final static String[] aliases = new String[] { "n", "e", "s", "w" }; - + public Merge() { super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true); } - + public static String direction(float yaw) { yaw = yaw / 90; final int i = Math.round(yaw); @@ -70,10 +68,10 @@ public class Merge extends SubCommand { return ""; } } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); @@ -107,7 +105,7 @@ public class Merge extends SubCommand { PlotId bot = MainUtil.getBottomPlot(plot).id; PlotId top = MainUtil.getTopPlot(plot).id; ArrayList plots; - String world = plr.getLocation().getWorld(); + final String world = plr.getLocation().getWorld(); switch (direction) { case 0: // north = -y plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); @@ -141,11 +139,10 @@ public class Merge extends SubCommand { } } final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); - if (PlotSquared.economy != null && plotWorld.USE_ECONOMY) { + if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) { double cost = plotWorld.MERGE_PRICE; cost = plots.size() * cost; if (cost > 0d) { - final Economy economy = PlotSquared.economy; if (EconHandler.getBalance(plr) < cost) { sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + ""); return false; @@ -156,7 +153,7 @@ public class Merge extends SubCommand { } //FIXME PlotMergeEvent // boolean result = event.isCancelled(); - boolean result = false; + final boolean result = false; if (result) { MainUtil.sendMessage(plr, "&cMerge has been cancelled"); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 7c1267523..b16af7d2b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -33,7 +33,7 @@ public class Move extends SubCommand { public Move() { super("debugmove", "plots.admin", "plot moving debug test", "debugmove", "move", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index ced6c571d..665574b2e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -39,10 +39,10 @@ public class MusicSubcommand extends SubCommand { public MusicSubcommand() { super("music", "plots.music", "Play music in plot", "music", "mus", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer player, final String... args) { - Location loc = player.getLocation(); + final Location loc = player.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(player, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index a9e1b0b97..b670b528c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -40,7 +40,7 @@ public class Purge extends SubCommand { public Purge() { super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false); } - + public PlotId getId(final String id) { try { final String[] split = id.split(";"); @@ -49,7 +49,7 @@ public class Purge extends SubCommand { return null; } } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { @@ -159,7 +159,7 @@ public class Purge extends SubCommand { MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } - + private boolean finishPurge(final int amount) { MainUtil.sendMessage(null, C.PURGE_SUCCESS, amount + ""); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index dfe8c9652..6073c9fae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -36,14 +36,14 @@ public class Rate extends SubCommand { public Rate() { super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { sendMessage(plr, C.RATING_NOT_VALID); return true; } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index d8d27b0d8..0556eab54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -35,7 +35,7 @@ public class RegenAllRoads extends SubCommand { public RegenAllRoads() { super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "rgar", CommandCategory.DEBUG, false); } - + @Override public boolean execute(final PlotPlayer player, final String... args) { if (player != null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index 22ef1b96c..af49dfc59 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -30,7 +30,7 @@ public class Reload extends SubCommand { public Reload() { super("reload", "plots.admin.command.reload", "Reload configurations", "", "reload", CommandCategory.INFO, false); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { try { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java index f692996b5..ee98bdd85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Schematic.java @@ -45,12 +45,12 @@ public class Schematic extends SubCommand { private boolean running = false; private Plot[] plots; private int task; - + public Schematic() { super("schematic", "plots.schematic", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false); // TODO command to fetch schematic from worldedit directory } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { @@ -75,8 +75,8 @@ public class Schematic extends SubCommand { break; } final Location loc = plr.getLocation(); - Plot plot = MainUtil.getPlot(loc); - if (plot == null) { + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { sendMessage(plr, C.NOT_IN_PLOT); break; } @@ -163,7 +163,7 @@ public class Schematic extends SubCommand { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent"); break; } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final int l1 = schematic.getSchematicDimension().getX(); final int l2 = schematic.getSchematicDimension().getZ(); final Plot plot = MainUtil.getPlot(loc); @@ -236,8 +236,7 @@ public class Schematic extends SubCommand { break; } case "export": - case "save": - { + case "save": { if (!Permissions.hasPermission(plr, "plots.schematic.save")) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); return false; @@ -249,7 +248,7 @@ public class Schematic extends SubCommand { final String world; final Plot p2; if (plr != null) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index be64e30c6..99cd56c01 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -51,15 +51,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Set extends SubCommand { public final static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "flag" }; public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" }; - + public Set() { super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true); } - + @SuppressWarnings("deprecation") @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); @@ -90,7 +90,7 @@ public class Set extends SubCommand { } if (args[0].equalsIgnoreCase("flag")) { if (args.length < 2) { - String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6"); + final String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6"); MainUtil.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } @@ -260,11 +260,11 @@ public class Set extends SubCommand { MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); return false; } - + private String getString(final String s) { return MainUtil.colorise('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); } - + private String getArgumentList(final String[] strings) { final StringBuilder builder = new StringBuilder(); for (final String s : strings) { @@ -272,7 +272,7 @@ public class Set extends SubCommand { } return builder.toString().substring(1, builder.toString().length() - 1); } - + private String getBiomeList(final String[] biomes) { final StringBuilder builder = new StringBuilder(); builder.append(MainUtil.colorise('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 41d048662..2c8449666 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -38,7 +38,7 @@ public class SetOwner extends SubCommand { public SetOwner() { super("setowner", "plots.set.owner", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true); } - + /* * private UUID getUUID(String string) { OfflinePlayer player = * Bukkit.getOfflinePlayer(string); return ((player != null) && @@ -47,10 +47,10 @@ public class SetOwner extends SubCommand { private UUID getUUID(final String string) { return UUIDHandler.getUUID(string); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || (plot.owner == null)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); @@ -66,7 +66,7 @@ public class SetOwner extends SubCommand { } final String world = loc.getWorld(); final PlotId bot = MainUtil.getBottomPlot(plot).id; - final PlotId top = MainUtil.getTopPlot( plot).id; + final PlotId top = MainUtil.getTopPlot(plot).id; final ArrayList plots = MainUtil.getPlotSelectionIds(bot, top); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index de209a6a6..d93203c31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -38,7 +38,7 @@ public class Setup extends SubCommand { public Setup() { super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { // going through setup @@ -180,5 +180,4 @@ public class Setup extends SubCommand { return false; } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index f5ca65fe3..ace7d182f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -62,7 +62,7 @@ public abstract class SubCommand { * Is this a player-online command? */ public final boolean isPlayer; - + /** * @param cmd Command /plot {cmd} <-- That! * @param permission Permission Node @@ -81,7 +81,7 @@ public abstract class SubCommand { this.category = category; this.isPlayer = isPlayer; } - + /** * @param cmd Command /plot {cmd} <-- That! * @param permission Permission Node @@ -100,7 +100,7 @@ public abstract class SubCommand { this.category = category; this.isPlayer = isPlayer; } - + /** * @param command Command /plot {cmd} <-- That! * @param description Simple description @@ -117,7 +117,7 @@ public abstract class SubCommand { this.category = category; this.isPlayer = isPlayer; } - + /** * Execute. * @@ -127,7 +127,7 @@ public abstract class SubCommand { * @return true on success, false on failure */ public abstract boolean execute(final PlotPlayer plr, final String... args); - + /** * Execute the command as console * @@ -136,7 +136,7 @@ public abstract class SubCommand { public void executeConsole(final String... args) { this.execute(null, args); } - + /** * Send a message * @@ -151,7 +151,7 @@ public abstract class SubCommand { MainUtil.sendMessage(plr, c, args); return true; } - + /** * CommandCategory * @@ -193,7 +193,7 @@ public abstract class SubCommand { * The category name (Readable) */ private final String name; - + /** * Constructor * @@ -202,7 +202,7 @@ public abstract class SubCommand { CommandCategory(final String name) { this.name = name; } - + @Override public String toString() { return this.name; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 89629f7ac..1ca9fba1e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -41,7 +41,7 @@ public class Swap extends SubCommand { public Swap() { super(Command.SWAP, "Swap two plots", "switch", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { @@ -49,7 +49,7 @@ public class Swap extends SubCommand { MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java index 4763f14d1..ba0b9a4d8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -39,7 +39,7 @@ public class TP extends SubCommand { public TP() { super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { @@ -48,8 +48,8 @@ public class TP extends SubCommand { } final String id = args[0]; PlotId plotid; - Location loc = plr.getLocation(); - String pworld = loc.getWorld(); + final Location loc = plr.getLocation(); + final String pworld = loc.getWorld(); String world = pworld; if (args.length == 2) { if (BlockManager.manager.isWorld(args[1])) { @@ -74,7 +74,7 @@ public class TP extends SubCommand { } return false; } - + private Plot isAlias(final String world, String a) { int index = 0; if (a.contains(";")) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java index b037251b4..99eb8269d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -31,10 +31,10 @@ public class Target extends SubCommand { public Target() { super(Command.TARGET, "Target a plot with your compass", "target ", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location ploc = plr.getLocation(); + final Location ploc = plr.getLocation(); if (!PlotSquared.isPlotWorld(ploc.getWorld())) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java index 0f18ea275..60e8401d8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -36,14 +36,14 @@ public class Template extends SubCommand { public Template() { super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length != 2) { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template "); return false; } - String world = args[1]; + final String world = args[1]; final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (!BlockManager.manager.isWorld(world) || (plotworld == null)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); @@ -63,7 +63,7 @@ public class Template extends SubCommand { // TODO allow world created based on these packaged files return true; } - + public void gzipIt(final String output, final String input) { final byte[] buffer = new byte[1024]; try { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java index c45033fbc..c626953bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -39,16 +39,15 @@ import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; public class Trim extends SubCommand { public static boolean TASK = false; private static int TASK_ID = 0; - + public Trim() { super("trim", "plots.admin", "Delete unmodified portions of your plotworld", "trim", "", CommandCategory.DEBUG, false); } - + public PlotId getId(final String id) { try { final String[] split = id.split(";"); @@ -57,7 +56,7 @@ public class Trim extends SubCommand { return null; } } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (plr != null) { @@ -106,7 +105,7 @@ public class Trim extends SubCommand { }); return true; } - + public static boolean getBulkRegions(final ArrayList empty, final String world, final Runnable whenDone) { if (Trim.TASK) { return false; @@ -160,12 +159,12 @@ public class Trim extends SubCommand { Trim.TASK = true; return true; } - + public static boolean getTrimRegions(final ArrayList empty, final String world, final Runnable whenDone) { if (Trim.TASK) { return false; } - final long startOld = System.currentTimeMillis(); + System.currentTimeMillis(); sendMessage("Collecting region data..."); final ArrayList plots = new ArrayList<>(); plots.addAll(PlotSquared.getPlots(world).values()); @@ -191,25 +190,25 @@ public class Trim extends SubCommand { final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); final Location pos3 = new Location(world, pos1.getX(), 64, pos2.getZ()); final Location pos4 = new Location(world, pos2.getX(), 64, pos1.getZ()); - chunks.remove(ChunkManager.getChunkChunk(pos1)); - chunks.remove(ChunkManager.getChunkChunk(pos2)); - chunks.remove(ChunkManager.getChunkChunk(pos3)); - chunks.remove(ChunkManager.getChunkChunk(pos4)); + chunks.remove(AChunkManager.getChunkChunk(pos1)); + chunks.remove(AChunkManager.getChunkChunk(pos2)); + chunks.remove(AChunkManager.getChunkChunk(pos3)); + chunks.remove(AChunkManager.getChunkChunk(pos4)); } } }, 20); Trim.TASK = true; return true; } - + public static ArrayList expired = null; - + public static void deleteChunks(final String world, final ArrayList chunks) { for (final ChunkLoc loc : chunks) { AChunkManager.manager.deleteRegionFile(world, loc); } } - + public static void sendMessage(final String message) { PlotSquared.log("&3PlotSquared -> World trim&8: &7" + message); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index ae707efdc..79378c179 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -36,14 +36,14 @@ public class Trusted extends SubCommand { public Trusted() { super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 2) { MainUtil.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; } - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index ec49c1abf..71af1cc06 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import net.milkbowl.vault.economy.Economy; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; @@ -38,10 +36,10 @@ public class Unclaim extends SubCommand { public Unclaim() { super(Command.UNCLAIM, "Unclaim a plot", "unclaim", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); @@ -54,10 +52,9 @@ public class Unclaim extends SubCommand { } assert plot != null; final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world); - if (PlotSquared.economy != null && pWorld.USE_ECONOMY) { + if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY) { final double c = pWorld.SELL_PRICE; if (c > 0d) { - final Economy economy = PlotSquared.economy; EconHandler.depositPlayer(plr, c); sendMessage(plr, C.ADDED_BALANCE, c + ""); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 097cc77a0..9654b709e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -44,10 +44,10 @@ public class Unlink extends SubCommand { public Unlink() { super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { - Location loc = plr.getLocation(); + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); @@ -66,9 +66,9 @@ public class Unlink extends SubCommand { MainUtil.sendMessage(plr, "&6Plots unlinked successfully!"); return true; } - + public static boolean unlinkPlot(final Plot plot) { - String world = plot.world; + final String world = plot.world; final PlotId pos1 = MainUtil.getBottomPlot(plot).id; final PlotId pos2 = MainUtil.getTopPlot(plot).id; final ArrayList ids = MainUtil.getPlotSelectionIds(pos1, pos2); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index 692fa7637..65c996dc3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -35,7 +35,7 @@ public class Visit extends SubCommand { public Visit() { super("visit", "plots.visit", "Visit someones plot", "visit {player} [#]", "v", CommandCategory.TELEPORT, true); } - + public List getPlots(final UUID uuid) { final List plots = new ArrayList<>(); for (final Plot p : PlotSquared.getPlots()) { @@ -45,7 +45,7 @@ public class Visit extends SubCommand { } return plots; } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index 83054b54a..89fac3f85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -30,7 +30,7 @@ public class WE_Anywhere extends SubCommand { public WE_Anywhere() { super("weanywhere", "plots.weanywhere", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true); } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (PlotSquared.worldEdit == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index 3d0f89b5b..b2135b91d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -41,7 +41,7 @@ public class list extends SubCommand { public list() { super(Command.LIST, "List all plots", "list {mine|shared|all|world|forsale}", CommandCategory.INFO, false); } - + private static String getName(final UUID id) { if (id == null) { return "none"; @@ -52,7 +52,7 @@ public class list extends SubCommand { } return name; } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { @@ -168,7 +168,7 @@ public class list extends SubCommand { return false; } } - + private String getArgumentList(final String[] strings) { final StringBuilder builder = new StringBuilder(); for (final String s : strings) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java index f65091931..f26f0b0a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -33,11 +33,11 @@ import com.intellectualcrafters.plot.util.TaskManager; public class plugin extends SubCommand { public static String downloads, version; - + public plugin() { super("plugin", "plots.use", "Show plugin information", "plugin", "version", CommandCategory.INFO, false); } - + public static void setup() { TaskManager.runTaskAsync(new Runnable() { @Override @@ -61,7 +61,7 @@ public class plugin extends SubCommand { } }, 200); } - + private static String convertToNumericString(final String str, final boolean dividers) { final StringBuilder builder = new StringBuilder(); for (final char c : str.toCharArray()) { @@ -73,7 +73,7 @@ public class plugin extends SubCommand { } return builder.toString(); } - + private static String getInfo(final String link) throws Exception { final URLConnection connection = new URL(link).openConnection(); connection.addRequestProperty("User-Agent", "Mozilla/4.0"); @@ -85,7 +85,7 @@ public class plugin extends SubCommand { reader.close(); return document; } - + @Override public boolean execute(final PlotPlayer plr, final String... args) { TaskManager.runTaskAsync(new Runnable() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index b68e8e4db..0ff5ed8b6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -469,7 +469,7 @@ public enum C { * Should the string be prefixed? */ private boolean prefix; - + /** * Constructor for custom strings. */ @@ -478,7 +478,7 @@ public enum C { * use setCustomString(); */ } - + /** * Constructor * @@ -492,7 +492,7 @@ public enum C { } this.prefix = prefix; } - + /** * Constructor * @@ -501,7 +501,7 @@ public enum C { C(final String d) { this(d, true); } - + public static void setupTranslations() { manager = new TranslationManager(); defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(), lang, "PlotSquared", manager).read(); @@ -510,7 +510,7 @@ public enum C { manager.addTranslationObject(new TranslationObject(c.toString(), c.d, "", "")); } } - + public static void saveTranslations() { try { manager.saveAll(defaultFile).saveFile(defaultFile); @@ -518,7 +518,7 @@ public enum C { e.printStackTrace(); } } - + /** * Get the default string * @@ -527,7 +527,7 @@ public enum C { public String d() { return this.d; } - + /** * Get translated if exists * @@ -549,11 +549,11 @@ public enum C { * return this.s.replace("\\n", "\n"); */ } - + public boolean usePrefix() { return this.prefix; } - + /** * @return translated and color decoded * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java index e47f641df..15cb48664 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -37,7 +37,7 @@ public class Configuration { public boolean validateValue(final String string) { return true; } - + @Override public Object parseString(final String string) { return string; @@ -48,7 +48,7 @@ public class Configuration { public boolean validateValue(final String string) { return true; } - + @Override public Object parseString(final String string) { return string.split(","); @@ -64,7 +64,7 @@ public class Configuration { return false; } } - + @Override public Object parseString(final String string) { return Integer.parseInt(string); @@ -80,7 +80,7 @@ public class Configuration { return false; } } - + @Override public Object parseString(final String string) { return Boolean.parseBoolean(string); @@ -96,7 +96,7 @@ public class Configuration { return false; } } - + @Override public Object parseString(final String string) { return Double.parseDouble(string); @@ -106,7 +106,7 @@ public class Configuration { @Override public boolean validateValue(final String string) { try { - int biome = BlockManager.manager.getBiomeFromString(string.toUpperCase()); + final int biome = BlockManager.manager.getBiomeFromString(string.toUpperCase()); if (biome == -1) { return false; } @@ -115,7 +115,7 @@ public class Configuration { return false; } } - + @Override public Object parseString(final String string) { if (validateValue(string)) { @@ -123,7 +123,7 @@ public class Configuration { } return "FOREST"; } - + @Override public Object parseObject(final Object object) { return object.toString(); @@ -145,7 +145,7 @@ public class Configuration { return false; } } - + @Override public Object parseString(final String string) { if (string.contains(":")) { @@ -155,7 +155,7 @@ public class Configuration { return new PlotBlock(Short.parseShort(string), (byte) 0); } } - + @Override public Object parseObject(final Object object) { return object; @@ -184,7 +184,7 @@ public class Configuration { return false; } } - + @Override public Object parseString(final String string) { final String[] blocks = string.split(","); @@ -223,20 +223,20 @@ public class Configuration { } return parsedvalues.toArray(new PlotBlock[parsedvalues.size()]); } - + @Override public Object parseObject(final Object object) { return object; } }; - + public static int gcd(final int a, final int b) { if (b == 0) { return a; } return gcd(b, a % b); } - + private static int gcd(final int[] a) { int result = a[0]; for (int i = 1; i < a.length; i++) { @@ -244,27 +244,27 @@ public class Configuration { } return result; } - + /** * Create your own SettingValue object to make the management of plotworld configuration easier */ public static abstract class SettingValue { private final String type; - + public SettingValue(final String type) { this.type = type; } - + public String getType() { return this.type; } - + public Object parseObject(final Object object) { return object; } - + public abstract Object parseString(final String string); - + public abstract boolean validateValue(final String string); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java index da13195e6..8f6a09b17 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java @@ -40,7 +40,7 @@ public class ConfigurationNode { private final String description; private final SettingValue type; private Object value; - + public ConfigurationNode(final String constant, final Object default_value, final String description, final SettingValue type, final boolean required) { this.constant = constant; this.default_value = default_value; @@ -48,11 +48,11 @@ public class ConfigurationNode { this.value = default_value; this.type = type; } - + public SettingValue getType() { return this.type; } - + public boolean isValid(final String string) { try { final Object result = this.type.parseString(string); @@ -61,7 +61,7 @@ public class ConfigurationNode { return false; } } - + public boolean setValue(final String string) { if (!this.type.validateValue(string)) { return false; @@ -69,7 +69,7 @@ public class ConfigurationNode { this.value = this.type.parseString(string); return true; } - + public Object getValue() { if (this.value instanceof String[]) { return Arrays.asList((String[]) this.value); @@ -84,18 +84,18 @@ public class ConfigurationNode { } return this.value; } - + public String getConstant() { return this.constant; } - + public Object getDefaultValue() { if (this.default_value instanceof Object[]) { return StringUtils.join((Object[]) this.default_value, ","); } return this.default_value; } - + public String getDescription() { return this.description; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index bc9d8e51f..60ff04f24 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -136,7 +136,7 @@ public class Settings { * Use offline mode storage */ public static boolean OFFLINE_MODE = false; - + /** * Database settings * @@ -147,9 +147,9 @@ public class Settings { * MongoDB enabled? */ public static boolean USE_MONGO = false; /* - * TODO: Implement Mongo - * @Brandon - */ + * TODO: Implement Mongo + * @Brandon + */ /** * SQLite enabled? */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index f898bd9af..53252ca88 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -45,7 +45,7 @@ public interface AbstractDB { * The UUID that will count as everyone */ public UUID everyone = UUID.fromString("1-1-3-3-7"); - + /** * Set Plot owner * @@ -53,28 +53,28 @@ public interface AbstractDB { * @param uuid The uuid of the new owner */ public void setOwner(final Plot plot, final UUID uuid); - + /** * Create all settings, and create default helpers, trusted + denied lists * * @param plots Plots for which the default table entries should be created */ public void createAllSettingsAndHelpers(final ArrayList plots); - + /** * Create a plot * * @param plots Plots that should be created */ public void createPlots(final ArrayList plots); - + /** * Create a plot * * @param plot That should be created */ public void createPlot(final Plot plot); - + /** * Create tables * @@ -83,16 +83,16 @@ public interface AbstractDB { * @throws SQLException If the database manager is unable to create the tables */ public void createTables(final String database, final boolean add_constraint) throws Exception; - + /** * Delete a plot * * @param plot Plot that should be deleted */ public void delete(final String world, final Plot plot); - + public void delete(final PlotCluster cluster); - + /** * Create plot settings * @@ -100,7 +100,7 @@ public interface AbstractDB { * @param plot Plot Object */ public void createPlotSettings(final int id, final Plot plot); - + /** * Get the table entry ID * @@ -110,7 +110,7 @@ public interface AbstractDB { * @return Integer = Plot Entry Id */ public int getId(final String world, final PlotId id2); - + /** * Get the id of a given plot cluster * @@ -121,17 +121,17 @@ public interface AbstractDB { * @return Integer = Cluster Entry Id */ public int getClusterId(final String world, final PlotClusterId id); - + /** * @return A linked hashmap containing all plots */ public LinkedHashMap> getPlots(); - + /** * @return A hashmap containing all plot clusters */ public HashMap> getClusters(); - + /** * Set the merged status for a plot * @@ -140,14 +140,14 @@ public interface AbstractDB { * @param merged boolean[] */ public void setMerged(final String world, final Plot plot, final boolean[] merged); - + /** * Swap the settings, helpers etc. of two plots * @param p1 Plot1 * @param p2 Plot2 */ public void swapPlots(final Plot p1, final Plot p2); - + /** * Set plot flags * @@ -156,7 +156,7 @@ public interface AbstractDB { * @param flags flags to set (flag[]) */ public void setFlags(final String world, final Plot plot, final Set flags); - + /** * Set cluster flags * @@ -165,12 +165,12 @@ public interface AbstractDB { * @param flags flags to set (flag[]) */ public void setFlags(final PlotCluster cluster, final Set flags); - + /** * Rename a cluster */ public void setClusterName(final PlotCluster cluster, final String name); - + /** * Set the plot alias * @@ -178,7 +178,7 @@ public interface AbstractDB { * @param alias Plot Alias */ public void setAlias(final String world, final Plot plot, final String alias); - + /** * Purgle a plot * @@ -186,14 +186,14 @@ public interface AbstractDB { * @param id Plot ID */ public void purgeIds(final String world, final Set uniqueIds); - + /** * Purge a whole world * * @param world World in which the plots should be purged */ public void purge(final String world, final Set plotIds); - + /** * Set Plot Home Position * @@ -201,71 +201,71 @@ public interface AbstractDB { * @param position Plot Home Position */ public void setPosition(final String world, final Plot plot, final String position); - + /** * * @param cluster * @param position */ public void setPosition(final PlotCluster cluster, final String position); - + /** * @param id Plot Entry ID * * @return Plot Settings */ public HashMap getSettings(final int id); - + /** * * @param id * @return */ public HashMap getClusterSettings(final int id); - + /** * @param plot Plot Object * @param uuid Player that should be removed */ public void removeHelper(final String world, final Plot plot, final UUID uuid); - + /** * @param cluster PlotCluster Object * @param uuid Player that should be removed */ public void removeHelper(final PlotCluster cluster, final UUID uuid); - + /** * @param plot Plot Object * @param uuid Player that should be removed */ public void removeTrusted(final String world, final Plot plot, final UUID uuid); - + /** * * @param cluster * @param uuid */ public void removeInvited(final PlotCluster cluster, final UUID uuid); - + /** * @param plot Plot Object * @param uuid Player that should be removed */ public void setHelper(final String world, final Plot plot, final UUID uuid); - + /** * @param cluster PlotCluster Object * @param uuid Player that should be removed */ public void setHelper(final PlotCluster cluster, final UUID uuid); - + /** * @param plot Plot Object * @param uuid Player that should be added */ public void setTrusted(final String world, final Plot plot, final UUID uuid); - + /** * * @param world @@ -273,19 +273,19 @@ public interface AbstractDB { * @param uuid */ public void setInvited(final String world, final PlotCluster cluster, final UUID uuid); - + /** * @param plot Plot Object * @param player Player that should be added */ public void removeDenied(final String world, final Plot plot, final UUID uuid); - + /** * @param plot Plot Object * @param player Player that should be added */ public void setDenied(final String world, final Plot plot, final UUID uuid); - + /** * Get Plots ratings * @@ -294,7 +294,7 @@ public interface AbstractDB { * @return Plot Ratings (pre-calculated) */ public double getRatings(final Plot plot); - + /** * Remove a plot comment * @@ -303,7 +303,7 @@ public interface AbstractDB { * @param comment Comment to remove */ public void removeComment(final String world, final Plot plot, final PlotComment comment); - + /** * Set a plot comment * @@ -312,7 +312,7 @@ public interface AbstractDB { * @param comment Comment to add */ public void setComment(final String world, final Plot plot, final PlotComment comment); - + /** * Get Plot Comments * @@ -323,12 +323,12 @@ public interface AbstractDB { * @return Plot Comments within the specified tier */ public ArrayList getComments(final String world, final Plot plot, final int tier, boolean below); - + public void createPlotAndSettings(Plot plot); - + public void createCluster(PlotCluster cluster); - + public void resizeCluster(PlotCluster current, PlotClusterId resize); - + public void movePlot(String world, PlotId originalPlot, PlotId newPlot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 9f5ae964f..7fa9b4f05 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -49,11 +49,11 @@ public class DBFunc { * Abstract Database Manager */ public static AbstractDB dbManager; - + public static void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { dbManager.movePlot(world, originalPlot, newPlot); } - + /** * Set the owner of a plot * @@ -63,7 +63,7 @@ public class DBFunc { public static void setOwner(final Plot plot, final UUID uuid) { dbManager.setOwner(plot, uuid); } - + /** * Create all settings + (helpers, denied, trusted) * @@ -72,7 +72,7 @@ public class DBFunc { public static void createAllSettingsAndHelpers(final ArrayList plots) { dbManager.createAllSettingsAndHelpers(plots); } - + /** * Create all plots * @@ -81,7 +81,7 @@ public class DBFunc { public static void createPlots(final ArrayList plots) { dbManager.createPlots(plots); } - + /** * Create a plot * @@ -90,7 +90,7 @@ public class DBFunc { public static void createPlot(final Plot plot) { dbManager.createPlot(plot); } - + /** * Create a plot * @@ -99,7 +99,7 @@ public class DBFunc { public static void createPlotAndSettings(final Plot plot) { dbManager.createPlotAndSettings(plot); } - + /** * Create tables * @@ -108,7 +108,7 @@ public class DBFunc { public static void createTables(final String database, final boolean add_constraint) throws Exception { dbManager.createTables(database, add_constraint); } - + /** * Delete a plot * @@ -117,11 +117,11 @@ public class DBFunc { public static void delete(final String world, final Plot plot) { dbManager.delete(world, plot); } - + public static void delete(final PlotCluster toDelete) { dbManager.delete(toDelete); } - + /** * Create plot settings * @@ -131,7 +131,7 @@ public class DBFunc { public static void createPlotSettings(final int id, final Plot plot) { dbManager.createPlotSettings(id, plot); } - + /** * Get a plot id * @@ -153,26 +153,26 @@ public class DBFunc { public static int getId(final String world, final PlotId id2) { return dbManager.getId(world, id2); } - + /** * @return Plots */ public static LinkedHashMap> getPlots() { return dbManager.getPlots(); } - + public static void setMerged(final String world, final Plot plot, final boolean[] merged) { dbManager.setMerged(world, plot, merged); } - + public static void setFlags(final String world, final Plot plot, final Set flags) { dbManager.setFlags(world, plot, flags); } - + public static void setFlags(final PlotCluster cluster, final Set flags) { dbManager.setFlags(cluster, flags); } - + /** * @param plot * @param alias @@ -180,15 +180,15 @@ public class DBFunc { public static void setAlias(final String world, final Plot plot, final String alias) { dbManager.setAlias(world, plot, alias); } - + public static void purgeIds(final String world, final Set uniqueIds) { dbManager.purgeIds(world, uniqueIds); } - + public static void purge(final String world, final Set plotIds) { dbManager.purge(world, plotIds); } - + /** * @param plot * @param position @@ -196,7 +196,7 @@ public class DBFunc { public static void setPosition(final String world, final Plot plot, final String position) { dbManager.setPosition(world, plot, position); } - + /** * @param id * @@ -205,7 +205,7 @@ public class DBFunc { public static HashMap getSettings(final int id) { return dbManager.getSettings(id); } - + /** * @param plot * @param comment @@ -213,7 +213,7 @@ public class DBFunc { public static void removeComment(final String world, final Plot plot, final PlotComment comment) { dbManager.removeComment(world, plot, comment); } - + /** * @param plot * @param comment @@ -221,14 +221,14 @@ public class DBFunc { public static void setComment(final String world, final Plot plot, final PlotComment comment) { dbManager.setComment(world, plot, comment); } - + /** * @param plot */ public static ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) { return dbManager.getComments(world, plot, tier, below); } - + /** * @param plot * @param player @@ -236,7 +236,7 @@ public class DBFunc { public static void removeHelper(final String world, final Plot plot, final UUID uuid) { dbManager.removeHelper(world, plot, uuid); } - + /** * @param cluster * @param player @@ -244,7 +244,7 @@ public class DBFunc { public static void removeHelper(final PlotCluster cluster, final UUID uuid) { dbManager.removeHelper(cluster, uuid); } - + /** * @param world * @param cluster @@ -253,7 +253,7 @@ public class DBFunc { public static void createCluster(final String world, final PlotCluster cluster) { dbManager.createCluster(cluster); } - + /** * @param world * @param current @@ -262,7 +262,7 @@ public class DBFunc { public static void resizeCluster(final PlotCluster current, final PlotClusterId resize) { dbManager.resizeCluster(current, resize); } - + /** * @param plot * @param player @@ -270,7 +270,7 @@ public class DBFunc { public static void removeTrusted(final String world, final Plot plot, final UUID uuid) { dbManager.removeTrusted(world, plot, uuid); } - + /** * * @param world @@ -280,7 +280,7 @@ public class DBFunc { public static void removeInvited(final PlotCluster cluster, final UUID uuid) { dbManager.removeInvited(cluster, uuid); } - + /** * @param plot * @param player @@ -288,11 +288,11 @@ public class DBFunc { public static void setHelper(final String world, final Plot plot, final UUID uuid) { dbManager.setHelper(world, plot, uuid); } - + public static void setHelper(final PlotCluster cluster, final UUID uuid) { dbManager.setHelper(cluster, uuid); } - + /** * @param plot * @param player @@ -300,11 +300,11 @@ public class DBFunc { public static void setTrusted(final String world, final Plot plot, final UUID uuid) { dbManager.setTrusted(world, plot, uuid); } - + public static void setInvited(final String world, final PlotCluster cluster, final UUID uuid) { dbManager.setInvited(world, cluster, uuid); } - + /** * @param plot * @param player @@ -312,7 +312,7 @@ public class DBFunc { public static void removeDenied(final String world, final Plot plot, final UUID uuid) { dbManager.removeDenied(world, plot, uuid); } - + /** * @param plot * @param player @@ -320,19 +320,19 @@ public class DBFunc { public static void setDenied(final String world, final Plot plot, final UUID uuid) { dbManager.setDenied(world, plot, uuid); } - + public static double getRatings(final Plot plot) { return dbManager.getRatings(plot); } - + public static HashMap> getClusters() { return dbManager.getClusters(); } - + public static void setPosition(final PlotCluster cluster, final String position) { dbManager.setPosition(cluster, position); } - + public static HashMap getClusterSettings(final int id) { return dbManager.getClusterSettings(id); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java index fba75f6b3..f473aa5d0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java @@ -37,7 +37,7 @@ public abstract class Database { * Plugin instance, use for plugin.getDataFolder() */ protected final PlotSquared plotsquared; - + /** * Creates a new Database * @@ -46,7 +46,7 @@ public abstract class Database { protected Database(final PlotSquared plotsquared) { this.plotsquared = plotsquared; } - + /** * Opens a connection with the database * @@ -56,7 +56,7 @@ public abstract class Database { * @throws ClassNotFoundException if the driver cannot be found */ public abstract Connection openConnection() throws SQLException, ClassNotFoundException; - + /** * Checks if a connection is open with the database * @@ -65,14 +65,14 @@ public abstract class Database { * @throws SQLException if the connection cannot be checked */ public abstract boolean checkConnection() throws SQLException; - + /** * Gets the connection with the database * * @return Connection with the database, null if none */ public abstract Connection getConnection(); - + /** * Closes the connection with the database * @@ -81,7 +81,7 @@ public abstract class Database { * @throws SQLException if the connection cannot be closed */ public abstract boolean closeConnection() throws SQLException; - + /** * Executes a SQL Query
If the connection is closed, it will be opened * @@ -93,7 +93,7 @@ public abstract class Database { * @throws ClassNotFoundException If the driver cannot be found; see {@link #openConnection()} */ public abstract ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException; - + /** * Executes an Update SQL Query
See {@link java.sql.Statement#executeUpdate(String)}
If the connection is * closed, it will be opened diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index 4f7856d70..53984cd46 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -41,7 +41,7 @@ public class MySQL extends Database { private final String port; private final String hostname; private Connection connection; - + /** * Creates a new MySQL instance * @@ -61,13 +61,13 @@ public class MySQL extends Database { this.password = password; this.connection = null; } - + public Connection forceConnection() throws SQLException, ClassNotFoundException { Class.forName("com.mysql.jdbc.Driver"); this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); return this.connection; } - + @Override public Connection openConnection() throws SQLException, ClassNotFoundException { if (checkConnection()) { @@ -77,17 +77,17 @@ public class MySQL extends Database { this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); return this.connection; } - + @Override public boolean checkConnection() throws SQLException { return (this.connection != null) && !this.connection.isClosed(); } - + @Override public Connection getConnection() { return this.connection; } - + @Override public boolean closeConnection() throws SQLException { if (this.connection == null) { @@ -96,7 +96,7 @@ public class MySQL extends Database { this.connection.close(); return true; } - + @Override public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { @@ -105,7 +105,7 @@ public class MySQL extends Database { final Statement statement = this.connection.createStatement(); return statement.executeQuery(query); } - + @Override public int updateSQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index 35ebaabf1..1e290decc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -60,7 +60,7 @@ public class PlotMeConverter { private void sendMessage(final String message) { PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message); } - + public void runAsync() throws Exception { // We have to make it wait a couple of seconds TaskManager.runTaskLaterAsync(new Runnable() { @@ -310,7 +310,7 @@ public class PlotMeConverter { } }, 20); } - + public String getWorld(final String world) { for (final World newworld : Bukkit.getWorlds()) { if (newworld.getName().equalsIgnoreCase(world)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index c28886d01..08470ab63 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -64,7 +64,7 @@ public class SQLManager implements AbstractDB { private final String prefix; // Private Final private Connection connection; - + /** * Constructor * @@ -99,7 +99,7 @@ public class SQLManager implements AbstractDB { }, 11000); } } - + /** * Set Plot owner * @@ -125,7 +125,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void createAllSettingsAndHelpers(final ArrayList mylist) { final int size = mylist.size(); @@ -227,7 +227,7 @@ public class SQLManager implements AbstractDB { } } } - + /** * Create a plot * @@ -287,7 +287,7 @@ public class SQLManager implements AbstractDB { } } } - + /** * Create a plot * @@ -314,7 +314,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void createPlotAndSettings(final Plot plot) { TaskManager.runTaskAsync(new Runnable() { @@ -341,7 +341,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * Create tables * @@ -383,7 +383,7 @@ public class SQLManager implements AbstractDB { stmt.clearBatch(); stmt.close(); } - + /** * Delete a plot * @@ -424,7 +424,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * Create plot settings * @@ -448,7 +448,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public int getId(final String world, final PlotId id2) { PreparedStatement stmt = null; @@ -470,7 +470,7 @@ public class SQLManager implements AbstractDB { } return Integer.MAX_VALUE; } - + /** * Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap */ @@ -700,7 +700,7 @@ public class SQLManager implements AbstractDB { } return newplots; } - + @Override public void setMerged(final String world, final Plot plot, final boolean[] merged) { plot.settings.setMerged(merged); @@ -724,7 +724,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void swapPlots(final Plot p1, final Plot p2) { TaskManager.runTaskAsync(new Runnable() { @@ -759,7 +759,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { TaskManager.runTaskAsync(new Runnable() { @@ -779,7 +779,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setFlags(final String world, final Plot plot, final Set flags) { final StringBuilder flag_string = new StringBuilder(); @@ -807,7 +807,7 @@ public class SQLManager implements AbstractDB { } }); } - + public void setFlags(final int id, final Flag[] flags) { final ArrayList newflags = new ArrayList(); for (final Flag flag : flags) { @@ -832,7 +832,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param plot * @param alias @@ -857,7 +857,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * Purge all plots with the following database IDs */ @@ -895,7 +895,7 @@ public class SQLManager implements AbstractDB { } PlotSquared.log("&6[INFO] " + "SUCCESSFULLY PURGED WORLD '" + world + "'!"); } - + @Override public void purge(final String world, final Set plots) { for (final PlotId id : plots) { @@ -922,7 +922,7 @@ public class SQLManager implements AbstractDB { PlotSquared.log("&c[ERROR] " + "FAILED TO PURGE WORLD '" + world + "'!"); } } - + /** * @param plot * @param position @@ -946,7 +946,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param id * @@ -999,7 +999,7 @@ public class SQLManager implements AbstractDB { } return h; } - + @Override public void removeComment(final String world, final Plot plot, final PlotComment comment) { TaskManager.runTaskAsync(new Runnable() { @@ -1028,7 +1028,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) { final ArrayList comments = new ArrayList(); @@ -1059,7 +1059,7 @@ public class SQLManager implements AbstractDB { } return comments; } - + @Override public void setComment(final String world, final Plot plot, final PlotComment comment) { TaskManager.runTaskAsync(new Runnable() { @@ -1080,7 +1080,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param plot * @param player @@ -1103,7 +1103,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param plot * @param player @@ -1126,7 +1126,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param plot * @param player @@ -1149,7 +1149,7 @@ public class SQLManager implements AbstractDB { } }); } - + public void setHelper(final int id, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override @@ -1167,7 +1167,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param plot * @param player @@ -1190,7 +1190,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param plot * @param player @@ -1213,7 +1213,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * @param plot * @param player @@ -1236,7 +1236,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public double getRatings(final Plot plot) { try { @@ -1256,7 +1256,7 @@ public class SQLManager implements AbstractDB { } return 0.0d; } - + @Override public void delete(final PlotCluster cluster) { ClusterManager.removeCluster(cluster); @@ -1287,7 +1287,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public int getClusterId(final String world, final PlotClusterId id) { PreparedStatement stmt = null; @@ -1311,7 +1311,7 @@ public class SQLManager implements AbstractDB { } return Integer.MAX_VALUE; } - + @Override public HashMap> getClusters() { final LinkedHashMap> newClusters = new LinkedHashMap<>(); @@ -1497,7 +1497,7 @@ public class SQLManager implements AbstractDB { } return newClusters; } - + @Override public void setFlags(final PlotCluster cluster, final Set flags) { final StringBuilder flag_string = new StringBuilder(); @@ -1525,7 +1525,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setClusterName(final PlotCluster cluster, final String name) { cluster.settings.setAlias(name); @@ -1546,7 +1546,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void removeHelper(final PlotCluster cluster, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1565,7 +1565,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setHelper(final PlotCluster cluster, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1584,7 +1584,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void createCluster(final PlotCluster cluster) { TaskManager.runTaskAsync(new Runnable() { @@ -1614,7 +1614,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void resizeCluster(final PlotCluster current, final PlotClusterId resize) { final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y); @@ -1641,7 +1641,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setPosition(final PlotCluster cluster, final String position) { TaskManager.runTaskAsync(new Runnable() { @@ -1661,7 +1661,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public HashMap getClusterSettings(final int id) { final HashMap h = new HashMap(); @@ -1709,7 +1709,7 @@ public class SQLManager implements AbstractDB { } return h; } - + @Override public void removeInvited(final PlotCluster cluster, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1728,7 +1728,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setInvited(final String world, final PlotCluster cluster, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index 4c7ddde40..6b9f66734 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -39,7 +39,7 @@ import com.intellectualcrafters.plot.PlotSquared; public class SQLite extends Database { private final String dbLocation; private Connection connection; - + /** * Creates a new SQLite instance * @@ -50,7 +50,7 @@ public class SQLite extends Database { super(plotsquared); this.dbLocation = dbLocation; } - + @Override public Connection openConnection() throws SQLException, ClassNotFoundException { if (checkConnection()) { @@ -71,17 +71,17 @@ public class SQLite extends Database { this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation); return this.connection; } - + @Override public boolean checkConnection() throws SQLException { return (this.connection != null) && !this.connection.isClosed(); } - + @Override public Connection getConnection() { return this.connection; } - + @Override public boolean closeConnection() throws SQLException { if (this.connection == null) { @@ -90,7 +90,7 @@ public class SQLite extends Database { this.connection.close(); return true; } - + @Override public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { @@ -99,7 +99,7 @@ public class SQLite extends Database { final Statement statement = this.connection.createStatement(); return statement.executeQuery(query); } - + @Override public int updateSQL(final String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java index 548d28d1a..3be47e9ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java @@ -37,7 +37,7 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { private final Plot plot; private final boolean auto; private boolean cancelled; - + /** * PlayerClaimPlotEvent: Called when a plot is claimed * @@ -49,11 +49,11 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { this.plot = plot; this.auto = auto; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -62,24 +62,24 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { public Plot getPlot() { return this.plot; } - + /** * @return true if it was an automated claim, else false */ public boolean wasAuto() { return this.auto; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java index cfb8ad5ea..d7b37386a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.object.Plot; public class PlayerEnterPlotEvent extends PlayerEvent { private static HandlerList handlers = new HandlerList(); private final Plot plot; - + /** * PlayerEnterPlotEvent: Called when a player leaves a plot * @@ -44,11 +44,11 @@ public class PlayerEnterPlotEvent extends PlayerEvent { super(player); this.plot = plot; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -57,7 +57,7 @@ public class PlayerEnterPlotEvent extends PlayerEvent { public Plot getPlot() { return this.plot; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java index 21d217f46..0a26eca47 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.object.Plot; public class PlayerLeavePlotEvent extends PlayerEvent { private static HandlerList handlers = new HandlerList(); private final Plot plot; - + /** * PlayerLeavePlotEvent: Called when a player leaves a plot * @@ -44,11 +44,11 @@ public class PlayerLeavePlotEvent extends PlayerEvent { super(player); this.plot = plot; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -57,7 +57,7 @@ public class PlayerLeavePlotEvent extends PlayerEvent { public Plot getPlot() { return this.plot; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java index 35703c2cd..97b90f61f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java @@ -38,7 +38,7 @@ public class PlayerPlotDeniedEvent extends Event { private final Player initiator; private final boolean added; private final UUID player; - + /** * PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot * @@ -53,11 +53,11 @@ public class PlayerPlotDeniedEvent extends Event { this.added = added; this.player = player; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * If a user was added * @@ -66,7 +66,7 @@ public class PlayerPlotDeniedEvent extends Event { public boolean wasAdded() { return this.added; } - + /** * The player added/removed * @@ -75,7 +75,7 @@ public class PlayerPlotDeniedEvent extends Event { public UUID getPlayer() { return this.player; } - + /** * The plot involved * @@ -84,7 +84,7 @@ public class PlayerPlotDeniedEvent extends Event { public Plot getPlot() { return this.plot; } - + /** * The player initiating the action * @@ -93,7 +93,7 @@ public class PlayerPlotDeniedEvent extends Event { public Player getInitiator() { return this.initiator; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java index e802e8123..c5b9a0909 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java @@ -38,7 +38,7 @@ public class PlayerPlotHelperEvent extends Event { private final Player initiator; private final boolean added; private final UUID player; - + /** * PlayerPlotHelperEvent: Called when a plot helper is added/removed * @@ -53,11 +53,11 @@ public class PlayerPlotHelperEvent extends Event { this.added = added; this.player = player; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * If a player was added * @@ -66,7 +66,7 @@ public class PlayerPlotHelperEvent extends Event { public boolean wasAdded() { return this.added; } - + /** * The UUID added/removed * @@ -75,7 +75,7 @@ public class PlayerPlotHelperEvent extends Event { public UUID getPlayer() { return this.player; } - + /** * The plot involved * @@ -84,7 +84,7 @@ public class PlayerPlotHelperEvent extends Event { public Plot getPlot() { return this.plot; } - + /** * The player initiating the action * @@ -93,7 +93,7 @@ public class PlayerPlotHelperEvent extends Event { public Player getInitiator() { return this.initiator; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java index 95333f704..02248ebc3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java @@ -38,7 +38,7 @@ public class PlayerPlotTrustedEvent extends Event { private final Player initiator; private final boolean added; private final UUID player; - + /** * PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed * @@ -53,11 +53,11 @@ public class PlayerPlotTrustedEvent extends Event { this.added = added; this.player = player; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * If a player was added * @@ -66,7 +66,7 @@ public class PlayerPlotTrustedEvent extends Event { public boolean wasAdded() { return this.added; } - + /** * The UUID added/removed * @@ -75,7 +75,7 @@ public class PlayerPlotTrustedEvent extends Event { public UUID getPlayer() { return this.player; } - + /** * The plot involved * @@ -84,7 +84,7 @@ public class PlayerPlotTrustedEvent extends Event { public Plot getPlot() { return this.plot; } - + /** * The player initiating the action * @@ -93,7 +93,7 @@ public class PlayerPlotTrustedEvent extends Event { public Player getInitiator() { return this.initiator; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java index 45af3054e..0ee562ab5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java @@ -39,7 +39,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl private final Location from; private final Plot plot; private boolean cancelled; - + /** * PlayerTeleportToPlotEvent: Called when a player teleports to a plot * @@ -52,16 +52,16 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl this.from = from; this.plot = plot; } - + public static HandlerList getHandlerList() { return handlers; } - + @Override public HandlerList getHandlers() { return handlers; } - + /** * Get the from location * @@ -70,7 +70,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl public Location getFrom() { return this.from; } - + /** * Get the plot involved * @@ -79,12 +79,12 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl public Plot getPlot() { return this.plot; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean cancelled) { this.cancelled = cancelled; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java index 76d55fb20..dcffe98c2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java @@ -37,7 +37,7 @@ public class PlotClearEvent extends Event implements Cancellable { private final PlotId id; private final String world; private boolean cancelled; - + /** * PlotDeleteEvent: Called when a plot is cleared * @@ -48,11 +48,11 @@ public class PlotClearEvent extends Event implements Cancellable { this.id = id; this.world = world; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the PlotId * @@ -61,7 +61,7 @@ public class PlotClearEvent extends Event implements Cancellable { public PlotId getPlotId() { return this.id; } - + /** * Get the world name * @@ -70,17 +70,17 @@ public class PlotClearEvent extends Event implements Cancellable { public String getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java index 9d6c1c067..e49ddae35 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java @@ -37,7 +37,7 @@ public class PlotDeleteEvent extends Event implements Cancellable { private final PlotId id; private final String world; private boolean cancelled; - + /** * PlotDeleteEvent: Called when a plot is deleted * @@ -48,11 +48,11 @@ public class PlotDeleteEvent extends Event implements Cancellable { this.id = id; this.world = world; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the PlotId * @@ -61,7 +61,7 @@ public class PlotDeleteEvent extends Event implements Cancellable { public PlotId getPlotId() { return this.id; } - + /** * Get the world name * @@ -70,17 +70,17 @@ public class PlotDeleteEvent extends Event implements Cancellable { public String getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java index 35035e3f5..b8c00be8b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java @@ -38,7 +38,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable { private final Plot plot; private final Flag flag; private boolean cancelled; - + /** * PlotFlagAddEvent: Called when a Flag is added to a plot * @@ -49,11 +49,11 @@ public class PlotFlagAddEvent extends Event implements Cancellable { this.plot = plot; this.flag = flag; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -62,7 +62,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable { public Plot getPlot() { return this.plot; } - + /** * Get the flag involved * @@ -71,17 +71,17 @@ public class PlotFlagAddEvent extends Event implements Cancellable { public Flag getFlag() { return this.flag; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java index 5a0e5b22e..0e813f7bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java @@ -38,7 +38,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { private final Plot plot; private final Flag flag; private boolean cancelled; - + /** * PlotFlagRemoveEvent: Called when a flag is removed from a plot * @@ -49,11 +49,11 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { this.plot = plot; this.flag = flag; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plot involved * @@ -62,7 +62,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { public Plot getPlot() { return this.plot; } - + /** * Get the flag involved * @@ -71,17 +71,17 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { public Flag getFlag() { return this.flag; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java index 61654ffbc..04ec0edbe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java @@ -39,7 +39,7 @@ public class PlotMergeEvent extends Event implements Cancellable { private boolean cancelled; private Plot plot; private World world; - + /** * PlotMergeEvent: Called when plots are merged * @@ -50,11 +50,11 @@ public class PlotMergeEvent extends Event implements Cancellable { public PlotMergeEvent(final World world, final Plot plot, final ArrayList plots) { this.plots = plots; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plots being added; * @@ -63,7 +63,7 @@ public class PlotMergeEvent extends Event implements Cancellable { public ArrayList getPlots() { return this.plots; } - + /** * Get the main plot * @@ -72,21 +72,21 @@ public class PlotMergeEvent extends Event implements Cancellable { public Plot getPlot() { return this.plot; } - + public World getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java index 8de7ab3a2..7013ced7f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java @@ -37,7 +37,7 @@ public class PlotUnlinkEvent extends Event implements Cancellable { private final ArrayList plots; private final World world; private boolean cancelled; - + /** * Called when a mega-plot is unlinked. * @@ -48,11 +48,11 @@ public class PlotUnlinkEvent extends Event implements Cancellable { this.plots = plots; this.world = world; } - + public static HandlerList getHandlerList() { return handlers; } - + /** * Get the plots involved * @@ -61,21 +61,21 @@ public class PlotUnlinkEvent extends Event implements Cancellable { public ArrayList getPlots() { return this.plots; } - + public World getWorld() { return this.world; } - + @Override public HandlerList getHandlers() { return handlers; } - + @Override public boolean isCancelled() { return this.cancelled; } - + @Override public void setCancelled(final boolean b) { this.cancelled = b; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java index e35d2ec98..f204be4ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java @@ -31,11 +31,11 @@ import org.apache.commons.lang.StringUtils; public class AbstractFlag { public final String key; public final FlagValue value; - + public AbstractFlag(final String key) { this(key, new FlagValue.StringValue()); } - + /** * AbstractFlag is a parameter used in creating a new Flag
* The key must be alphabetical characters and <= 16 characters in length @@ -55,11 +55,11 @@ public class AbstractFlag { this.value = value; } } - + public boolean isList() { return this.value instanceof FlagValue.ListValue; } - + public Object parseValueRaw(final String value) { try { return this.value.parse(value); @@ -67,15 +67,15 @@ public class AbstractFlag { return null; } } - + public String toString(final Object t) { return this.value.toString(t); } - + public String getValueDesc() { return this.value.getDescription(); } - + /** * AbstractFlag key * @@ -84,12 +84,12 @@ public class AbstractFlag { public String getKey() { return this.key; } - + @Override public String toString() { return this.key; } - + @Override public boolean equals(final Object other) { if (other == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index 9db2081bf..e5eab6261 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -25,7 +25,7 @@ import org.apache.commons.lang.StringUtils; public class Flag { private AbstractFlag key; private Object value; - + /** * Flag object used to store basic information for a Plot. Flags are a key/value pair. For a flag to be usable by a * player, you need to register it with PlotSquared. @@ -53,14 +53,14 @@ public class Flag { throw new IllegalArgumentException(key.getValueDesc()); } } - + public void setKey(final AbstractFlag key) { this.key = key; if (this.value instanceof String) { this.value = key.parseValueRaw((String) this.value); } } - + /** * Warning: Unchecked */ @@ -68,7 +68,7 @@ public class Flag { this.key = key; this.value = value; } - + /** * Get the AbstractFlag used in creating the flag * @@ -77,7 +77,7 @@ public class Flag { public AbstractFlag getAbstractFlag() { return this.key; } - + /** * Get the key for the AbstractFlag * @@ -86,7 +86,7 @@ public class Flag { public String getKey() { return this.key.getKey(); } - + /** * Get the value * @@ -95,11 +95,11 @@ public class Flag { public Object getValue() { return this.value; } - + public String getValueString() { return this.key.toString(this.value); } - + @Override public String toString() { if (this.value.equals("")) { @@ -107,7 +107,7 @@ public class Flag { } return this.key + ":" + getValueString(); } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -122,7 +122,7 @@ public class Flag { final Flag other = (Flag) obj; return (this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value)); } - + @Override public int hashCode() { return this.key.getKey().hashCode(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 1e10f15a3..828ce4227 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -48,7 +48,7 @@ public class FlagManager { // - Mob cap // - customized plot composition private final static ArrayList flags = new ArrayList<>(); - + /** * Register an AbstractFlag with PlotSquared * @@ -70,7 +70,7 @@ public class FlagManager { } return (getFlag(af.getKey()) == null) && flags.add(af); } - + public static Flag getSettingFlag(final String world, final PlotSettings settings, final String flag) { final ArrayList flags = new ArrayList<>(); if ((settings.flags != null) && (settings.flags.size() > 0)) { @@ -87,7 +87,7 @@ public class FlagManager { } return null; } - + /** * Get the value of a flag for a plot (respects flag defaults) * @param plot @@ -97,7 +97,7 @@ public class FlagManager { public static Flag getPlotFlag(final Plot plot, final String flag) { return getSettingFlag(plot.world, plot.settings, flag); } - + public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) { final Flag flag = getPlotFlag(plot, strFlag); if (flag == null) { @@ -108,7 +108,7 @@ public class FlagManager { } return false; } - + /** * Get the value of a flag for a plot (ignores flag defaults) * @param plot @@ -118,7 +118,7 @@ public class FlagManager { public static Flag getPlotFlagAbs(final Plot plot, final String flag) { return getSettingFlagAbs(plot.settings, flag); } - + public static Flag getSettingFlagAbs(final PlotSettings settings, final String flag) { if ((settings.flags == null) || (settings.flags.size() == 0)) { return null; @@ -130,7 +130,7 @@ public class FlagManager { } return null; } - + /** * Add a flag to a plot * @param plot @@ -146,7 +146,7 @@ public class FlagManager { DBFunc.setFlags(plot.world, plot, plot.settings.flags); return true; } - + public static boolean addClusterFlag(final PlotCluster cluster, final Flag flag) { //TODO plot cluster flag event final Flag hasFlag = getSettingFlag(cluster.world, cluster.settings, flag.getKey()); @@ -157,7 +157,7 @@ public class FlagManager { DBFunc.setFlags(cluster, cluster.settings.flags); return true; } - + /** * * @param plot @@ -166,7 +166,7 @@ public class FlagManager { public static Set getPlotFlags(final Plot plot) { return getSettingFlags(plot.world, plot.settings); } - + public static Set getSettingFlags(final String world, final PlotSettings settings) { final Set plotflags = settings.flags; final PlotWorld plotworld = PlotSquared.getPlotWorld(world); @@ -183,7 +183,7 @@ public class FlagManager { } return plotflags; } - + public static boolean removePlotFlag(final Plot plot, final String flag) { final Flag hasFlag = getPlotFlag(plot, flag); if (hasFlag != null) { @@ -197,7 +197,7 @@ public class FlagManager { } return false; } - + public static boolean removeClusterFlag(final PlotCluster cluster, final String flag) { final Flag hasFlag = getSettingFlag(cluster.world, cluster.settings, flag); if (hasFlag != null) { @@ -211,7 +211,7 @@ public class FlagManager { } return false; } - + public static void setPlotFlags(final Plot plot, final Set flags) { if (flags == null) { plot.settings.flags = new HashSet<>(); @@ -221,7 +221,7 @@ public class FlagManager { plot.settings.flags = flags; DBFunc.setFlags(plot.world, plot, plot.settings.flags); } - + public static void setClusterFlags(final PlotCluster cluster, final Set flags) { if (flags == null) { cluster.settings.flags = new HashSet<>(); @@ -231,7 +231,7 @@ public class FlagManager { cluster.settings.flags = flags; DBFunc.setFlags(cluster, cluster.settings.flags); } - + public static Flag[] removeFlag(final Flag[] flags, final String r) { final Flag[] f = new Flag[flags.length - 1]; int index = 0; @@ -242,7 +242,7 @@ public class FlagManager { } return f; } - + public static Set removeFlag(final Set flags, final String r) { final HashSet newflags = new HashSet<>(); for (final Flag flag : flags) { @@ -252,7 +252,7 @@ public class FlagManager { } return newflags; } - + /** * Get a list of registered AbstractFlag objects * @@ -261,7 +261,7 @@ public class FlagManager { public static List getFlags() { return flags; } - + /** * Get a list of registerd AbstragFlag objects based on player permissions * @@ -278,7 +278,7 @@ public class FlagManager { } return returnFlags; } - + /** * Get an AbstractFlag by a string Returns null if flag does not exist * @@ -294,7 +294,7 @@ public class FlagManager { } return null; } - + /** * Get an AbstractFlag by a string * @@ -311,7 +311,7 @@ public class FlagManager { } return getFlag(string); } - + /** * Remove a registered AbstractFlag * @@ -322,7 +322,7 @@ public class FlagManager { public static boolean removeFlag(final AbstractFlag flag) { return flags.remove(flag); } - + public static Flag[] parseFlags(final List flagstrings) { final Flag[] flags = new Flag[flagstrings.size()]; for (int i = 0; i < flagstrings.size(); i++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index 5166a68ea..ac7b91ed0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -13,39 +13,39 @@ import com.intellectualcrafters.plot.object.PlotBlock; */ public abstract class FlagValue { private final Class clazz; - + @SuppressWarnings("unchecked") public FlagValue() { this.clazz = (Class) getClass(); } - + public FlagValue(final Class clazz) { if (clazz == null) { throw new NullPointerException(); } this.clazz = clazz; } - + public boolean validValue(final Object value) { return (value != null) && (value.getClass() == this.clazz); } - + public String toString(final Object t) { return t.toString(); } - + public abstract T getValue(Object t); - + public abstract T parse(String t); - + public abstract String getDescription(); - + public static class BooleanValue extends FlagValue { @Override public Boolean getValue(final Object t) { return (Boolean) t; } - + @Override public Boolean parse(final String t) { try { @@ -54,19 +54,19 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a boolean (true|false)"; } } - + public static class IntegerValue extends FlagValue { @Override public Integer getValue(final Object t) { return (Integer) t; } - + @Override public Integer parse(final String t) { try { @@ -75,25 +75,25 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a whole number"; } } - + public static class IntervalValue extends FlagValue { @Override public String toString(final Object t) { final Integer[] value = ((Integer[]) t); return value[0] + " " + value[1]; } - + @Override public Integer[] getValue(final Object t) { return (Integer[]) t; } - + @Override public Integer[] parse(final String t) { int seconds; @@ -116,19 +116,19 @@ public abstract class FlagValue { } return new Integer[] { amount, seconds }; } - + @Override public String getDescription() { return "Value(s) must be numeric. /plot set flag {flag} {amount} [seconds]"; } } - + public static class UnsignedIntegerValue extends FlagValue { @Override public Integer getValue(final Object t) { return (Integer) t; } - + @Override public Integer parse(final String t) { try { @@ -141,19 +141,19 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a positive whole number (includes 0)"; } } - + public static class DoubleValue extends FlagValue { @Override public Double getValue(final Object t) { return (Double) t; } - + @Override public Double parse(final String t) { try { @@ -162,19 +162,19 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a number (negative decimals are allowed)"; } } - + public static class LongValue extends FlagValue { @Override public Long getValue(final Object t) { return (Long) t; } - + @Override public Long parse(final String t) { try { @@ -183,19 +183,19 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a whole number (large numbers allowed)"; } } - + public static class UnsignedLongValue extends FlagValue { @Override public Long getValue(final Object t) { return (Long) t; } - + @Override public Long parse(final String t) { try { @@ -208,19 +208,19 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a positive whole number (large numbers allowed)"; } } - + public static class UnsignedDoubleValue extends FlagValue { @Override public Double getValue(final Object t) { return (Double) t; } - + @Override public Double parse(final String t) { try { @@ -233,19 +233,19 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a positive number (decimals allowed)"; } } - + public static class PlotBlockValue extends FlagValue { @Override public PlotBlock getValue(final Object t) { return (PlotBlock) t; } - + @Override public PlotBlock parse(final String t) { try { @@ -266,32 +266,32 @@ public abstract class FlagValue { return null; } } - + @Override public String getDescription() { return "Flag value must be a number (negative decimals are allowed)"; } } - + public interface ListValue { public void add(Object t, String value); - + public void remove(Object t, String value); } - + public static class PlotBlockListValue extends FlagValue> implements ListValue { @SuppressWarnings("unchecked") @Override public String toString(final Object t) { return StringUtils.join((HashSet) t, ","); } - + @SuppressWarnings("unchecked") @Override public HashSet getValue(final Object t) { return (HashSet) t; } - + @Override public HashSet parse(final String t) { final HashSet list = new HashSet(); @@ -313,12 +313,12 @@ public abstract class FlagValue { } return list; } - + @Override public String getDescription() { return "Flag value must be a block list"; } - + @Override public void add(final Object t, final String value) { try { @@ -326,7 +326,7 @@ public abstract class FlagValue { } catch (final Exception e) { } } - + @Override public void remove(final Object t, final String value) { try { @@ -337,18 +337,18 @@ public abstract class FlagValue { } } } - + public static class StringValue extends FlagValue { @Override public String parse(final String s) { return s; } - + @Override public String getDescription() { return "Flag value must be alphanumeric. Some special characters are allowed."; } - + @Override public String getValue(final Object t) { return t.toString(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index fb6f190f3..dfe66821f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -37,9 +37,9 @@ public class AugmentedPopulator extends BlockPopulator { private final int bz; private final int tx; private final int tz; - - public static void removePopulator(String worldname, PlotCluster cluster) { - World world = Bukkit.getWorld(worldname); + + public static void removePopulator(final String worldname, final PlotCluster cluster) { + final World world = Bukkit.getWorld(worldname); for (final Iterator iterator = world.getPopulators().iterator(); iterator.hasNext();) { final BlockPopulator populator = iterator.next(); if (populator instanceof AugmentedPopulator) { @@ -49,7 +49,7 @@ public class AugmentedPopulator extends BlockPopulator { } } } - + public BlockWrapper get(final int X, final int Z, final int i, final int j, final short[][] r, final boolean c) { final int y = (i << 4) + (j >> 8); final int a = (j - ((y & 0xF) << 8)); @@ -61,7 +61,7 @@ public class AugmentedPopulator extends BlockPopulator { return (c && (((Z + z) < this.bz) || ((Z + z) > this.tz) || ((X + x) < this.bx) || ((X + x) > this.tx))) ? null : new BlockWrapper(x, y, z, r[i][j], (byte) 0); } } - + public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { this.cluster = cluster; this.generator = generator; @@ -91,7 +91,7 @@ public class AugmentedPopulator extends BlockPopulator { bukkitWorld.getPopulators().add(this); } } - + @Override public void populate(final World world, final Random rand, final Chunk chunk) { final int X = chunk.getX(); @@ -151,9 +151,9 @@ public class AugmentedPopulator extends BlockPopulator { }, 40 + rand.nextInt(40)); } } - + private void populateBiome(final World world, final int x, final int z) { - Biome biome = Biome.valueOf(this.plotworld.PLOT_BIOME); + final Biome biome = Biome.valueOf(this.plotworld.PLOT_BIOME); if (this.b) { for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { @@ -162,7 +162,7 @@ public class AugmentedPopulator extends BlockPopulator { } } } - + private void populateBlocks(final World world, final Random rand, final int X, final int Z, final int x, final int z, final boolean check) { final short[][] result = this.generator.generateExtBlockSections(world, rand, X, Z, null); final int length = result[0].length; @@ -190,7 +190,7 @@ public class AugmentedPopulator extends BlockPopulator { populator.populate(world, this.r, world.getChunkAt(X, Z)); } } - + public boolean isIn(final RegionWrapper plot, final int x, final int z) { return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index b788efd39..279ac4bdf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -19,10 +19,10 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class BukkitHybridUtils extends HybridUtils { - + @Override - public int checkModified(int threshhold, String worldname, int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) { - World world = BukkitUtil.getWorld(worldname); + public int checkModified(final int threshhold, final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) { + final World world = BukkitUtil.getWorld(worldname); int count = 0; for (int y = y1; y <= y2; y++) { for (int x = x1; x <= x2; x++) { @@ -47,11 +47,11 @@ public class BukkitHybridUtils extends HybridUtils { } return count; } - + @Override - public int get_ey(String worldname, int sx, int ex, int sz, int ez, int sy) { - World world = BukkitUtil.getWorld(worldname); - int maxY = world.getMaxHeight(); + public int get_ey(final String worldname, final int sx, final int ex, final int sz, final int ez, final int sy) { + final World world = BukkitUtil.getWorld(worldname); + final int maxY = world.getMaxHeight(); int ey = sy; for (int x = sx; x <= ex; x++) { for (int z = sz; z <= ez; z++) { @@ -67,10 +67,10 @@ public class BukkitHybridUtils extends HybridUtils { } return ey; } - + @Override - public void regenerateChunkChunk(String worldname, ChunkLoc loc) { - World world = BukkitUtil.getWorld(worldname); + public void regenerateChunkChunk(final String worldname, final ChunkLoc loc) { + final World world = BukkitUtil.getWorld(worldname); final int sx = loc.x << 5; final int sz = loc.z << 5; for (int x = sx; x < (sx + 32); x++) { @@ -84,22 +84,22 @@ public class BukkitHybridUtils extends HybridUtils { for (int z = sz; z < (sz + 32); z++) { final Chunk chunk = world.getChunkAt(x, z); chunks2.add(chunk); - regenerateRoad(worldname, new ChunkLoc(x,z)); + regenerateRoad(worldname, new ChunkLoc(x, z)); } } SetBlockManager.setBlockManager.update(chunks2); } - + private static boolean UPDATE = false; private int task; - + @Override public boolean scheduleRoadUpdate(final String world) { if (BukkitHybridUtils.UPDATE) { return false; } final List chunks = AChunkManager.manager.getChunkChunks(world); - final Plugin plugin = (Plugin) BukkitMain.THIS; + final Plugin plugin = BukkitMain.THIS; this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { @@ -126,5 +126,5 @@ public class BukkitHybridUtils extends HybridUtils { }, 20, 20); return true; } - + } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index f16f18df3..68f1f146a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -32,7 +32,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return false; } - + public boolean setFloor(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); @@ -42,7 +42,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { MainUtil.setCuboid(plotworld.worldname, pos1, pos2, blocks); return true; } - + public boolean setWallFilling(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; if (dpw.ROAD_WIDTH == 0) { @@ -52,8 +52,8 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1, 0, 1); int x, z; z = bottom.getZ(); - int length = top.getX() - bottom.getX(); - int size = (length) * 4 * (dpw.WALL_HEIGHT); + final int length = top.getX() - bottom.getX(); + final int size = (length) * 4 * (dpw.WALL_HEIGHT); final int[] xl = new int[size]; final int[] yl = new int[size]; final int[] zl = new int[size]; @@ -101,16 +101,16 @@ public abstract class ClassicPlotManager extends SquarePlotManager { BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, bl); return true; } - + public boolean setWall(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; if (dpw.ROAD_WIDTH == 0) { return false; } final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); - final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1,0,1); - int length = top.getX() - bottom.getX(); - int size = (length) * 4; + final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1, 0, 1); + final int length = top.getX() - bottom.getX(); + final int size = (length) * 4; final int[] xl = new int[size]; final int[] yl = new int[size]; final int[] zl = new int[size]; @@ -118,7 +118,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { int x, z; z = bottom.getZ(); int i = 0; - int y = dpw.WALL_HEIGHT + 1; + final int y = dpw.WALL_HEIGHT + 1; for (x = bottom.getX(); x <= (top.getX() - 1); x++) { xl[i] = x; zl[i] = z; @@ -153,7 +153,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, bl); return true; } - + /** * PLOT MERGING */ @@ -175,7 +175,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } - + @Override public boolean createRoadSouth(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; @@ -194,7 +194,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } - + @Override public boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; @@ -208,7 +208,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } - + @Override public boolean removeRoadEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; @@ -223,7 +223,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } - + @Override public boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; @@ -238,7 +238,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } - + @Override public boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; @@ -252,13 +252,12 @@ public abstract class ClassicPlotManager extends SquarePlotManager { MainUtil.setCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); return true; } - + /** * Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED) */ @Override public boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList plotIds) { - final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final PlotId pos1 = plotIds.get(0); final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK; if (block.id != 0) { @@ -266,7 +265,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return true; } - + @Override public boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds) { final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; @@ -278,17 +277,17 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return true; } - + @Override public boolean startPlotMerge(final PlotWorld plotworld, final ArrayList plotIds) { return true; } - + @Override public boolean startPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds) { return true; } - + @Override public boolean claimPlot(final PlotWorld plotworld, final Plot plot) { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; @@ -298,7 +297,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return true; } - + @Override public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot) { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; @@ -308,12 +307,12 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return true; } - + @Override public String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid) { return new String[] { "floor", "wall", "border" }; } - + /** * Remove sign for a plot */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java index 187505d61..d3130bf94 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java @@ -28,7 +28,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { public PlotBlock WALL_FILLING; public PlotBlock ROAD_BLOCK; public boolean PLOT_BEDROCK; - + /** * CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP *

@@ -41,7 +41,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { return new ConfigurationNode[] { new ConfigurationNode("plot.height", ClassicPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true), new ConfigurationNode("plot.size", SquarePlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true), new ConfigurationNode("plot.filling", ClassicPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.floor", ClassicPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("wall.block", ClassicPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), new ConfigurationNode("wall.block_claimed", ClassicPlotWorld.CLAIMED_WALL_BLOCK_DEFAULT, "Wall block (claimed)", Configuration.BLOCK, true), new ConfigurationNode("road.width", SquarePlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true), new ConfigurationNode("road.height", ClassicPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true), new ConfigurationNode("road.block", ClassicPlotWorld.ROAD_BLOCK_DEFAULT, "Road block", Configuration.BLOCK, true), new ConfigurationNode("wall.filling", ClassicPlotWorld.WALL_FILLING_DEFAULT, "Wall filling block", Configuration.BLOCK, true), new ConfigurationNode("wall.height", ClassicPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", Configuration.INTEGER, true), new ConfigurationNode("plot.bedrock", true, "Plot bedrock generation", Configuration.BOOLEAN, true) }; } - + /** * This method is called when a world loads. Make sure you set all your constants here. You are provided with the * configuration section for that specific world. @@ -65,7 +65,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block_claimed")); this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH); } - + public ClassicPlotWorld(final String worldname) { super(worldname); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java index cc179feb9..111eb644b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/GridPlotWorld.java @@ -4,7 +4,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; public abstract class GridPlotWorld extends PlotWorld { public short SIZE; - + public GridPlotWorld(final String worldname) { super(worldname); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 6651f5d79..3e290cff8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -83,7 +83,7 @@ public class HybridGen extends PlotGenerator { * Faster sudo-random number generator than java.util.random */ private long state = 13; - + /** * Initialize variables, and create plotworld object used in calculations */ @@ -125,7 +125,7 @@ public class HybridGen extends PlotGenerator { this.maxY = 256; } } - + /** * Return the plot manager for this type of generator, or create one For square plots you may as well use the * default plot manager which comes with PlotSquared @@ -137,7 +137,7 @@ public class HybridGen extends PlotGenerator { } return HybridGen.manager; } - + /** * Allow spawning everywhere */ @@ -145,7 +145,7 @@ public class HybridGen extends PlotGenerator { public boolean canSpawn(final World world, final int x, final int z) { return true; } - + /** * Get a new plotworld class For square plots you can use the DefaultPlotWorld class which comes with PlotSquared */ @@ -156,25 +156,25 @@ public class HybridGen extends PlotGenerator { } return this.plotworld; } - + public final long nextLong() { final long a = this.state; this.state = xorShift64(a); return a; } - + public final long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - + public final int random(final int n) { final long r = ((nextLong() >>> 32) * n) >> 32; return (int) r; } - + private void setBlock(final short[][] result, final int x, final int y, final int z, final short[] blkids) { if (blkids.length == 1) { setBlock(result, x, y, z, blkids[0]); @@ -183,7 +183,7 @@ public class HybridGen extends PlotGenerator { setBlock(result, x, y, z, blkids[i]); } } - + /** * Standard setblock method for world generation */ @@ -193,7 +193,7 @@ public class HybridGen extends PlotGenerator { } result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; } - + /** * Return the block populator */ @@ -211,7 +211,7 @@ public class HybridGen extends PlotGenerator { // populator, ore populator return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld)); } - + /** * Return the default spawn location for this world */ @@ -219,7 +219,7 @@ public class HybridGen extends PlotGenerator { public Location getFixedSpawnLocation(final World world, final Random random) { return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0); } - + /** * This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world * generator @@ -340,7 +340,7 @@ public class HybridGen extends PlotGenerator { } return this.result; } - + public boolean isIn(final RegionWrapper plot, final int x, final int z) { return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index ed69eb944..a644e658f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager { - + /** * Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid * function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index fb811d355..ad0382fb8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -42,17 +42,17 @@ public class HybridPlotWorld extends ClassicPlotWorld { public short REQUIRED_CHANGES = 0; public short PATH_WIDTH_LOWER; public short PATH_WIDTH_UPPER; - + /* * Here we are just calling the super method, nothing special */ public HybridPlotWorld(final String worldname) { super(worldname); } - + public HashMap> G_SCH; public HashMap> G_SCH_DATA; - + /** * This method is called when a world loads. Make sure you set all your constants here. You are provided with the * configuration section for that specific world. @@ -88,7 +88,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { this.ROAD_SCHEMATIC_ENABLED = false; } } - + public void setupSchematics() { this.G_SCH_DATA = new HashMap<>(); this.G_SCH = new HashMap<>(); @@ -175,7 +175,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { } this.ROAD_SCHEMATIC_ENABLED = true; } - + public static boolean isRotate(final short id) { switch (id) { case 23: @@ -292,7 +292,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { return false; } } - + public void addOverlayBlock(short x, final short y, short z, final short id, byte data, final boolean rotate) { if (z < 0) { z += this.SIZE; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index a4cd724d5..0b9b8b6d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -44,7 +44,7 @@ public class HybridPop extends BlockPopulator { private boolean doFilling = false; private boolean doFloor = false; private boolean doState = false; - + public HybridPop(final PlotWorld pw) { this.plotworld = (HybridPlotWorld) pw; // save configuration @@ -85,25 +85,25 @@ public class HybridPop extends BlockPopulator { } this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); } - + public final long nextLong() { final long a = this.state; this.state = xorShift64(a); return a; } - + public final long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - + public final int random(final int n) { final long result = ((nextLong() >>> 32) * n) >> 32; return (int) result; } - + @Override public void populate(final World w, final Random r, final Chunk c) { final int cx = c.getX(), cz = c.getZ(); @@ -116,7 +116,7 @@ public class HybridPop extends BlockPopulator { } this.X = cx << 4; this.Z = cz << 4; - final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(w.getName()); + PlotSquared.getPlotManager(w.getName()); final RegionWrapper plot = AChunkManager.CURRENT_PLOT_CLEAR; if (plot != null) { short sx = (short) ((this.X) % this.size); @@ -211,7 +211,7 @@ public class HybridPop extends BlockPopulator { } } } - + private void setBlock(final World w, final short x, final short y, final short z, final byte[] blkids) { if (blkids.length == 1) { setBlock(w, x, y, z, blkids[0]); @@ -220,12 +220,12 @@ public class HybridPop extends BlockPopulator { setBlock(w, x, y, z, blkids[i]); } } - + @SuppressWarnings("deprecation") private void setBlock(final World w, final short x, final short y, final short z, final byte val) { w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false); } - + public boolean isIn(final RegionWrapper plot, final int x, final int z) { return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index 2ba65f1c9..989558b58 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -18,9 +18,9 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class HybridUtils { - + public static HybridUtils manager; - + public boolean checkModified(final Plot plot, int requiredChanges) { final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); @@ -48,9 +48,9 @@ public abstract class HybridUtils { changes = checkModified(requiredChanges, plot.world, botx, topx, 1, hpw.PLOT_HEIGHT - 1, botz, topz, hpw.MAIN_BLOCK); return changes == -1; } - + public abstract int checkModified(final int threshhold, final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks); - + public boolean setupRoadSchematic(final Plot plot) { final String world = plot.world; final Location bot = MainUtil.getPlotBottomLoc(world, plot.id); @@ -81,14 +81,14 @@ public abstract class HybridUtils { plotworld.setupSchematics(); return true; } - - public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy); - - public abstract void regenerateChunkChunk(final String world, final ChunkLoc loc); - public abstract boolean scheduleRoadUpdate(final String world); + public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy); + + public abstract void regenerateChunkChunk(final String world, final ChunkLoc loc); - public boolean regenerateRoad(String world, final ChunkLoc chunk) { + public abstract boolean scheduleRoadUpdate(final String world); + + public boolean regenerateRoad(final String world, final ChunkLoc chunk) { final int x = chunk.x << 4; final int z = chunk.z << 4; final int ex = x + 15; @@ -97,7 +97,7 @@ public abstract class HybridUtils { if (!plotworld.ROAD_SCHEMATIC_ENABLED) { return false; } - PlotManager manager = PlotSquared.getPlotManager(world); + final PlotManager manager = PlotSquared.getPlotManager(world); final PlotId id1 = manager.getPlotId(plotworld, x, 0, z); final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez); boolean toCheck = false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java index 4ac024cac..89601effa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -20,7 +20,7 @@ public abstract class SquarePlotManager extends GridPlotManager { AChunkManager.manager.regenerateRegion(pos1, pos2, whenDone); return true; } - + @Override public Location getPlotTopLocAbs(final PlotWorld plotworld, final PlotId plotid) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); @@ -30,9 +30,9 @@ public abstract class SquarePlotManager extends GridPlotManager { final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; return new Location(plotworld.worldname, x, 256, z); } - + @Override - public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, int y, int z) { + public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, final int y, int z) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); // get plot size final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; @@ -68,9 +68,9 @@ public abstract class SquarePlotManager extends GridPlotManager { // returning the plot id (based on the number of shifts required) return new PlotId(dx + 1, dz + 1); } - + @Override - public PlotId getPlotId(final PlotWorld plotworld, int x, int y, int z) { + public PlotId getPlotId(final PlotWorld plotworld, int x, final int y, int z) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); if (plotworld == null) { return null; @@ -99,7 +99,7 @@ public abstract class SquarePlotManager extends GridPlotManager { final boolean eastWest = (rx <= pathWidthLower) || (rx > end); if (northSouth && eastWest) { // This means you are in the intersection - Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z + dpw.ROAD_WIDTH); + final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z + dpw.ROAD_WIDTH); final PlotId id = MainUtil.getPlotAbs(loc); final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id); if (plot == null) { @@ -112,7 +112,7 @@ public abstract class SquarePlotManager extends GridPlotManager { } if (northSouth) { // You are on a road running West to East (yeah, I named the var poorly) - Location loc = new Location(plotworld.worldname, x, y, z + dpw.ROAD_WIDTH); + final Location loc = new Location(plotworld.worldname, x, y, z + dpw.ROAD_WIDTH); final PlotId id = MainUtil.getPlotAbs(loc); final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id); if (plot == null) { @@ -125,7 +125,7 @@ public abstract class SquarePlotManager extends GridPlotManager { } if (eastWest) { // This is the road separating an Eastern and Western plot - Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z); + final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, y, z); final PlotId id = MainUtil.getPlotAbs(loc); final Plot plot = PlotSquared.getPlots(plotworld.worldname).get(id); if (plot == null) { @@ -143,7 +143,7 @@ public abstract class SquarePlotManager extends GridPlotManager { } return MainUtil.getBottomPlot(plot).id; } - + /** * Get the bottom plot loc (some basic math) */ @@ -156,7 +156,7 @@ public abstract class SquarePlotManager extends GridPlotManager { final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; return new Location(plotworld.worldname, x, 1, z); } - + /** * Set a plot biome */ @@ -166,10 +166,10 @@ public abstract class SquarePlotManager extends GridPlotManager { final int topX = MainUtil.getPlotTopLoc(plot.world, plot.id).getX() + 1; final int bottomZ = MainUtil.getPlotBottomLoc(plot.world, plot.id).getZ() - 1; final int topZ = MainUtil.getPlotTopLoc(plot.world, plot.id).getZ() + 1; - int size = (topX - bottomX + 1) * (topZ - bottomZ + 1); - int[] xb = new int[size]; - int[] zb = new int[size]; - int[] biomes = new int[size]; + final int size = ((topX - bottomX) + 1) * ((topZ - bottomZ) + 1); + final int[] xb = new int[size]; + final int[] zb = new int[size]; + final int[] biomes = new int[size]; int index = 0; for (int x = bottomX; x <= topX; x++) { for (int z = bottomZ; z <= topZ; z++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java index 01586954f..173183fa0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotWorld.java @@ -9,7 +9,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld { public static int ROAD_WIDTH_DEFAULT = 7; public int PLOT_WIDTH; public int ROAD_WIDTH; - + @Override public void loadConfiguration(final ConfigurationSection config) { if (!config.contains("plot.height")) { @@ -19,7 +19,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld { this.ROAD_WIDTH = config.getInt("road.width"); this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH); } - + public SquarePlotWorld(final String worldname) { super(worldname); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index abb608087..ce3278a4b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -51,28 +51,28 @@ public class ForceFieldListener implements Listener { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !BukkitPlayerFunctions.isInPlot(oPlayer) || !BukkitPlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } - UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer)); + final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer)); if (!plot.isAdded(uuid)) { players.add(oPlayer); } } return players; } - + private Player hasNearbyPermitted(final Player player, final Plot plot) { Player oPlayer; for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !BukkitPlayerFunctions.isInPlot(oPlayer) || !BukkitPlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; } - UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer)); + final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer)); if (plot.isAdded(uuid)) { return oPlayer; } } return null; } - + public Vector calculateVelocity(final Player p, final Player e) { final org.bukkit.Location playerLocation = p.getLocation(); final org.bukkit.Location oPlayerLocation = e.getLocation(); @@ -95,19 +95,19 @@ public class ForceFieldListener implements Listener { } return new Vector(x, y, z); } - + @EventHandler public void onPlotEntry(final PlayerMoveEvent event) { final Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); - Location loc = pp.getLocation(); - Plot plot = MainUtil.getPlot(loc); + final PlotPlayer pp = BukkitUtil.getPlayer(player); + final Location loc = pp.getLocation(); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return; } if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) { if (!PlotListener.booleanFlag(plot, "forcefield", false)) { - UUID uuid = pp.getUUID(); + final UUID uuid = pp.getUUID(); if (plot.isAdded(uuid)) { final Set players = getNearbyPlayers(player, plot); for (final Player oPlayer : players) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index 70649c1ae..8fb54c1dc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -23,7 +23,7 @@ public class InventoryListener implements Listener { event.setResult(Event.Result.DENY); } } - + @EventHandler public void onInventoryClick(final InventoryClickEvent event) { final Inventory inventory = event.getInventory(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index fb565466b..794384555 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -71,6 +71,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -82,7 +83,9 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.WorldInitEvent; +import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.generator.ChunkGenerator; +import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -124,7 +127,29 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi PlotSquared.loadWorld(world.getName(), null); } } - + + @EventHandler + public void worldLoad(final WorldLoadEvent event) { + UUIDHandler.cacheAll(event.getWorld().getName()); + } + + @EventHandler + public void PlayerCommand(final PlayerCommandPreprocessEvent event) { + final String message = event.getMessage(); + if (message.toLowerCase().startsWith("/plotme")) { + final Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe"); + if (plotme == null) { + final Player player = event.getPlayer(); + if (Settings.USE_PLOTME_ALIAS) { + player.performCommand(message.replace("/plotme", "plots")); + } else { + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME); + } + event.setCancelled(true); + } + } + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onChunkLoad(final ChunkLoadEvent event) { final String worldname = event.getWorld().getName(); @@ -138,14 +163,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onJoin(final PlayerJoinEvent event) { final Player player = event.getPlayer(); if (!player.hasPlayedBefore()) { player.saveData(); } - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); final String username = pp.getName(); final StringWrapper name = new StringWrapper(username); final UUID uuid = pp.getUUID(); @@ -161,7 +186,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } plotEntry(player, plot); } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void PlayerMove(final PlayerMoveEvent event) { final Location f = BukkitUtil.getLocation(event.getFrom()); @@ -190,7 +215,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi passed = false; } if (passed) { - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); MainUtil.sendMessage(pp, C.BORDER); return; } @@ -198,7 +223,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi Plot plot = getCurrentPlot(t); if (plot != null) { if (plot.denied.size() > 0) { - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot.isDenied(pp.getUUID())) { if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied"); @@ -216,7 +241,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onChat(final AsyncPlayerChatEvent event) { final Player player = event.getPlayer(); @@ -248,7 +273,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi format = ChatColor.translateAlternateColorCodes('&', format); event.setFormat(format); } - + @EventHandler(priority = EventPriority.HIGH) public static void BlockDestroy(final BlockBreakEvent event) { final Player player = event.getPlayer(); @@ -264,7 +289,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!plot.hasOwner()) { - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) { return; } @@ -272,7 +297,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (!plot.isAdded(pp.getUUID())) { final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Block block = event.getBlock(); @@ -288,7 +313,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) { return; } @@ -298,7 +323,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onBigBoom(final EntityExplodeEvent event) { final String world = event.getLocation().getWorld().getName(); @@ -324,21 +349,21 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Iterator iter = event.blockList().iterator(); while (iter.hasNext()) { - final Block b = iter.next(); + iter.next(); if (isPlotArea(loc)) { iter.remove(); } } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onWorldChanged(final PlayerChangedWorldEvent event) { - PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); + final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); ((BukkitPlayer) player).hasPerm = null; ((BukkitPlayer) player).noPerm = null; } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { final String world = event.getBlock().getWorld().getName(); @@ -356,7 +381,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = (Player) e; final Location loc = BukkitUtil.getLocation(b.getLocation()); if (!isInPlot(loc)) { - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); @@ -365,14 +390,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } } else { - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!plot.isAdded(pp.getUUID())) { if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { if (isPlotArea(loc)) { @@ -386,7 +411,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityBlockForm(final EntityBlockFormEvent e) { final String world = e.getBlock().getWorld().getName(); @@ -399,7 +424,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBS(final BlockSpreadEvent e) { final Block b = e.getBlock(); @@ -412,7 +437,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBF(final BlockFormEvent e) { final Block b = e.getBlock(); @@ -425,7 +450,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBD(final BlockDamageEvent e) { final Block b = e.getBlock(); @@ -438,7 +463,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onFade(final BlockFadeEvent e) { final Block b = e.getBlock(); @@ -451,7 +476,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onChange(final BlockFromToEvent e) { final Block b = e.getToBlock(); @@ -464,7 +489,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onGrow(final BlockGrowEvent e) { final Block b = e.getBlock(); @@ -477,12 +502,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonExtend(final BlockPistonExtendEvent e) { if (isInPlot(BukkitUtil.getLocation(e.getBlock().getLocation()))) { for (final Block block : e.getBlocks()) { - Plot plot = getCurrentPlot(BukkitUtil.getLocation(block.getLocation())); + final Plot plot = getCurrentPlot(BukkitUtil.getLocation(block.getLocation())); if (plot != null) { if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); @@ -491,7 +516,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void onBlockPistonRetract(final BlockPistonRetractEvent e) { final Block b = e.getRetractLocation().getBlock(); @@ -504,23 +529,22 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onStructureGrow(final StructureGrowEvent e) { if (!isPlotWorld(e.getWorld().getName())) { return; } final List blocks = e.getBlocks(); - boolean remove = false; for (int i = blocks.size() - 1; i >= 0; i--) { final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation()); - Plot plot = getCurrentPlot(loc); - if (plot == null || !plot.hasOwner()) { + final Plot plot = getCurrentPlot(loc); + if ((plot == null) || !plot.hasOwner()) { e.getBlocks().remove(i); } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractEvent event) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) { @@ -539,7 +563,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (isInPlot(loc)) { final Plot plot = getCurrentPlot(loc); if (!plot.hasOwner()) { - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { return; } @@ -551,7 +575,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if ((use != null) && ((HashSet) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { return; } - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (!plot.isAdded(pp.getUUID())) { if (Permissions.hasPermission(pp, "plots.admin.interact.other")) { return; @@ -562,7 +586,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(pp, "plots.admin.interact.road")) { return; } @@ -572,13 +596,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void MobSpawn(final CreatureSpawnEvent event) { if (event.getEntity() instanceof Player) { return; } - Location loc = BukkitUtil.getLocation(event.getLocation()); + final Location loc = BukkitUtil.getLocation(event.getLocation()); final String world = loc.getWorld(); if (!isPlotWorld(world)) { return; @@ -599,31 +623,27 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBlockIgnite(final BlockIgniteEvent e) { - Player player = e.getPlayer(); + final Player player = e.getPlayer(); final Block b = e.getBlock(); final Location loc; if (b != null) { loc = BukkitUtil.getLocation(b.getLocation()); - } - else { - Entity ent = e.getIgnitingEntity(); + } else { + final Entity ent = e.getIgnitingEntity(); if (ent != null) { loc = BukkitUtil.getLocation(ent); - } - else { + } else { if (player != null) { loc = BukkitUtil.getLocation(player); - } - else { + } else { return; } } } - - + final String world; if (e.getBlock() != null) { world = e.getBlock().getWorld().getName(); @@ -649,7 +669,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final Player p = e.getPlayer(); if (!isInPlot(loc)) { - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); e.setCancelled(true); @@ -658,35 +678,37 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(loc); if ((plot == null) || !plot.hasOwner()) { - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); return; } } else { - PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!plot.isAdded(pp.getUUID())) if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { - if (isPlotArea(loc)) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); - e.setCancelled(true); - return; + final PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!plot.isAdded(pp.getUUID())) { + if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { + if (isPlotArea(loc)) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); + e.setCancelled(true); + return; + } } } } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onTeleport(final PlayerTeleportEvent event) { final Location f = BukkitUtil.getLocation(event.getFrom()); final Location t = BukkitUtil.getLocation(event.getTo()); final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ()); - Player player = event.getPlayer(); + final Player player = event.getPlayer(); if (isPlotWorld(q)) { if (isInPlot(q)) { final Plot plot = getCurrentPlot(q); - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot.isDenied(pp.getUUID())) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); event.setCancelled(true); @@ -708,14 +730,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { final BlockFace bf = e.getBlockFace(); final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { - PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); + final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(loc)) { if (Permissions.hasPermission(pp, "plots.admin.build.road")) { return; @@ -749,7 +771,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGHEST) public static void onInventoryClick(final InventoryClickEvent event) { if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { @@ -757,10 +779,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - + @EventHandler public static void onLeave(final PlayerQuitEvent event) { - String name = event.getPlayer().getName(); + final String name = event.getPlayer().getName(); if (SetupUtils.setupMap.containsKey(name)) { SetupUtils.setupMap.remove(name); } @@ -776,14 +798,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketFill(final PlayerBucketFillEvent e) { final Block b = e.getBlockClicked(); final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(loc)) { if (Permissions.hasPermission(pp, "plots.admin.build.road")) { return; @@ -818,14 +840,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingPlace(final HangingPlaceEvent e) { final Block b = e.getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); if (isPlotWorld(loc)) { final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(loc)) { if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); @@ -855,14 +877,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { final Entity r = e.getRemover(); if (r instanceof Player) { final Player p = (Player) r; final Location l = BukkitUtil.getLocation(e.getEntity()); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (isPlotWorld(l)) { if (!isInPlot(l)) { if (!Permissions.hasPermission(pp, "plots.admin.destroy.road")) { @@ -894,13 +916,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); @@ -940,7 +962,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onVehicleDestroy(final VehicleDestroyEvent e) { final Location l = BukkitUtil.getLocation(e.getVehicle()); @@ -948,8 +970,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Entity d = e.getAttacker(); if (d instanceof Player) { final Player p = (Player) d; - final PlotWorld pW = PlotSquared.getPlotWorld(l.getWorld()); - PlotPlayer pp = BukkitUtil.getPlayer(p); + PlotSquared.getPlotWorld(l.getWorld()); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); @@ -982,7 +1004,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { final Location l = BukkitUtil.getLocation(e.getEntity()); @@ -1006,7 +1028,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!isInPlot(l)) { - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.pve.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.road"); e.setCancelled(true); @@ -1015,7 +1037,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { final Plot plot = getCurrentPlot(l); if ((plot == null) || !plot.hasOwner()) { - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.pve.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.unowned"); e.setCancelled(true); @@ -1028,7 +1050,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } assert plot != null; - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!plot.isAdded(pp.getUUID())) { if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { return; @@ -1054,13 +1076,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onPlayerEggThrow(final PlayerEggThrowEvent e) { final Location l = BukkitUtil.getLocation(e.getEgg().getLocation()); if (isPlotWorld(l)) { final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.road"); @@ -1087,7 +1109,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - + @EventHandler(priority = EventPriority.HIGH) public void BlockCreate(final BlockPlaceEvent event) { final Player player = event.getPlayer(); @@ -1095,7 +1117,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(world)) { return; } - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(pp, "plots.admin")) { return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index 9c52f184f..074f4be4d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -2,7 +2,6 @@ package com.intellectualcrafters.plot.listeners; import java.util.UUID; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -18,11 +17,11 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class PlayerEvents_1_8 extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public static void onInteract(final PlayerInteractAtEntityEvent e) { + public void onInteract(final PlayerInteractAtEntityEvent e) { final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { - final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); + e.getPlayer(); + final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(l)) { if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); @@ -36,7 +35,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { e.setCancelled(true); } } else { - UUID uuid = pp.getUUID(); + final UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid)) { if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { if (isPlotArea(l)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 99646b975..d82a743f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -57,7 +57,7 @@ public class PlotListener { p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); } } - + public static boolean booleanFlag(final Plot plot, final String key, final boolean defaultValue) { final Flag flag = FlagManager.getPlotFlag(plot, key); if (flag == null) { @@ -69,15 +69,15 @@ public class PlotListener { } return defaultValue; } - + public static boolean isInPlot(final String world, final int x, final int y, final int z) { return (MainUtil.getPlot(new Location(world, x, y, z)) != null); } - + public static boolean isPlotWorld(final String world) { return PlotSquared.isPlotWorld(world); } - + public static boolean isPlotArea(final Location location) { final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); if (plotworld.TYPE == 2) { @@ -85,7 +85,7 @@ public class PlotListener { } return true; } - + private static String getName(final UUID id) { if (id == null) { return "none"; @@ -96,31 +96,31 @@ public class PlotListener { } return name; } - + public static UUID getUUID(final String name) { return UUIDHandler.getUUID(name); } - + public static boolean enteredPlot(final Location l1, final Location l2) { final PlotId p1 = MainUtil.getPlotId(l1); final PlotId p2 = MainUtil.getPlotId(l2); return (p2 != null) && ((p1 == null) || !p1.equals(p2)); } - + public static boolean leftPlot(final Location l1, final Location l2) { final PlotId p1 = MainUtil.getPlotId(l1); final PlotId p2 = MainUtil.getPlotId(l2); return (p1 != null) && ((p2 == null) || !p1.equals(p2)); } - + public static boolean isPlotWorld(final Location l) { return PlotSquared.isPlotWorld(l.getWorld()); } - + public static boolean isInPlot(final Location loc) { return getCurrentPlot(loc) != null; } - + public static Plot getCurrentPlot(final Location loc) { final PlotId id = MainUtil.getPlotId(loc); if (id == null) { @@ -128,7 +128,7 @@ public class PlotListener { } return MainUtil.getPlot(loc.getWorld(), id); } - + private static WeatherType getWeatherType(String str) { str = str.toLowerCase(); if (str.equals("rain")) { @@ -137,7 +137,7 @@ public class PlotListener { return WeatherType.CLEAR; } } - + private static GameMode getGameMode(final String str) { switch (str) { case "creative": @@ -150,11 +150,11 @@ public class PlotListener { return Bukkit.getDefaultGameMode(); } } - + public static void plotEntry(final PlotPlayer player, final Plot plot) { plotEntry(((BukkitPlayer) player).player, plot); } - + public static void plotEntry(final Player player, final Plot plot) { if (plot.hasOwner()) { final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode"); @@ -191,7 +191,7 @@ public class PlotListener { } } } - + public static void plotExit(final Player player, final Plot plot) { { final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); @@ -210,7 +210,7 @@ public class PlotListener { player.resetPlayerWeather(); } } - + public static boolean getFlagValue(final String value) { return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index 1d6546d20..b3c5deeae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -66,7 +66,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlotPlusListener extends PlotListener implements Listener { private final static HashMap feedRunnable = new HashMap<>(); private final static HashMap healRunnable = new HashMap<>(); - + public static void startRunnable(final JavaPlugin plugin) { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override @@ -98,7 +98,7 @@ public class PlotPlusListener extends PlotListener implements Listener { } }, 0l, 20l); } - + @EventHandler public void onInventoryClick(final InventoryClickEvent event) { final Player player = (Player) event.getWhoClicked(); @@ -107,19 +107,19 @@ public class PlotPlusListener extends PlotListener implements Listener { } event.setCancelled(true); final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot == null) { MainUtil.sendMessage(pp, C.NOT_IN_PLOT); return; } - UUID uuid = pp.getUUID(); + final UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid)) { MainUtil.sendMessage(pp, C.NO_PLOT_PERMS); return; } final Set plotPlayers = new HashSet<>(); for (final Player p : player.getWorld().getPlayers()) { - Plot newPlot = MainUtil.getPlot(BukkitUtil.getLocation(player)); + final Plot newPlot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot.equals(newPlot)) { plotPlayers.add(p); } @@ -139,7 +139,7 @@ public class PlotPlusListener extends PlotListener implements Listener { MainUtil.sendMessage(pp, C.RECORD_PLAY.s().replaceAll("%player", player.getName()).replaceAll("%name", meta.toString())); } } - + @EventHandler(priority = EventPriority.HIGH) public void onInteract(final BlockDamageEvent event) { final Player player = event.getPlayer(); @@ -154,7 +154,7 @@ public class PlotPlusListener extends PlotListener implements Listener { event.getBlock().breakNaturally(); } } - + @EventHandler(priority = EventPriority.HIGH) public void onDamage(final EntityDamageEvent event) { if (event.getEntityType() != EntityType.PLAYER) { @@ -169,35 +169,35 @@ public class PlotPlusListener extends PlotListener implements Listener { event.setCancelled(true); } } - + @EventHandler public void onItemPickup(final PlayerPickupItemEvent event) { final Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); final Plot plot = MainUtil.getPlot(pp.getLocation()); if (plot == null) { return; } - UUID uuid = pp.getUUID(); + final UUID uuid = pp.getUUID(); if (plot.isAdded(uuid) && booleanFlag(plot, "drop-protection", false)) { event.setCancelled(true); } } - + @EventHandler public void onItemDrop(final PlayerDropItemEvent event) { final Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); final Plot plot = MainUtil.getPlot(pp.getLocation()); if (plot == null) { return; } - UUID uuid = pp.getUUID(); + final UUID uuid = pp.getUUID(); if (plot.isAdded(uuid) && booleanFlag(plot, "item-drop", false)) { event.setCancelled(true); } } - + @EventHandler public void onPlotEnter(final PlayerEnterPlotEvent event) { final Plot plot = event.getPlot(); @@ -211,7 +211,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } final Player trespasser = event.getPlayer(); - PlotPlayer pt = BukkitUtil.getPlayer(trespasser); + final PlotPlayer pt = BukkitUtil.getPlayer(trespasser); if (pp.getUUID().equals(pt.getUUID())) { return; } @@ -224,11 +224,11 @@ public class PlotPlusListener extends PlotListener implements Listener { } } } - + @EventHandler public void onPlayerQuit(final PlayerQuitEvent event) { - Player player = event.getPlayer(); - String name = player.getName(); + final Player player = event.getPlayer(); + final String name = player.getName(); if (feedRunnable.containsKey(name)) { feedRunnable.remove(name); } @@ -236,17 +236,17 @@ public class PlotPlusListener extends PlotListener implements Listener { healRunnable.remove(name); } } - + @EventHandler public void onPlotLeave(final PlayerLeavePlotEvent event) { - Player leaver = event.getPlayer(); + final Player leaver = event.getPlayer(); leaver.playEffect(leaver.getLocation(), Effect.RECORD_PLAY, 0); final Plot plot = event.getPlot(); if (FlagManager.getPlotFlag(plot, "farewell") != null) { event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString())); } - PlotPlayer pl = BukkitUtil.getPlayer(leaver); - String name = pl.getName(); + final PlotPlayer pl = BukkitUtil.getPlayer(leaver); + pl.getName(); if (feedRunnable.containsKey(leaver)) { feedRunnable.remove(leaver); } @@ -271,20 +271,20 @@ public class PlotPlusListener extends PlotListener implements Listener { } } } - + public static class Interval { public final int interval; public final int amount; public final int max; public int count = 0; - + public Interval(final int interval, final int amount, final int max) { this.interval = interval; this.amount = amount; this.max = max; } } - + /** * Record Meta Class * @@ -299,22 +299,22 @@ public class PlotPlusListener extends PlotListener implements Listener { } private final String name; private final Material material; - + public RecordMeta(final String name, final Material material) { this.name = name; this.material = material; } - + @Override public String toString() { return this.name; } - + @Override public int hashCode() { return this.name.hashCode(); } - + public Material getMaterial() { return this.material; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index 4741b631b..83bbfa0c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -65,11 +65,11 @@ public class WorldEditListener implements Listener { final List monitored = Arrays.asList(new String[] { "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "move", "stack", "naturalize", "paste", "count", "regen", "copy", "cut", "" }); public final Set blockedcmds = new HashSet<>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); - + private boolean isPlotWorld(final Location l) { return (PlotSquared.isPlotWorld(l.getWorld().getName())); } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDelete(final PlotDeleteEvent e) { final String world = e.getWorld(); @@ -90,7 +90,7 @@ public class WorldEditListener implements Listener { } PWE.setNoMask(player); } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInteract(final PlayerInteractEvent e) { final Block b = e.getClickedBlock(); @@ -106,8 +106,8 @@ public class WorldEditListener implements Listener { if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) { return; } - PlotPlayer pp = BukkitUtil.getPlayer(p); - com.intellectualcrafters.plot.object.Location loc = pp.getLocation(); + final PlotPlayer pp = BukkitUtil.getPlayer(p); + final com.intellectualcrafters.plot.object.Location loc = pp.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot != null) { if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(pp.getUUID()))) { @@ -115,11 +115,11 @@ public class WorldEditListener implements Listener { } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(final PlayerCommandPreprocessEvent e) { final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || Permissions.hasPermission(pp, "plots.worldedit.bypass")) { return; } @@ -165,12 +165,12 @@ public class WorldEditListener implements Listener { } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerJoin(final PlayerJoinEvent e) { final Player p = e.getPlayer(); final Location l = p.getLocation(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (isPlotWorld(l)) { PWE.removeMask(pp); @@ -178,13 +178,13 @@ public class WorldEditListener implements Listener { return; } if (isPlotWorld(l)) { - com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(l); + final com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(l); PWE.setMask(pp, loc, false); } else { PWE.removeMask(pp); } } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent e) { final Location t = e.getTo(); @@ -193,14 +193,14 @@ public class WorldEditListener implements Listener { } final Location f = e.getFrom(); final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (!PWE.hasMask(pp)) { return; } } - com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f); - com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); + final com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f); + final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) { final PlotId idF = MainUtil.getPlotId(locf); final PlotId idT = MainUtil.getPlotId(loct); @@ -209,11 +209,11 @@ public class WorldEditListener implements Listener { } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPortal(final PlayerPortalEvent e) { - Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final Player p = e.getPlayer(); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { return; } @@ -224,7 +224,7 @@ public class WorldEditListener implements Listener { return; } if (isPlotWorld(t)) { - com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); + final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); PWE.setMask(pp, loct, false); return; } @@ -232,18 +232,18 @@ public class WorldEditListener implements Listener { PWE.removeMask(pp); } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent e) { final Player p = e.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + final PlotPlayer pp = BukkitUtil.getPlayer(p); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (!PWE.hasMask(pp)) { return; } } final Location t = e.getTo(); - com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); + final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); final Location f = e.getFrom(); if (!PlotSquared.isPlotWorld(loct.getWorld())) { if (isPlotWorld(f)) { @@ -251,7 +251,7 @@ public class WorldEditListener implements Listener { } return; } - + PWE.setMask(pp, loct, false); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java index 1cc9b4b9e..b2bf235c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java @@ -4,13 +4,13 @@ public class BlockLoc { public int x; public int y; public int z; - + public BlockLoc(final int x, final int y, final int z) { this.x = x; this.y = y; this.z = z; } - + @Override public int hashCode() { final int prime = 31; @@ -20,7 +20,7 @@ public class BlockLoc { result = (prime * result) + this.z; return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java index b65a8adfa..216d2b351 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java @@ -52,7 +52,7 @@ public class BlockWrapper { * Block Data Value */ public final byte data; - + /** * Constructor * @@ -69,7 +69,7 @@ public class BlockWrapper { this.id = id; this.data = data; } - + /** * Alternative Constructor Uses block data, rather than typed data * @@ -83,7 +83,7 @@ public class BlockWrapper { this.id = block.getTypeId(); this.data = block.getData(); } - + /** * Get a block based on the block wrapper * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java index c09e291be..7c7db2eea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitOfflinePlayer.java @@ -5,34 +5,34 @@ import java.util.UUID; import org.bukkit.OfflinePlayer; public class BukkitOfflinePlayer implements OfflinePlotPlayer { - - public final OfflinePlayer player; + public final OfflinePlayer player; + /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. * @param player */ - public BukkitOfflinePlayer(OfflinePlayer player) { + public BukkitOfflinePlayer(final OfflinePlayer player) { this.player = player; } - + @Override public UUID getUUID() { - return player.getUniqueId(); + return this.player.getUniqueId(); } - + @Override public long getLastPlayed() { - return player.getLastPlayed(); + return this.player.getLastPlayed(); } - + @Override public boolean isOnline() { - return player.isOnline(); + return this.player.isOnline(); } - + @Override public String getName() { - return player.getName(); + return this.player.getName(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index efcf20e53..8ee274af1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -9,27 +9,27 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class BukkitPlayer implements PlotPlayer { - + public final Player player; UUID uuid; String name; public HashSet hasPerm; public HashSet noPerm; private int op = 0; - + /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. * @param player */ - public BukkitPlayer(Player player) { + public BukkitPlayer(final Player player) { this.player = player; } - + @Override public Location getLocation() { return BukkitUtil.getLocation(this.player); } - + @Override public UUID getUUID() { if (this.uuid == null) { @@ -37,35 +37,35 @@ public class BukkitPlayer implements PlotPlayer { } return this.uuid; } - + @Override - public boolean hasPermission(String perm) { - if (noPerm.contains(perm)) { + public boolean hasPermission(final String perm) { + if (this.noPerm.contains(perm)) { return false; } - if (hasPerm.contains(perm)) { + if (this.hasPerm.contains(perm)) { return true; } - boolean result = player.hasPermission(perm); + final boolean result = this.player.hasPermission(perm); if (!result) { - noPerm.add(perm); + this.noPerm.add(perm); return false; } - hasPerm.add(perm); + this.hasPerm.add(perm); return true; } - + @Override - public void sendMessage(String message) { + public void sendMessage(final String message) { this.player.sendMessage(message); } - + @Override - public void teleport(Location loc) { + public void teleport(final Location loc) { this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ())); - - } + } + @Override public boolean isOp() { if (this.op != 0) { @@ -74,7 +74,7 @@ public class BukkitPlayer implements PlotPlayer { } return true; } - boolean result = this.player.isOp(); + final boolean result = this.player.isOp(); if (!result) { this.op = 1; return false; @@ -82,24 +82,24 @@ public class BukkitPlayer implements PlotPlayer { this.op = 2; return true; } - + @Override public String getName() { if (this.name == null) { - this.name = player.getName(); + this.name = this.player.getName(); } return this.name; } - + @Override public boolean isOnline() { return this.player.isOnline(); } - - @Override - public void setCompassTarget(Location loc) { - player.setCompassTarget(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ())); - - } + @Override + public void setCompassTarget(final Location loc) { + this.player.setCompassTarget(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ())); + + } + } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java index c5282d48d..9cfbaa290 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/ChunkLoc.java @@ -3,12 +3,12 @@ package com.intellectualcrafters.plot.object; public class ChunkLoc { public int x; public int z; - + public ChunkLoc(final int x, final int z) { this.x = x; this.z = z; } - + @Override public int hashCode() { final int prime = 31; @@ -17,7 +17,7 @@ public class ChunkLoc { result = (prime * result) + this.z; return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index 61741c1bf..ff3a88197 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -25,7 +25,7 @@ public class InfoInventory implements InventoryHolder { private final Plot plot; private final Inventory inventory; private final Player player; - + /** * Constructor * @@ -36,12 +36,12 @@ public class InfoInventory implements InventoryHolder { this.player = ((BukkitPlayer) plr).player; this.inventory = Bukkit.createInventory(this, 9, "Plot: " + plot.id.toString()); } - + @Override public Inventory getInventory() { return this.inventory; } - + public String getName(final UUID uuid) { final String name = UUIDHandler.getName(this.plot.getOwner()); if (name == null) { @@ -49,9 +49,9 @@ public class InfoInventory implements InventoryHolder { } return name; } - + public InfoInventory build() { - UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(player)); + final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(this.player)); final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers"); final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players"); @@ -64,13 +64,13 @@ public class InfoInventory implements InventoryHolder { this.inventory.setItem(6, flags); return this; } - + public InfoInventory display() { this.player.closeInventory(); this.player.openInventory(this.inventory); return this; } - + private ItemStack getItem(final Material material, final String name, final String... lore) { final ItemStack stack = new ItemStack(material); final ItemMeta meta = stack.getItemMeta(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java index 0aa2d0ea0..e35cbc161 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -15,12 +15,12 @@ public class Location implements Cloneable, Comparable { private String world; private boolean built; private Object o; - + @Override public Location clone() { return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch); } - + public Location(final String world, final int x, final int y, final int z, final float yaw, final float pitch) { this.world = world; this.x = x; @@ -31,69 +31,69 @@ public class Location implements Cloneable, Comparable { this.built = false; this.o = null; } - + public Location() { this("", 0, 0, 0, 0, 0); } - + public Location(final String world, final int x, final int y, final int z) { this(world, x, y, z, 0f, 0f); } - + public int getX() { return this.x; } - + public void setX(final int x) { this.x = x; this.built = false; } - + public int getY() { return this.y; } - + public void setY(final int y) { this.y = y; this.built = false; } - + public int getZ() { return this.z; } - + public void setZ(final int z) { this.z = z; this.built = false; } - + public String getWorld() { return this.world; } - + public void setWorld(final String world) { this.world = world; this.built = false; } - + public float getYaw() { return this.yaw; } - + public void setYaw(final float yaw) { this.yaw = yaw; this.built = false; } - + public float getPitch() { return this.pitch; } - + public void setPitch(final float pitch) { this.pitch = pitch; this.built = false; } - + public Location add(final int x, final int y, final int z) { this.x += x; this.y += y; @@ -101,22 +101,22 @@ public class Location implements Cloneable, Comparable { this.built = false; return this; } - + public double getEuclideanDistanceSquared(final Location l2) { final double x = getX() - l2.getX(); final double y = getY() - l2.getY(); final double z = getZ() - l2.getZ(); return (x * x) + (y * y) + (z * z); } - + public double getEuclideanDistance(final Location l2) { return Math.sqrt(getEuclideanDistanceSquared(l2)); } - + public boolean isInSphere(final Location origin, final int radius) { return getEuclideanDistanceSquared(origin) < (radius * radius); } - + @Override public int hashCode() { int hash = 127; @@ -127,11 +127,11 @@ public class Location implements Cloneable, Comparable { hash = (int) ((hash * 31) + getPitch()); return (hash * 31) + (this.world == null ? 127 : this.world.hashCode()); } - + public boolean isInAABB(final Location min, final Location max) { return (this.x >= min.getX()) && (this.x <= max.getX()) && (this.y >= min.getY()) && (this.y <= max.getY()) && (this.z >= min.getX()) && (this.z < max.getZ()); } - + public void lookTowards(final int x, final int y) { final double l = this.x - x; final double w = this.z - this.z; @@ -143,7 +143,7 @@ public class Location implements Cloneable, Comparable { } this.built = false; } - + public Location subtract(final int x, final int y, final int z) { this.x -= x; this.y -= y; @@ -151,7 +151,7 @@ public class Location implements Cloneable, Comparable { this.built = false; return this; } - + @Override public boolean equals(final Object o) { if (o == null) { @@ -163,7 +163,7 @@ public class Location implements Cloneable, Comparable { final Location l = (Location) o; return (this.x == l.getX()) && (this.y == l.getY()) && (this.z == l.getZ()) && this.world.equals(l.getWorld()) && (this.yaw == l.getY()) && (this.pitch == l.getPitch()); } - + @Override public int compareTo(final Location o) { if (o == null) { @@ -177,12 +177,12 @@ public class Location implements Cloneable, Comparable { } return 1; } - + @Override public String toString() { return "\"plotsquaredlocation\":{" + "\"x\":" + this.x + ",\"y\":" + this.y + ",\"z\":" + this.z + ",\"yaw\":" + this.yaw + ",\"pitch\":" + this.pitch + ",\"world\":\"" + this.world + "\"}"; } - + private Object getBukkitWorld() { try { final Class clazz = Class.forName("org.bukkit.Bukkit"); @@ -191,7 +191,7 @@ public class Location implements Cloneable, Comparable { return null; } } - + public Object toBukkitLocation() { if (this.built) { return this.o; @@ -204,7 +204,7 @@ public class Location implements Cloneable, Comparable { return null; } } - + /** * Please use utility class as this is not efficient */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java index 41d3865fe..6743951f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/OfflinePlotPlayer.java @@ -9,10 +9,10 @@ import java.util.UUID; */ public interface OfflinePlotPlayer { public UUID getUUID(); - + public long getLastPlayed(); - + public boolean isOnline(); - + public String getName(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index a11eef6f0..bbe9614bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -78,7 +78,7 @@ public class Plot implements Cloneable { */ public boolean hasChanged = false; public boolean countsTowardsMax = true; - + /** * Primary constructor * @@ -100,7 +100,7 @@ public class Plot implements Cloneable { this.settings.flags = new HashSet(); this.world = world; } - + /** * Constructor for saved plots * @@ -129,7 +129,7 @@ public class Plot implements Cloneable { } this.world = world; } - + /** * Check if the plot has a set owner * @@ -138,7 +138,7 @@ public class Plot implements Cloneable { public boolean hasOwner() { return this.owner != null; } - + /** * Check if the player is either the owner or on the helpers list * @@ -149,7 +149,7 @@ public class Plot implements Cloneable { public boolean isAdded(final UUID uuid) { return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone))); } - + /** * Should the player be allowed to enter? * @@ -160,14 +160,14 @@ public class Plot implements Cloneable { public boolean isDenied(final UUID uuid) { return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); } - + /** * Get the UUID of the owner */ public UUID getOwner() { return this.owner; } - + /** * Set the owner * @@ -176,14 +176,14 @@ public class Plot implements Cloneable { public void setOwner(final UUID uuid) { this.owner = uuid; } - + /** * Get the plot ID */ public PlotId getId() { return this.id; } - + /** * Get a clone of the plot * @@ -197,7 +197,7 @@ public class Plot implements Cloneable { } return p; } - + /** * Deny someone (use DBFunc.addDenied() as well) * @@ -206,7 +206,7 @@ public class Plot implements Cloneable { public void addDenied(final UUID uuid) { this.denied.add(uuid); } - + /** * Add someone as a helper (use DBFunc as well) * @@ -215,7 +215,7 @@ public class Plot implements Cloneable { public void addHelper(final UUID uuid) { this.helpers.add(uuid); } - + /** * Add someone as a trusted user (use DBFunc as well) * @@ -224,7 +224,7 @@ public class Plot implements Cloneable { public void addTrusted(final UUID uuid) { this.trusted.add(uuid); } - + /** * Get plot display name * @@ -237,7 +237,7 @@ public class Plot implements Cloneable { } return this.world + ";" + this.getId().x + ";" + this.getId().y; } - + /** * Remove a denied player (use DBFunc as well) * @@ -246,7 +246,7 @@ public class Plot implements Cloneable { public void removeDenied(final UUID uuid) { this.denied.remove(uuid); } - + /** * Remove a helper (use DBFunc as well) * @@ -255,7 +255,7 @@ public class Plot implements Cloneable { public void removeHelper(final UUID uuid) { this.helpers.remove(uuid); } - + /** * Remove a trusted user (use DBFunc as well) * @@ -264,7 +264,7 @@ public class Plot implements Cloneable { public void removeTrusted(final UUID uuid) { this.trusted.remove(uuid); } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -279,7 +279,7 @@ public class Plot implements Cloneable { final Plot other = (Plot) obj; return ((this.id.x.equals(other.id.x)) && (this.id.y.equals(other.id.y)) && (this.world.equals(other.world))); } - + /** * Get the plot hashcode * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java index b27a3c0d4..53a6fb442 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java @@ -26,12 +26,12 @@ package com.intellectualcrafters.plot.object; public class PlotBlock { public final short id; public final byte data; - + public PlotBlock(final short id, final byte data) { this.id = id; this.data = data; } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -46,12 +46,12 @@ public class PlotBlock { final PlotBlock other = (PlotBlock) obj; return ((this.id == other.id) && ((this.data == other.data) || (this.data == -1) || (other.data == -1))); } - + @Override public int hashCode() { return this.id; } - + @Override public String toString() { if (this.data == -1) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java index 2bdef8e7c..65cd4c8ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java @@ -13,23 +13,23 @@ public class PlotCluster { public HashSet invited = new HashSet(); private PlotId pos1; private PlotId pos2; - + public PlotId getP1() { return this.pos1; } - + public PlotId getP2() { return this.pos2; } - + public void setP1(final PlotId id) { this.pos1 = id; } - + public void setP2(final PlotId id) { this.pos2 = id; } - + public PlotCluster(final String world, final PlotId pos1, final PlotId pos2, final UUID owner) { this.world = world; this.pos1 = pos1; @@ -37,24 +37,24 @@ public class PlotCluster { this.owner = owner; this.settings = new PlotSettings(null); } - + public boolean hasRights(final UUID uuid) { return (this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)); } - + public boolean hasHelperRights(final UUID uuid) { return (this.owner.equals(uuid) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)); } - + public String getName() { return this.settings.getAlias(); } - + @Override public int hashCode() { return this.pos1.hashCode(); } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -69,7 +69,7 @@ public class PlotCluster { final PlotCluster other = (PlotCluster) obj; return (this.world.equals(other.world) && this.pos1.equals(other.pos1) && this.pos2.equals(other.pos2)); } - + @Override public String toString() { return this.world + ";" + this.pos1.x + ";" + this.pos1.y + ";" + this.pos2.x + ";" + this.pos2.y; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java index ae8f4d2f1..010308d00 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotClusterId.java @@ -3,7 +3,7 @@ package com.intellectualcrafters.plot.object; public class PlotClusterId { public final PlotId pos1; public final PlotId pos2; - + public PlotClusterId(final PlotId pos1, final PlotId pos2) { this.pos1 = pos1; this.pos2 = pos2; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java index 0effd85d2..5c5409437 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java @@ -27,7 +27,7 @@ public class PlotComment { public final String comment; public final int tier; public final String senderName; - + public PlotComment(final String comment, final String senderName, final int tier) { this.comment = comment; this.tier = tier; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 752c5e2bd..912711102 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -28,8 +28,8 @@ public abstract class PlotGenerator extends ChunkGenerator { public PlotGenerator(final String world) { PlotSquared.loadWorld(world, this); } - + public abstract PlotWorld getNewPlotWorld(final String world); - + public abstract PlotManager getPlotManager(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java index 53c46c5c8..85b03f39d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java @@ -29,7 +29,7 @@ public class PlotId { * y value */ public Integer y; - + /** * PlotId class (PlotId x,y values do not correspond to Block locations) * @@ -40,7 +40,7 @@ public class PlotId { this.x = x; this.y = y; } - + /** * Get a Plot Id based on a string * @@ -62,7 +62,7 @@ public class PlotId { } return new PlotId(x, y); } - + @Override public boolean equals(final Object obj) { if (this == obj) { @@ -77,12 +77,12 @@ public class PlotId { final PlotId other = (PlotId) obj; return ((this.x.equals(other.x)) && (this.y.equals(other.y))); } - + @Override public String toString() { return this.x + ";" + this.y; } - + @Override public int hashCode() { if (this.x >= 0) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java index 5c2706b14..ec9a91002 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java @@ -3,12 +3,12 @@ package com.intellectualcrafters.plot.object; public class PlotLoc { public short x; public short z; - + public PlotLoc(final short x, final short z) { this.x = x; this.z = z; } - + @Override public int hashCode() { final int prime = 31; @@ -17,7 +17,7 @@ public class PlotLoc { result = (prime * result) + this.z; return result; } - + @Override public boolean equals(final Object obj) { if (this == obj) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 62bd5aab5..2a1c4a5e5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -28,57 +28,57 @@ public abstract class PlotManager { * plots) */ public abstract PlotId getPlotIdAbs(final PlotWorld plotworld, final int x, final int y, final int z); - + public abstract PlotId getPlotId(final PlotWorld plotworld, final int x, final int y, final int z); - + // If you have a circular plot, just return the corner if it were a square public abstract Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid); - + // the same applies here public abstract Location getPlotTopLocAbs(final PlotWorld plotworld, final PlotId plotid); - + /* * Plot clearing (return false if you do not support some method) */ public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone); - + public abstract boolean claimPlot(final PlotWorld plotworld, final Plot plot); - + public abstract boolean unclaimPlot(final PlotWorld plotworld, final Plot plot); - + public abstract Location getSignLoc(final PlotWorld plotworld, final Plot plot); - + /* * Plot set functions (return false if you do not support the specific set * method) */ public abstract String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid); - + public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks); - + public abstract boolean setBiome(final Plot plot, final int biome); - + /* * PLOT MERGING (return false if your generator does not support plot * merging) */ public abstract boolean createRoadEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean createRoadSouth(final PlotWorld plotworld, final Plot plot); - + public abstract boolean createRoadSouthEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean removeRoadEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean removeRoadSouth(final PlotWorld plotworld, final Plot plot); - + public abstract boolean removeRoadSouthEast(final PlotWorld plotworld, final Plot plot); - + public abstract boolean startPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); - + public abstract boolean startPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); - + public abstract boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList plotIds); - + public abstract boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList plotIds); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index f74f500f8..155d68c4b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -9,20 +9,20 @@ import java.util.UUID; */ public interface PlotPlayer { public Location getLocation(); - + public UUID getUUID(); - + public boolean hasPermission(final String perm); - + public void sendMessage(final String message); - - public void teleport(final Location loc); - - public boolean isOp(); - - public boolean isOnline(); - - public String getName(); + public void teleport(final Location loc); + + public boolean isOp(); + + public boolean isOnline(); + + public String getName(); + public void setCompassTarget(Location loc); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index c21fc6e3b..c0103b9cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -60,7 +60,7 @@ public class PlotSettings { * Home Position */ private BlockLoc position; - + /** * Constructor * @@ -70,7 +70,7 @@ public class PlotSettings { this.alias = ""; this.plot = plot; } - + /** * Check if the plot is merged in a direction
0 = North
1 = East
2 = South
3 = West
* @@ -81,26 +81,26 @@ public class PlotSettings { public boolean getMerged(final int direction) { return this.merged[direction]; } - + /** * Returns true if the plot is merged (i.e. if it's a mega plot) */ public boolean isMerged() { return (this.merged[0] || this.merged[1] || this.merged[2] || this.merged[3]); } - + public boolean[] getMerged() { return this.merged; } - + public void setMerged(final boolean[] merged) { this.merged = merged; } - + public void setMerged(final int direction, final boolean merged) { this.merged[direction] = merged; } - + /** * @return biome at plot loc */ @@ -108,22 +108,22 @@ public class PlotSettings { final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); return BlockManager.manager.getBiome(loc); } - + public BlockLoc getPosition() { if (this.position == null) { return new BlockLoc(0, 0, 0); } return this.position; } - + public void setPosition(final BlockLoc position) { this.position = position; } - + public String getAlias() { return this.alias; } - + /** * Set the plot alias * @@ -132,7 +132,7 @@ public class PlotSettings { public void setAlias(final String alias) { this.alias = alias; } - + public String getJoinMessage() { final Flag greeting = FlagManager.getPlotFlag(this.plot, "greeting"); if (greeting != null) { @@ -140,7 +140,7 @@ public class PlotSettings { } return ""; } - + /** * Get the "farewell" flag value * @@ -153,7 +153,7 @@ public class PlotSettings { } return ""; } - + public ArrayList getComments(final int tier) { final ArrayList c = new ArrayList<>(); if (this.comments == null) { @@ -166,23 +166,23 @@ public class PlotSettings { } return c; } - + public void setComments(final ArrayList comments) { this.comments = comments; } - + public void removeComment(final PlotComment comment) { if (this.comments.contains(comment)) { this.comments.remove(comment); } } - + public void removeComments(final ArrayList comments) { for (final PlotComment comment : comments) { removeComment(comment); } } - + public void addComment(final PlotComment comment) { if (this.comments == null) { this.comments = new ArrayList<>(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 1b3b0a3c7..20c3d9121 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -61,9 +61,7 @@ public abstract class PlotWorld { // make non static and static_default_valu + add config option public static int[] BLOCKS; static { - BLOCKS = new int[] { - 1,2,3,4,5,7,14,15,16,17,19,21,22,23,24,25,35,41,42,43,45,47,48,49,52,56,57,58,61,62,73,74,80,82,84,86,87,88,91,97,98,99,100,103,110,112,120,121,123,124,125,129,133,153,155,159,162,165,166,168,170,172,173,174,179,181 - }; + BLOCKS = new int[] { 1, 2, 3, 4, 5, 7, 14, 15, 16, 17, 19, 21, 22, 23, 24, 25, 35, 41, 42, 43, 45, 47, 48, 49, 52, 56, 57, 58, 61, 62, 73, 74, 80, 82, 84, 86, 87, 88, 91, 97, 98, 99, 100, 103, 110, 112, 120, 121, 123, 124, 125, 129, 133, 153, 155, 159, 162, 165, 166, 168, 170, 172, 173, 174, 179, 181 }; } public final String worldname; public boolean AUTO_MERGE; @@ -87,11 +85,11 @@ public abstract class PlotWorld { public boolean WORLD_BORDER; public int TYPE = 0; public int TERRAIN = 0; - + public PlotWorld(final String worldname) { this.worldname = worldname; } - + /** * When a world is created, the following method will be called for each * @@ -109,7 +107,7 @@ public abstract class PlotWorld { this.SCHEMATIC_FILE = config.getString("schematic.file"); this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim"); this.SCHEMATICS = config.getStringList("schematic.schematics"); - this.USE_ECONOMY = config.getBoolean("economy.use") && PlotSquared.economy != null; + this.USE_ECONOMY = config.getBoolean("economy.use") && (PlotSquared.economy != null); this.PLOT_PRICE = config.getDouble("economy.prices.claim"); this.MERGE_PRICE = config.getDouble("economy.prices.merge"); this.SELL_PRICE = config.getDouble("economy.prices.sell"); @@ -133,9 +131,9 @@ public abstract class PlotWorld { this.SPAWN_BREEDING = config.getBoolean("event.spawn.breeding"); loadConfiguration(config); } - + public abstract void loadConfiguration(final ConfigurationSection config); - + /** * Saving core plotworld settings * @@ -179,7 +177,7 @@ public abstract class PlotWorld { } } } - + /** * Used for the /plot setup command Return null if you do not want to support this feature * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java index 9f07ea83b..54ff17720 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java @@ -5,7 +5,7 @@ public class RegionWrapper { public final int maxX; public final int minZ; public final int maxZ; - + public RegionWrapper(final int minX, final int maxX, final int minZ, final int maxZ) { this.maxX = maxX; this.minX = minX; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java index bfea23147..cf2f92ce5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java @@ -25,7 +25,7 @@ package com.intellectualcrafters.plot.object; */ public class StringWrapper { public final String value; - + /** * Constructor * @@ -34,7 +34,7 @@ public class StringWrapper { public StringWrapper(final String value) { this.value = value; } - + /** * Check if a wrapped string equals another one * @@ -59,7 +59,7 @@ public class StringWrapper { } return other.value.toLowerCase().equals(this.value.toLowerCase()); } - + /** * Get the string value * @@ -69,7 +69,7 @@ public class StringWrapper { public String toString() { return this.value; } - + /** * Get the hash value * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java index 094c57148..cf42da852 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java @@ -51,11 +51,11 @@ public class EntityWrapper { public AgeableStats aged; public TameableStats tamed; private HorseStats horse; - + public void storeInventory(final InventoryHolder held) { this.inventory = held.getInventory().getContents().clone(); } - + private void restoreLiving(final LivingEntity entity) { if (this.lived.loot) { entity.setCanPickupItems(this.lived.loot); @@ -84,11 +84,11 @@ public class EntityWrapper { // entity.setLeashHolder(leash); } } - + private void restoreInventory(final InventoryHolder entity) { entity.getInventory().setContents(this.inventory); } - + public void storeLiving(final LivingEntity lived) { this.lived = new LivingEntityStats(); this.lived.potions = lived.getActivePotionEffects(); @@ -115,7 +115,7 @@ public class EntityWrapper { this.lived.helmet = equipment.getHelmet().clone(); } } - + private void restoreTameable(final Tameable entity) { if (this.tamed.tamed) { if (this.tamed.owner != null) { @@ -124,7 +124,7 @@ public class EntityWrapper { } } } - + private void restoreAgeable(final Ageable entity) { if (!this.aged.adult) { entity.setBaby(); @@ -134,20 +134,20 @@ public class EntityWrapper { } entity.setAge(this.aged.age); } - + public void storeAgeable(final Ageable aged) { this.aged = new AgeableStats(); this.aged.age = aged.getAge(); this.aged.locked = aged.getAgeLock(); this.aged.adult = aged.isAdult(); } - + public void storeTameable(final Tameable tamed) { this.tamed = new TameableStats(); this.tamed.owner = tamed.getOwner(); this.tamed.tamed = tamed.isTamed(); } - + @SuppressWarnings("deprecation") public EntityWrapper(final org.bukkit.entity.Entity entity, final short depth) { this.depth = depth; @@ -344,7 +344,7 @@ public class EntityWrapper { // END LIVING // } } - + @SuppressWarnings("deprecation") public Entity spawn(final World world, final int x_offset, final int z_offset) { final Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset); @@ -558,7 +558,7 @@ public class EntityWrapper { // END LIVING // } } - + private byte getOrdinal(final Object[] list, final Object value) { for (byte i = 0; i < list.length; i++) { if (list[i].equals(value)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java index dae7b8f41..3b1ad443b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java @@ -5,6 +5,6 @@ import org.bukkit.entity.Player; public abstract class AbstractTitle { public static AbstractTitle TITLE_CLASS; - + public abstract void sendTitle(Player player, String head, String sub, ChatColor head_color, ChatColor sub_color); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java index 6ea57eafb..6902460b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java @@ -37,19 +37,19 @@ public class DefaultTitleManager { private int fadeOutTime = -1; private boolean ticks = false; private static final Map, Class> CORRESPONDING_TYPES = new HashMap, Class>(); - + /** * Create a new 1.8 title * * @param title * Title - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public DefaultTitleManager(final String title) throws ClassNotFoundException { this.title = title; loadClasses(); } - + /** * Create a new 1.8 title * @@ -57,20 +57,20 @@ public class DefaultTitleManager { * Title text * @param subtitle * Subtitle text - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public DefaultTitleManager(final String title, final String subtitle) throws ClassNotFoundException { this.title = title; this.subtitle = subtitle; loadClasses(); } - + /** * Copy 1.8 title * * @param title * Title - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public DefaultTitleManager(final DefaultTitleManager title) throws ClassNotFoundException { // Copy title @@ -84,7 +84,7 @@ public class DefaultTitleManager { this.ticks = title.ticks; loadClasses(); } - + /** * Create a new 1.8 title * @@ -98,7 +98,7 @@ public class DefaultTitleManager { * Stay on screen time * @param fadeOutTime * Fade out time - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException { this.title = title; @@ -108,10 +108,10 @@ public class DefaultTitleManager { this.fadeOutTime = fadeOutTime; loadClasses(); } - + /** * Load spigot and NMS classes - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ private void loadClasses() throws ClassNotFoundException { this.packetTitle = getNMSClass("PacketPlayOutTitle"); @@ -119,7 +119,7 @@ public class DefaultTitleManager { this.chatBaseComponent = getNMSClass("IChatBaseComponent"); this.nmsChatSerializer = getNMSClass("ChatSerializer"); } - + /** * Set title text * @@ -129,7 +129,7 @@ public class DefaultTitleManager { public void setTitle(final String title) { this.title = title; } - + /** * Get title text * @@ -138,7 +138,7 @@ public class DefaultTitleManager { public String getTitle() { return this.title; } - + /** * Set subtitle text * @@ -148,7 +148,7 @@ public class DefaultTitleManager { public void setSubtitle(final String subtitle) { this.subtitle = subtitle; } - + /** * Get subtitle text * @@ -157,7 +157,7 @@ public class DefaultTitleManager { public String getSubtitle() { return this.subtitle; } - + /** * Set the title color * @@ -167,7 +167,7 @@ public class DefaultTitleManager { public void setTitleColor(final ChatColor color) { this.titleColor = color; } - + /** * Set the subtitle color * @@ -177,7 +177,7 @@ public class DefaultTitleManager { public void setSubtitleColor(final ChatColor color) { this.subtitleColor = color; } - + /** * Set title fade in time * @@ -187,7 +187,7 @@ public class DefaultTitleManager { public void setFadeInTime(final int time) { this.fadeInTime = time; } - + /** * Set title fade out time * @@ -197,7 +197,7 @@ public class DefaultTitleManager { public void setFadeOutTime(final int time) { this.fadeOutTime = time; } - + /** * Set title stay time * @@ -207,29 +207,29 @@ public class DefaultTitleManager { public void setStayTime(final int time) { this.stayTime = time; } - + /** * Set timings to ticks */ public void setTimingsToTicks() { this.ticks = true; } - + /** * Set timings to seconds */ public void setTimingsToSeconds() { this.ticks = false; } - + /** * Send the title to a player * * @param player * Player - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException */ public void send(final Player player) throws Exception { if (this.packetTitle != null) { @@ -257,17 +257,17 @@ public class DefaultTitleManager { } } } - + /** * Broadcast the title to all players - * @throws Exception + * @throws Exception */ public void broadcast() throws Exception { for (final Player p : Bukkit.getOnlinePlayers()) { send(p); } } - + /** * Clear the title * @@ -287,7 +287,7 @@ public class DefaultTitleManager { e.printStackTrace(); } } - + /** * Reset the title settings * @@ -307,11 +307,11 @@ public class DefaultTitleManager { e.printStackTrace(); } } - + private Class getPrimitiveType(final Class clazz) { return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; } - + private Class[] toPrimitiveTypeArray(final Class[] classes) { final int a = classes != null ? classes.length : 0; final Class[] types = new Class[a]; @@ -320,7 +320,7 @@ public class DefaultTitleManager { } return types; } - + private static boolean equalsTypeArray(final Class[] a, final Class[] o) { if (a.length != o.length) { return false; @@ -332,7 +332,7 @@ public class DefaultTitleManager { } return true; } - + private Object getHandle(final Object obj) { try { return getMethod("getHandle", obj.getClass()).invoke(obj); @@ -341,7 +341,7 @@ public class DefaultTitleManager { return null; } } - + private Method getMethod(final String name, final Class clazz, final Class... paramTypes) { final Class[] t = toPrimitiveTypeArray(paramTypes); for (final Method m : clazz.getMethods()) { @@ -352,20 +352,20 @@ public class DefaultTitleManager { } return null; } - + private String getVersion() { final String name = Bukkit.getServer().getClass().getPackage().getName(); final String version = name.substring(name.lastIndexOf('.') + 1) + "."; return version; } - + private Class getNMSClass(final String className) throws ClassNotFoundException { final String fullName = "net.minecraft.server." + getVersion() + className; Class clazz = null; clazz = Class.forName(fullName); return clazz; } - + private Field getField(final Class clazz, final String name) { try { final Field field = clazz.getDeclaredField(name); @@ -376,7 +376,7 @@ public class DefaultTitleManager { return null; } } - + private Method getMethod(final Class clazz, final String name, final Class... args) { for (final Method m : clazz.getMethods()) { if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) { @@ -386,7 +386,7 @@ public class DefaultTitleManager { } return null; } - + private boolean ClassListEqual(final Class[] l1, final Class[] l2) { boolean equal = true; if (l1.length != l2.length) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java index b879bf45d..f5d015b83 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java @@ -34,40 +34,40 @@ public class HackTitleManager { private int fadeOutTime = -1; private boolean ticks = false; private static final Map, Class> CORRESPONDING_TYPES = new HashMap, Class>(); - + /** * Create a new 1.8 title - * + * * @param title * Title - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public HackTitleManager(final String title) throws ClassNotFoundException { this.title = title; loadClasses(); } - + /** * Create a new 1.8 title - * + * * @param title * Title text * @param subtitle * Subtitle text - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public HackTitleManager(final String title, final String subtitle) throws ClassNotFoundException { this.title = title; this.subtitle = subtitle; loadClasses(); } - + /** * Copy 1.8 title - * + * * @param title * Title - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public HackTitleManager(final HackTitleManager title) throws ClassNotFoundException { // Copy title @@ -81,10 +81,10 @@ public class HackTitleManager { this.ticks = title.ticks; loadClasses(); } - + /** * Create a new 1.8 title - * + * * @param title * Title text * @param subtitle @@ -95,7 +95,7 @@ public class HackTitleManager { * Stay on screen time * @param fadeOutTime * Fade out time - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ public HackTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException { this.title = title; @@ -105,122 +105,122 @@ public class HackTitleManager { this.fadeOutTime = fadeOutTime; loadClasses(); } - + /** * Load spigot and NMS classes - * @throws ClassNotFoundException + * @throws ClassNotFoundException */ private void loadClasses() throws ClassNotFoundException { this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle"); this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action"); this.nmsChatSerializer = getNMSClass("ChatSerializer"); } - + /** * Set title text - * + * * @param title * Title */ public void setTitle(final String title) { this.title = title; } - + /** * Get title text - * + * * @return Title text */ public String getTitle() { return this.title; } - + /** * Set subtitle text - * + * * @param subtitle * Subtitle text */ public void setSubtitle(final String subtitle) { this.subtitle = subtitle; } - + /** * Get subtitle text - * + * * @return Subtitle text */ public String getSubtitle() { return this.subtitle; } - + /** * Set the title color - * + * * @param color * Chat color */ public void setTitleColor(final ChatColor color) { this.titleColor = color; } - + /** * Set the subtitle color - * + * * @param color * Chat color */ public void setSubtitleColor(final ChatColor color) { this.subtitleColor = color; } - + /** * Set title fade in time - * + * * @param time * Time */ public void setFadeInTime(final int time) { this.fadeInTime = time; } - + /** * Set title fade out time - * + * * @param time * Time */ public void setFadeOutTime(final int time) { this.fadeOutTime = time; } - + /** * Set title stay time - * + * * @param time * Time */ public void setStayTime(final int time) { this.stayTime = time; } - + /** * Set timings to ticks */ public void setTimingsToTicks() { this.ticks = true; } - + /** * Set timings to seconds */ public void setTimingsToSeconds() { this.ticks = false; } - + /** * Send the title to a player - * + * * @param player * Player */ @@ -250,7 +250,7 @@ public class HackTitleManager { } } } - + /** * Broadcast the title to all players */ @@ -259,10 +259,10 @@ public class HackTitleManager { send(p); } } - + /** * Clear the title - * + * * @param player * Player */ @@ -281,10 +281,10 @@ public class HackTitleManager { } } } - + /** * Reset the title settings - * + * * @param player * Player */ @@ -303,10 +303,10 @@ public class HackTitleManager { } } } - + /** * Get the protocol version of the player - * + * * @param player * Player * @return Protocol version @@ -324,19 +324,19 @@ public class HackTitleManager { } return version; } - + /** * Check if running spigot - * + * * @return Spigot */ private boolean isSpigot() { return Bukkit.getVersion().contains("Spigot"); } - + /** * Get class by url - * + * * @param namespace * Namespace url * @return Class @@ -348,21 +348,21 @@ public class HackTitleManager { } return null; } - + private Field getField(final String name, final Class clazz) throws Exception { return clazz.getDeclaredField(name); } - + private Object getValue(final String name, final Object obj) throws Exception { final Field f = getField(name, obj.getClass()); f.setAccessible(true); return f.get(obj); } - + private Class getPrimitiveType(final Class clazz) { return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; } - + private Class[] toPrimitiveTypeArray(final Class[] classes) { final int a = classes != null ? classes.length : 0; final Class[] types = new Class[a]; @@ -371,7 +371,7 @@ public class HackTitleManager { } return types; } - + private static boolean equalsTypeArray(final Class[] a, final Class[] o) { if (a.length != o.length) { return false; @@ -383,7 +383,7 @@ public class HackTitleManager { } return true; } - + private Object getHandle(final Object obj) { try { return getMethod("getHandle", obj.getClass()).invoke(obj); @@ -392,7 +392,7 @@ public class HackTitleManager { return null; } } - + private Method getMethod(final String name, final Class clazz, final Class... paramTypes) { final Class[] t = toPrimitiveTypeArray(paramTypes); for (final Method m : clazz.getMethods()) { @@ -403,20 +403,20 @@ public class HackTitleManager { } return null; } - + private String getVersion() { final String name = Bukkit.getServer().getClass().getPackage().getName(); final String version = name.substring(name.lastIndexOf('.') + 1) + "."; return version; } - + private Class getNMSClass(final String className) throws ClassNotFoundException { final String fullName = "net.minecraft.server." + getVersion() + className; Class clazz = null; clazz = Class.forName(fullName); return clazz; } - + private Field getField(final Class clazz, final String name) { try { final Field field = clazz.getDeclaredField(name); @@ -427,7 +427,7 @@ public class HackTitleManager { return null; } } - + private Method getMethod(final Class clazz, final String name, final Class... args) { for (final Method m : clazz.getMethods()) { if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) { @@ -437,7 +437,7 @@ public class HackTitleManager { } return null; } - + private boolean ClassListEqual(final Class[] l1, final Class[] l2) { boolean equal = true; if (l1.length != l2.length) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java index e9b1b7b54..b0f24fc29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -14,26 +14,26 @@ public abstract class AChunkManager { public static RegionWrapper CURRENT_PLOT_CLEAR = null; public static HashMap> GENERATE_BLOCKS = new HashMap<>(); public static HashMap> GENERATE_DATA = new HashMap<>(); - + public static ChunkLoc getChunkChunk(final Location loc) { final int x = loc.getX() >> 9; final int z = loc.getZ() >> 9; return new ChunkLoc(x, z); } - - public abstract boolean loadChunk(String world, ChunkLoc loc); - - public abstract List getChunkChunks(String world); - - public abstract void deleteRegionFile(final String world, final ChunkLoc loc); - - public abstract Plot hasPlot(String world, ChunkLoc chunk); - - public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone); - - public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone); - - public abstract void clearAllEntities(final Plot plot); + public abstract boolean loadChunk(String world, ChunkLoc loc); + + public abstract List getChunkChunks(String world); + + public abstract void deleteRegionFile(final String world, final ChunkLoc loc); + + public abstract Plot hasPlot(String world, ChunkLoc chunk); + + public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone); + + public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone); + + public abstract void clearAllEntities(final Plot plot); + public abstract void swap(String world, PlotId id, PlotId plotid); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java index 21a181532..5734f3406 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AbstractSetBlock.java @@ -7,6 +7,6 @@ import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public abstract class AbstractSetBlock { public static SetBlockManager setBlockManager = null; - + public abstract void update(String worldname, List chunkLocs); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 904c106a7..104d0c2c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -6,20 +6,20 @@ import com.intellectualcrafters.plot.object.PlotBlock; public abstract class BlockManager { public static BlockManager manager; private static long state = 1; - + public static long nextLong() { final long a = state; state = xorShift64(a); return a; } - + public static long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - + public static int random(final int n) { if (n == 1) { return 0; @@ -27,35 +27,35 @@ public abstract class BlockManager { final long r = ((nextLong() >>> 32) * n) >> 32; return (int) r; } - + public abstract String[] getBiomeList(); - + public abstract int getBiomeFromString(String biome); - + public abstract int getBlockIdFromString(String block); - + public abstract int getHeighestBlock(Location loc); - + public abstract String getBiome(Location loc); - + public abstract Location getSpawn(String world); - + public abstract String[] getSign(Location loc); - + public abstract boolean isWorld(String world); - + public abstract void functionSetBlocks(String worldname, int[] x, int[] y, int[] z, int[] id, byte[] data); - + public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines); - + public abstract void functionSetBlock(String worldname, int x, int y, int z, int id, byte data); - + public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final int[] biome); - + public static void setBiomes(final String worldname, final int[] x, final int z[], final int[] biome) { manager.functionSetBiomes(worldname, x, z, biome); } - + public static void setBlocks(final String worldname, final int[] x, final int y[], final int z[], final PlotBlock[][] blocks) { final int[] id = new int[blocks.length]; final byte[] data = new byte[blocks.length]; @@ -67,7 +67,7 @@ public abstract class BlockManager { } setBlocks(worldname, x, y, z, id, data); } - + public static void setBlocks(final String worldname, final int[] x, final int y[], final int z[], final PlotBlock[] blocks) { final int[] id = new int[blocks.length]; final byte[] data = new byte[blocks.length]; @@ -78,11 +78,11 @@ public abstract class BlockManager { } setBlocks(worldname, x, y, z, id, data); } - + public static void setSign(final String worldname, final int x, final int y, final int z, final String[] lines) { manager.functionSetSign(worldname, x, y, z, lines); } - + public static void setBlocks(final String worldname, final int[] x, final int[] y, final int[] z, final int[] id, final byte[] data) { manager.functionSetBlocks(worldname, x, y, z, id, data); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 42634a86c..bf3edc131 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -31,25 +31,25 @@ public class ClusterManager { public static HashMap> clusters; private static HashSet regenerating = new HashSet<>(); public static PlotCluster last; - + public static boolean contains(final PlotCluster cluster, final PlotId id) { if ((cluster.getP1().x <= id.x) && (cluster.getP1().y <= id.y) && (cluster.getP2().x >= id.x) && (cluster.getP2().y >= id.y)) { return true; } return false; } - + public static HashSet getClusters(final World world) { return getClusters(world.getName()); } - + public static HashSet getClusters(final String world) { if (clusters.containsKey(world)) { return clusters.get(world); } return new HashSet<>(); } - + public static Location getHome(final PlotCluster cluster) { final BlockLoc home = cluster.settings.getPosition(); Location toReturn; @@ -72,27 +72,27 @@ public class ClusterManager { } return toReturn; } - + public static PlotId getCenterPlot(final PlotCluster cluster) { final PlotId bot = cluster.getP1(); final PlotId top = cluster.getP2(); return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); } - + public static Location getClusterBottom(final PlotCluster cluster) { final String world = cluster.world; final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); } - + public static Location getClusterTop(final PlotCluster cluster) { final String world = cluster.world; final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, cluster.getP2()); } - + public static PlotCluster getCluster(final String world, final String name) { if (!clusters.containsKey(world)) { return null; @@ -104,7 +104,7 @@ public class ClusterManager { } return null; } - + public static boolean contains(final PlotCluster cluster, final Location loc) { final String world = loc.getWorld(); final PlotManager manager = PlotSquared.getPlotManager(world); @@ -116,7 +116,7 @@ public class ClusterManager { } return false; } - + public static HashSet getIntersects(final String world, final PlotClusterId id) { if (!clusters.containsKey(world)) { return new HashSet<>(); @@ -129,7 +129,7 @@ public class ClusterManager { } return list; } - + public static boolean intersects(final PlotCluster cluster, final PlotClusterId id) { final PlotId pos1 = cluster.getP1(); final PlotId pos2 = cluster.getP2(); @@ -138,11 +138,11 @@ public class ClusterManager { } return false; } - + public static PlotCluster getCluster(final Plot plot) { return getCluster(plot.world, plot.id); } - + public static PlotCluster getCluster(final Location loc) { final String world = loc.getWorld(); if ((last != null) && last.world.equals(world)) { @@ -165,7 +165,7 @@ public class ClusterManager { } return null; } - + public static PlotCluster getCluster(final String world, final PlotId id) { if ((last != null) && last.world.equals(world)) { if (contains(last, id)) { @@ -187,7 +187,7 @@ public class ClusterManager { } return null; } - + public static boolean removeCluster(final PlotCluster cluster) { if (clusters != null) { if (clusters.containsKey(cluster.world)) { @@ -197,11 +197,11 @@ public class ClusterManager { } return false; } - + public static PlotClusterId getClusterId(final PlotCluster cluster) { return new PlotClusterId(cluster.getP1(), cluster.getP2()); } - + public static AugmentedPopulator getPopulator(final PlotCluster cluster) { final World world = Bukkit.getWorld(cluster.world); for (final BlockPopulator populator : world.getPopulators()) { @@ -213,7 +213,7 @@ public class ClusterManager { } return null; } - + public static PlotId estimatePlotId(final Location loc) { final PlotId a = new PlotId(0, 0); final PlotId b = new PlotId(1, 1); @@ -235,7 +235,7 @@ public class ClusterManager { final int z = loc.getZ(); return new PlotId((x / xw) + 1, (z / zw) + 1); } - + public static void regenCluster(final PlotCluster cluster) { if (regenerating.contains(cluster.world + ":" + cluster.getName())) { return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java index 5e1641f09..b1cdaf604 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ConsoleColors.java @@ -28,7 +28,7 @@ public class ConsoleColors { .replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)).replaceAll("&o", fromChatColor(ChatColor.ITALIC)).replaceAll("&r", fromChatColor(ChatColor.RESET)); return input + "\u001B[0m"; } - + /* * public static final String ANSI_RESET = "\u001B[0m"; public static final * String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = @@ -44,7 +44,7 @@ public class ConsoleColors { public static String fromChatColor(final ChatColor color) { return chatColor(color).getLin(); } - + public static ConsoleColor chatColor(final ChatColor color) { switch (color) { case RESET: @@ -82,7 +82,7 @@ public class ConsoleColors { return ConsoleColor.RESET; } } - + static enum ConsoleColor { RESET("\u001B[0m"), BLACK("\u001B[30m"), @@ -98,17 +98,17 @@ public class ConsoleColors { ITALIC("\033[3m"); private final String win; private final String lin; - + ConsoleColor(final String lin) { this.lin = lin; this.win = lin; } - + @SuppressWarnings("unused") public String getWin() { return this.win; } - + public String getLin() { return this.lin; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index 38e581168..db525a4d5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -6,19 +6,19 @@ import com.intellectualcrafters.plot.object.PlotPlayer; public class EconHandler { // TODO economy shit - public static double getBalance(PlotPlayer player) { + public static double getBalance(final PlotPlayer player) { return PlotSquared.economy.getBalance(player.getName()); } - - public static void withdrawPlayer(PlotPlayer player, double amount) { + + public static void withdrawPlayer(final PlotPlayer player, final double amount) { PlotSquared.economy.withdrawPlayer(player.getName(), amount); } - - public static void depositPlayer(PlotPlayer player, double amount) { + + public static void depositPlayer(final PlotPlayer player, final double amount) { PlotSquared.economy.depositPlayer(player.getName(), amount); } - - public static void depositPlayer(OfflinePlotPlayer player, double amount) { + + public static void depositPlayer(final OfflinePlotPlayer player, final double amount) { PlotSquared.economy.depositPlayer(player.getName(), amount); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 0efd9348f..4ea467c31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -30,7 +30,7 @@ public class ExpireManager { public static ConcurrentHashMap updatingPlots = new ConcurrentHashMap<>(); public static ConcurrentHashMap timestamp = new ConcurrentHashMap<>(); public static int task; - + public static long getTimeStamp(final String world) { if (timestamp.containsKey(world)) { return timestamp.get(world); @@ -39,7 +39,7 @@ public class ExpireManager { return 0; } } - + public static boolean updateExpired(final String world) { updatingPlots.put(world, true); final long now = System.currentTimeMillis(); @@ -60,7 +60,7 @@ public class ExpireManager { return false; } } - + public static void runTask() { ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, new Runnable() { @Override @@ -129,7 +129,7 @@ public class ExpireManager { } }, 2400, 2400); } - + public static boolean isExpired(final UUID uuid) { final String name = UUIDHandler.getName(uuid); if (name != null) { @@ -144,7 +144,7 @@ public class ExpireManager { } return false; } - + public static HashMap getOldPlots(final String world) { final Collection plots = PlotSquared.getPlots(world).values(); final HashMap toRemove = new HashMap<>(); @@ -171,7 +171,7 @@ public class ExpireManager { continue; } final BukkitOfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if ((op == null) || op.getLastPlayed() == 0) { + if ((op == null) || (op.getLastPlayed() == 0)) { continue; } long last = op.getLastPlayed(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java index 438c2b6f2..559a6761f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java @@ -33,7 +33,7 @@ public class LSetCube { * Base locations */ private Location l1, l2; - + /** * Constructor * @@ -44,7 +44,7 @@ public class LSetCube { this.l1 = l1; this.l1 = l2; } - + /** * Secondary constructor * @@ -55,7 +55,7 @@ public class LSetCube { this.l1 = l1; this.l2 = l1.clone().add(size, size, size); } - + /** * Returns the absolute min. of the cube * @@ -67,7 +67,7 @@ public class LSetCube { final int z = Math.min(this.l1.getBlockZ(), this.l2.getBlockZ()); return new Location(this.l1.getWorld(), x, y, z); } - + /** * Returns the absolute max. of the cube * @@ -79,7 +79,7 @@ public class LSetCube { final int z = Math.max(this.l1.getBlockZ(), this.l2.getBlockZ()); return new Location(this.l1.getWorld(), x, y, z); } - + /** * Creates a LCycler for the cube. * @@ -88,7 +88,7 @@ public class LSetCube { public LCycler getCycler() { return new LCycler(this); } - + /** * @author Citymonstret */ @@ -105,7 +105,7 @@ public class LSetCube { * */ private Location current; - + /** * @param cube */ @@ -114,14 +114,14 @@ public class LSetCube { this.max = cube.maxLoc(); this.current = this.min; } - + /** * @return */ public boolean hasNext() { return ((this.current.getBlockX() + 1) <= this.max.getBlockX()) && ((this.current.getBlockY() + 1) <= this.max.getBlockY()) && ((this.current.getBlockZ() + 1) <= this.max.getBlockZ()); } - + /** * @return */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java index 10acaff29..04c69ccd5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java @@ -39,7 +39,7 @@ public class Lag implements Runnable { */ @SuppressWarnings("unused") public static long LT = 0L; - + /** * Get the server TPS * @@ -48,7 +48,7 @@ public class Lag implements Runnable { public static double getTPS() { return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math.round(getTPS(100)); } - + /** * Return the tick per second (measured in $ticks) * @@ -64,7 +64,7 @@ public class Lag implements Runnable { final long e = System.currentTimeMillis() - T[t]; return ticks / (e / 1000.0D); } - + /** * Get number of ticks since * @@ -76,7 +76,7 @@ public class Lag implements Runnable { final long t = T[tI % T.length]; return System.currentTimeMillis() - t; } - + /** * Get lag percentage * @@ -85,7 +85,7 @@ public class Lag implements Runnable { public static double getPercentage() { return Math.round((1.0D - (Lag.getTPS() / 20.0D)) * 100.0D); } - + /** * Get TPS percentage (of 20) * @@ -94,7 +94,7 @@ public class Lag implements Runnable { public static double getFullPercentage() { return getTPS() * 5.0D; } - + @Override public void run() { T[TC % T.length] = System.currentTimeMillis(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java index 2ac6ede4b..f200fc491 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Logger.java @@ -39,7 +39,7 @@ import com.intellectualcrafters.plot.config.C; public class Logger { private static ArrayList entries; private static File log; - + public static void setup(final File file) { log = file; entries = new ArrayList<>(); @@ -54,7 +54,7 @@ public class Logger { PlotSquared.log(C.PREFIX.s() + "File setup error Logger#setup"); } } - + public static void write() throws IOException { final FileWriter writer = new FileWriter(log); for (final String string : entries) { @@ -62,25 +62,25 @@ public class Logger { } writer.close(); } - + public static void add(final LogLevel level, final String string) { append("[" + level.toString() + "] " + string); } - + private static void append(final String string) { entries.add("[" + new Date().toString() + "]" + string); } - + public enum LogLevel { GENERAL("General"), WARNING("Warning"), DANGER("Danger"); private final String name; - + LogLevel(final String name) { this.name = name; } - + @Override public String toString() { return this.name; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 05de4cff9..82aecd3ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -53,20 +53,20 @@ public class MainUtil { static long state = 1; public static HashMap lastPlot = new HashMap<>(); public static HashMap worldBorder = new HashMap<>(); - - public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { + final Plot plot1 = PlotSquared.getPlots(world).get(pos1); final Plot plot2 = PlotSquared.getPlots(world).get(pos2); - + if (plot1 != null) { pos1 = getBottomPlot(plot1).id; } - + if (plot2 != null) { pos2 = getTopPlot(plot2).id; } - + final ArrayList myplots = new ArrayList<>(); for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -75,7 +75,7 @@ public class MainUtil { } return myplots; } - + /** * Get the number of plots for a player * @@ -93,15 +93,15 @@ public class MainUtil { } return count; } - + public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) { final Plot bot = MainUtil.getBottomPlot(plot); - + // TODO // boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot); final boolean result = true; // TOOD ^ remove that - + if (!result) { final Location location = MainUtil.getPlotHome(bot.world, bot); if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) { @@ -131,7 +131,7 @@ public class MainUtil { } return !result; } - + public static int getBorder(final String worldname) { if (worldBorder.containsKey(worldname)) { PlotSquared.getPlotWorld(worldname); @@ -139,7 +139,7 @@ public class MainUtil { } return Integer.MAX_VALUE; } - + public static void setupBorder(final String world) { final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (!plotworld.WORLD_BORDER) { @@ -152,7 +152,7 @@ public class MainUtil { updateWorldBorder(plot); } } - + public static void update(final Location loc) { final String world = loc.getWorld(); final ArrayList chunks = new ArrayList<>(); @@ -165,10 +165,10 @@ public class MainUtil { } AbstractSetBlock.setBlockManager.update(world, chunks); } - + public static void createWorld(final String world, final String generator) { } - + public static PlotId parseId(final String arg) { try { final String[] split = arg.split(";"); @@ -177,7 +177,7 @@ public class MainUtil { return null; } } - + /** * direction 0 = north, 1 = south, etc: * @@ -199,7 +199,7 @@ public class MainUtil { } return id; } - + public static ArrayList getPlotSelectionIds(final PlotId pos1, final PlotId pos2) { final ArrayList myplots = new ArrayList<>(); for (int x = pos1.x; x <= pos2.x; x++) { @@ -209,7 +209,7 @@ public class MainUtil { } return myplots; } - + /** * Completely merges a set of plots
(There are no checks to make sure you supply the correct * arguments)
- Misuse of this method can result in unusable plots
- the set of plots must belong to one @@ -229,9 +229,9 @@ public class MainUtil { final PlotId pos2 = plotIds.get(plotIds.size() - 1); final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - + // FIXME call event - + manager.startPlotMerge(plotworld, plotIds); for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -278,7 +278,7 @@ public class MainUtil { manager.finishPlotMerge(plotworld, plotIds); return true; } - + /** * Merges 2 plots Removes the road inbetween
- Assumes the first plot parameter is lower
- Assumes neither * are a Mega-plot
- Assumes plots are directly next to each other
- Saves to DB @@ -308,7 +308,7 @@ public class MainUtil { } } } - + public static void removeSign(final Plot p) { final String world = p.world; final PlotManager manager = PlotSquared.getPlotManager(world); @@ -316,7 +316,7 @@ public class MainUtil { final Location loc = manager.getSignLoc(plotworld, p); BlockManager.setBlocks(world, new int[] { loc.getX() }, new int[] { loc.getY() }, new int[] { loc.getZ() }, new int[] { 0 }, new byte[] { 0 }); } - + public static void setSign(String name, final Plot p) { if (name == null) { name = "unknown"; @@ -328,14 +328,14 @@ public class MainUtil { final String[] lines = new String[] { C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) }; BlockManager.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines); } - + public static String getStringSized(final int max, final String string) { if (string.length() > max) { return string.substring(0, max); } return string; } - + public static void autoMerge(final String world, final Plot plot, final UUID uuid) { if (plot == null) { return; @@ -392,7 +392,7 @@ public class MainUtil { } update(getPlotHome(world, plot)); } - + private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { final PlotId id_min = plots.get(0); final PlotId id_max = plots.get(plots.size() - 1); @@ -412,7 +412,7 @@ public class MainUtil { } return true; } - + public static void updateWorldBorder(final Plot plot) { if (!worldBorder.containsKey(plot.world)) { return; @@ -430,7 +430,7 @@ public class MainUtil { worldBorder.put(plot.world, max); } } - + /** * Create a plot and notify the world border and plot merger */ @@ -445,7 +445,7 @@ public class MainUtil { } return true; } - + /** * Create a plot without notifying the merge function or world border manager */ @@ -456,15 +456,15 @@ public class MainUtil { DBFunc.createPlotAndSettings(p); return p; } - + public static String createId(final int x, final int z) { return x + ";" + z; } - + public static int square(final int x) { return x * x; } - + public static short[] getBlock(final String block) { if (block.contains(":")) { final String[] split = block.split(":"); @@ -472,7 +472,7 @@ public class MainUtil { } return new short[] { Short.parseShort(block), 0 }; } - + /** * Clear a plot and associated sections: [sign, entities, border] * @@ -488,7 +488,7 @@ public class MainUtil { removeSign(plot); return true; } - + public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { final PlotManager manager = PlotSquared.getPlotManager(world); final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); @@ -523,7 +523,7 @@ public class MainUtil { }; manager.clearPlot(plotworld, plot, isDelete, run); } - + public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { if (blocks.length == 1) { setSimpleCuboid(world, pos1, pos2, blocks[0]); @@ -552,7 +552,7 @@ public class MainUtil { } BlockManager.setBlocks(world, xl, yl, zl, ids, data); } - + public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); final int[] xl = new int[length]; @@ -575,7 +575,7 @@ public class MainUtil { } BlockManager.setBlocks(world, xl, yl, zl, ids, data); } - + public static void setBiome(final String world, final Plot plot, final String biome) { final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; final int topX = getPlotTopLoc(world, plot.id).getX(); @@ -583,7 +583,7 @@ public class MainUtil { final int topZ = getPlotTopLoc(world, plot.id).getZ(); BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); } - + public static int getHeighestBlock(final String world, final int x, final int z) { final int result = BukkitUtil.getHeighestBlock(world, x, z); if (result == 0) { @@ -601,7 +601,7 @@ public class MainUtil { // } // return 64; } - + /** * Get plot home * @@ -626,7 +626,7 @@ public class MainUtil { return bot.add(home.x, y, home.z); } } - + /** * Retrieve the location of the default plot home position * @@ -639,7 +639,7 @@ public class MainUtil { l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); return l; } - + /** * Get the plot home * @@ -653,7 +653,7 @@ public class MainUtil { public static Location getPlotHome(final String w, final Plot plot) { return getPlotHome(w, plot.id); } - + /** * Refresh the plot chunks * @@ -691,7 +691,7 @@ public class MainUtil { } } } - + /** * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot * use getPlotTopLoc(...) @@ -706,7 +706,7 @@ public class MainUtil { final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } - + /** * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega * plot use getPlotBottomLoc(...) @@ -721,7 +721,7 @@ public class MainUtil { final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); } - + /** * Obtains the width of a plot (x width) * @@ -733,7 +733,7 @@ public class MainUtil { public static int getPlotWidth(final String world, final PlotId id) { return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); } - + /** * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as * a small plot use getPlotTopLocAbs(...) @@ -752,7 +752,7 @@ public class MainUtil { final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotTopLocAbs(plotworld, id); } - + /** * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot * treated as a small plot use getPlotBottomLocAbs(...) @@ -771,7 +771,7 @@ public class MainUtil { final PlotManager manager = PlotSquared.getPlotManager(world); return manager.getPlotBottomLocAbs(plotworld, id); } - + public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -785,7 +785,7 @@ public class MainUtil { } return true; } - + public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current); final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); @@ -821,7 +821,7 @@ public class MainUtil { }); return true; } - + /** * Send a message to the player * @@ -833,7 +833,7 @@ public class MainUtil { public static boolean sendMessage(final PlotPlayer plr, final String msg) { return sendMessage(plr, msg, true); } - + public static String colorise(final char alt, final String message) { final char[] b = message.toCharArray(); for (int i = 0; i < (b.length - 1); i++) { @@ -844,10 +844,10 @@ public class MainUtil { } return new String(b); } - + public static boolean sendMessage(final PlotPlayer plr, String msg, final boolean prefix) { msg = colorise('&', msg); - String prefixStr = colorise('&', C.PREFIX.s()); + final String prefixStr = colorise('&', C.PREFIX.s()); if ((msg.length() > 0) && !msg.equals("")) { if (plr == null) { PlotSquared.log(prefixStr + msg); @@ -857,7 +857,7 @@ public class MainUtil { } return true; } - + public static String[] wordWrap(final String rawString, final int lineLength) { if (rawString == null) { return new String[] { "" }; @@ -916,7 +916,7 @@ public class MainUtil { for (int i = 1; i < lines.size(); i++) { final String pLine = lines.get(i - 1); final String subLine = lines.get(i); - + final char color = pLine.charAt(pLine.lastIndexOf('§') + 1); if ((subLine.length() == 0) || (subLine.charAt(0) != '§')) { lines.set(i, '§' + (color) + subLine); @@ -924,28 +924,28 @@ public class MainUtil { } return lines.toArray(new String[lines.size()]); } - + /** * \\previous\\ * * @param plr * @param msg Was used to wrap the chat client length (Packets out--) */ - public static void sendMessageWrapped(final PlotPlayer plr, String msg) { -// if (msg.length() > 65) { -// final String[] ss = wordWrap(msg, 65); -// final StringBuilder b = new StringBuilder(); -// for (final String p : ss) { -// b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n "); -// } -// msg = b.toString(); -// } -// if (msg.endsWith("\n")) { -// msg = msg.substring(0, msg.length() - 2); -// } + public static void sendMessageWrapped(final PlotPlayer plr, final String msg) { + // if (msg.length() > 65) { + // final String[] ss = wordWrap(msg, 65); + // final StringBuilder b = new StringBuilder(); + // for (final String p : ss) { + // b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n "); + // } + // msg = b.toString(); + // } + // if (msg.endsWith("\n")) { + // msg = msg.substring(0, msg.length() - 2); + // } plr.sendMessage(msg); } - + /** * Send a message to the player * @@ -972,7 +972,7 @@ public class MainUtil { } return true; } - + public static Plot getBottomPlot(final Plot plot) { if (plot.settings.getMerged(0)) { final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1)); @@ -990,7 +990,7 @@ public class MainUtil { } return plot; } - + public static Plot getTopPlot(final Plot plot) { if (plot.settings.getMerged(2)) { return getTopPlot(PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1))); @@ -1000,7 +1000,7 @@ public class MainUtil { } return plot; } - + public static PlotId getSize(final String world, final Plot plot) { final PlotSettings settings = plot.settings; if (!settings.isMerged()) { @@ -1010,7 +1010,7 @@ public class MainUtil { final Plot bot = getBottomPlot(plot); return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1); } - + /** * Fetches the plot from the main class */ @@ -1023,7 +1023,7 @@ public class MainUtil { } return new Plot(id, null, new ArrayList(), new ArrayList(), world); } - + /** * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) * @param loc @@ -1038,7 +1038,7 @@ public class MainUtil { final PlotWorld plotworld = PlotSquared.getPlotWorld(world); return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); } - + /** * Returns the plot id at a location (mega plots are considered) * @param loc @@ -1059,17 +1059,17 @@ public class MainUtil { } return id; } - + /** * Get the maximum number of plots a player is allowed * * @param p * @return */ - public static int getAllowedPlots(final PlotPlayer p, int current) { + public static int getAllowedPlots(final PlotPlayer p, final int current) { return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS, current); } - + public static Plot getPlot(final Location loc) { final PlotId id = getPlotId(loc); if (id == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index 9b3514a29..28f5594e2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -17,7 +17,7 @@ public class Permissions { public static String BREAK_OTHER = "plots.admin.break.other"; public static String BREAK_ROAD = "plots.admin.break.road"; public static String BREAK_UNOWNED = "plots.admin.break.unowned"; - + public static boolean hasPermission(final PlotPlayer player, final String perm) { if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) { return true; @@ -35,7 +35,7 @@ public class Permissions { } return false; } - + public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range, final int min) { if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) { return Byte.MAX_VALUE; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java index e9090b103..b2c0f1ef9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java @@ -32,20 +32,20 @@ public class PlotSquaredException extends RuntimeException { super("PlotError >> " + error.getHeader() + ": " + details); PlotSquared.log("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details); } - + public static enum PlotError { PLOTMAIN_NULL("The PlotSquared instance was null"), MISSING_DEPENDENCY("Missing Dependency"); private final String errorHeader; - + PlotError(final String errorHeader) { this.errorHeader = errorHeader; } - + public String getHeader() { return this.errorHeader; } - + @Override public String toString() { return this.getHeader(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java index 3c2803a98..35e019709 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/RUtils.java @@ -37,7 +37,7 @@ public class RUtils { public static long getTotalRam() { return (Runtime.getRuntime().totalMemory() / 1024) / 1024; } - + /** * Get the total free ram * @@ -46,7 +46,7 @@ public class RUtils { public static long getFreeRam() { return (Runtime.getRuntime().freeMemory() / 1024) / 1024; } - + /** * Percentage of used ram * @@ -55,7 +55,7 @@ public class RUtils { public static long getRamPercentage() { return (getFreeRam() / getTotalRam()) * 100; } - + /** * Get formatted time * @@ -73,18 +73,18 @@ public class RUtils { final String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second"); return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m).replaceAll("%hours%", s_h); } - + enum Direction { SOUTH(0), EAST(1), NORTH(2), WEST(3); private final int i; - + Direction(final int i) { this.i = i; } - + public int getInt() { return this.i; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java index f590a1cb7..6afb88dc7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java @@ -75,14 +75,14 @@ public class ReflectionUtils { } } } - + /** * @return true if server has forge classes */ public static boolean isForge() { return forge; } - + /** * Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace * {nm} to net.minecraft @@ -103,7 +103,7 @@ public class ReflectionUtils { } throw new RuntimeException("no class found"); } - + /** * get RefClass object by real class * @@ -114,17 +114,17 @@ public class ReflectionUtils { public static RefClass getRefClass(final Class clazz) { return new RefClass(clazz); } - + /** * RefClass - utility to simplify work with reflections. */ public static class RefClass { private final Class clazz; - + private RefClass(final Class clazz) { this.clazz = clazz; } - + /** * get passed class * @@ -133,7 +133,7 @@ public class ReflectionUtils { public Class getRealClass() { return this.clazz; } - + /** * see {@link Class#isInstance(Object)} * @@ -144,7 +144,7 @@ public class ReflectionUtils { public boolean isInstance(final Object object) { return this.clazz.isInstance(object); } - + /** * get existing method by name and types * @@ -177,7 +177,7 @@ public class ReflectionUtils { throw new RuntimeException(e); } } - + /** * get existing constructor by types * @@ -209,7 +209,7 @@ public class ReflectionUtils { throw new RuntimeException(e); } } - + /** * find method by type parameters * @@ -235,20 +235,20 @@ public class ReflectionUtils { Collections.addAll(methods, this.clazz.getMethods()); Collections.addAll(methods, this.clazz.getDeclaredMethods()); findMethod: for (final Method m : methods) { - final Class[] methodTypes = m.getParameterTypes(); - if (methodTypes.length != classes.length) { - continue; - } - for (final Class aClass : classes) { - if (!Arrays.equals(classes, methodTypes)) { - continue findMethod; - } - return new RefMethod(m); - } + final Class[] methodTypes = m.getParameterTypes(); + if (methodTypes.length != classes.length) { + continue; } + for (final Class aClass : classes) { + if (!Arrays.equals(classes, methodTypes)) { + continue findMethod; + } + return new RefMethod(m); + } + } throw new RuntimeException("no such method"); } - + /** * find method by name * @@ -271,7 +271,7 @@ public class ReflectionUtils { } throw new RuntimeException("no such method"); } - + /** * find method by return value * @@ -284,7 +284,7 @@ public class ReflectionUtils { public RefMethod findMethodByReturnType(final RefClass type) { return findMethodByReturnType(type.clazz); } - + /** * find method by return value * @@ -308,7 +308,7 @@ public class ReflectionUtils { } throw new RuntimeException("no such method"); } - + /** * find constructor by number of arguments * @@ -329,7 +329,7 @@ public class ReflectionUtils { } throw new RuntimeException("no such constructor"); } - + /** * get field by name * @@ -350,7 +350,7 @@ public class ReflectionUtils { throw new RuntimeException(e); } } - + /** * find field by type * @@ -363,7 +363,7 @@ public class ReflectionUtils { public RefField findField(final RefClass type) { return findField(type.clazz); } - + /** * find field by type * @@ -388,39 +388,39 @@ public class ReflectionUtils { throw new RuntimeException("no such field"); } } - + /** * Method wrapper */ public static class RefMethod { private final Method method; - + private RefMethod(final Method method) { this.method = method; method.setAccessible(true); } - + /** * @return passed method */ public Method getRealMethod() { return this.method; } - + /** * @return owner class of method */ public RefClass getRefClass() { return new RefClass(this.method.getDeclaringClass()); } - + /** * @return class of method return type */ public RefClass getReturnRefClass() { return new RefClass(this.method.getReturnType()); } - + /** * apply method to object * @@ -431,7 +431,7 @@ public class ReflectionUtils { public RefExecutor of(final Object e) { return new RefExecutor(e); } - + /** * call static method * @@ -446,14 +446,14 @@ public class ReflectionUtils { throw new RuntimeException(e); } } - + public class RefExecutor { final Object e; - + public RefExecutor(final Object e) { this.e = e; } - + /** * apply method for selected object * @@ -472,32 +472,32 @@ public class ReflectionUtils { } } } - + /** * Constructor wrapper */ public static class RefConstructor { private final Constructor constructor; - + private RefConstructor(final Constructor constructor) { this.constructor = constructor; constructor.setAccessible(true); } - + /** * @return passed constructor */ public Constructor getRealConstructor() { return this.constructor; } - + /** * @return owner class of method */ public RefClass getRefClass() { return new RefClass(this.constructor.getDeclaringClass()); } - + /** * create new instance with constructor * @@ -515,36 +515,36 @@ public class ReflectionUtils { } } } - + public static class RefField { private final Field field; - + private RefField(final Field field) { this.field = field; field.setAccessible(true); } - + /** * @return passed field */ public Field getRealField() { return this.field; } - + /** * @return owner class of field */ public RefClass getRefClass() { return new RefClass(this.field.getDeclaringClass()); } - + /** * @return type of field */ public RefClass getFieldRefClass() { return new RefClass(this.field.getType()); } - + /** * apply fiend for object * @@ -555,14 +555,14 @@ public class ReflectionUtils { public RefExecutor of(final Object e) { return new RefExecutor(e); } - + public class RefExecutor { final Object e; - + public RefExecutor(final Object e) { this.e = e; } - + /** * set field value for applied object * @@ -575,7 +575,7 @@ public class ReflectionUtils { throw new RuntimeException(e); } } - + /** * get field value for applied object * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index bbe7ead4e..596435a46 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -108,7 +108,7 @@ public class SchematicHandler { } return true; } - + public static Schematic getSchematic(final CompoundTag tag, final File file) { final Map tagMap = tag.getValue(); byte[] addId = new byte[0]; @@ -140,7 +140,7 @@ public class SchematicHandler { } return new Schematic(collection, dimension, file); } - + /** * Get a schematic * @@ -173,7 +173,7 @@ public class SchematicHandler { return null; } } - + /** * Saves a schematic to a file path * @@ -201,7 +201,7 @@ public class SchematicHandler { } return true; } - + /** * Gets the schematic of a plot * @@ -218,7 +218,7 @@ public class SchematicHandler { final Location pos2 = MainUtil.getPlotTopLoc(world, id); return getCompoundTag(world, pos1, pos2); } - + @SuppressWarnings("deprecation") public static CompoundTag getCompoundTag(final String world, final Location pos1, final Location pos2) { // loading chunks @@ -290,7 +290,7 @@ public class SchematicHandler { } return new CompoundTag("Schematic", schematic); } - + public static boolean pastePart(final String world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) { int length = 0; for (int i = i1; i <= i2; i++) { @@ -328,7 +328,7 @@ public class SchematicHandler { BlockManager.setBlocks(world, xl, yl, zl, ids, data); return true; } - + /** * Schematic Class * @@ -338,26 +338,26 @@ public class SchematicHandler { private final DataCollection[] blockCollection; private final Dimension schematicDimension; private final File file; - + public Schematic(final DataCollection[] blockCollection, final Dimension schematicDimension, final File file) { this.blockCollection = blockCollection; this.schematicDimension = schematicDimension; this.file = file; } - + public File getFile() { return this.file; } - + public Dimension getSchematicDimension() { return this.schematicDimension; } - + public DataCollection[] getBlockCollection() { return this.blockCollection; } } - + /** * Schematic Dimensions * @@ -367,26 +367,26 @@ public class SchematicHandler { private final int x; private final int y; private final int z; - + public Dimension(final int x, final int y, final int z) { this.x = x; this.y = y; this.z = z; } - + public int getX() { return this.x; } - + public int getY() { return this.y; } - + public int getZ() { return this.z; } } - + /** * Schematic Data Collection * @@ -395,17 +395,17 @@ public class SchematicHandler { public static class DataCollection { private final short block; private final byte data; - + // public CompoundTag tag; public DataCollection(final short block, final byte data) { this.block = block; this.data = data; } - + public short getBlock() { return this.block; } - + public byte getData() { return this.data; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java index b40347e3e..7a860d778 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -7,13 +7,13 @@ import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.SetupObject; public abstract class SetupUtils { - + public static SetupUtils manager; - + public final static Map setupMap = new HashMap<>(); public static HashMap generators = new HashMap<>(); - + public abstract void updateGenerators(); - + public abstract String setupWorld(final SetupObject object); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java index d017796fd..261128cb8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java @@ -44,7 +44,7 @@ public class StringComparison { * The actual object */ private Object bestMatchObject; - + /** * Constructor * @@ -63,7 +63,7 @@ public class StringComparison { } } } - + /** * Compare two strings * @@ -87,7 +87,7 @@ public class StringComparison { } return (2.0 * intersection) / union; } - + /** * Create an ArrayList containing pairs of letters * @@ -104,7 +104,7 @@ public class StringComparison { } return aPairs; } - + /** * Get an array containing letter pairs * @@ -120,7 +120,7 @@ public class StringComparison { } return p; } - + /** * Get the object * @@ -129,7 +129,7 @@ public class StringComparison { public Object getMatchObject() { return this.bestMatchObject; } - + /** * Get the best match value * @@ -138,7 +138,7 @@ public class StringComparison { public String getBestMatch() { return this.bestMatch; } - + /** * Will return both the match number, and the actual match string * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java index b615a106b..8986fa2ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -6,44 +6,44 @@ import com.intellectualcrafters.plot.PlotSquared; public abstract class TaskManager { public static HashSet TELEPORT_QUEUE = new HashSet<>(); - + public abstract int taskRepeat(final Runnable r, int interval); - + public abstract void taskAsync(final Runnable r); - + public abstract void task(final Runnable r); - + public abstract void taskLater(final Runnable r, int delay); - + public abstract void taskLaterAsync(final Runnable r, int delay); - + public abstract void cancelTask(int task); - + public static int runTaskRepeat(final Runnable r, final int interval) { if (r != null) { return PlotSquared.TASK.taskRepeat(r, interval); } return -1; } - + public static void runTaskAsync(final Runnable r) { if (r != null) { PlotSquared.TASK.taskAsync(r); } } - + public static void runTask(final Runnable r) { if (r != null) { PlotSquared.TASK.task(r); } } - + public static void runTaskLater(final Runnable r, final int delay) { if (r != null) { PlotSquared.TASK.taskLater(r, delay); } } - + public static void runTaskLaterAsync(final Runnable r, final int delay) { if (r != null) { PlotSquared.TASK.taskLaterAsync(r, delay); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 7e789a4bc..724c497f3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -41,12 +41,12 @@ import com.intellectualcrafters.plot.util.MainUtil; * Functions involving players, plots and locations. */ public class BukkitPlayerFunctions { - + /* * =========== NOTICE ================ * - We will try to move as many functions as we can out of this class and into the MainUtil class */ - + /** * Clear a plot. Use null player if no player is present * @param player @@ -56,7 +56,7 @@ public class BukkitPlayerFunctions { */ public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) { final long start = System.currentTimeMillis(); - Runnable whenDone = new Runnable() { + final Runnable whenDone = new Runnable() { @Override public void run() { if ((player != null) && player.isOnline()) { @@ -68,7 +68,7 @@ public class BukkitPlayerFunctions { MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); } } - + /** * Merges all plots in the arraylist (with cost) * @@ -94,7 +94,7 @@ public class BukkitPlayerFunctions { } return MainUtil.mergePlots(world, plotIds, true); } - + public static String getPlayerName(final UUID uuid) { if (uuid == null) { return "unknown"; @@ -105,7 +105,7 @@ public class BukkitPlayerFunctions { } return name; } - + /** * @param player player * @@ -114,7 +114,7 @@ public class BukkitPlayerFunctions { public static boolean isInPlot(final Player player) { return getCurrentPlot(player) != null; } - + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { final Plot plot1 = PlotSquared.getPlots(world).get(pos1); final Plot plot2 = PlotSquared.getPlots(world).get(pos2); @@ -132,7 +132,7 @@ public class BukkitPlayerFunctions { } return myplots; } - + /** * Returns the plot a player is currently in. * @@ -154,7 +154,7 @@ public class BukkitPlayerFunctions { } return new Plot(id, null, new ArrayList(), new ArrayList(), world); } - + /** * Get the plots for a player * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index f4f1d7bf7..96aeb94f3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.SetupUtils; public class BukkitSetupUtils extends SetupUtils { - + @Override public void updateGenerators() { if (SetupUtils.generators.size() > 0) { @@ -40,7 +40,7 @@ public class BukkitSetupUtils extends SetupUtils { } } } - + @Override public String setupWorld(final SetupObject object) { final ConfigurationNode[] steps = object.step; @@ -84,5 +84,5 @@ public class BukkitSetupUtils extends SetupUtils { } return object.world; } - + } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java index 36d705b9d..856e92179 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitTaskManager.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.util.bukkit; import org.bukkit.Bukkit; -import org.bukkit.scheduler.BukkitTask; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.util.TaskManager; @@ -11,29 +10,29 @@ public class BukkitTaskManager extends TaskManager { public int taskRepeat(final Runnable r, final int interval) { return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval); } - + @Override public void taskAsync(final Runnable r) { BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r).getTaskId(); } - + @Override public void task(final Runnable r) { BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r).getTaskId(); } - + @Override public void taskLater(final Runnable r, final int delay) { BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay).getTaskId(); } - - @Override - public void taskLaterAsync(final Runnable r, final int delay) { - BukkitTask runnable = BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay); - } @Override - public void cancelTask(int task) { + public void taskLaterAsync(final Runnable r, final int delay) { + BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay); + } + + @Override + public void cancelTask(final int task) { if (task != -1) { Bukkit.getScheduler().cancelTask(task); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 08e7c6fc1..350b37a76 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -26,24 +26,24 @@ public class BukkitUtil extends BlockManager { private static HashMap worlds = new HashMap<>(); private static String lastString = null; private static World lastWorld = null; - + private static Player lastPlayer = null; private static PlotPlayer lastPlotPlayer = null; - - public static void removePlayer(String plr) { - if (lastPlayer != null && lastPlayer.getName().equals(plr)) { + + public static void removePlayer(final String plr) { + if ((lastPlayer != null) && lastPlayer.getName().equals(plr)) { lastPlayer = null; lastPlotPlayer = null; } UUIDHandler.players.remove(plr); } - + @Override - public boolean isWorld(String world) { + public boolean isWorld(final String world) { return getWorld(world) != null; } - - public static PlotPlayer getPlayer(Player player) { + + public static PlotPlayer getPlayer(final Player player) { if (player == lastPlayer) { return lastPlotPlayer; } @@ -52,16 +52,16 @@ public class BukkitUtil extends BlockManager { lastPlayer = player; return lastPlotPlayer; } - + @Override public String getBiome(final Location loc) { return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()).name(); } - - public static Location getLocation(org.bukkit.Location loc) { + + public static Location getLocation(final org.bukkit.Location loc) { return new Location(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } - + public static World getWorld(final String string) { if (string == lastString) { return lastWorld; @@ -73,20 +73,20 @@ public class BukkitUtil extends BlockManager { } return world; } - + public static int getMaxHeight(final String world) { return getWorld(world).getMaxHeight(); } - + public static int getHeighestBlock(final String world, final int x, final int z) { return getWorld(world).getHighestBlockYAt(x, z); } - + public static Chunk getChunkAt(final String worldname, final int x, final int z) { final World world = getWorld(worldname); return world.getChunkAt(x, z); } - + public static void update(final String world, final int x, final int z) { final ArrayList chunks = new ArrayList<>(); final int distance = Bukkit.getViewDistance(); @@ -98,20 +98,20 @@ public class BukkitUtil extends BlockManager { } SetBlockManager.setBlockManager.update(chunks); } - + public static String getWorld(final Entity entity) { return entity.getWorld().getName(); } - + public static void teleportPlayer(final Player player, final Location loc) { final org.bukkit.Location bukkitLoc = new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()); player.teleport(bukkitLoc); } - + public static List getEntities(final String worldname) { return getWorld(worldname).getEntities(); } - + public static void setBlock(final World world, final int x, final int y, final int z, final int id, final byte data) { try { SetBlockManager.setBlockManager.set(world, x, y, z, id, data); @@ -120,7 +120,7 @@ public class BukkitUtil extends BlockManager { SetBlockManager.setBlockManager.set(world, x, y, z, id, data); } } - + public static void setBiome(final String worldname, final int pos1_x, final int pos1_z, final int pos2_x, final int pos2_z, final String biome) { final Biome b = Biome.valueOf(biome.toUpperCase()); final World world = getWorld(worldname); @@ -136,15 +136,15 @@ public class BukkitUtil extends BlockManager { } } } - + public static void refreshChunk(final String world, final int x, final int z) { getWorld(world).refreshChunk(x, z); } - + public static void regenerateChunk(final String world, final int x, final int z) { getWorld(world).regenerateChunk(x, z); } - + public static PlotBlock getBlock(final Location loc) { final World world = getWorld(loc.getWorld()); final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); @@ -153,13 +153,13 @@ public class BukkitUtil extends BlockManager { } return new PlotBlock((short) block.getTypeId(), block.getData()); } - + public static Location getLocation(final Entity entity) { final org.bukkit.Location loc = entity.getLocation(); final String world = loc.getWorld().getName(); return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } - + @Override public void functionSetBlocks(final String worldname, final int[] x, final int[] y, final int[] z, final int[] id, final byte[] data) { final World world = getWorld(worldname); @@ -167,7 +167,7 @@ public class BukkitUtil extends BlockManager { BukkitUtil.setBlock(world, x[i], y[i], z[i], id[i], data[i]); } } - + @Override public void functionSetSign(final String worldname, final int x, final int y, final int z, final String[] lines) { final World world = getWorld(worldname); @@ -182,28 +182,28 @@ public class BukkitUtil extends BlockManager { ((Sign) blockstate).update(true); } } - + public static int getViewDistance() { return Bukkit.getViewDistance(); } - + @Override - public void functionSetBiomes(String worldname, int[] x, int[] z, int[] biome) { - World world = getWorld(worldname); - Biome[] biomes = Biome.values(); + public void functionSetBiomes(final String worldname, final int[] x, final int[] z, final int[] biome) { + final World world = getWorld(worldname); + final Biome[] biomes = Biome.values(); for (int i = 0; i < x.length; i++) { world.setBiome(x[i], z[i], biomes[biome[i]]); } } - + @Override - public void functionSetBlock(String worldname, int x, int y, int z, int id, byte data) { + public void functionSetBlock(final String worldname, final int x, final int y, final int z, final int id, final byte data) { BukkitUtil.setBlock(getWorld(worldname), x, y, z, id, data); } - + @Override - public String[] getSign(Location loc) { - Block block = getWorld(loc.getWorld()).getBlockAt(loc.getX(), loc.getY(), loc.getZ()); + public String[] getSign(final Location loc) { + final Block block = getWorld(loc.getWorld()).getBlockAt(loc.getX(), loc.getY(), loc.getZ()); if (block != null) { if (block.getState() instanceof Sign) { final Sign sign = (Sign) block.getState(); @@ -212,40 +212,40 @@ public class BukkitUtil extends BlockManager { } return null; } - + @Override - public Location getSpawn(String world) { - org.bukkit.Location temp = getWorld(world).getSpawnLocation(); + public Location getSpawn(final String world) { + final org.bukkit.Location temp = getWorld(world).getSpawnLocation(); return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ()); } - + @Override - public int getHeighestBlock(Location loc) { + public int getHeighestBlock(final Location loc) { return getWorld(loc.getWorld()).getHighestBlockAt(loc.getX(), loc.getZ()).getY(); } - + @Override - public int getBiomeFromString(String biomeStr) { - Biome biome = Biome.valueOf(biomeStr.toUpperCase()); + public int getBiomeFromString(final String biomeStr) { + final Biome biome = Biome.valueOf(biomeStr.toUpperCase()); if (biome == null) { return -1; } return Arrays.asList(Biome.values()).indexOf(biome); } - + @Override public String[] getBiomeList() { - Biome[] biomes = Biome.values(); - String[] list = new String[biomes.length]; - for (int i = 0; i< biomes.length; i++) { + final Biome[] biomes = Biome.values(); + final String[] list = new String[biomes.length]; + for (int i = 0; i < biomes.length; i++) { list[i] = biomes[i].name(); } return list; } - + @Override - public int getBlockIdFromString(String block) { - Material material = Material.valueOf(block.toUpperCase()); + public int getBlockIdFromString(final String block) { + final Material material = Material.valueOf(block.toUpperCase()); if (material == null) { return -1; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 7a82b9c15..00cb813d0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -58,7 +58,7 @@ import com.intellectualcrafters.plot.util.TaskManager; public class ChunkManager extends AChunkManager { public static MutableInt index = new MutableInt(0); public static HashMap tasks = new HashMap<>(); - + @Override public ArrayList getChunkChunks(final String world) { final String directory = new File(".").getAbsolutePath() + File.separator + world + File.separator + "region"; @@ -86,7 +86,7 @@ public class ChunkManager extends AChunkManager { } return chunks; } - + @Override public void deleteRegionFile(final String world, final ChunkLoc loc) { TaskManager.runTaskAsync(new Runnable() { @@ -101,7 +101,7 @@ public class ChunkManager extends AChunkManager { } }); } - + @Override public Plot hasPlot(final String world, final ChunkLoc chunk) { final int x1 = chunk.x << 4; @@ -121,7 +121,7 @@ public class ChunkManager extends AChunkManager { } return null; } - + private static HashMap chestContents; private static HashMap furnaceContents; private static HashMap dispenserContents; @@ -140,7 +140,7 @@ public class ChunkManager extends AChunkManager { private static HashMap> bannerColors; private static HashMap bannerBase; private static HashSet entities; - + /** * Copy a region to a new location (in the same world) */ @@ -250,7 +250,7 @@ public class ChunkManager extends AChunkManager { tasks.put(currentIndex, loadTask); return true; } - + @Override public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { index.increment(); @@ -266,7 +266,7 @@ public class ChunkManager extends AChunkManager { final int c1z = c1.getZ(); final int c2x = c2.getX(); final int c2z = c2.getZ(); - + final ArrayList chunks = new ArrayList(); for (int x = c1x; x <= c2x; x++) { for (int z = c1z; z <= c2z; z++) { @@ -343,7 +343,7 @@ public class ChunkManager extends AChunkManager { tasks.put(currentIndex, task); return true; } - + public static void initMaps() { GENERATE_BLOCKS = new HashMap<>(); GENERATE_DATA = new HashMap<>(); @@ -366,11 +366,11 @@ public class ChunkManager extends AChunkManager { bannerColors = new HashMap<>(); entities = new HashSet<>(); } - + public static boolean isIn(final RegionWrapper region, final int x, final int z) { return ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)); } - + public static void saveEntitiesOut(final Chunk chunk, final RegionWrapper region) { for (final Entity entity : chunk.getEntities()) { final Location loc = BukkitUtil.getLocation(entity); @@ -386,7 +386,7 @@ public class ChunkManager extends AChunkManager { entities.add(wrap); } } - + public static void saveEntitiesIn(final Chunk chunk, final RegionWrapper region) { for (final Entity entity : chunk.getEntities()) { final Location loc = BukkitUtil.getLocation(entity); @@ -402,7 +402,7 @@ public class ChunkManager extends AChunkManager { entities.add(wrap); } } - + public static void restoreEntities(final World world, final int x_offset, final int z_offset) { for (final EntityWrapper entity : entities) { try { @@ -413,7 +413,7 @@ public class ChunkManager extends AChunkManager { } } } - + public static void restoreBlocks(final World world, final int x_offset, final int z_offset) { for (final BlockLoc loc : chestContents.keySet()) { final Block block = world.getBlockAt(loc.x + x_offset, loc.y, loc.z + z_offset); @@ -597,7 +597,7 @@ public class ChunkManager extends AChunkManager { } } } - + public static void saveBlocks(final World world, final int maxY, final int x, final int z) { final HashMap ids = new HashMap<>(); final HashMap datas = new HashMap<>(); @@ -730,7 +730,7 @@ public class ChunkManager extends AChunkManager { GENERATE_BLOCKS.put(loc, ids); GENERATE_DATA.put(loc, datas); } - + private static byte getOrdinal(final Object[] list, final Object value) { for (byte i = 0; i < list.length; i++) { if (list[i].equals(value)) { @@ -739,7 +739,7 @@ public class ChunkManager extends AChunkManager { } return 0; } - + @Override public void clearAllEntities(final Plot plot) { final List entities = BukkitUtil.getEntities(plot.world); @@ -756,14 +756,14 @@ public class ChunkManager extends AChunkManager { } } } - + @Override - public boolean loadChunk(String world, ChunkLoc loc) { + public boolean loadChunk(final String world, final ChunkLoc loc) { return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(false); } - + @Override - public void swap(String world, PlotId id, PlotId plotid) { + public void swap(final String world, final PlotId id, final PlotId plotid) { // FIXME swap plots } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java index dfd2508a7..8e6677624 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java @@ -100,7 +100,7 @@ public class Metrics { * The scheduled task */ private volatile BukkitTask task = null; - + public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -122,7 +122,7 @@ public class Metrics { this.guid = this.configuration.getString("guid"); this.debug = this.configuration.getBoolean("debug", false); } - + /** * GZip compress a string of bytes * @@ -148,7 +148,7 @@ public class Metrics { } return baos.toByteArray(); } - + /** * Appends a json encoded key/value pair to the given string builder. * @@ -179,7 +179,7 @@ public class Metrics { json.append(escapeJSON(value)); } } - + /** * Escape a string to create a valid JSON string * @@ -223,7 +223,7 @@ public class Metrics { builder.append('"'); return builder.toString(); } - + /** * Encode text as UTF-8 * @@ -234,7 +234,7 @@ public class Metrics { private static String urlEncode(final String text) throws UnsupportedEncodingException { return URLEncoder.encode(text, "UTF-8"); } - + /** * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics * website. Plotters can be added to the graph object returned. @@ -254,7 +254,7 @@ public class Metrics { // and return back return graph; } - + /** * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend * @@ -266,7 +266,7 @@ public class Metrics { } this.graphs.add(graph); } - + /** * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 @@ -287,7 +287,7 @@ public class Metrics { // Begin hitting the server with glorious data this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() { private boolean firstPost = true; - + @Override public void run() { try { @@ -331,7 +331,7 @@ public class Metrics { return true; } } - + /** * Has the server owner denied plugin metrics? * @@ -356,7 +356,7 @@ public class Metrics { return this.configuration.getBoolean("opt-out", false); } } - + /** * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. * @@ -378,7 +378,7 @@ public class Metrics { } } } - + /** * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * @@ -401,7 +401,7 @@ public class Metrics { } } } - + /** * Gets the File object of the config file that should be used to store data such as the GUID and opt-out status * @@ -418,7 +418,7 @@ public class Metrics { // return => base/plugins/PluginMetrics/config.yml return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml"); } - + /** * Generic method that posts a plugin to the metrics website */ @@ -557,7 +557,7 @@ public class Metrics { } } } - + /** * Check if mineshafter is present. If it is, we need to bypass it to send POST requests * @@ -571,7 +571,7 @@ public class Metrics { return false; } } - + /** * Represents a custom graph on the website */ @@ -585,11 +585,11 @@ public class Metrics { * The set of plotters that are contained within this graph */ private final Set plotters = new LinkedHashSet(); - + private Graph(final String name) { this.name = name; } - + /** * Gets the graph's name * @@ -598,7 +598,7 @@ public class Metrics { public String getName() { return this.name; } - + /** * Add a plotter to the graph, which will be used to plot entries * @@ -607,7 +607,7 @@ public class Metrics { public void addPlotter(final Plotter plotter) { this.plotters.add(plotter); } - + /** * Remove a plotter from the graph * @@ -616,7 +616,7 @@ public class Metrics { public void removePlotter(final Plotter plotter) { this.plotters.remove(plotter); } - + /** * Gets an unmodifiable set of the plotter objects in the graph * @@ -625,12 +625,12 @@ public class Metrics { public Set getPlotters() { return Collections.unmodifiableSet(this.plotters); } - + @Override public int hashCode() { return this.name.hashCode(); } - + @Override public boolean equals(final Object object) { if (!(object instanceof Graph)) { @@ -639,14 +639,14 @@ public class Metrics { final Graph graph = (Graph) object; return graph.name.equals(this.name); } - + /** * Called when the server owner decides to opt-out of BukkitMetrics while the server is running. */ protected void onOptOut() { } } - + /** * Interface used to collect custom data for a plugin */ @@ -655,14 +655,14 @@ public class Metrics { * The plot's name */ private final String name; - + /** * Construct a plotter with the default plot name */ public Plotter() { this("Default"); } - + /** * Construct a plotter with a specific plot name * @@ -671,7 +671,7 @@ public class Metrics { public Plotter(final String name) { this.name = name; } - + /** * Get the current value for the plotted point. Since this function defers to an external function it may or may * not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called @@ -680,7 +680,7 @@ public class Metrics { * @return the current value for the point to be plotted. */ public abstract int getValue(); - + /** * Get the column name for the plotted point * @@ -689,18 +689,18 @@ public class Metrics { public String getColumnName() { return this.name; } - + /** * Called after the website graphs have been updated */ public void reset() { } - + @Override public int hashCode() { return getColumnName().hashCode(); } - + @Override public boolean equals(final Object object) { if (!(object instanceof Plotter)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index e9b68b1a9..04ba415cf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -44,7 +44,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; public class PWE { public static void setMask(final PlotPlayer p, final Location l, final boolean force) { try { - LocalSession s = WorldEdit.getInstance().getSession(p.getName()); + final LocalSession s = WorldEdit.getInstance().getSession(p.getName()); if (!PlotSquared.isPlotWorld(l.getWorld())) { removeMask(p); } @@ -63,8 +63,7 @@ public class PWE { final Vector bvec = new Vector(bloc.getX() + 1, bloc.getY(), bloc.getZ() + 1); final Vector tvec = new Vector(tloc.getX(), tloc.getY(), tloc.getZ()); - - // FIXME unchecked casting + // FIXME unchecked casting final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player).getWorld(); final CuboidRegion region = new CuboidRegion(lw, bvec, tvec); final RegionMask mask = new RegionMask(region); @@ -74,7 +73,7 @@ public class PWE { } } if (force ^ (noMask(s) && !p.hasPermission("plots.worldedit.bypass"))) { - // FIXME unchecked casting + // FIXME unchecked casting final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); @@ -83,20 +82,20 @@ public class PWE { e.printStackTrace(); } } - + public static boolean hasMask(final PlotPlayer p) { - LocalSession s = WorldEdit.getInstance().getSession(p.getName()); + final LocalSession s = WorldEdit.getInstance().getSession(p.getName()); return !noMask(s); } - + public static boolean noMask(final LocalSession s) { return s.getMask() == null; } - + @SuppressWarnings("deprecation") public static void setNoMask(final PlotPlayer p) { try { - LocalSession s = WorldEdit.getInstance().getSession(p.getName()); + final LocalSession s = WorldEdit.getInstance().getSession(p.getName()); final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); @@ -104,15 +103,15 @@ public class PWE { // } } - + public static void removeMask(final PlotPlayer p, final LocalSession s) { final Mask mask = null; s.setMask(mask); } - + public static void removeMask(final PlotPlayer p) { try { - LocalSession s = WorldEdit.getInstance().getSession(p.getName()); + final LocalSession s = WorldEdit.getInstance().getSession(p.getName()); removeMask(p, s); } catch (final Exception e) { // throw new diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java index faa2cd2d3..f0b3eac37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java @@ -37,7 +37,7 @@ public class SendChunk { private static RefField world; // Ref Constructor private static RefConstructor ChunkCoordIntPairCon; - + /** * Constructor * @@ -52,7 +52,7 @@ public class SendChunk { world = classChunk.getField("world"); ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); } - + public static void sendChunk(final List chunks) { int diffx, diffz; final int view = Bukkit.getServer().getViewDistance() << 4; @@ -73,7 +73,7 @@ public class SendChunk { } } } - + public static void sendChunk(final String worldname, final List locs) { final World myworld = Bukkit.getWorld(worldname); final ArrayList chunks = new ArrayList<>(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index 8e12c094c..740b51295 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -45,7 +45,7 @@ public class SetBlockFast extends SetBlockManager { private static RefMethod methodGetChunkAt; private static RefMethod methodA; private static RefMethod methodGetById; - + /** * Constructor * @@ -57,7 +57,7 @@ public class SetBlockFast extends SetBlockManager { methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class); methodGetById = classBlock.getMethod("getById", int.class); } - + /** * Set the block at the location * @@ -77,7 +77,7 @@ public class SetBlockFast extends SetBlockManager { final Object block = methodGetById.of(null).call(blockId); methodA.of(chunk).call(x & 0x0f, y, z & 0x0f, block, data); } - + /** * Update chunks * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 65bd2eea8..29592ae0f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -50,7 +50,7 @@ public class SetBlockFast_1_8 extends SetBlockManager { private static RefMethod methodA; private static RefMethod methodGetByCombinedId; private static RefConstructor constructorBlockPosition; - + /** * Constructor * @@ -63,7 +63,7 @@ public class SetBlockFast_1_8 extends SetBlockManager { methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); methodA = classChunk.getMethod("a", classBlockPosition, classIBlockData); } - + /** * Set the block at the location * @@ -120,7 +120,7 @@ public class SetBlockFast_1_8 extends SetBlockManager { final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12)); methodA.of(chunk).call(pos, combined); } - + /** * Update chunks * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockManager.java index 10bff0953..adeb1e74e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockManager.java @@ -11,16 +11,16 @@ import com.intellectualcrafters.plot.util.AbstractSetBlock; public abstract class SetBlockManager extends AbstractSetBlock { public static SetBlockManager setBlockManager = null; - + public abstract void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data); - + public abstract void update(List list); - + @Override - public void update(String worldname, List chunkLocs) { - World world = BukkitUtil.getWorld(worldname); - ArrayList chunks = new ArrayList(); - for (ChunkLoc loc : chunkLocs) { + public void update(final String worldname, final List chunkLocs) { + final World world = BukkitUtil.getWorld(worldname); + final ArrayList chunks = new ArrayList(); + for (final ChunkLoc loc : chunkLocs) { chunks.add(world.getChunkAt(loc.x, loc.z)); } setBlockManager.update(chunks); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java index 1ea698a31..ea15a158b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java @@ -22,7 +22,7 @@ public class SetBlockSlow extends SetBlockManager { } } } - + @Override public void update(final List chunks) { // TODO Auto-generated method stub diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index a57033c51..0f0db3751 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -23,14 +23,14 @@ public class UUIDHandler { public static boolean CACHED = false; public static UUIDWrapper uuidWrapper = null; public static HashMap players = new HashMap<>(); - + /** * Map containing names and UUIDs * * @see com.google.common.collect.BiMap */ private final static BiMap uuidMap = HashBiMap.create(new HashMap()); - + public static void add(final StringWrapper name, final UUID uuid) { if ((uuid == null) || (name == null)) { return; @@ -39,7 +39,7 @@ public class UUIDHandler { uuidMap.put(name, uuid); } } - + /** * Get the map containing all names/uuids * @@ -50,7 +50,7 @@ public class UUIDHandler { public static BiMap getUuidMap() { return uuidMap; } - + /** * Check if a uuid is cached * @@ -63,7 +63,7 @@ public class UUIDHandler { public static boolean uuidExists(final UUID uuid) { return uuidMap.containsValue(uuid); } - + /** * Check if a name is cached * @@ -76,8 +76,8 @@ public class UUIDHandler { public static boolean nameExists(final StringWrapper name) { return uuidMap.containsKey(name); } - - public static void cacheAll(String world) { + + public static void cacheAll(final String world) { if (CACHED) { return; } @@ -142,15 +142,15 @@ public class UUIDHandler { add(new StringWrapper("*"), DBFunc.everyone); PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); } - + public static UUID getUUID(final PlotPlayer player) { return UUIDHandler.uuidWrapper.getUUID(player); } - + public static UUID getUUID(final BukkitOfflinePlayer player) { return UUIDHandler.uuidWrapper.getUUID(player); } - + public static String getName(final UUID uuid) { if (uuid == null) { return null; @@ -167,20 +167,20 @@ public class UUIDHandler { } return null; } - - public static PlotPlayer getPlayer(UUID uuid) { - for (PlotPlayer player : players.values()) { + + public static PlotPlayer getPlayer(final UUID uuid) { + for (final PlotPlayer player : players.values()) { if (player.getUUID().equals(uuid)) { return player; } } return null; } - - public static PlotPlayer getPlayer(String name) { + + public static PlotPlayer getPlayer(final String name) { return players.get(name); } - + public static UUID getUUID(final String name) { if ((name == null) || (name.length() == 0)) { return null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java index f3d6a78b8..890a61989 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/DefaultUUIDWrapper.java @@ -13,17 +13,17 @@ public class DefaultUUIDWrapper extends UUIDWrapper { public UUID getUUID(final PlotPlayer player) { return ((BukkitPlayer) player).player.getUniqueId(); } - + @Override public UUID getUUID(final BukkitOfflinePlayer player) { return player.getUUID(); } - + @Override public BukkitOfflinePlayer getOfflinePlayer(final UUID uuid) { return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid)); } - + @Override public UUID getUUID(final String name) { return Bukkit.getOfflinePlayer(name).getUniqueId(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java index 106860259..7faa7ad41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java @@ -20,7 +20,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class OfflineUUIDWrapper extends UUIDWrapper { private Method getOnline = null; private final Object[] arg = new Object[0]; - + public OfflineUUIDWrapper() { try { this.getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]); @@ -30,21 +30,21 @@ public class OfflineUUIDWrapper extends UUIDWrapper { e.printStackTrace(); } } - + @Override public UUID getUUID(final PlotPlayer player) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); } - + @Override public UUID getUUID(final BukkitOfflinePlayer player) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); } - + public UUID getUUID(final OfflinePlayer player) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)); } - + @Override public BukkitOfflinePlayer getOfflinePlayer(final UUID uuid) { final BiMap map = UUIDHandler.getUuidMap().inverse(); @@ -67,7 +67,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper { } return null; } - + public Player[] getOnlinePlayers() { if (this.getOnline == null) { return Bukkit.getOnlinePlayers().toArray(new Player[0]); @@ -87,7 +87,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper { return Bukkit.getOnlinePlayers().toArray(new Player[0]); } } - + @Override public UUID getUUID(final String name) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java index 33b5623a6..b325f9df0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDWrapper.java @@ -7,10 +7,10 @@ import com.intellectualcrafters.plot.object.PlotPlayer; public abstract class UUIDWrapper { public abstract UUID getUUID(PlotPlayer player); - + public abstract UUID getUUID(BukkitOfflinePlayer player); - + public abstract UUID getUUID(String name); - + public abstract BukkitOfflinePlayer getOfflinePlayer(UUID uuid); } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java b/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java index b05140163..6476cd624 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/Translation.java @@ -14,6 +14,6 @@ import java.lang.annotation.Target; @Target(ElementType.FIELD) public @interface Translation { String description() default ""; - + String creationDescription() default ""; } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java index 4973fcf2b..62ef22d96 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java @@ -9,21 +9,21 @@ public class TranslationAsset { private final TranslationObject trans; private final String translated; private final TranslationLanguage lang; - + public TranslationAsset(final TranslationObject trans, final String translated, final TranslationLanguage lang) { this.trans = trans; this.translated = translated; this.lang = lang; } - + public TranslationObject getObject() { return this.trans; } - + public String getTranslated() { return this.translated.replace("\n", "&-"); } - + public TranslationLanguage getLang() { return this.lang; } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java index 074bb3349..5ee23690a 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationFile.java @@ -12,19 +12,19 @@ public abstract class TranslationFile { * @return language */ public abstract TranslationLanguage getLanguage(); - + /** * Save the file */ public abstract void saveFile(); - + /** * Read from the file * * @return instance */ public abstract TranslationFile read(); - + /** * Add a value * diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java index 85e284a77..f02033f7e 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java @@ -8,29 +8,29 @@ public class TranslationLanguage { private final String countryCode; private final String languageCode; private final String friendlyName; - + public TranslationLanguage(final String friendlyName, final String countryCode, final String languageCode) { this.friendlyName = friendlyName; this.countryCode = countryCode; this.languageCode = languageCode; } - + public static TranslationLanguage[] values() { return new TranslationLanguage[] { englishAmerican, englishBritish, swedishSwedish }; } - + public String getName() { return this.friendlyName; } - + public String getCountryCode() { return this.countryCode; } - + public String getLanguageCode() { return this.languageCode; } - + @Override public String toString() { /* en_US */ diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java index 1c0cfa2ac..16e9ca51f 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java @@ -23,14 +23,14 @@ public class TranslationManager { * The translations */ private final LinkedHashMap translatedObjects; - + /** * Constructor */ public TranslationManager() { this(new TranslationObject[] {}); } - + /** * Constructor * @@ -40,7 +40,7 @@ public class TranslationManager { this.translationObjects = new LinkedList(Arrays.asList(translationObjects)); this.translatedObjects = new LinkedHashMap(); } - + public static List transformEnum(final Object[] os) { final List eList = new ArrayList(); for (final Object o : os) { @@ -48,7 +48,7 @@ public class TranslationManager { } return eList; } - + public static void scan(final Class c, final TranslationManager manager) throws IllegalAccessException { final Field[] fields = c.getDeclaredFields(); Annotation annotation; @@ -64,7 +64,7 @@ public class TranslationManager { manager.addTranslationObject(new TranslationObject(key, defaultValue, t.description(), t.creationDescription())); } } - + /** * Don't use this! * @@ -73,7 +73,7 @@ public class TranslationManager { public TranslationManager instance() { return this; } - + /** * Get the translation objects * @@ -82,7 +82,7 @@ public class TranslationManager { public List translations() { return this.translationObjects; } - + /** * Add an object * @@ -94,7 +94,7 @@ public class TranslationManager { this.translationObjects.add(t); return instance(); } - + /** * Remove an object * @@ -106,7 +106,7 @@ public class TranslationManager { this.translationObjects.remove(t); return instance(); } - + public String getDescription(final String key) { for (final TranslationObject o : translations()) { if (o.getKey().equals(key) && !o.getDescription().equals("")) { @@ -115,11 +115,11 @@ public class TranslationManager { } return ""; } - + public TranslationManager addTranslation(final TranslationObject t, final TranslationAsset a) { return addTranslation(t.getKey(), a); } - + public TranslationManager addTranslation(final String key, final TranslationAsset a) { String eKey = key + "." + a.getLang().toString(); eKey = eKey.toLowerCase(); @@ -129,7 +129,7 @@ public class TranslationManager { this.translatedObjects.put(eKey, a); return instance(); } - + public TranslationAsset getTranslated(final String key, final String language) { String eKey = key + "." + language; eKey = eKey.toLowerCase(); @@ -138,7 +138,7 @@ public class TranslationManager { } return this.translatedObjects.get(key); } - + public TranslationAsset getTranslated(final String key, final TranslationLanguage language) { String eKey = key + "." + language.toString(); eKey = eKey.toLowerCase(); @@ -147,15 +147,15 @@ public class TranslationManager { } return this.translatedObjects.get(eKey); } - + public TranslationAsset getTranslated(final TranslationObject t, final TranslationLanguage l) { return getTranslated(t.getKey(), l); } - + public String getTranslation(final String key, final TranslationLanguage l) { return getTranslated(key, l).getTranslated(); } - + public TranslationObject getDefault(final String key) { for (final TranslationObject o : translations()) { if (o.getKey().equals(key.toLowerCase())) { @@ -164,7 +164,7 @@ public class TranslationManager { } return null; } - + public TranslationManager saveAll(final TranslationFile file) { for (final TranslationObject object : translations()) { final TranslationAsset o = getTranslated(object.getKey(), file.getLanguage()); @@ -172,7 +172,7 @@ public class TranslationManager { } return instance(); } - + public TranslationManager debug(final PrintStream out) { for (final TranslationObject object : translations()) { out.println(object.getKey() + ":"); @@ -182,7 +182,7 @@ public class TranslationManager { } return instance(); } - + public TranslationManager saveFile(final TranslationFile file) { file.saveFile(); return instance(); diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java index e4deb1934..814d4aa6b 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java @@ -9,7 +9,7 @@ public class TranslationObject { private final String description; // Like a plugin name for example | can be null private final String creationDescription; - + public TranslationObject(final String key, final String defaultValue, String description, String creationDescription) { if (description == null) { description = ""; @@ -27,19 +27,19 @@ public class TranslationObject { this.description = description; this.creationDescription = creationDescription; } - + public String getKey() { return this.key; } - + public String getDefaultValue() { return this.defaultValue; } - + public String getDescription() { return this.description; } - + public String getCreationDescription() { return this.creationDescription; } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java index 7b41e9c91..82021070e 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java @@ -29,7 +29,7 @@ public class YamlTranslationFile extends TranslationFile { * YAML Object */ private Yaml yaml; - + /** * Constructor * @@ -59,7 +59,7 @@ public class YamlTranslationFile extends TranslationFile { this.instance = this; this.instance = this; } - + /** * Reload */ @@ -67,7 +67,7 @@ public class YamlTranslationFile extends TranslationFile { this.map = new HashMap(); this.read(); } - + /** * Set the header * @@ -80,7 +80,7 @@ public class YamlTranslationFile extends TranslationFile { this.fancyHead = false; return this.instance; } - + /** * Set a fancy header * @@ -106,7 +106,7 @@ public class YamlTranslationFile extends TranslationFile { this.fancyHead = true; return this.instance; } - + /** * Add a translation * @@ -120,7 +120,7 @@ public class YamlTranslationFile extends TranslationFile { } this.map.put(key, value); } - + /** * Get the translation language * @@ -130,7 +130,7 @@ public class YamlTranslationFile extends TranslationFile { public TranslationLanguage getLanguage() { return this.language; } - + /** * Save the file */ @@ -166,7 +166,7 @@ public class YamlTranslationFile extends TranslationFile { e.printStackTrace(); } } - + /** * Get the YAML object * @@ -184,7 +184,7 @@ public class YamlTranslationFile extends TranslationFile { } return this.yaml; } - + /** * Read the file * diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java index 04c9b23f3..32b47622b 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java @@ -27,7 +27,7 @@ public class BukkitTranslation { // &- = new line return asset.getTranslated().replace("&-", "\n").replace('&', '\u00A7'); } - + /** * Get the universal parent based on the plugin data folder * @@ -38,7 +38,7 @@ public class BukkitTranslation { public static File getParent() { return new File(PlotSquared.IMP.getDirectory() + File.separator + "translations"); } - + /** * The default translation language * @@ -47,7 +47,7 @@ public class BukkitTranslation { public TranslationLanguage getDefaultLanguage() { return TranslationLanguage.englishAmerican; } - + /** * Add material names to the translation list Will default to a somewhat friendly name */ diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java index 7fcf92f9a..091e64610 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/TranslationPlugin.java @@ -17,7 +17,7 @@ public class TranslationPlugin extends JavaPlugin { private static final String TRANSLATOR_DISABLED = "The translator has been disabled"; private static TranslationManager manager; private TranslationFile english; - + @Override public void onEnable() { // Create a new manager @@ -33,7 +33,7 @@ public class TranslationPlugin extends JavaPlugin { // That created the file, read it, and made a default header getLogger().log(Level.INFO, BukkitTranslation.convert(manager.getTranslated("translator_loaded", TranslationLanguage.englishAmerican))); } - + @Override public void onDisable() { // Add all translations and save the file