Code cleanup and Optimizations

This commit is contained in:
MattBDev 2016-03-29 00:56:44 -04:00
parent 49d18b9229
commit 32ba55baf5
34 changed files with 456 additions and 540 deletions

View File

@ -39,19 +39,20 @@ import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* PlotSquared API<br> * PlotSquared API.
* <br> * <br>
* @version API 3.3.1 * @version API 3.3.1
* <br> * <br>
@ -95,7 +96,7 @@ public class PlotAPI {
} }
/** /**
* Get all plots * Get all plots.
* *
* @return all plots * @return all plots
* *
@ -106,7 +107,7 @@ public class PlotAPI {
} }
/** /**
* Return all plots for a player * Return all plots for a player.
* *
* @param player Player, whose plots to search for * @param player Player, whose plots to search for
* *
@ -117,7 +118,7 @@ public class PlotAPI {
} }
/** /**
* Add a plot world * Add a plot world.
* *
* @param plotArea Plot World Object * @param plotArea Plot World Object
* @see PS#addPlotArea(PlotArea) * @see PS#addPlotArea(PlotArea)
@ -491,7 +492,7 @@ public class PlotAPI {
*/ */
@Deprecated @Deprecated
public boolean hasPlot(World world, Player player) { public boolean hasPlot(World world, Player player) {
return getPlots(world, player, true) != null && getPlots(world, player, true).length > 0; return getPlots(world, player, true).length > 0;
} }
/** /**
@ -510,10 +511,8 @@ public class PlotAPI {
if (plot.hasOwner() && plot.isOwner(uuid)) { if (plot.hasOwner() && plot.isOwner(uuid)) {
pPlots.add(plot); pPlots.add(plot);
} }
} else { } else if (plot.isAdded(uuid)) {
if (plot.isAdded(uuid)) { pPlots.add(plot);
pPlots.add(plot);
}
} }
} }
return pPlots.toArray(new Plot[pPlots.size()]); return pPlots.toArray(new Plot[pPlots.size()]);

View File

@ -14,10 +14,10 @@ import java.util.Map;
*/ */
final class JsonString implements JsonRepresentedObject, ConfigurationSerializable { final class JsonString implements JsonRepresentedObject, ConfigurationSerializable {
private final String _value; private final String value;
public JsonString(CharSequence value) { public JsonString(CharSequence value) {
this._value = value == null ? null : value.toString(); this.value = value == null ? null : value.toString();
} }
public static JsonString deserialize(Map<String, Object> map) { public static JsonString deserialize(Map<String, Object> map) {
@ -30,18 +30,18 @@ final class JsonString implements JsonRepresentedObject, ConfigurationSerializab
} }
public String getValue() { public String getValue() {
return this._value; return this.value;
} }
@Override @Override
public Map<String, Object> serialize() { public Map<String, Object> serialize() {
HashMap<String, Object> theSingleValue = new HashMap<>(); HashMap<String, Object> theSingleValue = new HashMap<>();
theSingleValue.put("stringValue", this._value); theSingleValue.put("stringValue", this.value);
return theSingleValue; return theSingleValue;
} }
@Override @Override
public String toString() { public String toString() {
return this._value; return this.value;
} }
} }

View File

@ -835,14 +835,14 @@ public class PlayerEvents extends PlotListener implements Listener {
public void onChange(BlockFromToEvent e) { public void onChange(BlockFromToEvent e) {
Block from = e.getBlock(); Block from = e.getBlock();
Block to = e.getToBlock(); Block to = e.getToBlock();
Location tloc = BukkitUtil.getLocation(to.getLocation()); Location tLocation = BukkitUtil.getLocation(to.getLocation());
PlotArea area = tloc.getPlotArea(); PlotArea area = tLocation.getPlotArea();
if (area == null) { if (area == null) {
return; return;
} }
Plot plot = area.getOwnedPlot(tloc); Plot plot = area.getOwnedPlot(tLocation);
Location floc = BukkitUtil.getLocation(from.getLocation()); Location fLocation = BukkitUtil.getLocation(from.getLocation());
if (!area.contains(floc.getX(), floc.getZ()) || !Objects.equals(plot, area.getOwnedPlot(floc)) || (plot != null && FlagManager if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation)) || (plot != null && FlagManager
.isPlotFlagTrue(plot, "disable-physics"))) { .isPlotFlagTrue(plot, "disable-physics"))) {
e.setCancelled(true); e.setCancelled(true);
} }

View File

