Some optimization, fixed copyright.

This commit is contained in:
Sauilitired 2014-11-08 20:27:09 +01:00
parent bcc34e7cd8
commit f71fabbfbf
143 changed files with 5090 additions and 4580 deletions

View File

@ -11,8 +11,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.7.9-R0.2" level="project" />
<orderEntry type="library" name="Maven: net.milkbowl.vault:Vault:1.3.2" level="project" />
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.7.10-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.sk89q:worldedit:6.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" name="Maven: rhino:js:1.7R2" level="project" />
@ -29,6 +29,8 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
@ -10,8 +31,7 @@ public final class ByteArrayTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public ByteArrayTag(final byte[] value) {
super();
@ -21,10 +41,8 @@ public final class ByteArrayTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public ByteArrayTag(final String name, final byte[] value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
@ -10,8 +31,7 @@ public final class ByteTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public ByteTag(final byte value) {
super();
@ -21,10 +41,8 @@ public final class ByteTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public ByteTag(final String name, final byte value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import java.util.Collections;
@ -15,8 +36,7 @@ public final class CompoundTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public CompoundTag(final Map<String, Tag> value) {
super();
@ -26,10 +46,8 @@ public final class CompoundTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public CompoundTag(final String name, final Map<String, Tag> value) {
super(name);
@ -39,8 +57,7 @@ public final class CompoundTag extends Tag {
/**
* Returns whether this compound tag contains the given key.
*
* @param key
* the given key
* @param key the given key
* @return true if the tag contains the given key
*/
public boolean containsKey(final String key) {
@ -55,8 +72,7 @@ public final class CompoundTag extends Tag {
/**
* Return a new compound tag with the given values.
*
* @param value
* the value
* @param value the value
* @return the new compound tag
*/
public CompoundTag setValue(final Map<String, Tag> value) {
@ -74,66 +90,60 @@ public final class CompoundTag extends Tag {
/**
* Get a byte array named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a byte array tag, then an
* empty byte array will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a byte array
*/
public byte[] getByteArray(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
}
else {
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a byte tag, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a byte
*/
public byte getByte(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else {
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a double tag, then
* {@code 0} will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a double
*/
public double getDouble(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
}
else {
} else {
return 0;
}
}
@ -141,14 +151,13 @@ public final class CompoundTag extends Tag {
/**
* Get a double named with the given key, even if it's another
* type of number.
*
* <p/>
* <p>
* If the key does not exist or its value is not a number, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a double
*/
public double asDouble(final String key) {
@ -156,94 +165,82 @@ public final class CompoundTag extends Tag {
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else if (tag instanceof ShortTag) {
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else if (tag instanceof IntTag) {
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else if (tag instanceof LongTag) {
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
}
else if (tag instanceof FloatTag) {
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
}
else if (tag instanceof DoubleTag) {
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
}
else {
} else {
return 0;
}
}
/**
* Get a float named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a float tag, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a float
*/
public float getFloat(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
}
else {
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not an int array tag, then an
* empty array will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return an int array
*/
public int[] getIntArray(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
}
else {
} else {
return new int[0];
}
}
/**
* Get an int named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not an int tag, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return an int
*/
public int getInt(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else {
} else {
return 0;
}
}
@ -251,14 +248,13 @@ public final class CompoundTag extends Tag {
/**
* Get an int named with the given key, even if it's another
* type of number.
*
* <p/>
* <p>
* If the key does not exist or its value is not a number, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return an int
*/
public int asInt(final String key) {
@ -266,92 +262,79 @@ public final class CompoundTag extends Tag {
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else if (tag instanceof ShortTag) {
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else if (tag instanceof IntTag) {
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else if (tag instanceof LongTag) {
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
}
else if (tag instanceof FloatTag) {
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
}
else if (tag instanceof DoubleTag) {
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
}
else {
} else {
return 0;
}
}
/**
* Get a list of tags named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a list tag, then an empty
* list will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a list of tags
*/
public List<Tag> getList(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
}
else {
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a list tag, then an empty
* tag list will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a tag list instance
*/
public ListTag getListTag(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof ListTag) {
return (ListTag) tag;
}
else {
return new ListTag(key, StringTag.class, Collections.<Tag> emptyList());
} else {
return new ListTag(key, StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a list tag, then an empty
* list will be returned. If the given key references a list but the list of
* of a different type, then an empty list will also be returned.
* </p>
*
* @param key
* the key
* @param listType
* the class of the contained type
* @param key the key
* @param listType the class of the contained type
* @param <T> the type of list
* @return a list of tags
* @param <T>
* the type of list
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(final String key, final Class<T> listType) {
@ -360,34 +343,30 @@ public final class CompoundTag extends Tag {
final ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
}
else {
} else {
return Collections.emptyList();
}
}
else {
} else {
return Collections.emptyList();
}
}
/**
* Get a long named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a long tag, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a long
*/
public long getLong(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
}
else {
} else {
return 0L;
}
}
@ -395,14 +374,13 @@ public final class CompoundTag extends Tag {
/**
* Get a long named with the given key, even if it's another
* type of number.
*
* <p/>
* <p>
* If the key does not exist or its value is not a number, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a long
*/
public long asLong(final String key) {
@ -410,72 +388,62 @@ public final class CompoundTag extends Tag {
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else if (tag instanceof ShortTag) {
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else if (tag instanceof IntTag) {
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else if (tag instanceof LongTag) {
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
}
else if (tag instanceof FloatTag) {
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
}
else if (tag instanceof DoubleTag) {
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
}
else {
} else {
return 0L;
}
}
/**
* Get a short named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a short tag, then {@code 0}
* will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a short
*/
public short getShort(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else {
} else {
return 0;
}
}
/**
* Get a string named with the given key.
*
* <p/>
* <p>
* If the key does not exist or its value is not a string tag, then
* {@code ""} will be returned.
* </p>
*
* @param key
* the key
* @param key the key
* @return a string
*/
public String getString(final String key) {
final Tag tag = this.value.get(key);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
}
else {
} else {
return "";
}
}

View File

@ -1,10 +1,31 @@
package com.intellectualcrafters.jnbt;
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
import static com.google.common.base.Preconditions.checkNotNull;
package com.intellectualcrafters.jnbt;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Helps create compound tags.
*/
@ -22,8 +43,7 @@ public class CompoundTagBuilder {
/**
* Create a new instance and use the given map (which will be modified).
*
* @param value
* the value
* @param value the value
*/
CompoundTagBuilder(final Map<String, Tag> value) {
checkNotNull(value);
@ -33,10 +53,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and tag into the compound tag.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder put(final String key, final Tag value) {
@ -50,10 +68,8 @@ public class CompoundTagBuilder {
* Put the given key and value into the compound tag as a
* {@code ByteArrayTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putByteArray(final String key, final byte[] value) {
@ -63,10 +79,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and value into the compound tag as a {@code ByteTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putByte(final String key, final byte value) {
@ -76,10 +90,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and value into the compound tag as a {@code DoubleTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putDouble(final String key, final double value) {
@ -89,10 +101,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and value into the compound tag as a {@code FloatTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putFloat(final String key, final float value) {
@ -103,10 +113,8 @@ public class CompoundTagBuilder {
* Put the given key and value into the compound tag as a
* {@code IntArrayTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putIntArray(final String key, final int[] value) {
@ -116,10 +124,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and value into the compound tag as an {@code IntTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putInt(final String key, final int value) {
@ -129,10 +135,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and value into the compound tag as a {@code LongTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putLong(final String key, final long value) {
@ -142,10 +146,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and value into the compound tag as a {@code ShortTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putShort(final String key, final short value) {
@ -155,10 +157,8 @@ public class CompoundTagBuilder {
/**
* Put the given key and value into the compound tag as a {@code StringTag}.
*
* @param key
* they key
* @param value
* the value
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putString(final String key, final String value) {
@ -168,8 +168,7 @@ public class CompoundTagBuilder {
/**
* Put all the entries from the given map into this map.
*
* @param value
* the map of tags
* @param value the map of tags
* @return this object
*/
public CompoundTagBuilder putAll(final Map<String, ? extends Tag> value) {
@ -192,8 +191,7 @@ public class CompoundTagBuilder {
/**
* Build a new compound tag with this builder's entries.
*
* @param name
* the name of the tag
* @param name the name of the tag
* @return the created compound tag
*/
public CompoundTag build(final String name) {

View File

@ -1,8 +1,28 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
* The {@code TAG_Double} tag.
*
*/
public final class DoubleTag extends Tag {
@ -11,8 +31,7 @@ public final class DoubleTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public DoubleTag(final double value) {
super();
@ -22,10 +41,8 @@ public final class DoubleTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public DoubleTag(final String name, final double value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
@ -10,8 +31,7 @@ public final class FloatTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public FloatTag(final float value) {
super();
@ -21,10 +41,8 @@ public final class FloatTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public FloatTag(final String name, final float value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
@ -12,8 +33,7 @@ public final class IntArrayTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public IntArrayTag(final int[] value) {
super();
@ -24,10 +44,8 @@ public final class IntArrayTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public IntArrayTag(final String name, final int[] value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
@ -10,8 +31,7 @@ public final class IntTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public IntTag(final int value) {
super();
@ -21,10 +41,8 @@ public final class IntTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public IntTag(final String name, final int value) {
super(name);

View File

@ -1,12 +1,32 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The {@code TAG_List} tag.
@ -14,15 +34,13 @@ import javax.annotation.Nullable;
public final class ListTag extends Tag {
private final Class<? extends Tag> type;
private final List<Tag> value;
private final List<Tag> value;
/**
* Creates the tag with an empty name.
*
* @param type
* the type of tag
* @param value
* the value of the tag
* @param type the type of tag
* @param value the value of the tag
*/
public ListTag(final Class<? extends Tag> type, final List<? extends Tag> value) {
super();
@ -34,12 +52,9 @@ public final class ListTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param type
* the type of tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param type the type of tag
* @param value the value of the tag
*/
public ListTag(final String name, final Class<? extends Tag> type, final List<? extends Tag> value) {
super(name);
@ -65,8 +80,7 @@ public final class ListTag extends Tag {
/**
* Create a new list tag with this tag's name and type.
*
* @param list
* the new list
* @param list the new list
* @return a new list tag
*/
public ListTag setValue(final List<Tag> list) {
@ -76,82 +90,74 @@ public final class ListTag extends Tag {
/**
* Get the tag if it exists at the given index.
*
* @param index
* the index
* @param index the index
* @return the tag or null
*/
@Nullable
public Tag getIfExists(final int index) {
try {
return this.value.get(index);
}
catch (final NoSuchElementException e) {
} catch (final NoSuchElementException e) {
return null;
}
}
/**
* Get a byte array named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a byte array tag, then an
* empty byte array will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a byte array
*/
public byte[] getByteArray(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
}
else {
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a byte tag, then
* {@code 0} will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a byte
*/
public byte getByte(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else {
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a double tag, then
* {@code 0} will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a double
*/
public double getDouble(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
}
else {
} else {
return 0;
}
}
@ -159,14 +165,13 @@ public final class ListTag extends Tag {
/**
* Get a double named with the given index, even if it's another
* type of number.
*
* <p/>
* <p>
* If the index does not exist or its value is not a number, then {@code 0}
* will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a double
*/
public double asDouble(final int index) {
@ -174,94 +179,82 @@ public final class ListTag extends Tag {
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else if (tag instanceof ShortTag) {
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else if (tag instanceof IntTag) {
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else if (tag instanceof LongTag) {
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
}
else if (tag instanceof FloatTag) {
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
}
else if (tag instanceof DoubleTag) {
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
}
else {
} else {
return 0;
}
}
/**
* Get a float named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a float tag, then
* {@code 0} will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a float
*/
public float getFloat(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
}
else {
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not an int array tag, then an
* empty array will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return an int array
*/
public int[] getIntArray(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
}
else {
} else {
return new int[0];
}
}
/**
* Get an int named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not an int tag, then
* {@code 0} will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return an int
*/
public int getInt(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else {
} else {
return 0;
}
}
@ -269,14 +262,13 @@ public final class ListTag extends Tag {
/**
* Get an int named with the given index, even if it's another
* type of number.
*
* <p/>
* <p>
* If the index does not exist or its value is not a number, then {@code 0}
* will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return an int
*/
public int asInt(final int index) {
@ -284,92 +276,79 @@ public final class ListTag extends Tag {
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else if (tag instanceof ShortTag) {
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else if (tag instanceof IntTag) {
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else if (tag instanceof LongTag) {
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
}
else if (tag instanceof FloatTag) {
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
}
else if (tag instanceof DoubleTag) {
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
}
else {
} else {
return 0;
}
}
/**
* Get a list of tags named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a list tag, then an empty
* list will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a list of tags
*/
public List<Tag> getList(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
}
else {
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a list tag, then an empty
* tag list will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a tag list instance
*/
public ListTag getListTag(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return (ListTag) tag;
}
else {
return new ListTag(StringTag.class, Collections.<Tag> emptyList());
} else {
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a list tag, then an empty
* list will be returned. If the given index references a list but the list
* of of a different type, then an empty list will also be returned.
* </p>
*
* @param index
* the index
* @param listType
* the class of the contained type
* @param index the index
* @param listType the class of the contained type
* @param <T> the NBT type
* @return a list of tags
* @param <T>
* the NBT type
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(final int index, final Class<T> listType) {
@ -378,34 +357,30 @@ public final class ListTag extends Tag {
final ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
}
else {
} else {
return Collections.emptyList();
}
}
else {
} else {
return Collections.emptyList();
}
}
/**
* Get a long named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a long tag, then
* {@code 0} will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a long
*/
public long getLong(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
}
else {
} else {
return 0L;
}
}
@ -413,14 +388,13 @@ public final class ListTag extends Tag {
/**
* Get a long named with the given index, even if it's another
* type of number.
*
* <p/>
* <p>
* If the index does not exist or its value is not a number, then {@code 0}
* will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a long
*/
public long asLong(final int index) {
@ -428,72 +402,62 @@ public final class ListTag extends Tag {
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
}
else if (tag instanceof ShortTag) {
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else if (tag instanceof IntTag) {
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
}
else if (tag instanceof LongTag) {
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
}
else if (tag instanceof FloatTag) {
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
}
else if (tag instanceof DoubleTag) {
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
}
else {
} else {
return 0;
}
}
/**
* Get a short named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a short tag, then
* {@code 0} will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a short
*/
public short getShort(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
}
else {
} else {
return 0;
}
}
/**
* Get a string named with the given index.
*
* <p/>
* <p>
* If the index does not exist or its value is not a string tag, then
* {@code ""} will be returned.
* </p>
*
* @param index
* the index
* @param index the index
* @return a string
*/
public String getString(final int index) {
final Tag tag = getIfExists(index);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
}
else {
} else {
return "";
}
}

View File

@ -1,25 +1,45 @@
package com.intellectualcrafters.jnbt;
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
import static com.google.common.base.Preconditions.checkNotNull;
package com.intellectualcrafters.jnbt;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Helps create list tags.
*/
public class ListTagBuilder {
private final Class<? extends Tag> type;
private final List<Tag> entries;
private final List<Tag> entries;
/**
* Create a new instance.
*
* @param type
* of tag contained in this list
* @param type of tag contained in this list
*/
ListTagBuilder(final Class<? extends Tag> type) {
checkNotNull(type);
@ -30,8 +50,7 @@ public class ListTagBuilder {
/**
* Add the given tag.
*
* @param value
* the tag
* @param value the tag
* @return this object
*/
public ListTagBuilder add(final Tag value) {
@ -46,8 +65,7 @@ public class ListTagBuilder {
/**
* Add all the tags in the given list.
*
* @param value
* a list of tags
* @param value a list of tags
* @return this object
*/
public ListTagBuilder addAll(final Collection<? extends Tag> value) {
@ -70,8 +88,7 @@ public class ListTagBuilder {
/**
* Build a new list tag with this builder's entries.
*
* @param name
* the name of the tag
* @param name the name of the tag
* @return the created list tag
*/
public ListTag build(final String name) {

View File

@ -1,8 +1,28 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
* The {@code TAG_Long} tag.
*
*/
public final class LongTag extends Tag {
@ -11,8 +31,7 @@ public final class LongTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public LongTag(final long value) {
super();
@ -22,10 +41,8 @@ public final class LongTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public LongTag(final String name, final long value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import java.nio.charset.Charset;
@ -9,7 +30,7 @@ public final class NBTConstants {
public static final Charset CHARSET = Charset.forName("UTF-8");
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
/**
* Default private constructor.
@ -21,11 +42,9 @@ public final class NBTConstants {
/**
* Convert a type ID to its corresponding {@link Tag} class.
*
* @param id
* type ID
* @param id type ID
* @return tag class
* @throws IllegalArgumentException
* thrown if the tag ID is not valid
* @throws IllegalArgumentException thrown if the tag ID is not valid
*/
public static Class<? extends Tag> getClassFromType(final int id) {
switch (id) {

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import java.io.Closeable;
@ -13,7 +34,7 @@ import java.util.Map;
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* streams, and produces an object graph of subclasses of the {@code Tag}
* object.
*
* <p/>
* <p>
* The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
@ -28,10 +49,8 @@ public final class NBTInputStream implements Closeable {
* Creates a new {@code NBTInputStream}, which will source its data
* from the specified input stream.
*
* @param is
* the input stream
* @throws IOException
* if an I/O error occurs
* @param is the input stream
* @throws IOException if an I/O error occurs
*/
public NBTInputStream(final InputStream is) throws IOException {
this.is = new DataInputStream(is);
@ -41,8 +60,7 @@ public final class NBTInputStream implements Closeable {
* Reads an NBT tag from the stream.
*
* @return The tag that was read.
* @throws IOException
* if an I/O error occurs.
* @throws IOException if an I/O error occurs.
*/
public Tag readTag() throws IOException {
return readTag(0);
@ -51,11 +69,9 @@ public final class NBTInputStream implements Closeable {
/**
* Reads an NBT from the stream.
*
* @param depth
* the depth of this tag
* @param depth the depth of this tag
* @return The tag that was read.
* @throws IOException
* if an I/O error occurs.
* @throws IOException if an I/O error occurs.
*/
private Tag readTag(final int depth) throws IOException {
final int type = this.is.readByte() & 0xFF;
@ -66,8 +82,7 @@ public final class NBTInputStream implements Closeable {
final byte[] nameBytes = new byte[nameLength];
this.is.readFully(nameBytes);
name = new String(nameBytes, NBTConstants.CHARSET);
}
else {
} else {
name = "";
}
@ -77,23 +92,18 @@ public final class NBTInputStream implements Closeable {
/**
* Reads the payload of a tag, given the name and type.
*
* @param type
* the type
* @param name
* the name
* @param depth
* the depth
* @param type the type
* @param name the name
* @param depth the depth
* @return the tag
* @throws IOException
* if an I/O error occurs.
* @throws IOException if an I/O error occurs.
*/
private Tag readTagPayload(final int type, final String name, final int depth) throws IOException {
switch (type) {
case NBTConstants.TYPE_END:
if (depth == 0) {
throw new IOException("TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
}
else {
} else {
return new EndTag();
}
case NBTConstants.TYPE_BYTE:
@ -138,8 +148,7 @@ public final class NBTInputStream implements Closeable {
final Tag tag = readTag(depth + 1);
if (tag instanceof EndTag) {
break;
}
else {
} else {
tagMap.put(tag.getName(), tag);
}
}

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import java.io.Closeable;
@ -11,7 +32,7 @@ import java.util.List;
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* <code>Tag</code> objects to an underlying <code>OutputStream</code>.
* </p>
*
* <p/>
* <p>
* The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
@ -19,7 +40,6 @@ import java.util.List;
* </p>
*
* @author Graham Edgecombe
*
*/
public final class NBTOutputStream implements Closeable {
@ -32,10 +52,8 @@ public final class NBTOutputStream implements Closeable {
* Creates a new <code>NBTOutputStream</code>, which will write data to the
* specified underlying output stream.
*
* @param os
* The output stream.
* @throws IOException
* if an I/O error occurs.
* @param os The output stream.
* @throws IOException if an I/O error occurs.
*/
public NBTOutputStream(final OutputStream os) throws IOException {
this.os = new DataOutputStream(os);
@ -44,10 +62,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a tag.
*
* @param tag
* The tag to write.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag to write.
* @throws IOException if an I/O error occurs.
*/
public void writeTag(final Tag tag) throws IOException {
final int type = NBTUtils.getTypeCode(tag.getClass());
@ -68,10 +84,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes tag payload.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeTagPayload(final Tag tag) throws IOException {
final int type = NBTUtils.getTypeCode(tag.getClass());
@ -120,10 +134,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Byte</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeByteTagPayload(final ByteTag tag) throws IOException {
this.os.writeByte(tag.getValue());
@ -132,10 +144,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Byte_Array</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeByteArrayTagPayload(final ByteArrayTag tag) throws IOException {
final byte[] bytes = tag.getValue();
@ -146,10 +156,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Compound</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeCompoundTagPayload(final CompoundTag tag) throws IOException {
for (final Tag childTag : tag.getValue().values()) {
@ -161,10 +169,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_List</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeListTagPayload(final ListTag tag) throws IOException {
final Class<? extends Tag> clazz = tag.getType();
@ -181,10 +187,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_String</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeStringTagPayload(final StringTag tag) throws IOException {
final byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
@ -195,10 +199,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Double</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeDoubleTagPayload(final DoubleTag tag) throws IOException {
this.os.writeDouble(tag.getValue());
@ -207,10 +209,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Float</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeFloatTagPayload(final FloatTag tag) throws IOException {
this.os.writeFloat(tag.getValue());
@ -219,10 +219,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Long</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeLongTagPayload(final LongTag tag) throws IOException {
this.os.writeLong(tag.getValue());
@ -231,10 +229,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Int</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeIntTagPayload(final IntTag tag) throws IOException {
this.os.writeInt(tag.getValue());
@ -243,10 +239,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Short</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeShortTagPayload(final ShortTag tag) throws IOException {
this.os.writeShort(tag.getValue());
@ -255,10 +249,8 @@ public final class NBTOutputStream implements Closeable {
/**
* Writes a <code>TAG_Empty</code> tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeEndTagPayload(final EndTag tag) {
/* empty */

View File

@ -1,10 +1,30 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import java.util.Map;
/**
* A class which contains NBT-related utility methods.
*
*/
public final class NBTUtils {
@ -17,48 +37,35 @@ public final class NBTUtils {
/**
* Gets the type name of a tag.
*
* @param clazz
* the tag class
* @param clazz the tag class
* @return The type name.
*/
public static String getTypeName(final Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return "TAG_Byte_Array";
}
else if (clazz.equals(ByteTag.class)) {
} else if (clazz.equals(ByteTag.class)) {
return "TAG_Byte";
}
else if (clazz.equals(CompoundTag.class)) {
} else if (clazz.equals(CompoundTag.class)) {
return "TAG_Compound";
}
else if (clazz.equals(DoubleTag.class)) {
} else if (clazz.equals(DoubleTag.class)) {
return "TAG_Double";
}
else if (clazz.equals(EndTag.class)) {
} else if (clazz.equals(EndTag.class)) {
return "TAG_End";
}
else if (clazz.equals(FloatTag.class)) {
} else if (clazz.equals(FloatTag.class)) {
return "TAG_Float";
}
else if (clazz.equals(IntTag.class)) {
} else if (clazz.equals(IntTag.class)) {
return "TAG_Int";
}
else if (clazz.equals(ListTag.class)) {
} else if (clazz.equals(ListTag.class)) {
return "TAG_List";
}
else if (clazz.equals(LongTag.class)) {
} else if (clazz.equals(LongTag.class)) {
return "TAG_Long";
}
else if (clazz.equals(ShortTag.class)) {
} else if (clazz.equals(ShortTag.class)) {
return "TAG_Short";
}
else if (clazz.equals(StringTag.class)) {
} else if (clazz.equals(StringTag.class)) {
return "TAG_String";
}
else if (clazz.equals(IntArrayTag.class)) {
} else if (clazz.equals(IntArrayTag.class)) {
return "TAG_Int_Array";
}
else {
} else {
throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
@ -66,50 +73,36 @@ public final class NBTUtils {
/**
* Gets the type code of a tag class.
*
* @param clazz
* the tag class
* @param clazz the tag class
* @return The type code.
* @throws IllegalArgumentException
* if the tag class is invalid.
* @throws IllegalArgumentException if the tag class is invalid.
*/
public static int getTypeCode(final Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return NBTConstants.TYPE_BYTE_ARRAY;
}
else if (clazz.equals(ByteTag.class)) {
} else if (clazz.equals(ByteTag.class)) {
return NBTConstants.TYPE_BYTE;
}
else if (clazz.equals(CompoundTag.class)) {
} else if (clazz.equals(CompoundTag.class)) {
return NBTConstants.TYPE_COMPOUND;
}
else if (clazz.equals(DoubleTag.class)) {
} else if (clazz.equals(DoubleTag.class)) {
return NBTConstants.TYPE_DOUBLE;
}
else if (clazz.equals(EndTag.class)) {
} else if (clazz.equals(EndTag.class)) {
return NBTConstants.TYPE_END;
}
else if (clazz.equals(FloatTag.class)) {
} else if (clazz.equals(FloatTag.class)) {
return NBTConstants.TYPE_FLOAT;
}
else if (clazz.equals(IntTag.class)) {
} else if (clazz.equals(IntTag.class)) {
return NBTConstants.TYPE_INT;
}
else if (clazz.equals(ListTag.class)) {
} else if (clazz.equals(ListTag.class)) {
return NBTConstants.TYPE_LIST;
}
else if (clazz.equals(LongTag.class)) {
} else if (clazz.equals(LongTag.class)) {
return NBTConstants.TYPE_LONG;
}
else if (clazz.equals(ShortTag.class)) {
} else if (clazz.equals(ShortTag.class)) {
return NBTConstants.TYPE_SHORT;
}
else if (clazz.equals(StringTag.class)) {
} else if (clazz.equals(StringTag.class)) {
return NBTConstants.TYPE_STRING;
}
else if (clazz.equals(IntArrayTag.class)) {
} else if (clazz.equals(IntArrayTag.class)) {
return NBTConstants.TYPE_INT_ARRAY;
}
else {
} else {
throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
@ -117,11 +110,9 @@ public final class NBTUtils {
/**
* Gets the class of a type of tag.
*
* @param type
* the type
* @param type the type
* @return The class.
* @throws IllegalArgumentException
* if the tag type is invalid.
* @throws IllegalArgumentException if the tag type is invalid.
*/
public static Class<? extends Tag> getTypeClass(final int type) {
switch (type) {
@ -157,12 +148,9 @@ public final class NBTUtils {
/**
* Get child tag of a NBT structure.
*
* @param items
* the map to read from
* @param key
* the key to look for
* @param expected
* the expected NBT class type
* @param items the map to read from
* @param key the key to look for
* @param expected the expected NBT class type
* @return child tag
* @throws InvalidFormatException
*/

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
@ -10,8 +31,7 @@ public final class ShortTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public ShortTag(final short value) {
super();
@ -21,10 +41,8 @@ public final class ShortTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public ShortTag(final String name, final short value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
@ -12,8 +33,7 @@ public final class StringTag extends Tag {
/**
* Creates the tag with an empty name.
*
* @param value
* the value of the tag
* @param value the value of the tag
*/
public StringTag(final String value) {
super();
@ -24,10 +44,8 @@ public final class StringTag extends Tag {
/**
* Creates the tag.
*
* @param name
* the name of the tag
* @param value
* the value of the tag
* @param name the name of the tag
* @param value the value of the tag
*/
public StringTag(final String name, final String value) {
super(name);

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
@ -17,8 +38,7 @@ public abstract class Tag {
/**
* Creates the tag with the specified name.
*
* @param name
* the name
* @param name the name
*/
Tag(String name) {
if (name == null) {

View File

@ -1,14 +1,28 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import org.bukkit.World;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitUtil;
public class WorldEditUtils {
public static void setNBT(final World world, final short id, final byte data, final int x, final int y, final int z, final com.intellectualcrafters.jnbt.CompoundTag tag) {

View File

@ -1,42 +1,39 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* This provides static methods to convert comma delimited text into a
* JSONArray, and to covert a JSONArray into comma delimited text. Comma
* delimited text is a very popular format for data interchange. It is
* understood by most database, spreadsheet, and organizer programs.
* <p>
* <p/>
* Each row of text represents a row in a table or a data record. Each row ends
* with a NEWLINE character. Each row contains one or more values. Values are
* separated by commas. A value can contain any character except for comma,
* unless is is wrapped in single quotes or double quotes.
* <p>
* <p/>
* The first row usually contains the names of the columns.
* <p>
* <p/>
* A comma delimited list can be converted into a JSONArray of JSONObjects. The
* names for the elements in the JSONObjects can be taken from the names in the
* first row.
@ -50,11 +47,9 @@ public class CDL {
* Get the next value. The value can be wrapped in quotes. The value can
* be empty.
*
* @param x
* A JSONTokener of the source text.
* @param x A JSONTokener of the source text.
* @return The value string, or null if empty.
* @throws JSONException
* if the quoted string is badly formed.
* @throws JSONException if the quoted string is badly formed.
*/
private static String getValue(final JSONTokener x) throws JSONException {
char c;
@ -71,7 +66,7 @@ public class CDL {
case '\'':
q = c;
sb = new StringBuffer();
for (;;) {
for (; ; ) {
c = x.next();
if (c == q) {
break;
@ -94,21 +89,20 @@ public class CDL {
/**
* Produce a JSONArray of strings from a row of comma delimited values.
*
* @param x
* A JSONTokener of the source text.
* @param x A JSONTokener of the source text.
* @return A JSONArray of strings.
* @throws JSONException
*/
public static JSONArray rowToJSONArray(final JSONTokener x) throws JSONException {
final JSONArray ja = new JSONArray();
for (;;) {
for (; ; ) {
final String value = getValue(x);
char c = x.next();
if ((value == null) || ((ja.length() == 0) && (value.length() == 0) && (c != ','))) {
return null;
}
ja.put(value);
for (;;) {
for (; ; ) {
if (c == ',') {
break;
}
@ -127,13 +121,11 @@ public class CDL {
* Produce a JSONObject from a row of comma delimited text, using a
* parallel JSONArray of strings to provides the names of the elements.
*
* @param names
* A JSONArray of names. This is commonly obtained from the
* first row of a comma delimited text file using the
* rowToJSONArray
* method.
* @param x
* A JSONTokener of the source text.
* @param names A JSONArray of names. This is commonly obtained from the
* first row of a comma delimited text file using the
* rowToJSONArray
* method.
* @param x A JSONTokener of the source text.
* @return A JSONObject combining the names and values.
* @throws JSONException
*/
@ -147,8 +139,7 @@ public class CDL {
* the comma character will be quoted. Troublesome characters may be
* removed.
*
* @param ja
* A JSONArray of strings.
* @param ja A JSONArray of strings.
* @return A string ending in NEWLINE.
*/
public static String rowToString(final JSONArray ja) {
@ -170,8 +161,7 @@ public class CDL {
}
}
sb.append('"');
}
else {
} else {
sb.append(string);
}
}
@ -184,8 +174,7 @@ public class CDL {
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
*
* @param string
* The comma delimited text.
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
@ -197,8 +186,7 @@ public class CDL {
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
*
* @param x
* The JSONTokener containing the comma delimited text.
* @param x The JSONTokener containing the comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
@ -210,10 +198,8 @@ public class CDL {
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
*
* @param names
* A JSONArray of strings.
* @param string
* The comma delimited text.
* @param names A JSONArray of strings.
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
@ -225,10 +211,8 @@ public class CDL {
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
*
* @param names
* A JSONArray of strings.
* @param x
* A JSONTokener of the source text.
* @param names A JSONArray of strings.
* @param x A JSONTokener of the source text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
@ -237,7 +221,7 @@ public class CDL {
return null;
}
final JSONArray ja = new JSONArray();
for (;;) {
for (; ; ) {
final JSONObject jo = rowToJSONObject(names, x);
if (jo == null) {
break;
@ -255,8 +239,7 @@ public class CDL {
* first row will be a list of names obtained by inspecting the first
* JSONObject.
*
* @param ja
* A JSONArray of JSONObjects.
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/
@ -276,10 +259,8 @@ public class CDL {
* a provided list of names. The list of names is not included in the
* output.
*
* @param names
* A JSONArray of strings.
* @param ja
* A JSONArray of JSONObjects.
* @param names A JSONArray of strings.
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Convert a web browser cookie specification to a JSONObject and back.
* JSON and Cookies are both notations for name/value pairs.
@ -43,8 +40,7 @@ public class Cookie {
* encoded values. We encode '=' and ';' because we must. We encode '%' and
* '+' because they are meta characters in URL encoding.
*
* @param string
* The source string.
* @param string The source string.
* @return The escaped result.
*/
public static String escape(final String string) {
@ -58,8 +54,7 @@ public class Cookie {
sb.append('%');
sb.append(Character.forDigit((char) ((c >>> 4) & 0x0f), 16));
sb.append(Character.forDigit((char) (c & 0x0f), 16));
}
else {
} else {
sb.append(c);
}
}
@ -77,10 +72,9 @@ public class Cookie {
* validation of the parameters. It only converts the cookie string into
* a JSONObject.
*
* @param string
* The cookie specification string.
* @param string The cookie specification string.
* @return A JSONObject containing "name", "value", and possibly other
* members.
* members.
* @throws JSONException
*/
public static JSONObject toJSONObject(final String string) throws JSONException {
@ -97,12 +91,10 @@ public class Cookie {
if (x.next() != '=') {
if (name.equals("secure")) {
value = Boolean.TRUE;
}
else {
} else {
throw x.syntaxError("Missing '=' in cookie parameter.");
}
}
else {
} else {
value = unescape(x.nextTo(';'));
x.next();
}
@ -118,8 +110,7 @@ public class Cookie {
* members, they will be appended to the cookie specification string.
* All other members are ignored.
*
* @param jo
* A JSONObject
* @param jo A JSONObject
* @return A cookie specification string
* @throws JSONException
*/
@ -151,10 +142,9 @@ public class Cookie {
* Convert <code>%</code><i>hh</i> sequences to single characters, and
* convert plus to space.
*
* @param string
* A string that may contain <code>+</code>
* &nbsp;<small>(plus)</small> and <code>%</code><i>hh</i>
* sequences.
* @param string A string that may contain <code>+</code>
* &nbsp;<small>(plus)</small> and <code>%</code><i>hh</i>
* sequences.
* @return The unescaped string.
*/
public static String unescape(final String string) {
@ -164,8 +154,7 @@ public class Cookie {
char c = string.charAt(i);
if (c == '+') {
c = ' ';
}
else if ((c == '%') && ((i + 2) < length)) {
} else if ((c == '%') && ((i + 2) < length)) {
final int d = JSONTokener.dehexchar(string.charAt(i + 1));
final int e = JSONTokener.dehexchar(string.charAt(i + 2));
if ((d >= 0) && (e >= 0)) {

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.util.Iterator;
/**
@ -39,13 +36,12 @@ public class CookieList {
* 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 converting '+' and '%' sequences.
*
* <p/>
* To add a cookie to a cooklist,
* cookielistJSONObject.put(cookieJSONObject.getString("name"),
* cookieJSONObject.getString("value"));
*
* @param string
* A cookie list string
* @param string A cookie list string
* @return A JSONObject
* @throws JSONException
*/
@ -67,8 +63,7 @@ public class CookieList {
* The pairs are separated by ';'. The characters '%', '+', '=', and ';'
* in the names and values are replaced by "%hh".
*
* @param jo
* A JSONObject
* @param jo A JSONObject
* @return A cookie list string
* @throws JSONException
*/

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.util.Iterator;
/**
@ -34,13 +31,15 @@ import java.util.Iterator;
*/
public class HTTP {
/** Carriage return/line feed. */
/**
* Carriage return/line feed.
*/
public static final String CRLF = "\r\n";
/**
* Convert an HTTP header string into a JSONObject. It can be a request
* header or a response header. A request header will contain
*
* <p/>
* <pre>
* {
* Method: "POST" (for example),
@ -48,9 +47,9 @@ public class HTTP {
* "HTTP-Version": "HTTP/1.1" (for example)
* }
* </pre>
*
* <p/>
* A response header will contain
*
* <p/>
* <pre>
* {
* "HTTP-Version": "HTTP/1.1" (for example),
@ -58,18 +57,18 @@ public class HTTP {
* "Reason-Phrase": "OK" (for example)
* }
* </pre>
*
* <p/>
* In addition, the other parameters in the header will be captured, using
* the HTTP field names as JSON names, so that
*
* <p/>
* <pre>
* Date: Sun, 26 May 2002 18:06:04 GMT
* Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
* Cache-Control: no-cache
* </pre>
*
* <p/>
* become
*
* <p/>
* <pre>
* {...
* Date: "Sun, 26 May 2002 18:06:04 GMT",
@ -77,14 +76,13 @@ public class HTTP {
* "Cache-Control": "no-cache",
* ...}
* </pre>
*
* <p/>
* It does no further checking or conversion. It does not parse dates.
* It does not do '%' transforms on URLs.
*
* @param string
* An HTTP header string.
* @param string An HTTP header string.
* @return A JSONObject containing the elements and attributes
* of the XML string.
* of the XML string.
* @throws JSONException
*/
public static JSONObject toJSONObject(final String string) throws JSONException {
@ -102,8 +100,7 @@ public class HTTP {
jo.put("Reason-Phrase", x.nextTo('\0'));
x.next();
}
else {
} else {
// Request
@ -125,7 +122,7 @@ public class HTTP {
/**
* Convert a JSONObject into an HTTP header. A request header must contain
*
* <p/>
* <pre>
* {
* Method: "POST" (for example),
@ -133,9 +130,9 @@ public class HTTP {
* "HTTP-Version": "HTTP/1.1" (for example)
* }
* </pre>
*
* <p/>
* A response header must contain
*
* <p/>
* <pre>
* {
* "HTTP-Version": "HTTP/1.1" (for example),
@ -143,16 +140,14 @@ public class HTTP {
* "Reason-Phrase": "OK" (for example)
* }
* </pre>
*
* <p/>
* Any other members of the JSONObject will be output as HTTP fields.
* The result will end with two CRLF pairs.
*
* @param jo
* A JSONObject
* @param jo A JSONObject
* @return An HTTP header string.
* @throws JSONException
* if the object does not contain enough
* information.
* @throws JSONException if the object does not contain enough
* information.
*/
public static String toString(final JSONObject jo) throws JSONException {
final Iterator<String> keys = jo.keys();
@ -164,8 +159,7 @@ public class HTTP {
sb.append(jo.getString("Status-Code"));
sb.append(' ');
sb.append(jo.getString("Reason-Phrase"));
}
else if (jo.has("Method") && jo.has("Request-URI")) {
} else if (jo.has("Method") && jo.has("Request-URI")) {
sb.append(jo.getString("Method"));
sb.append(' ');
sb.append('"');
@ -173,8 +167,7 @@ public class HTTP {
sb.append('"');
sb.append(' ');
sb.append(jo.getString("HTTP-Version"));
}
else {
} else {
throw new JSONException("Not enough material for an HTTP header.");
}
sb.append(CRLF);

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* The HTTPTokener extends the JSONTokener to provide additional methods
* for the parsing of HTTP headers.
@ -36,8 +33,7 @@ public class HTTPTokener extends JSONTokener {
/**
* Construct an HTTPTokener from a string.
*
* @param string
* A source string.
* @param string A source string.
*/
public HTTPTokener(final String string) {
super(string);
@ -46,8 +42,8 @@ public class HTTPTokener extends JSONTokener {
/**
* Get the next token or string. This is used in parsing HTTP headers.
*
* @throws JSONException
* @return A String.
* @throws JSONException
*/
public String nextToken() throws JSONException {
char c;
@ -59,7 +55,7 @@ public class HTTPTokener extends JSONTokener {
while (Character.isWhitespace(c));
if ((c == '"') || (c == '\'')) {
q = c;
for (;;) {
for (; ; ) {
c = next();
if (c < ' ') {
throw syntaxError("Unterminated string.");
@ -70,7 +66,7 @@ public class HTTPTokener extends JSONTokener {
sb.append(c);
}
}
for (;;) {
for (; ; ) {
if ((c == 0) || Character.isWhitespace(c)) {
return sb.toString();
}

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
@ -42,20 +39,20 @@ import java.util.Map;
* <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
* <code>Number</code>, <code>String</code>, or the
* <code>JSONObject.NULL object</code>.
* <p>
* <p/>
* The constructor can convert a JSON text into a Java object. The
* <code>toString</code> method converts to JSON text.
* <p>
* <p/>
* A <code>get</code> method returns a value if one can be found, and throws an
* exception if one cannot be found. An <code>opt</code> method returns a
* default value instead of throwing an exception, and so is useful for
* obtaining optional values.
* <p>
* <p/>
* The generic <code>get()</code> and <code>opt()</code> methods return an
* object which you can cast or query for type. There are also typed
* <code>get</code> and <code>opt</code> methods that do type checking and type
* coercion for you.
* <p>
* <p/>
* The texts produced by the <code>toString</code> methods strictly conform to
* JSON syntax rules. The constructors are more forgiving in the texts they will
* accept:
@ -94,10 +91,8 @@ public class JSONArray {
/**
* Construct a JSONArray from a JSONTokener.
*
* @param x
* A JSONTokener
* @throws JSONException
* If there is a syntax error.
* @param x A JSONTokener
* @throws JSONException If there is a syntax error.
*/
public JSONArray(final JSONTokener x) throws JSONException {
this();
@ -106,12 +101,11 @@ public class JSONArray {
}
if (x.nextClean() != ']') {
x.back();
for (;;) {
for (; ; ) {
if (x.nextClean() == ',') {
x.back();
this.myArrayList.add(JSONObject.NULL);
}
else {
} else {
x.back();
this.myArrayList.add(x.nextValue());
}
@ -134,12 +128,10 @@ public class JSONArray {
/**
* Construct a JSONArray from a source JSON text.
*
* @param source
* A string that begins with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ends with <code>]</code>
* &nbsp;<small>(right bracket)</small>.
* @throws JSONException
* If there is a syntax error.
* @param source A string that begins with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ends with <code>]</code>
* &nbsp;<small>(right bracket)</small>.
* @throws JSONException If there is a syntax error.
*/
public JSONArray(final String source) throws JSONException {
this(new JSONTokener(source));
@ -148,8 +140,7 @@ public class JSONArray {
/**
* Construct a JSONArray from a Collection.
*
* @param collection
* A Collection.
* @param collection A Collection.
*/
public JSONArray(final Collection<Object> collection) {
this.myArrayList = new ArrayList<Object>();
@ -164,8 +155,7 @@ public class JSONArray {
/**
* Construct a JSONArray from an array
*
* @throws JSONException
* If not an array.
* @throws JSONException If not an array.
*/
public JSONArray(final Object array) throws JSONException {
this();
@ -174,8 +164,7 @@ public class JSONArray {
for (int i = 0; i < length; i += 1) {
this.put(JSONObject.wrap(Array.get(array, i)));
}
}
else {
} else {
throw new JSONException("JSONArray initial value should be a string or collection or array.");
}
}
@ -183,11 +172,9 @@ public class JSONArray {
/**
* Get the object value associated with an index.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return An object value.
* @throws JSONException
* If there is no value for the index.
* @throws JSONException If there is no value for the index.
*/
public Object get(final int index) throws JSONException {
final Object object = this.opt(index);
@ -201,19 +188,16 @@ public class JSONArray {
* Get the boolean value associated with an index. The string values "true"
* and "false" are converted to boolean.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The truth.
* @throws JSONException
* If there is no value for the index or if the value is not
* convertible to boolean.
* @throws JSONException If there is no value for the index or if the value is not
* convertible to boolean.
*/
public boolean getBoolean(final int index) throws JSONException {
final Object object = this.get(index);
if (object.equals(Boolean.FALSE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("false"))) {
return false;
}
else if (object.equals(Boolean.TRUE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("true"))) {
} else if (object.equals(Boolean.TRUE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("true"))) {
return true;
}
throw new JSONException("JSONArray[" + index + "] is not a boolean.");
@ -222,19 +206,16 @@ public class JSONArray {
/**
* Get the double value associated with an index.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException
* If the key is not found or if the value cannot be converted
* to a number.
* @throws JSONException If the key is not found or if the value cannot be converted
* to a number.
*/
public double getDouble(final int index) throws JSONException {
final Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
@ -242,18 +223,15 @@ public class JSONArray {
/**
* Get the int value associated with an index.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException
* If the key is not found or if the value is not a number.
* @throws JSONException If the key is not found or if the value is not a number.
*/
public int getInt(final int index) throws JSONException {
final Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
@ -261,12 +239,10 @@ public class JSONArray {
/**
* Get the JSONArray associated with an index.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return A JSONArray value.
* @throws JSONException
* If there is no value for the index. or if the value is not a
* JSONArray
* @throws JSONException If there is no value for the index. or if the value is not a
* JSONArray
*/
public JSONArray getJSONArray(final int index) throws JSONException {
final Object object = this.get(index);
@ -279,12 +255,10 @@ public class JSONArray {
/**
* Get the JSONObject associated with an index.
*
* @param index
* subscript
* @param index subscript
* @return A JSONObject value.
* @throws JSONException
* If there is no value for the index or if the value is not a
* JSONObject
* @throws JSONException If there is no value for the index or if the value is not a
* JSONObject
*/
public JSONObject getJSONObject(final int index) throws JSONException {
final Object object = this.get(index);
@ -297,19 +271,16 @@ public class JSONArray {
/**
* Get the long value associated with an index.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException
* If the key is not found or if the value cannot be converted
* to a number.
* @throws JSONException If the key is not found or if the value cannot be converted
* to a number.
*/
public long getLong(final int index) throws JSONException {
final Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
@ -317,11 +288,9 @@ public class JSONArray {
/**
* Get the string associated with an index.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return A string value.
* @throws JSONException
* If there is no string value for the index.
* @throws JSONException If there is no string value for the index.
*/
public String getString(final int index) throws JSONException {
final Object object = this.get(index);
@ -334,8 +303,7 @@ public class JSONArray {
/**
* Determine if the value is null.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return true if the value at the index is null, or if there is no value.
*/
public boolean isNull(final int index) {
@ -347,11 +315,9 @@ public class JSONArray {
* <code>separator</code> string is inserted between each element. Warning:
* This method assumes that the data structure is acyclical.
*
* @param separator
* A string that will be inserted between the elements.
* @param separator A string that will be inserted between the elements.
* @return a string.
* @throws JSONException
* If the array contains an invalid number.
* @throws JSONException If the array contains an invalid number.
*/
public String join(final String separator) throws JSONException {
final int len = this.length();
@ -378,8 +344,7 @@ public class JSONArray {
/**
* Get the optional object value associated with an index.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return An object value, or null if there is no object at that index.
*/
public Object opt(final int index) {
@ -391,8 +356,7 @@ public class JSONArray {
* if there is no value at that index, or if the value is not Boolean.TRUE
* or the String "true".
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The truth.
*/
public boolean optBoolean(final int index) {
@ -404,17 +368,14 @@ public class JSONArray {
* defaultValue if there is no value at that index or if it is not a Boolean
* or the String "true" or "false" (case insensitive).
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* A boolean default.
* @param index The index must be between 0 and length() - 1.
* @param defaultValue A boolean default.
* @return The truth.
*/
public boolean optBoolean(final int index, final boolean defaultValue) {
try {
return this.getBoolean(index);
}
catch (final Exception e) {
} catch (final Exception e) {
return defaultValue;
}
}
@ -424,8 +385,7 @@ public class JSONArray {
* if there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The value.
*/
public double optDouble(final int index) {
@ -437,17 +397,14 @@ public class JSONArray {
* is returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number.
*
* @param index
* subscript
* @param defaultValue
* The default value.
* @param index subscript
* @param defaultValue The default value.
* @return The value.
*/
public double optDouble(final int index, final double defaultValue) {
try {
return this.getDouble(index);
}
catch (final Exception e) {
} catch (final Exception e) {
return defaultValue;
}
}
@ -457,8 +414,7 @@ public class JSONArray {
* there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The value.
*/
public int optInt(final int index) {
@ -470,17 +426,14 @@ public class JSONArray {
* returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number.
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @return The value.
*/
public int optInt(final int index, final int defaultValue) {
try {
return this.getInt(index);
}
catch (final Exception e) {
} catch (final Exception e) {
return defaultValue;
}
}
@ -488,10 +441,9 @@ public class JSONArray {
/**
* Get the optional JSONArray associated with an index.
*
* @param index
* subscript
* @param index subscript
* @return A JSONArray value, or null if the index has no value, or if the
* value is not a JSONArray.
* value is not a JSONArray.
*/
public JSONArray optJSONArray(final int index) {
final Object o = this.opt(index);
@ -503,8 +455,7 @@ public class JSONArray {
* the key is not found, or null if the index has no value, or if the value
* is not a JSONObject.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return A JSONObject value.
*/
public JSONObject optJSONObject(final int index) {
@ -517,8 +468,7 @@ public class JSONArray {
* there is no value for the index, or if the value is not a number and
* cannot be converted to a number.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return The value.
*/
public long optLong(final int index) {
@ -530,17 +480,14 @@ public class JSONArray {
* returned if there is no value for the index, or if the value is not a
* number and cannot be converted to a number.
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @return The value.
*/
public long optLong(final int index, final long defaultValue) {
try {
return this.getLong(index);
}
catch (final Exception e) {
} catch (final Exception e) {
return defaultValue;
}
}
@ -550,8 +497,7 @@ public class JSONArray {
* empty string if there is no value at that index. If the value is not a
* string and is not null, then it is coverted to a string.
*
* @param index
* The index must be between 0 and length() - 1.
* @param index The index must be between 0 and length() - 1.
* @return A String value.
*/
public String optString(final int index) {
@ -562,10 +508,8 @@ public class JSONArray {
* Get the optional string associated with an index. The defaultValue is
* returned if the key is not found.
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @return A String value.
*/
public String optString(final int index, final String defaultValue) {
@ -576,8 +520,7 @@ public class JSONArray {
/**
* Append a boolean value. This increases the array's length by one.
*
* @param value
* A boolean value.
* @param value A boolean value.
* @return this.
*/
public JSONArray put(final boolean value) {
@ -589,8 +532,7 @@ public class JSONArray {
* Put a value in the JSONArray, where the value will be a JSONArray which
* is produced from a Collection.
*
* @param value
* A Collection value.
* @param value A Collection value.
* @return this.
*/
public JSONArray put(final Collection<Object> value) {
@ -601,11 +543,9 @@ public class JSONArray {
/**
* Append a double value. This increases the array's length by one.
*
* @param value
* A double value.
* @throws JSONException
* if the value is not finite.
* @param value A double value.
* @return this.
* @throws JSONException if the value is not finite.
*/
public JSONArray put(final double value) throws JSONException {
final Double d = new Double(value);
@ -617,8 +557,7 @@ public class JSONArray {
/**
* Append an int value. This increases the array's length by one.
*
* @param value
* An int value.
* @param value An int value.
* @return this.
*/
public JSONArray put(final int value) {
@ -629,8 +568,7 @@ public class JSONArray {
/**
* Append an long value. This increases the array's length by one.
*
* @param value
* A long value.
* @param value A long value.
* @return this.
*/
public JSONArray put(final long value) {
@ -642,8 +580,7 @@ public class JSONArray {
* Put a value in the JSONArray, where the value will be a JSONObject which
* is produced from a Map.
*
* @param value
* A Map value.
* @param value A Map value.
* @return this.
*/
public JSONArray put(final Map<String, Object> value) {
@ -654,10 +591,9 @@ public class JSONArray {
/**
* Append an object value. This increases the array's length by one.
*
* @param value
* An object value. The value should be a Boolean, Double,
* Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object.
* @param value An object value. The value should be a Boolean, Double,
* Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object.
* @return this.
*/
public JSONArray put(final Object value) {
@ -670,13 +606,10 @@ public class JSONArray {
* than the length of the JSONArray, then null elements will be added as
* necessary to pad it out.
*
* @param index
* The subscript.
* @param value
* A boolean value.
* @param index The subscript.
* @param value A boolean value.
* @return this.
* @throws JSONException
* If the index is negative.
* @throws JSONException If the index is negative.
*/
public JSONArray put(final int index, final boolean value) throws JSONException {
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
@ -687,13 +620,10 @@ public class JSONArray {
* Put a value in the JSONArray, where the value will be a JSONArray which
* is produced from a Collection.
*
* @param index
* The subscript.
* @param value
* A Collection value.
* @param index The subscript.
* @param value A Collection value.
* @return this.
* @throws JSONException
* If the index is negative or if the value is not finite.
* @throws JSONException If the index is negative or if the value is not finite.
*/
public JSONArray put(final int index, final Collection<Object> value) throws JSONException {
this.put(index, new JSONArray(value));
@ -705,13 +635,10 @@ public class JSONArray {
* the JSONArray, then null elements will be added as necessary to pad it
* out.
*
* @param index
* The subscript.
* @param value
* A double value.
* @param index The subscript.
* @param value A double value.
* @return this.
* @throws JSONException
* If the index is negative or if the value is not finite.
* @throws JSONException If the index is negative or if the value is not finite.
*/
public JSONArray put(final int index, final double value) throws JSONException {
this.put(index, new Double(value));
@ -723,13 +650,10 @@ public class JSONArray {
* the JSONArray, then null elements will be added as necessary to pad it
* out.
*
* @param index
* The subscript.
* @param value
* An int value.
* @param index The subscript.
* @param value An int value.
* @return this.
* @throws JSONException
* If the index is negative.
* @throws JSONException If the index is negative.
*/
public JSONArray put(final int index, final int value) throws JSONException {
this.put(index, new Integer(value));
@ -741,13 +665,10 @@ public class JSONArray {
* the JSONArray, then null elements will be added as necessary to pad it
* out.
*
* @param index
* The subscript.
* @param value
* A long value.
* @param index The subscript.
* @param value A long value.
* @return this.
* @throws JSONException
* If the index is negative.
* @throws JSONException If the index is negative.
*/
public JSONArray put(final int index, final long value) throws JSONException {
this.put(index, new Long(value));
@ -758,14 +679,11 @@ public class JSONArray {
* Put a value in the JSONArray, where the value will be a JSONObject that
* is produced from a Map.
*
* @param index
* The subscript.
* @param value
* The Map value.
* @param index The subscript.
* @param value The Map value.
* @return this.
* @throws JSONException
* If the index is negative or if the the value is an invalid
* number.
* @throws JSONException If the index is negative or if the the value is an invalid
* number.
*/
public JSONArray put(final int index, final Map<String, Object> value) throws JSONException {
this.put(index, new JSONObject(value));
@ -777,16 +695,13 @@ public class JSONArray {
* than the length of the JSONArray, then null elements will be added as
* necessary to pad it out.
*
* @param index
* The subscript.
* @param value
* The value to put into the array. The value should be a
* Boolean, Double, Integer, JSONArray, JSONObject, Long, or
* String, or the JSONObject.NULL object.
* @param index The subscript.
* @param value The value to put into the array. The value should be a
* Boolean, Double, Integer, JSONArray, JSONObject, Long, or
* String, or the JSONObject.NULL object.
* @return this.
* @throws JSONException
* If the index is negative or if the the value is an invalid
* number.
* @throws JSONException If the index is negative or if the the value is an invalid
* number.
*/
public JSONArray put(final int index, final Object value) throws JSONException {
JSONObject.testValidity(value);
@ -795,8 +710,7 @@ public class JSONArray {
}
if (index < this.length()) {
this.myArrayList.set(index, value);
}
else {
} else {
while (index != this.length()) {
this.put(JSONObject.NULL);
}
@ -808,10 +722,9 @@ public class JSONArray {
/**
* Remove an index and close the hole.
*
* @param index
* The index of the element to be removed.
* @param index The index of the element to be removed.
* @return The value that was associated with the index, or null if there
* was no value.
* was no value.
*/
public Object remove(final int index) {
return (index >= 0) && (index < this.length()) ? this.myArrayList.remove(index) : null;
@ -821,8 +734,7 @@ public class JSONArray {
* Determine if two JSONArrays are similar.
* They must contain similar sequences.
*
* @param other
* The other JSONArray
* @param other The other JSONArray
* @return true if they are equal
*/
public boolean similar(final Object other) {
@ -840,13 +752,11 @@ public class JSONArray {
if (!((JSONObject) valueThis).similar(valueOther)) {
return false;
}
}
else if (valueThis instanceof JSONArray) {
} else if (valueThis instanceof JSONArray) {
if (!((JSONArray) valueThis).similar(valueOther)) {
return false;
}
}
else if (!valueThis.equals(valueOther)) {
} else if (!valueThis.equals(valueOther)) {
return false;
}
}
@ -857,13 +767,11 @@ public class JSONArray {
* Produce a JSONObject by combining a JSONArray of names with the values of
* this JSONArray.
*
* @param names
* A JSONArray containing a list of key strings. These will be
* paired with the values.
* @param names A JSONArray containing a list of key strings. These will be
* paired with the values.
* @return A JSONObject, or null if there are no names or if this JSONArray
* has no values.
* @throws JSONException
* If any of the names are null.
* has no values.
* @throws JSONException If any of the names are null.
*/
public JSONObject toJSONObject(final JSONArray names) throws JSONException {
if ((names == null) || (names.length() == 0) || (this.length() == 0)) {
@ -881,18 +789,17 @@ public class JSONArray {
* whitespace is added. If it is not possible to produce a syntactically
* correct JSON text then null will be returned instead. This could occur if
* the array contains an invalid number.
* <p>
* <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return a printable, displayable, transmittable representation of the
* array.
* array.
*/
@Override
public String toString() {
try {
return this.toString(0);
}
catch (final Exception e) {
} catch (final Exception e) {
return null;
}
}
@ -901,12 +808,11 @@ public class JSONArray {
* Make a prettyprinted JSON text of this JSONArray. Warning: This method
* assumes that the data structure is acyclical.
*
* @param indentFactor
* The number of spaces to add to each level of indentation.
* @param indentFactor The number of spaces to add to each level of indentation.
* @return a printable, displayable, transmittable representation of the
* object, beginning with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ending with <code>]</code>
* &nbsp;<small>(right bracket)</small>.
* object, beginning with <code>[</code>&nbsp;<small>(left
* bracket)</small> and ending with <code>]</code>
* &nbsp;<small>(right bracket)</small>.
* @throws JSONException
*/
public String toString(final int indentFactor) throws JSONException {
@ -919,7 +825,7 @@ public class JSONArray {
/**
* Write the contents of the JSONArray as JSON text to a writer. For
* compactness, no whitespace is added.
* <p>
* <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return The writer.
@ -932,13 +838,11 @@ public class JSONArray {
/**
* Write the contents of the JSONArray as JSON text to a writer. For
* compactness, no whitespace is added.
* <p>
* <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @param indentFactor
* The number of spaces to add to each level of indentation.
* @param indent
* The indention of the top level.
* @param indentFactor The number of spaces to add to each level of indentation.
* @param indent The indention of the top level.
* @return The writer.
* @throws JSONException
*/
@ -950,8 +854,7 @@ public class JSONArray {
if (length == 1) {
JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
}
else if (length != 0) {
} else if (length != 0) {
final int newindent = indent + indentFactor;
for (int i = 0; i < length; i += 1) {
@ -972,8 +875,7 @@ public class JSONArray {
}
writer.write(']');
return writer;
}
catch (final IOException e) {
} catch (final IOException e) {
throw new JSONException(e);
}
}

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/**
@ -8,13 +29,12 @@ package com.intellectualcrafters.json;
*/
public class JSONException extends RuntimeException {
private static final long serialVersionUID = 0;
private Throwable cause;
private Throwable cause;
/**
* Constructs a JSONException with an explanatory message.
*
* @param message
* Detail about the reason for the exception.
* @param message Detail about the reason for the exception.
*/
public JSONException(final String message) {
super(message);
@ -23,8 +43,7 @@ public class JSONException extends RuntimeException {
/**
* Constructs a new JSONException with the specified cause.
*
* @param cause
* The cause.
* @param cause The cause.
*/
public JSONException(final Throwable cause) {
super(cause.getMessage());
@ -36,7 +55,7 @@ public class JSONException extends RuntimeException {
* or unknown.
*
* @return the cause of this exception or null if the cause is nonexistent
* or unknown.
* or unknown.
*/
@Override
public Throwable getCause() {

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2008 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.util.Iterator;
/**
@ -39,13 +36,10 @@ public class JSONML {
/**
* Parse XML values and store them in a JSONArray.
*
* @param x
* The XMLTokener containing the source string.
* @param arrayForm
* true if array form, false if object form.
* @param ja
* The JSONArray that is containing the current tag or null
* if we are at the outermost level.
* @param x The XMLTokener containing the source string.
* @param arrayForm true if array form, false if object form.
* @param ja The JSONArray that is containing the current tag or null
* if we are at the outermost level.
* @return A JSONArray if the value is the outermost tag, otherwise null.
* @throws JSONException
*/
@ -85,8 +79,7 @@ public class JSONML {
throw x.syntaxError("Misshaped close tag");
}
return token;
}
else if (token == XML.BANG) {
} else if (token == XML.BANG) {
// <!
@ -94,53 +87,44 @@ public class JSONML {
if (c == '-') {
if (x.next() == '-') {
x.skipPast("-->");
}
else {
} else {
x.back();
}
}
else if (c == '[') {
} else if (c == '[') {
token = x.nextToken();
if (token.equals("CDATA") && (x.next() == '[')) {
if (ja != null) {
ja.put(x.nextCDATA());
}
}
else {
} else {
throw x.syntaxError("Expected 'CDATA['");
}
}
else {
} else {
i = 1;
do {
token = x.nextMeta();
if (token == null) {
throw x.syntaxError("Missing '>' after '<!'.");
}
else if (token == XML.LT) {
} else if (token == XML.LT) {
i += 1;
}
else if (token == XML.GT) {
} else if (token == XML.GT) {
i -= 1;
}
}
while (i > 0);
}
}
else if (token == XML.QUEST) {
} else if (token == XML.QUEST) {
// <?
x.skipPast("?>");
}
else {
} else {
throw x.syntaxError("Misshaped tag");
}
// Open tag <
}
else {
} else {
if (!(token instanceof String)) {
throw x.syntaxError("Bad tagName '" + token + "'.");
}
@ -152,15 +136,14 @@ public class JSONML {
if (ja != null) {
ja.put(newja);
}
}
else {
} else {
newjo.put("tagName", tagName);
if (ja != null) {
ja.put(newjo);
}
}
token = null;
for (;;) {
for (; ; ) {
if (token == null) {
token = x.nextToken();
}
@ -185,8 +168,7 @@ public class JSONML {
}
newjo.accumulate(attribute, XML.stringToValue((String) token));
token = null;
}
else {
} else {
newjo.accumulate(attribute, "");
}
}
@ -203,16 +185,14 @@ public class JSONML {
if (ja == null) {
if (arrayForm) {
return newja;
}
else {
} else {
return newjo;
}
}
// Content, between <...> and </...>
}
else {
} else {
if (token != XML.GT) {
throw x.syntaxError("Misshaped tag");
}
@ -228,16 +208,14 @@ public class JSONML {
if (ja == null) {
if (arrayForm) {
return newja;
}
else {
} else {
return newjo;
}
}
}
}
}
}
else {
} else {
if (ja != null) {
ja.put(token instanceof String ? XML.stringToValue((String) token) : token);
}
@ -254,8 +232,7 @@ public class JSONML {
* JSONArrays will represent the child tags.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
*
* @param string
* The source string.
* @param string The source string.
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException
*/
@ -272,8 +249,7 @@ public class JSONML {
* JSONArrays will represent the child content and tags.
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
*
* @param x
* An XMLTokener.
* @param x An XMLTokener.
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException
*/
@ -288,11 +264,10 @@ public class JSONML {
* the attributes will be in the JSONObject as properties. If the tag
* contains children, the object will have a "childNodes" property which
* will be an array of strings and JsonML JSONObjects.
*
* <p/>
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
*
* @param x
* An XMLTokener of the XML source text.
* @param x An XMLTokener of the XML source text.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException
*/
@ -307,11 +282,10 @@ public class JSONML {
* the attributes will be in the JSONObject as properties. If the tag
* contains children, the object will have a "childNodes" property which
* will be an array of strings and JsonML JSONObjects.
*
* <p/>
* Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
*
* @param string
* The XML source text.
* @param string The XML source text.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException
*/
@ -322,8 +296,7 @@ public class JSONML {
/**
* Reverse the JSONML transformation, making an XML text from a JSONArray.
*
* @param ja
* A JSONArray.
* @param ja A JSONArray.
* @return An XML string.
* @throws JSONException
*/
@ -367,8 +340,7 @@ public class JSONML {
sb.append('"');
}
}
}
else {
} else {
i = 1;
}
@ -378,8 +350,7 @@ public class JSONML {
if (i >= length) {
sb.append('/');
sb.append('>');
}
else {
} else {
sb.append('>');
do {
object = ja.get(i);
@ -387,11 +358,9 @@ public class JSONML {
if (object != null) {
if (object instanceof String) {
sb.append(XML.escape(object.toString()));
}
else if (object instanceof JSONObject) {
} else if (object instanceof JSONObject) {
sb.append(toString((JSONObject) object));
}
else if (object instanceof JSONArray) {
} else if (object instanceof JSONArray) {
sb.append(toString((JSONArray) object));
}
}
@ -411,8 +380,7 @@ public class JSONML {
* then it must have a "childNodes" property containing an array of objects.
* The other properties are attributes with string values.
*
* @param jo
* A JSONObject.
* @param jo A JSONObject.
* @return An XML string.
* @throws JSONException
*/
@ -463,8 +431,7 @@ public class JSONML {
if (ja == null) {
sb.append('/');
sb.append('>');
}
else {
} else {
sb.append('>');
length = ja.length();
for (i = 0; i < length; i += 1) {
@ -472,14 +439,11 @@ public class JSONML {
if (object != null) {
if (object instanceof String) {
sb.append(XML.escape(object.toString()));
}
else if (object instanceof JSONObject) {
} else if (object instanceof JSONObject) {
sb.append(toString((JSONObject) object));
}
else if (object instanceof JSONArray) {
} else if (object instanceof JSONArray) {
sb.append(toString((JSONArray) object));
}
else {
} else {
sb.append(object.toString());
}
}

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.io.StringWriter;
/**
@ -31,7 +28,7 @@ import java.io.StringWriter;
* The texts produced strictly conform to JSON syntax rules. No whitespace is
* added, so the results are ready for transmission or storage. Each instance of
* JSONStringer can produce one JSON text.
* <p>
* <p/>
* A JSONStringer instance provides a <code>value</code> method for appending
* values to the text, and a <code>key</code> method for adding keys before
* values in objects. There are <code>array</code> and <code>endArray</code>
@ -39,21 +36,21 @@ import java.io.StringWriter;
* <code>endObject</code> methods which make and bound object values. All of
* these methods return the JSONWriter instance, permitting cascade style. For
* example,
*
* <p/>
* <pre>
* myString = new JSONStringer().object().key(&quot;JSON&quot;).value(&quot;Hello, World!&quot;).endObject().toString();
* </pre>
*
* <p/>
* which produces the string
*
* <p/>
* <pre>
* {"JSON":"Hello, World!"}
* </pre>
* <p>
* <p/>
* The first method called must be <code>array</code> or <code>object</code>.
* There are no methods for adding commas or colons. JSONStringer adds them for
* you. Objects and arrays can be nested up to 20 levels deep.
* <p>
* <p/>
* This can sometimes be easier than using a JSONObject to build a string.
*
* @author JSON.org

View File

@ -1,35 +1,27 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.io.*;
/**
* A JSONTokener takes a source string and extracts characters and tokens from
@ -41,19 +33,18 @@ import java.io.StringReader;
*/
public class JSONTokener {
private long character;
private boolean eof;
private long index;
private long line;
private char previous;
private long character;
private boolean eof;
private long index;
private long line;
private char previous;
private final Reader reader;
private boolean usePrevious;
private boolean usePrevious;
/**
* Construct a JSONTokener from a Reader.
*
* @param reader
* A reader.
* @param reader A reader.
*/
public JSONTokener(final Reader reader) {
this.reader = reader.markSupported() ? reader : new BufferedReader(reader);
@ -68,8 +59,7 @@ public class JSONTokener {
/**
* Construct a JSONTokener from an InputStream.
*
* @param inputStream
* The source.
* @param inputStream The source.
*/
public JSONTokener(final InputStream inputStream) throws JSONException {
this(new InputStreamReader(inputStream));
@ -78,8 +68,7 @@ public class JSONTokener {
/**
* Construct a JSONTokener from a string.
*
* @param s
* A source string.
* @param s A source string.
*/
public JSONTokener(final String s) {
this(new StringReader(s));
@ -103,9 +92,8 @@ public class JSONTokener {
/**
* Get the hex value of a character (base16).
*
* @param c
* A character between '0' and '9' or between 'A' and 'F' or
* between 'a' and 'f'.
* @param c A character between '0' and '9' or between 'A' and 'F' or
* between 'a' and 'f'.
* @return An int between 0 and 15, or -1 if c was not a hex digit.
*/
public static int dehexchar(final char c) {
@ -150,12 +138,10 @@ public class JSONTokener {
if (this.usePrevious) {
this.usePrevious = false;
c = this.previous;
}
else {
} else {
try {
c = this.reader.read();
}
catch (final IOException exception) {
} catch (final IOException exception) {
throw new JSONException(exception);
}
@ -168,12 +154,10 @@ public class JSONTokener {
if (this.previous == '\r') {
this.line += 1;
this.character = c == '\n' ? 0 : 1;
}
else if (c == '\n') {
} else if (c == '\n') {
this.line += 1;
this.character = 0;
}
else {
} else {
this.character += 1;
}
this.previous = (char) c;
@ -184,11 +168,9 @@ public class JSONTokener {
* Consume the next character, and check that it matches a specified
* character.
*
* @param c
* The character to match.
* @param c The character to match.
* @return The character.
* @throws JSONException
* if the character does not match.
* @throws JSONException if the character does not match.
*/
public char next(final char c) throws JSONException {
final char n = this.next();
@ -201,12 +183,10 @@ public class JSONTokener {
/**
* Get the next n characters.
*
* @param n
* The number of characters to take.
* @param n The number of characters to take.
* @return A string of n characters.
* @throws JSONException
* Substring bounds error if there are not
* n characters remaining in the source string.
* @throws JSONException Substring bounds error if there are not
* n characters remaining in the source string.
*/
public String next(final int n) throws JSONException {
if (n == 0) {
@ -229,11 +209,11 @@ public class JSONTokener {
/**
* Get the next char in the string, skipping whitespace.
*
* @throws JSONException
* @return A character, or 0 if there are no more characters.
* @throws JSONException
*/
public char nextClean() throws JSONException {
for (;;) {
for (; ; ) {
final char c = this.next();
if ((c == 0) || (c > ' ')) {
return c;
@ -247,18 +227,16 @@ public class JSONTokener {
* allow strings in single quotes, but an implementation is allowed to
* accept them.
*
* @param quote
* The quoting character, either <code>"</code>
* &nbsp;<small>(double quote)</small> or <code>'</code>
* &nbsp;<small>(single quote)</small>.
* @param quote The quoting character, either <code>"</code>
* &nbsp;<small>(double quote)</small> or <code>'</code>
* &nbsp;<small>(single quote)</small>.
* @return A String.
* @throws JSONException
* Unterminated string.
* @throws JSONException Unterminated string.
*/
public String nextString(final char quote) throws JSONException {
char c;
final StringBuilder sb = new StringBuilder();
for (;;) {
for (; ; ) {
c = this.next();
switch (c) {
case 0:
@ -309,13 +287,12 @@ public class JSONTokener {
* Get the text up but not including the specified character or the
* end of line, whichever comes first.
*
* @param delimiter
* A delimiter character.
* @param delimiter A delimiter character.
* @return A string.
*/
public String nextTo(final char delimiter) throws JSONException {
final StringBuilder sb = new StringBuilder();
for (;;) {
for (; ; ) {
final char c = this.next();
if ((c == delimiter) || (c == 0) || (c == '\n') || (c == '\r')) {
if (c != 0) {
@ -331,14 +308,13 @@ public class JSONTokener {
* Get the text up but not including one of the specified delimiter
* characters or the end of line, whichever comes first.
*
* @param delimiters
* A set of delimiter characters.
* @param delimiters A set of delimiter characters.
* @return A string, trimmed.
*/
public String nextTo(final String delimiters) throws JSONException {
char c;
final StringBuilder sb = new StringBuilder();
for (;;) {
for (; ; ) {
c = this.next();
if ((delimiters.indexOf(c) >= 0) || (c == 0) || (c == '\n') || (c == '\r')) {
if (c != 0) {
@ -354,10 +330,8 @@ public class JSONTokener {
* Get the next value. The value can be a Boolean, Double, Integer,
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
*
* @throws JSONException
* If syntax error.
*
* @return An object.
* @throws JSONException If syntax error.
*/
public Object nextValue() throws JSONException {
char c = this.nextClean();
@ -401,10 +375,9 @@ public class JSONTokener {
* Skip characters until the next character is the requested character.
* If the requested character is not found, no characters are skipped.
*
* @param to
* A character to skip to.
* @param to A character to skip to.
* @return The requested character, or zero if the requested character
* is not found.
* is not found.
*/
public char skipTo(final char to) throws JSONException {
char c;
@ -424,8 +397,7 @@ public class JSONTokener {
}
}
while (c != to);
}
catch (final IOException exception) {
} catch (final IOException exception) {
throw new JSONException(exception);
}
this.back();
@ -435,8 +407,7 @@ public class JSONTokener {
/**
* Make a JSONException to signal a syntax error.
*
* @param message
* The error message.
* @param message The error message.
* @return A JSONException object, suitable for throwing
*/
public JSONException syntaxError(final String message) {

View File

@ -1,38 +1,35 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
import java.io.IOException;
import java.io.Writer;
/*
Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* JSONWriter provides a quick and convenient way of producing JSON text.
* The texts produced strictly conform to JSON syntax rules. No whitespace is
* added, so the results are ready for transmission or storage. Each instance of
* JSONWriter can produce one JSON text.
* <p>
* <p/>
* A JSONWriter instance provides a <code>value</code> method for appending
* values to the text, and a <code>key</code> method for adding keys before
* values in objects. There are <code>array</code> and <code>endArray</code>
@ -40,21 +37,21 @@ import java.io.Writer;
* <code>endObject</code> methods which make and bound object values. All of
* these methods return the JSONWriter instance, permitting a cascade style. For
* example,
*
* <p/>
* <pre>
* new JSONWriter(myWriter).object().key(&quot;JSON&quot;).value(&quot;Hello, World!&quot;).endObject();
* </pre>
*
* <p/>
* which writes
*
* <p/>
* <pre>
* {"JSON":"Hello, World!"}
* </pre>
* <p>
* <p/>
* The first method called must be <code>array</code> or <code>object</code>.
* There are no methods for adding commas or colons. JSONWriter adds them for
* you. Objects and arrays can be nested up to 20 levels deep.
* <p>
* <p/>
* This can sometimes be easier than using a JSONObject to build a string.
*
* @author JSON.org
@ -67,7 +64,7 @@ public class JSONWriter {
* The comma flag determines if a comma should be output before the next
* value.
*/
private boolean comma;
private boolean comma;
/**
* The current mode. Values:
@ -77,7 +74,7 @@ public class JSONWriter {
* 'k' (key),
* 'o' (object).
*/
protected char mode;
protected char mode;
/**
* The object/array stack.
@ -87,12 +84,12 @@ public class JSONWriter {
/**
* The stack top index. A value of 0 indicates that the stack is empty.
*/
private int top;
private int top;
/**
* The writer that will receive the output.
*/
protected Writer writer;
protected Writer writer;
/**
* Make a fresh JSONWriter. It can be used to build one JSON text.
@ -108,11 +105,9 @@ public class JSONWriter {
/**
* Append a value.
*
* @param string
* A string value.
* @param string A string value.
* @return this
* @throws JSONException
* If the value is out of sequence.
* @throws JSONException If the value is out of sequence.
*/
private JSONWriter append(final String string) throws JSONException {
if (string == null) {
@ -124,8 +119,7 @@ public class JSONWriter {
this.writer.write(',');
}
this.writer.write(string);
}
catch (final IOException e) {
} catch (final IOException e) {
throw new JSONException(e);
}
if (this.mode == 'o') {
@ -143,11 +137,10 @@ public class JSONWriter {
* <code>endArray</code> method must be called to mark the array's end.
*
* @return this
* @throws JSONException
* If the nesting is too deep, or if the object is
* started in the wrong place (for example as a key or after the
* end of the
* outermost array or object).
* @throws JSONException If the nesting is too deep, or if the object is
* started in the wrong place (for example as a key or after the
* end of the
* outermost array or object).
*/
public JSONWriter array() throws JSONException {
if ((this.mode == 'i') || (this.mode == 'o') || (this.mode == 'a')) {
@ -162,13 +155,10 @@ public class JSONWriter {
/**
* End something.
*
* @param mode
* Mode
* @param c
* Closing character
* @param mode Mode
* @param c Closing character
* @return this
* @throws JSONException
* If unbalanced.
* @throws JSONException If unbalanced.
*/
private JSONWriter end(final char mode, final char c) throws JSONException {
if (this.mode != mode) {
@ -177,8 +167,7 @@ public class JSONWriter {
this.pop(mode);
try {
this.writer.write(c);
}
catch (final IOException e) {
} catch (final IOException e) {
throw new JSONException(e);
}
this.comma = true;
@ -190,8 +179,7 @@ public class JSONWriter {
* <code>array</code>.
*
* @return this
* @throws JSONException
* If incorrectly nested.
* @throws JSONException If incorrectly nested.
*/
public JSONWriter endArray() throws JSONException {
return this.end('a', ']');
@ -202,8 +190,7 @@ public class JSONWriter {
* <code>object</code>.
*
* @return this
* @throws JSONException
* If incorrectly nested.
* @throws JSONException If incorrectly nested.
*/
public JSONWriter endObject() throws JSONException {
return this.end('k', '}');
@ -213,12 +200,10 @@ public class JSONWriter {
* Append a key. The key will be associated with the next value. In an
* object, every value must be preceded by a key.
*
* @param string
* A key string.
* @param string A key string.
* @return this
* @throws JSONException
* If the key is out of place. For example, keys
* do not belong in arrays or if the key is null.
* @throws JSONException If the key is out of place. For example, keys
* do not belong in arrays or if the key is null.
*/
public JSONWriter key(final String string) throws JSONException {
if (string == null) {
@ -235,8 +220,7 @@ public class JSONWriter {
this.comma = false;
this.mode = 'o';
return this;
}
catch (final IOException e) {
} catch (final IOException e) {
throw new JSONException(e);
}
}
@ -249,11 +233,10 @@ public class JSONWriter {
* <code>endObject</code> method must be called to mark the object's end.
*
* @return this
* @throws JSONException
* If the nesting is too deep, or if the object is
* started in the wrong place (for example as a key or after the
* end of the
* outermost array or object).
* @throws JSONException If the nesting is too deep, or if the object is
* started in the wrong place (for example as a key or after the
* end of the
* outermost array or object).
*/
public JSONWriter object() throws JSONException {
if (this.mode == 'i') {
@ -272,10 +255,8 @@ public class JSONWriter {
/**
* Pop an array or object scope.
*
* @param c
* The scope to close.
* @throws JSONException
* If nesting is wrong.
* @param c The scope to close.
* @throws JSONException If nesting is wrong.
*/
private void pop(final char c) throws JSONException {
if (this.top <= 0) {
@ -292,10 +273,8 @@ public class JSONWriter {
/**
* Push an array or object scope.
*
* @param jo
* The scope to open.
* @throws JSONException
* If nesting is too deep.
* @param jo The scope to open.
* @throws JSONException If nesting is too deep.
*/
private void push(final JSONObject jo) throws JSONException {
if (this.top >= maxdepth) {
@ -310,8 +289,7 @@ public class JSONWriter {
* Append either the value <code>true</code> or the value <code>false</code>
* .
*
* @param b
* A boolean.
* @param b A boolean.
* @return this
* @throws JSONException
*/
@ -322,11 +300,9 @@ public class JSONWriter {
/**
* Append a double value.
*
* @param d
* A double.
* @param d A double.
* @return this
* @throws JSONException
* If the number is not finite.
* @throws JSONException If the number is not finite.
*/
public JSONWriter value(final double d) throws JSONException {
return this.value(new Double(d));
@ -335,8 +311,7 @@ public class JSONWriter {
/**
* Append a long value.
*
* @param l
* A long.
* @param l A long.
* @return this
* @throws JSONException
*/
@ -347,13 +322,11 @@ public class JSONWriter {
/**
* Append an object value.
*
* @param object
* The object to append. It can be null, or a Boolean, Number,
* String, JSONObject, or JSONArray, or an object that implements
* JSONString.
* @param object The object to append. It can be null, or a Boolean, Number,
* String, JSONObject, or JSONArray, or an object that implements
* JSONString.
* @return this
* @throws JSONException
* If the value is out of sequence.
* @throws JSONException If the value is out of sequence.
*/
public JSONWriter value(final Object object) throws JSONException {
return this.append(JSONObject.valueToString(object));

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2013 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Kim makes immutable eight bit Unicode strings. If the MSB of a byte is set,
* then the next byte is a continuation byte. The last byte of a character
@ -31,16 +28,16 @@ package com.intellectualcrafters.json;
* set. Kim stands for "Keep it minimal". A Unicode character is never longer
* than 3 bytes. Every byte contributes 7 bits to the character. ASCII is
* unmodified.
*
* <p/>
* Kim UTF-8
* one byte U+007F U+007F
* two bytes U+3FFF U+07FF
* three bytes U+10FFF U+FFFF
* four bytes U+10FFFF
*
* <p/>
* Characters in the ranges U+0800..U+3FFF and U+10000..U+10FFFF will be one
* byte smaller when encoded in Kim compared to UTF-8.
*
* <p/>
* Kim is beneficial when using scripts such as Old South Arabian, Aramaic,
* Avestan, Balinese, Batak, Bopomofo, Buginese, Buhid, Carian, Cherokee,
* Coptic, Cyrillic, Deseret, Egyptian Hieroglyphs, Ethiopic, Georgian,
@ -50,10 +47,10 @@ package com.intellectualcrafters.json;
* Ol Chiki, Old Turkic, Oriya, Osmanya, Pahlavi, Parthian, Phags-Pa,
* Phoenician, Samaritan, Sharada, Sinhala, Sora Sompeng, Tagalog, Tagbanwa,
* Takri, Tai Le, Tai Tham, Tamil, Telugu, Thai, Tibetan, Tifinagh, UCAS.
*
* <p/>
* A kim object can be constructed from an ordinary UTF-16 string, or from a
* byte array. A kim object can produce a UTF-16 string.
*
* <p/>
* As with UTF-8, it is possible to detect character boundaries within a byte
* sequence. UTF-8 is one of the world's great inventions. While Kim is more
* efficient, it is not clear that it is worth the expense of transition.
@ -65,33 +62,30 @@ public class Kim {
/**
* The byte array containing the kim's content.
*/
private byte[] bytes = null;
private byte[] bytes = null;
/**
* The kim's hashcode, conforming to Java's hashcode conventions.
*/
private int hashcode = 0;
private int hashcode = 0;
/**
* The number of bytes in the kim. The number of bytes can be as much as
* three times the number of characters.
*/
public int length = 0;
public int length = 0;
/**
* The memoization of toString().
*/
private String string = null;
private String string = null;
/**
* Make a kim from a portion of a byte array.
*
* @param bytes
* A byte array.
* @param from
* The index of the first byte.
* @param thru
* The index of the last byte plus one.
* @param bytes A byte array.
* @param from The index of the first byte.
* @param thru The index of the last byte plus one.
*/
public Kim(final byte[] bytes, final int from, final int thru) {
@ -118,10 +112,8 @@ public class Kim {
/**
* Make a kim from a byte array.
*
* @param bytes
* The byte array.
* @param length
* The number of bytes.
* @param bytes The byte array.
* @param length The number of bytes.
*/
public Kim(final byte[] bytes, final int length) {
this(bytes, 0, length);
@ -131,12 +123,9 @@ public class Kim {
* Make a new kim from a substring of an existing kim. The coordinates are
* in byte units, not character units.
*
* @param kim
* The source of bytes.
* @param from
* The point at which to take bytes.
* @param thru
* The point at which to stop taking bytes.
* @param kim The source of bytes.
* @param from The point at which to take bytes.
* @param thru The point at which to stop taking bytes.
*/
public Kim(final Kim kim, final int from, final int thru) {
this(kim.bytes, from, thru);
@ -145,10 +134,8 @@ public class Kim {
/**
* Make a kim from a string.
*
* @param string
* The string.
* @throws JSONException
* if surrogate pair mismatch.
* @param string The string.
* @throws JSONException if surrogate pair mismatch.
*/
public Kim(final String string) throws JSONException {
final int stringLength = string.length();
@ -163,11 +150,9 @@ public class Kim {
final int c = string.charAt(i);
if (c <= 0x7F) {
this.length += 1;
}
else if (c <= 0x3FFF) {
} else if (c <= 0x3FFF) {
this.length += 2;
}
else {
} else {
if ((c >= 0xD800) && (c <= 0xDFFF)) {
i += 1;
final int d = string.charAt(i);
@ -194,8 +179,7 @@ public class Kim {
sum += character;
this.hashcode += sum;
at += 1;
}
else if (character <= 0x3FFF) {
} else if (character <= 0x3FFF) {
b = 0x80 | (character >>> 7);
this.bytes[at] = (byte) b;
sum += b;
@ -206,8 +190,7 @@ public class Kim {
sum += b;
this.hashcode += sum;
at += 1;
}
else {
} else {
if ((character >= 0xD800) && (character <= 0xDBFF)) {
i += 1;
character = (((character & 0x3FF) << 10) | (string.charAt(i) & 0x3FF)) + 65536;
@ -238,11 +221,9 @@ public class Kim {
* values and ranges from 0 to length - 1. The index of the next character
* is at index + Kim.characterSize(kim.characterAt(index)).
*
* @param at
* the index of the char value. The first character is at 0.
* @param at the index of the char value. The first character is at 0.
* @throws JSONException if at does not point to a valid character.
* @returns a Unicode character between 0 and 0x10FFFF.
* @throws JSONException
* if at does not point to a valid character.
*/
public int characterAt(final int at) throws JSONException {
final int c = get(at);
@ -256,8 +237,7 @@ public class Kim {
if (character > 0x7F) {
return character;
}
}
else {
} else {
final int c2 = get(at + 2);
character = ((c & 0x7F) << 14) | ((c1 & 0x7F) << 7) | c2;
if (((c2 & 0x80) == 0) && (character > 0x3FFF) && (character <= 0x10FFFF) && ((character < 0xD800) || (character > 0xDFFF))) {
@ -271,11 +251,9 @@ public class Kim {
* Returns the number of bytes needed to contain the character in Kim
* format.
*
* @param character
* a Unicode character between 0 and 0x10FFFF.
* @param character a Unicode character between 0 and 0x10FFFF.
* @return 1, 2, or 3
* @throws JSONException
* if the character is not representable in a kim.
* @throws JSONException if the character is not representable in a kim.
*/
public static int characterSize(final int character) throws JSONException {
if ((character < 0) || (character > 0x10FFFF)) {
@ -287,10 +265,8 @@ public class Kim {
/**
* Copy the contents of this kim to a byte array.
*
* @param bytes
* A byte array of sufficient size.
* @param at
* The position within the byte array to take the byes.
* @param bytes A byte array of sufficient size.
* @param at The position within the byte array to take the byes.
* @return The position immediately after the copy.
*/
public int copy(final byte[] bytes, final int at) {
@ -302,10 +278,9 @@ public class Kim {
* Two kim objects containing exactly the same bytes in the same order are
* equal to each other.
*
* @param obj
* the other kim with which to compare.
* @param obj the other kim with which to compare.
* @returns true if this and obj are both kim objects containing identical
* byte sequences.
* byte sequences.
*/
@Override
public boolean equals(final Object obj) {
@ -325,11 +300,9 @@ public class Kim {
/**
* Get a byte from a kim.
*
* @param at
* The position of the byte. The first byte is at 0.
* @param at The position of the byte. The first byte is at 0.
* @return The byte.
* @throws JSONException
* if there is no byte at that position.
* @throws JSONException if there is no byte at that position.
*/
public int get(final int at) throws JSONException {
if ((at < 0) || (at > this.length)) {
@ -352,8 +325,7 @@ public class Kim {
* it could be less.
*
* @return The string. A kim memoizes its string representation.
* @throws JSONException
* if the kim is not valid.
* @throws JSONException if the kim is not valid.
*/
@Override
public String toString() throws JSONException {
@ -366,8 +338,7 @@ public class Kim {
if (c < 0x10000) {
chars[length] = (char) c;
length += 1;
}
else {
} else {
chars[length] = (char) (0xD800 | ((c - 0x10000) >>> 10));
length += 1;
chars[length] = (char) (0xDC00 | (c & 0x03FF));

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
@ -39,8 +36,7 @@ public class Property {
* Converts a property file object into a JSONObject. The property file
* object is a table of name value pairs.
*
* @param properties
* java.util.Properties
* @param properties java.util.Properties
* @return JSONObject
* @throws JSONException
*/
@ -59,8 +55,7 @@ public class Property {
/**
* Converts the JSONObject into a property file object.
*
* @param jo
* JSONObject
* @param jo JSONObject
* @return java.util.Properties
* @throws JSONException
*/

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import java.util.Iterator;
/**
@ -35,36 +32,54 @@ import java.util.Iterator;
*/
public class XML {
/** The Character '&amp;'. */
public static final Character AMP = '&';
/**
* The Character '&amp;'.
*/
public static final Character AMP = '&';
/** The Character '''. */
public static final Character APOS = '\'';
/**
* The Character '''.
*/
public static final Character APOS = '\'';
/** The Character '!'. */
public static final Character BANG = '!';
/**
* The Character '!'.
*/
public static final Character BANG = '!';
/** The Character '='. */
public static final Character EQ = '=';
/**
* The Character '='.
*/
public static final Character EQ = '=';
/** The Character '>'. */
public static final Character GT = '>';
/**
* The Character '>'.
*/
public static final Character GT = '>';
/** The Character '&lt;'. */
public static final Character LT = '<';
/**
* The Character '&lt;'.
*/
public static final Character LT = '<';
/** The Character '?'. */
/**
* The Character '?'.
*/
public static final Character QUEST = '?';
/** The Character '"'. */
public static final Character QUOT = '"';
/**
* The Character '"'.
*/
public static final Character QUOT = '"';
/** The Character '/'. */
/**
* The Character '/'.
*/
public static final Character SLASH = '/';
/**
* Replace special characters with XML escapes:
*
* <p/>
* <pre>
* &amp; <small>(ampersand)</small> is replaced by &amp;amp;
* &lt; <small>(less than)</small> is replaced by &amp;lt;
@ -72,8 +87,7 @@ public class XML {
* &quot; <small>(double quote)</small> is replaced by &amp;quot;
* </pre>
*
* @param string
* The string to be escaped.
* @param string The string to be escaped.
* @return The escaped string.
*/
public static String escape(final String string) {
@ -107,8 +121,7 @@ public class XML {
* Throw an exception if the string contains whitespace.
* Whitespace is not allowed in tagNames and attributes.
*
* @param string
* A string.
* @param string A string.
* @throws JSONException
*/
public static void noSpace(final String string) throws JSONException {
@ -127,12 +140,9 @@ public class XML {
/**
* Scan the content following the named tag, attaching it to the context.
*
* @param x
* The XMLTokener containing the source string.
* @param context
* The JSONObject that will include the new material.
* @param name
* The tag name.
* @param x The XMLTokener containing the source string.
* @param context The JSONObject that will include the new material.
* @param name The tag name.
* @return true if the close tag is processed.
* @throws JSONException
*/
@ -166,8 +176,7 @@ public class XML {
return false;
}
x.back();
}
else if (c == '[') {
} else if (c == '[') {
token = x.nextToken();
if ("CDATA".equals(token)) {
if (x.next() == '[') {
@ -185,25 +194,21 @@ public class XML {
token = x.nextMeta();
if (token == null) {
throw x.syntaxError("Missing '>' after '<!'.");
}
else if (token == LT) {
} else if (token == LT) {
i += 1;
}
else if (token == GT) {
} else if (token == GT) {
i -= 1;
}
}
while (i > 0);
return false;
}
else if (token == QUEST) {
} else if (token == QUEST) {
// <?
x.skipPast("?>");
return false;
}
else if (token == SLASH) {
} else if (token == SLASH) {
// Close tag </
@ -219,18 +224,16 @@ public class XML {
}
return true;
}
else if (token instanceof Character) {
} else if (token instanceof Character) {
throw x.syntaxError("Misshaped tag");
// Open tag <
}
else {
} else {
tagName = (String) token;
token = null;
jsonobject = new JSONObject();
for (;;) {
for (; ; ) {
if (token == null) {
token = x.nextToken();
}
@ -247,39 +250,34 @@ public class XML {
}
jsonobject.accumulate(string, XML.stringToValue((String) token));
token = null;
}
else {
} else {
jsonobject.accumulate(string, "");
}
// Empty tag <.../>
}
else if (token == SLASH) {
} else if (token == SLASH) {
if (x.nextToken() != GT) {
throw x.syntaxError("Misshaped tag");
}
if (jsonobject.length() > 0) {
context.accumulate(tagName, jsonobject);
}
else {
} else {
context.accumulate(tagName, "");
}
return false;
// Content, between <...> and </...>
}
else if (token == GT) {
for (;;) {
} else if (token == GT) {
for (; ; ) {
token = x.nextContent();
if (token == null) {
if (tagName != null) {
throw x.syntaxError("Unclosed tag " + tagName);
}
return false;
}
else if (token instanceof String) {
} else if (token instanceof String) {
string = (String) token;
if (string.length() > 0) {
jsonobject.accumulate("content", XML.stringToValue(string));
@ -287,24 +285,20 @@ public class XML {
// Nested element
}
else if (token == LT) {
} else if (token == LT) {
if (parse(x, jsonobject, tagName)) {
if (jsonobject.length() == 0) {
context.accumulate(tagName, "");
}
else if ((jsonobject.length() == 1) && (jsonobject.opt("content") != null)) {
} else if ((jsonobject.length() == 1) && (jsonobject.opt("content") != null)) {
context.accumulate(tagName, jsonobject.opt("content"));
}
else {
} else {
context.accumulate(tagName, jsonobject);
}
return false;
}
}
}
}
else {
} else {
throw x.syntaxError("Misshaped tag");
}
}
@ -318,8 +312,7 @@ public class XML {
* convert plus forms, octal forms, hex forms, or E forms lacking decimal
* points.
*
* @param string
* A String.
* @param string A String.
* @return A simple JSON value.
*/
public static Object stringToValue(final String string) {
@ -345,15 +338,13 @@ public class XML {
return value;
}
}
}
catch (final Exception ignore) {
} catch (final Exception ignore) {
try {
final Double value = new Double(string);
if (value.toString().equals(string)) {
return value;
}
}
catch (final Exception ignoreAlso) {
} catch (final Exception ignoreAlso) {
}
}
return string;
@ -370,8 +361,7 @@ public class XML {
* text may be placed in a "content" member. Comments, prologs, DTDs, and
* <code>&lt;[ [ ]]></code> are ignored.
*
* @param string
* The source string.
* @param string The source string.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException
*/
@ -387,8 +377,7 @@ public class XML {
/**
* Convert a JSONObject into a well-formed, element-normal XML string.
*
* @param object
* A JSONObject.
* @param object A JSONObject.
* @return A string.
* @throws JSONException
*/
@ -399,10 +388,8 @@ public class XML {
/**
* Convert a JSONObject into a well-formed, element-normal XML string.
*
* @param object
* A JSONObject.
* @param tagName
* The optional name of the enclosing tag.
* @param object A JSONObject.
* @param tagName The optional name of the enclosing tag.
* @return A string.
* @throws JSONException
*/
@ -450,15 +437,13 @@ public class XML {
}
sb.append(escape(ja.get(i).toString()));
}
}
else {
} else {
sb.append(escape(value.toString()));
}
// Emit an array of similar keys
}
else if (value instanceof JSONArray) {
} else if (value instanceof JSONArray) {
ja = (JSONArray) value;
length = ja.length();
for (i = 0; i < length; i += 1) {
@ -471,21 +456,18 @@ public class XML {
sb.append("</");
sb.append(key);
sb.append('>');
}
else {
} else {
sb.append(toString(value, key));
}
}
}
else if ("".equals(value)) {
} else if ("".equals(value)) {
sb.append('<');
sb.append(key);
sb.append("/>");
// Emit a new tag <k>
}
else {
} else {
sb.append(toString(value, key));
}
}
@ -503,8 +485,7 @@ public class XML {
// a place
// where XML is lacking, synthesize an <array> element.
}
else {
} else {
if (object.getClass().isArray()) {
object = new JSONArray(object);
}
@ -515,8 +496,7 @@ public class XML {
sb.append(toString(ja.opt(i), tagName == null ? "array" : tagName));
}
return sb.toString();
}
else {
} else {
string = (object == null) ? "null" : escape(object.toString());
return (tagName == null) ? "\"" + string + "\"" : (string.length() == 0) ? "<" + tagName + "/>" : "<" + tagName + ">" + string + "</" + tagName + ">";
}

View File

@ -1,29 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* The XMLTokener extends the JSONTokener to provide additional methods
* for the parsing of XML texts.
@ -51,8 +48,7 @@ public class XMLTokener extends JSONTokener {
/**
* Construct an XMLTokener from a string.
*
* @param s
* A source string.
* @param s A source string.
*/
public XMLTokener(final String s) {
super(s);
@ -62,14 +58,13 @@ public class XMLTokener extends JSONTokener {
* Get the text in the CDATA block.
*
* @return The string up to the <code>]]&gt;</code>.
* @throws JSONException
* If the <code>]]&gt;</code> is not found.
* @throws JSONException If the <code>]]&gt;</code> is not found.
*/
public String nextCDATA() throws JSONException {
char c;
int i;
final StringBuilder sb = new StringBuilder();
for (;;) {
for (; ; ) {
c = next();
if (end()) {
throw syntaxError("Unclosed CDATA");
@ -88,7 +83,7 @@ public class XMLTokener extends JSONTokener {
* of tokens: the '<' character which begins a markup tag, and the content
* text between markup tags.
*
* @return A string, or a '<' Character, or null if there is no more
* @return A string, or a '<' Character, or null if there is no more
* source text.
* @throws JSONException
*/
@ -106,15 +101,14 @@ public class XMLTokener extends JSONTokener {
return XML.LT;
}
sb = new StringBuilder();
for (;;) {
for (; ; ) {
if ((c == '<') || (c == 0)) {
back();
return sb.toString().trim();
}
if (c == '&') {
sb.append(nextEntity(c));
}
else {
} else {
sb.append(c);
}
c = next();
@ -125,23 +119,19 @@ public class XMLTokener extends JSONTokener {
* Return the next entity. These entities are translated to Characters:
* <code>&amp; &apos; &gt; &lt; &quot;</code>.
*
* @param ampersand
* An ampersand character.
* @param ampersand An ampersand character.
* @return A Character or an entity String if the entity is not recognized.
* @throws JSONException
* If missing ';' in XML entity.
* @throws JSONException If missing ';' in XML entity.
*/
public Object nextEntity(final char ampersand) throws JSONException {
final StringBuilder sb = new StringBuilder();
for (;;) {
for (; ; ) {
final char c = next();
if (Character.isLetterOrDigit(c) || (c == '#')) {
sb.append(Character.toLowerCase(c));
}
else if (c == ';') {
} else if (c == ';') {
break;
}
else {
} else {
throw syntaxError("Missing ';' in XML entity: &" + sb);
}
}
@ -155,12 +145,11 @@ public class XMLTokener extends JSONTokener {
* and <?...?> structures.
*
* @return Syntax characters (<code>< > / = ! ?</code>) are returned as
* Character, and strings and names are returned as Boolean. We
* don't care
* what the values actually are.
* @throws JSONException
* If a string is not properly closed or if the XML
* is badly structured.
* Character, and strings and names are returned as Boolean. We
* don't care
* what the values actually are.
* @throws JSONException If a string is not properly closed or if the XML
* is badly structured.
*/
public Object nextMeta() throws JSONException {
char c;
@ -187,7 +176,7 @@ public class XMLTokener extends JSONTokener {
case '"':
case '\'':
q = c;
for (;;) {
for (; ; ) {
c = next();
if (c == 0) {
throw syntaxError("Unterminated string");
@ -197,7 +186,7 @@ public class XMLTokener extends JSONTokener {
}
}
default:
for (;;) {
for (; ; ) {
c = next();
if (Character.isWhitespace(c)) {
return Boolean.TRUE;
@ -226,8 +215,7 @@ public class XMLTokener extends JSONTokener {
* name.
*
* @return a String or a Character.
* @throws JSONException
* If the XML is not well formed.
* @throws JSONException If the XML is not well formed.
*/
public Object nextToken() throws JSONException {
char c;
@ -253,13 +241,13 @@ public class XMLTokener extends JSONTokener {
case '?':
return XML.QUEST;
// Quoted string
// Quoted string
case '"':
case '\'':
q = c;
sb = new StringBuilder();
for (;;) {
for (; ; ) {
c = next();
if (c == 0) {
throw syntaxError("Unterminated string");
@ -269,8 +257,7 @@ public class XMLTokener extends JSONTokener {
}
if (c == '&') {
sb.append(nextEntity(c));
}
else {
} else {
sb.append(c);
}
}
@ -279,7 +266,7 @@ public class XMLTokener extends JSONTokener {
// Name
sb = new StringBuilder();
for (;;) {
for (; ; ) {
sb.append(c);
c = next();
if (Character.isWhitespace(c)) {
@ -311,8 +298,7 @@ public class XMLTokener extends JSONTokener {
* If it is not found, we are left at the end of the source with a result of
* false.
*
* @param to
* A string to skip past.
* @param to A string to skip past.
* @throws JSONException
*/
public boolean skipPast(final String to) throws JSONException {
@ -339,7 +325,7 @@ public class XMLTokener extends JSONTokener {
/* We will loop, possibly for all of the remaining characters. */
for (;;) {
for (; ; ) {
j = offset;
b = true;

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import org.apache.commons.lang.StringUtils;
@ -12,8 +33,7 @@ public class AbstractFlag {
/**
* AbstractFlag is a parameter used in creating a new Flag
*
* @param key
* The key must be alphabetical characters and <= 16 characters
* @param key The key must be alphabetical characters and <= 16 characters
* in length
*/
public AbstractFlag(final String key) {

View File

@ -1,11 +1,32 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
public class BlockWrapper {
public int x;
public int y;
public int z;
public int id;
public int x;
public int y;
public int z;
public int id;
public byte data;
public BlockWrapper(final int x, final int y, final int z, final short id, final byte data) {

View File

@ -1,10 +1,23 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = C.java >> Generated by: Citymonstret at 2014-08-09 01:43
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
@ -360,15 +373,13 @@ public enum C {
/**
* Constructor
*
* @param d
* default
* @param d default
*/
C(final String d) {
this.d = d;
if (PlotMain.translations == null) {
this.s = d;
}
else {
} else {
this.s = PlotMain.translations.getString(this.toString());
}
if (this.s == null) {

View File

@ -1,12 +1,33 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import org.bukkit.block.Biome;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.Biome;
public class Configuration {
public static final SettingValue STRING = new SettingValue("STRING") {
public static final SettingValue STRING = new SettingValue("STRING") {
@Override
public boolean validateValue(final String string) {
return true;
@ -30,14 +51,13 @@ public class Configuration {
}
};
public static final SettingValue INTEGER = new SettingValue("INTEGER") {
public static final SettingValue INTEGER = new SettingValue("INTEGER") {
@Override
public boolean validateValue(final String string) {
try {
Integer.parseInt(string);
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}
@ -48,14 +68,13 @@ public class Configuration {
}
};
public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") {
public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") {
@Override
public boolean validateValue(final String string) {
try {
Boolean.parseBoolean(string);
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}
@ -66,14 +85,13 @@ public class Configuration {
}
};
public static final SettingValue DOUBLE = new SettingValue("DOUBLE") {
public static final SettingValue DOUBLE = new SettingValue("DOUBLE") {
@Override
public boolean validateValue(final String string) {
try {
Double.parseDouble(string);
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}
@ -84,14 +102,13 @@ public class Configuration {
}
};
public static final SettingValue BIOME = new SettingValue("BIOME") {
public static final SettingValue BIOME = new SettingValue("BIOME") {
@Override
public boolean validateValue(final String string) {
try {
Biome.valueOf(string.toUpperCase());
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}
@ -112,7 +129,7 @@ public class Configuration {
}
};
public static final SettingValue BLOCK = new SettingValue("BLOCK") {
public static final SettingValue BLOCK = new SettingValue("BLOCK") {
@Override
public boolean validateValue(final String string) {
try {
@ -120,13 +137,11 @@ public class Configuration {
final String[] split = string.split(":");
Short.parseShort(split[0]);
Short.parseShort(split[1]);
}
else {
} else {
Short.parseShort(string);
}
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}
@ -136,8 +151,7 @@ public class Configuration {
if (string.contains(":")) {
final String[] split = string.split(":");
return new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
}
else {
} else {
return new PlotBlock(Short.parseShort(string), (byte) 0);
}
}
@ -177,14 +191,12 @@ public class Configuration {
final String[] split = block.split(":");
Short.parseShort(split[0]);
Short.parseShort(split[1]);
}
else {
} else {
Short.parseShort(block);
}
}
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}
@ -206,8 +218,7 @@ public class Configuration {
if (value < min) {
min = value;
}
}
else {
} else {
counts[i] = 1;
if (1 < min) {
min = 1;
@ -216,8 +227,7 @@ public class Configuration {
if (blocks[i].contains(":")) {
final String[] split = blocks[i].split(":");
values[i] = new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
}
else {
} else {
values[i] = new PlotBlock(Short.parseShort(blocks[i]), (byte) 0);
}
}

View File

@ -1,16 +1,36 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.Configuration.SettingValue;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays;
import org.apache.commons.lang.StringUtils;
import com.intellectualcrafters.plot.Configuration.SettingValue;
public class ConfigurationNode {
private final String constant;
private final Object default_value;
private final String description;
private Object value;
private final String constant;
private final Object default_value;
private final String description;
private Object value;
private final SettingValue type;
public ConfigurationNode(final String constant, final Object default_value, final String description, final SettingValue type, final boolean required) {
@ -32,8 +52,7 @@ public class ConfigurationNode {
return false;
}
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}

View File

@ -1,26 +1,44 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import org.apache.commons.lang.StringUtils;
public class Flag {
private final AbstractFlag key;
private final String value;
private final String value;
/**
* Flag object used to store basic information for a Plot. Flags are a
* key/value pair. For a flag to be usable by a player, you need to register
* it with PlotSquared.
*
* @param key
* AbstractFlag
* @param value
* Value must be alphanumerical (can have spaces) and be <= 48
* characters
* @throws IllegalArgumentException
* if you provide inadequate inputs
* @param key AbstractFlag
* @param value Value must be alphanumerical (can have spaces) and be <= 48
* characters
* @throws IllegalArgumentException if you provide inadequate inputs
*/
public Flag(final AbstractFlag key, final String value) {
final char[] allowedCharacters = new char[] { '[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', '§' };
final char[] allowedCharacters = new char[]{'[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', '<27>'};
String tempValue = value;
for (final char c : allowedCharacters) {
tempValue = tempValue.replace(c, 'c');

View File

@ -1,11 +1,32 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.entity.Player;
public class FlagManager {
// TODO add some flags
@ -64,8 +85,7 @@ public class FlagManager {
/**
* Get a list of registerd AbstragFlag objects based on player permissions
*
* @param player
* with permissions
* @param player with permissions
* @return List (AbstractFlag)
*/
public static List<AbstractFlag> getFlags(final Player player) {
@ -97,8 +117,7 @@ public class FlagManager {
* Get an AbstractFlag by a string
*
* @param string
* @param create
* If to create the flag if it does not exist
* @param create If to create the flag if it does not exist
* @return AbstractFlag
*/
public static AbstractFlag getFlag(final String string, final boolean create) {
@ -126,8 +145,7 @@ public class FlagManager {
final String[] split = flagstrings.get(i).split(";");
if (split.length == 1) {
flags[i] = new Flag(getFlag(split[0], true), "");
}
else {
} else {
flags[i] = new Flag(getFlag(split[0], true), split[1]);
}
}

View File

@ -1,10 +1,23 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = LSetCube.java >> Generated by: Citymonstret at 2014-08-09 01:43
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
@ -92,7 +105,7 @@ public class LSetCube {
/**
*
*/
private Location current;
private Location current;
/**
* @param cube

View File

@ -1,10 +1,23 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Lag.java >> Generated by: Citymonstret at 2014-08-09 01:43
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
@ -18,16 +31,16 @@ public class Lag implements Runnable {
/**
* Tick count
*/
public static int TC = 0;
public static int TC = 0;
/**
* Ticks
*/
public static long[] T = new long[600];
public static long[] T = new long[600];
/**
* something :_:
*/
@SuppressWarnings("unused")
public static long LT = 0L;
public static long LT = 0L;
/**
* Get the server TPS
@ -41,8 +54,7 @@ public class Lag implements Runnable {
/**
* Return the tick per second (measured in $ticks)
*
* @param ticks
* Ticks
* @param ticks Ticks
* @return ticks per second
*/
public static double getTPS(final int ticks) {
@ -57,8 +69,7 @@ public class Lag implements Runnable {
/**
* Get number of ticks since
*
* @param tI
* Ticks <
* @param tI Ticks <
* @return number of ticks since $tI
*/
@SuppressWarnings("unused")

View File

@ -1,18 +1,27 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Logger.java >> Generated by: Citymonstret at 2014-08-09 01:43
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
@ -24,7 +33,7 @@ import java.util.Date;
public class Logger {
private static ArrayList<String> entries;
private static File log;
private static File log;
public static void setup(final File file) {
log = file;
@ -36,8 +45,7 @@ public class Logger {
entries.add(line);
}
reader.close();
}
catch (final IOException e) {
} catch (final IOException e) {
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup");
}
}

View File

@ -1,56 +1,26 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
/*
* Copyright 2011-2013 Tyler Blair. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and contributors and should not be interpreted as
* representing official policies, either expressed or implied, of anybody else.
*/
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
@ -59,31 +29,41 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.*;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
public class Metrics {
/**
* The current revision number
*/
private final static int REVISION = 7;
private final static int REVISION = 7;
/**
* The base url of the metrics domain
*/
private static final String BASE_URL = "http://report.mcstats.org";
private static final String BASE_URL = "http://report.mcstats.org";
/**
* The url used to report a server's status
*/
private static final String REPORT_URL = "/plugin/%s";
private static final String REPORT_URL = "/plugin/%s";
/**
* Interval of time to ping (in minutes)
*/
private static final int PING_INTERVAL = 15;
private static final int PING_INTERVAL = 15;
/**
* The plugin this metrics submits for
*/
private final Plugin plugin;
private final Plugin plugin;
/**
* All of the custom graphs to submit to metrics
*/
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
/**
* The plugin configuration file
*/
@ -91,23 +71,23 @@ public class Metrics {
/**
* The plugin configuration file
*/
private final File configurationFile;
private final File configurationFile;
/**
* Unique server id
*/
private final String guid;
private final String guid;
/**
* Debug mode
*/
private final boolean debug;
private final boolean debug;
/**
* Lock for synchronization
*/
private final Object optOutLock = new Object();
private final Object optOutLock = new Object();
/**
* The scheduled task
*/
private volatile BukkitTask task = null;
private volatile BukkitTask task = null;
public Metrics(final Plugin plugin) throws IOException {
if (plugin == null) {
@ -136,10 +116,9 @@ public class Metrics {
* plotters to their own graphs on the metrics website. Plotters can be
* added to the graph object returned.
*
* @param name
* The name of the graph
* @param name The name of the graph
* @return Graph object created. Will never return NULL under normal
* circumstances unless bad parameters are given
* circumstances unless bad parameters are given
*/
public Graph createGraph(final String name) {
if (name == null) {
@ -157,8 +136,7 @@ public class Metrics {
* Add a Graph object to BukkitMetrics that represents data for the plugin
* that should be sent to the backend
*
* @param graph
* The name of the graph
* @param graph The name of the graph
*/
public void addGraph(final Graph graph) {
if (graph == null) {
@ -222,8 +200,7 @@ public class Metrics {
// false
// Each post thereafter will be a ping
this.firstPost = false;
}
catch (final IOException e) {
} catch (final IOException e) {
if (Metrics.this.debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
}
@ -244,14 +221,12 @@ public class Metrics {
try {
// Reload the metrics file
this.configuration.load(getConfigFile());
}
catch (final IOException ex) {
} catch (final IOException ex) {
if (this.debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
return true;
}
catch (final InvalidConfigurationException ex) {
} catch (final InvalidConfigurationException ex) {
if (this.debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
@ -334,7 +309,7 @@ public class Metrics {
final PluginDescriptionFile description = this.plugin.getDescription();
final String pluginName = description.getName();
final boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE
// if
// if
// online
// mode
// is
@ -345,12 +320,10 @@ public class Metrics {
try {
if (Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).getReturnType() == Collection.class) {
playersOnline = ((Collection<?>) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null, new Object[0])).size();
}
else {
} else {
playersOnline = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null, new Object[0])).length;
}
}
catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
}
// END server software specific section -- all code below does not use
@ -423,8 +396,7 @@ public class Metrics {
// It does not reroute POST requests so we need to go around it
if (isMineshafterPresent()) {
connection = url.openConnection(Proxy.NO_PROXY);
}
else {
} else {
connection = url.openConnection();
}
final byte[] uncompressed = json.toString().getBytes();
@ -453,13 +425,11 @@ public class Metrics {
if ((response == null) || response.startsWith("ERR") || response.startsWith("7")) {
if (response == null) {
response = "null";
}
else if (response.startsWith("7")) {
} else if (response.startsWith("7")) {
response = response.substring(response.startsWith("7,") ? 2 : 1);
}
throw new IOException(response);
}
else {
} else {
// Is this the first update this hour?
if (response.equals("1") || response.contains("This is your first update this hour")) {
synchronized (this.graphs) {
@ -487,16 +457,13 @@ public class Metrics {
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
}
catch (final IOException e) {
} catch (final IOException e) {
e.printStackTrace();
}
finally {
} finally {
if (gzos != null) {
try {
gzos.close();
}
catch (final IOException ignore) {
} catch (final IOException ignore) {
}
}
}
@ -513,8 +480,7 @@ public class Metrics {
try {
Class.forName("mineshafter.MineServer");
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
}
@ -534,8 +500,7 @@ public class Metrics {
Double.parseDouble(value);
isValueNumeric = true;
}
}
catch (final NumberFormatException e) {
} catch (final NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
@ -545,8 +510,7 @@ public class Metrics {
json.append(':');
if (isValueNumeric) {
json.append(value);
}
else {
} else {
json.append(escapeJSON(value));
}
}
@ -584,8 +548,7 @@ public class Metrics {
if (chr < ' ') {
final String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
}
else {
} else {
builder.append(chr);
}
break;
@ -598,8 +561,7 @@ public class Metrics {
/**
* Encode text as UTF-8
*
* @param text
* the text to encode
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
@ -614,7 +576,7 @@ public class Metrics {
* The graph's name, alphanumeric and spaces only :) If it does not
* comply to the above when submitted, it is rejected
*/
private final String name;
private final String name;
/**
* The set of plotters that are contained within this graph
*/
@ -636,8 +598,7 @@ public class Metrics {
/**
* Add a plotter to the graph, which will be used to plot entries
*
* @param plotter
* the plotter to add to the graph
* @param plotter the plotter to add to the graph
*/
public void addPlotter(final Plotter plotter) {
this.plotters.add(plotter);
@ -646,8 +607,7 @@ public class Metrics {
/**
* Remove a plotter from the graph
*
* @param plotter
* the plotter to remove from the graph
* @param plotter the plotter to remove from the graph
*/
public void removePlotter(final Plotter plotter) {
this.plotters.remove(plotter);
@ -703,9 +663,8 @@ public class Metrics {
/**
* Construct a plotter with a specific plot name
*
* @param name
* the name of the plotter to use, which will show up on the
* website
* @param name the name of the plotter to use, which will show up on the
* website
*/
public Plotter(final String name) {
this.name = name;

View File

@ -1,8 +1,25 @@
package com.intellectualcrafters.plot;
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.database.DBFunc;
import com.sk89q.worldedit.LocalSession;
@ -13,6 +30,9 @@ import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
/**
* @author Citymonstret
@ -25,8 +45,7 @@ public class PWE {
LocalSession s;
if (PlotMain.worldEdit == null) {
s = WorldEdit.getInstance().getSession(p.getName());
}
else {
} else {
s = PlotMain.worldEdit.getSession(p);
}
@ -41,8 +60,7 @@ public class PWE {
removeMask(p, s);
return;
}
}
else {
} else {
final World w = p.getWorld();
@ -66,8 +84,7 @@ public class PWE {
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
}
}
catch (final Exception e) {
} catch (final Exception e) {
// throw new
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
// "WorldEdit == Null?");
@ -83,15 +100,13 @@ public class PWE {
LocalSession s;
if (PlotMain.worldEdit == null) {
s = WorldEdit.getInstance().getSession(p.getName());
}
else {
} else {
s = PlotMain.worldEdit.getSession(p);
}
final BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
}
catch (final Exception e) {
} catch (final Exception e) {
}
}
@ -106,13 +121,11 @@ public class PWE {
LocalSession s;
if (PlotMain.worldEdit == null) {
s = WorldEdit.getInstance().getSession(p.getName());
}
else {
} else {
s = PlotMain.worldEdit.getSession(p);
}
removeMask(p, s);
}
catch (final Exception e) {
} catch (final Exception e) {
// throw new
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
// "WorldEdit == Null?");

View File

@ -1,22 +1,34 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Plot.java >> Generated by: Citymonstret at 2014-08-09 01:43
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import java.util.ArrayList;
import java.util.UUID;
import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.database.DBFunc;
import java.util.ArrayList;
import java.util.UUID;
/**
* The plot class
@ -29,19 +41,19 @@ public class Plot implements Cloneable {
/**
* plot ID
*/
public PlotId id;
public PlotId id;
/**
* plot world
*/
public String world;
public String world;
/**
* plot owner
*/
public UUID owner;
public UUID owner;
/**
* Deny Entry
*/
public boolean deny_entry;
public boolean deny_entry;
/**
* List of helpers (with plot permissions)
*/
@ -57,16 +69,16 @@ public class Plot implements Cloneable {
/**
* External settings class
*/
public PlotSettings settings;
public PlotSettings settings;
/**
* Delete on next save cycle?
*/
public boolean delete;
public boolean delete;
/**
* Has the plot changed since the last save cycle?
*/
public boolean hasChanged = false;
public boolean countsTowardsMax = true;
public boolean hasChanged = false;
public boolean countsTowardsMax = true;
/**
* Primary constructor
@ -120,8 +132,7 @@ public class Plot implements Cloneable {
this.delete = false;
if (flags != null) {
this.settings.setFlags(flags);
}
else {
} else {
this.settings.setFlags(new Flag[0]);
}
this.world = world;
@ -195,8 +206,7 @@ public class Plot implements Cloneable {
public Object clone() throws CloneNotSupportedException {
try {
return super.clone();
}
catch (final CloneNotSupportedException e) {
} catch (final CloneNotSupportedException e) {
return null;
}
}
@ -270,8 +280,7 @@ public class Plot implements Cloneable {
/**
* Clear a plot
*
* @param plr
* initiator
* @param plr initiator
*/
public void clear(final Player plr) {
PlotHelper.clear(plr, this);
@ -292,21 +301,18 @@ public class Plot implements Cloneable {
int y = id.y;
if (x >= 0) {
if (y >= 0) {
return x*x + 3*x + 2*x*y + y + y*y;
}
else {
return x * x + 3 * x + 2 * x * y + y + y * y;
} else {
int y1 = -y;
return x*x + 3*x + 2*x*y1 + y1 + y1*y1 + 1;
return x * x + 3 * x + 2 * x * y1 + y1 + y1 * y1 + 1;
}
}
else {
} else {
int x1 = -x;
if (y >= 0) {
return -(x1*x1 + 3*x1 + 2*x1*y + y + y*y);
}
else {
return -(x1 * x1 + 3 * x1 + 2 * x1 * y + y + y * y);
} else {
int y1 = -y;
return -(x1*x1 + 3*x1 + 2*x1*y1 + y1 + y1*y1 + 1);
return -(x1 * x1 + 3 * x1 + 2 * x1 * y1 + y1 + y1 * y1 + 1);
}
}
}

View File

@ -1,8 +1,29 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
public class PlotBlock {
public short id;
public byte data;
public byte data;
public PlotBlock(final short id, final byte data) {
this.id = id;

View File

@ -1,8 +1,29 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
public class PlotComment {
public final String comment;
public final int tier;
public final int tier;
public final String senderName;
public PlotComment(final String comment, final String senderName, final int tier) {

View File

@ -1,26 +1,30 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = PlotHelper.java >> Generated by: Citymonstret at 2014-08-09 01:43
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.listeners.PlotListener;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@ -28,8 +32,10 @@ import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.listeners.PlotListener;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
/**
* plot functions
@ -38,7 +44,7 @@ import com.intellectualcrafters.plot.listeners.PlotListener;
*/
public class PlotHelper {
public static boolean canSetFast = false;
static long state = 1;
static long state = 1;
/**
* direction 0 = north, 1 = south, etc:
@ -185,8 +191,7 @@ public class PlotHelper {
greaterPlot.settings.setMerged(0, true);
manager.removeRoadSouth(plotworld, lesserPlot);
}
}
else {
} else {
if (!lesserPlot.settings.getMerged(1)) {
lesserPlot.settings.setMerged(1, true);
greaterPlot.settings.setMerged(3, true);
@ -216,7 +221,7 @@ public class PlotHelper {
return 0;
}
final long r = ((nextLong() >>> 32) * n) >> 32;
return (int) r;
return (int) r;
}
/*
@ -283,8 +288,7 @@ public class PlotHelper {
try {
SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data);
return true;
}
catch (final Throwable e) {
} catch (final Throwable e) {
canSetFast = false;
}
}
@ -294,12 +298,10 @@ public class PlotHelper {
if (block.getTypeId() != plotblock.id) {
block.setTypeId(plotblock.id);
}
}
else {
} else {
if (block.getTypeId() == plotblock.id) {
block.setData(plotblock.data);
}
else {
} else {
block.setTypeIdAndData(plotblock.id, plotblock.data, false);
}
}
@ -603,8 +605,8 @@ public class PlotHelper {
return x + ";" + z;
}
public static ArrayList<String> runners_p = new ArrayList<String>();
public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>();
public static ArrayList<String> runners_p = new ArrayList<String>();
public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>();
public static void adjustWallFilling(final Player requester, final Plot plot, final PlotBlock block) {
if (runners.containsKey(plot)) {
@ -644,9 +646,9 @@ public class PlotHelper {
public static short[] getBlock(final String block) {
if (block.contains(":")) {
final String[] split = block.split(":");
return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) };
return new short[]{Short.parseShort(split[0]), Short.parseShort(split[1])};
}
return new short[] { Short.parseShort(block), 0 };
return new short[]{Short.parseShort(block), 0};
}
public static void clearAllEntities(final World world, final Plot plot, final boolean tile) {
@ -662,8 +664,7 @@ public class PlotHelper {
Player player = (Player) entity;
PlotMain.teleportPlayer(player, entity.getLocation(), plot);
PlotListener.plotExit(player, plot);
}
else {
} else {
entity.remove();
}
}
@ -717,8 +718,7 @@ public class PlotHelper {
final World world;
if (requester != null) {
world = requester.getWorld();
}
else {
} else {
world = Bukkit.getWorld(plot.world);
}
@ -747,8 +747,7 @@ public class PlotHelper {
}
}
}
}
else {
} else {
try {
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
@ -762,8 +761,7 @@ public class PlotHelper {
}
}
}
}
catch (final Exception e) {
} catch (final Exception e) {
}
}
}
@ -780,8 +778,7 @@ public class PlotHelper {
}
}
}
}
else {
} else {
try {
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
@ -793,8 +790,7 @@ public class PlotHelper {
}
}
}
}
catch (final Exception e) {
} catch (final Exception e) {
}
}
@ -841,8 +837,7 @@ public class PlotHelper {
final int z = bot.getBlockZ() - 2;
final int y = getHeighestBlock(w, x, z);
return new Location(w, x, y, z);
}
else {
} else {
final Location bot = getPlotBottomLoc(w, plotid), top = getPlotTopLoc(w, plotid);
final int x = top.getBlockX() - bot.getBlockX();
final int z = top.getBlockZ() - bot.getBlockZ();

View File

@ -1,11 +1,23 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = PlotHomePosition.java >> Generated by: Citymonstret at 2014-08-09
* 01:44
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
@ -17,7 +29,7 @@ public enum PlotHomePosition {
DEFAULT("Default", 'd');
private String string;
private char ch;
private char ch;
PlotHomePosition(final String string, final char ch) {
this.string = string;

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
public class PlotId {
@ -13,10 +34,8 @@ public class PlotId {
/**
* PlotId class (PlotId x,y values do not correspond to Block locations)
*
* @param x
* The plot x coordinate
* @param y
* The plot y coordinate
* @param x The plot x coordinate
* @param y The plot y coordinate
*/
public PlotId(final int x, final int y) {
this.x = x;
@ -47,21 +66,18 @@ public class PlotId {
public int hashCode() {
if (x >= 0) {
if (y >= 0) {
return x*x + 3*x + 2*x*y + y + y*y;
}
else {
return x * x + 3 * x + 2 * x * y + y + y * y;
} else {
int y1 = -y;
return x*x + 3*x + 2*x*y1 + y1 + y1*y1 + 1;
return x * x + 3 * x + 2 * x * y1 + y1 + y1 * y1 + 1;
}
}
else {
} else {
int x1 = -x;
if (y >= 0) {
return -(x1*x1 + 3*x1 + 2*x1*y + y + y*y);
}
else {
return -(x1 * x1 + 3 * x1 + 2 * x1 * y + y + y * y);
} else {
int y1 = -y;
return -(x1*x1 + 3*x1 + 2*x1*y1 + y1 + y1*y1 + 1);
return -(x1 * x1 + 3 * x1 + 2 * x1 * y1 + y1 + y1 * y1 + 1);
}
}
}

View File

@ -1,11 +1,32 @@
package com.intellectualcrafters.plot;
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
import java.util.ArrayList;
package com.intellectualcrafters.plot;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Biome;
import java.util.ArrayList;
public abstract class PlotManager {
/*

View File

@ -1,12 +1,33 @@
package com.intellectualcrafters.plot;
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
import java.util.HashMap;
package com.intellectualcrafters.plot;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import java.util.HashMap;
/**
* Created by Citymonstret on 2014-10-12.
*/
@ -14,13 +35,13 @@ public class PlotSelection {
public static HashMap<String, PlotSelection> currentSelection = new HashMap<>();
private final PlotBlock[] plotBlocks;
private final PlotBlock[] plotBlocks;
private final int width;
private final int width;
private final Plot plot;
private final Plot plot;
private final Biome biome;
private final Biome biome;
public PlotSelection(final int width, final World world, final Plot plot) {
this.width = width;
@ -86,21 +107,17 @@ public class PlotSelection {
try {
SetBlockFast.set(world, b1.x, b1.y, b1.z, b2.id, b2.data);
SetBlockFast.set(world, b2.x, b2.y, b2.z, b1.id, b1.data);
}
catch (final NoSuchMethodException e) {
} catch (final NoSuchMethodException e) {
PlotHelper.canSetFast = false;
}
}
else {
} else {
if ((b1.id != b2.id) && (b1.data != b2.data)) {
block1.setTypeIdAndData(b2.id, b2.data, false);
block2.setTypeIdAndData(b1.id, b1.data, false);
}
else if (b1.id != b2.id) {
} else if (b1.id != b2.id) {
block1.setTypeId(b2.id);
block2.setTypeId(b1.id);
}
else {
} else {
block1.setData(b2.data);
block2.setData(b1.data);
}

View File

@ -1,20 +1,33 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = PlotSettings.java >> Generated by: Citymonstret at 2014-08-09 01:44
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import org.bukkit.block.Biome;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.block.Biome;
/**
* plot settings
*
@ -24,23 +37,23 @@ public class PlotSettings {
/**
* merged plots
*/
private boolean[] merged = new boolean[] { false, false, false, false };
private boolean[] merged = new boolean[]{false, false, false, false};
/**
* plot alias
*/
private String alias;
private String alias;
/**
* plot biome
*/
private Biome biome;
private Biome biome;
private ArrayList<PlotComment> comments = null;
/**
*
*/
private Set<Flag> flags;
private Set<Flag> flags;
private PlotHomePosition position;
private PlotHomePosition position;
/**
* Constructor
@ -178,7 +191,7 @@ public class PlotSettings {
public void setComments(final ArrayList<PlotComment> comments) {
this.comments = comments;
}
public void removeComment(PlotComment comment) {
if (this.comments.contains(comment)) {
this.comments.remove(comment);
@ -190,7 +203,7 @@ public class PlotSettings {
removeComment(comment);
}
}
public void addComment(final PlotComment comment) {
if (this.comments == null) {
this.comments = new ArrayList<PlotComment>();

View File

@ -1,164 +1,101 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import static org.bukkit.Material.ACACIA_STAIRS;
import static org.bukkit.Material.BEACON;
import static org.bukkit.Material.BEDROCK;
import static org.bukkit.Material.BIRCH_WOOD_STAIRS;
import static org.bukkit.Material.BOOKSHELF;
import static org.bukkit.Material.BREWING_STAND;
import static org.bukkit.Material.BRICK;
import static org.bukkit.Material.BRICK_STAIRS;
import static org.bukkit.Material.BURNING_FURNACE;
import static org.bukkit.Material.CAKE_BLOCK;
import static org.bukkit.Material.CAULDRON;
import static org.bukkit.Material.CLAY;
import static org.bukkit.Material.CLAY_BRICK;
import static org.bukkit.Material.COAL_BLOCK;
import static org.bukkit.Material.COAL_ORE;
import static org.bukkit.Material.COBBLESTONE;
import static org.bukkit.Material.COBBLESTONE_STAIRS;
import static org.bukkit.Material.COBBLE_WALL;
import static org.bukkit.Material.COMMAND;
import static org.bukkit.Material.DARK_OAK_STAIRS;
import static org.bukkit.Material.DAYLIGHT_DETECTOR;
import static org.bukkit.Material.DIAMOND_BLOCK;
import static org.bukkit.Material.DIAMOND_ORE;
import static org.bukkit.Material.DIRT;
import static org.bukkit.Material.DISPENSER;
import static org.bukkit.Material.DROPPER;
import static org.bukkit.Material.EMERALD_BLOCK;
import static org.bukkit.Material.EMERALD_ORE;
import static org.bukkit.Material.ENCHANTMENT_TABLE;
import static org.bukkit.Material.ENDER_PORTAL_FRAME;
import static org.bukkit.Material.ENDER_STONE;
import static org.bukkit.Material.FURNACE;
import static org.bukkit.Material.GLASS;
import static org.bukkit.Material.GLOWSTONE;
import static org.bukkit.Material.GOLD_BLOCK;
import static org.bukkit.Material.GOLD_ORE;
import static org.bukkit.Material.GRASS;
import static org.bukkit.Material.GRAVEL;
import static org.bukkit.Material.HARD_CLAY;
import static org.bukkit.Material.HAY_BLOCK;
import static org.bukkit.Material.HUGE_MUSHROOM_1;
import static org.bukkit.Material.HUGE_MUSHROOM_2;
import static org.bukkit.Material.IRON_BLOCK;
import static org.bukkit.Material.IRON_ORE;
import static org.bukkit.Material.JACK_O_LANTERN;
import static org.bukkit.Material.JUKEBOX;
import static org.bukkit.Material.JUNGLE_WOOD_STAIRS;
import static org.bukkit.Material.LAPIS_BLOCK;
import static org.bukkit.Material.LAPIS_ORE;
import static org.bukkit.Material.LEAVES;
import static org.bukkit.Material.LEAVES_2;
import static org.bukkit.Material.LOG;
import static org.bukkit.Material.LOG_2;
import static org.bukkit.Material.MELON_BLOCK;
import static org.bukkit.Material.MOB_SPAWNER;
import static org.bukkit.Material.MOSSY_COBBLESTONE;
import static org.bukkit.Material.MYCEL;
import static org.bukkit.Material.NETHERRACK;
import static org.bukkit.Material.NETHER_BRICK;
import static org.bukkit.Material.NETHER_BRICK_STAIRS;
import static org.bukkit.Material.NOTE_BLOCK;
import static org.bukkit.Material.OBSIDIAN;
import static org.bukkit.Material.PACKED_ICE;
import static org.bukkit.Material.PUMPKIN;
import static org.bukkit.Material.QUARTZ_BLOCK;
import static org.bukkit.Material.QUARTZ_ORE;
import static org.bukkit.Material.QUARTZ_STAIRS;
import static org.bukkit.Material.REDSTONE_BLOCK;
import static org.bukkit.Material.SAND;
import static org.bukkit.Material.SANDSTONE;
import static org.bukkit.Material.SANDSTONE_STAIRS;
import static org.bukkit.Material.SMOOTH_BRICK;
import static org.bukkit.Material.SMOOTH_STAIRS;
import static org.bukkit.Material.SNOW_BLOCK;
import static org.bukkit.Material.SOUL_SAND;
import static org.bukkit.Material.SPONGE;
import static org.bukkit.Material.SPRUCE_WOOD_STAIRS;
import static org.bukkit.Material.STONE;
import static org.bukkit.Material.WOOD;
import static org.bukkit.Material.WOOD_STAIRS;
import static org.bukkit.Material.WOOL;
import static org.bukkit.Material.WORKBENCH;
import static org.bukkit.Material.getMaterial;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
import static org.bukkit.Material.*;
/**
*
* @author Jesse Boyd
*
*/
public abstract class PlotWorld {
// TODO make this configurable
// make non static and static_default_valu + add config option
@SuppressWarnings("deprecation")
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(Arrays.asList(new Material[] { ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), getMaterial(126) }));
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), getMaterial(126)}));
public boolean AUTO_MERGE;
public static boolean AUTO_MERGE_DEFAULT = false;
public boolean AUTO_MERGE;
public static boolean AUTO_MERGE_DEFAULT = false;
public boolean MOB_SPAWNING;
public static boolean MOB_SPAWNING_DEFAULT = false;
public boolean MOB_SPAWNING;
public static boolean MOB_SPAWNING_DEFAULT = false;
public Biome PLOT_BIOME;
public static Biome PLOT_BIOME_DEFAULT = Biome.FOREST;
public Biome PLOT_BIOME;
public static Biome PLOT_BIOME_DEFAULT = Biome.FOREST;
public boolean PLOT_CHAT;
public static boolean PLOT_CHAT_DEFAULT = false;
public boolean PLOT_CHAT;
public static boolean PLOT_CHAT_DEFAULT = false;
public boolean SCHEMATIC_CLAIM_SPECIFY = false;
public static boolean SCHEMATIC_CLAIM_SPECIFY_DEFAULT = false;
public boolean SCHEMATIC_CLAIM_SPECIFY = false;
public static boolean SCHEMATIC_CLAIM_SPECIFY_DEFAULT = false;
public boolean SCHEMATIC_ON_CLAIM;
public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
public boolean SCHEMATIC_ON_CLAIM;
public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
public String SCHEMATIC_FILE;
public static String SCHEMATIC_FILE_DEFAULT = "null";
public String SCHEMATIC_FILE;
public static String SCHEMATIC_FILE_DEFAULT = "null";
public List<String> SCHEMATICS;
public static List<String> SCHEMATICS_DEFAULT = null;
public List<String> SCHEMATICS;
public static List<String> SCHEMATICS_DEFAULT = null;
public List<String> DEFAULT_FLAGS;
public static List<String> DEFAULT_FLAGS_DEFAULT = new ArrayList<String>();
public List<String> DEFAULT_FLAGS;
public static List<String> DEFAULT_FLAGS_DEFAULT = new ArrayList<String>();
public boolean USE_ECONOMY;
public static boolean USE_ECONOMY_DEFAULT = false;
public boolean USE_ECONOMY;
public static boolean USE_ECONOMY_DEFAULT = false;
public double PLOT_PRICE;
public static double PLOT_PRICE_DEFAULT = 100;
public double PLOT_PRICE;
public static double PLOT_PRICE_DEFAULT = 100;
public double MERGE_PRICE;
public static double MERGE_PRICE_DEFAULT = 100;
public double MERGE_PRICE;
public static double MERGE_PRICE_DEFAULT = 100;
public double SELL_PRICE;
public static double SELL_PRICE_DEFAULT = 75;
public double SELL_PRICE;
public static double SELL_PRICE_DEFAULT = 75;
public boolean PVP;
public static boolean PVP_DEFAULT = false;
public boolean PVP;
public static boolean PVP_DEFAULT = false;
public boolean PVE;
public static boolean PVE_DEFAULT = false;
public boolean PVE;
public static boolean PVE_DEFAULT = false;
public boolean SPAWN_EGGS;
public static boolean SPAWN_EGGS_DEFAULT = false;
public boolean SPAWN_EGGS;
public static boolean SPAWN_EGGS_DEFAULT = false;
public boolean SPAWN_CUSTOM;
public static boolean SPAWN_CUSTOM_DEFAULT = true;
public boolean SPAWN_CUSTOM;
public static boolean SPAWN_CUSTOM_DEFAULT = true;
public boolean SPAWN_BREEDING;
public static boolean SPAWN_BREEDING_DEFAULT = false;
public boolean SPAWN_BREEDING;
public static boolean SPAWN_BREEDING_DEFAULT = false;
public PlotWorld(final String worldname) {
this.worldname = worldname;

View File

@ -1,5 +1,29 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -7,22 +31,25 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Server;
/**
* @author DPOH-VAR
* @version 1.0
*/
@SuppressWarnings({ "UnusedDeclaration", "rawtypes" })
@SuppressWarnings({"UnusedDeclaration", "rawtypes"})
public class ReflectionUtils {
/** prefix of bukkit classes */
private static String preClassB = "org.bukkit.craftbukkit";
/** prefix of minecraft classes */
private static String preClassM = "net.minecraft.server";
/** boolean value, TRUE if server uses forge or MCPC+ */
private static boolean forge = false;
/**
* prefix of bukkit classes
*/
private static String preClassB = "org.bukkit.craftbukkit";
/**
* prefix of minecraft classes
*/
private static String preClassM = "net.minecraft.server";
/**
* boolean value, TRUE if server uses forge or MCPC+
*/
private static boolean forge = false;
/** check server version and class names */
static {
@ -46,8 +73,7 @@ public class ReflectionUtils {
final String verM = pas[3];
preClassM += "." + verM;
}
}
catch (final Exception ignored) {
} catch (final Exception ignored) {
}
}
}
@ -63,19 +89,16 @@ public class ReflectionUtils {
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace
* {cb} to org.bukkit.craftbukkit.V*. Replace {nm} to net.minecraft
*
* @param classes
* possible class paths
* @param classes possible class paths
* @return RefClass object
* @throws RuntimeException
* if no class found
* @throws RuntimeException if no class found
*/
public static RefClass getRefClass(final String... classes) {
for (String className : classes) {
try {
className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft");
return getRefClass(Class.forName(className));
}
catch (final ClassNotFoundException ignored) {
} catch (final ClassNotFoundException ignored) {
}
}
throw new RuntimeException("no class found");
@ -84,8 +107,7 @@ public class ReflectionUtils {
/**
* get RefClass object by real class
*
* @param clazz
* class
* @param clazz class
* @return RefClass based on passed class
*/
public static RefClass getRefClass(final Class clazz) {
@ -114,8 +136,7 @@ public class ReflectionUtils {
/**
* see {@link Class#isInstance(Object)}
*
* @param object
* the object to check
* @param object the object to check
* @return true if object is an instance of this class
*/
public boolean isInstance(final Object object) {
@ -125,13 +146,10 @@ public class ReflectionUtils {
/**
* get existing method by name and types
*
* @param name
* name
* @param types
* method parameters. can be Class or RefClass
* @param name name
* @param types method parameters. can be Class or RefClass
* @return RefMethod object
* @throws RuntimeException
* if method not found
* @throws RuntimeException if method not found
*/
public RefMethod getMethod(final String name, final Object... types) throws NoSuchMethodException {
try {
@ -140,22 +158,18 @@ public class ReflectionUtils {
for (final Object e : types) {
if (e instanceof Class) {
classes[i++] = (Class) e;
}
else if (e instanceof RefClass) {
} else if (e instanceof RefClass) {
classes[i++] = ((RefClass) e).getRealClass();
}
else {
} else {
classes[i++] = e.getClass();
}
}
try {
return new RefMethod(this.clazz.getMethod(name, classes));
}
catch (final NoSuchMethodException ignored) {
} catch (final NoSuchMethodException ignored) {
return new RefMethod(this.clazz.getDeclaredMethod(name, classes));
}
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -163,11 +177,9 @@ public class ReflectionUtils {
/**
* get existing constructor by types
*
* @param types
* parameters. can be Class or RefClass
* @param types parameters. can be Class or RefClass
* @return RefMethod object
* @throws RuntimeException
* if constructor not found
* @throws RuntimeException if constructor not found
*/
public RefConstructor getConstructor(final Object... types) {
try {
@ -176,22 +188,18 @@ public class ReflectionUtils {
for (final Object e : types) {
if (e instanceof Class) {
classes[i++] = (Class) e;
}
else if (e instanceof RefClass) {
} else if (e instanceof RefClass) {
classes[i++] = ((RefClass) e).getRealClass();
}
else {
} else {
classes[i++] = e.getClass();
}
}
try {
return new RefConstructor(this.clazz.getConstructor(classes));
}
catch (final NoSuchMethodException ignored) {
} catch (final NoSuchMethodException ignored) {
return new RefConstructor(this.clazz.getDeclaredConstructor(classes));
}
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -199,11 +207,9 @@ public class ReflectionUtils {
/**
* find method by type parameters
*
* @param types
* parameters. can be Class or RefClass
* @param types parameters. can be Class or RefClass
* @return RefMethod object
* @throws RuntimeException
* if method not found
* @throws RuntimeException if method not found
*/
public RefMethod findMethod(final Object... types) {
final Class[] classes = new Class[types.length];
@ -211,18 +217,17 @@ public class ReflectionUtils {
for (final Object e : types) {
if (e instanceof Class) {
classes[t++] = (Class) e;
}
else if (e instanceof RefClass) {
} else if (e instanceof RefClass) {
classes[t++] = ((RefClass) e).getRealClass();
}
else {
} else {
classes[t++] = e.getClass();
}
}
final List<Method> methods = new ArrayList<>();
Collections.addAll(methods, this.clazz.getMethods());
Collections.addAll(methods, this.clazz.getDeclaredMethods());
findMethod: for (final Method m : methods) {
findMethod:
for (final Method m : methods) {
final Class<?>[] methodTypes = m.getParameterTypes();
if (methodTypes.length != classes.length) {
continue;
@ -240,11 +245,9 @@ public class ReflectionUtils {
/**
* find method by name
*
* @param names
* possible names of method
* @param names possible names of method
* @return RefMethod object
* @throws RuntimeException
* if method not found
* @throws RuntimeException if method not found
*/
public RefMethod findMethodByName(final String... names) {
final List<Method> methods = new ArrayList<>();
@ -263,11 +266,9 @@ public class ReflectionUtils {
/**
* find method by return value
*
* @param type
* type of returned value
* @throws RuntimeException
* if method not found
* @param type type of returned value
* @return RefMethod
* @throws RuntimeException if method not found
*/
public RefMethod findMethodByReturnType(final RefClass type) {
return findMethodByReturnType(type.clazz);
@ -276,11 +277,9 @@ public class ReflectionUtils {
/**
* find method by return value
*
* @param type
* type of returned value
* @param type type of returned value
* @return RefMethod
* @throws RuntimeException
* if method not found
* @throws RuntimeException if method not found
*/
public RefMethod findMethodByReturnType(Class type) {
if (type == null) {
@ -300,11 +299,9 @@ public class ReflectionUtils {
/**
* find constructor by number of arguments
*
* @param number
* number of arguments
* @param number number of arguments
* @return RefConstructor
* @throws RuntimeException
* if constructor not found
* @throws RuntimeException if constructor not found
*/
public RefConstructor findConstructor(final int number) {
final List<Constructor> constructors = new ArrayList<>();
@ -321,22 +318,18 @@ public class ReflectionUtils {
/**
* get field by name
*
* @param name
* field name
* @param name field name
* @return RefField
* @throws RuntimeException
* if field not found
* @throws RuntimeException if field not found
*/
public RefField getField(final String name) {
try {
try {
return new RefField(this.clazz.getField(name));
}
catch (final NoSuchFieldException ignored) {
} catch (final NoSuchFieldException ignored) {
return new RefField(this.clazz.getDeclaredField(name));
}
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -344,11 +337,9 @@ public class ReflectionUtils {
/**
* find field by type
*
* @param type
* field type
* @param type field type
* @return RefField
* @throws RuntimeException
* if field not found
* @throws RuntimeException if field not found
*/
public RefField findField(final RefClass type) {
return findField(type.clazz);
@ -357,11 +348,9 @@ public class ReflectionUtils {
/**
* find field by type
*
* @param type
* field type
* @param type field type
* @return RefField
* @throws RuntimeException
* if field not found
* @throws RuntimeException if field not found
*/
public RefField findField(Class type) {
if (type == null) {
@ -414,8 +403,7 @@ public class ReflectionUtils {
/**
* apply method to object
*
* @param e
* object to which the method is applied
* @param e object to which the method is applied
* @return RefExecutor with method call(...)
*/
public RefExecutor of(final Object e) {
@ -425,15 +413,13 @@ public class ReflectionUtils {
/**
* call static method
*
* @param params
* sent parameters
* @param params sent parameters
* @return return value
*/
public Object call(final Object... params) {
try {
return this.method.invoke(null, params);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -448,17 +434,14 @@ public class ReflectionUtils {
/**
* apply method for selected object
*
* @param params
* sent parameters
* @param params sent parameters
* @return return value
* @throws RuntimeException
* if something went wrong
* @throws RuntimeException if something went wrong
*/
public Object call(final Object... params) {
try {
return RefMethod.this.method.invoke(this.e, params);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -493,17 +476,14 @@ public class ReflectionUtils {
/**
* create new instance with constructor
*
* @param params
* parameters for constructor
* @param params parameters for constructor
* @return new object
* @throws RuntimeException
* if something went wrong
* @throws RuntimeException if something went wrong
*/
public Object create(final Object... params) {
try {
return this.constructor.newInstance(params);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -541,8 +521,7 @@ public class ReflectionUtils {
/**
* apply fiend for object
*
* @param e
* applied object
* @param e applied object
* @return RefExecutor with getter and setter
*/
public RefExecutor of(final Object e) {
@ -559,14 +538,12 @@ public class ReflectionUtils {
/**
* set field value for applied object
*
* @param param
* value
* @param param value
*/
public void set(final Object param) {
try {
RefField.this.field.set(this.e, param);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -579,8 +556,7 @@ public class ReflectionUtils {
public Object get() {
try {
return RefField.this.field.get(this.e);
}
catch (final Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}

View File

@ -1,32 +1,39 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import com.intellectualcrafters.jnbt.*;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.jnbt.ByteArrayTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.IntTag;
import com.intellectualcrafters.jnbt.ListTag;
import com.intellectualcrafters.jnbt.NBTInputStream;
import com.intellectualcrafters.jnbt.NBTOutputStream;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.StringTag;
import com.intellectualcrafters.jnbt.Tag;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
/**
* Schematic Handler
@ -34,17 +41,14 @@ import com.intellectualcrafters.jnbt.Tag;
* @author Citymonstret
* @author Empire92
*/
@SuppressWarnings({ "all" })
@SuppressWarnings({"all"})
public class SchematicHandler {
/**
* Paste a schematic
*
* @param location
* origin
* @param schematic
* schematic to paste
* @param plot
* plot to paste in
* @param location origin
* @param schematic schematic to paste
* @param plot plot to paste in
* @return true if succeeded
*/
public static boolean paste(final Location location, final Schematic schematic, final Plot plot, final int x_offset, final int z_offset) {
@ -72,8 +76,7 @@ public class SchematicHandler {
int y_offset;
if (HEIGHT == location.getWorld().getMaxHeight()) {
y_offset = 0;
}
else {
} else {
y_offset = l1.getBlockY();
}
@ -102,8 +105,7 @@ public class SchematicHandler {
}
}
}
}
catch (final Exception e) {
} catch (final Exception e) {
return false;
}
return true;
@ -112,8 +114,7 @@ public class SchematicHandler {
/**
* Get a schematic
*
* @param name
* to check
* @param name to check
* @return schematic if found, else null
*/
public static Schematic getSchematic(final String name) {
@ -155,12 +156,10 @@ public class SchematicHandler {
if ((index >> 1) >= addId.length) { // No corresponding
// AddBlocks index
blocks[index] = (short) (b[index] & 0xFF);
}
else {
} else {
if ((index & 1) == 0) {
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF));
}
else {
} else {
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF));
}
}
@ -208,8 +207,7 @@ public class SchematicHandler {
// }
// }
schematic = new Schematic(collection, dimension, file);
}
catch (final Exception e) {
} catch (final Exception e) {
e.printStackTrace();
return null;
}
@ -223,8 +221,8 @@ public class SchematicHandler {
*/
public static class Schematic {
private final DataCollection[] blockCollection;
private final Dimension schematicDimension;
private final File file;
private final Dimension schematicDimension;
private final File file;
public Schematic(final DataCollection[] blockCollection, final Dimension schematicDimension, final File file) {
this.blockCollection = blockCollection;
@ -277,10 +275,8 @@ public class SchematicHandler {
/**
* Saves a schematic to a file path
*
* @param tag
* to save
* @param path
* to save in
* @param tag to save
* @param path to save in
* @return true if succeeded
*/
public static boolean save(final CompoundTag tag, final String path) {
@ -296,8 +292,7 @@ public class SchematicHandler {
output.writeTag(tag);
output.close();
stream.close();
}
catch (final IOException e) {
} catch (final IOException e) {
e.printStackTrace();
return false;
}
@ -307,10 +302,8 @@ public class SchematicHandler {
/**
* Gets the schematic of a plot
*
* @param world
* to check
* @param id
* plot
* @param world to check
* @param id plot
* @return tag
*/
public static CompoundTag getCompoundTag(final World world, final PlotId id) {
@ -338,8 +331,7 @@ public class SchematicHandler {
}
}
}
}
catch (final Exception e) {
} catch (final Exception e) {
PlotMain.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at " + (i / 16) + ", " + (j / 16));
return null;
}
@ -407,7 +399,7 @@ public class SchematicHandler {
*/
public static class DataCollection {
private final short block;
private final byte data;
private final byte data;
// public CompoundTag tag;

View File

@ -1,11 +1,31 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import static com.intellectualcrafters.plot.ReflectionUtils.getRefClass;
import org.bukkit.Bukkit;
import com.intellectualcrafters.plot.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.ReflectionUtils.RefMethod;
import org.bukkit.Bukkit;
import static com.intellectualcrafters.plot.ReflectionUtils.getRefClass;
/**
* SetBlockFast class<br>
@ -13,15 +33,15 @@ import com.intellectualcrafters.plot.ReflectionUtils.RefMethod;
*/
public class SetBlockFast {
private static final RefClass classBlock = getRefClass("{nms}.Block");
private static final RefClass classChunk = getRefClass("{nms}.Chunk");
private static final RefClass classWorld = getRefClass("{nms}.World");
private static final RefClass classBlock = getRefClass("{nms}.Block");
private static final RefClass classChunk = getRefClass("{nms}.Chunk");
private static final RefClass classWorld = getRefClass("{nms}.World");
private static final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
private static RefMethod methodGetHandle;
private static RefMethod methodGetChunkAt;
private static RefMethod methodA;
private static RefMethod methodGetById;
private static RefMethod methodGetHandle;
private static RefMethod methodGetChunkAt;
private static RefMethod methodA;
private static RefMethod methodGetById;
public SetBlockFast() throws NoSuchMethodException {
methodGetHandle = classCraftWorld.getMethod("getHandle");

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import java.util.ArrayList;
@ -28,12 +49,13 @@ public class StringComparsion {
public Object getMatchObject() {
return this.bestMatchObject;
}
public String getBestMatch() {
return this.bestMatch;
}
public Object[] getBestMatchAdvanced() {
return new Object[] { this.match, this.bestMatch };
return new Object[]{this.match, this.bestMatch};
}
public static double compare(final String s1, final String s2) {

View File

@ -1,3 +1,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
/**
@ -9,8 +30,7 @@ public class StringWrapper {
/**
* Constructor
*
* @param value
* to wrap
* @param value to wrap
*/
public StringWrapper(final String value) {
this.value = value;
@ -19,8 +39,7 @@ public class StringWrapper {
/**
* Check if a wrapped string equals another one
*
* @param obj
* to compare
* @param obj to compare
* @return true if obj equals the stored value
*/
@Override

View File

@ -1,39 +1,60 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
* Minecraft 1.8 Title
*
* @version 1.0.3
* @author Maxim Van de Wynckel
* @version 1.0.3
*/
@SuppressWarnings("unused")
public class Title {
/* Title packet */
private Class<?> packetTitle;
private Class<?> packetTitle;
/* Title packet actions ENUM */
private Class<?> packetActions;
private Class<?> packetActions;
/* Chat serializer */
private Class<?> nmsChatSerializer;
private Class<?> nmsChatSerializer;
/* Title text and color */
private String title = "";
private ChatColor titleColor = ChatColor.WHITE;
private String title = "";
private ChatColor titleColor = ChatColor.WHITE;
/* Subtitle text and color */
private String subtitle = "";
private ChatColor subtitleColor = ChatColor.WHITE;
private String subtitle = "";
private ChatColor subtitleColor = ChatColor.WHITE;
/* Title timings */
private int fadeInTime = -1;
private int stayTime = -1;
private int fadeOutTime = -1;
private boolean ticks = false;
private int fadeInTime = -1;
private int stayTime = -1;
private int fadeOutTime = -1;
private boolean ticks = false;
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES;
@ -44,8 +65,7 @@ public class Title {
/**
* Create a new 1.8 title
*
* @param title
* Title
* @param title Title
*/
public Title(final String title) {
this.title = title;
@ -55,10 +75,8 @@ public class Title {
/**
* Create a new 1.8 title
*
* @param title
* Title text
* @param subtitle
* Subtitle text
* @param title Title text
* @param subtitle Subtitle text
*/
public Title(final String title, final String subtitle) {
this.title = title;
@ -69,16 +87,11 @@ public class Title {
/**
* Create a new 1.8 title
*
* @param title
* Title text
* @param subtitle
* Subtitle text
* @param fadeInTime
* Fade in time
* @param stayTime
* Stay on screen time
* @param fadeOutTime
* Fade out time
* @param title Title text
* @param subtitle Subtitle text
* @param fadeInTime Fade in time
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
public Title(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) {
this.title = title;
@ -101,8 +114,7 @@ public class Title {
/**
* Set the title color
*
* @param color
* Chat color
* @param color Chat color
*/
public void setTitleColor(final ChatColor color) {
this.titleColor = color;
@ -111,8 +123,7 @@ public class Title {
/**
* Set the subtitle color
*
* @param color
* Chat color
* @param color Chat color
*/
public void setSubtitleColor(final ChatColor color) {
this.subtitleColor = color;
@ -121,8 +132,7 @@ public class Title {
/**
* Set title fade in time
*
* @param time
* Time
* @param time Time
*/
public void setFadeInTime(final int time) {
this.fadeInTime = time;
@ -131,8 +141,7 @@ public class Title {
/**
* Set title fade out time
*
* @param time
* Time
* @param time Time
*/
public void setFadeOutTime(final int time) {
this.fadeOutTime = time;
@ -141,8 +150,7 @@ public class Title {
/**
* Set title stay time
*
* @param time
* Time
* @param time Time
*/
public void setStayTime(final int time) {
this.stayTime = time;
@ -165,8 +173,7 @@ public class Title {
/**
* Send the title to a player
*
* @param player
* Player
* @param player Player
*/
public void send(final Player player) {
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
@ -194,8 +201,7 @@ public class Title {
packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
}
catch (final Exception e) {
} catch (final Exception e) {
e.printStackTrace();
}
}
@ -213,8 +219,7 @@ public class Title {
/**
* Clear the title
*
* @param player
* Player
* @param player Player
*/
public void clearTitle(final Player player) {
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
@ -226,8 +231,7 @@ public class Title {
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
sendPacket.invoke(connection, packet);
}
catch (final Exception e) {
} catch (final Exception e) {
e.printStackTrace();
}
}
@ -236,8 +240,7 @@ public class Title {
/**
* Reset the title settings
*
* @param player
* Player
* @param player Player
*/
public void resetTitle(final Player player) {
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
@ -249,8 +252,7 @@ public class Title {
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
sendPacket.invoke(connection, packet);
}
catch (final Exception e) {
} catch (final Exception e) {
e.printStackTrace();
}
}
@ -259,8 +261,7 @@ public class Title {
/**
* Get the protocol version of the player
*
* @param player
* Player
* @param player Player
* @return Protocol version
*/
private int getProtocolVersion(final Player player) {
@ -272,8 +273,7 @@ public class Title {
version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
return version;
}
catch (final Exception ex) {
} catch (final Exception ex) {
// ex.printStackTrace(); <-- spammy console
}
return version;
@ -291,15 +291,13 @@ public class Title {
/**
* Get class by url
*
* @param namespace
* Namespace url
* @param namespace Namespace url
* @return Class
*/
private Class<?> getClass(final String namespace) {
try {
return Class.forName(namespace);
}
catch (final Exception e) {
} catch (final Exception e) {
return null;
}
}
@ -342,8 +340,7 @@ public class Title {
private Object getHandle(final Object obj) {
try {
return getMethod("getHandle", obj.getClass()).invoke(obj);
}
catch (final Exception e) {
} catch (final Exception e) {
e.printStackTrace();
return null;
}
@ -370,8 +367,7 @@ public class Title {
Class<?> clazz = null;
try {
clazz = Class.forName(fullName);
}
catch (final Exception e) {
} catch (final Exception e) {
e.printStackTrace();
}
return clazz;
@ -382,8 +378,7 @@ public class Title {
final Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field;
}
catch (final Exception e) {
} catch (final Exception e) {
e.printStackTrace();
return null;
}

View File

@ -1,19 +1,39 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot;
import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.intellectualcrafters.plot.uuid.NameFetcher;
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
import com.intellectualcrafters.plot.uuid.UUIDSaver;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;
/**
* This class can be used to efficiently translate UUIDs and names back and
@ -24,13 +44,13 @@ import com.intellectualcrafters.plot.uuid.UUIDSaver;
* - Read from (if onlinemode: mojang api) (else: playername hashing)
* All UUIDs/Usernames will be stored in a map (cache) until the server is
* restarted.
*
* <p/>
* You can use getUuidMap() to save the uuids/names to a file (SQLite db for
* example).
* Primary methods: getUUID(String name) & getName(UUID uuid) <-- You should
* ONLY use these.
* Call startFetch(JavaPlugin plugin) in your onEnable().
*
* <p/>
* Originally created by:
*
* @author Citymonstret
@ -44,7 +64,7 @@ public class UUIDHandler {
*
* @see org.bukkit.Server#getOnlineMode()
*/
private static boolean online = Bukkit.getServer().getOnlineMode();
private static boolean online = Bukkit.getServer().getOnlineMode();
/**
* Map containing names and UUID's
@ -63,8 +83,7 @@ public class UUIDHandler {
/**
* Check if a uuid is cached
*
* @param uuid
* to check
* @param uuid to check
* @return true of the uuid is cached
*/
public static boolean uuidExists(final UUID uuid) {
@ -74,8 +93,7 @@ public class UUIDHandler {
/**
* Check if a name is cached
*
* @param name
* to check
* @param name to check
* @return true of the name is cached
*/
public static boolean nameExists(final StringWrapper name) {
@ -85,10 +103,8 @@ public class UUIDHandler {
/**
* Add a set to the cache
*
* @param name
* to cache
* @param uuid
* to cache
* @param name to cache
* @param uuid to cache
*/
public static void add(final StringWrapper name, final UUID uuid) {
if (!uuidMap.containsKey(name) && !uuidMap.inverse().containsKey(uuid)) {
@ -97,8 +113,7 @@ public class UUIDHandler {
}
/**
* @param name
* to use as key
* @param name to use as key
* @return uuid
*/
public static UUID getUUID(final String name) {
@ -121,38 +136,32 @@ public class UUIDHandler {
}
try {
return PlotMain.getUUIDSaver().mojangUUID(name);
}
catch (final Exception e) {
} catch (final Exception e) {
try {
final UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name);
add(nameWrap, uuid);
}
catch (final Exception ex) {
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
else {
} else {
try {
final UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name);
add(nameWrap, uuid);
}
catch (final Exception ex) {
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
else {
} else {
return getUuidOfflineMode(nameWrap);
}
return null;
}
/**
* @param uuid
* to use as key
* @param uuid to use as key
* @return name (cache)
*/
private static StringWrapper loopSearch(final UUID uuid) {
@ -160,8 +169,7 @@ public class UUIDHandler {
}
/**
* @param uuid
* to use as key
* @param uuid to use as key
* @return Name
*/
public static String getName(final UUID uuid) {
@ -182,51 +190,43 @@ public class UUIDHandler {
name = fetcher.call().get(uuid);
add(new StringWrapper(name), uuid);
return name;
}
catch (final Exception ex) {
} catch (final Exception ex) {
ex.printStackTrace();
}
}
else {
} else {
try {
return PlotMain.getUUIDSaver().mojangName(uuid);
}
catch (final Exception e) {
} catch (final Exception e) {
try {
final NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid);
add(new StringWrapper(name), uuid);
return name;
}
catch (final Exception ex) {
} catch (final Exception ex) {
e.printStackTrace();
}
}
}
try {
return PlotMain.getUUIDSaver().mojangName(uuid);
}
catch (final Exception e) {
} catch (final Exception e) {
try {
final NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid);
add(new StringWrapper(name), uuid);
return name;
}
catch (final Exception ex) {
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
else {
} else {
return "unknown";
}
return "";
}
/**
* @param name
* to use as key
* @param name to use as key
* @return UUID (name hash)
*/
private static UUID getUuidOfflineMode(final StringWrapper name) {
@ -236,8 +236,7 @@ public class UUIDHandler {
}
/**
* @param uuid
* to use as key
* @param uuid to use as key
* @return String - name
*/
private static String getNameOnlinePlayer(final UUID uuid) {
@ -251,8 +250,7 @@ public class UUIDHandler {
}
/**
* @param uuid
* to use as key
* @param uuid to use as key
* @return String - name
*/
private static String getNameOfflinePlayer(final UUID uuid) {
@ -266,8 +264,7 @@ public class UUIDHandler {
}
/**
* @param name
* to use as key
* @param name to use as key
* @return UUID
*/
private static UUID getUuidOnlinePlayer(final StringWrapper name) {

View File

@ -1,16 +1,29 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = PlotAPI.java >> Generated by: Citymonstret at 2014-08-09 01:44
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.api;
import java.util.ArrayList;
import java.util.Set;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.SubCommand;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -18,33 +31,22 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.plot.AbstractFlag;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotManager;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SchematicHandler;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.SubCommand;
import java.util.ArrayList;
import java.util.Set;
/**
* The plotMain api class.
*
* @author Citymonstret, Empire92
*/
@SuppressWarnings({ "unused", "javadoc" })
@SuppressWarnings({"unused", "javadoc"})
public class PlotAPI {
private static PlotHelper plotHelper;
private static PlayerFunctions playerFunctions;
private static FlagManager flagManager;
private static PlotHelper plotHelper;
private static PlayerFunctions playerFunctions;
private static FlagManager flagManager;
private static SchematicHandler schematicHandler;
private static C c;
private static C c;
// Methods/fields in PlotMain class
@ -63,13 +65,13 @@ public class PlotAPI {
// PlotMain.updatePlot(plot);
// To access plotMain stuff.
private final PlotMain plotMain;
private final PlotMain plotMain;
// Reference
/**
* Admin Permission
*/
public static final String ADMIN_PERMISSION = "plots.admin";
public static final String ADMIN_PERMISSION = "plots.admin";
/**
* Get all plots
@ -93,39 +95,36 @@ public class PlotAPI {
/**
* Add a plotoworld
*
* @param world World Name
* @param plotWorld Plot World Object
* @param manager World Manager
* @see com.intellectualcrafters.plot.PlotMain#addPlotWorld(String,
* com.intellectualcrafters.plot.PlotWorld,
* com.intellectualcrafters.plot.PlotManager)
* @param world
* World Name
* @param plotWorld
* Plot World Object
* @param manager
* World Manager
* com.intellectualcrafters.plot.PlotWorld,
* com.intellectualcrafters.plot.PlotManager)
*/
public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) {
PlotMain.addPlotWorld(world, plotWorld, manager);
}
/**
* @see com.intellectualcrafters.plot.PlotMain#config
* @return main configuration
* @see com.intellectualcrafters.plot.PlotMain#config
*/
public YamlConfiguration getConfig() {
return PlotMain.config;
}
/**
* @see com.intellectualcrafters.plot.PlotMain#translations
* @return translation configuration
* @see com.intellectualcrafters.plot.PlotMain#translations
*/
public YamlConfiguration getTranslations() {
return PlotMain.translations;
}
/**
* @see com.intellectualcrafters.plot.PlotMain#storage
* @return storage configuration
* @see com.intellectualcrafters.plot.PlotMain#storage
*/
public YamlConfiguration getStorage() {
return PlotMain.storage;
@ -135,8 +134,7 @@ public class PlotAPI {
* Constructor. Insert any Plugin.
* (Optimally the plugin that is accessing the method)
*
* @param plugin
* Plugin used to access this method
* @param plugin Plugin used to access this method
*/
public PlotAPI(final JavaPlugin plugin) {
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
@ -226,10 +224,9 @@ public class PlotAPI {
* will need to downcast for the specific settings a Generator has. e.g.
* DefaultPlotWorld class implements PlotWorld
*
* @param world
* (to get settings of)
* @param world (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
* world world
*/
public PlotWorld getWorldSettings(final World world) {
return PlotMain.getWorldSettings(world);
@ -238,10 +235,9 @@ public class PlotAPI {
/**
* Get the settings for a world (settings bundled in PlotWorld class)
*
* @param world
* (to get settings of)
* @param world (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
* world world
*/
public PlotWorld getWorldSettings(final String world) {
return PlotMain.getWorldSettings(world);
@ -251,8 +247,7 @@ public class PlotAPI {
* Send a message to a player.
*
* @param player
* @param c
* (Caption)
* @param c (Caption)
*/
public void sendMessage(final Player player, final C c) {
PlayerFunctions.sendMessage(player, c);
@ -280,8 +275,7 @@ public class PlotAPI {
/**
* Send a message to the console
*
* @param c
* (Caption)
* @param c (Caption)
*/
public void sendConsoleMessage(final C c) {
sendConsoleMessage(c.s());
@ -350,10 +344,8 @@ public class PlotAPI {
/**
* Get all plots for the player
*
* @param plr
* to search for
* @param just_owner
* should we just search for owner? Or with rights?
* @param plr to search for
* @param just_owner should we just search for owner? Or with rights?
*/
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
final ArrayList<Plot> pPlots = new ArrayList<>();
@ -362,8 +354,7 @@ public class PlotAPI {
if ((plot.owner != null) && (plot.owner == plr.getUniqueId())) {
pPlots.add(plot);
}
}
else {
} else {
if (plot.hasRights(plr)) {
pPlots.add(plot);
}
@ -375,8 +366,7 @@ public class PlotAPI {
/**
* Get all plots for the world
*
* @param world
* to get plots of
* @param world to get plots of
* @return Plot[] - array of plot objects in world
*/
public Plot[] getPlots(final World world) {
@ -395,8 +385,7 @@ public class PlotAPI {
/**
* Get if plot world
*
* @param world
* (to check if plot world)
* @param world (to check if plot world)
* @return boolean (if plot world or not)
*/
public boolean isPlotWorld(final World world) {
@ -411,7 +400,7 @@ public class PlotAPI {
*/
public Location[] getLocations(final Plot p) {
final World world = Bukkit.getWorld(p.world);
return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id) };
return new Location[]{PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id)};
}
/**

View File

@ -1,27 +1,32 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Auto.java >> Generated by: Citymonstret at 2014-08-09 01:40
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
@SuppressWarnings("deprecation")
public class Auto extends SubCommand {
public Auto() {
@ -39,12 +44,10 @@ public class Auto extends SubCommand {
String schematic = "";
if (PlotMain.getPlotWorlds().length == 1) {
world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
}
else {
} else {
if (PlotMain.isPlotWorld(plr.getWorld())) {
world = plr.getWorld();
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
return false;
}
@ -64,15 +67,13 @@ public class Auto extends SubCommand {
if (args.length > 1) {
schematic = args[1];
}
}
catch (final Exception e) {
} catch (final Exception e) {
schematic = args[0];
// PlayerFunctions.sendMessage(plr,
// "&cError: Invalid size (X,Y)");
// return false;
}
}
else {
} else {
schematic = args[0];
// PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
// return false;
@ -124,14 +125,16 @@ public class Auto extends SubCommand {
}
Auto.lastPlot = getNextPlot(Auto.lastPlot, 1);
}
}
else {
final boolean claimed = true;
} else {
// FIXME: Not used
// TODO: Fix this!
// final boolean claimed = true;
while (!br) {
final PlotId start = getNextPlot(Auto.lastPlot, 1);
// FIXME: Wtf is going on here?
if (claimed) {
/*if (claimed) */
{
if ((PlotMain.getPlots(world).get(start) == null) || (PlotMain.getPlots(world).get(start).owner == null)) {
Auto.lastPlot = start;
continue;
@ -168,20 +171,16 @@ public class Auto extends SubCommand {
if (absX > absY) {
if (id.x > 0) {
return new PlotId(id.x, id.y + 1);
}
else {
} else {
return new PlotId(id.x, id.y - 1);
}
}
else if (absY > absX) {
} else if (absY > absX) {
if (id.y > 0) {
return new PlotId(id.x - 1, id.y);
}
else {
} else {
return new PlotId(id.x + 1, id.y);
}
}
else {
} else {
if (id.x.equals(id.y) && (id.x > 0)) {
return new PlotId(id.x, id.y + step);
}

View File

@ -1,28 +1,32 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SchematicHandler;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* @author Citymonstret
@ -40,17 +44,14 @@ public class Claim extends SubCommand {
schematic = args[0];
}
if (!PlayerFunctions.isInPlot(plr)) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
return true;
return sendMessage(plr, C.NOT_IN_PLOT);
}
if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions.getAllowedPlots(plr)) {
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
return true;
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (plot.hasOwner()) {
PlayerFunctions.sendMessage(plr, C.PLOT_IS_CLAIMED);
return false;
return sendMessage(plr, C.PLOT_IS_CLAIMED);
}
final PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
if (PlotMain.useEconomy && world.USE_ECONOMY) {
@ -58,8 +59,7 @@ public class Claim extends SubCommand {
if (cost > 0d) {
final Economy economy = PlotMain.economy;
if (economy.getBalance(plr) < cost) {
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
return true;
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
}
economy.withdrawPlayer(plr, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
@ -68,21 +68,15 @@ public class Claim extends SubCommand {
if (!schematic.equals("")) {
if (world.SCHEMATIC_CLAIM_SPECIFY) {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true;
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
}
if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
return true;
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
}
}
}
final boolean result = claimPlot(plr, plot, false, schematic);
if (result) {
PlayerFunctions.sendMessage(plr, C.PLOT_NOT_CLAIMED);
return false;
}
return true;
return !claimPlot(plr, plot, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
}
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
@ -107,8 +101,7 @@ public class Claim extends SubCommand {
SchematicHandler.Schematic sch;
if (schematic.equals("")) {
sch = SchematicHandler.getSchematic(world.SCHEMATIC_FILE);
}
else {
} else {
sch = SchematicHandler.getSchematic(schematic);
if (sch == null) {
sch = SchematicHandler.getSchematic(world.SCHEMATIC_FILE);

View File

@ -1,23 +1,32 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.entity.Player;
/**
* Created by Citymonstret on 2014-08-01.
*/
public class Clear extends SubCommand {
public Clear() {
@ -30,18 +39,16 @@ public class Clear extends SubCommand {
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
return false;
return sendMessage(plr, C.NOT_IN_PLOT);
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
return false;
return sendMessage(plr, C.UNLINK_REQUIRED);
}
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
return sendMessage(plr, C.NO_PLOT_PERMS);
}
assert plot != null;
plot.clear(plr);
return true;
}

View File

@ -1,17 +1,34 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import static com.intellectualcrafters.plot.PlotSelection.currentSelection;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotSelection;
import org.bukkit.entity.Player;
import static com.intellectualcrafters.plot.PlotSelection.currentSelection;
/**
* Created by Citymonstret on 2014-10-13.
*/
public class Clipboard extends SubCommand {
public Clipboard() {
@ -21,8 +38,7 @@ public class Clipboard extends SubCommand {
@Override
public boolean execute(final Player plr, final String... args) {
if (!currentSelection.containsKey(plr.getName())) {
sendMessage(plr, C.NO_CLIPBOARD);
return true;
return sendMessage(plr, C.NO_CLIPBOARD);
}
final PlotSelection selection = currentSelection.get(plr.getName());

View File

@ -1,10 +1,23 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Command.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
@ -118,11 +131,11 @@ public enum Command {
/**
*
*/
private String command;
private String command;
/**
*
*/
private String alias;
private String alias;
/**
*
*/

View File

@ -1,17 +1,28 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = CommandPermission.java >> Generated by: Citymonstret at 2014-08-09
* 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.entity.Player;
/**
* Created by Citymonstret on 2014-08-03.
@ -26,15 +37,15 @@ public class CommandPermission {
public String permission;
/**
* @param permission
* @param permission Command Permission
*/
public CommandPermission(final String permission) {
this.permission = permission.toLowerCase();
}
/**
* @param player
* @return
* @param player Does the player have the permission?
* @return true of player has the required permission node
*/
public boolean hasPermission(final Player player) {
return PlotMain.hasPermission(player, this.permission) || PlotMain.hasPermission(player, "plots.admin");

View File

@ -1,29 +1,34 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotComment;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc;
/**
* Created by Citymonstret on 2014-08-01.
*/
public class Comment extends SubCommand {
public Comment() {
@ -33,16 +38,14 @@ public class Comment extends SubCommand {
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
return false;
return sendMessage(plr, C.NOT_IN_PLOT);
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (!plot.hasOwner()) {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
return false;
return sendMessage(plr, C.NOT_IN_PLOT);
}
final List<String> recipients = Arrays.asList(new String[] { "admin", "owner", "helper", "trusted", "everyone" });
final List<String> recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone");
if ((args.length == 2) && recipients.contains(args[0].toLowerCase())) {
@ -54,13 +57,10 @@ public class Comment extends SubCommand {
DBFunc.setComment(plr.getWorld().getName(), plot, comment);
return true;
}
else {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase());
return false;
} else {
return sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase());
}
}
PlayerFunctions.sendMessage(plr, C.COMMENT_SYNTAX);
return false;
return sendMessage(plr, C.COMMENT_SYNTAX);
}
}

View File

@ -1,25 +1,29 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotSelection;
/**
* Created by Citymonstret on 2014-08-01.
*/
public class Copy extends SubCommand {
public Copy() {
@ -37,11 +41,11 @@ public class Copy extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
assert plot != null;
if (plot.settings.isMerged()) {
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
return false;
}
assert plot != null;
final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
final PlotSelection selection = new PlotSelection(size, plr.getWorld(), plot);
if (PlotSelection.currentSelection.containsKey(plr.getName())) {
@ -49,8 +53,6 @@ public class Copy extends SubCommand {
}
PlotSelection.currentSelection.put(plr.getName(), selection);
sendMessage(plr, C.CLIPBOARD_SET);
// section.paste(plr.getWorld(), PlotHelper.getPlot(plr.getWorld()zs,
// new PlotId(plot.getId().x + 1, plot.getId().y)));
return true;
}
}

View File

@ -1,45 +1,35 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Debug.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.Lag;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.RUtils;
/**
* @author Citymonstret \\SuperCharged Compiler made by Citymonstret\\
* ||#Compiler:ALPHA-1.0#########################
* ||#ST:Java(1.7.*)\impl(bukkit)->api(s[])######
* ||#Section:\Debug\############################
* ||##Debug->Debug.properties|Debug.txt#########
* ||############################################ ||#Signed
* By:Citymonstret@IC##################
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
*/
public class Debug extends SubCommand {
// private extends SubCommand^Implements {Command, Information} from
// >>\\S.txt6\\
public Debug() {
super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false);
{
/**
* This.
*/
}
}
@Override
@ -47,35 +37,23 @@ public class Debug extends SubCommand {
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
final StringBuilder msg = new StringBuilder();
for (final C c : C.values()) {
msg.append(c.s() + "\n");
msg.append(c.s()).append("\n");
}
PlayerFunctions.sendMessage(plr, msg.toString());
return true;
}
StringBuilder information;
String header, line, section;
/**
* {$notnull || compile:: \\Debug:Captions\\}
*/
{
information = new StringBuilder();
header = C.DEUBG_HEADER.s();
line = C.DEBUG_LINE.s();
section = C.DEBUG_SECTION.s();
}
/**
* {||direct:: load: debug::I>Captions::trsl} \\ if(missing)
* set(default) -> this->(){} \\ echo line->line(Compiler.cpp ->
* lineCompiler); when finished: now = this();
* now(getter)->setter(this())->{ "string" = getter(this);
* setter(string) = getter(this->setter); } when ^ finished compile;
* if(^compile failed -> |this->failed.|tests->failed.| ||run test
* {this->test}|on fail(action(){return FAILED})|
*/
{
final StringBuilder worlds = new StringBuilder("");
for (final String world : PlotMain.getPlotWorlds()) {
worlds.append(world + " ");
worlds.append(world).append(" ");
}
information.append(header);
information.append(getSection(section, "Lag / TPS"));
@ -85,8 +63,8 @@ public class Debug extends SubCommand {
information.append(getSection(section, "PlotWorld"));
information.append(getLine(line, "Plot Worlds", worlds));
information.append(getLine(line, "Owned Plots", PlotMain.getPlots().size()));
// information.append(getLine(line, "PlotWorld Size",
// PlotHelper.getWorldFolderSize() + "MB"));
//information.append(getLine(line, "PlotWorld Size",
//PlotHelper.getWorldFolderSize() + "MB"));
for (final String worldname : PlotMain.getPlotWorlds()) {
final World world = Bukkit.getWorld(worldname);
information.append(getLine(line, "World: " + world + " size", PlotHelper.getWorldFolderSize(world)));
@ -101,10 +79,6 @@ public class Debug extends SubCommand {
information.append(getLine(line, "Total Messages", C.values().length));
information.append(getLine(line, "View all captions", "/plot debug msg"));
}
/**
* {function:: SEND_MESSAGE |local player -> plr|local string ->
* information.toString())}
*/
{
PlayerFunctions.sendMessage(plr, information.toString());
}

View File

@ -1,16 +1,30 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.UUID;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@ -19,20 +33,8 @@ import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotManager;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.StringWrapper;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import java.util.ArrayList;
import java.util.UUID;
/**
* @author Citymonstret
@ -47,13 +49,11 @@ public class DebugClaimTest extends SubCommand {
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
if (args.length < 3) {
PlayerFunctions.sendMessage(plr, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
return false;
return !PlayerFunctions.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
}
final World world = Bukkit.getWorld(args[0]);
if ((world == null) || !PlotMain.isPlotWorld(world)) {
PlayerFunctions.sendMessage(plr, "&cInvalid plot world!");
return false;
return !PlayerFunctions.sendMessage(null, "&cInvalid plot world!");
}
PlotId min, max;
@ -64,24 +64,22 @@ public class DebugClaimTest extends SubCommand {
min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]));
max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1]));
} catch (final Exception e) {
return !PlayerFunctions.sendMessage(null, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area.");
}
catch (final Exception e) {
PlayerFunctions.sendMessage(plr, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area.");
return false;
}
PlayerFunctions.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
PlayerFunctions.sendMessage(plr, "&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: &7Beginning sign to plot conversion. This may take a while...");
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
final PlotManager manager = PlotMain.getPlotManager(world);
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
final ArrayList<Plot> plots = new ArrayList<Plot>();
final ArrayList<Plot> plots = new ArrayList<>();
for (final PlotId id : PlayerFunctions.getPlotSelectionIds(world, min, max)) {
final Plot plot = PlotHelper.getPlot(world, id);
final boolean contains = PlotMain.getPlots(world).containsKey(plot.id);
if (contains) {
PlayerFunctions.sendMessage(plr, " - &cDB Already contains: " + plot.id);
PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id);
continue;
}
@ -100,35 +98,32 @@ public class DebugClaimTest extends SubCommand {
if (block != null) {
if (block.getState() instanceof Sign) {
final Sign sign = (Sign) block.getState();
if (sign != null) {
String line = sign.getLine(2);
if ((line != null) && (line.length() > 2)) {
line = line.substring(2);
String line = sign.getLine(2);
if ((line != null) && (line.length() > 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) {
for (final StringWrapper string : map.keySet()) {
if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
uuid = map.get(string);
break;
}
if (uuid == null) {
for (final StringWrapper string : map.keySet()) {
if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
uuid = map.get(string);
break;
}
}
if (uuid == null) {
uuid = UUIDHandler.getUUID(line);
}
if (uuid != null) {
PlayerFunctions.sendMessage(plr, " - &aFound plot: " + plot.id + " : " + line);
plot.owner = uuid;
plot.hasChanged = true;
plots.add(plot);
}
else {
PlayerFunctions.sendMessage(plr, " - &cInvalid playername: " + plot.id + " : " + line);
}
}
if (uuid == null) {
uuid = UUIDHandler.getUUID(line);
}
if (uuid != null) {
PlayerFunctions.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
plot.owner = uuid;
plot.hasChanged = true;
plots.add(plot);
} else {
PlayerFunctions.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line);
}
}
}
@ -136,7 +131,7 @@ public class DebugClaimTest extends SubCommand {
}
if (plots.size() > 0) {
PlayerFunctions.sendMessage(plr, "&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.createAllSettingsAndHelpers(plots);
@ -144,25 +139,24 @@ public class DebugClaimTest extends SubCommand {
PlotMain.updatePlot(plot);
}
PlayerFunctions.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
PlayerFunctions.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
}
else {
PlayerFunctions.sendMessage(plr, "No plots were found for the given search.");
} else {
PlayerFunctions.sendMessage(null, "No plots were found for the given search.");
}
}
else {
} else {
PlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused.");
}
return true;
}
@SuppressWarnings("unused")
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
return claimPlot(player, plot, teleport, "");
}
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic) {
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {

View File

@ -1,20 +1,32 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.lang.reflect.Field;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
/**
* @author Citymonstret
@ -32,14 +44,12 @@ public class DebugLoadTest extends SubCommand {
final Field fPlots = PlotMain.class.getDeclaredField("plots");
fPlots.setAccessible(true);
fPlots.set(null, DBFunc.getPlots());
}
catch (final Exception e) {
} catch (final Exception e) {
PlotMain.sendConsoleSenderMessage("&3===FAILED&3===");
e.printStackTrace();
PlotMain.sendConsoleSenderMessage("&3===END OF STACKTRACE===");
}
}
else {
} else {
PlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused.");
}
return true;

View File

@ -1,21 +1,33 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.entity.Player;
import java.util.ArrayList;
/**
* @author Citymonstret
@ -33,8 +45,7 @@ public class DebugSaveTest extends SubCommand {
plots.addAll(PlotMain.getPlots());
DBFunc.createPlots(plots);
DBFunc.createAllSettingsAndHelpers(plots);
}
else {
} else {
PlayerFunctions.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused.");
}
return true;

View File

@ -1,27 +1,31 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Delete.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.database.DBFunc;
/**
* Created by Citymonstret on 2014-08-01.
*/
public class Delete extends SubCommand {
public Delete() {
@ -31,18 +35,16 @@ public class Delete extends SubCommand {
@Override
public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) {
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
return false;
return !sendMessage(plr, C.NOT_IN_PLOT);
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
return false;
return !sendMessage(plr, C.UNLINK_REQUIRED);
}
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
return !sendMessage(plr, C.NO_PLOT_PERMS);
}
assert plot != null;
final PlotWorld pWorld = PlotMain.getWorldSettings(plot.getWorld());
if (PlotMain.useEconomy && pWorld.USE_ECONOMY) {
final double c = pWorld.SELL_PRICE;
@ -59,8 +61,7 @@ public class Delete extends SubCommand {
if ((Math.abs(plot.id.x) <= Math.abs(Auto.lastPlot.x)) && (Math.abs(plot.id.y) <= Math.abs(Auto.lastPlot.y))) {
Auto.lastPlot = plot.id;
}
}
else {
} else {
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
}
return true;

View File

@ -1,28 +1,38 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Denied.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.UUID;
/**
* Created by Citymonstret on 2014-08-03.
*/
@SuppressWarnings("deprecated")
public class Denied extends SubCommand {
@ -50,8 +60,7 @@ public class Denied extends SubCommand {
if (args[1].equalsIgnoreCase("*")) {
uuid = DBFunc.everyone;
}
else {
} else {
uuid = UUIDHandler.getUUID(args[1]);
}
if (!plot.denied.contains(uuid)) {
@ -71,8 +80,7 @@ public class Denied extends SubCommand {
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
@ -85,8 +93,7 @@ public class Denied extends SubCommand {
}
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
return true;
}
else if (args[0].equalsIgnoreCase("remove")) {
} else if (args[0].equalsIgnoreCase("remove")) {
if (args[1].equalsIgnoreCase("*")) {
final UUID uuid = DBFunc.everyone;
if (!plot.denied.contains(uuid)) {
@ -116,8 +123,7 @@ public class Denied extends SubCommand {
final PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT);
return true;
}

View File

@ -1,24 +1,36 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Helpers.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.UUID;
@SuppressWarnings("deprecation")
public class Helpers extends SubCommand {
@ -46,8 +58,7 @@ public class Helpers extends SubCommand {
UUID uuid;
if (args[1].equalsIgnoreCase("*")) {
uuid = DBFunc.everyone;
}
else {
} else {
uuid = UUIDHandler.getUUID(args[1]);
}
if (!plot.helpers.contains(uuid)) {
@ -67,15 +78,13 @@ public class Helpers extends SubCommand {
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
return true;
}
else if (args[0].equalsIgnoreCase("remove")) {
} else if (args[0].equalsIgnoreCase("remove")) {
if (args[1].equalsIgnoreCase("*")) {
final UUID uuid = DBFunc.everyone;
if (!plot.helpers.contains(uuid)) {
@ -106,8 +115,7 @@ public class Helpers extends SubCommand {
final PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT);
return true;
}

View File

@ -1,19 +1,31 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Home.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.entity.Player;
/**
* @author Citymonstret
@ -39,16 +51,14 @@ public class Home extends SubCommand {
if (plots.length == 1) {
PlotMain.teleportPlayer(plr, plr.getLocation(), plots[0]);
return true;
}
else if (plots.length > 1) {
} else if (plots.length > 1) {
if (args.length < 1) {
args = new String[] { "1" };
args = new String[]{"1"};
}
int id = 0;
try {
id = Integer.parseInt(args[0]);
}
catch (final Exception e) {
} catch (final Exception e) {
Plot temp;
if ((temp = isAlias(args[0])) != null) {
if (temp.hasOwner()) {
@ -69,8 +79,7 @@ public class Home extends SubCommand {
}
PlotMain.teleportPlayer(plr, plr.getLocation(), plots[id - 1]);
return true;
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
return true;
}

View File

@ -1,28 +1,36 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotComment;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc;
/**
* Created by Citymonstret on 2014-08-01.
*/
@ -48,17 +56,13 @@ public class Inbox extends SubCommand {
final UUID uuid = plr.getUniqueId();
if (PlotMain.hasPermission(plr, "plots.admin")) {
tier = 0;
}
else if (plot.owner == uuid) {
} else if (plot.owner == uuid) {
tier = 1;
}
else if (plot.helpers.contains(uuid)) {
} else if (plot.helpers.contains(uuid)) {
tier = 2;
}
else if (plot.trusted.contains(uuid)) {
} else if (plot.trusted.contains(uuid)) {
tier = 3;
}
else {
} else {
tier = 4;
}
@ -67,8 +71,7 @@ public class Inbox extends SubCommand {
case "admin":
if (tier <= 0) {
tier = 0;
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
return false;
}
@ -76,8 +79,7 @@ public class Inbox extends SubCommand {
case "owner":
if (tier <= 1) {
tier = 1;
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
return false;
}
@ -85,8 +87,7 @@ public class Inbox extends SubCommand {
case "helper":
if (tier <= 2) {
tier = 2;
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
return false;
}
@ -94,8 +95,7 @@ public class Inbox extends SubCommand {
case "trusted":
if (tier <= 3) {
tier = 3;
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
return false;
}
@ -103,14 +103,13 @@ public class Inbox extends SubCommand {
case "everyone":
if (tier <= 4) {
tier = 4;
}
else {
} else {
PlayerFunctions.sendMessage(plr, C.NO_PERM_INBOX);
return false;
}
break;
case "default":
PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, tier, 4));
PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[]{"admin", "owner", "helper", "trusted", "everyone"}, tier, 4));
return false;
}
}
@ -138,11 +137,10 @@ public class Inbox extends SubCommand {
final int index = Integer.parseInt(split[1]);
final PlotComment comment = comments.get(index - 1);
DBFunc.removeComment(world, plot, comment);
plot.settings.removeComment(comment);
plot.settings.removeComment(comment);
PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "1 comment");
return;
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]");
return;
}
@ -153,9 +151,8 @@ public class Inbox extends SubCommand {
plot.settings.removeComments(comments);
PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category");
return;
}
else {
final List<String> recipients = Arrays.asList(new String[] { "A", "O", "H", "T", "E" });
} else {
final List<String> recipients = Arrays.asList(new String[]{"A", "O", "H", "T", "E"});
int count = 1;
final StringBuilder message = new StringBuilder();
String prefix = "";

View File

@ -1,16 +1,28 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Info.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.UUID;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -18,15 +30,8 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import java.util.ArrayList;
import java.util.UUID;
/**
* @author Citymonstret
@ -48,8 +53,7 @@ public class Info extends SubCommand {
return false;
}
plot = PlayerFunctions.getCurrentPlot(player);
}
else {
} else {
if (args.length < 2) {
PlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE);
return false;
@ -69,13 +73,11 @@ public class Info extends SubCommand {
}
world = Bukkit.getWorld(args[0]);
if (args.length == 3) {
args = new String[] { args[2] };
}
else {
args = new String[]{args[2]};
} else {
args = new String[0];
}
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE);
return false;
}
@ -89,14 +91,12 @@ public class Info extends SubCommand {
{
if (plot.helpers == null) {
containsEveryone = false;
}
else {
} else {
containsEveryone = plot.helpers.contains(DBFunc.everyone);
}
if (plot.trusted == null) {
trustedEveryone = false;
}
else {
} else {
trustedEveryone = plot.trusted.contains(DBFunc.everyone);
}
}
@ -205,8 +205,7 @@ public class Info extends SubCommand {
for (int x = 0; x < l.size(); x++) {
if ((x + 1) == l.size()) {
list.append(c.replace("%user%", getPlayerName(l.get(x))).replace(",", ""));
}
else {
} else {
list.append(c.replace("%user%", getPlayerName(l.get(x))));
}
}

View File

@ -1,15 +1,26 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Inventory.java >> Generated by: Citymonstret at 2014-08-10 13:57
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -17,6 +28,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
public class Inventory extends SubCommand {
public Inventory() {

View File

@ -1,20 +1,32 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Kick.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Created by Citymonstret on 2014-08-01.

View File

@ -1,10 +1,23 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = MainCommand.java >> Generated by: Citymonstret at 2014-08-09 01:42
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
@ -34,9 +47,9 @@ public class MainCommand implements CommandExecutor, TabCompleter {
public static final String
MAIN_PERMISSION = "plots.use";
private static SubCommand[] _subCommands = new SubCommand[] { 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 Setup(), new DebugClaimTest(), new Inbox(), new Comment(), new Swap(), new MusicSubcommand() };
private static SubCommand[] _subCommands = new SubCommand[]{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 Setup(), new DebugClaimTest(), new Inbox(), new Comment(), new Swap(), new MusicSubcommand()};
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
{
addAll(Arrays.asList(_subCommands));
}
@ -83,15 +96,14 @@ public class MainCommand implements CommandExecutor, TabCompleter {
int page = 0;
boolean digit = true;
String arg2;
if (args.length>2) {
if (args.length > 2) {
arg2 = args[2];
}
else {
} else {
arg2 = "1";
}
for (final char c : arg2.toCharArray()) {
if (!Character.isDigit(c)) {
digit = false;
@ -110,8 +122,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
}
return PlayerFunctions.sendMessage(player, help.toString());
}
else {
} else {
for (final SubCommand command : subCommands) {
if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.equalsIgnoreCase(args[0])) {
final String[] arguments = new String[args.length - 1];
@ -119,12 +130,10 @@ public class MainCommand implements CommandExecutor, TabCompleter {
if (command.permission.hasPermission(player)) {
if ((player != null) || !command.isPlayer) {
return command.execute(player, arguments);
}
else {
} else {
return !PlayerFunctions.sendMessage(null, C.IS_CONSOLE);
}
}
else {
} else {
return no_permission(player, command.permission.permission.toLowerCase());
}
}
@ -146,7 +155,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
public static List<SubCommand> getCommands(final SubCommand.CommandCategory category, final Player player) {
final List<SubCommand> cmds = new ArrayList<>();
for (final SubCommand c : subCommands) {
if ((c.category == category) && c.permission.hasPermission(player)) {
if ((c.category.equals(category)) && c.permission.hasPermission(player)) {
cmds.add(c);
}
}
@ -224,8 +233,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
if (cmd.permission.hasPermission(player)) {
if (cmd.cmd.startsWith(arg)) {
tabOptions.add(cmd.cmd);
}
else if (cmd.alias.startsWith(arg)) {
} else if (cmd.alias.startsWith(arg)) {
tabOptions.add(cmd.alias);
}
}

View File

@ -1,39 +1,43 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Merge.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.events.PlotMergeEvent;
import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SetBlockFast;
import com.intellectualcrafters.plot.events.PlotMergeEvent;
import java.util.ArrayList;
/**
* @author Citymonstret
*/
public class Merge extends SubCommand {
public static String[] values = new String[] { "north", "east", "south", "west" };
public static String[] aliases = new String[] { "n", "e", "s", "w" };
public static String[] values = new String[]{"north", "east", "south", "west"};
public static String[] aliases = new String[]{"n", "e", "s", "w"};
public Merge() {
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true);

View File

@ -1,17 +1,37 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import java.util.Arrays;
public class MusicSubcommand extends SubCommand {
public MusicSubcommand() {

View File

@ -1,14 +1,29 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotSelection;
/**
* Created by Citymonstret on 2014-10-12.
*/
@ -44,8 +59,7 @@ public class Paste extends SubCommand {
}
selection.paste(plr.getWorld(), plot);
sendMessage(plr, C.PASTED);
}
else {
} else {
sendMessage(plr, C.NO_CLIPBOARD);
return false;
}

View File

@ -1,21 +1,32 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Purge.java >> Generated by: Citymonstret at 2014-08-09 01:42
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.entity.Player;
/**
* @Deprecated
@ -50,8 +61,7 @@ public class Purge extends SubCommand {
DBFunc.purge(world, id);
PlayerFunctions.sendMessage(plr, "&aPurge of '" + args[0] + "' was successful!");
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
}
}
@ -59,7 +69,7 @@ public class Purge extends SubCommand {
return false;
}
if (args[1].equals("-o")) {
if (PlotMain.getPlots(args[0])==null) {
if (PlotMain.getPlots(args[0]) == null) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
return false;
}
@ -67,8 +77,7 @@ public class Purge extends SubCommand {
DBFunc.purge(args[0]);
PlayerFunctions.sendMessage(plr, (C.PURGE_SUCCESS));
return true;
}
else {
} else {
PlayerFunctions.sendMessage(plr, "This is a dangerous command, if you are sure, use /plot purge {world} -o");
return false;
}

View File

@ -1,10 +1,30 @@
package com.intellectualcrafters.plot.commands;
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
import org.bukkit.entity.Player;
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import org.bukkit.entity.Player;
/**
* Created by Citymonstret on 2014-10-02.
@ -64,8 +84,7 @@ public class Rate extends SubCommand {
final boolean success = false;
if (success) {
sendMessage(plr, C.RATING_APPLIED, plot.getId().toString());
}
else {
} else {
sendMessage(plr, C.COMMAND_WENT_WRONG);
}
return true;

View File

@ -1,19 +1,31 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Reload.java >> Generated by: Citymonstret at 2014-08-09 01:42
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import org.bukkit.entity.Player;
/**
* @Deprecated
@ -40,8 +52,7 @@ public class Reload extends SubCommand {
plotworld.loadDefaultConfiguration(PlotMain.config.getConfigurationSection("worlds." + pw));
}
PlotMain.BroadcastWithPerms(C.RELOADED_CONFIGS);
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.RELOAD_FAILED);
}
return true;

View File

@ -1,26 +1,37 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.HashMap;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.SchematicHandler.DataCollection;
import com.intellectualcrafters.plot.SchematicHandler.Dimension;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.SchematicHandler;
import com.intellectualcrafters.plot.SchematicHandler.DataCollection;
import com.intellectualcrafters.plot.SchematicHandler.Dimension;
import com.intellectualcrafters.plot.SetBlockFast;
import com.intellectualcrafters.plot.Settings;
import com.intellectualcrafters.plot.UUIDHandler;
import java.util.HashMap;
public class Schematic extends SubCommand {
@ -30,10 +41,10 @@ public class Schematic extends SubCommand {
// TODO command to fetch schematic from worldedit directory
}
private int counter = 0;
private int counter = 0;
private boolean running = false;
private Plot[] plots;
private int task;
private Plot[] plots;
private int task;
@Override
public boolean execute(final Player plr, final String... args) {
@ -98,8 +109,7 @@ public class Schematic extends SubCommand {
final Location loc = plr.getLocation();
x = Math.min(length2 - dem.getX(), loc.getBlockX() - bot.getBlockX());
z = Math.min(length2 - dem.getZ(), loc.getBlockZ() - bot.getBlockZ());
}
else {
} else {
x = 0;
z = 0;
}
@ -215,8 +225,7 @@ public class Schematic extends SubCommand {
final String owner = o == null ? "unknown" : o;
if (sch == null) {
PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c" + plot.id);
}
else {
} else {
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() {
@Override
public void run() {
@ -224,8 +233,7 @@ public class Schematic extends SubCommand {
final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + worldname + "," + owner + ".schematic");
if (!result) {
PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c" + plot.id);
}
else {
} else {
PlayerFunctions.sendMessage(plr, "&7 - &aExport success: " + plot.id);
}
}
@ -259,8 +267,7 @@ public class Schematic extends SubCommand {
}
p2 = myplot;
world = plr.getWorld().getName();
}
else {
} else {
if (args.length == 3) {
try {
world = args[0];
@ -271,13 +278,11 @@ public class Schematic extends SubCommand {
return false;
}
p2 = PlotMain.getPlots(world).get(i);
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
return false;
}
}
else {
} else {
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
return false;
}
@ -285,7 +290,7 @@ public class Schematic extends SubCommand {
final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
this.plots = new Plot[] { p2 };
this.plots = new Plot[]{p2};
this.running = true;
this.counter = 0;
@ -304,8 +309,7 @@ public class Schematic extends SubCommand {
final String owner = o == null ? "unknown" : o;
if (sch == null) {
PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c" + plot.id);
}
else {
} else {
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() {
@Override
public void run() {
@ -313,8 +317,7 @@ public class Schematic extends SubCommand {
final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + world + "," + owner.trim() + ".schematic");
if (!result) {
PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c" + plot.id);
}
else {
} else {
PlayerFunctions.sendMessage(plr, "&7 - &aExport success: " + plot.id);
}
}

View File

@ -1,17 +1,31 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Set.java >> Generated by: Citymonstret at 2014-08-09 01:42
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
import com.intellectualcrafters.plot.listeners.PlotListener;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -19,22 +33,9 @@ import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.AbstractFlag;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.Flag;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotBlock;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotHomePosition;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.StringComparsion;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
import com.intellectualcrafters.plot.listeners.PlotListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Citymonstret
@ -45,8 +46,8 @@ public class Set extends SubCommand {
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true);
}
public static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "flag" };
public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" };
public static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"};
public static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
@SuppressWarnings("deprecation")
@Override
@ -92,8 +93,7 @@ public class Set extends SubCommand {
if (PlotMain.worldGuardListener != null) {
if (message.equals("")) {
message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
}
else {
} else {
message += "," + StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
}
}
@ -105,8 +105,7 @@ public class Set extends SubCommand {
try {
af = FlagManager.getFlag(args[1].toLowerCase());
}
catch (final Exception e) {
} catch (final Exception e) {
af = new AbstractFlag(args[1].toLowerCase());
}
@ -174,8 +173,7 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
PlotListener.plotEntry(plr, plot);
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, "&c" + e.getMessage());
return false;
}
@ -265,8 +263,7 @@ public class Set extends SubCommand {
Material material;
try {
material = getMaterial(args[1], PlotWorld.BLOCKS);
}
catch (NullPointerException e) {
} catch (NullPointerException e) {
material = null;
}
/*
@ -286,8 +283,7 @@ public class Set extends SubCommand {
if (args.length > 2) {
try {
data = (byte) Integer.parseInt(args[2]);
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
return true;
}
@ -343,12 +339,10 @@ public class Set extends SubCommand {
if (ss.length == 1) {
blocks[index] = new PlotBlock((short) m.getId(), (byte) 0);
}
else {
} else {
try {
b = (byte) Integer.parseInt(ss[1]);
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
return true;
}
@ -392,8 +386,7 @@ public class Set extends SubCommand {
if (args.length > 2) {
try {
data = (byte) Integer.parseInt(args[2]);
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
return true;
}
@ -405,8 +398,7 @@ public class Set extends SubCommand {
AbstractFlag af = new AbstractFlag("");
try {
af = new AbstractFlag(args[0].toLowerCase());
}
catch (final Exception e) {
} catch (final Exception e) {
}
if (FlagManager.getFlags().contains(af)) {
final StringBuilder a = new StringBuilder();

View File

@ -1,23 +1,31 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = SetOwner.java >> Generated by: Citymonstret at 2014-08-09 01:42
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import java.util.UUID;
@SuppressWarnings("deprecation")
public class SetOwner extends SubCommand {

View File

@ -1,10 +1,28 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
@ -14,13 +32,10 @@ import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.ConfigurationNode;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotGenerator;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Citymonstret on 2014-09-26.
@ -30,9 +45,9 @@ public class Setup extends SubCommand implements Listener {
public static Map<String, SetupObject> setupMap = new HashMap<>();
private class SetupObject {
String world;
String plugin;
int current = 0;
String world;
String plugin;
int current = 0;
ConfigurationNode[] step;
@ -61,8 +76,7 @@ public class Setup extends SubCommand implements Listener {
if (plr == null) {
plrname = "";
}
else {
} else {
plrname = plr.getName();
}
@ -76,20 +90,17 @@ public class Setup extends SubCommand implements Listener {
}
try {
PlotMain.config.save(PlotMain.configFile);
}
catch (final IOException e) {
} catch (final IOException e) {
e.printStackTrace();
}
// Creating the worlds
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.plugin);
}
else {
} else {
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.plugin);
}
else {
} else {
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (plugin.isEnabled()) {
if (plugin.getDefaultWorldGenerator("world", "") != null) {
@ -117,8 +128,7 @@ public class Setup extends SubCommand implements Listener {
if (args.length < 1) {
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return true;
}
else {
} else {
if (args[0].equalsIgnoreCase("cancel")) {
setupMap.remove(plrname);
PlayerFunctions.sendMessage(plr, "&cCancelled setup.");
@ -130,8 +140,7 @@ public class Setup extends SubCommand implements Listener {
step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return true;
}
else {
} else {
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return true;
}
@ -148,15 +157,13 @@ public class Setup extends SubCommand implements Listener {
step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return true;
}
else {
} else {
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
return true;
}
}
}
else {
} else {
if (args.length < 1) {
sendMessage(plr, C.SETUP_MISSING_WORLD);
return true;
@ -200,8 +207,7 @@ public class Setup extends SubCommand implements Listener {
PlotWorld plotworld;
if (generator instanceof PlotGenerator) {
plotworld = ((PlotGenerator) generator).getNewPlotWorld(world);
}
else {
} else {
plotworld = new DefaultPlotWorld(world);
}

View File

@ -1,17 +1,29 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = SubCommand.java >> Generated by: Citymonstret at 2014-08-09 01:42
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import org.bukkit.entity.Player;
/**
* SubCommand class
@ -19,11 +31,11 @@ import com.intellectualcrafters.plot.PlayerFunctions;
* @author Citymonstret
*/
public abstract class SubCommand {
public boolean isPlayer;
public boolean isPlayer;
/**
* Command
*/
public String cmd;
public String cmd;
/**
* Permission node
*/
@ -31,32 +43,26 @@ public abstract class SubCommand {
/**
* Simple description
*/
public String description;
public String description;
/**
* Alias
*/
public String alias;
public String alias;
/**
* Command usage
*/
public String usage;
public String usage;
public CommandCategory category;
public CommandCategory category;
/**
* @param cmd
* Command /plot {cmd} <-- That!
* @param permission
* Permission Node
* @param description
* Simple description
* @param usage
* Usage description: /plot command {args...}
* @param alias
* Command alias
* @param category
* CommandCategory. Pick whichever closests to what you want.
* @param cmd Command /plot {cmd} <-- That!
* @param permission Permission Node
* @param description Simple description
* @param usage Usage description: /plot command {args...}
* @param alias Command alias
* @param category CommandCategory. Pick whichever closests to what you want.
*/
public SubCommand(final String cmd, final String permission, final String description, final String usage, final String alias, final CommandCategory category, final boolean isPlayer) {
this.cmd = cmd;
@ -69,14 +75,10 @@ public abstract class SubCommand {
}
/**
* @param command
* Command /plot {cmd} <-- That!
* @param description
* Simple description
* @param usage
* Usage description: /plot command {args...}
* @param category
* CommandCategory. Pick whichever closests to what you want.
* @param command Command /plot {cmd} <-- That!
* @param description Simple description
* @param usage Usage description: /plot command {args...}
* @param category CommandCategory. Pick whichever closests to what you want.
*/
public SubCommand(final Command command, final String description, final String usage, final CommandCategory category, final boolean isPlayer) {
this.cmd = command.getCommand();
@ -91,10 +93,8 @@ public abstract class SubCommand {
/**
* Execute.
*
* @param plr
* executor
* @param args
* arguments
* @param plr executor
* @param args arguments
* @return true on success, false on failure
*/
public abstract boolean execute(final Player plr, final String... args);
@ -110,8 +110,9 @@ public abstract class SubCommand {
* @param c
* @param args
*/
public void sendMessage(final Player plr, final C c, final String... args) {
public boolean sendMessage(final Player plr, final C c, final String... args) {
PlayerFunctions.sendMessage(plr, c, args);
return true;
}
public enum CommandCategory {

View File

@ -1,25 +1,30 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotSelection;
import com.intellectualcrafters.plot.SetBlockFast;
/**
* Created by Citymonstret on 2014-08-01.
*/
@ -59,8 +64,7 @@ public class Swap extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString());
return false;
}
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX);
return false;

View File

@ -1,25 +1,32 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = TP.java >> Generated by: Citymonstret at 2014-08-09 01:42
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
/**
* @author Citymonstret
*/
@ -57,8 +64,7 @@ public class TP extends SubCommand {
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
PlotMain.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
return true;
}
catch (final Exception e) {
} catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
}
return false;

Some files were not shown because too many files have changed in this diff Show More