mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
cleanup
This commit is contained in:
parent
dea6e84407
commit
0d382ac9c3
@ -4,7 +4,6 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Byte_Array} tag.
|
* The {@code TAG_Byte_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class ByteArrayTag extends Tag {
|
public final class ByteArrayTag extends Tag {
|
||||||
|
|
||||||
private final byte[] value;
|
private final byte[] value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,5 +49,4 @@ public final class ByteArrayTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Byte_Array" + append + ": " + hex;
|
return "TAG_Byte_Array" + append + ": " + hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Byte} tag.
|
* The {@code TAG_Byte} tag.
|
||||||
*/
|
*/
|
||||||
public final class ByteTag extends Tag {
|
public final class ByteTag extends Tag {
|
||||||
|
|
||||||
private final byte value;
|
private final byte value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,5 +41,4 @@ public final class ByteTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Byte" + append + ": " + this.value;
|
return "TAG_Byte" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import java.util.Map;
|
|||||||
* The {@code TAG_Compound} tag.
|
* The {@code TAG_Compound} tag.
|
||||||
*/
|
*/
|
||||||
public final class CompoundTag extends Tag {
|
public final class CompoundTag extends Tag {
|
||||||
|
|
||||||
private final Map<String, Tag> value;
|
private final Map<String, Tag> value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,22 +131,16 @@ public final class CompoundTag extends Tag {
|
|||||||
final Tag tag = this.value.get(key);
|
final Tag tag = this.value.get(key);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
return ((ShortTag) tag).getValue();
|
return ((ShortTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof IntTag) {
|
} else if (tag instanceof IntTag) {
|
||||||
return ((IntTag) tag).getValue();
|
return ((IntTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof LongTag) {
|
} else if (tag instanceof LongTag) {
|
||||||
return ((LongTag) tag).getValue();
|
return ((LongTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof FloatTag) {
|
} else if (tag instanceof FloatTag) {
|
||||||
return ((FloatTag) tag).getValue();
|
return ((FloatTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof DoubleTag) {
|
} else if (tag instanceof DoubleTag) {
|
||||||
return ((DoubleTag) tag).getValue();
|
return ((DoubleTag) tag).getValue();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -216,22 +209,16 @@ public final class CompoundTag extends Tag {
|
|||||||
final Tag tag = this.value.get(key);
|
final Tag tag = this.value.get(key);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
return ((ShortTag) tag).getValue();
|
return ((ShortTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof IntTag) {
|
} else if (tag instanceof IntTag) {
|
||||||
return ((IntTag) tag).getValue();
|
return ((IntTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof LongTag) {
|
} else if (tag instanceof LongTag) {
|
||||||
return ((LongTag) tag).getValue().intValue();
|
return ((LongTag) tag).getValue().intValue();
|
||||||
|
|
||||||
} else if (tag instanceof FloatTag) {
|
} else if (tag instanceof FloatTag) {
|
||||||
return ((FloatTag) tag).getValue().intValue();
|
return ((FloatTag) tag).getValue().intValue();
|
||||||
|
|
||||||
} else if (tag instanceof DoubleTag) {
|
} else if (tag instanceof DoubleTag) {
|
||||||
return ((DoubleTag) tag).getValue().intValue();
|
return ((DoubleTag) tag).getValue().intValue();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -267,7 +254,7 @@ public final class CompoundTag extends Tag {
|
|||||||
if (tag instanceof ListTag) {
|
if (tag instanceof ListTag) {
|
||||||
return (ListTag) tag;
|
return (ListTag) tag;
|
||||||
} else {
|
} else {
|
||||||
return new ListTag(key, StringTag.class, Collections.<Tag>emptyList());
|
return new ListTag(key, StringTag.class, Collections.<Tag> emptyList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,22 +313,16 @@ public final class CompoundTag extends Tag {
|
|||||||
final Tag tag = this.value.get(key);
|
final Tag tag = this.value.get(key);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
return ((ShortTag) tag).getValue();
|
return ((ShortTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof IntTag) {
|
} else if (tag instanceof IntTag) {
|
||||||
return ((IntTag) tag).getValue();
|
return ((IntTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof LongTag) {
|
} else if (tag instanceof LongTag) {
|
||||||
return ((LongTag) tag).getValue();
|
return ((LongTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof FloatTag) {
|
} else if (tag instanceof FloatTag) {
|
||||||
return ((FloatTag) tag).getValue().longValue();
|
return ((FloatTag) tag).getValue().longValue();
|
||||||
|
|
||||||
} else if (tag instanceof DoubleTag) {
|
} else if (tag instanceof DoubleTag) {
|
||||||
return ((DoubleTag) tag).getValue().longValue();
|
return ((DoubleTag) tag).getValue().longValue();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
@ -396,5 +377,4 @@ public final class CompoundTag extends Tag {
|
|||||||
bldr.append("}");
|
bldr.append("}");
|
||||||
return bldr.toString();
|
return bldr.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import java.util.Map;
|
|||||||
* Helps create compound tags.
|
* Helps create compound tags.
|
||||||
*/
|
*/
|
||||||
public class CompoundTagBuilder {
|
public class CompoundTagBuilder {
|
||||||
|
|
||||||
private final Map<String, Tag> entries;
|
private final Map<String, Tag> entries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,5 +194,4 @@ public class CompoundTagBuilder {
|
|||||||
public CompoundTag build(final String name) {
|
public CompoundTag build(final String name) {
|
||||||
return new CompoundTag(name, new HashMap<String, Tag>(this.entries));
|
return new CompoundTag(name, new HashMap<String, Tag>(this.entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Double} tag.
|
* The {@code TAG_Double} tag.
|
||||||
*/
|
*/
|
||||||
public final class DoubleTag extends Tag {
|
public final class DoubleTag extends Tag {
|
||||||
|
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,5 +41,4 @@ public final class DoubleTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Double" + append + ": " + this.value;
|
return "TAG_Double" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_End} tag.
|
* The {@code TAG_End} tag.
|
||||||
*/
|
*/
|
||||||
public final class EndTag extends Tag {
|
public final class EndTag extends Tag {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the tag.
|
* Creates the tag.
|
||||||
*/
|
*/
|
||||||
@ -21,5 +20,4 @@ public final class EndTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "TAG_End";
|
return "TAG_End";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Float} tag.
|
* The {@code TAG_Float} tag.
|
||||||
*/
|
*/
|
||||||
public final class FloatTag extends Tag {
|
public final class FloatTag extends Tag {
|
||||||
|
|
||||||
private final float value;
|
private final float value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,5 +41,4 @@ public final class FloatTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Float" + append + ": " + this.value;
|
return "TAG_Float" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* The {@code TAG_Int_Array} tag.
|
* The {@code TAG_Int_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class IntArrayTag extends Tag {
|
public final class IntArrayTag extends Tag {
|
||||||
|
|
||||||
private final int[] value;
|
private final int[] value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,5 +53,4 @@ public final class IntArrayTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Int_Array" + append + ": " + hex;
|
return "TAG_Int_Array" + append + ": " + hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Int} tag.
|
* The {@code TAG_Int} tag.
|
||||||
*/
|
*/
|
||||||
public final class IntTag extends Tag {
|
public final class IntTag extends Tag {
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,5 +41,4 @@ public final class IntTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Int" + append + ": " + this.value;
|
return "TAG_Int" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import javax.annotation.Nullable;
|
|||||||
* The {@code TAG_List} tag.
|
* The {@code TAG_List} tag.
|
||||||
*/
|
*/
|
||||||
public final class ListTag extends Tag {
|
public final class ListTag extends Tag {
|
||||||
|
|
||||||
private final Class<? extends Tag> type;
|
private final Class<? extends Tag> type;
|
||||||
private final List<Tag> value;
|
private final List<Tag> value;
|
||||||
|
|
||||||
@ -147,22 +146,16 @@ public final class ListTag extends Tag {
|
|||||||
final Tag tag = getIfExists(index);
|
final Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
return ((ShortTag) tag).getValue();
|
return ((ShortTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof IntTag) {
|
} else if (tag instanceof IntTag) {
|
||||||
return ((IntTag) tag).getValue();
|
return ((IntTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof LongTag) {
|
} else if (tag instanceof LongTag) {
|
||||||
return ((LongTag) tag).getValue();
|
return ((LongTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof FloatTag) {
|
} else if (tag instanceof FloatTag) {
|
||||||
return ((FloatTag) tag).getValue();
|
return ((FloatTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof DoubleTag) {
|
} else if (tag instanceof DoubleTag) {
|
||||||
return ((DoubleTag) tag).getValue();
|
return ((DoubleTag) tag).getValue();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -231,22 +224,16 @@ public final class ListTag extends Tag {
|
|||||||
final Tag tag = getIfExists(index);
|
final Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
return ((ShortTag) tag).getValue();
|
return ((ShortTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof IntTag) {
|
} else if (tag instanceof IntTag) {
|
||||||
return ((IntTag) tag).getValue();
|
return ((IntTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof LongTag) {
|
} else if (tag instanceof LongTag) {
|
||||||
return ((LongTag) tag).getValue().intValue();
|
return ((LongTag) tag).getValue().intValue();
|
||||||
|
|
||||||
} else if (tag instanceof FloatTag) {
|
} else if (tag instanceof FloatTag) {
|
||||||
return ((FloatTag) tag).getValue().intValue();
|
return ((FloatTag) tag).getValue().intValue();
|
||||||
|
|
||||||
} else if (tag instanceof DoubleTag) {
|
} else if (tag instanceof DoubleTag) {
|
||||||
return ((DoubleTag) tag).getValue().intValue();
|
return ((DoubleTag) tag).getValue().intValue();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -282,7 +269,7 @@ public final class ListTag extends Tag {
|
|||||||
if (tag instanceof ListTag) {
|
if (tag instanceof ListTag) {
|
||||||
return (ListTag) tag;
|
return (ListTag) tag;
|
||||||
} else {
|
} else {
|
||||||
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
|
return new ListTag(StringTag.class, Collections.<Tag> emptyList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,22 +328,16 @@ public final class ListTag extends Tag {
|
|||||||
final Tag tag = getIfExists(index);
|
final Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
return ((ShortTag) tag).getValue();
|
return ((ShortTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof IntTag) {
|
} else if (tag instanceof IntTag) {
|
||||||
return ((IntTag) tag).getValue();
|
return ((IntTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof LongTag) {
|
} else if (tag instanceof LongTag) {
|
||||||
return ((LongTag) tag).getValue();
|
return ((LongTag) tag).getValue();
|
||||||
|
|
||||||
} else if (tag instanceof FloatTag) {
|
} else if (tag instanceof FloatTag) {
|
||||||
return ((FloatTag) tag).getValue().longValue();
|
return ((FloatTag) tag).getValue().longValue();
|
||||||
|
|
||||||
} else if (tag instanceof DoubleTag) {
|
} else if (tag instanceof DoubleTag) {
|
||||||
return ((DoubleTag) tag).getValue().longValue();
|
return ((DoubleTag) tag).getValue().longValue();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -411,5 +392,4 @@ public final class ListTag extends Tag {
|
|||||||
bldr.append("}");
|
bldr.append("}");
|
||||||
return bldr.toString();
|
return bldr.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import java.util.List;
|
|||||||
* Helps create list tags.
|
* Helps create list tags.
|
||||||
*/
|
*/
|
||||||
public class ListTagBuilder {
|
public class ListTagBuilder {
|
||||||
|
|
||||||
private final Class<? extends Tag> type;
|
private final Class<? extends Tag> type;
|
||||||
private final List<Tag> entries;
|
private final List<Tag> entries;
|
||||||
|
|
||||||
@ -43,18 +42,15 @@ public class ListTagBuilder {
|
|||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public static <T extends Tag> ListTagBuilder createWith(final T... entries) {
|
public static <T extends Tag> ListTagBuilder createWith(final T... entries) {
|
||||||
checkNotNull(entries);
|
checkNotNull(entries);
|
||||||
|
|
||||||
if (entries.length == 0) {
|
if (entries.length == 0) {
|
||||||
throw new IllegalArgumentException("This method needs an array of at least one entry");
|
throw new IllegalArgumentException("This method needs an array of at least one entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Class<? extends Tag> type = entries[0].getClass();
|
final Class<? extends Tag> type = entries[0].getClass();
|
||||||
for (int i = 1; i < entries.length; i++) {
|
for (int i = 1; i < entries.length; i++) {
|
||||||
if (!type.isInstance(entries[i])) {
|
if (!type.isInstance(entries[i])) {
|
||||||
throw new IllegalArgumentException("An array of different tag types was provided");
|
throw new IllegalArgumentException("An array of different tag types was provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ListTagBuilder builder = new ListTagBuilder(type);
|
final ListTagBuilder builder = new ListTagBuilder(type);
|
||||||
builder.addAll(Arrays.asList(entries));
|
builder.addAll(Arrays.asList(entries));
|
||||||
return builder;
|
return builder;
|
||||||
@ -110,5 +106,4 @@ public class ListTagBuilder {
|
|||||||
public ListTag build(final String name) {
|
public ListTag build(final String name) {
|
||||||
return new ListTag(name, this.type, new ArrayList<Tag>(this.entries));
|
return new ListTag(name, this.type, new ArrayList<Tag>(this.entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Long} tag.
|
* The {@code TAG_Long} tag.
|
||||||
*/
|
*/
|
||||||
public final class LongTag extends Tag {
|
public final class LongTag extends Tag {
|
||||||
|
|
||||||
private final long value;
|
private final long value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,5 +41,4 @@ public final class LongTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Long" + append + ": " + this.value;
|
return "TAG_Long" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.jnbt;
|
package com.intellectualcrafters.jnbt;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@ -27,16 +26,13 @@ import java.nio.charset.Charset;
|
|||||||
* A class which holds constant values.
|
* A class which holds constant values.
|
||||||
*/
|
*/
|
||||||
public final class NBTConstants {
|
public final class NBTConstants {
|
||||||
|
|
||||||
public static final Charset CHARSET = Charset.forName("UTF-8");
|
public static final Charset CHARSET = Charset.forName("UTF-8");
|
||||||
|
|
||||||
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
|
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor.
|
* Default private constructor.
|
||||||
*/
|
*/
|
||||||
private NBTConstants() {
|
private NBTConstants() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,5 +74,4 @@ public final class NBTConstants {
|
|||||||
throw new IllegalArgumentException("Unknown tag type ID of " + id);
|
throw new IllegalArgumentException("Unknown tag type ID of " + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import java.util.Map;
|
|||||||
* may be found at <a href="http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt</a>. </p>
|
* may be found at <a href="http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt</a>. </p>
|
||||||
*/
|
*/
|
||||||
public final class NBTInputStream implements Closeable {
|
public final class NBTInputStream implements Closeable {
|
||||||
|
|
||||||
private final DataInputStream is;
|
private final DataInputStream is;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +50,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
*/
|
*/
|
||||||
private Tag readTag(final int depth) throws IOException {
|
private Tag readTag(final int depth) throws IOException {
|
||||||
final int type = this.is.readByte() & 0xFF;
|
final int type = this.is.readByte() & 0xFF;
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
if (type != NBTConstants.TYPE_END) {
|
if (type != NBTConstants.TYPE_END) {
|
||||||
final int nameLength = this.is.readShort() & 0xFFFF;
|
final int nameLength = this.is.readShort() & 0xFFFF;
|
||||||
@ -61,7 +59,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
} else {
|
} else {
|
||||||
name = "";
|
name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return readTagPayload(type, name, depth);
|
return readTagPayload(type, name, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +106,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
case NBTConstants.TYPE_LIST:
|
case NBTConstants.TYPE_LIST:
|
||||||
final int childType = this.is.readByte();
|
final int childType = this.is.readByte();
|
||||||
length = this.is.readInt();
|
length = this.is.readInt();
|
||||||
|
|
||||||
final List<Tag> tagList = new ArrayList<Tag>();
|
final List<Tag> tagList = new ArrayList<Tag>();
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
final Tag tag = readTagPayload(childType, "", depth + 1);
|
final Tag tag = readTagPayload(childType, "", depth + 1);
|
||||||
@ -118,7 +114,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
}
|
}
|
||||||
tagList.add(tag);
|
tagList.add(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
|
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
|
||||||
case NBTConstants.TYPE_COMPOUND:
|
case NBTConstants.TYPE_COMPOUND:
|
||||||
final Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
final Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
||||||
@ -130,7 +125,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
tagMap.put(tag.getName(), tag);
|
tagMap.put(tag.getName(), tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CompoundTag(name, tagMap);
|
return new CompoundTag(name, tagMap);
|
||||||
case NBTConstants.TYPE_INT_ARRAY:
|
case NBTConstants.TYPE_INT_ARRAY:
|
||||||
length = this.is.readInt();
|
length = this.is.readInt();
|
||||||
@ -148,5 +142,4 @@ public final class NBTInputStream implements Closeable {
|
|||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
this.is.close();
|
this.is.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.jnbt;
|
package com.intellectualcrafters.jnbt;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@ -36,7 +35,6 @@ import java.util.List;
|
|||||||
* @author Graham Edgecombe
|
* @author Graham Edgecombe
|
||||||
*/
|
*/
|
||||||
public final class NBTOutputStream implements Closeable {
|
public final class NBTOutputStream implements Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The output stream.
|
* The output stream.
|
||||||
*/
|
*/
|
||||||
@ -64,15 +62,12 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
final int type = NBTUtils.getTypeCode(tag.getClass());
|
final int type = NBTUtils.getTypeCode(tag.getClass());
|
||||||
final String name = tag.getName();
|
final String name = tag.getName();
|
||||||
final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
|
final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
|
||||||
|
|
||||||
this.os.writeByte(type);
|
this.os.writeByte(type);
|
||||||
this.os.writeShort(nameBytes.length);
|
this.os.writeShort(nameBytes.length);
|
||||||
this.os.write(nameBytes);
|
this.os.write(nameBytes);
|
||||||
|
|
||||||
if (type == NBTConstants.TYPE_END) {
|
if (type == NBTConstants.TYPE_END) {
|
||||||
throw new IOException("Named TAG_End not permitted.");
|
throw new IOException("Named TAG_End not permitted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
writeTagPayload(tag);
|
writeTagPayload(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +171,6 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
final Class<? extends Tag> clazz = tag.getType();
|
final Class<? extends Tag> clazz = tag.getType();
|
||||||
final List<Tag> tags = tag.getValue();
|
final List<Tag> tags = tag.getValue();
|
||||||
final int size = tags.size();
|
final int size = tags.size();
|
||||||
|
|
||||||
this.os.writeByte(NBTUtils.getTypeCode(clazz));
|
this.os.writeByte(NBTUtils.getTypeCode(clazz));
|
||||||
this.os.writeInt(size);
|
this.os.writeInt(size);
|
||||||
for (final Tag tag1 : tags) {
|
for (final Tag tag1 : tags) {
|
||||||
@ -275,5 +269,4 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
this.os.close();
|
this.os.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import java.util.Map;
|
|||||||
* A class which contains NBT-related utility methods.
|
* A class which contains NBT-related utility methods.
|
||||||
*/
|
*/
|
||||||
public final class NBTUtils {
|
public final class NBTUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor.
|
* Default private constructor.
|
||||||
*/
|
*/
|
||||||
@ -148,5 +147,4 @@ public final class NBTUtils {
|
|||||||
}
|
}
|
||||||
return expected.cast(tag);
|
return expected.cast(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,12 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.jnbt;
|
package com.intellectualcrafters.jnbt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code TAG_Short} tag.
|
* The {@code TAG_Short} tag.
|
||||||
*/
|
*/
|
||||||
public final class ShortTag extends Tag {
|
public final class ShortTag extends Tag {
|
||||||
|
|
||||||
private final short value;
|
private final short value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,5 +61,4 @@ public final class ShortTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_Short" + append + ": " + this.value;
|
return "TAG_Short" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* The {@code TAG_String} tag.
|
* The {@code TAG_String} tag.
|
||||||
*/
|
*/
|
||||||
public final class StringTag extends Tag {
|
public final class StringTag extends Tag {
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,5 +45,4 @@ public final class StringTag extends Tag {
|
|||||||
}
|
}
|
||||||
return "TAG_String" + append + ": " + this.value;
|
return "TAG_String" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,12 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.jnbt;
|
package com.intellectualcrafters.jnbt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a NBT tag.
|
* Represents a NBT tag.
|
||||||
*/
|
*/
|
||||||
public abstract class Tag {
|
public abstract class Tag {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,5 +60,4 @@ public abstract class Tag {
|
|||||||
* @return the value
|
* @return the value
|
||||||
*/
|
*/
|
||||||
public abstract Object getValue();
|
public abstract Object getValue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,8 @@ import org.bukkit.World;
|
|||||||
|
|
||||||
public class WorldEditUtils {
|
public class WorldEditUtils {
|
||||||
public static void setNBT(final World world, final short id, final byte data, final int x, final int y, final int z, final com.intellectualcrafters.jnbt.CompoundTag tag) {
|
public static void setNBT(final World world, final short id, final byte data, final int x, final int y, final int z, final com.intellectualcrafters.jnbt.CompoundTag tag) {
|
||||||
|
|
||||||
// final LocalWorld bukkitWorld = BukkitUtil.getLocalWorld(world);
|
// final LocalWorld bukkitWorld = BukkitUtil.getLocalWorld(world);
|
||||||
|
|
||||||
// I need to somehow convert our CompoundTag to WorldEdit's
|
// I need to somehow convert our CompoundTag to WorldEdit's
|
||||||
|
|
||||||
// final BaseBlock block = new BaseBlock(5, 5, (CompoundTag) tag);
|
// final BaseBlock block = new BaseBlock(5, 5, (CompoundTag) tag);
|
||||||
// final Vector vector = new Vector(x, y, z);
|
// final Vector vector = new Vector(x, y, z);
|
||||||
// try {
|
// try {
|
||||||
|
@ -18,7 +18,6 @@ package com.intellectualcrafters.json;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class CDL {
|
public class CDL {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next value. The value can be wrapped in quotes. The value can be empty.
|
* Get the next value. The value can be wrapped in quotes. The value can be empty.
|
||||||
*
|
*
|
||||||
@ -42,7 +41,7 @@ public class CDL {
|
|||||||
case '\'':
|
case '\'':
|
||||||
q = c;
|
q = c;
|
||||||
sb = new StringBuffer();
|
sb = new StringBuffer();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = x.next();
|
c = x.next();
|
||||||
if (c == q) {
|
if (c == q) {
|
||||||
break;
|
break;
|
||||||
@ -73,14 +72,14 @@ public class CDL {
|
|||||||
*/
|
*/
|
||||||
public static JSONArray rowToJSONArray(final JSONTokener x) throws JSONException {
|
public static JSONArray rowToJSONArray(final JSONTokener x) throws JSONException {
|
||||||
final JSONArray ja = new JSONArray();
|
final JSONArray ja = new JSONArray();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
final String value = getValue(x);
|
final String value = getValue(x);
|
||||||
char c = x.next();
|
char c = x.next();
|
||||||
if ((value == null) || ((ja.length() == 0) && (value.length() == 0) && (c != ','))) {
|
if ((value == null) || ((ja.length() == 0) && (value.length() == 0) && (c != ','))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ja.put(value);
|
ja.put(value);
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
if (c == ',') {
|
if (c == ',') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -205,7 +204,7 @@ public class CDL {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final JSONArray ja = new JSONArray();
|
final JSONArray ja = new JSONArray();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
final JSONObject jo = rowToJSONObject(names, x);
|
final JSONObject jo = rowToJSONObject(names, x);
|
||||||
if (jo == null) {
|
if (jo == null) {
|
||||||
break;
|
break;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.json;
|
package com.intellectualcrafters.json;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +28,6 @@ package com.intellectualcrafters.json;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class Cookie {
|
public class Cookie {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Produce a copy of a string in which the characters '+', '%', '=', ';' and control characters are replaced with
|
* Produce a copy of a string in which the characters '+', '%', '=', ';' and control characters are replaced with
|
||||||
* "%hh". This is a gentle form of URL encoding, attempting to cause as little distortion to the string as possible.
|
* "%hh". This is a gentle form of URL encoding, attempting to cause as little distortion to the string as possible.
|
||||||
@ -112,7 +110,6 @@ public class Cookie {
|
|||||||
*/
|
*/
|
||||||
public static String toString(final JSONObject jo) throws JSONException {
|
public static String toString(final JSONObject jo) throws JSONException {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(escape(jo.getString("name")));
|
sb.append(escape(jo.getString("name")));
|
||||||
sb.append("=");
|
sb.append("=");
|
||||||
sb.append(escape(jo.getString("value")));
|
sb.append(escape(jo.getString("value")));
|
||||||
|
@ -9,7 +9,6 @@ import java.util.Iterator;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class CookieList {
|
public class CookieList {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The names are separated
|
* Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The names are separated
|
||||||
* from the values by '='. The pairs are separated by ';'. The names and the values will be unescaped, possibly
|
* from the values by '='. The pairs are separated by ';'. The names and the values will be unescaped, possibly
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.json;
|
package com.intellectualcrafters.json;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -30,7 +29,6 @@ import java.util.Iterator;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class HTTP {
|
public class HTTP {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Carriage return/line feed.
|
* Carriage return/line feed.
|
||||||
*/
|
*/
|
||||||
@ -93,28 +91,20 @@ public class HTTP {
|
|||||||
final JSONObject jo = new JSONObject();
|
final JSONObject jo = new JSONObject();
|
||||||
final HTTPTokener x = new HTTPTokener(string);
|
final HTTPTokener x = new HTTPTokener(string);
|
||||||
String token;
|
String token;
|
||||||
|
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
if (token.toUpperCase().startsWith("HTTP")) {
|
if (token.toUpperCase().startsWith("HTTP")) {
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
|
|
||||||
jo.put("HTTP-Version", token);
|
jo.put("HTTP-Version", token);
|
||||||
jo.put("Status-Code", x.nextToken());
|
jo.put("Status-Code", x.nextToken());
|
||||||
jo.put("Reason-Phrase", x.nextTo('\0'));
|
jo.put("Reason-Phrase", x.nextTo('\0'));
|
||||||
x.next();
|
x.next();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
|
|
||||||
jo.put("Method", token);
|
jo.put("Method", token);
|
||||||
jo.put("Request-URI", x.nextToken());
|
jo.put("Request-URI", x.nextToken());
|
||||||
jo.put("HTTP-Version", x.nextToken());
|
jo.put("HTTP-Version", x.nextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
|
|
||||||
while (x.more()) {
|
while (x.more()) {
|
||||||
final String name = x.nextTo(':');
|
final String name = x.nextTo(':');
|
||||||
x.next(':');
|
x.next(':');
|
||||||
|
@ -7,7 +7,6 @@ package com.intellectualcrafters.json;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class HTTPTokener extends JSONTokener {
|
public class HTTPTokener extends JSONTokener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an HTTPTokener from a string.
|
* Construct an HTTPTokener from a string.
|
||||||
*
|
*
|
||||||
@ -33,7 +32,7 @@ public class HTTPTokener extends JSONTokener {
|
|||||||
} while (Character.isWhitespace(c));
|
} while (Character.isWhitespace(c));
|
||||||
if ((c == '"') || (c == '\'')) {
|
if ((c == '"') || (c == '\'')) {
|
||||||
q = c;
|
q = c;
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = next();
|
c = next();
|
||||||
if (c < ' ') {
|
if (c < ' ') {
|
||||||
throw syntaxError("Unterminated string.");
|
throw syntaxError("Unterminated string.");
|
||||||
@ -44,7 +43,7 @@ public class HTTPTokener extends JSONTokener {
|
|||||||
sb.append(c);
|
sb.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
if ((c == 0) || Character.isWhitespace(c)) {
|
if ((c == 0) || Character.isWhitespace(c)) {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.json;
|
package com.intellectualcrafters.json;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -58,7 +57,6 @@ import java.util.Map;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class JSONArray {
|
public class JSONArray {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The arrayList where the JSONArray's properties are kept.
|
* The arrayList where the JSONArray's properties are kept.
|
||||||
*/
|
*/
|
||||||
@ -85,7 +83,7 @@ public class JSONArray {
|
|||||||
}
|
}
|
||||||
if (x.nextClean() != ']') {
|
if (x.nextClean() != ']') {
|
||||||
x.back();
|
x.back();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
if (x.nextClean() == ',') {
|
if (x.nextClean() == ',') {
|
||||||
x.back();
|
x.back();
|
||||||
this.myArrayList.add(JSONObject.NULL);
|
this.myArrayList.add(JSONObject.NULL);
|
||||||
@ -317,7 +315,6 @@ public class JSONArray {
|
|||||||
public String join(final String separator) throws JSONException {
|
public String join(final String separator) throws JSONException {
|
||||||
final int len = this.length();
|
final int len = this.length();
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < len; i += 1) {
|
for (int i = 0; i < len; i += 1) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
sb.append(separator);
|
sb.append(separator);
|
||||||
@ -855,12 +852,10 @@ public class JSONArray {
|
|||||||
boolean commanate = false;
|
boolean commanate = false;
|
||||||
final int length = this.length();
|
final int length = this.length();
|
||||||
writer.write('[');
|
writer.write('[');
|
||||||
|
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
|
JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
|
||||||
} else if (length != 0) {
|
} else if (length != 0) {
|
||||||
final int newindent = indent + indentFactor;
|
final int newindent = indent + indentFactor;
|
||||||
|
|
||||||
for (int i = 0; i < length; i += 1) {
|
for (int i = 0; i < length; i += 1) {
|
||||||
if (commanate) {
|
if (commanate) {
|
||||||
writer.write(',');
|
writer.write(',');
|
||||||
|
@ -10,7 +10,6 @@ import java.util.Iterator;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class JSONML {
|
public class JSONML {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse XML values and store them in a JSONArray.
|
* Parse XML values and store them in a JSONArray.
|
||||||
*
|
*
|
||||||
@ -31,13 +30,11 @@ public class JSONML {
|
|||||||
JSONObject newjo = null;
|
JSONObject newjo = null;
|
||||||
Object token;
|
Object token;
|
||||||
String tagName = null;
|
String tagName = null;
|
||||||
|
|
||||||
// Test for and skip past these forms:
|
// Test for and skip past these forms:
|
||||||
// <!-- ... -->
|
// <!-- ... -->
|
||||||
// <![ ... ]]>
|
// <![ ... ]]>
|
||||||
// <! ... >
|
// <! ... >
|
||||||
// <? ... ?>
|
// <? ... ?>
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!x.more()) {
|
if (!x.more()) {
|
||||||
throw x.syntaxError("Bad XML");
|
throw x.syntaxError("Bad XML");
|
||||||
@ -47,9 +44,7 @@ public class JSONML {
|
|||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
if (token instanceof Character) {
|
if (token instanceof Character) {
|
||||||
if (token == XML.SLASH) {
|
if (token == XML.SLASH) {
|
||||||
|
|
||||||
// Close tag </
|
// Close tag </
|
||||||
|
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
if (!(token instanceof String)) {
|
if (!(token instanceof String)) {
|
||||||
throw new JSONException("Expected a closing name instead of '" + token + "'.");
|
throw new JSONException("Expected a closing name instead of '" + token + "'.");
|
||||||
@ -59,9 +54,7 @@ public class JSONML {
|
|||||||
}
|
}
|
||||||
return token;
|
return token;
|
||||||
} else if (token == XML.BANG) {
|
} else if (token == XML.BANG) {
|
||||||
|
|
||||||
// <!
|
// <!
|
||||||
|
|
||||||
c = x.next();
|
c = x.next();
|
||||||
if (c == '-') {
|
if (c == '-') {
|
||||||
if (x.next() == '-') {
|
if (x.next() == '-') {
|
||||||
@ -92,16 +85,12 @@ public class JSONML {
|
|||||||
} while (i > 0);
|
} while (i > 0);
|
||||||
}
|
}
|
||||||
} else if (token == XML.QUEST) {
|
} else if (token == XML.QUEST) {
|
||||||
|
|
||||||
// <?
|
// <?
|
||||||
|
|
||||||
x.skipPast("?>");
|
x.skipPast("?>");
|
||||||
} else {
|
} else {
|
||||||
throw x.syntaxError("Misshaped tag");
|
throw x.syntaxError("Misshaped tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open tag <
|
// Open tag <
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(token instanceof String)) {
|
if (!(token instanceof String)) {
|
||||||
throw x.syntaxError("Bad tagName '" + token + "'.");
|
throw x.syntaxError("Bad tagName '" + token + "'.");
|
||||||
@ -121,7 +110,7 @@ public class JSONML {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
token = null;
|
token = null;
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
}
|
}
|
||||||
@ -131,9 +120,7 @@ public class JSONML {
|
|||||||
if (!(token instanceof String)) {
|
if (!(token instanceof String)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// attribute = value
|
// attribute = value
|
||||||
|
|
||||||
attribute = (String) token;
|
attribute = (String) token;
|
||||||
if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) {
|
if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) {
|
||||||
throw x.syntaxError("Reserved attribute.");
|
throw x.syntaxError("Reserved attribute.");
|
||||||
@ -153,9 +140,7 @@ public class JSONML {
|
|||||||
if (arrayForm && (newjo.length() > 0)) {
|
if (arrayForm && (newjo.length() > 0)) {
|
||||||
newja.put(newjo);
|
newja.put(newjo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty tag <.../>
|
// Empty tag <.../>
|
||||||
|
|
||||||
if (token == XML.SLASH) {
|
if (token == XML.SLASH) {
|
||||||
if (x.nextToken() != XML.GT) {
|
if (x.nextToken() != XML.GT) {
|
||||||
throw x.syntaxError("Misshaped tag");
|
throw x.syntaxError("Misshaped tag");
|
||||||
@ -167,9 +152,7 @@ public class JSONML {
|
|||||||
return newjo;
|
return newjo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content, between <...> and </...>
|
// Content, between <...> and </...>
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (token != XML.GT) {
|
if (token != XML.GT) {
|
||||||
throw x.syntaxError("Misshaped tag");
|
throw x.syntaxError("Misshaped tag");
|
||||||
@ -289,22 +272,17 @@ public class JSONML {
|
|||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
String tagName;
|
String tagName;
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
// Emit <tagName
|
// Emit <tagName
|
||||||
|
|
||||||
tagName = ja.getString(0);
|
tagName = ja.getString(0);
|
||||||
XML.noSpace(tagName);
|
XML.noSpace(tagName);
|
||||||
tagName = XML.escape(tagName);
|
tagName = XML.escape(tagName);
|
||||||
sb.append('<');
|
sb.append('<');
|
||||||
sb.append(tagName);
|
sb.append(tagName);
|
||||||
|
|
||||||
object = ja.opt(1);
|
object = ja.opt(1);
|
||||||
if (object instanceof JSONObject) {
|
if (object instanceof JSONObject) {
|
||||||
i = 2;
|
i = 2;
|
||||||
jo = (JSONObject) object;
|
jo = (JSONObject) object;
|
||||||
|
|
||||||
// Emit the attributes
|
// Emit the attributes
|
||||||
|
|
||||||
keys = jo.keys();
|
keys = jo.keys();
|
||||||
while (keys.hasNext()) {
|
while (keys.hasNext()) {
|
||||||
key = keys.next();
|
key = keys.next();
|
||||||
@ -322,9 +300,7 @@ public class JSONML {
|
|||||||
} else {
|
} else {
|
||||||
i = 1;
|
i = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit content in body
|
// Emit content in body
|
||||||
|
|
||||||
length = ja.length();
|
length = ja.length();
|
||||||
if (i >= length) {
|
if (i >= length) {
|
||||||
sb.append('/');
|
sb.append('/');
|
||||||
@ -373,9 +349,7 @@ public class JSONML {
|
|||||||
Object object;
|
Object object;
|
||||||
String tagName;
|
String tagName;
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
// Emit <tagName
|
// Emit <tagName
|
||||||
|
|
||||||
tagName = jo.optString("tagName");
|
tagName = jo.optString("tagName");
|
||||||
if (tagName == null) {
|
if (tagName == null) {
|
||||||
return XML.escape(jo.toString());
|
return XML.escape(jo.toString());
|
||||||
@ -384,9 +358,7 @@ public class JSONML {
|
|||||||
tagName = XML.escape(tagName);
|
tagName = XML.escape(tagName);
|
||||||
sb.append('<');
|
sb.append('<');
|
||||||
sb.append(tagName);
|
sb.append(tagName);
|
||||||
|
|
||||||
// Emit the attributes
|
// Emit the attributes
|
||||||
|
|
||||||
keys = jo.keys();
|
keys = jo.keys();
|
||||||
while (keys.hasNext()) {
|
while (keys.hasNext()) {
|
||||||
key = keys.next();
|
key = keys.next();
|
||||||
@ -403,9 +375,7 @@ public class JSONML {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit content in body
|
// Emit content in body
|
||||||
|
|
||||||
ja = jo.optJSONArray("childNodes");
|
ja = jo.optJSONArray("childNodes");
|
||||||
if (ja == null) {
|
if (ja == null) {
|
||||||
sb.append('/');
|
sb.append('/');
|
||||||
|
@ -103,11 +103,10 @@ public class JSONObject {
|
|||||||
this();
|
this();
|
||||||
char c;
|
char c;
|
||||||
String key;
|
String key;
|
||||||
|
|
||||||
if (x.nextClean() != '{') {
|
if (x.nextClean() != '{') {
|
||||||
throw x.syntaxError("A JSONObject text must begin with '{'");
|
throw x.syntaxError("A JSONObject text must begin with '{'");
|
||||||
}
|
}
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = x.nextClean();
|
c = x.nextClean();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -118,17 +117,13 @@ public class JSONObject {
|
|||||||
x.back();
|
x.back();
|
||||||
key = x.nextValue().toString();
|
key = x.nextValue().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The key is followed by ':'.
|
// The key is followed by ':'.
|
||||||
|
|
||||||
c = x.nextClean();
|
c = x.nextClean();
|
||||||
if (c != ':') {
|
if (c != ':') {
|
||||||
throw x.syntaxError("Expected a ':' after a key");
|
throw x.syntaxError("Expected a ':' after a key");
|
||||||
}
|
}
|
||||||
this.putOnce(key, x.nextValue());
|
this.putOnce(key, x.nextValue());
|
||||||
|
|
||||||
// Pairs are separated by ','.
|
// Pairs are separated by ','.
|
||||||
|
|
||||||
switch (x.nextClean()) {
|
switch (x.nextClean()) {
|
||||||
case ';':
|
case ';':
|
||||||
case ',':
|
case ',':
|
||||||
@ -226,20 +221,16 @@ public class JSONObject {
|
|||||||
public JSONObject(final String baseName, final Locale locale) throws JSONException {
|
public JSONObject(final String baseName, final Locale locale) throws JSONException {
|
||||||
this();
|
this();
|
||||||
final ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader());
|
final ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader());
|
||||||
|
|
||||||
// Iterate through the keys in the bundle.
|
// Iterate through the keys in the bundle.
|
||||||
|
|
||||||
final Enumeration<String> keys = bundle.getKeys();
|
final Enumeration<String> keys = bundle.getKeys();
|
||||||
while (keys.hasMoreElements()) {
|
while (keys.hasMoreElements()) {
|
||||||
final Object key = keys.nextElement();
|
final Object key = keys.nextElement();
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
|
|
||||||
// Go through the path, ensuring that there is a nested
|
// Go through the path, ensuring that there is a nested
|
||||||
// JSONObject for each
|
// JSONObject for each
|
||||||
// segment except the last. Add the value using the last
|
// segment except the last. Add the value using the last
|
||||||
// segment's name into
|
// segment's name into
|
||||||
// the deepest nested JSONObject.
|
// the deepest nested JSONObject.
|
||||||
|
|
||||||
final String[] path = ((String) key).split("\\.");
|
final String[] path = ((String) key).split("\\.");
|
||||||
final int last = path.length - 1;
|
final int last = path.length - 1;
|
||||||
JSONObject target = this;
|
JSONObject target = this;
|
||||||
@ -268,9 +259,7 @@ public class JSONObject {
|
|||||||
if (Double.isInfinite(d) || Double.isNaN(d)) {
|
if (Double.isInfinite(d) || Double.isNaN(d)) {
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shave off trailing zeros and decimal point, if possible.
|
// Shave off trailing zeros and decimal point, if possible.
|
||||||
|
|
||||||
String string = Double.toString(d);
|
String string = Double.toString(d);
|
||||||
if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) {
|
if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) {
|
||||||
while (string.endsWith("0")) {
|
while (string.endsWith("0")) {
|
||||||
@ -339,9 +328,7 @@ public class JSONObject {
|
|||||||
throw new JSONException("Null pointer");
|
throw new JSONException("Null pointer");
|
||||||
}
|
}
|
||||||
testValidity(number);
|
testValidity(number);
|
||||||
|
|
||||||
// Shave off trailing zeros and decimal point, if possible.
|
// Shave off trailing zeros and decimal point, if possible.
|
||||||
|
|
||||||
String string = number.toString();
|
String string = number.toString();
|
||||||
if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) {
|
if ((string.indexOf('.') > 0) && (string.indexOf('e') < 0) && (string.indexOf('E') < 0)) {
|
||||||
while (string.endsWith("0")) {
|
while (string.endsWith("0")) {
|
||||||
@ -380,13 +367,11 @@ public class JSONObject {
|
|||||||
w.write("\"\"");
|
w.write("\"\"");
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
char b;
|
char b;
|
||||||
char c = 0;
|
char c = 0;
|
||||||
String hhhh;
|
String hhhh;
|
||||||
int i;
|
int i;
|
||||||
final int len = string.length();
|
final int len = string.length();
|
||||||
|
|
||||||
w.write('"');
|
w.write('"');
|
||||||
for (i = 0; i < len; i += 1) {
|
for (i = 0; i < len; i += 1) {
|
||||||
b = c;
|
b = c;
|
||||||
@ -454,12 +439,10 @@ public class JSONObject {
|
|||||||
if (string.equalsIgnoreCase("null")) {
|
if (string.equalsIgnoreCase("null")) {
|
||||||
return JSONObject.NULL;
|
return JSONObject.NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If it might be a number, try converting it. If a number cannot be
|
* If it might be a number, try converting it. If a number cannot be
|
||||||
* produced, then the value will just be a string.
|
* produced, then the value will just be a string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final char b = string.charAt(0);
|
final char b = string.charAt(0);
|
||||||
if (((b >= '0') && (b <= '9')) || (b == '-')) {
|
if (((b >= '0') && (b <= '9')) || (b == '-')) {
|
||||||
try {
|
try {
|
||||||
@ -576,7 +559,6 @@ public class JSONObject {
|
|||||||
if ((object instanceof JSONObject) || (object instanceof JSONArray) || NULL.equals(object) || (object instanceof JSONString) || (object instanceof Byte) || (object instanceof Character) || (object instanceof Short) || (object instanceof Integer) || (object instanceof Long) || (object instanceof Boolean) || (object instanceof Float) || (object instanceof Double) || (object instanceof String)) {
|
if ((object instanceof JSONObject) || (object instanceof JSONArray) || NULL.equals(object) || (object instanceof JSONString) || (object instanceof Byte) || (object instanceof Character) || (object instanceof Short) || (object instanceof Integer) || (object instanceof Long) || (object instanceof Boolean) || (object instanceof Float) || (object instanceof Double) || (object instanceof String)) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object instanceof Collection) {
|
if (object instanceof Collection) {
|
||||||
return new JSONArray((Collection<Object>) object);
|
return new JSONArray((Collection<Object>) object);
|
||||||
}
|
}
|
||||||
@ -1104,11 +1086,8 @@ public class JSONObject {
|
|||||||
|
|
||||||
private void populateMap(final Object bean) {
|
private void populateMap(final Object bean) {
|
||||||
final Class klass = bean.getClass();
|
final Class klass = bean.getClass();
|
||||||
|
|
||||||
// If klass is a System class then set includeSuperClass to false.
|
// If klass is a System class then set includeSuperClass to false.
|
||||||
|
|
||||||
final boolean includeSuperClass = klass.getClassLoader() != null;
|
final boolean includeSuperClass = klass.getClassLoader() != null;
|
||||||
|
|
||||||
final Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
|
final Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
|
||||||
for (final Method method : methods) {
|
for (final Method method : methods) {
|
||||||
try {
|
try {
|
||||||
@ -1130,7 +1109,6 @@ public class JSONObject {
|
|||||||
} else if (!Character.isUpperCase(key.charAt(1))) {
|
} else if (!Character.isUpperCase(key.charAt(1))) {
|
||||||
key = key.substring(0, 1).toLowerCase() + key.substring(1);
|
key = key.substring(0, 1).toLowerCase() + key.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Object result = method.invoke(bean, (Object[]) null);
|
final Object result = method.invoke(bean, (Object[]) null);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
this.map.put(key, wrap(result));
|
this.map.put(key, wrap(result));
|
||||||
@ -1433,7 +1411,6 @@ public class JSONObject {
|
|||||||
final int length = this.length();
|
final int length = this.length();
|
||||||
final Iterator<String> keys = this.keys();
|
final Iterator<String> keys = this.keys();
|
||||||
writer.write('{');
|
writer.write('{');
|
||||||
|
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
final Object key = keys.next();
|
final Object key = keys.next();
|
||||||
writer.write(quote(key.toString()));
|
writer.write(quote(key.toString()));
|
||||||
@ -1478,7 +1455,6 @@ public class JSONObject {
|
|||||||
* value that JavaScript calls undefined.
|
* value that JavaScript calls undefined.
|
||||||
*/
|
*/
|
||||||
private static final class Null {
|
private static final class Null {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There is only intended to be a single instance of the NULL object, so the clone method returns itself.
|
* There is only intended to be a single instance of the NULL object, so the clone method returns itself.
|
||||||
*
|
*
|
||||||
|
@ -15,7 +15,6 @@ import java.io.StringReader;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class JSONTokener {
|
public class JSONTokener {
|
||||||
|
|
||||||
private final Reader reader;
|
private final Reader reader;
|
||||||
private long character;
|
private long character;
|
||||||
private boolean eof;
|
private boolean eof;
|
||||||
@ -125,7 +124,6 @@ public class JSONTokener {
|
|||||||
} catch (final IOException exception) {
|
} catch (final IOException exception) {
|
||||||
throw new JSONException(exception);
|
throw new JSONException(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c <= 0) { // End of stream
|
if (c <= 0) { // End of stream
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
c = 0;
|
c = 0;
|
||||||
@ -175,10 +173,8 @@ public class JSONTokener {
|
|||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
final char[] chars = new char[n];
|
final char[] chars = new char[n];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
while (pos < n) {
|
while (pos < n) {
|
||||||
chars[pos] = this.next();
|
chars[pos] = this.next();
|
||||||
if (this.end()) {
|
if (this.end()) {
|
||||||
@ -197,7 +193,7 @@ public class JSONTokener {
|
|||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
public char nextClean() throws JSONException {
|
public char nextClean() throws JSONException {
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
final char c = this.next();
|
final char c = this.next();
|
||||||
if ((c == 0) || (c > ' ')) {
|
if ((c == 0) || (c > ' ')) {
|
||||||
return c;
|
return c;
|
||||||
@ -219,7 +215,7 @@ public class JSONTokener {
|
|||||||
public String nextString(final char quote) throws JSONException {
|
public String nextString(final char quote) throws JSONException {
|
||||||
char c;
|
char c;
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = this.next();
|
c = this.next();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -275,7 +271,7 @@ public class JSONTokener {
|
|||||||
*/
|
*/
|
||||||
public String nextTo(final char delimiter) throws JSONException {
|
public String nextTo(final char delimiter) throws JSONException {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
final char c = this.next();
|
final char c = this.next();
|
||||||
if ((c == delimiter) || (c == 0) || (c == '\n') || (c == '\r')) {
|
if ((c == delimiter) || (c == 0) || (c == '\n') || (c == '\r')) {
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
@ -298,7 +294,7 @@ public class JSONTokener {
|
|||||||
public String nextTo(final String delimiters) throws JSONException {
|
public String nextTo(final String delimiters) throws JSONException {
|
||||||
char c;
|
char c;
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = this.next();
|
c = this.next();
|
||||||
if ((delimiters.indexOf(c) >= 0) || (c == 0) || (c == '\n') || (c == '\r')) {
|
if ((delimiters.indexOf(c) >= 0) || (c == 0) || (c == '\n') || (c == '\r')) {
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
@ -321,7 +317,6 @@ public class JSONTokener {
|
|||||||
public Object nextValue() throws JSONException {
|
public Object nextValue() throws JSONException {
|
||||||
char c = this.nextClean();
|
char c = this.nextClean();
|
||||||
String string;
|
String string;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
@ -333,7 +328,6 @@ public class JSONTokener {
|
|||||||
this.back();
|
this.back();
|
||||||
return new JSONArray(this);
|
return new JSONArray(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle unquoted text. This could be the values true, false, or
|
* Handle unquoted text. This could be the values true, false, or
|
||||||
* null, or it can be a number. An implementation (such as this one)
|
* null, or it can be a number. An implementation (such as this one)
|
||||||
@ -341,14 +335,12 @@ public class JSONTokener {
|
|||||||
* Accumulate characters until we reach the end of the text or a
|
* Accumulate characters until we reach the end of the text or a
|
||||||
* formatting character.
|
* formatting character.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
while ((c >= ' ') && (",:]}/\\\"[{;=#".indexOf(c) < 0)) {
|
while ((c >= ' ') && (",:]}/\\\"[{;=#".indexOf(c) < 0)) {
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
c = this.next();
|
c = this.next();
|
||||||
}
|
}
|
||||||
this.back();
|
this.back();
|
||||||
|
|
||||||
string = sb.toString().trim();
|
string = sb.toString().trim();
|
||||||
if ("".equals(string)) {
|
if ("".equals(string)) {
|
||||||
throw this.syntaxError("Missing value");
|
throw this.syntaxError("Missing value");
|
||||||
|
@ -216,7 +216,6 @@ public class JSONWriter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
throw new JSONException("Misplaced object.");
|
throw new JSONException("Misplaced object.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ package com.intellectualcrafters.json;
|
|||||||
* @version 2013-04-18
|
* @version 2013-04-18
|
||||||
*/
|
*/
|
||||||
public class Kim {
|
public class Kim {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of bytes in the kim. The number of bytes can be as much as three times the number of characters.
|
* The number of bytes in the kim. The number of bytes can be as much as three times the number of characters.
|
||||||
*/
|
*/
|
||||||
@ -53,11 +52,9 @@ public class Kim {
|
|||||||
* @param thru The index of the last byte plus one.
|
* @param thru The index of the last byte plus one.
|
||||||
*/
|
*/
|
||||||
public Kim(final byte[] bytes, final int from, final int thru) {
|
public Kim(final byte[] bytes, final int from, final int thru) {
|
||||||
|
|
||||||
// As the bytes are copied into the new kim, a hashcode is computed
|
// As the bytes are copied into the new kim, a hashcode is computed
|
||||||
// using a
|
// using a
|
||||||
// modified Fletcher code.
|
// modified Fletcher code.
|
||||||
|
|
||||||
int sum = 1;
|
int sum = 1;
|
||||||
int value;
|
int value;
|
||||||
this.hashcode = 0;
|
this.hashcode = 0;
|
||||||
@ -106,10 +103,8 @@ public class Kim {
|
|||||||
final int stringLength = string.length();
|
final int stringLength = string.length();
|
||||||
this.hashcode = 0;
|
this.hashcode = 0;
|
||||||
this.length = 0;
|
this.length = 0;
|
||||||
|
|
||||||
// First pass: Determine the length of the kim, allowing for the UTF-16
|
// First pass: Determine the length of the kim, allowing for the UTF-16
|
||||||
// to UTF-32 conversion, and then the UTF-32 to Kim conversion.
|
// to UTF-32 conversion, and then the UTF-32 to Kim conversion.
|
||||||
|
|
||||||
if (stringLength > 0) {
|
if (stringLength > 0) {
|
||||||
for (int i = 0; i < stringLength; i += 1) {
|
for (int i = 0; i < stringLength; i += 1) {
|
||||||
final int c = string.charAt(i);
|
final int c = string.charAt(i);
|
||||||
@ -128,11 +123,9 @@ public class Kim {
|
|||||||
this.length += 3;
|
this.length += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second pass: Allocate a byte array and fill that array with the
|
// Second pass: Allocate a byte array and fill that array with the
|
||||||
// conversion
|
// conversion
|
||||||
// while computing the hashcode.
|
// while computing the hashcode.
|
||||||
|
|
||||||
this.bytes = new byte[this.length];
|
this.bytes = new byte[this.length];
|
||||||
int at = 0;
|
int at = 0;
|
||||||
int b;
|
int b;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.json;
|
package com.intellectualcrafters.json;
|
||||||
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
@ -9,47 +9,38 @@ import java.util.Iterator;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class XML {
|
public class XML {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '&'.
|
* The Character '&'.
|
||||||
*/
|
*/
|
||||||
public static final Character AMP = '&';
|
public static final Character AMP = '&';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '''.
|
* The Character '''.
|
||||||
*/
|
*/
|
||||||
public static final Character APOS = '\'';
|
public static final Character APOS = '\'';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '!'.
|
* The Character '!'.
|
||||||
*/
|
*/
|
||||||
public static final Character BANG = '!';
|
public static final Character BANG = '!';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '='.
|
* The Character '='.
|
||||||
*/
|
*/
|
||||||
public static final Character EQ = '=';
|
public static final Character EQ = '=';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '>'.
|
* The Character '>'.
|
||||||
*/
|
*/
|
||||||
public static final Character GT = '>';
|
public static final Character GT = '>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '<'.
|
* The Character '<'.
|
||||||
*/
|
*/
|
||||||
public static final Character LT = '<';
|
public static final Character LT = '<';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '?'.
|
* The Character '?'.
|
||||||
*/
|
*/
|
||||||
public static final Character QUEST = '?';
|
public static final Character QUEST = '?';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '"'.
|
* The Character '"'.
|
||||||
*/
|
*/
|
||||||
public static final Character QUOT = '"';
|
public static final Character QUOT = '"';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Character '/'.
|
* The Character '/'.
|
||||||
*/
|
*/
|
||||||
@ -135,7 +126,6 @@ public class XML {
|
|||||||
String string;
|
String string;
|
||||||
String tagName;
|
String tagName;
|
||||||
Object token;
|
Object token;
|
||||||
|
|
||||||
// Test for and skip past these forms:
|
// Test for and skip past these forms:
|
||||||
// <!-- ... -->
|
// <!-- ... -->
|
||||||
// <! ... >
|
// <! ... >
|
||||||
@ -145,11 +135,8 @@ public class XML {
|
|||||||
// <>
|
// <>
|
||||||
// <=
|
// <=
|
||||||
// <<
|
// <<
|
||||||
|
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
|
|
||||||
// <!
|
// <!
|
||||||
|
|
||||||
if (token == BANG) {
|
if (token == BANG) {
|
||||||
c = x.next();
|
c = x.next();
|
||||||
if (c == '-') {
|
if (c == '-') {
|
||||||
@ -184,15 +171,11 @@ public class XML {
|
|||||||
} while (i > 0);
|
} while (i > 0);
|
||||||
return false;
|
return false;
|
||||||
} else if (token == QUEST) {
|
} else if (token == QUEST) {
|
||||||
|
|
||||||
// <?
|
// <?
|
||||||
|
|
||||||
x.skipPast("?>");
|
x.skipPast("?>");
|
||||||
return false;
|
return false;
|
||||||
} else if (token == SLASH) {
|
} else if (token == SLASH) {
|
||||||
|
|
||||||
// Close tag </
|
// Close tag </
|
||||||
|
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw x.syntaxError("Mismatched close tag " + token);
|
throw x.syntaxError("Mismatched close tag " + token);
|
||||||
@ -204,23 +187,18 @@ public class XML {
|
|||||||
throw x.syntaxError("Misshaped close tag");
|
throw x.syntaxError("Misshaped close tag");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (token instanceof Character) {
|
} else if (token instanceof Character) {
|
||||||
throw x.syntaxError("Misshaped tag");
|
throw x.syntaxError("Misshaped tag");
|
||||||
|
|
||||||
// Open tag <
|
// Open tag <
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
tagName = (String) token;
|
tagName = (String) token;
|
||||||
token = null;
|
token = null;
|
||||||
jsonobject = new JSONObject();
|
jsonobject = new JSONObject();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// attribute = value
|
// attribute = value
|
||||||
|
|
||||||
if (token instanceof String) {
|
if (token instanceof String) {
|
||||||
string = (String) token;
|
string = (String) token;
|
||||||
token = x.nextToken();
|
token = x.nextToken();
|
||||||
@ -234,9 +212,7 @@ public class XML {
|
|||||||
} else {
|
} else {
|
||||||
jsonobject.accumulate(string, "");
|
jsonobject.accumulate(string, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty tag <.../>
|
// Empty tag <.../>
|
||||||
|
|
||||||
} else if (token == SLASH) {
|
} else if (token == SLASH) {
|
||||||
if (x.nextToken() != GT) {
|
if (x.nextToken() != GT) {
|
||||||
throw x.syntaxError("Misshaped tag");
|
throw x.syntaxError("Misshaped tag");
|
||||||
@ -247,11 +223,9 @@ public class XML {
|
|||||||
context.accumulate(tagName, "");
|
context.accumulate(tagName, "");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Content, between <...> and </...>
|
// Content, between <...> and </...>
|
||||||
|
|
||||||
} else if (token == GT) {
|
} else if (token == GT) {
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
token = x.nextContent();
|
token = x.nextContent();
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
if (tagName != null) {
|
if (tagName != null) {
|
||||||
@ -263,9 +237,7 @@ public class XML {
|
|||||||
if (string.length() > 0) {
|
if (string.length() > 0) {
|
||||||
jsonobject.accumulate("content", XML.stringToValue(string));
|
jsonobject.accumulate("content", XML.stringToValue(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nested element
|
// Nested element
|
||||||
|
|
||||||
} else if (token == LT) {
|
} else if (token == LT) {
|
||||||
if (parse(x, jsonobject, tagName)) {
|
if (parse(x, jsonobject, tagName)) {
|
||||||
if (jsonobject.length() == 0) {
|
if (jsonobject.length() == 0) {
|
||||||
@ -305,11 +277,9 @@ public class XML {
|
|||||||
if ("null".equalsIgnoreCase(string)) {
|
if ("null".equalsIgnoreCase(string)) {
|
||||||
return JSONObject.NULL;
|
return JSONObject.NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it might be a number, try converting it, first as a Long, and then
|
// If it might be a number, try converting it, first as a Long, and then
|
||||||
// as a
|
// as a
|
||||||
// Double. If that doesn't work, return the string.
|
// Double. If that doesn't work, return the string.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final char initial = string.charAt(0);
|
final char initial = string.charAt(0);
|
||||||
if ((initial == '-') || ((initial >= '0') && (initial <= '9'))) {
|
if ((initial == '-') || ((initial >= '0') && (initial <= '9'))) {
|
||||||
@ -387,17 +357,13 @@ public class XML {
|
|||||||
String string;
|
String string;
|
||||||
Object value;
|
Object value;
|
||||||
if (object instanceof JSONObject) {
|
if (object instanceof JSONObject) {
|
||||||
|
|
||||||
// Emit <tagName>
|
// Emit <tagName>
|
||||||
|
|
||||||
if (tagName != null) {
|
if (tagName != null) {
|
||||||
sb.append('<');
|
sb.append('<');
|
||||||
sb.append(tagName);
|
sb.append(tagName);
|
||||||
sb.append('>');
|
sb.append('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop thru the keys.
|
// Loop thru the keys.
|
||||||
|
|
||||||
jo = (JSONObject) object;
|
jo = (JSONObject) object;
|
||||||
keys = jo.keys();
|
keys = jo.keys();
|
||||||
while (keys.hasNext()) {
|
while (keys.hasNext()) {
|
||||||
@ -407,9 +373,7 @@ public class XML {
|
|||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
string = value instanceof String ? (String) value : null;
|
string = value instanceof String ? (String) value : null;
|
||||||
|
|
||||||
// Emit content in body
|
// Emit content in body
|
||||||
|
|
||||||
if ("content".equals(key)) {
|
if ("content".equals(key)) {
|
||||||
if (value instanceof JSONArray) {
|
if (value instanceof JSONArray) {
|
||||||
ja = (JSONArray) value;
|
ja = (JSONArray) value;
|
||||||
@ -423,9 +387,7 @@ public class XML {
|
|||||||
} else {
|
} else {
|
||||||
sb.append(escape(value.toString()));
|
sb.append(escape(value.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit an array of similar keys
|
// Emit an array of similar keys
|
||||||
|
|
||||||
} else if (value instanceof JSONArray) {
|
} else if (value instanceof JSONArray) {
|
||||||
ja = (JSONArray) value;
|
ja = (JSONArray) value;
|
||||||
length = ja.length();
|
length = ja.length();
|
||||||
@ -447,27 +409,21 @@ public class XML {
|
|||||||
sb.append('<');
|
sb.append('<');
|
||||||
sb.append(key);
|
sb.append(key);
|
||||||
sb.append("/>");
|
sb.append("/>");
|
||||||
|
|
||||||
// Emit a new tag <k>
|
// Emit a new tag <k>
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sb.append(toString(value, key));
|
sb.append(toString(value, key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tagName != null) {
|
if (tagName != null) {
|
||||||
|
|
||||||
// Emit the </tagname> close tag
|
// Emit the </tagname> close tag
|
||||||
|
|
||||||
sb.append("</");
|
sb.append("</");
|
||||||
sb.append(tagName);
|
sb.append(tagName);
|
||||||
sb.append('>');
|
sb.append('>');
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
||||||
// XML does not have good support for arrays. If an array appears in
|
// XML does not have good support for arrays. If an array appears in
|
||||||
// a place
|
// a place
|
||||||
// where XML is lacking, synthesize an <array> element.
|
// where XML is lacking, synthesize an <array> element.
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (object.getClass().isArray()) {
|
if (object.getClass().isArray()) {
|
||||||
object = new JSONArray(object);
|
object = new JSONArray(object);
|
||||||
|
@ -7,12 +7,10 @@ package com.intellectualcrafters.json;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class XMLTokener extends JSONTokener {
|
public class XMLTokener extends JSONTokener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot.
|
* The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot.
|
||||||
*/
|
*/
|
||||||
public static final java.util.HashMap<String, Character> entity;
|
public static final java.util.HashMap<String, Character> entity;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
entity = new java.util.HashMap<String, Character>(8);
|
entity = new java.util.HashMap<String, Character>(8);
|
||||||
entity.put("amp", XML.AMP);
|
entity.put("amp", XML.AMP);
|
||||||
@ -42,7 +40,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
char c;
|
char c;
|
||||||
int i;
|
int i;
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = next();
|
c = next();
|
||||||
if (end()) {
|
if (end()) {
|
||||||
throw syntaxError("Unclosed CDATA");
|
throw syntaxError("Unclosed CDATA");
|
||||||
@ -77,7 +75,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
return XML.LT;
|
return XML.LT;
|
||||||
}
|
}
|
||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
if ((c == '<') || (c == 0)) {
|
if ((c == '<') || (c == 0)) {
|
||||||
back();
|
back();
|
||||||
return sb.toString().trim();
|
return sb.toString().trim();
|
||||||
@ -103,7 +101,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
*/
|
*/
|
||||||
public Object nextEntity(final char ampersand) throws JSONException {
|
public Object nextEntity(final char ampersand) throws JSONException {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
final char c = next();
|
final char c = next();
|
||||||
if (Character.isLetterOrDigit(c) || (c == '#')) {
|
if (Character.isLetterOrDigit(c) || (c == '#')) {
|
||||||
sb.append(Character.toLowerCase(c));
|
sb.append(Character.toLowerCase(c));
|
||||||
@ -150,7 +148,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
q = c;
|
q = c;
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = next();
|
c = next();
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
throw syntaxError("Unterminated string");
|
throw syntaxError("Unterminated string");
|
||||||
@ -160,7 +158,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = next();
|
c = next();
|
||||||
if (Character.isWhitespace(c)) {
|
if (Character.isWhitespace(c)) {
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
@ -212,14 +210,12 @@ public class XMLTokener extends JSONTokener {
|
|||||||
return XML.BANG;
|
return XML.BANG;
|
||||||
case '?':
|
case '?':
|
||||||
return XML.QUEST;
|
return XML.QUEST;
|
||||||
|
// Quoted string
|
||||||
// Quoted string
|
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
q = c;
|
q = c;
|
||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
c = next();
|
c = next();
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
throw syntaxError("Unterminated string");
|
throw syntaxError("Unterminated string");
|
||||||
@ -234,11 +230,9 @@ public class XMLTokener extends JSONTokener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
|
|
||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
for (; ; ) {
|
for (;;) {
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
c = next();
|
c = next();
|
||||||
if (Character.isWhitespace(c)) {
|
if (Character.isWhitespace(c)) {
|
||||||
@ -281,12 +275,10 @@ public class XMLTokener extends JSONTokener {
|
|||||||
int offset = 0;
|
int offset = 0;
|
||||||
final int length = to.length();
|
final int length = to.length();
|
||||||
final char[] circle = new char[length];
|
final char[] circle = new char[length];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First fill the circle buffer with as many characters as are in the
|
* First fill the circle buffer with as many characters as are in the
|
||||||
* to string. If we reach an early end, bail.
|
* to string. If we reach an early end, bail.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i < length; i += 1) {
|
for (i = 0; i < length; i += 1) {
|
||||||
c = next();
|
c = next();
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
@ -294,15 +286,11 @@ public class XMLTokener extends JSONTokener {
|
|||||||
}
|
}
|
||||||
circle[i] = c;
|
circle[i] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We will loop, possibly for all of the remaining characters. */
|
/* We will loop, possibly for all of the remaining characters. */
|
||||||
|
for (;;) {
|
||||||
for (; ; ) {
|
|
||||||
j = offset;
|
j = offset;
|
||||||
b = true;
|
b = true;
|
||||||
|
|
||||||
/* Compare the circle buffer with the to string. */
|
/* Compare the circle buffer with the to string. */
|
||||||
|
|
||||||
for (i = 0; i < length; i += 1) {
|
for (i = 0; i < length; i += 1) {
|
||||||
if (circle[j] != to.charAt(i)) {
|
if (circle[j] != to.charAt(i)) {
|
||||||
b = false;
|
b = false;
|
||||||
@ -313,15 +301,11 @@ public class XMLTokener extends JSONTokener {
|
|||||||
j -= length;
|
j -= length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we exit the loop with b intact, then victory is ours. */
|
/* If we exit the loop with b intact, then victory is ours. */
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the next character. If there isn't one, then defeat is ours. */
|
/* Get the next character. If there isn't one, then defeat is ours. */
|
||||||
|
|
||||||
c = next();
|
c = next();
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,9 +2,7 @@ package com.intellectualcrafters.plot;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -20,7 +18,6 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.Buy;
|
import com.intellectualcrafters.plot.commands.Buy;
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
||||||
@ -55,8 +52,7 @@ import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||||
|
|
||||||
public static BukkitMain THIS = null;
|
public static BukkitMain THIS = null;
|
||||||
public static PlotSquared MAIN = null;
|
public static PlotSquared MAIN = null;
|
||||||
|
|
||||||
@ -97,21 +93,18 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
|
|
||||||
// TODO restructure this
|
// TODO restructure this
|
||||||
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
|
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
|
||||||
Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot);
|
final Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot);
|
||||||
final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, bot);
|
final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, bot);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
final Location location = PlotHelper.getPlotHome(bot.world, bot);
|
final Location location = PlotHelper.getPlotHome(bot.world, bot);
|
||||||
|
final int x = location.getX();
|
||||||
int x = location.getX();
|
final int z = location.getZ();
|
||||||
int z = location.getZ();
|
|
||||||
|
|
||||||
|
|
||||||
if ((x >= 29999999) || (x <= -29999999) || (z >= 299999999) || (z <= -29999999)) {
|
if ((x >= 29999999) || (x <= -29999999) || (z >= 299999999) || (z <= -29999999)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Settings.TELEPORT_DELAY == 0 || hasPermission(player, "plots.teleport.delay.bypass")) {
|
if ((Settings.TELEPORT_DELAY == 0) || hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||||
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||||
BukkitUtil.teleportPlayer(player, location);
|
BukkitUtil.teleportPlayer(player, location);
|
||||||
return true;
|
return true;
|
||||||
@ -140,17 +133,17 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void worldLoad(WorldLoadEvent event) {
|
public static void worldLoad(final WorldLoadEvent event) {
|
||||||
UUIDHandler.cacheAll();
|
UUIDHandler.cacheAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void PlayerCommand(PlayerCommandPreprocessEvent event) {
|
public void PlayerCommand(final PlayerCommandPreprocessEvent event) {
|
||||||
String message = event.getMessage();
|
final String message = event.getMessage();
|
||||||
if (message.toLowerCase().startsWith("/plotme")) {
|
if (message.toLowerCase().startsWith("/plotme")) {
|
||||||
Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe");
|
final Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe");
|
||||||
if (plotme == null) {
|
if (plotme == null) {
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (Settings.USE_PLOTME_ALIAS) {
|
if (Settings.USE_PLOTME_ALIAS) {
|
||||||
player.performCommand(message.replace("/plotme", "plots"));
|
player.performCommand(message.replace("/plotme", "plots"));
|
||||||
} else {
|
} else {
|
||||||
@ -165,7 +158,6 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
MAIN = new PlotSquared(this);
|
MAIN = new PlotSquared(this);
|
||||||
THIS = this;
|
THIS = this;
|
||||||
|
|
||||||
if (Settings.METRICS) {
|
if (Settings.METRICS) {
|
||||||
try {
|
try {
|
||||||
final Metrics metrics = new Metrics(this);
|
final Metrics metrics = new Metrics(this);
|
||||||
@ -177,7 +169,6 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
} else {
|
} else {
|
||||||
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
||||||
}
|
}
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +181,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
if (THIS == null || Bukkit.getServer().getConsoleSender() == null) {
|
if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) {
|
||||||
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message)));
|
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message)));
|
||||||
} else {
|
} else {
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
@ -279,20 +270,20 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
return new HybridGen(world);
|
return new HybridGen(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkVersion(int major, int minor, int minor2) {
|
public static boolean checkVersion(final int major, final int minor, final int minor2) {
|
||||||
try {
|
try {
|
||||||
String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
final String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
||||||
int a = Integer.parseInt(version[0]);
|
final int a = Integer.parseInt(version[0]);
|
||||||
int b = Integer.parseInt(version[1]);
|
final int b = Integer.parseInt(version[1]);
|
||||||
int c = 0;
|
int c = 0;
|
||||||
if (version.length == 3) {
|
if (version.length == 3) {
|
||||||
c = Integer.parseInt(version[2]);
|
c = Integer.parseInt(version[2]);
|
||||||
}
|
}
|
||||||
if (a > major || (a == major && b > minor) || (a == major && b == minor && c >= minor2)) {
|
if ((a > major) || ((a == major) && (b > minor)) || ((a == major) && (b == minor) && (c >= minor2))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -354,16 +345,14 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
if (checkVersion(1, 8, 0)) {
|
if (checkVersion(1, 8, 0)) {
|
||||||
try {
|
try {
|
||||||
SetBlockManager.setBlockManager = new SetBlockFast_1_8();
|
SetBlockManager.setBlockManager = new SetBlockFast_1_8();
|
||||||
}
|
} catch (final Throwable e) {
|
||||||
catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
SetBlockManager.setBlockManager = new SetBlockSlow();
|
SetBlockManager.setBlockManager = new SetBlockSlow();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
try {
|
try {
|
||||||
SetBlockManager.setBlockManager = new SetBlockFast();
|
SetBlockManager.setBlockManager = new SetBlockFast();
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
SetBlockManager.setBlockManager = new SetBlockSlow();
|
SetBlockManager.setBlockManager = new SetBlockSlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,9 +378,9 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getGenerator(String world, String name) {
|
public void getGenerator(final String world, final String name) {
|
||||||
Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
|
final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
|
||||||
if (gen_plugin != null && gen_plugin.isEnabled()) {
|
if ((gen_plugin != null) && gen_plugin.isEnabled()) {
|
||||||
gen_plugin.getDefaultWorldGenerator(world, "");
|
gen_plugin.getDefaultWorldGenerator(world, "");
|
||||||
} else {
|
} else {
|
||||||
new HybridGen(world);
|
new HybridGen(world);
|
||||||
@ -399,7 +388,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callRemovePlot(String world, PlotId id) {
|
public boolean callRemovePlot(final String world, final PlotId id) {
|
||||||
final PlotDeleteEvent event = new PlotDeleteEvent(world, id);
|
final PlotDeleteEvent event = new PlotDeleteEvent(world, id);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
@ -36,9 +36,11 @@ import com.intellectualcrafters.plot.flag.AbstractFlag;
|
|||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||||
|
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
||||||
|
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
@ -56,19 +58,14 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
public class PlotSquared {
|
public class PlotSquared {
|
||||||
|
|
||||||
public static final String MAIN_PERMISSION = "plots.use";
|
public static final String MAIN_PERMISSION = "plots.use";
|
||||||
public static final String ADMIN_PERMISSION = "plots.admin";
|
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||||
|
|
||||||
public static File styleFile;
|
public static File styleFile;
|
||||||
public static YamlConfiguration style;
|
public static YamlConfiguration style;
|
||||||
|
|
||||||
public static File configFile;
|
public static File configFile;
|
||||||
public static YamlConfiguration config;
|
public static YamlConfiguration config;
|
||||||
|
|
||||||
public static File storageFile;
|
public static File storageFile;
|
||||||
public static YamlConfiguration storage;
|
public static YamlConfiguration storage;
|
||||||
|
|
||||||
public static PlotSquared THIS = null; // This class
|
public static PlotSquared THIS = null; // This class
|
||||||
public static IPlotMain IMP = null; // Specific implementation of PlotSquared
|
public static IPlotMain IMP = null; // Specific implementation of PlotSquared
|
||||||
public static String VERSION = null;
|
public static String VERSION = null;
|
||||||
@ -76,11 +73,9 @@ public class PlotSquared {
|
|||||||
private static boolean LOADING_WORLD = false;
|
private static boolean LOADING_WORLD = false;
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
public static WorldEditPlugin worldEdit = null;
|
public static WorldEditPlugin worldEdit = null;
|
||||||
|
|
||||||
private final static HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
private final static HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
||||||
private final static HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
private final static HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
||||||
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||||
|
|
||||||
private static MySQL mySQL;
|
private static MySQL mySQL;
|
||||||
public static Connection connection;
|
public static Connection connection;
|
||||||
|
|
||||||
@ -190,10 +185,9 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
plots.get(world).remove(id);
|
plots.get(world).remove(id);
|
||||||
if (PlotHelper.lastPlot.containsKey(world)) {
|
if (PlotHelper.lastPlot.containsKey(world)) {
|
||||||
PlotId last = PlotHelper.lastPlot.get(world);
|
final PlotId last = PlotHelper.lastPlot.get(world);
|
||||||
int last_max = Math.max(last.x, last.y);
|
final int last_max = Math.max(last.x, last.y);
|
||||||
int this_max = Math.max(id.x, id.y);
|
final int this_max = Math.max(id.x, id.y);
|
||||||
|
|
||||||
if (this_max < last_max) {
|
if (this_max < last_max) {
|
||||||
PlotHelper.lastPlot.put(world, id);
|
PlotHelper.lastPlot.put(world, id);
|
||||||
}
|
}
|
||||||
@ -205,16 +199,13 @@ public class PlotSquared {
|
|||||||
if (getWorldSettings(world) != null) {
|
if (getWorldSettings(world) != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<String> worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>());
|
final Set<String> worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>());
|
||||||
|
|
||||||
final PlotWorld plotWorld;
|
final PlotWorld plotWorld;
|
||||||
final PlotGenerator plotGenerator;
|
final PlotGenerator plotGenerator;
|
||||||
final PlotManager plotManager;
|
final PlotManager plotManager;
|
||||||
final String path = "worlds." + world;
|
final String path = "worlds." + world;
|
||||||
|
|
||||||
if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) {
|
if (!LOADING_WORLD && (generator != null) && (generator instanceof PlotGenerator)) {
|
||||||
plotGenerator = (PlotGenerator) generator;
|
plotGenerator = generator;
|
||||||
plotWorld = plotGenerator.getNewPlotWorld(world);
|
plotWorld = plotGenerator.getNewPlotWorld(world);
|
||||||
plotManager = plotGenerator.getPlotManager();
|
plotManager = plotGenerator.getPlotManager();
|
||||||
if (!world.equals("CheckingPlotSquaredGenerator")) {
|
if (!world.equals("CheckingPlotSquaredGenerator")) {
|
||||||
@ -243,14 +234,13 @@ public class PlotSquared {
|
|||||||
if (!LOADING_WORLD) {
|
if (!LOADING_WORLD) {
|
||||||
LOADING_WORLD = true;
|
LOADING_WORLD = true;
|
||||||
try {
|
try {
|
||||||
String gen_string = config.getString("worlds." + world + "." + "generator.plugin");
|
final String gen_string = config.getString("worlds." + world + "." + "generator.plugin");
|
||||||
if (gen_string == null) {
|
if (gen_string == null) {
|
||||||
new HybridGen(world);
|
new HybridGen(world);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
IMP.getGenerator(world, gen_string);
|
IMP.getGenerator(world, gen_string);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
log("&d=== Oh no! Please set the generator for the " + world + " ===");
|
log("&d=== Oh no! Please set the generator for the " + world + " ===");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
LOADING_WORLD = false;
|
LOADING_WORLD = false;
|
||||||
@ -259,7 +249,7 @@ public class PlotSquared {
|
|||||||
LOADING_WORLD = false;
|
LOADING_WORLD = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PlotGenerator gen_class = (PlotGenerator) generator;
|
final PlotGenerator gen_class = generator;
|
||||||
plotWorld = gen_class.getNewPlotWorld(world);
|
plotWorld = gen_class.getNewPlotWorld(world);
|
||||||
plotManager = gen_class.getPlotManager();
|
plotManager = gen_class.getPlotManager();
|
||||||
if (!config.contains(path)) {
|
if (!config.contains(path)) {
|
||||||
@ -274,14 +264,14 @@ public class PlotSquared {
|
|||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if ((plotWorld.TYPE == 2 && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) {
|
if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) {
|
||||||
log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!");
|
log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addPlotWorld(world, plotWorld, plotManager);
|
addPlotWorld(world, plotWorld, plotManager);
|
||||||
if (plotWorld.TYPE == 2) {
|
if (plotWorld.TYPE == 2) {
|
||||||
if (ClusterManager.getClusters(world).size() > 0) {
|
if (ClusterManager.getClusters(world).size() > 0) {
|
||||||
for (PlotCluster cluster : ClusterManager.getClusters(world)) {
|
for (final PlotCluster cluster : ClusterManager.getClusters(world)) {
|
||||||
new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,65 +282,63 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setupPlotWorld(String world, String id) {
|
public static boolean setupPlotWorld(final String world, final String id) {
|
||||||
if (id != null && id.length() > 0) {
|
if ((id != null) && (id.length() > 0)) {
|
||||||
// save configuration
|
// save configuration
|
||||||
String[] split = id.split(",");
|
final String[] split = id.split(",");
|
||||||
HybridPlotWorld plotworld = new HybridPlotWorld(world);
|
final HybridPlotWorld plotworld = new HybridPlotWorld(world);
|
||||||
|
final int width = SquarePlotWorld.PLOT_WIDTH_DEFAULT;
|
||||||
int width = HybridPlotWorld.PLOT_WIDTH_DEFAULT;
|
final int gap = SquarePlotWorld.ROAD_WIDTH_DEFAULT;
|
||||||
int gap = HybridPlotWorld.ROAD_WIDTH_DEFAULT;
|
final int height = ClassicPlotWorld.PLOT_HEIGHT_DEFAULT;
|
||||||
int height = HybridPlotWorld.PLOT_HEIGHT_DEFAULT;
|
final PlotBlock[] floor = ClassicPlotWorld.TOP_BLOCK_DEFAULT;
|
||||||
PlotBlock[] floor = HybridPlotWorld.TOP_BLOCK_DEFAULT;
|
final PlotBlock[] main = ClassicPlotWorld.MAIN_BLOCK_DEFAULT;
|
||||||
PlotBlock[] main = HybridPlotWorld.MAIN_BLOCK_DEFAULT;
|
final PlotBlock wall = ClassicPlotWorld.WALL_FILLING_DEFAULT;
|
||||||
PlotBlock wall = HybridPlotWorld.WALL_FILLING_DEFAULT;
|
final PlotBlock border = ClassicPlotWorld.WALL_BLOCK_DEFAULT;
|
||||||
PlotBlock border = HybridPlotWorld.WALL_BLOCK_DEFAULT;
|
for (final String element : split) {
|
||||||
|
final String[] pair = element.split("=");
|
||||||
for (String element : split) {
|
|
||||||
String[] pair = element.split("=");
|
|
||||||
if (pair.length != 2) {
|
if (pair.length != 2) {
|
||||||
log("&cNo value provided for: &7" + element);
|
log("&cNo value provided for: &7" + element);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String key = pair[0].toLowerCase();
|
final String key = pair[0].toLowerCase();
|
||||||
String value = pair[1];
|
final String value = pair[1];
|
||||||
try {
|
try {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "s":
|
case "s":
|
||||||
case "size": {
|
case "size": {
|
||||||
HybridPlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
|
SquarePlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "g":
|
case "g":
|
||||||
case "gap": {
|
case "gap": {
|
||||||
HybridPlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
|
SquarePlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "h":
|
case "h":
|
||||||
case "height": {
|
case "height": {
|
||||||
HybridPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
||||||
HybridPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
||||||
HybridPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "f":
|
case "f":
|
||||||
case "floor": {
|
case "floor": {
|
||||||
HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
ClassicPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "m":
|
case "m":
|
||||||
case "main": {
|
case "main": {
|
||||||
HybridPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "w":
|
case "w":
|
||||||
case "wall": {
|
case "wall": {
|
||||||
HybridPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
|
ClassicPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "b":
|
case "b":
|
||||||
case "border": {
|
case "border": {
|
||||||
HybridPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
|
ClassicPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -358,30 +346,28 @@ public class PlotSquared {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log("&cInvalid value: &7" + value + " in arg " + element);
|
log("&cInvalid value: &7" + value + " in arg " + element);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String root = "worlds." + world;
|
final String root = "worlds." + world;
|
||||||
if (!config.contains(root)) {
|
if (!config.contains(root)) {
|
||||||
config.createSection(root);
|
config.createSection(root);
|
||||||
}
|
}
|
||||||
plotworld.saveConfiguration(config.getConfigurationSection(root));
|
plotworld.saveConfiguration(config.getConfigurationSection(root));
|
||||||
HybridPlotWorld.PLOT_HEIGHT_DEFAULT = height;
|
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = height;
|
||||||
HybridPlotWorld.ROAD_HEIGHT_DEFAULT = height;
|
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = height;
|
||||||
HybridPlotWorld.WALL_HEIGHT_DEFAULT = height;
|
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = height;
|
||||||
HybridPlotWorld.TOP_BLOCK_DEFAULT = floor;
|
ClassicPlotWorld.TOP_BLOCK_DEFAULT = floor;
|
||||||
HybridPlotWorld.MAIN_BLOCK_DEFAULT = main;
|
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = main;
|
||||||
HybridPlotWorld.WALL_BLOCK_DEFAULT = border;
|
ClassicPlotWorld.WALL_BLOCK_DEFAULT = border;
|
||||||
HybridPlotWorld.WALL_FILLING_DEFAULT = wall;
|
ClassicPlotWorld.WALL_FILLING_DEFAULT = wall;
|
||||||
HybridPlotWorld.PLOT_WIDTH_DEFAULT = width;
|
SquarePlotWorld.PLOT_WIDTH_DEFAULT = width;
|
||||||
HybridPlotWorld.ROAD_WIDTH_DEFAULT = gap;
|
SquarePlotWorld.ROAD_WIDTH_DEFAULT = gap;
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,14 +378,12 @@ public class PlotSquared {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotSquared(IPlotMain imp_class) {
|
public PlotSquared(final IPlotMain imp_class) {
|
||||||
THIS = this;
|
THIS = this;
|
||||||
IMP = imp_class;
|
IMP = imp_class;
|
||||||
VERSION = IMP.getVersion();
|
VERSION = IMP.getVersion();
|
||||||
|
|
||||||
C.setupTranslations();
|
C.setupTranslations();
|
||||||
C.saveTranslations();
|
C.saveTranslations();
|
||||||
|
|
||||||
if (getJavaVersion() < 1.7) {
|
if (getJavaVersion() < 1.7) {
|
||||||
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
||||||
// Didn't know of any other link :D
|
// Didn't know of any other link :D
|
||||||
@ -410,7 +394,6 @@ public class PlotSquared {
|
|||||||
if (getJavaVersion() < 1.8) {
|
if (getJavaVersion() < 1.8) {
|
||||||
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
|
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
|
||||||
}
|
}
|
||||||
|
|
||||||
TASK = IMP.getTaskManager();
|
TASK = IMP.getTaskManager();
|
||||||
if (Settings.KILL_ROAD_MOBS) {
|
if (Settings.KILL_ROAD_MOBS) {
|
||||||
IMP.runEntityTask();
|
IMP.runEntityTask();
|
||||||
@ -418,11 +401,9 @@ public class PlotSquared {
|
|||||||
if (C.ENABLED.s().length() > 0) {
|
if (C.ENABLED.s().length() > 0) {
|
||||||
log(C.ENABLED.s());
|
log(C.ENABLED.s());
|
||||||
}
|
}
|
||||||
|
|
||||||
setupConfigs();
|
setupConfigs();
|
||||||
setupDefaultFlags();
|
setupDefaultFlags();
|
||||||
setupDatabase();
|
setupDatabase();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
IMP.registerCommands();
|
IMP.registerCommands();
|
||||||
IMP.registerPlayerEvents();
|
IMP.registerPlayerEvents();
|
||||||
@ -430,10 +411,8 @@ public class PlotSquared {
|
|||||||
IMP.registerPlotPlusEvents();
|
IMP.registerPlotPlusEvents();
|
||||||
IMP.registerForceFieldEvents();
|
IMP.registerForceFieldEvents();
|
||||||
IMP.registerWorldEditEvents();
|
IMP.registerWorldEditEvents();
|
||||||
|
|
||||||
// Set block
|
// Set block
|
||||||
IMP.initSetBlockManager();
|
IMP.initSetBlockManager();
|
||||||
|
|
||||||
// PlotMe
|
// PlotMe
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -447,11 +426,9 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
if (Settings.AUTO_CLEAR) {
|
if (Settings.AUTO_CLEAR) {
|
||||||
ExpireManager.runTask();
|
ExpireManager.runTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
economy = IMP.getEconomy();
|
economy = IMP.getEconomy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +443,7 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message) {
|
public static void log(final String message) {
|
||||||
IMP.log(message);
|
IMP.log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,10 +451,9 @@ public class PlotSquared {
|
|||||||
final String[] tables;
|
final String[] tables;
|
||||||
if (Settings.ENABLE_CLUSTERS) {
|
if (Settings.ENABLE_CLUSTERS) {
|
||||||
MainCommand.subCommands.add(new Cluster());
|
MainCommand.subCommands.add(new Cluster());
|
||||||
tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments", "cluster"};
|
tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments", "cluster" };
|
||||||
}
|
} else {
|
||||||
else {
|
tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" };
|
||||||
tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"};
|
|
||||||
}
|
}
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
try {
|
try {
|
||||||
@ -515,12 +491,10 @@ public class PlotSquared {
|
|||||||
if (Settings.ENABLE_CLUSTERS) {
|
if (Settings.ENABLE_CLUSTERS) {
|
||||||
ClusterManager.clusters = DBFunc.getClusters();
|
ClusterManager.clusters = DBFunc.getClusters();
|
||||||
}
|
}
|
||||||
}
|
} else if (Settings.DB.USE_MONGO) {
|
||||||
else if (Settings.DB.USE_MONGO) {
|
|
||||||
// DBFunc.dbManager = new MongoManager();
|
// DBFunc.dbManager = new MongoManager();
|
||||||
log(C.PREFIX.s() + "MongoDB is not yet implemented");
|
log(C.PREFIX.s() + "MongoDB is not yet implemented");
|
||||||
}
|
} else if (Settings.DB.USE_SQLITE) {
|
||||||
else if (Settings.DB.USE_SQLITE) {
|
|
||||||
try {
|
try {
|
||||||
connection = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection();
|
connection = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection();
|
||||||
{
|
{
|
||||||
@ -554,8 +528,7 @@ public class PlotSquared {
|
|||||||
IMP.disable();
|
IMP.disable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void setupDefaultFlags() {
|
public static void setupDefaultFlags() {
|
||||||
final List<String> booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit");
|
final List<String> booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit");
|
||||||
@ -571,31 +544,22 @@ public class PlotSquared {
|
|||||||
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
|
||||||
}
|
}
|
||||||
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("hostile-attack", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hostile-attack", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("animal-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("animal-interact", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("hanging-place", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hanging-place", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("hanging-break", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hanging-break", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("vehicle-use", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("vehicle-use", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("vehicle-place", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("vehicle-place", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("vehicle-break", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("vehicle-break", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("place", new FlagValue.PlotBlockListValue()));
|
FlagManager.addFlag(new AbstractFlag("place", new FlagValue.PlotBlockListValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue()));
|
FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue()));
|
FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("gamemode") {
|
FlagManager.addFlag(new AbstractFlag("gamemode") {
|
||||||
@Override
|
@Override
|
||||||
public String parseValueRaw(final String value) {
|
public String parseValueRaw(final String value) {
|
||||||
@ -622,11 +586,8 @@ public class PlotSquared {
|
|||||||
return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'";
|
return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue()));
|
FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue()));
|
FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("weather") {
|
FlagManager.addFlag(new AbstractFlag("weather") {
|
||||||
@Override
|
@Override
|
||||||
public String parseValueRaw(final String value) {
|
public String parseValueRaw(final String value) {
|
||||||
@ -676,7 +637,6 @@ public class PlotSquared {
|
|||||||
options.put("titles", Settings.TITLES);
|
options.put("titles", Settings.TITLES);
|
||||||
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
|
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
|
||||||
options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION);
|
options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION);
|
||||||
|
|
||||||
for (final Entry<String, Object> node : options.entrySet()) {
|
for (final Entry<String, Object> node : options.entrySet()) {
|
||||||
if (!config.contains(node.getKey())) {
|
if (!config.contains(node.getKey())) {
|
||||||
config.set(node.getKey(), node.getValue());
|
config.set(node.getKey(), node.getValue());
|
||||||
@ -693,8 +653,7 @@ public class PlotSquared {
|
|||||||
Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias");
|
Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias");
|
||||||
Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled");
|
Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled");
|
||||||
Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs");
|
Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs");
|
||||||
Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf"
|
Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding");
|
||||||
+ "inding");
|
|
||||||
Settings.METRICS = config.getBoolean("metrics");
|
Settings.METRICS = config.getBoolean("metrics");
|
||||||
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
||||||
Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk");
|
Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk");
|
||||||
@ -707,10 +666,8 @@ public class PlotSquared {
|
|||||||
Settings.MAX_PLOTS = 32767;
|
Settings.MAX_PLOTS = 32767;
|
||||||
}
|
}
|
||||||
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
||||||
|
|
||||||
Settings.OFFLINE_MODE = config.getBoolean("UUID.offline");
|
Settings.OFFLINE_MODE = config.getBoolean("UUID.offline");
|
||||||
Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk");
|
Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk");
|
||||||
|
|
||||||
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
|
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,44 +745,43 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void showDebug() {
|
public static void showDebug() {
|
||||||
Settings.DB.USE_MYSQL = storage.getBoolean("mysql.use");
|
Settings.DB.USE_MYSQL = storage.getBoolean("mysql.use");
|
||||||
Settings.DB.USER = storage.getString("mysql.user");
|
Settings.DB.USER = storage.getString("mysql.user");
|
||||||
Settings.DB.PASSWORD = storage.getString("mysql.password");
|
Settings.DB.PASSWORD = storage.getString("mysql.password");
|
||||||
Settings.DB.HOST_NAME = storage.getString("mysql.host");
|
Settings.DB.HOST_NAME = storage.getString("mysql.host");
|
||||||
Settings.DB.PORT = storage.getString("mysql.port");
|
Settings.DB.PORT = storage.getString("mysql.port");
|
||||||
Settings.DB.DATABASE = storage.getString("mysql.database");
|
Settings.DB.DATABASE = storage.getString("mysql.database");
|
||||||
Settings.DB.USE_SQLITE = storage.getBoolean("sqlite.use");
|
Settings.DB.USE_SQLITE = storage.getBoolean("sqlite.use");
|
||||||
Settings.DB.SQLITE_DB = storage.getString("sqlite.db");
|
Settings.DB.SQLITE_DB = storage.getString("sqlite.db");
|
||||||
Settings.DB.PREFIX = storage.getString("prefix");
|
Settings.DB.PREFIX = storage.getString("prefix");
|
||||||
Settings.METRICS = config.getBoolean("metrics");
|
Settings.METRICS = config.getBoolean("metrics");
|
||||||
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
|
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
|
||||||
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
||||||
Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
|
Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
|
||||||
Settings.API_URL = config.getString("uuid.api.location");
|
Settings.API_URL = config.getString("uuid.api.location");
|
||||||
Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
|
Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
|
||||||
Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
|
Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
|
||||||
|
C.COLOR_1 = ChatColor.getByChar(style.getString("color.1"));
|
||||||
C.COLOR_1 = ChatColor.getByChar(style.getString("color.1"));
|
C.COLOR_2 = ChatColor.getByChar(style.getString("color.2"));
|
||||||
C.COLOR_2 = ChatColor.getByChar(style.getString("color.2"));
|
C.COLOR_3 = ChatColor.getByChar(style.getString("color.3"));
|
||||||
C.COLOR_3 = ChatColor.getByChar(style.getString("color.3"));
|
C.COLOR_4 = ChatColor.getByChar(style.getString("color.4"));
|
||||||
C.COLOR_4 = ChatColor.getByChar(style.getString("color.4"));
|
if (Settings.DEBUG) {
|
||||||
if (Settings.DEBUG) {
|
final Map<String, String> settings = new HashMap<>();
|
||||||
final Map<String, String> settings = new HashMap<>();
|
settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS);
|
||||||
settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS);
|
settings.put("Use Metrics", "" + Settings.METRICS);
|
||||||
settings.put("Use Metrics", "" + Settings.METRICS);
|
settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN);
|
||||||
settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN);
|
settings.put("Mob Pathfinding", "" + Settings.MOB_PATHFINDING);
|
||||||
settings.put("Mob Pathfinding", "" + Settings.MOB_PATHFINDING);
|
settings.put("DB Mysql Enabled", "" + Settings.DB.USE_MYSQL);
|
||||||
settings.put("DB Mysql Enabled", "" + Settings.DB.USE_MYSQL);
|
settings.put("DB SQLite Enabled", "" + Settings.DB.USE_SQLITE);
|
||||||
settings.put("DB SQLite Enabled", "" + Settings.DB.USE_SQLITE);
|
settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
|
||||||
settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
|
settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS);
|
||||||
settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS);
|
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
||||||
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
settings.put("API Location", "" + Settings.API_URL);
|
||||||
settings.put("API Location", "" + Settings.API_URL);
|
for (final Entry<String, String> setting : settings.entrySet()) {
|
||||||
for (final Entry<String, String> setting : settings.entrySet()) {
|
log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
||||||
log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void setupStyle() {
|
private static void setupStyle() {
|
||||||
style.set("version", VERSION);
|
style.set("version", VERSION);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
@ -121,7 +120,6 @@ public class Auto extends SubCommand {
|
|||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) {
|
if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
||||||
return false;
|
return false;
|
||||||
@ -161,42 +159,40 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
String worldname = world.getName();
|
final String worldname = world.getName();
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(worldname);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(worldname);
|
||||||
if (plotworld.TYPE == 2) {
|
if (plotworld.TYPE == 2) {
|
||||||
Location loc = BukkitUtil.getLocation(plr);
|
final Location loc = BukkitUtil.getLocation(plr);
|
||||||
Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
final Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
PlotCluster cluster = ClusterManager.getCluster(loc);
|
final PlotCluster cluster = ClusterManager.getCluster(loc);
|
||||||
// Must be standing in a cluster
|
// Must be standing in a cluster
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotId bot = cluster.getP1();
|
final PlotId bot = cluster.getP1();
|
||||||
PlotId top = cluster.getP2();
|
final PlotId top = cluster.getP2();
|
||||||
PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
||||||
PlotId id = new PlotId(0, 0);
|
PlotId id = new PlotId(0, 0);
|
||||||
int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
|
final int width = Math.max((top.x - bot.x) + 1, (top.y - bot.y) + 1);
|
||||||
int max = width * width;
|
final int max = width * width;
|
||||||
//
|
//
|
||||||
for (int i = 0; i <= max; i++) {
|
for (int i = 0; i <= max; i++) {
|
||||||
PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||||
Plot current = PlotHelper.getPlot(worldname, currentId);
|
final Plot current = PlotHelper.getPlot(worldname, currentId);
|
||||||
if (current != null && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
||||||
Claim.claimPlot(plr, current, true, true);
|
Claim.claimPlot(plr, current, true, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
id = getNextPlot(id, 1);
|
id = getNextPlot(id, 1);
|
||||||
}
|
}
|
||||||
|
// no free plots
|
||||||
// no free plots
|
PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS);
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS);
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean br = false;
|
boolean br = false;
|
||||||
if ((size_x == 1) && (size_z == 1)) {
|
if ((size_x == 1) && (size_z == 1)) {
|
||||||
while (!br) {
|
while (!br) {
|
||||||
@ -240,11 +236,10 @@ public class Auto extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotId getLastPlot(String world) {
|
public PlotId getLastPlot(final String world) {
|
||||||
if (PlotHelper.lastPlot == null || !PlotHelper.lastPlot.containsKey(world)) {
|
if ((PlotHelper.lastPlot == null) || !PlotHelper.lastPlot.containsKey(world)) {
|
||||||
PlotHelper.lastPlot.put(world, new PlotId(0,0));
|
PlotHelper.lastPlot.put(world, new PlotId(0, 0));
|
||||||
}
|
}
|
||||||
return PlotHelper.lastPlot.get(world);
|
return PlotHelper.lastPlot.get(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Ban extends SubCommand {
|
public class Ban extends SubCommand {
|
||||||
|
|
||||||
public Ban() {
|
public Ban() {
|
||||||
super(Command.BAN, "Alias for /plot denied add", "/plot ban [player]", CommandCategory.ACTIONS, true);
|
super(Command.BAN, "Alias for /plot denied add", "/plot ban [player]", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
@ -42,7 +41,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Buy extends SubCommand {
|
public class Buy extends SubCommand {
|
||||||
|
|
||||||
public Buy() {
|
public Buy() {
|
||||||
super(Command.BUY, "Buy the plot you are standing on", "b", CommandCategory.CLAIMING, true);
|
super(Command.BUY, "Buy the plot you are standing on", "b", CommandCategory.CLAIMING, true);
|
||||||
}
|
}
|
||||||
@ -52,22 +50,20 @@ public class Buy extends SubCommand {
|
|||||||
if (!PlotSquared.useEconomy) {
|
if (!PlotSquared.useEconomy) {
|
||||||
return sendMessage(plr, C.ECON_DISABLED);
|
return sendMessage(plr, C.ECON_DISABLED);
|
||||||
}
|
}
|
||||||
World world = plr.getWorld();
|
final World world = plr.getWorld();
|
||||||
if (!PlotSquared.isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
Plot plot;
|
Plot plot;
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
try {
|
try {
|
||||||
String[] split = args[0].split(";");
|
final String[] split = args[0].split(";");
|
||||||
PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
plot = PlotHelper.getPlot(world, id);
|
plot = PlotHelper.getPlot(world, id);
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
plot = PlayerFunctions.getCurrentPlot(plr);
|
plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
}
|
}
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -82,16 +78,16 @@ public class Buy extends SubCommand {
|
|||||||
if (plot.owner.equals(UUIDHandler.getUUID(plr))) {
|
if (plot.owner.equals(UUIDHandler.getUUID(plr))) {
|
||||||
return sendMessage(plr, C.CANNOT_BUY_OWN);
|
return sendMessage(plr, C.CANNOT_BUY_OWN);
|
||||||
}
|
}
|
||||||
Flag flag = FlagManager.getPlotFlag(plot, "price");
|
final Flag flag = FlagManager.getPlotFlag(plot, "price");
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
return sendMessage(plr, C.NOT_FOR_SALE);
|
return sendMessage(plr, C.NOT_FOR_SALE);
|
||||||
}
|
}
|
||||||
double initPrice = (double) flag.getValue();
|
double initPrice = (double) flag.getValue();
|
||||||
double price = initPrice;
|
double price = initPrice;
|
||||||
PlotId id = plot.id;
|
final PlotId id = plot.id;
|
||||||
PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id;
|
final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id;
|
||||||
int size = PlayerFunctions.getPlotSelectionIds(id, id2).size();
|
final int size = PlayerFunctions.getPlotSelectionIds(id, id2).size();
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
if (plotworld.USE_ECONOMY) {
|
if (plotworld.USE_ECONOMY) {
|
||||||
price += plotworld.PLOT_PRICE * size;
|
price += plotworld.PLOT_PRICE * size;
|
||||||
initPrice += plotworld.SELL_PRICE * size;
|
initPrice += plotworld.SELL_PRICE * size;
|
||||||
@ -104,7 +100,7 @@ public class Buy extends SubCommand {
|
|||||||
economy.withdrawPlayer(plr, price);
|
economy.withdrawPlayer(plr, price);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||||
economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
||||||
Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
|
final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
|
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
@ -41,7 +40,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Claim extends SubCommand {
|
public class Claim extends SubCommand {
|
||||||
|
|
||||||
public Claim() {
|
public Claim() {
|
||||||
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true);
|
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true);
|
||||||
}
|
}
|
||||||
@ -51,9 +49,9 @@ public class Claim extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
|
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
|
||||||
if (plot.hasOwner() || plot.settings.isMerged()) {
|
if (plot.hasOwner() || plot.settings.isMerged()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto);
|
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
@ -63,11 +61,9 @@ public class Claim extends SubCommand {
|
|||||||
if (teleport) {
|
if (teleport) {
|
||||||
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||||
}
|
}
|
||||||
World world = plot.world;
|
final World world = plot.world;
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
|
|
||||||
final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id);
|
final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id);
|
||||||
|
|
||||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||||
SchematicHandler.Schematic sch;
|
SchematicHandler.Schematic sch;
|
||||||
if (schematic.equals("")) {
|
if (schematic.equals("")) {
|
||||||
@ -124,7 +120,6 @@ public class Claim extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
return !claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -34,7 +33,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Clear extends SubCommand {
|
public class Clear extends SubCommand {
|
||||||
|
|
||||||
public Clear() {
|
public Clear() {
|
||||||
super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false);
|
super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false);
|
||||||
}
|
}
|
||||||
@ -66,7 +64,6 @@ public class Clear extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PlayerFunctions.isInPlot(plr)) {
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
@ -79,11 +76,8 @@ public class Clear extends SubCommand {
|
|||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
plot.clear(plr, false);
|
plot.clear(plr, false);
|
||||||
|
|
||||||
// sign
|
// sign
|
||||||
|
|
||||||
// wall
|
// wall
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -28,7 +27,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Clipboard extends SubCommand {
|
public class Clipboard extends SubCommand {
|
||||||
|
|
||||||
public Clipboard() {
|
public Clipboard() {
|
||||||
super(Command.CLIPBOARD, "View information about your current copy", "clipboard", CommandCategory.INFO, true);
|
super(Command.CLIPBOARD, "View information about your current copy", "clipboard", CommandCategory.INFO, true);
|
||||||
}
|
}
|
||||||
@ -39,17 +37,12 @@ public class Clipboard extends SubCommand {
|
|||||||
return sendMessage(plr, C.NO_CLIPBOARD);
|
return sendMessage(plr, C.NO_CLIPBOARD);
|
||||||
}
|
}
|
||||||
final PlotSelection selection = currentSelection.get(plr.getName());
|
final PlotSelection selection = currentSelection.get(plr.getName());
|
||||||
|
|
||||||
final PlotId plotId = selection.getPlot().getId();
|
final PlotId plotId = selection.getPlot().getId();
|
||||||
final int width = selection.getWidth();
|
final int width = selection.getWidth();
|
||||||
final int total = selection.getBlocks().length;
|
final int total = selection.getBlocks().length;
|
||||||
|
|
||||||
String message = C.CLIPBOARD_INFO.s();
|
String message = C.CLIPBOARD_INFO.s();
|
||||||
|
|
||||||
message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + "");
|
message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + "");
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(plr, message);
|
PlayerFunctions.sendMessage(plr, message);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -47,7 +46,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Cluster extends SubCommand {
|
public class Cluster extends SubCommand {
|
||||||
|
|
||||||
public Cluster() {
|
public Cluster() {
|
||||||
super(Command.CLUSTER, "Manage a plot cluster", "cluster", CommandCategory.ACTIONS, true);
|
super(Command.CLUSTER, "Manage a plot cluster", "cluster", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -55,13 +53,12 @@ public class Cluster extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
// return arguments
|
// return arguments
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String sub = args[0].toLowerCase();
|
final String sub = args[0].toLowerCase();
|
||||||
switch (sub) {
|
switch (sub) {
|
||||||
case "l":
|
case "l":
|
||||||
case "list": {
|
case "list": {
|
||||||
@ -73,21 +70,18 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster list");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashSet<PlotCluster> clusters = ClusterManager.getClusters(plr.getWorld());
|
final HashSet<PlotCluster> clusters = ClusterManager.getClusters(plr.getWorld());
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + "");
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + "");
|
||||||
for (PlotCluster cluster : clusters) {
|
for (final PlotCluster cluster : clusters) {
|
||||||
// Ignore unmanaged clusters
|
// Ignore unmanaged clusters
|
||||||
String name = "'" + cluster.getName() + "' : " + cluster.toString();
|
final String name = "'" + cluster.getName() + "' : " + cluster.toString();
|
||||||
if (UUIDHandler.getUUID(plr).equals(cluster.owner)) {
|
if (UUIDHandler.getUUID(plr).equals(cluster.owner)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name);
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name);
|
||||||
}
|
} else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) {
|
||||||
else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name);
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name);
|
||||||
}
|
} else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) {
|
||||||
else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name);
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString());
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,36 +94,36 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 4) {
|
if (args.length != 4) {
|
||||||
PlotId id = ClusterManager.estimatePlotId(plr.getLocation());
|
final PlotId id = ClusterManager.estimatePlotId(plr.getLocation());
|
||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>");
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id);
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check pos1 / pos2
|
// check pos1 / pos2
|
||||||
PlotId pos1 = PlotHelper.parseId(args[2]);
|
final PlotId pos1 = PlotHelper.parseId(args[2]);
|
||||||
PlotId pos2 = PlotHelper.parseId(args[3]);
|
final PlotId pos2 = PlotHelper.parseId(args[3]);
|
||||||
if (pos1 == null || pos2 == null) {
|
if ((pos1 == null) || (pos2 == null)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if name is taken
|
// check if name is taken
|
||||||
String name = args[1];
|
final String name = args[1];
|
||||||
for (PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) {
|
for (final PlotCluster cluster : ClusterManager.getClusters(plr.getWorld())) {
|
||||||
if (name.equals(cluster.getName())) {
|
if (name.equals(cluster.getName())) {
|
||||||
PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//check if overlap
|
//check if overlap
|
||||||
PlotClusterId id = new PlotClusterId(pos1, pos2);
|
final PlotClusterId id = new PlotClusterId(pos1, pos2);
|
||||||
HashSet<PlotCluster> intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
|
final HashSet<PlotCluster> intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
|
||||||
if (intersects.size() > 0 || pos2.x < pos1.x || pos2.y < pos1.y) {
|
if ((intersects.size() > 0) || (pos2.x < pos1.x) || (pos2.y < pos1.y)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + "");
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, intersects.size() + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// create cluster
|
// create cluster
|
||||||
String world = plr.getWorld().getName();
|
final String world = plr.getWorld().getName();
|
||||||
PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr));
|
final PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr));
|
||||||
cluster.settings.setAlias(name);
|
cluster.settings.setAlias(name);
|
||||||
DBFunc.createCluster(world, cluster);
|
DBFunc.createCluster(world, cluster);
|
||||||
if (!ClusterManager.clusters.containsKey(world)) {
|
if (!ClusterManager.clusters.containsKey(world)) {
|
||||||
@ -137,8 +131,8 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
ClusterManager.clusters.get(world).add(cluster);
|
ClusterManager.clusters.get(world).add(cluster);
|
||||||
// Add any existing plots to the current cluster
|
// Add any existing plots to the current cluster
|
||||||
for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
|
for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
|
||||||
PlotCluster current = ClusterManager.getCluster(plot);
|
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||||
if (cluster.equals(current) && !cluster.hasRights(plot.owner)) {
|
if (cluster.equals(current) && !cluster.hasRights(plot.owner)) {
|
||||||
cluster.invited.add(plot.owner);
|
cluster.invited.add(plot.owner);
|
||||||
DBFunc.setInvited(world, cluster, plot.owner);
|
DBFunc.setInvited(world, cluster, plot.owner);
|
||||||
@ -158,7 +152,7 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 1 && args.length != 2) {
|
if ((args.length != 1) && (args.length != 2)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -169,8 +163,7 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cluster = ClusterManager.getCluster(plr.getLocation());
|
cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
@ -183,23 +176,23 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld());
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(plr.getWorld());
|
||||||
if (plotworld.TYPE == 2) {
|
if (plotworld.TYPE == 2) {
|
||||||
ArrayList<Plot> toRemove = new ArrayList<>();
|
final ArrayList<Plot> toRemove = new ArrayList<>();
|
||||||
for (Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
|
for (final Plot plot : PlotSquared.getPlots(plr.getWorld()).values()) {
|
||||||
PlotCluster other = ClusterManager.getCluster(plot);
|
final PlotCluster other = ClusterManager.getCluster(plot);
|
||||||
if (cluster.equals(other)) {
|
if (cluster.equals(other)) {
|
||||||
toRemove.add(plot);
|
toRemove.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Plot plot : toRemove) {
|
for (final Plot plot : toRemove) {
|
||||||
DBFunc.delete(plot.world, plot);
|
DBFunc.delete(plot.world, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBFunc.delete(cluster);
|
DBFunc.delete(cluster);
|
||||||
if (plotworld.TYPE == 2) {
|
if (plotworld.TYPE == 2) {
|
||||||
for (Iterator<BlockPopulator> iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) {
|
for (final Iterator<BlockPopulator> iterator = plr.getWorld().getPopulators().iterator(); iterator.hasNext();) {
|
||||||
BlockPopulator populator = iterator.next();
|
final BlockPopulator populator = iterator.next();
|
||||||
if (populator instanceof AugmentedPopulator) {
|
if (populator instanceof AugmentedPopulator) {
|
||||||
if (((AugmentedPopulator) populator).cluster.equals(cluster)) {
|
if (((AugmentedPopulator) populator).cluster.equals(cluster)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@ -207,7 +200,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String set : ClusterManager.clusters.keySet()) {
|
for (final String set : ClusterManager.clusters.keySet()) {
|
||||||
}
|
}
|
||||||
ClusterManager.last = null;
|
ClusterManager.last = null;
|
||||||
ClusterManager.clusters.get(cluster.world).remove(cluster);
|
ClusterManager.clusters.get(cluster.world).remove(cluster);
|
||||||
@ -226,14 +219,14 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check pos1 / pos2
|
// check pos1 / pos2
|
||||||
PlotId pos1 = PlotHelper.parseId(args[1]);
|
final PlotId pos1 = PlotHelper.parseId(args[1]);
|
||||||
PlotId pos2 = PlotHelper.parseId(args[2]);
|
final PlotId pos2 = PlotHelper.parseId(args[2]);
|
||||||
if (pos1 == null || pos2 == null) {
|
if ((pos1 == null) || (pos2 == null)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if in cluster
|
// check if in cluster
|
||||||
PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
@ -245,8 +238,8 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//check if overlap
|
//check if overlap
|
||||||
PlotClusterId id = new PlotClusterId(pos1, pos2);
|
final PlotClusterId id = new PlotClusterId(pos1, pos2);
|
||||||
HashSet<PlotCluster> intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
|
final HashSet<PlotCluster> intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id);
|
||||||
if (intersects.size() > 1) {
|
if (intersects.size() > 1) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + "");
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_INTERSECTION, (intersects.size() - 1) + "");
|
||||||
return false;
|
return false;
|
||||||
@ -263,7 +256,7 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.regen");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 1 && args.length != 2) {
|
if ((args.length != 1) && (args.length != 2)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster regen [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -274,8 +267,7 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cluster = ClusterManager.getCluster(plr.getLocation());
|
cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
@ -304,7 +296,7 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if in cluster
|
// check if in cluster
|
||||||
PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
@ -316,7 +308,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check uuid
|
// check uuid
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1]);
|
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
@ -324,9 +316,9 @@ public class Cluster extends SubCommand {
|
|||||||
if (!cluster.hasRights(uuid)) {
|
if (!cluster.hasRights(uuid)) {
|
||||||
// add the user if not added
|
// add the user if not added
|
||||||
cluster.invited.add(uuid);
|
cluster.invited.add(uuid);
|
||||||
String world = plr.getWorld().getName();
|
final String world = plr.getWorld().getName();
|
||||||
DBFunc.setInvited(world, cluster, uuid);
|
DBFunc.setInvited(world, cluster, uuid);
|
||||||
Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
PlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName());
|
PlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName());
|
||||||
}
|
}
|
||||||
@ -345,7 +337,7 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick <player>");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick <player>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
@ -357,7 +349,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check uuid
|
// check uuid
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1]);
|
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
@ -373,14 +365,14 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
cluster.invited.remove(uuid);
|
cluster.invited.remove(uuid);
|
||||||
DBFunc.removeInvited(cluster, uuid);
|
DBFunc.removeInvited(cluster, uuid);
|
||||||
Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
PlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
|
PlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
|
||||||
}
|
}
|
||||||
for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
|
for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
|
||||||
PlotCluster current = ClusterManager.getCluster(plot);
|
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||||
if (current != null && current.equals(cluster)) {
|
if ((current != null) && current.equals(cluster)) {
|
||||||
String world = plr.getWorld().getName();
|
final String world = plr.getWorld().getName();
|
||||||
DBFunc.delete(world, plot);
|
DBFunc.delete(world, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,7 +385,7 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 1 && args.length != 2) {
|
if ((args.length != 1) && (args.length != 2)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -404,15 +396,14 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cluster = ClusterManager.getCluster(plr.getLocation());
|
cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UUID uuid = UUIDHandler.getUUID(plr);
|
final UUID uuid = UUIDHandler.getUUID(plr);
|
||||||
if (!cluster.hasRights(uuid)) {
|
if (!cluster.hasRights(uuid)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED);
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED);
|
||||||
return false;
|
return false;
|
||||||
@ -428,10 +419,10 @@ public class Cluster extends SubCommand {
|
|||||||
cluster.invited.remove(uuid);
|
cluster.invited.remove(uuid);
|
||||||
DBFunc.removeInvited(cluster, uuid);
|
DBFunc.removeInvited(cluster, uuid);
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
||||||
for (Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
|
for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
|
||||||
PlotCluster current = ClusterManager.getCluster(plot);
|
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||||
if (current != null && current.equals(cluster)) {
|
if ((current != null) && current.equals(cluster)) {
|
||||||
String world = plr.getWorld().getName();
|
final String world = plr.getWorld().getName();
|
||||||
DBFunc.delete(world, plot);
|
DBFunc.delete(world, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,12 +439,12 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers <add|remove> <player>");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers <add|remove> <player>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID uuid = UUIDHandler.getUUID(args[2]);
|
final UUID uuid = UUIDHandler.getUUID(args[2]);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
@ -480,12 +471,12 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp <name>");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp <name>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]);
|
final PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]);
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID uuid = UUIDHandler.getUUID(plr);
|
final UUID uuid = UUIDHandler.getUUID(plr);
|
||||||
if (!cluster.hasRights(uuid)) {
|
if (!cluster.hasRights(uuid)) {
|
||||||
if (!BukkitMain.hasPermission(plr, "plots.cluster.tp.other")) {
|
if (!BukkitMain.hasPermission(plr, "plots.cluster.tp.other")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
|
||||||
@ -503,7 +494,7 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 1 && args.length != 2) {
|
if ((args.length != 1) && (args.length != 2)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -514,30 +505,27 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cluster = ClusterManager.getCluster(plr.getLocation());
|
cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String id = cluster.toString();
|
final String id = cluster.toString();
|
||||||
String owner = UUIDHandler.getName(cluster.owner);
|
String owner = UUIDHandler.getName(cluster.owner);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
owner = "unknown";
|
owner = "unknown";
|
||||||
}
|
}
|
||||||
String name = cluster.getName();
|
final String name = cluster.getName();
|
||||||
String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1);
|
final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1);
|
||||||
String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + "";
|
final String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + "";
|
||||||
|
|
||||||
String message = C.CLUSTER_INFO.s();
|
String message = C.CLUSTER_INFO.s();
|
||||||
message = message.replaceAll("%id%", id);
|
message = message.replaceAll("%id%", id);
|
||||||
message = message.replaceAll("%owner%", owner);
|
message = message.replaceAll("%owner%", owner);
|
||||||
message = message.replaceAll("%name%", name);
|
message = message.replaceAll("%name%", name);
|
||||||
message = message.replaceAll("%size%", size);
|
message = message.replaceAll("%size%", size);
|
||||||
message = message.replaceAll("%rights%", rights);
|
message = message.replaceAll("%rights%", rights);
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(plr, message);
|
PlayerFunctions.sendMessage(plr, message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -548,11 +536,11 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 1 && args.length != 2) {
|
if ((args.length != 1) && (args.length != 2)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
final PlotCluster cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
if (cluster == null) {
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
@ -563,10 +551,10 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Location base = ClusterManager.getClusterBottom(cluster);
|
final Location base = ClusterManager.getClusterBottom(cluster);
|
||||||
base.setY(0);
|
base.setY(0);
|
||||||
Location relative = plr.getLocation().subtract(base);
|
final Location relative = plr.getLocation().subtract(base);
|
||||||
BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
|
final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
|
||||||
cluster.settings.setPosition(blockloc);
|
cluster.settings.setPosition(blockloc);
|
||||||
DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ());
|
DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ());
|
||||||
return PlayerFunctions.sendMessage(plr, C.POSITION_SET);
|
return PlayerFunctions.sendMessage(plr, C.POSITION_SET);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +27,6 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public enum Command {
|
public enum Command {
|
||||||
|
|
||||||
// TODO new commands
|
// TODO new commands
|
||||||
// (economy)
|
// (economy)
|
||||||
// - /plot buy
|
// - /plot buy
|
||||||
@ -39,7 +37,7 @@ public enum Command {
|
|||||||
FLAG("flag", "f"),
|
FLAG("flag", "f"),
|
||||||
TARGET("target"),
|
TARGET("target"),
|
||||||
CLUSTER("cluster", "clusters"),
|
CLUSTER("cluster", "clusters"),
|
||||||
BUY("buy","b"),
|
BUY("buy", "b"),
|
||||||
CREATEROADSCHEMATIC("createroadschematic"),
|
CREATEROADSCHEMATIC("createroadschematic"),
|
||||||
DEBUGROADREGEN("debugroadregen"),
|
DEBUGROADREGEN("debugroadregen"),
|
||||||
DEBUGFIXFLAGS("debugfixflags"),
|
DEBUGFIXFLAGS("debugfixflags"),
|
||||||
@ -77,17 +75,14 @@ public enum Command {
|
|||||||
UNBAN("unban", "unblock"),
|
UNBAN("unban", "unblock"),
|
||||||
DATABASE("database", "convert"),
|
DATABASE("database", "convert"),
|
||||||
TP("tp", "tp");
|
TP("tp", "tp");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command
|
* Command
|
||||||
*/
|
*/
|
||||||
private final String command;
|
private final String command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias
|
* Alias
|
||||||
*/
|
*/
|
||||||
private final String alias;
|
private final String alias;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permission Node
|
* Permission Node
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -31,7 +30,6 @@ import com.intellectualcrafters.plot.BukkitMain;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class CommandPermission {
|
public class CommandPermission {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permission Node
|
* Permission Node
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.object.PlotComment;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Comment extends SubCommand {
|
public class Comment extends SubCommand {
|
||||||
|
|
||||||
public Comment() {
|
public Comment() {
|
||||||
super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
|
super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -49,11 +47,8 @@ public class Comment extends SubCommand {
|
|||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone");
|
final List<String> recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone");
|
||||||
|
|
||||||
if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) {
|
if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) {
|
||||||
|
|
||||||
if (BukkitMain.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) {
|
if (BukkitMain.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) {
|
||||||
final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
||||||
final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase()));
|
final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase()));
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -40,9 +39,7 @@ import com.intellectualcrafters.plot.util.PlotHelper;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Condense extends SubCommand {
|
public class Condense extends SubCommand {
|
||||||
|
|
||||||
public static boolean TASK = false;
|
public static boolean TASK = false;
|
||||||
private static int TASK_ID = 0;
|
|
||||||
|
|
||||||
public Condense() {
|
public Condense() {
|
||||||
super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false);
|
super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false);
|
||||||
@ -54,13 +51,13 @@ public class Condense extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE));
|
PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 2 && args.length != 3) {
|
if ((args.length != 2) && (args.length != 3)) {
|
||||||
PlayerFunctions.sendMessage(plr, "/plot condense <world> <start|stop|info> [radius]");
|
PlayerFunctions.sendMessage(plr, "/plot condense <world> <start|stop|info> [radius]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String worldname = args[0];
|
final String worldname = args[0];
|
||||||
final World world = Bukkit.getWorld(worldname);
|
final World world = Bukkit.getWorld(worldname);
|
||||||
if (world == null || !PlotSquared.isPlotWorld(worldname)) {
|
if ((world == null) || !PlotSquared.isPlotWorld(worldname)) {
|
||||||
PlayerFunctions.sendMessage(plr, "INVALID WORLD");
|
PlayerFunctions.sendMessage(plr, "INVALID WORLD");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -82,19 +79,19 @@ public class Condense extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "INVALID RADIUS");
|
PlayerFunctions.sendMessage(plr, "INVALID RADIUS");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int radius = Integer.parseInt(args[2]);
|
final int radius = Integer.parseInt(args[2]);
|
||||||
Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
|
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
|
||||||
int size = plots.size();
|
final int size = plots.size();
|
||||||
int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1);
|
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||||
if (radius < minimum_radius) {
|
if (radius < minimum_radius) {
|
||||||
PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL");
|
PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final List<PlotId> to_move = new ArrayList<>(getPlots(plots, radius));
|
final List<PlotId> to_move = new ArrayList<>(getPlots(plots, radius));
|
||||||
final List<PlotId> free = new ArrayList<>();
|
final List<PlotId> free = new ArrayList<>();
|
||||||
PlotId start = new PlotId(0,0);
|
PlotId start = new PlotId(0, 0);
|
||||||
while (start.x <= minimum_radius && start.y <= minimum_radius) {
|
while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
|
||||||
Plot plot = PlotHelper.getPlot(world, start);
|
final Plot plot = PlotHelper.getPlot(world, start);
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
free.add(plot.id);
|
free.add(plot.id);
|
||||||
}
|
}
|
||||||
@ -110,25 +107,25 @@ public class Condense extends SubCommand {
|
|||||||
to_move.remove(0);
|
to_move.remove(0);
|
||||||
free.remove(0);
|
free.remove(0);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (PlotId id : to_move) {
|
for (final PlotId id : to_move) {
|
||||||
Plot plot = PlotHelper.getPlot(world, id);
|
final Plot plot = PlotHelper.getPlot(world, id);
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
for (int i = 0; i<index; i++) {
|
for (int i = 0; i < index; i++) {
|
||||||
to_move.remove(0);
|
to_move.remove(0);
|
||||||
}
|
}
|
||||||
index = 0;
|
index = 0;
|
||||||
for (PlotId id : free) {
|
for (final PlotId id : free) {
|
||||||
Plot plot = PlotHelper.getPlot(world, id);
|
final Plot plot = PlotHelper.getPlot(world, id);
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
for (int i = 0; i<index; i++) {
|
for (int i = 0; i < index; i++) {
|
||||||
free.remove(0);
|
free.remove(0);
|
||||||
}
|
}
|
||||||
if (to_move.size() == 0) {
|
if (to_move.size() == 0) {
|
||||||
@ -141,7 +138,7 @@ public class Condense extends SubCommand {
|
|||||||
TASK = false;
|
TASK = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendMessage("MOVING " + to_move.get(0) +" to " + free.get(0));
|
sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0));
|
||||||
PlotHelper.move(world, to_move.get(0), free.get(0), this);
|
PlotHelper.move(world, to_move.get(0), free.get(0), this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -167,16 +164,16 @@ public class Condense extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "INVALID RADIUS");
|
PlayerFunctions.sendMessage(plr, "INVALID RADIUS");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int radius = Integer.parseInt(args[2]);
|
final int radius = Integer.parseInt(args[2]);
|
||||||
Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
|
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
|
||||||
int size = plots.size();
|
final int size = plots.size();
|
||||||
int minimum_radius = (int) Math.ceil((Math.sqrt(size)/2) + 1);
|
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||||
if (radius < minimum_radius) {
|
if (radius < minimum_radius) {
|
||||||
PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL");
|
PlayerFunctions.sendMessage(plr, "RADIUS TOO SMALL");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int max_move = getPlots(plots, minimum_radius).size();
|
final int max_move = getPlots(plots, minimum_radius).size();
|
||||||
int user_move = getPlots(plots, radius).size();
|
final int user_move = getPlots(plots, radius).size();
|
||||||
PlayerFunctions.sendMessage(plr, "=== DEFAULT EVAL ===");
|
PlayerFunctions.sendMessage(plr, "=== DEFAULT EVAL ===");
|
||||||
PlayerFunctions.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius);
|
PlayerFunctions.sendMessage(plr, "MINIMUM RADIUS: " + minimum_radius);
|
||||||
PlayerFunctions.sendMessage(plr, "MAXIMUM MOVES: " + max_move);
|
PlayerFunctions.sendMessage(plr, "MAXIMUM MOVES: " + max_move);
|
||||||
@ -192,10 +189,10 @@ public class Condense extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
|
public Set<PlotId> getPlots(final Collection<Plot> plots, final int radius) {
|
||||||
HashSet<PlotId> outside = new HashSet<>();
|
final HashSet<PlotId> outside = new HashSet<>();
|
||||||
for (Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
if (plot.id.x > radius || plot.id.x < -radius || plot.id.y > radius || plot.id.y < -radius) {
|
if ((plot.id.x > radius) || (plot.id.x < -radius) || (plot.id.y > radius) || (plot.id.y < -radius)) {
|
||||||
outside.add(plot.id);
|
outside.add(plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,5 +202,4 @@ public class Condense extends SubCommand {
|
|||||||
public static void sendMessage(final String message) {
|
public static void sendMessage(final String message) {
|
||||||
PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message);
|
PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -31,7 +30,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Copy extends SubCommand {
|
public class Copy extends SubCommand {
|
||||||
|
|
||||||
public Copy() {
|
public Copy() {
|
||||||
super(Command.COPY, "Copy a plot", "copy", CommandCategory.ACTIONS, true);
|
super(Command.COPY, "Copy a plot", "copy", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -32,31 +31,24 @@ import com.intellectualcrafters.plot.util.PlotHelper;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class CreateRoadSchematic extends SubCommand {
|
public class CreateRoadSchematic extends SubCommand {
|
||||||
|
|
||||||
public CreateRoadSchematic() {
|
public CreateRoadSchematic() {
|
||||||
super(Command.CREATEROADSCHEMATIC, "Add a road schematic to your world using the road around your current plot", "crs", CommandCategory.DEBUG, true);
|
super(Command.CREATEROADSCHEMATIC, "Add a road schematic to your world using the road around your current plot", "crs", CommandCategory.DEBUG, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player player, final String... args) {
|
public boolean execute(final Player player, final String... args) {
|
||||||
|
|
||||||
if (!PlayerFunctions.isInPlot(player)) {
|
if (!PlayerFunctions.isInPlot(player)) {
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) {
|
if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) {
|
||||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Plot plot = PlayerFunctions.getCurrentPlot(player);
|
final Plot plot = PlayerFunctions.getCurrentPlot(player);
|
||||||
|
final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
|
||||||
HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
|
|
||||||
|
|
||||||
manager.setupRoadSchematic(plot);
|
manager.setupRoadSchematic(plot);
|
||||||
PlotHelper.update(BukkitUtil.getLocation(entity));
|
PlotHelper.update(BukkitUtil.getLocation(entity));
|
||||||
PlayerFunctions.sendMessage(player, "&6Saved new road schematic");
|
PlayerFunctions.sendMessage(player, "&6Saved new road schematic");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class DEOP extends SubCommand {
|
public class DEOP extends SubCommand {
|
||||||
|
|
||||||
public DEOP() {
|
public DEOP() {
|
||||||
super(Command.DEOP, "Alias for /plot trusted remove", "/plot deop [player]", CommandCategory.ACTIONS, true);
|
super(Command.DEOP, "Alias for /plot trusted remove", "/plot deop [player]", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Database extends SubCommand {
|
public class Database extends SubCommand {
|
||||||
|
final String[] tables = new String[] { "plot_trusted", "plot_ratings", "plot_comments" };
|
||||||
final String[] tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"};
|
|
||||||
|
|
||||||
public Database() {
|
public Database() {
|
||||||
super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false);
|
super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false);
|
||||||
@ -76,7 +75,7 @@ public class Database extends SubCommand {
|
|||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
return sendMessage(plr, "/plot database [sqlite/mysql]");
|
return sendMessage(plr, "/plot database [sqlite/mysql]");
|
||||||
}
|
}
|
||||||
final String type = new StringComparison(args[0], new String[]{"mysql", "sqlite"}).getBestMatch().toLowerCase();
|
final String type = new StringComparison(args[0], new String[] { "mysql", "sqlite" }).getBestMatch().toLowerCase();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if (args.length < 6) {
|
if (args.length < 6) {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -33,7 +32,6 @@ import com.intellectualcrafters.plot.util.RUtils;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Debug extends SubCommand {
|
public class Debug extends SubCommand {
|
||||||
|
|
||||||
public Debug() {
|
public Debug() {
|
||||||
super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false);
|
super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -50,7 +49,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class DebugClaimTest extends SubCommand {
|
public class DebugClaimTest extends SubCommand {
|
||||||
|
|
||||||
public DebugClaimTest() {
|
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);
|
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);
|
||||||
}
|
}
|
||||||
@ -84,13 +82,10 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
if ((world == null) || !PlotSquared.isPlotWorld(world)) {
|
if ((world == null) || !PlotSquared.isPlotWorld(world)) {
|
||||||
return !PlayerFunctions.sendMessage(null, "&cInvalid plot world!");
|
return !PlayerFunctions.sendMessage(null, "&cInvalid plot world!");
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotId min, max;
|
PlotId min, max;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final String[] split1 = args[1].split(";");
|
final String[] split1 = args[1].split(";");
|
||||||
final String[] split2 = args[2].split(";");
|
final String[] split2 = args[2].split(";");
|
||||||
|
|
||||||
min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]));
|
min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]));
|
||||||
max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1]));
|
max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1]));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@ -98,12 +93,9 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
|
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
|
||||||
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
||||||
|
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
|
|
||||||
final ArrayList<Plot> plots = new ArrayList<>();
|
final ArrayList<Plot> plots = new ArrayList<>();
|
||||||
|
|
||||||
for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) {
|
for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) {
|
||||||
final Plot plot = PlotHelper.getPlot(world, id);
|
final Plot plot = PlotHelper.getPlot(world, id);
|
||||||
final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id);
|
final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id);
|
||||||
@ -111,18 +103,14 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Location loc = manager.getSignLoc(world, plotworld, plot);
|
final Location loc = manager.getSignLoc(world, plotworld, plot);
|
||||||
|
|
||||||
final Chunk chunk = world.getChunkAt(loc);
|
final Chunk chunk = world.getChunkAt(loc);
|
||||||
|
|
||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
final boolean result = chunk.load(false);
|
final boolean result = chunk.load(false);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Block block = world.getBlockAt(loc);
|
final Block block = world.getBlockAt(loc);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
if (block.getState() instanceof Sign) {
|
if (block.getState() instanceof Sign) {
|
||||||
@ -130,11 +118,8 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
String line = sign.getLine(2);
|
String line = sign.getLine(2);
|
||||||
if ((line != null) && (line.length() > 2)) {
|
if ((line != null) && (line.length() > 2)) {
|
||||||
line = line.substring(2);
|
line = line.substring(2);
|
||||||
|
|
||||||
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||||
|
|
||||||
UUID uuid = (map.get(new StringWrapper(line)));
|
UUID uuid = (map.get(new StringWrapper(line)));
|
||||||
|
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
for (final StringWrapper string : map.keySet()) {
|
for (final StringWrapper string : map.keySet()) {
|
||||||
if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
|
if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
|
||||||
@ -158,22 +143,17 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plots.size() > 0) {
|
if (plots.size() > 0) {
|
||||||
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
||||||
DBFunc.createPlots(plots);
|
DBFunc.createPlots(plots);
|
||||||
DBFunc.createAllSettingsAndHelpers(plots);
|
DBFunc.createAllSettingsAndHelpers(plots);
|
||||||
|
|
||||||
for (final Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
PlotSquared.updatePlot(plot);
|
PlotSquared.updatePlot(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(null, "No plots were found for the given search.");
|
PlayerFunctions.sendMessage(null, "No plots were found for the given search.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.");
|
PlayerFunctions.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.");
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -38,7 +37,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class DebugClear extends SubCommand {
|
public class DebugClear extends SubCommand {
|
||||||
|
|
||||||
public DebugClear() {
|
public DebugClear() {
|
||||||
super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false);
|
super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
@ -62,9 +60,9 @@ public class DebugClear extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
PlotSquared.log("Could not find plot " + args[0] + " in world " + world);
|
PlotSquared.log("Could not find plot " + args[0] + " in world " + world);
|
||||||
} else {
|
} else {
|
||||||
World bukkitWorld = Bukkit.getWorld(world);
|
final World bukkitWorld = Bukkit.getWorld(world);
|
||||||
Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
||||||
Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
|
final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
|
||||||
if (PlotHelper.runners.containsKey(plot)) {
|
if (PlotHelper.runners.containsKey(plot)) {
|
||||||
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||||
return false;
|
return false;
|
||||||
@ -84,7 +82,6 @@ public class DebugClear extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getWorldSettings(plr.getWorld()) instanceof SquarePlotWorld)) {
|
if (!PlayerFunctions.isInPlot(plr) || !(PlotSquared.getWorldSettings(plr.getWorld()) instanceof SquarePlotWorld)) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
@ -96,9 +93,9 @@ public class DebugClear extends SubCommand {
|
|||||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
World bukkitWorld = plr.getWorld();
|
final World bukkitWorld = plr.getWorld();
|
||||||
Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
||||||
Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
|
final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
|
||||||
if (PlotHelper.runners.containsKey(plot)) {
|
if (PlotHelper.runners.containsKey(plot)) {
|
||||||
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||||
return false;
|
return false;
|
||||||
@ -111,11 +108,8 @@ public class DebugClear extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "&aDone!");
|
PlayerFunctions.sendMessage(plr, "&aDone!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// sign
|
// sign
|
||||||
|
|
||||||
// wall
|
// wall
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -46,100 +45,94 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class DebugExec extends SubCommand {
|
public class DebugExec extends SubCommand {
|
||||||
|
|
||||||
private ArrayList<ChunkLoc> chunks = null;
|
|
||||||
private World world;
|
|
||||||
|
|
||||||
public DebugExec() {
|
public DebugExec() {
|
||||||
super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false);
|
super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player player, final String... args) {
|
public boolean execute(final Player player, final String... args) {
|
||||||
List<String> allowed_params = Arrays.asList(new String[]{"stop-expire","start-expire", "show-expired", "update-expired", "seen", "trim-check"});
|
final List<String> allowed_params = Arrays.asList(new String[] { "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check" });
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String arg = args[0].toLowerCase();
|
final String arg = args[0].toLowerCase();
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "stop-expire": {
|
case "stop-expire": {
|
||||||
if (ExpireManager.task != -1) {
|
if (ExpireManager.task != -1) {
|
||||||
Bukkit.getScheduler().cancelTask(ExpireManager.task);
|
Bukkit.getScheduler().cancelTask(ExpireManager.task);
|
||||||
}
|
} else {
|
||||||
else {
|
return PlayerFunctions.sendMessage(null, "Task already halted");
|
||||||
return PlayerFunctions.sendMessage(null, "Task already halted");
|
|
||||||
}
|
|
||||||
ExpireManager.task = -1;
|
|
||||||
return PlayerFunctions.sendMessage(null, "Cancelled task.");
|
|
||||||
}
|
|
||||||
case "start-expire": {
|
|
||||||
if (ExpireManager.task == -1) {
|
|
||||||
ExpireManager.runTask();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return PlayerFunctions.sendMessage(null, "Plot expiry task already started");
|
|
||||||
}
|
|
||||||
return PlayerFunctions.sendMessage(null, "Started plot expiry task");
|
|
||||||
}
|
|
||||||
case "update-expired": {
|
|
||||||
if (args.length > 1) {
|
|
||||||
World world = Bukkit.getWorld(args[1]);
|
|
||||||
if (world == null) {
|
|
||||||
return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]);
|
|
||||||
}
|
|
||||||
PlayerFunctions.sendMessage(null, "Updating expired plot list");
|
|
||||||
ExpireManager.updateExpired(args[1]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired <world>");
|
|
||||||
}
|
|
||||||
case "show-expired": {
|
|
||||||
if (args.length > 1) {
|
|
||||||
World world = Bukkit.getWorld(args[1]);
|
|
||||||
if (world == null || !ExpireManager.expiredPlots.containsKey(args[1])) {
|
|
||||||
return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]);
|
|
||||||
}
|
|
||||||
PlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
|
|
||||||
for (Entry<Plot, Long> entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) {
|
|
||||||
Plot plot = entry.getKey();
|
|
||||||
Long stamp = entry.getValue();
|
|
||||||
PlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) +" : " + stamp);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return PlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired <world>");
|
|
||||||
}
|
|
||||||
case "seen": {
|
|
||||||
if (args.length != 2) {
|
|
||||||
return PlayerFunctions.sendMessage(null, "Use /plot debugexec seen <player>");
|
|
||||||
}
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1]);
|
|
||||||
if (uuid == null) {
|
|
||||||
return PlayerFunctions.sendMessage(null, "player not found: " + args[1]);
|
|
||||||
}
|
|
||||||
OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
|
||||||
if (op == null || !op.hasPlayedBefore()) {
|
|
||||||
return PlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]);
|
|
||||||
}
|
|
||||||
Timestamp stamp = new Timestamp(op.getLastPlayed());
|
|
||||||
Date date = new Date(stamp.getTime());
|
|
||||||
PlayerFunctions.sendMessage(null, "PLAYER: " + args[1]);
|
|
||||||
PlayerFunctions.sendMessage(null, "UUID: " + uuid);
|
|
||||||
PlayerFunctions.sendMessage(null, "Object: " + date.toGMTString());
|
|
||||||
PlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString());
|
|
||||||
PlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "trim-check": {
|
|
||||||
if (args.length != 2) {
|
|
||||||
PlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check <world>");
|
|
||||||
PlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim");
|
|
||||||
return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run");
|
|
||||||
}
|
|
||||||
final World world = Bukkit.getWorld(args[1]);
|
|
||||||
if (world == null || !PlotSquared.isPlotWorld(args[1])) {
|
|
||||||
return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]);
|
|
||||||
}
|
}
|
||||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
ExpireManager.task = -1;
|
||||||
boolean result = Trim.getTrimRegions(empty, world, new Runnable() {
|
return PlayerFunctions.sendMessage(null, "Cancelled task.");
|
||||||
|
}
|
||||||
|
case "start-expire": {
|
||||||
|
if (ExpireManager.task == -1) {
|
||||||
|
ExpireManager.runTask();
|
||||||
|
} else {
|
||||||
|
return PlayerFunctions.sendMessage(null, "Plot expiry task already started");
|
||||||
|
}
|
||||||
|
return PlayerFunctions.sendMessage(null, "Started plot expiry task");
|
||||||
|
}
|
||||||
|
case "update-expired": {
|
||||||
|
if (args.length > 1) {
|
||||||
|
final World world = Bukkit.getWorld(args[1]);
|
||||||
|
if (world == null) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]);
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(null, "Updating expired plot list");
|
||||||
|
ExpireManager.updateExpired(args[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired <world>");
|
||||||
|
}
|
||||||
|
case "show-expired": {
|
||||||
|
if (args.length > 1) {
|
||||||
|
final World world = Bukkit.getWorld(args[1]);
|
||||||
|
if ((world == null) || !ExpireManager.expiredPlots.containsKey(args[1])) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]);
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(null, "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
|
||||||
|
for (final Entry<Plot, Long> entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) {
|
||||||
|
final Plot plot = entry.getKey();
|
||||||
|
final Long stamp = entry.getValue();
|
||||||
|
PlayerFunctions.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return PlayerFunctions.sendMessage(null, "Use /plot debugexec show-expired <world>");
|
||||||
|
}
|
||||||
|
case "seen": {
|
||||||
|
if (args.length != 2) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "Use /plot debugexec seen <player>");
|
||||||
|
}
|
||||||
|
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
|
if (uuid == null) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "player not found: " + args[1]);
|
||||||
|
}
|
||||||
|
final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
if ((op == null) || !op.hasPlayedBefore()) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "player hasn't connected before: " + args[1]);
|
||||||
|
}
|
||||||
|
final Timestamp stamp = new Timestamp(op.getLastPlayed());
|
||||||
|
final Date date = new Date(stamp.getTime());
|
||||||
|
PlayerFunctions.sendMessage(null, "PLAYER: " + args[1]);
|
||||||
|
PlayerFunctions.sendMessage(null, "UUID: " + uuid);
|
||||||
|
PlayerFunctions.sendMessage(null, "Object: " + date.toGMTString());
|
||||||
|
PlayerFunctions.sendMessage(null, "GMT: " + date.toGMTString());
|
||||||
|
PlayerFunctions.sendMessage(null, "Local: " + date.toLocaleString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "trim-check": {
|
||||||
|
if (args.length != 2) {
|
||||||
|
PlayerFunctions.sendMessage(null, "Use /plot debugexec trim-check <world>");
|
||||||
|
PlayerFunctions.sendMessage(null, "&7 - Generates a list of regions to trim");
|
||||||
|
return PlayerFunctions.sendMessage(null, "&7 - Run after plot expiry has run");
|
||||||
|
}
|
||||||
|
final World world = Bukkit.getWorld(args[1]);
|
||||||
|
if ((world == null) || !PlotSquared.isPlotWorld(args[1])) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "Invalid world: " + args[1]);
|
||||||
|
}
|
||||||
|
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||||
|
final boolean result = Trim.getTrimRegions(empty, world, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Trim.sendMessage("Processing is complete! Here's how many chunks would be deleted:");
|
Trim.sendMessage("Processing is complete! Here's how many chunks would be deleted:");
|
||||||
@ -150,13 +143,13 @@ public class DebugExec extends SubCommand {
|
|||||||
PrintWriter writer;
|
PrintWriter writer;
|
||||||
try {
|
try {
|
||||||
writer = new PrintWriter(file);
|
writer = new PrintWriter(file);
|
||||||
String worldname = world.getName();
|
final String worldname = world.getName();
|
||||||
for (ChunkLoc loc : empty) {
|
for (final ChunkLoc loc : empty) {
|
||||||
writer.println(worldname +"/region/r." + loc.x + "." + loc.z +".mca" );
|
writer.println(worldname + "/region/r." + loc.x + "." + loc.z + ".mca");
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'");
|
Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'");
|
||||||
} catch (FileNotFoundException e) {
|
} catch (final FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Trim.sendMessage("File failed to save! :(");
|
Trim.sendMessage("File failed to save! :(");
|
||||||
}
|
}
|
||||||
@ -166,14 +159,14 @@ public class DebugExec extends SubCommand {
|
|||||||
Trim.sendMessage(" - Add 31 to each number to get the end position");
|
Trim.sendMessage(" - Add 31 to each number to get the end position");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlayerFunctions.sendMessage(null, "Trim task already started!");
|
PlayerFunctions.sendMessage(null, "Trim task already started!");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">");
|
PlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -38,7 +37,6 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class DebugFixFlags extends SubCommand {
|
public class DebugFixFlags extends SubCommand {
|
||||||
|
|
||||||
public DebugFixFlags() {
|
public DebugFixFlags() {
|
||||||
super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false);
|
super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
@ -53,22 +51,22 @@ public class DebugFixFlags extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags <world>");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags <world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
World world = Bukkit.getWorld(args[0]);
|
final World world = Bukkit.getWorld(args[0]);
|
||||||
if (world == null || !PlotSquared.isPlotWorld(world)) {
|
if ((world == null) || !PlotSquared.isPlotWorld(world)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
PlayerFunctions.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
||||||
for (Plot plot : PlotSquared.getPlots(world).values()) {
|
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
||||||
Set<Flag> flags = plot.settings.flags;
|
final Set<Flag> flags = plot.settings.flags;
|
||||||
ArrayList<Flag> toRemove = new ArrayList<Flag>();
|
final ArrayList<Flag> toRemove = new ArrayList<Flag>();
|
||||||
for (Flag flag : flags) {
|
for (final Flag flag : flags) {
|
||||||
AbstractFlag af = FlagManager.getFlag(flag.getKey());
|
final AbstractFlag af = FlagManager.getFlag(flag.getKey());
|
||||||
if (af == null) {
|
if (af == null) {
|
||||||
toRemove.add(flag);
|
toRemove.add(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Flag flag : toRemove) {
|
for (final Flag flag : toRemove) {
|
||||||
plot.settings.flags.remove(flag);
|
plot.settings.flags.remove(flag);
|
||||||
}
|
}
|
||||||
if (toRemove.size() > 0) {
|
if (toRemove.size() > 0) {
|
||||||
@ -76,7 +74,6 @@ public class DebugFixFlags extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, "&aDone!");
|
PlayerFunctions.sendMessage(plr, "&aDone!");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -33,7 +32,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class DebugLoadTest extends SubCommand {
|
public class DebugLoadTest extends SubCommand {
|
||||||
|
|
||||||
public DebugLoadTest() {
|
public DebugLoadTest() {
|
||||||
super(Command.DEBUGLOADTEST, "This debug command will force the reload of all plots in the DB", "debugloadtest", CommandCategory.DEBUG, false);
|
super(Command.DEBUGLOADTEST, "This debug command will force the reload of all plots in the DB", "debugloadtest", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -34,7 +33,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.SetBlockManager;
|
import com.intellectualcrafters.plot.util.bukkit.SetBlockManager;
|
||||||
|
|
||||||
public class DebugRoadRegen extends SubCommand {
|
public class DebugRoadRegen extends SubCommand {
|
||||||
|
|
||||||
public DebugRoadRegen() {
|
public DebugRoadRegen() {
|
||||||
super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true);
|
super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true);
|
||||||
}
|
}
|
||||||
@ -44,14 +42,13 @@ public class DebugRoadRegen extends SubCommand {
|
|||||||
if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) {
|
if (!(PlotSquared.getWorldSettings(player.getWorld()) instanceof HybridPlotWorld)) {
|
||||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
|
final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
|
||||||
|
final Chunk chunk = BukkitUtil.getLocation(entity).getChunk();
|
||||||
Chunk chunk = BukkitUtil.getLocation(entity).getChunk();
|
final boolean result = manager.regenerateRoad(chunk);
|
||||||
boolean result = manager.regenerateRoad(chunk);
|
|
||||||
if (result) {
|
if (result) {
|
||||||
SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] {chunk}));
|
SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(player, "&6Regenerating chunk: "+chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
|
PlayerFunctions.sendMessage(player, "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -34,7 +33,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class DebugSaveTest extends SubCommand {
|
public class DebugSaveTest extends SubCommand {
|
||||||
|
|
||||||
public DebugSaveTest() {
|
public DebugSaveTest() {
|
||||||
super(Command.DEBUGSAVETEST, "This debug command will force the recreation of all plots in the DB", "debugsavetest", CommandCategory.DEBUG, false);
|
super(Command.DEBUGSAVETEST, "This debug command will force the recreation of all plots in the DB", "debugsavetest", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Delete extends SubCommand {
|
public class Delete extends SubCommand {
|
||||||
|
|
||||||
public Delete() {
|
public Delete() {
|
||||||
super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS, true);
|
super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -34,8 +33,8 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public class Denied extends SubCommand {
|
@SuppressWarnings("deprecation")
|
||||||
|
public class Denied extends SubCommand {
|
||||||
public Denied() {
|
public Denied() {
|
||||||
super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS, true);
|
super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -63,7 +62,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
UUID uuid;
|
UUID uuid;
|
||||||
if (args[1].equalsIgnoreCase("*")) {
|
if (args[1].equalsIgnoreCase("*")) {
|
||||||
uuid = DBFunc.everyone;
|
uuid = DBFunc.everyone;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
uuid = UUIDHandler.getUUID(args[1]);
|
uuid = UUIDHandler.getUUID(args[1]);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -40,7 +39,6 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class FlagCmd extends SubCommand {
|
public class FlagCmd extends SubCommand {
|
||||||
|
|
||||||
public FlagCmd() {
|
public FlagCmd() {
|
||||||
super(Command.FLAG, "Manage plot flags", "f", CommandCategory.ACTIONS, true);
|
super(Command.FLAG, "Manage plot flags", "f", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -58,7 +56,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
|
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(player);
|
final Plot plot = PlayerFunctions.getCurrentPlot(player);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
@ -81,7 +79,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AbstractFlag af = FlagManager.getFlag(args[1]);
|
final AbstractFlag af = FlagManager.getFlag(args[1]);
|
||||||
if (af == null) {
|
if (af == null) {
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||||
@ -104,7 +102,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set <flag> <value>");
|
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set <flag> <value>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||||
if (af == null) {
|
if (af == null) {
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
@ -113,14 +111,14 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
Object parsed = af.parseValueRaw(value);
|
final Object parsed = af.parseValueRaw(value);
|
||||||
if (parsed == null) {
|
if (parsed == null) {
|
||||||
PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc());
|
PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
|
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
|
||||||
boolean result = FlagManager.addPlotFlag(plot, flag);
|
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED);
|
PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||||
return false;
|
return false;
|
||||||
@ -134,11 +132,11 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove");
|
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 2 && args.length != 3) {
|
if ((args.length != 2) && (args.length != 3)) {
|
||||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||||
if (af == null) {
|
if (af == null) {
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
@ -147,18 +145,17 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
|
final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 3 && flag.getAbstractFlag().isList()) {
|
if ((args.length == 3) && flag.getAbstractFlag().isList()) {
|
||||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
|
((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
|
||||||
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||||
}
|
} else {
|
||||||
else {
|
final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
|
||||||
boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED);
|
PlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||||
return false;
|
return false;
|
||||||
@ -177,7 +174,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
|
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
|
||||||
if (af == null) {
|
if (af == null) {
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
@ -186,20 +183,19 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
Object parsed = af.parseValueRaw(value);
|
final Object parsed = af.parseValueRaw(value);
|
||||||
if (parsed == null) {
|
if (parsed == null) {
|
||||||
PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc());
|
PlayerFunctions.sendMessage(player, "&c" + af.getValueDesc());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase());
|
Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase());
|
||||||
if (flag == null || !flag.getAbstractFlag().isList()) {
|
if ((flag == null) || !flag.getAbstractFlag().isList()) {
|
||||||
flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
|
flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
((FlagValue.ListValue) flag.getAbstractFlag().value).add(flag.getValue(), value);
|
((FlagValue.ListValue) flag.getAbstractFlag().value).add(flag.getValue(), value);
|
||||||
}
|
}
|
||||||
boolean result = FlagManager.addPlotFlag(plot, flag);
|
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED);
|
PlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||||
return false;
|
return false;
|
||||||
@ -218,9 +214,9 @@ public class FlagCmd extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list");
|
PlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
final HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||||
for (AbstractFlag af : FlagManager.getFlags()) {
|
for (final AbstractFlag af : FlagManager.getFlags()) {
|
||||||
String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
|
final String type = af.value.getClass().getSimpleName().replaceAll("Value", "");
|
||||||
if (!flags.containsKey(type)) {
|
if (!flags.containsKey(type)) {
|
||||||
flags.put(type, new ArrayList<String>());
|
flags.put(type, new ArrayList<String>());
|
||||||
}
|
}
|
||||||
@ -228,8 +224,8 @@ public class FlagCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
String message = "";
|
String message = "";
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
for (String flag : flags.keySet()) {
|
for (final String flag : flags.keySet()) {
|
||||||
message += prefix + "&6" + flag +": &7" + StringUtils.join(flags.get(flag), ", ");
|
message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", ");
|
||||||
prefix = "\n";
|
prefix = "\n";
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(player, message);
|
PlayerFunctions.sendMessage(player, message);
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*
|
*
|
||||||
* >> File = Help.java >> Generated by: Citymonstret at 2014-08-11 17:32
|
* >> File = Help.java >> Generated by: Citymonstret at 2014-08-11 17:32
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Helpers extends SubCommand {
|
public class Helpers extends SubCommand {
|
||||||
|
|
||||||
public Helpers() {
|
public Helpers() {
|
||||||
super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS, true);
|
super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -33,7 +32,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Home extends SubCommand {
|
public class Home extends SubCommand {
|
||||||
|
|
||||||
public Home() {
|
public Home() {
|
||||||
super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT, true);
|
super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT, true);
|
||||||
}
|
}
|
||||||
@ -55,7 +53,7 @@ public class Home extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
} else if (plots.length > 1) {
|
} else if (plots.length > 1) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
args = new String[]{"1"};
|
args = new String[] { "1" };
|
||||||
}
|
}
|
||||||
int id = 0;
|
int id = 0;
|
||||||
try {
|
try {
|
||||||
@ -87,8 +85,7 @@ public class Home extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportPlayer(Player player, Plot plot) {
|
public void teleportPlayer(final Player player, final Plot plot) {
|
||||||
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -39,51 +38,49 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Inbox extends SubCommand {
|
public class Inbox extends SubCommand {
|
||||||
|
|
||||||
public Inbox() {
|
public Inbox() {
|
||||||
super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true);
|
super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
boolean report = false;
|
boolean report = false;
|
||||||
if (args.length == 1){
|
if (args.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("reports")) {
|
if (args[0].equalsIgnoreCase("reports")) {
|
||||||
report = true;
|
report = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!PlayerFunctions.isInPlot(plr) && !report) {
|
if (!PlayerFunctions.isInPlot(plr) && !report) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
if (plot != null && !plot.hasOwner()) {
|
if ((plot != null) && !plot.hasOwner()) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer tier;
|
Integer tier;
|
||||||
final UUID uuid = UUIDHandler.getUUID(plr);
|
final UUID uuid = UUIDHandler.getUUID(plr);
|
||||||
if (BukkitMain.hasPermission(plr, "plots.comment.admin")) {
|
if (BukkitMain.hasPermission(plr, "plots.comment.admin")) {
|
||||||
tier = 0;
|
tier = 0;
|
||||||
} else if (plot != null && plot.owner.equals(uuid)) {
|
} else if ((plot != null) && plot.owner.equals(uuid)) {
|
||||||
tier = 1;
|
tier = 1;
|
||||||
} else if (plot != null && plot.helpers.contains(uuid)) {
|
} else if ((plot != null) && plot.helpers.contains(uuid)) {
|
||||||
tier = 2;
|
tier = 2;
|
||||||
} else if (plot != null && plot.trusted.contains(uuid)) {
|
} else if ((plot != null) && plot.trusted.contains(uuid)) {
|
||||||
tier = 3;
|
tier = 3;
|
||||||
} else {
|
} else {
|
||||||
tier = 4;
|
tier = 4;
|
||||||
}
|
}
|
||||||
final boolean below;
|
final boolean below;
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
below = false;
|
below = false;
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "admin":
|
case "admin":
|
||||||
if (tier <= 0) {
|
if (tier <= 0) {
|
||||||
tier = 0;
|
tier = 0;
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -91,7 +88,7 @@ public class Inbox extends SubCommand {
|
|||||||
if (tier <= 1) {
|
if (tier <= 1) {
|
||||||
tier = 1;
|
tier = 1;
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -99,7 +96,7 @@ public class Inbox extends SubCommand {
|
|||||||
if (tier <= 2) {
|
if (tier <= 2) {
|
||||||
tier = 2;
|
tier = 2;
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -107,7 +104,7 @@ public class Inbox extends SubCommand {
|
|||||||
if (tier <= 3) {
|
if (tier <= 3) {
|
||||||
tier = 3;
|
tier = 3;
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -115,45 +112,40 @@ public class Inbox extends SubCommand {
|
|||||||
if (tier <= 4) {
|
if (tier <= 4) {
|
||||||
tier = 4;
|
tier = 4;
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "reports":
|
case "reports":
|
||||||
if (tier <= 0) {
|
if (tier <= 0) {
|
||||||
tier = -1;
|
tier = -1;
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[]{"admin", "owner", "helper", "trusted", "everyone"}, Math.max(0, tier), 4));
|
PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
below = true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
below = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String world = plr.getWorld().getName();
|
final String world = plr.getWorld().getName();
|
||||||
final int tier2 = tier;
|
final int tier2 = tier;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(PlotSquared.getMain(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ArrayList<PlotComment> comments = null;
|
ArrayList<PlotComment> comments = null;
|
||||||
if (tier2 == -1) {
|
if (tier2 == -1) {
|
||||||
comments = DBFunc.getComments(world, null, 0, false);
|
comments = DBFunc.getComments(world, null, 0, false);
|
||||||
}
|
} else {
|
||||||
else {
|
comments = plot.settings.getComments(tier2);
|
||||||
comments = plot.settings.getComments(tier2);
|
}
|
||||||
}
|
|
||||||
if (comments == null) {
|
if (comments == null) {
|
||||||
comments = DBFunc.getComments(world, plot, tier2, below);
|
comments = DBFunc.getComments(world, plot, tier2, below);
|
||||||
plot.settings.setComments(comments);
|
plot.settings.setComments(comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
final String[] split = args[1].toLowerCase().split(":");
|
final String[] split = args[1].toLowerCase().split(":");
|
||||||
if (!split[0].equals("clear")) {
|
if (!split[0].equals("clear")) {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -46,8 +45,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"javadoc"}) public class Info extends SubCommand {
|
@SuppressWarnings({ "javadoc" })
|
||||||
|
public class Info extends SubCommand {
|
||||||
public Info() {
|
public Info() {
|
||||||
super(Command.INFO, "Display plot info", "info", CommandCategory.INFO, false);
|
super(Command.INFO, "Display plot info", "info", CommandCategory.INFO, false);
|
||||||
}
|
}
|
||||||
@ -87,7 +86,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
}
|
}
|
||||||
world = Bukkit.getWorld(args[0]);
|
world = Bukkit.getWorld(args[0]);
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
args = new String[]{args[2]};
|
args = new String[] { args[2] };
|
||||||
} else {
|
} else {
|
||||||
args = new String[0];
|
args = new String[0];
|
||||||
}
|
}
|
||||||
@ -96,28 +95,23 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
|
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
|
||||||
new InfoInventory(plot, player).build().display();
|
new InfoInventory(plot, player).build().display();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean hasOwner = plot.hasOwner();
|
final boolean hasOwner = plot.hasOwner();
|
||||||
boolean containsEveryone;
|
boolean containsEveryone;
|
||||||
boolean trustedEveryone;
|
boolean trustedEveryone;
|
||||||
|
|
||||||
// Wildcard player {added}
|
// Wildcard player {added}
|
||||||
{
|
{
|
||||||
containsEveryone = (plot.helpers != null) && plot.helpers.contains(DBFunc.everyone);
|
containsEveryone = (plot.helpers != null) && plot.helpers.contains(DBFunc.everyone);
|
||||||
trustedEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone);
|
trustedEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unclaimed?
|
// Unclaimed?
|
||||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||||
PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y));
|
PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
if (plot.owner != null) {
|
if (plot.owner != null) {
|
||||||
owner = UUIDHandler.getName(plot.owner);
|
owner = UUIDHandler.getName(plot.owner);
|
||||||
@ -126,7 +120,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
owner = plot.owner.toString();
|
owner = plot.owner.toString();
|
||||||
}
|
}
|
||||||
String info = C.PLOT_INFO.s();
|
String info = C.PLOT_INFO.s();
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
info = getCaption(args[0].toLowerCase());
|
info = getCaption(args[0].toLowerCase());
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
@ -134,7 +127,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info = format(info, world, plot, player);
|
info = format(info, world, plot, player);
|
||||||
PlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER);
|
PlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER);
|
||||||
PlayerFunctions.sendMessage(player, info, false);
|
PlayerFunctions.sendMessage(player, info, false);
|
||||||
@ -169,7 +161,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String format(String info, final World world, final Plot plot, final Player player) {
|
private String format(String info, final World world, final Plot plot, final Player player) {
|
||||||
|
|
||||||
final PlotId id = plot.id;
|
final PlotId id = plot.id;
|
||||||
final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id;
|
final PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id;
|
||||||
final int num = PlayerFunctions.getPlotSelectionIds(id, id2).size();
|
final int num = PlayerFunctions.getPlotSelectionIds(id, id2).size();
|
||||||
@ -181,7 +172,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
final String rating = String.format("%.1f", DBFunc.getRatings(plot));
|
final String rating = String.format("%.1f", DBFunc.getRatings(plot));
|
||||||
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none");
|
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none");
|
||||||
final boolean build = (player == null) || plot.hasRights(player);
|
final boolean build = (player == null) || plot.hasRights(player);
|
||||||
|
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
if (plot.owner != null) {
|
if (plot.owner != null) {
|
||||||
owner = UUIDHandler.getName(plot.owner);
|
owner = UUIDHandler.getName(plot.owner);
|
||||||
@ -189,7 +179,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
owner = plot.owner.toString();
|
owner = plot.owner.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
info = info.replaceAll("%alias%", alias);
|
info = info.replaceAll("%alias%", alias);
|
||||||
info = info.replaceAll("%id%", id.toString());
|
info = info.replaceAll("%id%", id.toString());
|
||||||
info = info.replaceAll("%id2%", id2.toString());
|
info = info.replaceAll("%id2%", id2.toString());
|
||||||
@ -203,7 +192,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
info = info.replaceAll("%flags%", flags);
|
info = info.replaceAll("%flags%", flags);
|
||||||
info = info.replaceAll("%build%", build + "");
|
info = info.replaceAll("%build%", build + "");
|
||||||
info = info.replaceAll("%desc%", "No description set.");
|
info = info.replaceAll("%desc%", "No description set.");
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +218,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
|
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
|
||||||
return "everyone";
|
return "everyone";
|
||||||
}
|
}
|
||||||
String name = UUIDHandler.getName(uuid);
|
final String name = UUIDHandler.getName(uuid);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -31,7 +30,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class Inventory extends SubCommand {
|
public class Inventory extends SubCommand {
|
||||||
|
|
||||||
public Inventory() {
|
public Inventory() {
|
||||||
super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO, true);
|
super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -30,8 +29,8 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "deprecation", "javadoc"}) public class Kick extends SubCommand {
|
@SuppressWarnings({ "unused", "deprecation", "javadoc" })
|
||||||
|
public class Kick extends SubCommand {
|
||||||
public Kick() {
|
public Kick() {
|
||||||
super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS, true);
|
super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -44,12 +43,10 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class MainCommand implements CommandExecutor, TabCompleter {
|
public class MainCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Permission Node
|
* Main Permission Node
|
||||||
*/
|
*/
|
||||||
private final static SubCommand[] _subCommands = new SubCommand[]{new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense() };
|
private final static SubCommand[] _subCommands = new SubCommand[] { new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense() };
|
||||||
|
|
||||||
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
addAll(Arrays.asList(_subCommands));
|
addAll(Arrays.asList(_subCommands));
|
||||||
@ -64,11 +61,11 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
public static List<SubCommand> getCommands(final SubCommand.CommandCategory category, final Player player) {
|
public static List<SubCommand> getCommands(final SubCommand.CommandCategory category, final Player player) {
|
||||||
final List<SubCommand> cmds = new ArrayList<>();
|
final List<SubCommand> cmds = new ArrayList<>();
|
||||||
for (final SubCommand c : subCommands) {
|
for (final SubCommand c : subCommands) {
|
||||||
if (!c.isPlayer || player != null) {
|
if (!c.isPlayer || (player != null)) {
|
||||||
if ((c.category.equals(category)) && c.permission.hasPermission(player)) {
|
if ((c.category.equals(category)) && c.permission.hasPermission(player)) {
|
||||||
cmds.add(c);
|
cmds.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmds;
|
return cmds;
|
||||||
}
|
}
|
||||||
@ -91,15 +88,11 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (max > commands.size()) {
|
if (max > commands.size()) {
|
||||||
max = commands.size();
|
max = commands.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> help = new ArrayList<>();
|
final List<String> help = new ArrayList<>();
|
||||||
|
|
||||||
help.add(C.HELP_HEADER.s());
|
help.add(C.HELP_HEADER.s());
|
||||||
// HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"),
|
// HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"),
|
||||||
help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size()));
|
help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size()));
|
||||||
|
|
||||||
SubCommand cmd;
|
SubCommand cmd;
|
||||||
|
|
||||||
final int start = page * perPage;
|
final int start = page * perPage;
|
||||||
for (int x = start; x < max; x++) {
|
for (int x = start; x < max; x++) {
|
||||||
cmd = commands.get(x);
|
cmd = commands.get(x);
|
||||||
@ -120,11 +113,9 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
|
||||||
final Player player = (sender instanceof Player) ? (Player) sender : null;
|
final Player player = (sender instanceof Player) ? (Player) sender : null;
|
||||||
|
|
||||||
if (!BukkitMain.hasPermission(player, PlotSquared.MAIN_PERMISSION)) {
|
if (!BukkitMain.hasPermission(player, PlotSquared.MAIN_PERMISSION)) {
|
||||||
return no_permission(player, PlotSquared.MAIN_PERMISSION);
|
return no_permission(player, PlotSquared.MAIN_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
|
if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
@ -143,7 +134,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cato == null && !cat.equalsIgnoreCase("all")) {
|
if ((cato == null) && !cat.equalsIgnoreCase("all")) {
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
builder.append(C.HELP_INFO.s());
|
builder.append(C.HELP_INFO.s());
|
||||||
for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
|
for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
|
||||||
@ -153,16 +144,13 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
final StringBuilder help = new StringBuilder();
|
final StringBuilder help = new StringBuilder();
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
boolean digit = true;
|
boolean digit = true;
|
||||||
|
|
||||||
String arg2;
|
String arg2;
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
arg2 = args[2];
|
arg2 = args[2];
|
||||||
} else {
|
} else {
|
||||||
arg2 = "1";
|
arg2 = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final char c : arg2.toCharArray()) {
|
for (final char c : arg2.toCharArray()) {
|
||||||
if (!Character.isDigit(c)) {
|
if (!Character.isDigit(c)) {
|
||||||
digit = false;
|
digit = false;
|
||||||
@ -175,7 +163,6 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
page = 0;
|
page = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final String string : helpMenu(player, cato, page)) {
|
for (final String string : helpMenu(player, cato, page)) {
|
||||||
help.append(string).append("\n");
|
help.append(string).append("\n");
|
||||||
}
|
}
|
||||||
@ -198,12 +185,10 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
PlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||||
|
|
||||||
final String[] commands = new String[subCommands.size()];
|
final String[] commands = new String[subCommands.size()];
|
||||||
for (int x = 0; x < subCommands.size(); x++) {
|
for (int x = 0; x < subCommands.size(); x++) {
|
||||||
commands[x] = subCommands.get(x).cmd;
|
commands[x] = subCommands.get(x).cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let's try to get a proper usage string */
|
/* Let's try to get a proper usage string */
|
||||||
final String command = new StringComparison(args[0], commands).getBestMatch();
|
final String command = new StringComparison(args[0], commands).getBestMatch();
|
||||||
return PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
|
return PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
|
||||||
@ -219,7 +204,6 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Player player = (Player) commandSender;
|
final Player player = (Player) commandSender;
|
||||||
|
|
||||||
if (strings.length < 1) {
|
if (strings.length < 1) {
|
||||||
if ((strings.length == 0) || "plots".startsWith(s)) {
|
if ((strings.length == 0) || "plots".startsWith(s)) {
|
||||||
return Arrays.asList("plots");
|
return Arrays.asList("plots");
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -45,9 +44,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Merge extends SubCommand {
|
public class Merge extends SubCommand {
|
||||||
|
public final static String[] values = new String[] { "north", "east", "south", "west" };
|
||||||
public final static String[] values = new String[]{"north", "east", "south", "west"};
|
public final static String[] aliases = new String[] { "n", "e", "s", "w" };
|
||||||
public final static String[] aliases = new String[]{"n", "e", "s", "w"};
|
|
||||||
|
|
||||||
public Merge() {
|
public Merge() {
|
||||||
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true);
|
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true);
|
||||||
@ -86,7 +84,7 @@ public class Merge extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED);
|
PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge");
|
final boolean admin = BukkitMain.hasPermission(plr, "plots.admin.command.merge");
|
||||||
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) {
|
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
@ -128,21 +126,15 @@ public class Merge extends SubCommand {
|
|||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
final PlotId botId = plots.get(0);
|
||||||
PlotId botId = plots.get(0);
|
final PlotId topId = plots.get(plots.size() - 1);
|
||||||
PlotId topId = plots.get(plots.size() - 1);
|
final PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id;
|
||||||
|
final PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id;
|
||||||
PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id;
|
final PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id;
|
||||||
PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id;
|
final PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id;
|
||||||
|
|
||||||
PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id;
|
|
||||||
PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id;
|
|
||||||
|
|
||||||
bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
|
bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
|
||||||
top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
|
top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
|
||||||
|
|
||||||
plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top);
|
plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top);
|
||||||
|
|
||||||
for (final PlotId myid : plots) {
|
for (final PlotId myid : plots) {
|
||||||
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
||||||
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) {
|
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) {
|
||||||
@ -150,7 +142,6 @@ public class Merge extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlotWorld plotWorld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotWorld = PlotSquared.getWorldSettings(world);
|
||||||
if (PlotSquared.useEconomy && plotWorld.USE_ECONOMY) {
|
if (PlotSquared.useEconomy && plotWorld.USE_ECONOMY) {
|
||||||
double cost = plotWorld.MERGE_PRICE;
|
double cost = plotWorld.MERGE_PRICE;
|
||||||
@ -165,9 +156,7 @@ public class Merge extends SubCommand {
|
|||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlotMergeEvent event = new PlotMergeEvent(world, plot, plots);
|
final PlotMergeEvent event = new PlotMergeEvent(world, plot, plots);
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -176,7 +165,6 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, "&cPlots have been merged");
|
PlayerFunctions.sendMessage(plr, "&cPlots have been merged");
|
||||||
PlotHelper.mergePlots(world, plots, true);
|
PlotHelper.mergePlots(world, plots, true);
|
||||||
|
|
||||||
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
||||||
PlotHelper.update(plr.getLocation());
|
PlotHelper.update(plr.getLocation());
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -34,7 +33,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class Move extends SubCommand {
|
public class Move extends SubCommand {
|
||||||
|
|
||||||
public Move() {
|
public Move() {
|
||||||
super("debugmove", "plots.admin", "plot moving debug test", "debugmove", "move", CommandCategory.DEBUG, true);
|
super("debugmove", "plots.admin", "plot moving debug test", "debugmove", "move", CommandCategory.DEBUG, true);
|
||||||
}
|
}
|
||||||
@ -48,10 +46,10 @@ public class Move extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "/plot move <pos1> <pos2>");
|
PlayerFunctions.sendMessage(plr, "/plot move <pos1> <pos2>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
World world = plr.getWorld();
|
final World world = plr.getWorld();
|
||||||
PlotId plot1 = PlotHelper.parseId(args[0]);
|
final PlotId plot1 = PlotHelper.parseId(args[0]);
|
||||||
PlotId plot2 = PlotHelper.parseId(args[1]);
|
final PlotId plot2 = PlotHelper.parseId(args[1]);
|
||||||
if (plot1 == null || plot2 == null) {
|
if ((plot1 == null) || (plot2 == null)) {
|
||||||
PlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move <pos1> <pos2>");
|
PlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move <pos1> <pos2>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -66,8 +64,7 @@ public class Move extends SubCommand {
|
|||||||
}
|
}
|
||||||
})) {
|
})) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
PlayerFunctions.sendMessage(plr, "MOVE FAILED");
|
PlayerFunctions.sendMessage(plr, "MOVE FAILED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class OP extends SubCommand {
|
public class OP extends SubCommand {
|
||||||
|
|
||||||
public OP() {
|
public OP() {
|
||||||
super(Command.OP, "Alias for /plot trusted add", "/plot op [player]", CommandCategory.ACTIONS, true);
|
super(Command.OP, "Alias for /plot trusted add", "/plot op [player]", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -31,7 +30,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Paste extends SubCommand {
|
public class Paste extends SubCommand {
|
||||||
|
|
||||||
public Paste() {
|
public Paste() {
|
||||||
super(Command.PASTE, "Paste a plot", "paste", CommandCategory.ACTIONS, true);
|
super(Command.PASTE, "Paste a plot", "paste", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -53,7 +51,6 @@ public class Paste extends SubCommand {
|
|||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
||||||
|
|
||||||
if (PlotSelection.currentSelection.containsKey(plr.getName())) {
|
if (PlotSelection.currentSelection.containsKey(plr.getName())) {
|
||||||
final PlotSelection selection = PlotSelection.currentSelection.get(plr.getName());
|
final PlotSelection selection = PlotSelection.currentSelection.get(plr.getName());
|
||||||
if (size != selection.getWidth()) {
|
if (size != selection.getWidth()) {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -38,18 +37,17 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@SuppressWarnings({"javadoc"}) public class Purge extends SubCommand {
|
@SuppressWarnings({ "javadoc" })
|
||||||
|
public class Purge extends SubCommand {
|
||||||
public Purge() {
|
public Purge() {
|
||||||
super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false);
|
super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotId getId(String id) {
|
public PlotId getId(final String id) {
|
||||||
try {
|
try {
|
||||||
String[] split = id.split(";");
|
final String[] split = id.split(";");
|
||||||
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,15 +59,15 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String arg = args[0].toLowerCase();
|
final String arg = args[0].toLowerCase();
|
||||||
PlotId id = getId(arg);
|
final PlotId id = getId(arg);
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
PlayerFunctions.sendMessage(plr, "/plot purge x;z &l<world>");
|
PlayerFunctions.sendMessage(plr, "/plot purge x;z &l<world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0]);
|
final UUID uuid = UUIDHandler.getUUID(args[0]);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
PlayerFunctions.sendMessage(plr, "/plot purge "+args[0]+" &l<world>");
|
PlayerFunctions.sendMessage(plr, "/plot purge " + args[0] + " &l<world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (arg.equals("player")) {
|
if (arg.equals("player")) {
|
||||||
@ -95,68 +93,68 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX);
|
PlayerFunctions.sendMessage(plr, C.PURGE_SYNTAX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
World world = Bukkit.getWorld(args[1]);
|
final World world = Bukkit.getWorld(args[1]);
|
||||||
if (world == null || !PlotSquared.isPlotWorld(world)) {
|
if ((world == null) || !PlotSquared.isPlotWorld(world)) {
|
||||||
PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD);
|
PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String worldname = world.getName();
|
final String worldname = world.getName();
|
||||||
String arg = args[0].toLowerCase();
|
final String arg = args[0].toLowerCase();
|
||||||
PlotId id = getId(arg);
|
final PlotId id = getId(arg);
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
HashSet<Integer> ids = new HashSet<Integer>();
|
final HashSet<Integer> ids = new HashSet<Integer>();
|
||||||
int DBid = DBFunc.getId(worldname, id);
|
final int DBid = DBFunc.getId(worldname, id);
|
||||||
if (DBid != Integer.MAX_VALUE) {
|
if (DBid != Integer.MAX_VALUE) {
|
||||||
ids.add(DBid);
|
ids.add(DBid);
|
||||||
}
|
}
|
||||||
DBFunc.purgeIds(worldname, ids);
|
DBFunc.purgeIds(worldname, ids);
|
||||||
return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0);
|
return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0);
|
||||||
}
|
}
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0]);
|
final UUID uuid = UUIDHandler.getUUID(args[0]);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
Set<Plot> plots = PlotSquared.getPlots(world,uuid);
|
final Set<Plot> plots = PlotSquared.getPlots(world, uuid);
|
||||||
Set<PlotId> ids = new HashSet<>();
|
final Set<PlotId> ids = new HashSet<>();
|
||||||
for (Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
ids.add(plot.id);
|
ids.add(plot.id);
|
||||||
}
|
}
|
||||||
DBFunc.purge(worldname, ids);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(ids.size());
|
return finishPurge(ids.size());
|
||||||
}
|
}
|
||||||
if (arg.equals("all")) {
|
if (arg.equals("all")) {
|
||||||
Set<PlotId> ids = PlotSquared.getPlots(world).keySet();
|
final Set<PlotId> ids = PlotSquared.getPlots(world).keySet();
|
||||||
if (ids.size() == 0) {
|
if (ids.size() == 0) {
|
||||||
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||||
}
|
}
|
||||||
DBFunc.purge(worldname, ids);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(ids.size());
|
return finishPurge(ids.size());
|
||||||
}
|
}
|
||||||
if (arg.equals("unknown")) {
|
if (arg.equals("unknown")) {
|
||||||
Collection<Plot> plots = PlotSquared.getPlots(world).values();
|
final Collection<Plot> plots = PlotSquared.getPlots(world).values();
|
||||||
Set<PlotId> ids = new HashSet<>();
|
final Set<PlotId> ids = new HashSet<>();
|
||||||
for (Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
if (plot.owner != null) {
|
if (plot.owner != null) {
|
||||||
String name = UUIDHandler.getName(plot.owner);
|
final String name = UUIDHandler.getName(plot.owner);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
ids.add(plot.id);
|
ids.add(plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ids.size() == 0) {
|
if (ids.size() == 0) {
|
||||||
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||||
}
|
}
|
||||||
DBFunc.purge(worldname, ids);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(ids.size());
|
return finishPurge(ids.size());
|
||||||
}
|
}
|
||||||
if (arg.equals("unowned")) {
|
if (arg.equals("unowned")) {
|
||||||
Collection<Plot> plots = PlotSquared.getPlots(world).values();
|
final Collection<Plot> plots = PlotSquared.getPlots(world).values();
|
||||||
Set<PlotId> ids = new HashSet<>();
|
final Set<PlotId> ids = new HashSet<>();
|
||||||
for (Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
ids.add(plot.id);
|
ids.add(plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ids.size() == 0) {
|
if (ids.size() == 0) {
|
||||||
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||||
}
|
}
|
||||||
DBFunc.purge(worldname, ids);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(ids.size());
|
return finishPurge(ids.size());
|
||||||
@ -165,9 +163,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean finishPurge(int amount) {
|
private boolean finishPurge(final int amount) {
|
||||||
PlayerFunctions.sendMessage(null, C.PURGE_SUCCESS, amount + "");
|
PlayerFunctions.sendMessage(null, C.PURGE_SUCCESS, amount + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,13 +28,12 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Rate extends SubCommand {
|
@SuppressWarnings({ "unused", "deprecated", "javadoc" })
|
||||||
|
public class Rate extends SubCommand {
|
||||||
/*
|
/*
|
||||||
* String cmd, String permission, String description, String usage, String
|
* String cmd, String permission, String description, String usage, String
|
||||||
* alias, CommandCategory category
|
* alias, CommandCategory category
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Rate() {
|
public Rate() {
|
||||||
super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS, true);
|
super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -82,7 +80,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
rated = false;
|
rated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rated) {
|
if (rated) {
|
||||||
sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString());
|
sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -35,49 +34,38 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||||
|
|
||||||
public class RegenAllRoads extends SubCommand {
|
public class RegenAllRoads extends SubCommand {
|
||||||
|
|
||||||
public RegenAllRoads() {
|
public RegenAllRoads() {
|
||||||
super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "rgar", CommandCategory.DEBUG, false);
|
super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "rgar", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player player, final String... args) {
|
public boolean execute(final Player player, final String... args) {
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
sendMessage(player, C.NOT_CONSOLE);
|
sendMessage(player, C.NOT_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
sendMessage(player, C.NEED_PLOT_WORLD);
|
sendMessage(player, C.NEED_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
final String name = args[0];
|
||||||
String name = args[0];
|
final PlotManager manager = PlotSquared.getPlotManager(name);
|
||||||
PlotManager manager = PlotSquared.getPlotManager(name);
|
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
|
||||||
|
|
||||||
if (manager == null || !(manager instanceof HybridPlotManager)) {
|
|
||||||
sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
final HybridPlotManager hpm = (HybridPlotManager) manager;
|
||||||
HybridPlotManager hpm = (HybridPlotManager) manager;
|
final World world = Bukkit.getWorld(name);
|
||||||
|
final ArrayList<ChunkLoc> chunks = ChunkManager.getChunkChunks(world);
|
||||||
World world = Bukkit.getWorld(name);
|
|
||||||
ArrayList<ChunkLoc> chunks = ChunkManager.getChunkChunks(world);
|
|
||||||
|
|
||||||
PlotSquared.log("&cIf no schematic is set, the following will not do anything");
|
PlotSquared.log("&cIf no schematic is set, the following will not do anything");
|
||||||
PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
|
PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
|
||||||
PlotSquared.log("&6Potential chunks to update: &7"+ (chunks.size() * 1024));
|
PlotSquared.log("&6Potential chunks to update: &7" + (chunks.size() * 1024));
|
||||||
PlotSquared.log("&6Estimated time: &7"+ (chunks.size()) + " seconds");
|
PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds");
|
||||||
|
final boolean result = hpm.scheduleRoadUpdate(world);
|
||||||
boolean result = hpm.scheduleRoadUpdate(world);
|
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
|
PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,7 +28,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Reload extends SubCommand {
|
public class Reload extends SubCommand {
|
||||||
|
|
||||||
public Reload() {
|
public Reload() {
|
||||||
super("reload", "plots.admin.command.reload", "Reload configurations", "", "reload", CommandCategory.INFO, false);
|
super("reload", "plots.admin.command.reload", "Reload configurations", "", "reload", CommandCategory.INFO, false);
|
||||||
}
|
}
|
||||||
@ -52,5 +50,4 @@ public class Reload extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -45,7 +44,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Schematic extends SubCommand {
|
public class Schematic extends SubCommand {
|
||||||
|
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
private Plot[] plots;
|
private Plot[] plots;
|
||||||
@ -99,22 +97,17 @@ public class Schematic extends SubCommand {
|
|||||||
Schematic.this.running = false;
|
Schematic.this.running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int x;
|
final int x;
|
||||||
final int z;
|
final int z;
|
||||||
|
|
||||||
final Plot plot2 = PlayerFunctions.getCurrentPlot(plr);
|
final Plot plot2 = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
|
||||||
final Dimension dem = schematic.getSchematicDimension();
|
final Dimension dem = schematic.getSchematicDimension();
|
||||||
final Location bot = PlotHelper.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1);
|
final Location bot = PlotHelper.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1);
|
||||||
final int length2 = PlotHelper.getPlotWidth(plr.getWorld(), plot2.id);
|
final int length2 = PlotHelper.getPlotWidth(plr.getWorld(), plot2.id);
|
||||||
|
|
||||||
if ((dem.getX() > length2) || (dem.getZ() > length2)) {
|
if ((dem.getX() > length2) || (dem.getZ() > length2)) {
|
||||||
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2));
|
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2));
|
||||||
Schematic.this.running = false;
|
Schematic.this.running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dem.getX() != length2) || (dem.getZ() != length2)) {
|
if ((dem.getX() != length2) || (dem.getZ() != length2)) {
|
||||||
final Location loc = plr.getLocation();
|
final Location loc = plr.getLocation();
|
||||||
x = Math.min(length2 - dem.getX(), loc.getBlockX() - bot.getBlockX());
|
x = Math.min(length2 - dem.getX(), loc.getBlockX() - bot.getBlockX());
|
||||||
@ -123,7 +116,6 @@ public class Schematic extends SubCommand {
|
|||||||
x = 0;
|
x = 0;
|
||||||
z = 0;
|
z = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final World w = plot2.getWorld();
|
final World w = plot2.getWorld();
|
||||||
final DataCollection[] b = schematic.getBlockCollection();
|
final DataCollection[] b = schematic.getBlockCollection();
|
||||||
final int sy = w.getHighestBlockYAt(bot.getBlockX(), bot.getBlockZ());
|
final int sy = w.getHighestBlockYAt(bot.getBlockX(), bot.getBlockZ());
|
||||||
@ -131,7 +123,6 @@ public class Schematic extends SubCommand {
|
|||||||
final int WIDTH = schematic.getSchematicDimension().getX();
|
final int WIDTH = schematic.getSchematicDimension().getX();
|
||||||
final int LENGTH = schematic.getSchematicDimension().getZ();
|
final int LENGTH = schematic.getSchematicDimension().getZ();
|
||||||
final int blen = b.length - 1;
|
final int blen = b.length - 1;
|
||||||
|
|
||||||
Schematic.this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
|
Schematic.this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -173,13 +164,10 @@ public class Schematic extends SubCommand {
|
|||||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int l1 = schematic.getSchematicDimension().getX();
|
final int l1 = schematic.getSchematicDimension().getX();
|
||||||
final int l2 = schematic.getSchematicDimension().getZ();
|
final int l2 = schematic.getSchematicDimension().getZ();
|
||||||
|
|
||||||
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
final int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id);
|
final int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id);
|
||||||
|
|
||||||
if ((l1 < length) || (l2 < length)) {
|
if ((l1 < length) || (l2 < length)) {
|
||||||
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||||
break;
|
break;
|
||||||
@ -205,19 +193,15 @@ public class Schematic extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(null, "&cTask is already running.");
|
PlayerFunctions.sendMessage(null, "&cTask is already running.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
|
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
|
||||||
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots...");
|
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots...");
|
||||||
final World worldObj = Bukkit.getWorld(args[1]);
|
final World worldObj = Bukkit.getWorld(args[1]);
|
||||||
final String worldname = Bukkit.getWorld(args[1]).getName();
|
final String worldname = Bukkit.getWorld(args[1]).getName();
|
||||||
|
|
||||||
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
|
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
|
||||||
|
|
||||||
final Collection<Plot> values = plotmap.values();
|
final Collection<Plot> values = plotmap.values();
|
||||||
this.plots = values.toArray(new Plot[values.size()]);
|
this.plots = values.toArray(new Plot[values.size()]);
|
||||||
this.running = true;
|
this.running = true;
|
||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
|
|
||||||
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -295,13 +279,10 @@ public class Schematic extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
|
final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
|
||||||
|
this.plots = new Plot[] { p2 };
|
||||||
this.plots = new Plot[]{p2};
|
|
||||||
this.running = true;
|
this.running = true;
|
||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
|
|
||||||
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin2, new Runnable() {
|
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin2, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -56,9 +55,8 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Set extends SubCommand {
|
public class Set extends SubCommand {
|
||||||
|
public final static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "flag" };
|
||||||
public final static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"};
|
public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" };
|
||||||
public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
|
|
||||||
|
|
||||||
public Set() {
|
public Set() {
|
||||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true);
|
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true);
|
||||||
@ -96,7 +94,6 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("flag")) {
|
if (args[0].equalsIgnoreCase("flag")) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6");
|
String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6");
|
||||||
@ -110,15 +107,12 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message));
|
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractFlag af;
|
AbstractFlag af;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
af = FlagManager.getFlag(args[1].toLowerCase());
|
af = FlagManager.getFlag(args[1].toLowerCase());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
af = new AbstractFlag(args[1].toLowerCase());
|
af = new AbstractFlag(args[1].toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FlagManager.getFlags().contains(af) && ((PlotSquared.worldGuardListener == null) || !PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) {
|
if (!FlagManager.getFlags().contains(af) && ((PlotSquared.worldGuardListener == null) || !PlotSquared.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
@ -138,9 +132,7 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
final boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase());
|
||||||
boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase());
|
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
|
||||||
return false;
|
return false;
|
||||||
@ -150,20 +142,18 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
Object parsed_value = af.parseValueRaw(value);
|
final Object parsed_value = af.parseValueRaw(value);
|
||||||
if (parsed_value == null) {
|
if (parsed_value == null) {
|
||||||
PlayerFunctions.sendMessage(plr, af.getValueDesc());
|
PlayerFunctions.sendMessage(plr, af.getValueDesc());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotSquared.worldGuardListener != null)) {
|
if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotSquared.worldGuardListener != null)) {
|
||||||
PlotSquared.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], af.toString(parsed_value));
|
PlotSquared.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], af.toString(parsed_value));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed_value);
|
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed_value);
|
||||||
boolean result = FlagManager.addPlotFlag(plot, flag);
|
final boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||||
return false;
|
return false;
|
||||||
@ -176,7 +166,6 @@ public class Set extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("home")) {
|
if (args[0].equalsIgnoreCase("home")) {
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
if (args[1].equalsIgnoreCase("none")) {
|
if (args[1].equalsIgnoreCase("none")) {
|
||||||
@ -187,16 +176,15 @@ public class Set extends SubCommand {
|
|||||||
return PlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT);
|
return PlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT);
|
||||||
}
|
}
|
||||||
//set to current location
|
//set to current location
|
||||||
World world = plr.getWorld();
|
final World world = plr.getWorld();
|
||||||
Location base = PlotHelper.getPlotBottomLoc(world, plot.id);
|
final Location base = PlotHelper.getPlotBottomLoc(world, plot.id);
|
||||||
base.setY(0);
|
base.setY(0);
|
||||||
Location relative = plr.getLocation().subtract(base);
|
final Location relative = plr.getLocation().subtract(base);
|
||||||
BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
|
final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
|
||||||
plot.settings.setPosition(blockloc);
|
plot.settings.setPosition(blockloc);
|
||||||
DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ());
|
DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ());
|
||||||
return PlayerFunctions.sendMessage(plr, C.POSITION_SET);
|
return PlayerFunctions.sendMessage(plr, C.POSITION_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("alias")) {
|
if (args[0].equalsIgnoreCase("alias")) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS);
|
PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS);
|
||||||
@ -230,7 +218,6 @@ public class Set extends SubCommand {
|
|||||||
sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2");
|
sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Biome biome = Biome.valueOf(new StringComparison(args[1], Biome.values()).getBestMatch());
|
final Biome biome = Biome.valueOf(new StringComparison(args[1], Biome.values()).getBestMatch());
|
||||||
/*
|
/*
|
||||||
* for (Biome b : Biome.values()) {
|
* for (Biome b : Biome.values()) {
|
||||||
@ -240,7 +227,6 @@ public class Set extends SubCommand {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (biome == null) {
|
if (biome == null) {
|
||||||
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
||||||
return true;
|
return true;
|
||||||
@ -249,13 +235,12 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
|
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get components
|
// Get components
|
||||||
World world = plr.getWorld();
|
final World world = plr.getWorld();
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
PlotManager manager = PlotSquared.getPlotManager(world);
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
String[] components = manager.getPlotComponents(world, plotworld, plot.id);
|
final String[] components = manager.getPlotComponents(world, plotworld, plot.id);
|
||||||
for (String component : components) {
|
for (final String component : components) {
|
||||||
if (component.equalsIgnoreCase(args[0])) {
|
if (component.equalsIgnoreCase(args[0])) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||||
@ -264,14 +249,13 @@ public class Set extends SubCommand {
|
|||||||
PlotBlock[] blocks;
|
PlotBlock[] blocks;
|
||||||
try {
|
try {
|
||||||
blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseObject(args[2]);
|
blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseObject(args[2]);
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
try {
|
try {
|
||||||
blocks = new PlotBlock[] {new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0)};
|
blocks = new PlotBlock[] { new PlotBlock((short) getMaterial(args[1], PlotWorld.BLOCKS).getId(), (byte) 0) };
|
||||||
} catch (Exception e2) {
|
} catch (final Exception e2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
manager.setComponent(world, plotworld, plot.id, component, blocks);
|
manager.setComponent(world, plotworld, plot.id, component, blocks);
|
||||||
PlayerFunctions.sendMessage(plr, C.GENERATING_COMPONENT);
|
PlayerFunctions.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||||
@ -332,14 +316,4 @@ public class Set extends SubCommand {
|
|||||||
private Material getMaterial(final String input, final List<Material> blocks) {
|
private Material getMaterial(final String input, final List<Material> blocks) {
|
||||||
return Material.valueOf(new StringComparison(input, blocks.toArray()).getBestMatch());
|
return Material.valueOf(new StringComparison(input, blocks.toArray()).getBestMatch());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBlockList(final List<Material> blocks) {
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
|
||||||
for (final Material b : blocks) {
|
|
||||||
builder.append(getMaterial(b));
|
|
||||||
}
|
|
||||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -38,7 +37,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class SetOwner extends SubCommand {
|
public class SetOwner extends SubCommand {
|
||||||
|
|
||||||
public SetOwner() {
|
public SetOwner() {
|
||||||
super("setowner", "plots.set.owner", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true);
|
super("setowner", "plots.set.owner", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -48,15 +46,14 @@ public class SetOwner extends SubCommand {
|
|||||||
* Bukkit.getOfflinePlayer(string); return ((player != null) &&
|
* Bukkit.getOfflinePlayer(string); return ((player != null) &&
|
||||||
* player.hasPlayedBefore()) ? UUIDHandler.getUUID(player) : null; }
|
* player.hasPlayedBefore()) ? UUIDHandler.getUUID(player) : null; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private UUID getUUID(final String string) {
|
private UUID getUUID(final String string) {
|
||||||
return UUIDHandler.getUUID(string);
|
return UUIDHandler.getUUID(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
if (plot == null || plot.owner == null) {
|
if ((plot == null) || (plot.owner == null)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -64,7 +61,6 @@ public class SetOwner extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NEED_USER);
|
PlayerFunctions.sendMessage(plr, C.NEED_USER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.setowner")) {
|
if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !BukkitMain.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
|
||||||
return false;
|
return false;
|
||||||
@ -75,18 +71,14 @@ public class SetOwner extends SubCommand {
|
|||||||
final ArrayList<PlotId> plots = PlayerFunctions.getPlotSelectionIds(bot, top);
|
final ArrayList<PlotId> plots = PlayerFunctions.getPlotSelectionIds(bot, top);
|
||||||
for (final PlotId id : plots) {
|
for (final PlotId id : plots) {
|
||||||
final Plot current = PlotSquared.getPlots(world).get(id);
|
final Plot current = PlotSquared.getPlots(world).get(id);
|
||||||
|
final UUID uuid = getUUID(args[0]);
|
||||||
UUID uuid = getUUID(args[0]);
|
|
||||||
|
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
current.owner = uuid;
|
current.owner = uuid;
|
||||||
PlotSquared.updatePlot(current);
|
PlotSquared.updatePlot(current);
|
||||||
DBFunc.setOwner(current, current.owner);
|
DBFunc.setOwner(current, current.owner);
|
||||||
|
|
||||||
if (PlotSquared.worldGuardListener != null) {
|
if (PlotSquared.worldGuardListener != null) {
|
||||||
PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current);
|
PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -45,7 +44,6 @@ import com.intellectualcrafters.plot.object.PlotGenerator;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Setup extends SubCommand {
|
public class Setup extends SubCommand {
|
||||||
|
|
||||||
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||||
public HashMap<String, PlotGenerator> generators = new HashMap<>();
|
public HashMap<String, PlotGenerator> generators = new HashMap<>();
|
||||||
|
|
||||||
@ -64,20 +62,20 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateGenerators() {
|
public void updateGenerators() {
|
||||||
if (generators.size() > 0) {
|
if (this.generators.size() > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String testWorld = "CheckingPlotSquaredGenerator";
|
final String testWorld = "CheckingPlotSquaredGenerator";
|
||||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled()) {
|
||||||
ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
|
final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
|
||||||
if (generator != null) {
|
if (generator != null) {
|
||||||
PlotSquared.removePlotWorld(testWorld);
|
PlotSquared.removePlotWorld(testWorld);
|
||||||
final String name = plugin.getDescription().getName();
|
final String name = plugin.getDescription().getName();
|
||||||
if (generator instanceof PlotGenerator) {
|
if (generator instanceof PlotGenerator) {
|
||||||
PlotGenerator pgen = (PlotGenerator) generator;
|
final PlotGenerator pgen = (PlotGenerator) generator;
|
||||||
if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
||||||
generators.put(name, pgen);
|
this.generators.put(name, pgen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,15 +86,14 @@ public class Setup extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
// going through setup
|
// going through setup
|
||||||
|
final String name = plr.getName();
|
||||||
String name = plr.getName();
|
|
||||||
if (!setupMap.containsKey(name)) {
|
if (!setupMap.containsKey(name)) {
|
||||||
SetupObject object = new SetupObject();
|
final SetupObject object = new SetupObject();
|
||||||
setupMap.put(name, object);
|
setupMap.put(name, object);
|
||||||
updateGenerators();
|
updateGenerators();
|
||||||
String prefix = "\n&8 - &7";
|
final String prefix = "\n&8 - &7";
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
PlayerFunctions.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
@ -106,86 +103,70 @@ public class Setup extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("back")) {
|
if (args[0].equalsIgnoreCase("back")) {
|
||||||
SetupObject object = setupMap.get(plr.getName());
|
final SetupObject object = setupMap.get(plr.getName());
|
||||||
if (object.setup_index > 0) {
|
if (object.setup_index > 0) {
|
||||||
object.setup_index--;
|
object.setup_index--;
|
||||||
ConfigurationNode node = object.step[object.current];
|
final ConfigurationNode node = object.step[object.current];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (object.current > 0) {
|
||||||
else if (object.current > 0 ){
|
|
||||||
object.current--;
|
object.current--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetupObject object = setupMap.get(name);
|
final SetupObject object = setupMap.get(name);
|
||||||
int index = object.current;
|
final int index = object.current;
|
||||||
switch(index) {
|
switch (index) {
|
||||||
case 0: { // choose generator
|
case 0: { // choose generator
|
||||||
if (args.length != 1 || !generators.containsKey(args[0])) {
|
if ((args.length != 1) || !this.generators.containsKey(args[0])) {
|
||||||
String prefix = "\n&8 - &7";
|
final String prefix = "\n&8 - &7";
|
||||||
PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
PlayerFunctions.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringUtils.join(this.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object.generator = args[0];
|
object.generator = args[0];
|
||||||
object.current++;
|
object.current++;
|
||||||
|
final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : "";
|
||||||
String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : "";
|
PlayerFunctions.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
||||||
PlayerFunctions.sendMessage(plr, "&6What world type do you want?"
|
|
||||||
+ "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
|
||||||
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
|
|
||||||
+ partial);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: { // choose world type
|
case 1: { // choose world type
|
||||||
List<String> types;
|
List<String> types;
|
||||||
if (Settings.ENABLE_CLUSTERS) {
|
if (Settings.ENABLE_CLUSTERS) {
|
||||||
types = Arrays.asList(new String[] {"default", "augmented", "partial"});
|
types = Arrays.asList(new String[] { "default", "augmented", "partial" });
|
||||||
|
} else {
|
||||||
|
types = Arrays.asList(new String[] { "default", "augmented" });
|
||||||
}
|
}
|
||||||
else {
|
if ((args.length != 1) || !types.contains(args[0].toLowerCase())) {
|
||||||
types = Arrays.asList(new String[] {"default", "augmented"});
|
PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
|
||||||
}
|
|
||||||
if (args.length != 1 || !types.contains(args[0].toLowerCase())) {
|
|
||||||
PlayerFunctions.sendMessage(plr, "&cYou must choose a world type!"
|
|
||||||
+ "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
|
||||||
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain"
|
|
||||||
+ "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object.type = types.indexOf(args[0].toLowerCase());
|
object.type = types.indexOf(args[0].toLowerCase());
|
||||||
if (object.type == 0) {
|
if (object.type == 0) {
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
||||||
}
|
}
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
}
|
} else {
|
||||||
else {
|
PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
PlayerFunctions.sendMessage(plr, "&6What terrain would you like in plots?"
|
|
||||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
|
||||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
|
||||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
|
||||||
}
|
}
|
||||||
object.current++;
|
object.current++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: { // Choose terrain
|
case 2: { // Choose terrain
|
||||||
List<String> terrain = Arrays.asList(new String[] {"none", "ore", "all"});
|
final List<String> terrain = Arrays.asList(new String[] { "none", "ore", "all" });
|
||||||
if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) {
|
if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
|
||||||
PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!"
|
PlayerFunctions.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
|
||||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
|
||||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.step = generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
object.step = this.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
||||||
}
|
}
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -229,11 +210,10 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
object.world = args[0];
|
object.world = args[0];
|
||||||
setupMap.remove(plr.getName());
|
setupMap.remove(plr.getName());
|
||||||
World world = setupWorld(object);
|
final World world = setupWorld(object);
|
||||||
try {
|
try {
|
||||||
plr.teleport(world.getSpawnLocation());
|
plr.teleport(world.getSpawnLocation());
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
plr.sendMessage("&cAn error occured. See console for more information");
|
plr.sendMessage("&cAn error occured. See console for more information");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -294,7 +274,7 @@ public class Setup extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public World setupWorld(SetupObject object) {
|
public World setupWorld(final SetupObject object) {
|
||||||
// Configuration
|
// Configuration
|
||||||
final ConfigurationNode[] steps = object.step;
|
final ConfigurationNode[] steps = object.step;
|
||||||
final String world = object.world;
|
final String world = object.world;
|
||||||
@ -318,14 +298,13 @@ public class Setup extends SubCommand {
|
|||||||
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator);
|
||||||
} else {
|
} else {
|
||||||
WorldCreator wc = new WorldCreator(object.world);
|
final WorldCreator wc = new WorldCreator(object.world);
|
||||||
wc.generator(object.generator);
|
wc.generator(object.generator);
|
||||||
wc.environment(Environment.NORMAL);
|
wc.environment(Environment.NORMAL);
|
||||||
World newWorld = Bukkit.createWorld(wc);
|
Bukkit.createWorld(wc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -34,8 +33,8 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"deprecation", "unused"}) public abstract class SubCommand {
|
@SuppressWarnings({ "deprecation", "unused" })
|
||||||
|
public abstract class SubCommand {
|
||||||
/**
|
/**
|
||||||
* Command
|
* Command
|
||||||
*/
|
*/
|
||||||
@ -191,7 +190,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* Such as: /plot debug
|
* Such as: /plot debug
|
||||||
*/
|
*/
|
||||||
DEBUG("Debug");
|
DEBUG("Debug");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The category name (Readable)
|
* The category name (Readable)
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -40,7 +39,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class Swap extends SubCommand {
|
public class Swap extends SubCommand {
|
||||||
|
|
||||||
public Swap() {
|
public Swap() {
|
||||||
super(Command.SWAP, "Swap two plots", "switch", CommandCategory.ACTIONS, true);
|
super(Command.SWAP, "Swap two plots", "switch", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -87,11 +85,9 @@ public class Swap extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotSelection.swap(world, plot.id, plotid);
|
PlotSelection.swap(world, plot.id, plotid);
|
||||||
|
|
||||||
// TODO Requires testing!!
|
// TODO Requires testing!!
|
||||||
DBFunc.dbManager.swapPlots(plot, PlotHelper.getPlot(world, plotid));
|
DBFunc.dbManager.swapPlots(plot, PlotHelper.getPlot(world, plotid));
|
||||||
// TODO Requires testing!!
|
// TODO Requires testing!!
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
|
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
|
||||||
PlotHelper.update(plr.getLocation());
|
PlotHelper.update(plr.getLocation());
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -37,7 +36,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class TP extends SubCommand {
|
public class TP extends SubCommand {
|
||||||
|
|
||||||
public TP() {
|
public TP() {
|
||||||
super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT, true);
|
super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT, true);
|
||||||
}
|
}
|
||||||
@ -65,7 +63,6 @@ public class TP extends SubCommand {
|
|||||||
PlotSquared.teleportPlayer(plr, plr.getLocation(), temp);
|
PlotSquared.teleportPlayer(plr, plr.getLocation(), temp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
||||||
PlotSquared.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
|
PlotSquared.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
|
||||||
@ -85,7 +82,8 @@ public class TP extends SubCommand {
|
|||||||
}
|
}
|
||||||
a = split[0];
|
a = split[0];
|
||||||
}
|
}
|
||||||
@SuppressWarnings("deprecation") final Player player = Bukkit.getPlayer(a);
|
@SuppressWarnings("deprecation")
|
||||||
|
final Player player = Bukkit.getPlayer(a);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
final java.util.Set<Plot> plotMainPlots = PlotSquared.getPlots(world, player);
|
final java.util.Set<Plot> plotMainPlots = PlotSquared.getPlots(world, player);
|
||||||
final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]);
|
final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -31,7 +30,6 @@ import com.intellectualcrafters.plot.util.PlotHelper;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Target extends SubCommand {
|
public class Target extends SubCommand {
|
||||||
|
|
||||||
public Target() {
|
public Target() {
|
||||||
super(Command.TARGET, "Target a plot with your compass", "target <X;Z>", CommandCategory.ACTIONS, true);
|
super(Command.TARGET, "Target a plot with your compass", "target <X;Z>", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -43,12 +41,12 @@ public class Target extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
PlotId id = PlotHelper.parseId(args[1]);
|
final PlotId id = PlotHelper.parseId(args[1]);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location loc = PlotHelper.getPlotHome(plr.getWorld(), id);
|
final Location loc = PlotHelper.getPlotHome(plr.getWorld(), id);
|
||||||
plr.setCompassTarget(loc);
|
plr.setCompassTarget(loc);
|
||||||
PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET);
|
PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET);
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -36,7 +35,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Template extends SubCommand {
|
public class Template extends SubCommand {
|
||||||
|
|
||||||
public Template() {
|
public Template() {
|
||||||
super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true);
|
super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, true);
|
||||||
}
|
}
|
||||||
@ -47,9 +45,9 @@ public class Template extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template <import|export> <world>");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template <import|export> <world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
World world = Bukkit.getWorld(args[1]);
|
final World world = Bukkit.getWorld(args[1]);
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(args[1]);
|
||||||
if (world == null || plotworld == null) {
|
if ((world == null) || (plotworld == null)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -63,19 +61,16 @@ public class Template extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "TODO");
|
PlayerFunctions.sendMessage(plr, "TODO");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO allow world settings (including schematics to be packed into a single file)
|
// TODO allow world settings (including schematics to be packed into a single file)
|
||||||
|
|
||||||
// TODO allow world created based on these packaged files
|
// TODO allow world created based on these packaged files
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gzipIt(String output, String input) {
|
public void gzipIt(final String output, final String input) {
|
||||||
byte[] buffer = new byte[1024];
|
final byte[] buffer = new byte[1024];
|
||||||
try {
|
try {
|
||||||
GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(output));
|
final GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(output));
|
||||||
FileInputStream in = new FileInputStream(input);
|
final FileInputStream in = new FileInputStream(input);
|
||||||
int len;
|
int len;
|
||||||
while ((len = in.read(buffer)) > 0) {
|
while ((len = in.read(buffer)) > 0) {
|
||||||
gzos.write(buffer, 0, len);
|
gzos.write(buffer, 0, len);
|
||||||
@ -83,7 +78,7 @@ public class Template extends SubCommand {
|
|||||||
in.close();
|
in.close();
|
||||||
gzos.finish();
|
gzos.finish();
|
||||||
gzos.close();
|
gzos.close();
|
||||||
} catch (IOException ex) {
|
} catch (final IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -40,12 +39,11 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class Trim extends SubCommand {
|
public class Trim extends SubCommand {
|
||||||
|
|
||||||
public static boolean TASK = false;
|
public static boolean TASK = false;
|
||||||
private static int TASK_ID = 0;
|
private static int TASK_ID = 0;
|
||||||
|
|
||||||
@ -53,12 +51,11 @@ public class Trim extends SubCommand {
|
|||||||
super("trim", "plots.admin", "Delete unmodified portions of your plotworld", "trim", "", CommandCategory.DEBUG, false);
|
super("trim", "plots.admin", "Delete unmodified portions of your plotworld", "trim", "", CommandCategory.DEBUG, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotId getId(String id) {
|
public PlotId getId(final String id) {
|
||||||
try {
|
try {
|
||||||
String[] split = id.split(";");
|
final String[] split = id.split(";");
|
||||||
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,8 +67,8 @@ public class Trim extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String arg = args[0].toLowerCase();
|
final String arg = args[0].toLowerCase();
|
||||||
PlotId id = getId(arg);
|
final PlotId id = getId(arg);
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
PlayerFunctions.sendMessage(plr, "/plot trim x;z &l<world>");
|
PlayerFunctions.sendMessage(plr, "/plot trim x;z &l<world>");
|
||||||
return false;
|
return false;
|
||||||
@ -87,22 +84,20 @@ public class Trim extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX);
|
PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String arg = args[0].toLowerCase();
|
final String arg = args[0].toLowerCase();
|
||||||
if (!arg.equals("all")) {
|
if (!arg.equals("all")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX);
|
PlayerFunctions.sendMessage(plr, C.TRIM_SYNTAX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final World world = Bukkit.getWorld(args[1]);
|
final World world = Bukkit.getWorld(args[1]);
|
||||||
if (world == null || PlotSquared.getWorldSettings(world) == null) {
|
if ((world == null) || (PlotSquared.getWorldSettings(world) == null)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Trim.TASK) {
|
if (Trim.TASK) {
|
||||||
sendMessage(C.TRIM_IN_PROGRESS.s());
|
sendMessage(C.TRIM_IN_PROGRESS.s());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(C.TRIM_START.s());
|
sendMessage(C.TRIM_START.s());
|
||||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||||
getTrimRegions(empty, world, new Runnable() {
|
getTrimRegions(empty, world, new Runnable() {
|
||||||
@ -118,54 +113,50 @@ public class Trim extends SubCommand {
|
|||||||
if (Trim.TASK) {
|
if (Trim.TASK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BukkitTaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String directory = world.getName() + File.separator + "region";
|
final String directory = world.getName() + File.separator + "region";
|
||||||
File folder = new File(directory);
|
final File folder = new File(directory);
|
||||||
File[] regionFiles = folder.listFiles();
|
final File[] regionFiles = folder.listFiles();
|
||||||
for (File file : regionFiles) {
|
for (final File file : regionFiles) {
|
||||||
String name = file.getName();
|
final String name = file.getName();
|
||||||
if (name.endsWith("mca")) {
|
if (name.endsWith("mca")) {
|
||||||
if (file.getTotalSpace() <= 8192) {
|
if (file.getTotalSpace() <= 8192) {
|
||||||
try {
|
try {
|
||||||
String[] split = name.split("\\.");
|
final String[] split = name.split("\\.");
|
||||||
int x = Integer.parseInt(split[1]);
|
final int x = Integer.parseInt(split[1]);
|
||||||
int z = Integer.parseInt(split[2]);
|
final int z = Integer.parseInt(split[2]);
|
||||||
ChunkLoc loc = new ChunkLoc(x, z);
|
final ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
empty.add(loc);
|
empty.add(loc);
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
System.out.print("INVALID MCA: " + name);
|
System.out.print("INVALID MCA: " + name);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
final Path path = Paths.get(file.getPath());
|
||||||
Path path = Paths.get(file.getPath());
|
|
||||||
try {
|
try {
|
||||||
BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
|
final BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
|
||||||
long creation = attr.creationTime().toMillis();
|
final long creation = attr.creationTime().toMillis();
|
||||||
long modification = file.lastModified();
|
final long modification = file.lastModified();
|
||||||
long diff = Math.abs(creation - modification);
|
final long diff = Math.abs(creation - modification);
|
||||||
if (diff < 10000) {
|
if (diff < 10000) {
|
||||||
try {
|
try {
|
||||||
String[] split = name.split("\\.");
|
final String[] split = name.split("\\.");
|
||||||
int x = Integer.parseInt(split[1]);
|
final int x = Integer.parseInt(split[1]);
|
||||||
int z = Integer.parseInt(split[2]);
|
final int z = Integer.parseInt(split[2]);
|
||||||
ChunkLoc loc = new ChunkLoc(x, z);
|
final ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
empty.add(loc);
|
empty.add(loc);
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
System.out.print("INVALID MCA: " + name);
|
System.out.print("INVALID MCA: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Trim.TASK = false;
|
Trim.TASK = false;
|
||||||
BukkitTaskManager.runTaskAsync(whenDone);
|
TaskManager.runTaskAsync(whenDone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Trim.TASK = true;
|
Trim.TASK = true;
|
||||||
@ -182,29 +173,27 @@ public class Trim extends SubCommand {
|
|||||||
plots.addAll(PlotSquared.getPlots(world).values());
|
plots.addAll(PlotSquared.getPlots(world).values());
|
||||||
final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.getChunkChunks(world));
|
final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.getChunkChunks(world));
|
||||||
sendMessage(" - MCA #: " + chunks.size());
|
sendMessage(" - MCA #: " + chunks.size());
|
||||||
sendMessage(" - CHUNKS: " + (chunks.size() * 1024) +" (max)");
|
sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
|
||||||
sendMessage(" - TIME ESTIMATE: " + (chunks.size()/1200) +" minutes");
|
sendMessage(" - TIME ESTIMATE: " + (chunks.size() / 1200) + " minutes");
|
||||||
Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
|
Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
while (System.currentTimeMillis() - start < 50) {
|
while ((System.currentTimeMillis() - start) < 50) {
|
||||||
if (plots.size() == 0) {
|
if (plots.size() == 0) {
|
||||||
empty.addAll(chunks);
|
empty.addAll(chunks);
|
||||||
System.out.print("DONE!");
|
System.out.print("DONE!");
|
||||||
Trim.TASK = false;
|
Trim.TASK = false;
|
||||||
BukkitTaskManager.runTaskAsync(whenDone);
|
TaskManager.runTaskAsync(whenDone);
|
||||||
Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
|
Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = plots.get(0);
|
final Plot plot = plots.get(0);
|
||||||
plots.remove(0);
|
plots.remove(0);
|
||||||
Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id);
|
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id);
|
||||||
Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||||
|
final Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ());
|
||||||
Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ());
|
final Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ());
|
||||||
Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ());
|
|
||||||
|
|
||||||
chunks.remove(ChunkManager.getChunkChunk(pos1));
|
chunks.remove(ChunkManager.getChunkChunk(pos1));
|
||||||
chunks.remove(ChunkManager.getChunkChunk(pos2));
|
chunks.remove(ChunkManager.getChunkChunk(pos2));
|
||||||
chunks.remove(ChunkManager.getChunkChunk(pos3));
|
chunks.remove(ChunkManager.getChunkChunk(pos3));
|
||||||
@ -218,39 +207,39 @@ public class Trim extends SubCommand {
|
|||||||
|
|
||||||
public static ArrayList<Plot> expired = null;
|
public static ArrayList<Plot> expired = null;
|
||||||
|
|
||||||
// public static void updateUnmodifiedPlots(final World world) {
|
// public static void updateUnmodifiedPlots(final World world) {
|
||||||
// final SquarePlotManager manager = (SquarePlotManager) PlotSquared.getPlotManager(world);
|
// final SquarePlotManager manager = (SquarePlotManager) PlotSquared.getPlotManager(world);
|
||||||
// final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getWorldSettings(world);
|
// final SquarePlotWorld plotworld = (SquarePlotWorld) PlotSquared.getWorldSettings(world);
|
||||||
// final ArrayList<Plot> expired = new ArrayList<>();
|
// final ArrayList<Plot> expired = new ArrayList<>();
|
||||||
// final Set<Plot> plots = ExpireManager.getOldPlots(world.getName()).keySet();
|
// final Set<Plot> plots = ExpireManager.getOldPlots(world.getName()).keySet();
|
||||||
// sendMessage("Checking " + plots.size() +" plots! This may take a long time...");
|
// sendMessage("Checking " + plots.size() +" plots! This may take a long time...");
|
||||||
// Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
|
// Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
|
||||||
// @Override
|
// @Override
|
||||||
// public void run() {
|
// public void run() {
|
||||||
// if (manager != null && plots.size() > 0) {
|
// if (manager != null && plots.size() > 0) {
|
||||||
// Plot plot = plots.iterator().next();
|
// Plot plot = plots.iterator().next();
|
||||||
// if (plot.hasOwner()) {
|
// if (plot.hasOwner()) {
|
||||||
// SquarePlotManager.checkModified(plot, 0);
|
// SquarePlotManager.checkModified(plot, 0);
|
||||||
// }
|
// }
|
||||||
// if (plot.owner == null || !SquarePlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) {
|
// if (plot.owner == null || !SquarePlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) {
|
||||||
// expired.add(plot);
|
// expired.add(plot);
|
||||||
// sendMessage("found expired: " + plot);
|
// sendMessage("found expired: " + plot);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
// Trim.expired = expired;
|
// Trim.expired = expired;
|
||||||
// Trim.TASK = false;
|
// Trim.TASK = false;
|
||||||
// sendMessage("Done!");
|
// sendMessage("Done!");
|
||||||
// Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
|
// Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }, 1, 1);
|
// }, 1, 1);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
public static void deleteChunks(World world, ArrayList<ChunkLoc> chunks) {
|
public static void deleteChunks(final World world, final ArrayList<ChunkLoc> chunks) {
|
||||||
String worldname = world.getName();
|
final String worldname = world.getName();
|
||||||
for (ChunkLoc loc : chunks) {
|
for (final ChunkLoc loc : chunks) {
|
||||||
ChunkManager.deleteRegionFile(worldname, loc);
|
ChunkManager.deleteRegionFile(worldname, loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,5 +247,4 @@ public class Trim extends SubCommand {
|
|||||||
public static void sendMessage(final String message) {
|
public static void sendMessage(final String message) {
|
||||||
PlotSquared.log("&3PlotSquared -> World trim&8: &7" + message);
|
PlotSquared.log("&3PlotSquared -> World trim&8: &7" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -34,8 +33,8 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public class Trusted extends SubCommand {
|
@SuppressWarnings("deprecation")
|
||||||
|
public class Trusted extends SubCommand {
|
||||||
public Trusted() {
|
public Trusted() {
|
||||||
super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS, true);
|
super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -63,7 +62,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
UUID uuid;
|
UUID uuid;
|
||||||
if (args[1].equalsIgnoreCase("*")) {
|
if (args[1].equalsIgnoreCase("*")) {
|
||||||
uuid = DBFunc.everyone;
|
uuid = DBFunc.everyone;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
uuid = UUIDHandler.getUUID(args[1]);
|
uuid = UUIDHandler.getUUID(args[1]);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Unban extends SubCommand {
|
public class Unban extends SubCommand {
|
||||||
|
|
||||||
public Unban() {
|
public Unban() {
|
||||||
super(Command.UNBAN, "Alias for /plot denied remove", "/plot unban [player]", CommandCategory.ACTIONS, true);
|
super(Command.UNBAN, "Alias for /plot denied remove", "/plot unban [player]", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
@ -36,7 +35,6 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
public class Unclaim extends SubCommand {
|
public class Unclaim extends SubCommand {
|
||||||
|
|
||||||
public Unclaim() {
|
public Unclaim() {
|
||||||
super(Command.UNCLAIM, "Unclaim a plot", "unclaim", CommandCategory.ACTIONS, true);
|
super(Command.UNCLAIM, "Unclaim a plot", "unclaim", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -65,8 +63,8 @@ public class Unclaim extends SubCommand {
|
|||||||
}
|
}
|
||||||
final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true);
|
final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true);
|
||||||
if (result) {
|
if (result) {
|
||||||
World world = plr.getWorld();
|
final World world = plr.getWorld();
|
||||||
String worldname = world.getName();
|
final String worldname = world.getName();
|
||||||
PlotSquared.getPlotManager(world).unclaimPlot(world, pWorld, plot);
|
PlotSquared.getPlotManager(world).unclaimPlot(world, pWorld, plot);
|
||||||
DBFunc.delete(worldname, plot);
|
DBFunc.delete(worldname, plot);
|
||||||
// TODO set wall block
|
// TODO set wall block
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -46,7 +45,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class Unlink extends SubCommand {
|
public class Unlink extends SubCommand {
|
||||||
|
|
||||||
public Unlink() {
|
public Unlink() {
|
||||||
super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS, true);
|
super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
@ -63,7 +61,6 @@ public class Unlink extends SubCommand {
|
|||||||
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||||
return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final World world = plr.getWorld();
|
final World world = plr.getWorld();
|
||||||
if (!unlinkPlot(world, plot)) {
|
if (!unlinkPlot(world, plot)) {
|
||||||
PlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled");
|
PlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled");
|
||||||
@ -83,31 +80,24 @@ public class Unlink extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean unlinkPlot(World world, Plot plot) {
|
public static boolean unlinkPlot(final World world, final Plot plot) {
|
||||||
final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id;
|
final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||||
final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id;
|
final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id;
|
||||||
final ArrayList<PlotId> ids = PlayerFunctions.getPlotSelectionIds(pos1, pos2);
|
final ArrayList<PlotId> ids = PlayerFunctions.getPlotSelectionIds(pos1, pos2);
|
||||||
|
|
||||||
final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids);
|
final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids);
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
|
|
||||||
manager.startPlotUnlink(world, plotworld, ids);
|
manager.startPlotUnlink(world, plotworld, ids);
|
||||||
|
|
||||||
for (final PlotId id : ids) {
|
for (final PlotId id : ids) {
|
||||||
final Plot myplot = PlotSquared.getPlots(world).get(id);
|
final Plot myplot = PlotSquared.getPlots(world).get(id);
|
||||||
|
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plot.helpers != null) {
|
if (plot.helpers != null) {
|
||||||
myplot.helpers = plot.helpers;
|
myplot.helpers = plot.helpers;
|
||||||
}
|
}
|
||||||
@ -115,25 +105,20 @@ public class Unlink extends SubCommand {
|
|||||||
myplot.denied = plot.denied;
|
myplot.denied = plot.denied;
|
||||||
}
|
}
|
||||||
myplot.deny_entry = plot.deny_entry;
|
myplot.deny_entry = plot.deny_entry;
|
||||||
myplot.settings.setMerged(new boolean[]{false, false, false, false});
|
myplot.settings.setMerged(new boolean[] { false, false, false, false });
|
||||||
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
|
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
final boolean lx = x < pos2.x;
|
final boolean lx = x < pos2.x;
|
||||||
final boolean ly = y < pos2.y;
|
final boolean ly = y < pos2.y;
|
||||||
|
|
||||||
final Plot p = PlotHelper.getPlot(world, new PlotId(x, y));
|
final Plot p = PlotHelper.getPlot(world, new PlotId(x, y));
|
||||||
|
|
||||||
if (lx) {
|
if (lx) {
|
||||||
manager.createRoadEast(plotworld, p);
|
manager.createRoadEast(plotworld, p);
|
||||||
if (ly) {
|
if (ly) {
|
||||||
manager.createRoadSouthEast(plotworld, p);
|
manager.createRoadSouthEast(plotworld, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ly) {
|
if (ly) {
|
||||||
manager.createRoadSouth(plotworld, p);
|
manager.createRoadSouth(plotworld, p);
|
||||||
}
|
}
|
||||||
@ -141,10 +126,10 @@ public class Unlink extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
manager.finishPlotUnlink(world, plotworld, ids);
|
manager.finishPlotUnlink(world, plotworld, ids);
|
||||||
for (PlotId id : ids) {
|
for (final PlotId id : ids) {
|
||||||
Plot myPlot = PlotHelper.getPlot(world, id);
|
final Plot myPlot = PlotHelper.getPlot(world, id);
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
String name = UUIDHandler.getName(myPlot.owner);
|
final String name = UUIDHandler.getName(myPlot.owner);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
PlotHelper.setSign(world, name, myPlot);
|
PlotHelper.setSign(world, name, myPlot);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,7 +28,6 @@ import com.intellectualcrafters.plot.util.bukkit.PWE;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class WE_Anywhere extends SubCommand {
|
public class WE_Anywhere extends SubCommand {
|
||||||
|
|
||||||
public WE_Anywhere() {
|
public WE_Anywhere() {
|
||||||
super("weanywhere", "plots.weanywhere", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
|
super("weanywhere", "plots.weanywhere", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
|
||||||
}
|
}
|
||||||
@ -40,12 +38,10 @@ public class WE_Anywhere extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server");
|
PlayerFunctions.sendMessage(plr, "&cWorldEdit is not enabled on this server");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BukkitMain.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) {
|
if (BukkitMain.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) {
|
||||||
PWE.removeMask(plr);
|
PWE.removeMask(plr);
|
||||||
PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask");
|
PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
PWE.setMask(plr, plr.getLocation(), true);
|
PWE.setMask(plr, plr.getLocation(), true);
|
||||||
PlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask");
|
PlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask");
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -41,7 +40,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class list extends SubCommand {
|
public class list extends SubCommand {
|
||||||
|
|
||||||
public list() {
|
public list() {
|
||||||
super(Command.LIST, "List all plots", "list {mine|shared|all|world|forsale}", CommandCategory.INFO, false);
|
super(Command.LIST, "List all plots", "list {mine|shared|all|world|forsale}", CommandCategory.INFO, false);
|
||||||
}
|
}
|
||||||
@ -50,7 +48,7 @@ public class list extends SubCommand {
|
|||||||
if (id == null) {
|
if (id == null) {
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
String name = UUIDHandler.getName(id);
|
final String name = UUIDHandler.getName(id);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
@ -63,9 +61,9 @@ public class list extends SubCommand {
|
|||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||||
if (plr != null) {
|
if (plr != null) {
|
||||||
builder.append(getArgumentList(new String[]{"mine", "shared", "world", "all", "forsale"}));
|
builder.append(getArgumentList(new String[] { "mine", "shared", "world", "all", "forsale" }));
|
||||||
} else {
|
} else {
|
||||||
builder.append(getArgumentList(new String[]{"all"}));
|
builder.append(getArgumentList(new String[] { "all" }));
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, builder.toString());
|
PlayerFunctions.sendMessage(plr, builder.toString());
|
||||||
return true;
|
return true;
|
||||||
@ -78,7 +76,7 @@ public class list extends SubCommand {
|
|||||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "buyable")).append("\n");
|
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "buyable")).append("\n");
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) {
|
for (final Plot p : PlotSquared.getPlots(plr.getWorld()).values()) {
|
||||||
Flag price = FlagManager.getPlotFlag(p, "price");
|
final Flag price = FlagManager.getPlotFlag(p, "price");
|
||||||
if (price != null) {
|
if (price != null) {
|
||||||
string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", idx + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", price.getValueString()).replaceAll("%owner", getName(p.owner))).append("\n");
|
string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", idx + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", price.getValueString()).replaceAll("%owner", getName(p.owner))).append("\n");
|
||||||
idx++;
|
idx++;
|
||||||
@ -121,7 +119,6 @@ public class list extends SubCommand {
|
|||||||
} else if (args[0].equalsIgnoreCase("all")) {
|
} else if (args[0].equalsIgnoreCase("all")) {
|
||||||
// Current page
|
// Current page
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
// is a page specified? else use 0
|
// is a page specified? else use 0
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
try {
|
try {
|
||||||
@ -134,34 +131,26 @@ public class list extends SubCommand {
|
|||||||
page = 0;
|
page = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the total pages
|
// Get the total pages
|
||||||
// int totalPages = ((int) Math.ceil(12 *
|
// int totalPages = ((int) Math.ceil(12 *
|
||||||
// (PlotSquared.getPlotsSorted().size()) / 100));
|
// (PlotSquared.getPlotsSorted().size()) / 100));
|
||||||
final int totalPages = (int) Math.ceil(PlotSquared.getPlotsSorted().size() / 12);
|
final int totalPages = (int) Math.ceil(PlotSquared.getPlotsSorted().size() / 12);
|
||||||
|
|
||||||
if (page > totalPages) {
|
if (page > totalPages) {
|
||||||
page = totalPages;
|
page = totalPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only display 12!
|
// Only display 12!
|
||||||
int max = (page * 12) + 12;
|
int max = (page * 12) + 12;
|
||||||
|
|
||||||
if (max > PlotSquared.getPlotsSorted().size()) {
|
if (max > PlotSquared.getPlotsSorted().size()) {
|
||||||
max = PlotSquared.getPlotsSorted().size();
|
max = PlotSquared.getPlotsSorted().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder string = new StringBuilder();
|
final StringBuilder string = new StringBuilder();
|
||||||
|
|
||||||
string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n");
|
string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n");
|
||||||
Plot p;
|
Plot p;
|
||||||
|
|
||||||
// This might work xD
|
// This might work xD
|
||||||
for (int x = (page * 12); x < max; x++) {
|
for (int x = (page * 12); x < max; x++) {
|
||||||
p = (Plot) PlotSquared.getPlotsSorted().toArray()[x];
|
p = (Plot) PlotSquared.getPlotsSorted().toArray()[x];
|
||||||
string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n");
|
string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots"));
|
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotSquared.getPlotsSorted().size() + "").replaceAll("%plot%", PlotSquared.getPlotsSorted().size() == 1 ? "plot" : "plots"));
|
||||||
PlayerFunctions.sendMessage(plr, string.toString());
|
PlayerFunctions.sendMessage(plr, string.toString());
|
||||||
return true;
|
return true;
|
||||||
@ -177,7 +166,7 @@ public class list extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// execute(plr);
|
// execute(plr);
|
||||||
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
|
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison(args[0], new String[] { "mine", "shared", "world", "all" }).getBestMatch());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,5 +182,4 @@ public class list extends SubCommand {
|
|||||||
private String getString(final String s) {
|
private String getString(final String s) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.PlotSquared;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||||
|
|
||||||
public class plugin extends SubCommand {
|
public class plugin extends SubCommand {
|
||||||
|
|
||||||
public static String downloads, version;
|
public static String downloads, version;
|
||||||
|
|
||||||
public plugin() {
|
public plugin() {
|
||||||
@ -111,5 +109,4 @@ public class plugin extends SubCommand {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.config;
|
package com.intellectualcrafters.plot.config;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -201,7 +200,6 @@ public enum C {
|
|||||||
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."),
|
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."),
|
||||||
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"),
|
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"),
|
||||||
YOU_BE_DENIED("$2You are not allowed to enter this plot"),
|
YOU_BE_DENIED("$2You are not allowed to enter this plot"),
|
||||||
|
|
||||||
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"),
|
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"),
|
||||||
UNLINK_REQUIRED("$2An unlink is required to do this."),
|
UNLINK_REQUIRED("$2An unlink is required to do this."),
|
||||||
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot"),
|
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot"),
|
||||||
@ -329,7 +327,6 @@ public enum C {
|
|||||||
PLOT_INFO_ID("$1ID:$2 %id%"),
|
PLOT_INFO_ID("$1ID:$2 %id%"),
|
||||||
PLOT_INFO_ALIAS("$1Alias:$2 %alias%"),
|
PLOT_INFO_ALIAS("$1Alias:$2 %alias%"),
|
||||||
PLOT_INFO_SIZE("$1Size:$2 %size%"),
|
PLOT_INFO_SIZE("$1Size:$2 %size%"),
|
||||||
|
|
||||||
PLOT_USER_LIST(" $1%user%$2,"),
|
PLOT_USER_LIST(" $1%user%$2,"),
|
||||||
INFO_SYNTAX_CONSOLE("$2/plot info <world> X;Y"),
|
INFO_SYNTAX_CONSOLE("$2/plot info <world> X;Y"),
|
||||||
/*
|
/*
|
||||||
@ -389,7 +386,6 @@ public enum C {
|
|||||||
FLAG_KEY("$2Key: %s"),
|
FLAG_KEY("$2Key: %s"),
|
||||||
FLAG_TYPE("$2Type: %s"),
|
FLAG_TYPE("$2Type: %s"),
|
||||||
FLAG_DESC("$2Desc: %s"),
|
FLAG_DESC("$2Desc: %s"),
|
||||||
|
|
||||||
NEED_KEY("$2Possible values: $1%values%"),
|
NEED_KEY("$2Possible values: $1%values%"),
|
||||||
NOT_VALID_FLAG("$2That is not a valid flag"),
|
NOT_VALID_FLAG("$2That is not a valid flag"),
|
||||||
NOT_VALID_VALUE("$2Flag values must be alphanumerical"),
|
NOT_VALID_VALUE("$2Flag values must be alphanumerical"),
|
||||||
@ -442,7 +438,6 @@ public enum C {
|
|||||||
* Custom
|
* Custom
|
||||||
*/
|
*/
|
||||||
CUSTOM_STRING("-");
|
CUSTOM_STRING("-");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special Language
|
* Special Language
|
||||||
*
|
*
|
||||||
@ -474,7 +469,6 @@ public enum C {
|
|||||||
* Should the string be prefixed?
|
* Should the string be prefixed?
|
||||||
*/
|
*/
|
||||||
private boolean prefix;
|
private boolean prefix;
|
||||||
private ChatColor[] sColors = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for custom strings.
|
* Constructor for custom strings.
|
||||||
@ -520,7 +514,7 @@ public enum C {
|
|||||||
public static void saveTranslations() {
|
public static void saveTranslations() {
|
||||||
try {
|
try {
|
||||||
manager.saveAll(defaultFile).saveFile(defaultFile);
|
manager.saveAll(defaultFile).saveFile(defaultFile);
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,7 +534,7 @@ public enum C {
|
|||||||
* @return translated if exists else default
|
* @return translated if exists else default
|
||||||
*/
|
*/
|
||||||
public String s() {
|
public String s() {
|
||||||
String s = manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n");
|
final String s = manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n");
|
||||||
return s.replace("$1", COLOR_1.toString()).replace("$2", COLOR_2.toString()).replace("$3", COLOR_3.toString()).replace("$4", COLOR_4.toString());
|
return s.replace("$1", COLOR_1.toString()).replace("$2", COLOR_2.toString()).replace("$3", COLOR_3.toString()).replace("$4", COLOR_4.toString());
|
||||||
/*
|
/*
|
||||||
* if (PlotSquared.translations != null) {
|
* if (PlotSquared.translations != null) {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.config;
|
package com.intellectualcrafters.plot.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -32,8 +31,8 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
*
|
*
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused") public class Configuration {
|
@SuppressWarnings("unused")
|
||||||
|
public class Configuration {
|
||||||
public static final SettingValue STRING = new SettingValue("STRING") {
|
public static final SettingValue STRING = new SettingValue("STRING") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
@ -45,7 +44,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue STRINGLIST = new SettingValue("STRINGLIST") {
|
public static final SettingValue STRINGLIST = new SettingValue("STRINGLIST") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
@ -57,7 +55,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
return string.split(",");
|
return string.split(",");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue INTEGER = new SettingValue("INTEGER") {
|
public static final SettingValue INTEGER = new SettingValue("INTEGER") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
@ -74,7 +71,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
return Integer.parseInt(string);
|
return Integer.parseInt(string);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") {
|
public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
@ -91,7 +87,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
return Boolean.parseBoolean(string);
|
return Boolean.parseBoolean(string);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue DOUBLE = new SettingValue("DOUBLE") {
|
public static final SettingValue DOUBLE = new SettingValue("DOUBLE") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
@ -108,7 +103,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
return Double.parseDouble(string);
|
return Double.parseDouble(string);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue BIOME = new SettingValue("BIOME") {
|
public static final SettingValue BIOME = new SettingValue("BIOME") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
@ -135,7 +129,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
return (((Biome) object)).toString();
|
return (((Biome) object)).toString();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue BLOCK = new SettingValue("BLOCK") {
|
public static final SettingValue BLOCK = new SettingValue("BLOCK") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
@ -196,7 +189,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
public Object parseString(final String string) {
|
public Object parseString(final String string) {
|
||||||
final String[] blocks = string.split(",");
|
final String[] blocks = string.split(",");
|
||||||
final ArrayList<PlotBlock> parsedvalues = new ArrayList<>();
|
final ArrayList<PlotBlock> parsedvalues = new ArrayList<>();
|
||||||
|
|
||||||
final PlotBlock[] values = new PlotBlock[blocks.length];
|
final PlotBlock[] values = new PlotBlock[blocks.length];
|
||||||
final int[] counts = new int[blocks.length];
|
final int[] counts = new int[blocks.length];
|
||||||
int min = 100;
|
int min = 100;
|
||||||
@ -229,7 +221,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
parsedvalues.add(values[i]);
|
parsedvalues.add(values[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedvalues.toArray(new PlotBlock[parsedvalues.size()]);
|
return parsedvalues.toArray(new PlotBlock[parsedvalues.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.config;
|
package com.intellectualcrafters.plot.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -74,15 +73,13 @@ public class ConfigurationNode {
|
|||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
if (this.value instanceof String[]) {
|
if (this.value instanceof String[]) {
|
||||||
return Arrays.asList((String[]) this.value);
|
return Arrays.asList((String[]) this.value);
|
||||||
}
|
} else if (this.value instanceof Object[]) {
|
||||||
else if (this.value instanceof Object[]) {
|
final List<String> values = new ArrayList<String>();
|
||||||
List<String> values = new ArrayList<String>();
|
for (final Object value : (Object[]) this.value) {
|
||||||
for (Object value : (Object[]) this.value) {
|
|
||||||
values.add(value.toString());
|
values.add(value.toString());
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
}
|
} else if (this.value instanceof PlotBlock) {
|
||||||
else if (this.value instanceof PlotBlock) {
|
|
||||||
return this.value.toString();
|
return this.value.toString();
|
||||||
}
|
}
|
||||||
return this.value;
|
return this.value;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user