@ -40,10 +40,9 @@ public class DefaultTitleManager {
private boolean ticks = false; private boolean ticks = false;
/** /**
* Create a new 1.8 title * Create a new 1.8 title.
* *
* @param title * @param title Title
* Title
* @throws ClassNotFoundException * @throws ClassNotFoundException
*/ */
public DefaultTitleManager(String title) throws ClassNotFoundException { public DefaultTitleManager(String title) throws ClassNotFoundException {
@ -52,12 +51,10 @@ public class DefaultTitleManager {
} }
/** /**
* Create a new 1.8 title * Create a new 1.8 title.
* *
* @param title * @param title Title text
* Title text * @param subtitle Subtitle text
* @param subtitle
* Subtitle text
* @throws ClassNotFoundException * @throws ClassNotFoundException
*/ */
public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException { public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException {
@ -118,8 +115,7 @@ public class DefaultTitleManager {
} }
/** /**
* Load spigot and NMS classes * Load spigot and NMS classes.
* @throws ClassNotFoundException
*/ */
private void loadClasses() { private void loadClasses() {
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle"); this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
@ -129,7 +125,7 @@ public class DefaultTitleManager {
} }
/** /**
* Get title text * Get title text.
* *
* @return Title text * @return Title text
*/ */
@ -138,17 +134,16 @@ public class DefaultTitleManager {
} }
/** /**
* Set title text * Set title text.
* *
* @param title * @param title Title
* Title
*/ */
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
/** /**
* Get subtitle text * Get subtitle text.
* *
* @return Subtitle text * @return Subtitle text
*/ */

View File

@ -6,7 +6,6 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -53,12 +52,10 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Create a new 1.8 title * Create a new 1.8 title.
* *
* @param title * @param title Title text
* Title text * @param subtitle Subtitle text
* @param subtitle
* Subtitle text
* @throws ClassNotFoundException * @throws ClassNotFoundException
*/ */
public DefaultTitleManager_183(String title, String subtitle) throws ClassNotFoundException { public DefaultTitleManager_183(String title, String subtitle) throws ClassNotFoundException {
@ -68,10 +65,9 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Copy 1.8 title * Copy 1.8 title.
* *
* @param title * @param title Title
* Title
* @throws ClassNotFoundException * @throws ClassNotFoundException
*/ */
public DefaultTitleManager_183(DefaultTitleManager_183 title) throws ClassNotFoundException { public DefaultTitleManager_183(DefaultTitleManager_183 title) throws ClassNotFoundException {
@ -88,18 +84,13 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Create a new 1.8 title * Create a new 1.8 title.
* *
* @param title * @param title Title text
* Title text * @param subtitle Subtitle text
* @param subtitle * @param fadeInTime Fade in time
* Subtitle text * @param stayTime Stay on screen time
* @param fadeInTime * @param fadeOutTime Fade out time
* Fade in time
* @param stayTime
* Stay on screen time
* @param fadeOutTime
* Fade out time
* @throws ClassNotFoundException * @throws ClassNotFoundException
*/ */
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException { public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException {
@ -124,8 +115,7 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Load spigot and NMS classes * Load spigot and NMS classes.
* @throws ClassNotFoundException
*/ */
private void loadClasses() { private void loadClasses() {
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle"); this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
@ -136,7 +126,7 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Get title text * Get title text.
* *
* @return Title text * @return Title text
*/ */
@ -145,17 +135,16 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Set title text * Set title text.
* *
* @param title * @param title Title
* Title
*/ */
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
/** /**
* Get subtitle text * Get subtitle text.
* *
* @return Subtitle text * @return Subtitle text
*/ */
@ -164,37 +153,34 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Set subtitle text * Set subtitle text.
* *
* @param subtitle * @param subtitle Subtitle text
* Subtitle text
*/ */
public void setSubtitle(String subtitle) { public void setSubtitle(String subtitle) {
this.subtitle = subtitle; this.subtitle = subtitle;
} }
/** /**
* Set the title color * Set the title color.
* *
* @param color * @param color Chat color
* Chat color
*/ */
public void setTitleColor(ChatColor color) { public void setTitleColor(ChatColor color) {
this.titleColor = color; this.titleColor = color;
} }
/** /**
* Set the subtitle color * Set the subtitle color.
* *
* @param color * @param color Chat color
* Chat color
*/ */
public void setSubtitleColor(ChatColor color) { public void setSubtitleColor(ChatColor color) {
this.subtitleColor = color; this.subtitleColor = color;
} }
/** /**
* Set title fade in time * Set title fade in time.
* *
* @param time * @param time
* Time * Time
@ -204,47 +190,42 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Set title fade out time * Set title fade out time.
* *
* @param time * @param time Time
* Time
*/ */
public void setFadeOutTime(int time) { public void setFadeOutTime(int time) {
this.fadeOutTime = time; this.fadeOutTime = time;
} }
/** /**
* Set title stay time * Set title stay time.
* *
* @param time * @param time Time
* Time
*/ */
public void setStayTime(int time) { public void setStayTime(int time) {
this.stayTime = time; this.stayTime = time;
} }
/** /**
* Set timings to ticks * Set timings to ticks.
*/ */
public void setTimingsToTicks() { public void setTimingsToTicks() {
this.ticks = true; this.ticks = true;
} }
/** /**
* Set timings to seconds * Set timings to seconds.
*/ */
public void setTimingsToSeconds() { public void setTimingsToSeconds() {
this.ticks = false; this.ticks = false;
} }
/** /**
* Send the title to a player * Send the title to a player.
* *
* @param player * @param player Player
* Player * @throws Exception
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/ */
public void send(Player player) throws Exception { public void send(Player player) throws Exception {
if (this.packetTitle != null) { if (this.packetTitle != null) {
@ -258,11 +239,7 @@ public class DefaultTitleManager_183 {
Object packet = this.packetTitle Object packet = this.packetTitle
.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE) .getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
.newInstance(actions[2], null, .newInstance(actions[2], null,
this.fadeInTime * (this.ticks ? 1 : 20),
this.fadeInTime * (
this.ticks ? 1 : 20),
this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20)); this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set // Send if set
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) { if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
@ -285,7 +262,7 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Broadcast the title to all players * Broadcast the title to all players.
* @throws Exception * @throws Exception
*/ */
public void broadcast() throws Exception { public void broadcast() throws Exception {
@ -295,12 +272,10 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Clear the title * Clear the title.
* *
* @param player * @param player Player
* Player * @throws Exception
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/ */
public void clearTitle(Player player) throws Exception { public void clearTitle(Player player) throws Exception {
// Send timings first // Send timings first
@ -313,16 +288,10 @@ public class DefaultTitleManager_183 {
} }
/** /**
* Reset the title settings * Reset the title settings.
* *
* @param player * @param player Player
* Player * @throws Exception
* @throws SecurityException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws InstantiationException
*/ */
public void resetTitle(Player player) throws Exception { public void resetTitle(Player player) throws Exception {
// Send timings first // Send timings first

View File

@ -114,7 +114,6 @@ public class HackTitleManager {
/** /**
* Load spigot and NMS classes. * Load spigot and NMS classes.
* @throws ClassNotFoundException Spigot Error.
*/ */
private void loadClasses() { private void loadClasses() {
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle"); this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");

View File

@ -51,39 +51,39 @@ import java.util.zip.GZIPOutputStream;
public class Metrics { public class Metrics {
/** /**
* The current revision number * The current revision number.
*/ */
private static final int REVISION = 7; private static final int REVISION = 7;
/** /**
* The base url of the metrics domain * 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 * 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) * 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 * The plugin this metrics submits for.
*/ */
private final Plugin plugin; private final Plugin plugin;
/** /**
* All of the custom graphs to submit to metrics * 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>());
/** /**
* Unique server id * Unique server id.
*/ */
private final String guid; private final String guid;
/** /**
* Debug mode * Debug mode.
*/ */
private final boolean debug; private final boolean debug;
/** /**
* The scheduled task * The scheduled task.
*/ */
private volatile BukkitTask task = null; private volatile BukkitTask task = null;
@ -97,7 +97,7 @@ public class Metrics {
} }
/** /**
* GZip compress a string of bytes * GZip compress a string of bytes.
* *
* @param input * @param input
* *
@ -129,7 +129,6 @@ public class Metrics {
* @param key * @param key
* @param value * @param value
* *
* @throws UnsupportedEncodingException
*/ */
private static void appendJSONPair(StringBuilder json, String key, String value) { private static void appendJSONPair(StringBuilder json, String key, String value) {
boolean isValueNumeric = false; boolean isValueNumeric = false;

View File

@ -336,7 +336,7 @@ public class NbtFactory {
} }
/** /**
* Search for the first publically and privately defined method of the given name and parameter count. * Search for the first publicly and privately defined method of the given name and parameter count.
* @param requireMod - modifiers that are required. * @param requireMod - modifiers that are required.
* @param bannedMod - modifiers that are banned. * @param bannedMod - modifiers that are banned.
* @param clazz - a class to start with. * @param clazz - a class to start with.
@ -366,7 +366,7 @@ public class NbtFactory {
} }
/** /**
* Search for the first publically and privately defined field of the given name. * Search for the first publicly and privately defined field of the given name.
* @param instance - an instance of the class with the field. * @param instance - an instance of the class with the field.
* @param clazz - an optional class to start with, or NULL to deduce it from instance. * @param clazz - an optional class to start with, or NULL to deduce it from instance.
* @param fieldName - the field name. * @param fieldName - the field name.

View File

@ -56,7 +56,7 @@ public class OfflinePlayerUtil {
return name; return name;
} }
Constructor gameProfileConstructor = makeConstructor(gameProfileClass, UUID.class, String.class); Constructor gameProfileConstructor = makeConstructor(gameProfileClass, UUID.class, String.class);
if (gameProfileConstructor == null) { //Verson has string constructor if (gameProfileConstructor == null) { //Version has string constructor
gameProfileConstructor = makeConstructor(gameProfileClass, String.class, String.class); gameProfileConstructor = makeConstructor(gameProfileClass, String.class, String.class);
return callConstructor(gameProfileConstructor, id.toString(), name); return callConstructor(gameProfileConstructor, id.toString(), name);
} else { //Version has uuid constructor } else { //Version has uuid constructor

View File

@ -127,10 +127,10 @@ public class SendChunk {
} }
} }
public void sendChunk(String worldname, Collection<ChunkLoc> locs) { public void sendChunk(String worldname, Collection<ChunkLoc> chunkLocs) {
World myworld = Bukkit.getWorld(worldname); World myworld = Bukkit.getWorld(worldname);
ArrayList<Chunk> chunks = new ArrayList<>(); ArrayList<Chunk> chunks = new ArrayList<>();
for (ChunkLoc loc : locs) { for (ChunkLoc loc : chunkLocs) {
if (myworld.isChunkLoaded(loc.x, loc.z)) { if (myworld.isChunkLoaded(loc.x, loc.z)) {
chunks.add(myworld.getChunkAt(loc.x, loc.z)); chunks.add(myworld.getChunkAt(loc.x, loc.z));
} }

View File

@ -539,10 +539,6 @@ public class MemorySection implements ConfigurationSection {
public List<String> getStringList(String path) { public List<String> getStringList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -558,10 +554,6 @@ public class MemorySection implements ConfigurationSection {
public List<Integer> getIntegerList(String path) { public List<Integer> getIntegerList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Integer> result = new ArrayList<>(); List<Integer> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -586,10 +578,6 @@ public class MemorySection implements ConfigurationSection {
public List<Boolean> getBooleanList(String path) { public List<Boolean> getBooleanList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Boolean> result = new ArrayList<>(); List<Boolean> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -611,10 +599,6 @@ public class MemorySection implements ConfigurationSection {
public List<Double> getDoubleList(String path) { public List<Double> getDoubleList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Double> result = new ArrayList<>(); List<Double> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -639,10 +623,6 @@ public class MemorySection implements ConfigurationSection {
public List<Float> getFloatList(String path) { public List<Float> getFloatList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Float> result = new ArrayList<>(); List<Float> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -667,10 +647,6 @@ public class MemorySection implements ConfigurationSection {
public List<Long> getLongList(String path) { public List<Long> getLongList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Long> result = new ArrayList<>(); List<Long> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -695,10 +671,6 @@ public class MemorySection implements ConfigurationSection {
public List<Byte> getByteList(String path) { public List<Byte> getByteList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Byte> result = new ArrayList<>(); List<Byte> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -723,10 +695,6 @@ public class MemorySection implements ConfigurationSection {
public List<Character> getCharacterList(String path) { public List<Character> getCharacterList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Character> result = new ArrayList<>(); List<Character> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -750,10 +718,6 @@ public class MemorySection implements ConfigurationSection {
public List<Short> getShortList(String path) { public List<Short> getShortList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Short> result = new ArrayList<>(); List<Short> result = new ArrayList<>();
for (Object object : list) { for (Object object : list) {
@ -779,10 +743,6 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
List<Map<?, ?>> result = new ArrayList<>(); List<Map<?, ?>> result = new ArrayList<>();
if (list == null) {
return result;
}
for (Object object : list) { for (Object object : list) {
if (object instanceof Map) { if (object instanceof Map) {
result.add((Map<?, ?>) object); result.add((Map<?, ?>) object);

View File

@ -48,7 +48,7 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
public NBTOutputStream(final OutputStream os) { public NBTOutputStream(OutputStream os) {
this.os = new DataOutputStream(os); this.os = new DataOutputStream(os);
} }
@ -59,13 +59,13 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
public void writeTag(final Tag tag) throws IOException { public void writeTag(Tag tag) throws IOException {
final int type = NBTUtils.getTypeCode(tag.getClass()); int type = NBTUtils.getTypeCode(tag.getClass());
final String name = tag.getName(); String name = tag.getName();
final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET); byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
os.writeByte(type); this.os.writeByte(type);
os.writeShort(nameBytes.length); this.os.writeShort(nameBytes.length);
os.write(nameBytes); this.os.write(nameBytes);
if (type == NBTConstants.TYPE_END) { if (type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted."); throw new IOException("Named TAG_End not permitted.");
} }
@ -79,8 +79,8 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeTagPayload(final Tag tag) throws IOException { private void writeTagPayload(Tag tag) throws IOException {
final int type = NBTUtils.getTypeCode(tag.getClass()); int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) { switch (type) {
case NBTConstants.TYPE_END: case NBTConstants.TYPE_END:
writeEndTagPayload((EndTag) tag); writeEndTagPayload((EndTag) tag);
@ -130,8 +130,8 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeByteTagPayload(final ByteTag tag) throws IOException { private void writeByteTagPayload(ByteTag tag) throws IOException {
os.writeByte(tag.getValue()); this.os.writeByte(tag.getValue());
} }
/** /**
@ -141,10 +141,10 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeByteArrayTagPayload(final ByteArrayTag tag) throws IOException { private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
final byte[] bytes = tag.getValue(); byte[] bytes = tag.getValue();
os.writeInt(bytes.length); this.os.writeInt(bytes.length);
os.write(bytes); this.os.write(bytes);
} }
/** /**
@ -154,11 +154,11 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeCompoundTagPayload(final CompoundTag tag) throws IOException { private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
for (final Tag childTag : tag.getValue().values()) { for (Tag childTag : tag.getValue().values()) {
writeTag(childTag); writeTag(childTag);
} }
os.writeByte((byte) 0); // end tag - better way? this.os.writeByte((byte) 0); // end tag - better way?
} }
/** /**
@ -168,13 +168,13 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeListTagPayload(final ListTag tag) throws IOException { private void writeListTagPayload(ListTag tag) throws IOException {
final Class<? extends Tag> clazz = tag.getType(); Class<? extends Tag> clazz = tag.getType();
final List<Tag> tags = tag.getValue(); List<Tag> tags = tag.getValue();
final int size = tags.size(); int size = tags.size();
os.writeByte(NBTUtils.getTypeCode(clazz)); this.os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size); this.os.writeInt(size);
for (final Tag tag1 : tags) { for (Tag tag1 : tags) {
writeTagPayload(tag1); writeTagPayload(tag1);
} }
} }
@ -186,10 +186,10 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeStringTagPayload(final StringTag tag) throws IOException { private void writeStringTagPayload(StringTag tag) throws IOException {
final byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET); byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
os.writeShort(bytes.length); this.os.writeShort(bytes.length);
os.write(bytes); this.os.write(bytes);
} }
/** /**
@ -199,8 +199,8 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeDoubleTagPayload(final DoubleTag tag) throws IOException { private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
os.writeDouble(tag.getValue()); this.os.writeDouble(tag.getValue());
} }
/** /**
@ -210,8 +210,8 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeFloatTagPayload(final FloatTag tag) throws IOException { private void writeFloatTagPayload(FloatTag tag) throws IOException {
os.writeFloat(tag.getValue()); this.os.writeFloat(tag.getValue());
} }
/** /**
@ -221,8 +221,8 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeLongTagPayload(final LongTag tag) throws IOException { private void writeLongTagPayload(LongTag tag) throws IOException {
os.writeLong(tag.getValue()); this.os.writeLong(tag.getValue());
} }
/** /**
@ -232,8 +232,8 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeIntTagPayload(final IntTag tag) throws IOException { private void writeIntTagPayload(IntTag tag) throws IOException {
os.writeInt(tag.getValue()); this.os.writeInt(tag.getValue());
} }
/** /**
@ -243,32 +243,30 @@ public final class NBTOutputStream implements Closeable {
* *
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
private void writeShortTagPayload(final ShortTag tag) throws IOException { private void writeShortTagPayload(ShortTag tag) throws IOException {
os.writeShort(tag.getValue()); this.os.writeShort(tag.getValue());
} }
/** /**
* Writes a <code>TAG_Empty</code> tag. * Writes a <code>TAG_Empty</code> tag.
* *
* @param tag The tag. * @param tag The tag.
*
* @throws IOException if an I/O error occurs.
*/ */
private void writeEndTagPayload(final EndTag tag) { private void writeEndTagPayload(EndTag tag) {
/* empty */ /* empty */
} }
private void writeIntArrayTagPayload(final IntArrayTag tag) throws IOException { private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
final int[] data = tag.getValue(); int[] data = tag.getValue();
os.writeInt(data.length); this.os.writeInt(data.length);
for (final int element : data) { for (int element : data) {
os.writeInt(element); this.os.writeInt(element);
} }
} }
@Override @Override
public void close() throws IOException { public void close() throws IOException {
os.close(); this.os.close();
} }
/** /**
@ -276,6 +274,6 @@ public final class NBTOutputStream implements Closeable {
* @throws IOException * @throws IOException
*/ */
public void flush() throws IOException { public void flush() throws IOException {
os.flush(); this.os.flush();
} }
} }

View File

@ -21,7 +21,7 @@ public class JSONML {
* *
* @throws JSONException * @throws JSONException
*/ */
private static Object parse(final XMLTokener x, final boolean arrayForm, final JSONArray ja) throws JSONException { private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja) throws JSONException {
String attribute; String attribute;
char c; char c;
String closeTag = null; String closeTag = null;
@ -114,9 +114,6 @@ public class JSONML {
if (token == null) { if (token == null) {
token = x.nextToken(); token = x.nextToken();
} }
if (token == null) {
throw x.syntaxError("Misshaped tag");
}
if (!(token instanceof String)) { if (!(token instanceof String)) {
break; break;
} }
@ -195,7 +192,7 @@ public class JSONML {
* *
* @throws JSONException * @throws JSONException
*/ */
public static JSONArray toJSONArray(final String string) throws JSONException { public static JSONArray toJSONArray(String string) throws JSONException {
return toJSONArray(new XMLTokener(string)); return toJSONArray(new XMLTokener(string));
} }
@ -212,7 +209,7 @@ public class JSONML {
* *
* @throws JSONException * @throws JSONException
*/ */
public static JSONArray toJSONArray(final XMLTokener x) throws JSONException { public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
return (JSONArray) parse(x, true, null); return (JSONArray) parse(x, true, null);
} }
@ -230,7 +227,7 @@ public class JSONML {
* *
* @throws JSONException * @throws JSONException
*/ */
public static JSONObject toJSONObject(final XMLTokener x) throws JSONException { public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
return (JSONObject) parse(x, false, null); return (JSONObject) parse(x, false, null);
} }
@ -248,7 +245,7 @@ public class JSONML {
* *
* @throws JSONException * @throws JSONException
*/ */
public static JSONObject toJSONObject(final String string) throws JSONException { public static JSONObject toJSONObject(String string) throws JSONException {
return toJSONObject(new XMLTokener(string)); return toJSONObject(new XMLTokener(string));
} }
@ -261,14 +258,14 @@ public class JSONML {
* *
* @throws JSONException * @throws JSONException
*/ */
public static String toString(final JSONArray ja) throws JSONException { public static String toString(JSONArray ja) throws JSONException {
int i; int i;
JSONObject jo; JSONObject jo;
String key; String key;
Iterator<String> keys; Iterator<String> keys;
int length; int length;
Object object; Object object;
final StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String tagName; String tagName;
String value; String value;
// Emit <tagName // Emit <tagName
@ -338,8 +335,8 @@ public class JSONML {
* *
* @throws JSONException * @throws JSONException
*/ */
public static String toString(final JSONObject jo) throws JSONException { public static String toString(JSONObject jo) throws JSONException {
final StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int i; int i;
JSONArray ja; JSONArray ja;
String key; String key;

View File

@ -2324,7 +2324,7 @@ public class PS {
*/ */
private void setupStyle() { private void setupStyle() {
this.style.set("version", StringMan.join(this.version, ".")); this.style.set("version", StringMan.join(this.version, "."));
Map<String, Object> o = new HashMap<>(); Map<String, Object> o = new HashMap<>(4);
o.put("color.1", "6"); o.put("color.1", "6");
o.put("color.2", "7"); o.put("color.2", "7");
o.put("color.3", "8"); o.put("color.3", "8");

View File

@ -137,7 +137,7 @@ public class Area extends SubCommand {
}, null); }, null);
} }
} else { } else {
MainUtil.sendMessage(plr, "An error occured while creating the world: " + area.worldname); MainUtil.sendMessage(plr, "An error occurred while creating the world: " + area.worldname);
} }
} }
}; };
@ -257,7 +257,7 @@ public class Area extends SubCommand {
C.SETUP_FINISHED.send(plr); C.SETUP_FINISHED.send(plr);
plr.teleport(WorldUtil.IMP.getSpawn(world)); plr.teleport(WorldUtil.IMP.getSpawn(world));
} else { } else {
MainUtil.sendMessage(plr, "An error occured while creating the world: " + pa.worldname); MainUtil.sendMessage(plr, "An error occurred while creating the world: " + pa.worldname);
} }
try { try {
PS.get().config.save(PS.get().configFile); PS.get().config.save(PS.get().configFile);

View File

@ -42,7 +42,7 @@ import java.util.UUID;
aliases = {"owner", "so", "seto"}, aliases = {"owner", "so", "seto"},
category = CommandCategory.CLAIMING, category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE, requiredType = RequiredType.NONE,
confirmation=true) confirmation = true)
public class Owner extends SetCommand { public class Owner extends SetCommand {
@Override @Override

View File

@ -189,8 +189,8 @@ public class SchematicCmd extends SubCommand {
MainUtil.sendMessage(plr, "&cTask is already running."); MainUtil.sendMessage(plr, "&cTask is already running.");
return false; return false;
} else { } else {
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schematic&8: &7Mass export has started. This may take a while.");
MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plots.size() + "&7 plots..."); MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots...");
} }
break; break;
} }
@ -204,7 +204,6 @@ public class SchematicCmd extends SubCommand {
MainUtil.sendMessage(plr, "&cTask is already running."); MainUtil.sendMessage(plr, "&cTask is already running.");
return false; return false;
} }
Plot p2;
Location loc = plr.getLocation(); Location loc = plr.getLocation();
Plot plot = loc.getPlotAbs(); Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
@ -218,7 +217,7 @@ public class SchematicCmd extends SubCommand {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }
p2 = plot; Plot p2 = plot;
loc.getWorld(); loc.getWorld();
Collection<Plot> plots = new ArrayList<Plot>(); Collection<Plot> plots = new ArrayList<Plot>();
plots.add(p2); plots.add(p2);

View File

@ -954,7 +954,7 @@ public class SQLManager implements AbstractDB {
} }
/** /**
* Create a plot * Create a plot.
* *
* @param plot * @param plot
*/ */
@ -1038,7 +1038,7 @@ public class SQLManager implements AbstractDB {
} }
/** /**
* Create tables * Create tables.
* *
* @throws SQLException * @throws SQLException
*/ */

View File

@ -31,15 +31,16 @@ public class Flag<T> implements Cloneable {
private String name; private String name;
/** /**
* Flag object used to store basic information for a Plot. Flags are a key/value pair. For a flag to be usable by a * Flag object used to store basic information for a Plot. Flags are a
* player, you need to register it with PlotSquared. * key/value pair. For a flag to be usable by a player, you need to
* register it with PlotSquared.
* *
* @param key AbstractFlag * @param key AbstractFlag
* @param value Value must be alphanumerical (can have spaces) and be &lt;= 48 characters * @param value Value must be alphanumerical (can have spaces) and be &lt;= 48 characters
* *
* @throws IllegalArgumentException if you provide inadequate inputs * @throws IllegalArgumentException if you provide inadequate inputs
*/ */
public Flag(final AbstractFlag key, final String value) { public Flag(AbstractFlag key, String value) {
if (!StringMan.isAsciiPrintable(value)) { if (!StringMan.isAsciiPrintable(value)) {
throw new IllegalArgumentException("Flag must be ascii"); throw new IllegalArgumentException("Flag must be ascii");
} }
@ -55,8 +56,10 @@ public class Flag<T> implements Cloneable {
/** /**
* Warning: Unchecked * Warning: Unchecked
* @param key
* @param value
*/ */
public Flag(final AbstractFlag key, final Object value) { public Flag(AbstractFlag key, Object value) {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
@ -66,53 +69,53 @@ public class Flag<T> implements Cloneable {
} }
/** /**
* Get the AbstractFlag used in creating the flag * Get the AbstractFlag used in creating the flag.
* *
* @return AbstractFlag * @return AbstractFlag
*/ */
public AbstractFlag getAbstractFlag() { public AbstractFlag getAbstractFlag() {
return key; return this.key;
} }
/** /**
* Get the key for the AbstractFlag * Get the key for the AbstractFlag.
* *
* @return String * @return String
*/ */
public String getKey() { public String getKey() {
return key.getKey(); return this.key.getKey();
} }
public void setKey(final AbstractFlag key) { public void setKey(AbstractFlag key) {
this.key = key; this.key = key;
if (value instanceof String) { if (this.value instanceof String) {
value = key.parseValueRaw((String) value); this.value = key.parseValueRaw((String) this.value);
} }
} }
/** /**
* Get the value * Get the value.
* *
* @return String * @return String
*/ */
public Object getValue() { public Object getValue() {
return value; return this.value;
} }
public String getValueString() { public String getValueString() {
return key.toString(value); return this.key.toString(this.value);
} }
@Override @Override
public String toString() { public String toString() {
if ("".equals(value)) { if ("".equals(this.value)) {
return key.getKey(); return this.key.getKey();
} }
return key + ":" + getValueString(); return this.key + ":" + getValueString();
} }
@Override @Override
public boolean equals(final Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
@ -122,29 +125,29 @@ public class Flag<T> implements Cloneable {
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
final Flag other = (Flag) obj; Flag other = (Flag) obj;
return key.getKey().equals(other.key.getKey()) && value.equals(other.value); return this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return key.getKey().hashCode(); return this.key.getKey().hashCode();
} }
@Override @Override
protected Object clone() { protected Object clone() {
try { try {
if (value == null) { if (this.value == null) {
return super.clone(); return super.clone();
} }
if (value instanceof Cloneable) { if (this.value instanceof Cloneable) {
Method method = value.getClass().getDeclaredMethod("clone"); Method method = this.value.getClass().getDeclaredMethod("clone");
if (!method.isAccessible()) { if (!method.isAccessible()) {
method.setAccessible(true); method.setAccessible(true);
} }
return new Flag(key, method.invoke(value)); return new Flag(this.key, method.invoke(this.value));
} }
return new Flag(key, key.parseValueRaw(value.toString())); return new Flag(this.key, this.key.parseValueRaw(this.value.toString()));
} catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) { } catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -152,6 +155,6 @@ public class Flag<T> implements Cloneable {
} }
public String getName() { public String getName() {
return name; return this.name;
} }
} }

View File

@ -367,7 +367,7 @@ public class Plot {
} }
/** /**
* Get a list of owner UUIDs for a plot (supports multi-owner mega-plots) * Get a list of owner UUIDs for a plot (supports multi-owner mega-plots).
* @return * @return
*/ */
public HashSet<UUID> getOwners() { public HashSet<UUID> getOwners() {
@ -474,7 +474,7 @@ public class Plot {
} }
/** /**
* Get or create plot settings * Get or create plot settings.
* @return PlotSettings * @return PlotSettings
* @deprecated use equivalent plot method; * @deprecated use equivalent plot method;
*/ */
@ -487,7 +487,8 @@ public class Plot {
} }
/** /**
* Returns true if the plot is not merged, or it is the base plot of multiple merged plots * Returns true if the plot is not merged, or it is the base
* plot of multiple merged plots.
* @return * @return
*/ */
public boolean isBasePlot() { public boolean isBasePlot() {
@ -528,7 +529,7 @@ public class Plot {
} }
/** /**
* Check if the plot is merged in any direction * Check if the plot is merged in any direction.
* @return * @return
*/ */
public boolean isMerged() { public boolean isMerged() {
@ -603,7 +604,7 @@ public class Plot {
} }
/** /**
* Get the denied users * Get the denied users.
* @return * @return
*/ */
public HashSet<UUID> getDenied() { public HashSet<UUID> getDenied() {
@ -614,7 +615,7 @@ public class Plot {
} }
/** /**
* Set the denied users for this plot * Set the denied users for this plot.
* @param uuids * @param uuids
*/ */
public void setDenied(Set<UUID> uuids) { public void setDenied(Set<UUID> uuids) {
@ -633,7 +634,7 @@ public class Plot {
} }
/** /**
* Get the trusted users * Get the trusted users.
* @return * @return
*/ */
public HashSet<UUID> getTrusted() { public HashSet<UUID> getTrusted() {
@ -644,7 +645,7 @@ public class Plot {
} }
/** /**
* Set the trusted users for this plot * Set the trusted users for this plot.
* @param uuids * @param uuids
*/ */
public void setTrusted(Set<UUID> uuids) { public void setTrusted(Set<UUID> uuids) {

View File

@ -294,9 +294,9 @@ public abstract class PlotArea {
} }
List<String> flags = config.getStringList("flags.default"); List<String> flags = config.getStringList("flags.default");
if (flags == null || flags.isEmpty()) { if (flags.isEmpty()) {
flags = config.getStringList("flags"); flags = config.getStringList("flags");
if (flags == null || flags.isEmpty()) { if (flags.isEmpty()) {
flags = new ArrayList<>(); flags = new ArrayList<>();
ConfigurationSection section = config.getConfigurationSection("flags"); ConfigurationSection section = config.getConfigurationSection("flags");
Set<String> keys = section.getKeys(false); Set<String> keys = section.getKeys(false);

View File

@ -17,71 +17,72 @@ public class PlotCluster {
private PlotId pos2; private PlotId pos2;
private RegionWrapper region; private RegionWrapper region;
public PlotCluster(final PlotArea area, final PlotId pos1, final PlotId pos2, final UUID owner) { public PlotCluster(PlotArea area, PlotId pos1, PlotId pos2, UUID owner) {
this.area = area; this.area = area;
this.pos1 = pos1; this.pos1 = pos1;
this.pos2 = pos2; this.pos2 = pos2;
this.owner = owner; this.owner = owner;
settings = new PlotSettings(); this.settings = new PlotSettings();
this.temp = -1; this.temp = -1;
setRegion(); setRegion();
} }
public PlotCluster(final PlotArea area, final PlotId pos1, final PlotId pos2, final UUID owner, int temp) { public PlotCluster(PlotArea area, PlotId pos1, PlotId pos2, UUID owner, int temp) {
this.area = area; this.area = area;
this.pos1 = pos1; this.pos1 = pos1;
this.pos2 = pos2; this.pos2 = pos2;
this.owner = owner; this.owner = owner;
settings = new PlotSettings(); this.settings = new PlotSettings();
this.temp = temp; this.temp = temp;
setRegion(); setRegion();
} }
public PlotId getP1() { public PlotId getP1() {
return pos1; return this.pos1;
} }
public void setP1(final PlotId id) { public void setP1(PlotId id) {
pos1 = id; this.pos1 = id;
setRegion(); setRegion();
} }
public PlotId getP2() { public PlotId getP2() {
return pos2; return this.pos2;
} }
public void setP2(final PlotId id) { public void setP2(PlotId id) {
pos2 = id; this.pos2 = id;
setRegion(); setRegion();
} }
private void setRegion() { private void setRegion() {
region = new RegionWrapper(pos1.x, pos2.x, pos1.y, pos2.y); this.region = new RegionWrapper(this.pos1.x, this.pos2.x, this.pos1.y, this.pos2.y);
} }
public RegionWrapper getRegion() { public RegionWrapper getRegion() {
return region; return this.region;
} }
public boolean isAdded(final UUID uuid) { public boolean isAdded(UUID uuid) {
return owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers return this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid)
|| this.helpers
.contains(DBFunc.everyone); .contains(DBFunc.everyone);
} }
public boolean hasHelperRights(final UUID uuid) { public boolean hasHelperRights(UUID uuid) {
return owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone); return this.owner.equals(uuid) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone);
} }
public String getName() { public String getName() {
return settings.getAlias(); return this.settings.getAlias();
} }
/** /**
* Get the area (in plots) * Get the area (in plots).
* @return * @return
*/ */
public int getArea() { public int getArea() {
return (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); return (1 + this.pos2.x - this.pos1.x) * (1 + this.pos2.y - this.pos1.y);
} }
public void setArea(PlotArea plotarea) { public void setArea(PlotArea plotarea) {
@ -94,11 +95,11 @@ public class PlotCluster {
@Override @Override
public int hashCode() { public int hashCode() {
return pos1.hashCode(); return this.pos1.hashCode();
} }
@Override @Override
public boolean equals(final Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
@ -108,31 +109,31 @@ public class PlotCluster {
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
final PlotCluster other = (PlotCluster) obj; PlotCluster other = (PlotCluster) obj;
return pos1.equals(other.pos1) && pos2.equals(other.pos2) && area.equals(other.area); return this.pos1.equals(other.pos1) && this.pos2.equals(other.pos2) && this.area.equals(other.area);
} }
@Override @Override
public String toString() { public String toString() {
return area + ";" + pos1.x + ";" + pos1.y + ";" + pos2.x + ";" + pos2.y; return this.area + ";" + this.pos1.x + ";" + this.pos1.y + ";" + this.pos2.x + ";" + this.pos2.y;
} }
public Location getHome() { public Location getHome() {
final BlockLoc home = settings.getPosition(); BlockLoc home = this.settings.getPosition();
Location toReturn; Location toReturn;
if (home.y == 0) { if (home.y == 0) {
// default pos // default pos
final Plot center = getCenterPlot(); Plot center = getCenterPlot();
toReturn = center.getHome(); toReturn = center.getHome();
if (toReturn.getY() == 0) { if (toReturn.getY() == 0) {
final PlotManager manager = area.getPlotManager(); PlotManager manager = this.area.getPlotManager();
final Location loc = manager.getSignLoc(area, center); Location loc = manager.getSignLoc(this.area, center);
toReturn.setY(loc.getY()); toReturn.setY(loc.getY());
} }
} else { } else {
toReturn = getClusterBottom().add(home.x, home.y, home.z); toReturn = getClusterBottom().add(home.x, home.y, home.z);
} }
final int max = MainUtil.getHeighestBlock(area.worldname, toReturn.getX(), toReturn.getZ()); int max = MainUtil.getHeighestBlock(this.area.worldname, toReturn.getX(), toReturn.getZ());
if (max > toReturn.getY()) { if (max > toReturn.getY()) {
toReturn.setY(max); toReturn.setY(max);
} }
@ -140,30 +141,30 @@ public class PlotCluster {
} }
public PlotId getCenterPlotId() { public PlotId getCenterPlotId() {
final PlotId bot = getP1(); PlotId bot = getP1();
final PlotId top = getP2(); PlotId top = getP2();
return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
} }
public Plot getCenterPlot() { public Plot getCenterPlot() {
return area.getPlotAbs(getCenterPlotId()); return this.area.getPlotAbs(getCenterPlotId());
} }
public Location getClusterBottom() { public Location getClusterBottom() {
final PlotManager manager = area.getPlotManager(); PlotManager manager = this.area.getPlotManager();
return manager.getPlotBottomLocAbs(area, getP1()); return manager.getPlotBottomLocAbs(this.area, getP1());
} }
public Location getClusterTop() { public Location getClusterTop() {
final PlotManager manager = area.getPlotManager(); PlotManager manager = this.area.getPlotManager();
return manager.getPlotTopLocAbs(area, getP2()); return manager.getPlotTopLocAbs(this.area, getP2());
} }
public boolean intersects(PlotId pos1, PlotId pos2) { public boolean intersects(PlotId pos1, PlotId pos2) {
return pos1.x <= this.pos2.x && pos2.x >= this.pos1.x && pos1.y <= this.pos2.y && pos2.y >= this.pos1.y; return pos1.x <= this.pos2.x && pos2.x >= this.pos1.x && pos1.y <= this.pos2.y && pos2.y >= this.pos1.y;
} }
public boolean contains(final PlotId id) { public boolean contains(PlotId id) {
return pos1.x <= id.x && pos1.y <= id.y && pos2.x >= id.x && pos2.y >= id.y; return this.pos1.x <= id.x && this.pos1.y <= id.y && this.pos2.x >= id.x && this.pos2.y >= id.y;
} }
} }

View File

@ -3,82 +3,81 @@ package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.util.InventoryUtil; import com.intellectualcrafters.plot.util.InventoryUtil;
public class PlotInventory { public class PlotInventory {
public final PlotPlayer player; public final PlotPlayer player;
public final int size; public final int size;
private String title;
private final PlotItemStack[] items; private final PlotItemStack[] items;
private String title;
private boolean open = false; private boolean open = false;
public PlotInventory(final PlotPlayer player) { public PlotInventory(PlotPlayer player) {
size = 4; this.size = 4;
title = null; this.title = null;
this.player = player; this.player = player;
items = InventoryUtil.manager.getItems(player); this.items = InventoryUtil.manager.getItems(player);
} }
public PlotInventory(final PlotPlayer player, final int size, final String name) { public PlotInventory(PlotPlayer player, int size, String name) {
this.size = size; this.size = size;
title = name == null ? "" : name; this.title = name == null ? "" : name;
this.player = player; this.player = player;
items = new PlotItemStack[size * 9]; this.items = new PlotItemStack[size * 9];
} }
public boolean onClick(final int index) { public boolean onClick(int index) {
return true; return true;
} }
public void openInventory() { public void openInventory() {
if (title == null) { if (this.title == null) {
return; return;
} }
open = true; this.open = true;
InventoryUtil.manager.open(this); InventoryUtil.manager.open(this);
} }
public void close() { public void close() {
if (title == null) { if (this.title == null) {
return; return;
} }
InventoryUtil.manager.close(this); InventoryUtil.manager.close(this);
open = false; this.open = false;
} }
public void setItem(final int index, final PlotItemStack item) { public void setItem(int index, PlotItemStack item) {
items[index] = item; this.items[index] = item;
InventoryUtil.manager.setItem(this, index, item); InventoryUtil.manager.setItem(this, index, item);
} }
public PlotItemStack getItem(final int index) { public PlotItemStack getItem(int index) {
if ((index < 0) || (index >= items.length)) { if ((index < 0) || (index >= this.items.length)) {
return null; return null;
} }
return items[index]; return this.items[index];
} }
public void setTitle(final String title) { public PlotItemStack[] getItems() {
return this.items;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
if (title == null) { if (title == null) {
return; return;
} }
final boolean tmp = open; boolean tmp = this.open;
close(); close();
this.title = title; this.title = title;
if (tmp) { if (tmp) {
openInventory(); openInventory();
} }
} }
public PlotItemStack[] getItems() {
return items;
}
public String getTitle() {
return title;
}
public boolean isOpen() { public boolean isOpen() {
return open; return this.open;
} }
} }

View File

@ -599,43 +599,43 @@ public enum ItemType {
WARD_DISC("record_ward", 2265), WARD_DISC("record_ward", 2265),
DISC_11("record_11", 2266), DISC_11("record_11", 2266),
WAIT_DISC("record_wait", 2267); WAIT_DISC("record_wait", 2267);
private static final Map<String, Integer> ids = new HashMap<String, Integer>(); private static final Map<String, Integer> ids = new HashMap<>();
private static final Map<String, Byte> datas = new HashMap<String, Byte>(); private static final Map<String, Byte> datas = new HashMap<>();
private final int id;
private final byte data;
private final String name;
static { static {
for (final ItemType type : EnumSet.allOf(ItemType.class)) { for (ItemType type : EnumSet.allOf(ItemType.class)) {
ids.put(type.name, type.id); ids.put(type.name, type.id);
datas.put(type.name, type.data); datas.put(type.name, type.data);
} }
} }
ItemType(final String name, final int id) { private final int id;
private final byte data;
private final String name;
ItemType(String name, int id) {
this.id = id; this.id = id;
data = 0; this.data = 0;
this.name = name; this.name = name;
} }
ItemType(final String name, final int id, final int data) { ItemType(String name, int id, int data) {
this.id = id; this.id = id;
this.data = (byte) data; this.data = (byte) data;
this.name = name; this.name = name;
} }
public static int getId(final String name) { public static int getId(String name) {
final Integer value = ids.get(name); Integer value = ids.get(name);
if (value == null) { if (value == null) {
return 0; return 0;
} }
return value; return value;
} }
public static byte getData(final String name) { public static byte getData(String name) {
final Byte value = datas.get(name); Byte value = datas.get(name);
if (value == null) { if (value == null) {
return 0; return 0;
} }

View File

@ -229,17 +229,13 @@ public class MainUtil {
if (MathMan.isInteger(string)) { if (MathMan.isInteger(string)) {
return Long.parseLong(string); return Long.parseLong(string);
} }
if (string == null) {
return 0;
}
string = string.toLowerCase().trim().toLowerCase(); string = string.toLowerCase().trim().toLowerCase();
if (string.equalsIgnoreCase("false")) { if (string.equalsIgnoreCase("false")) {
return 0; return 0;
} }
String[] split = string.split(" "); String[] split = string.split(" ");
long time = 0; long time = 0;
for (int i = 0; i < split.length; i++) { for (String value : split) {
String value = split[i];
int nums = Integer.parseInt(value.replaceAll("[^\\d]", "")); int nums = Integer.parseInt(value.replaceAll("[^\\d]", ""));
String letters = value.replaceAll("[^a-z]", ""); String letters = value.replaceAll("[^a-z]", "");
switch (letters) { switch (letters) {

View File

@ -1,58 +1,58 @@
package com.intellectualcrafters.plot.util.helpmenu; package com.intellectualcrafters.plot.util.helpmenu;
import java.util.List;
import com.intellectualcrafters.plot.commands.CommandCategory; import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
import java.util.List;
public class HelpMenu { public class HelpMenu {
public static final int PER_PAGE = 5; public static final int PER_PAGE = 5;
private final PlotPlayer _player; private final PlotPlayer player;
private HelpPage _page = new HelpPage(CommandCategory.INFO, 0, 0); private HelpPage page = new HelpPage(CommandCategory.INFO, 0, 0);
private int _maxPage; private int maxPage;
private CommandCategory _commandCategory; private CommandCategory commandCategory;
private List<Command> _commands; private List<Command> commands;
public HelpMenu(final PlotPlayer player) { public HelpMenu(PlotPlayer player) {
_player = player; this.player = player;
} }
public HelpMenu setCategory(final CommandCategory commandCategory) { public HelpMenu setCategory(CommandCategory commandCategory) {
_commandCategory = commandCategory; this.commandCategory = commandCategory;
return this; return this;
} }
public HelpMenu getCommands() { public HelpMenu getCommands() {
_commands = MainCommand.getInstance().getCommands(_commandCategory, _player); this.commands = MainCommand.getInstance().getCommands(this.commandCategory, this.player);
return this; return this;
} }
public HelpMenu generateMaxPages() { public HelpMenu generateMaxPages() {
_maxPage = Math.max((_commands.size() - 1) / PER_PAGE, 0); this.maxPage = Math.max((this.commands.size() - 1) / PER_PAGE, 0);
return this; return this;
} }
public HelpMenu generatePage(int currentPage, final String label) { public HelpMenu generatePage(int currentPage, String label) {
if (currentPage > _maxPage) { if (currentPage > this.maxPage) {
currentPage = _maxPage; currentPage = this.maxPage;
} }
if (currentPage < 0) { if (currentPage < 0) {
currentPage = 0; currentPage = 0;
} }
_page = new HelpPage(_commandCategory, currentPage, _maxPage); this.page = new HelpPage(this.commandCategory, currentPage, this.maxPage);
final int max = Math.min((currentPage * PER_PAGE) + (PER_PAGE - 1), _commands.size()); int max = Math.min((currentPage * PER_PAGE) + (PER_PAGE - 1), this.commands.size());
for (int i = currentPage * PER_PAGE; i < max; i++) { for (int i = currentPage * PER_PAGE; i < max; i++) {
_page.addHelpItem(new HelpObject(_commands.get(i), label)); this.page.addHelpItem(new HelpObject(this.commands.get(i), label));
} }
return this; return this;
} }
public void render() { public void render() {
_page.render(_player); this.page.render(this.player);
} }
} }

View File

@ -5,29 +5,31 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class HelpPage { public class HelpPage {
private final List<HelpObject> helpObjects; private final List<HelpObject> helpObjects;
private final String _header; private final String header;
public HelpPage(final CommandCategory category, final int currentPage, final int maxPages) { public HelpPage(CommandCategory category, int currentPage, int maxPages) {
helpObjects = new ArrayList<>(); this.helpObjects = new ArrayList<>();
_header = C.HELP_PAGE_HEADER.s().replace("%category%", category == null ? "ALL" : category.toString()).replace("%current%", (currentPage + 1) + "").replace("%max%", (maxPages + 1) + ""); this.header = C.HELP_PAGE_HEADER.s().replace("%category%", category == null ? "ALL" : category.toString())
.replace("%current%", (currentPage + 1) + "").replace("%max%", (maxPages + 1) + "");
} }
public void render(final PlotPlayer player) { public void render(PlotPlayer player) {
if (helpObjects.size() < 1) { if (this.helpObjects.size() < 1) {
MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0)"); MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0)");
} else { } else {
String message = C.HELP_HEADER.s() + "\n" + _header + "\n" + StringMan.join(helpObjects, "\n") + "\n" + C.HELP_FOOTER.s(); String message = C.HELP_HEADER.s() + "\n" + this.header + "\n" + StringMan.join(this.helpObjects, "\n") + "\n" + C.HELP_FOOTER.s();
MainUtil.sendMessage(player, message, false); MainUtil.sendMessage(player, message, false);
} }
} }
public void addHelpItem(final HelpObject object) { public void addHelpItem(HelpObject object) {
helpObjects.add(object); this.helpObjects.add(object);
} }
} }

View File

@ -143,7 +143,7 @@ public class SpongeMain implements IPlotMain {
if (!Settings.CONSOLE_COLOR) { if (!Settings.CONSOLE_COLOR) {
message = message.replaceAll('\u00a7' + "[a-z|0-9]", ""); message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
} }
if (this.server == null || this.server.getConsole() == null) { if (this.server == null) {
this.logger.info(message); this.logger.info(message);
return; return;
} }
@ -306,7 +306,7 @@ public class SpongeMain implements IPlotMain {
@Override @Override
public void startMetrics() { public void startMetrics() {
try { try {
Metrics metrics = new Metrics(this.game, plugin); Metrics metrics = new Metrics(this.game, this.plugin);
metrics.start(); metrics.start();
log(C.PREFIX.s() + "&6Metrics enabled."); log(C.PREFIX.s() + "&6Metrics enabled.");
} catch (IOException e) { } catch (IOException e) {

View File

@ -1,16 +1,15 @@
package com.plotsquared.sponge.events; package com.plotsquared.sponge.events;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import org.spongepowered.api.event.Cancellable; import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.event.impl.AbstractEvent;
import com.intellectualcrafters.plot.object.PlotId;
public class PlotClearEvent extends AbstractEvent implements Cancellable { public class PlotClearEvent extends AbstractEvent implements Cancellable {
private final Plot plot;
private boolean cancelled; private boolean cancelled;
private Plot plot;
/** /**
* PlotDeleteEvent: Called when a plot is cleared * PlotDeleteEvent: Called when a plot is cleared
@ -23,31 +22,31 @@ public class PlotClearEvent extends AbstractEvent implements Cancellable {
} }
/** /**
* Get the PlotId * Get the PlotId.
* *
* @return PlotId * @return PlotId
*/ */
public PlotId getPlotId() { public PlotId getPlotId() {
return plot.getId(); return this.plot.getId();
} }
/** /**
* Get the world name * Get the world name.
* *
* @return String * @return String
*/ */
public String getWorld() { public String getWorld() {
return plot.getArea().worldname; return this.plot.getArea().worldname;
} }
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return this.cancelled;
} }
@Override @Override
public void setCancelled(final boolean cancel) { public void setCancelled(boolean cancel) {
cancelled = cancel; this.cancelled = cancel;
} }
@Override @Override

View File

@ -24,14 +24,6 @@ import com.plotsquared.listener.PlotListener;
import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.object.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;
import org.spongepowered.api.block.BlockSnapshot; import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.data.Transaction; import org.spongepowered.api.data.Transaction;
@ -60,6 +52,15 @@ import org.spongepowered.api.event.world.ExplosionEvent.Detonate;
import org.spongepowered.api.text.Text; import org.spongepowered.api.text.Text;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;
public class MainListener { public class MainListener {
/* /*
@ -159,7 +160,7 @@ public class MainListener {
} }
((SpongePlayer) user).player.sendMessage(Text.join(components)); ((SpongePlayer) user).player.sendMessage(Text.join(components));
} }
event.setMessage(null); //event.setMessage(null);
} }
@Listener @Listener
@ -185,7 +186,7 @@ public class MainListener {
@Listener @Listener
public void onSpawnEntity(SpawnEntityEvent event) throws Exception { public void onSpawnEntity(SpawnEntityEvent event) throws Exception {
World world = event.getTargetWorld(); World world = event.getTargetWorld();
event.filterEntities((Predicate<Entity>) entity -> { event.filterEntities(entity -> {
if (entity instanceof Player) { if (entity instanceof Player) {
return true; return true;
} }
@ -396,7 +397,7 @@ public class MainListener {
return; return;
} }
} }
if (currentPlot == null || !FlagManager.isPlotFlagTrue(currentPlot, "explosion")) { if (!FlagManager.isPlotFlagTrue(currentPlot, "explosion")) {
event.filterAll(); event.filterAll();
return; return;
} }

View File

@ -16,12 +16,13 @@ public class FastChunk extends PlotChunk<Chunk> {
public short[] relight; public short[] relight;
public int[][] biomes; public int[][] biomes;
public Chunk chunk; public Chunk chunk;
public FastChunk(final ChunkWrapper chunk) {
public FastChunk(ChunkWrapper chunk) {
super(chunk); super(chunk);
ids = new char[16][]; this.ids = new char[16][];
count = new short[16]; this.count = new short[16];
air = new short[16]; this.air = new short[16];
relight = new short[16]; this.relight = new short[16];
} }
@Override @Override
@ -32,89 +33,89 @@ public class FastChunk extends PlotChunk<Chunk> {
@Override @Override
public Chunk getChunk() { public Chunk getChunk() {
if (chunk == null) { if (this.chunk == null) {
final ChunkWrapper cl = getChunkWrapper(); ChunkWrapper cl = getChunkWrapper();
chunk = SpongeUtil.getWorld(cl.world).getChunk(cl.x, 0, cl.z).get(); this.chunk = SpongeUtil.getWorld(cl.world).getChunk(cl.x, 0, cl.z).get();
} }
return chunk; return this.chunk;
} }
@Override @Override
public void setChunkWrapper(final ChunkWrapper loc) { public void setChunkWrapper(ChunkWrapper loc) {
super.setChunkWrapper(loc); super.setChunkWrapper(loc);
chunk = null; this.chunk = null;
} }
/** /**
* Get the number of block changes in a specified section * Get the number of block changes in a specified section.
* @param i * @param i
* @return * @return
*/ */
public int getCount(final int i) { public int getCount(int i) {
return count[i]; return this.count[i];
} }
public int getAir(final int i) { public int getAir(int i) {
return air[i]; return this.air[i];
} }
public void setCount(int i, short value) { public void setCount(int i, short value) {
count[i] = value; this.count[i] = value;
} }
/** /**
* Get the number of block changes in a specified section * Get the number of block changes in a specified section.
* @param i * @param i
* @return * @return
*/ */
public int getRelight(final int i) { public int getRelight(int i) {
return relight[i]; return this.relight[i];
} }
public int getTotalCount() { public int getTotalCount() {
int total = 0; int total = 0;
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
total += count[i]; total += this.count[i];
} }
return total; return total;
} }
public int getTotalRelight() { public int getTotalRelight() {
if (getTotalCount() == 0) { if (getTotalCount() == 0) {
Arrays.fill(count, (short) 1); Arrays.fill(this.count, (short) 1);
Arrays.fill(relight, Short.MAX_VALUE); Arrays.fill(this.relight, Short.MAX_VALUE);
return Short.MAX_VALUE; return Short.MAX_VALUE;
} }
int total = 0; int total = 0;
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
total += relight[i]; total += this.relight[i];
} }
return total; return total;
} }
/** /**
* Get the raw data for a section * Get the raw data for a section.
* @param i * @param i
* @return * @return
*/ */
public char[] getIdArray(final int i) { public char[] getIdArray(int i) {
return ids[i]; return this.ids[i];
} }
@Override @Override
public void setBlock(final int x, final int y, final int z, final int id, byte data) { public void setBlock(int x, int y, int z, int id, byte data) {
final int i = MainUtil.CACHE_I[y][x][z]; int i = MainUtil.CACHE_I[y][x][z];
final int j = MainUtil.CACHE_J[y][x][z]; int j = MainUtil.CACHE_J[y][x][z];
char[] vs = ids[i]; char[] vs = this.ids[i];
if (vs == null) { if (vs == null) {
vs = ids[i] = new char[4096]; vs = this.ids[i] = new char[4096];
count[i]++; this.count[i]++;
} else if (vs[j] == 0) { } else if (vs[j] == 0) {
count[i]++; this.count[i]++;
} }
switch (id) { switch (id) {
case 0: case 0:
air[i]++; this.air[i]++;
vs[j] = (char) 1; vs[j] = (char) 1;
return; return;
case 10: case 10:
@ -128,7 +129,7 @@ public class FastChunk extends PlotChunk<Chunk> {
case 124: case 124:
case 138: case 138:
case 169: case 169:
relight[i]++; this.relight[i]++;
case 2: case 2:
case 4: case 4:
case 13: case 13:
@ -192,7 +193,7 @@ public class FastChunk extends PlotChunk<Chunk> {
case 130: case 130:
case 76: case 76:
case 62: case 62:
relight[i]++; this.relight[i]++;
case 54: case 54:
case 146: case 146:
case 61: case 61:
@ -211,12 +212,12 @@ public class FastChunk extends PlotChunk<Chunk> {
@Override @Override
public PlotChunk clone() { public PlotChunk clone() {
FastChunk toReturn = new FastChunk(getChunkWrapper()); FastChunk toReturn = new FastChunk(getChunkWrapper());
toReturn.air = air.clone(); toReturn.air = this.air.clone();
toReturn.count = count.clone(); toReturn.count = this.count.clone();
toReturn.relight = relight.clone(); toReturn.relight = this.relight.clone();
toReturn.ids = new char[ids.length][]; toReturn.ids = new char[this.ids.length][];
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < this.ids.length; i++) {
char[] matrix = ids[i]; char[] matrix = this.ids[i];
if (matrix != null) { if (matrix != null) {
toReturn.ids[i] = new char[matrix.length]; toReturn.ids[i] = new char[matrix.length];
System.arraycopy(matrix, 0, toReturn.ids[i], 0, matrix.length); System.arraycopy(matrix, 0, toReturn.ids[i], 0, matrix.length);
@ -228,18 +229,18 @@ public class FastChunk extends PlotChunk<Chunk> {
@Override @Override
public PlotChunk shallowClone() { public PlotChunk shallowClone() {
FastChunk toReturn = new FastChunk(getChunkWrapper()); FastChunk toReturn = new FastChunk(getChunkWrapper());
toReturn.air = air; toReturn.air = this.air;
toReturn.count = count; toReturn.count = this.count;
toReturn.relight = relight; toReturn.relight = this.relight;
toReturn.ids = ids; toReturn.ids = this.ids;
return toReturn; return toReturn;
} }
@Override @Override
public void setBiome(int x, int z, int biome) { public void setBiome(int x, int z, int biome) {
if (biomes == null) { if (this.biomes == null) {
biomes = new int[16][16]; this.biomes = new int[16][16];
} }
biomes[x][z] = biome; this.biomes[x][z] = biome;
} }
} }

View File

@ -76,14 +76,14 @@ public class FastQueue extends SlowQueue {
/** /**
* This should be overridden by any specialized queues. * This should be overridden by any specialized queues.
* @param pc * @param plotChunk
*/ */
@Override @Override
public void execute(PlotChunk<Chunk> pc) { public void execute(PlotChunk<Chunk> plotChunk) {
FastChunk fs = (FastChunk) pc; FastChunk fs = (FastChunk) plotChunk;
Chunk spongeChunk = pc.getChunk(); Chunk spongeChunk = plotChunk.getChunk();
net.minecraft.world.World nmsWorld = (net.minecraft.world.World) spongeChunk.getWorld(); net.minecraft.world.World nmsWorld = (net.minecraft.world.World) spongeChunk.getWorld();
ChunkWrapper wrapper = pc.getChunkWrapper(); ChunkWrapper wrapper = plotChunk.getChunkWrapper();
if (!this.toUpdate.containsKey(wrapper)) { if (!this.toUpdate.containsKey(wrapper)) {
this.toUpdate.put(wrapper, spongeChunk); this.toUpdate.put(wrapper, spongeChunk);
} }

View File

@ -1,12 +1,11 @@
package com.plotsquared.sponge.util.block; package com.plotsquared.sponge.util.block;
import org.spongepowered.api.world.Chunk;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotChunk; import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
import org.spongepowered.api.world.Chunk;
public class SlowChunk extends PlotChunk<Chunk> { public class SlowChunk extends PlotChunk<Chunk> {
@ -26,29 +25,29 @@ public class SlowChunk extends PlotChunk<Chunk> {
@Override @Override
public void setBiome(int x, int z, int biome) { public void setBiome(int x, int z, int biome) {
if (biomes == null) { if (this.biomes == null) {
biomes = new int[16][16]; this.biomes = new int[16][16];
} }
biomes[x][z] = biome; this.biomes[x][z] = biome;
} }
@Override @Override
public void setBlock(int x, int y, int z, int id, byte data) { public void setBlock(int x, int y, int z, int id, byte data) {
if (result[y >> 4] == null) { if (this.result[y >> 4] == null) {
result[y >> 4] = new PlotBlock[4096]; this.result[y >> 4] = new PlotBlock[4096];
} }
if (id == lastBlock.id && data == lastBlock.data) { if (id == this.lastBlock.id && data == this.lastBlock.data) {
result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = lastBlock; this.result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = this.lastBlock;
} else { } else {
result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = new PlotBlock((short) id, data); this.result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = new PlotBlock((short) id, data);
} }
} }
@Override @Override
public PlotChunk clone() { public PlotChunk clone() {
SlowChunk toReturn = new SlowChunk(getChunkWrapper()); SlowChunk toReturn = new SlowChunk(getChunkWrapper());
for (int i = 0; i < result.length; i++) { for (int i = 0; i < this.result.length; i++) {
PlotBlock[] matrix = result[i]; PlotBlock[] matrix = this.result[i];
if (matrix != null) { if (matrix != null) {
toReturn.result[i] = new PlotBlock[matrix.length]; toReturn.result[i] = new PlotBlock[matrix.length];
System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length); System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length);
@ -60,7 +59,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
@Override @Override
public PlotChunk shallowClone() { public PlotChunk shallowClone() {
SlowChunk toReturn = new SlowChunk(getChunkWrapper()); SlowChunk toReturn = new SlowChunk(getChunkWrapper());
toReturn.result = result; toReturn.result = this.result;
return toReturn; return toReturn;
} }
} }

View File

@ -1,13 +1,5 @@
package com.plotsquared.sponge.util.block; package com.plotsquared.sponge.util.block;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.world.Chunk;
import com.flowpowered.math.vector.Vector3i; import com.flowpowered.math.vector.Vector3i;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
@ -18,6 +10,13 @@ import com.intellectualcrafters.plot.util.PlotQueue;
import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.world.Chunk;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
public class SlowQueue implements PlotQueue<Chunk> { public class SlowQueue implements PlotQueue<Chunk> {
@ -28,18 +27,18 @@ public class SlowQueue implements PlotQueue<Chunk> {
if (y > 255 || y < 0) { if (y > 255 || y < 0) {
return false; return false;
} }
final ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, x >> 4, z >> 4); ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, x >> 4, z >> 4);
x = x & 15; x = x & 15;
z = z & 15; z = z & 15;
PlotChunk<Chunk> result = blocks.get(wrap); PlotChunk<Chunk> result = this.blocks.get(wrap);
if (result == null) { if (result == null) {
result = getChunk(wrap); result = getChunk(wrap);
result.setBlock(x, y, z, id, data); result.setBlock(x, y, z, id, data);
final PlotChunk<Chunk> previous = blocks.put(wrap, result); PlotChunk<Chunk> previous = this.blocks.put(wrap, result);
if (previous == null) { if (previous == null) {
return true; return true;
} }
blocks.put(wrap, previous); this.blocks.put(wrap, previous);
result = previous; result = previous;
} }
result.setBlock(x, y, z, id, data); result.setBlock(x, y, z, id, data);
@ -48,7 +47,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
@Override @Override
public void setChunk(PlotChunk<Chunk> chunk) { public void setChunk(PlotChunk<Chunk> chunk) {
blocks.put(chunk.getChunkWrapper(), chunk); this.blocks.put(chunk.getChunkWrapper(), chunk);
} }
@Override @Override
@ -57,11 +56,11 @@ public class SlowQueue implements PlotQueue<Chunk> {
throw new IllegalStateException("Must be called from main thread!"); throw new IllegalStateException("Must be called from main thread!");
} }
try { try {
if (blocks.isEmpty()) { if (this.blocks.isEmpty()) {
return null; return null;
} }
final Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iter = blocks.entrySet().iterator(); Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iter = this.blocks.entrySet().iterator();
final PlotChunk<Chunk> toReturn = iter.next().getValue(); PlotChunk<Chunk> toReturn = iter.next().getValue();
if (SetQueue.IMP.isWaiting()) { if (SetQueue.IMP.isWaiting()) {
return null; return null;
} }
@ -69,7 +68,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
execute(toReturn); execute(toReturn);
fixLighting(toReturn, true); fixLighting(toReturn, true);
return toReturn; return toReturn;
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
@ -81,17 +80,17 @@ public class SlowQueue implements PlotQueue<Chunk> {
throw new IllegalStateException("Must be called from main thread!"); throw new IllegalStateException("Must be called from main thread!");
} }
try { try {
if (blocks.isEmpty()) { if (this.blocks.isEmpty()) {
return null; return null;
} }
final PlotChunk<Chunk> toReturn = blocks.remove(wrap); PlotChunk<Chunk> toReturn = this.blocks.remove(wrap);
if (toReturn == null) { if (toReturn == null) {
return null; return null;
} }
execute(toReturn); execute(toReturn);
fixLighting(toReturn, fixLighting); fixLighting(toReturn, fixLighting);
return toReturn; return toReturn;
} catch (final Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
@ -99,16 +98,16 @@ public class SlowQueue implements PlotQueue<Chunk> {
@Override @Override
public void clear() { public void clear() {
blocks.clear(); this.blocks.clear();
} }
/** /**
* This should be overriden by any specialized queues * This should be overriden by any specialized queues.
* @param pc * @param plotChunk
*/ */
public void execute(PlotChunk<Chunk> pc) { public void execute(PlotChunk<Chunk> plotChunk) {
SlowChunk sc = (SlowChunk) pc; SlowChunk sc = (SlowChunk) plotChunk;
Chunk chunk = pc.getChunk(); Chunk chunk = plotChunk.getChunk();
chunk.loadChunk(true); chunk.loadChunk(true);
Vector3i min = chunk.getBlockMin(); Vector3i min = chunk.getBlockMin();
int bx = min.getX(); int bx = min.getX();
@ -119,9 +118,9 @@ public class SlowQueue implements PlotQueue<Chunk> {
continue; continue;
} }
for (int j = 0; j < 4096; j++) { for (int j = 0; j < 4096; j++) {
final int x = MainUtil.x_loc[i][j]; int x = MainUtil.x_loc[i][j];
final int y = MainUtil.y_loc[i][j]; int y = MainUtil.y_loc[i][j];
final int z = MainUtil.z_loc[i][j]; int z = MainUtil.z_loc[i][j];
PlotBlock newBlock = result2[j]; PlotBlock newBlock = result2[j];
BlockState state = SpongeUtil.getBlockState(newBlock.id, newBlock.data); BlockState state = SpongeUtil.getBlockState(newBlock.id, newBlock.data);
chunk.setBlock(bx + x, y, bz + z, state, false); chunk.setBlock(bx + x, y, bz + z, state, false);
@ -146,7 +145,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
} }
/** /**
* This should be overriden by any specialized queues * This should be overriden by any specialized queues.
* @param wrap * @param wrap
*/ */
@Override @Override
@ -155,7 +154,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
} }
/** /**
* This should be overriden by any specialized queues * This should be overriden by any specialized queues.
* @param fixAll * @param fixAll
*/ */
@Override @Override
@ -165,7 +164,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
} }
/** /**
* This should be overriden by any specialized queues * This should be overriden by any specialized queues.
* @param locs * @param locs
*/ */
@Override @Override