From 32ba55baf597f6f92d613ca851352a6f90043b81 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Tue, 29 Mar 2016 00:56:44 -0400 Subject: [PATCH] Code cleanup and Optimizations --- .../plot/api/PlotAPI.java | 27 ++--- .../plotsquared/bukkit/chat/JsonString.java | 10 +- .../bukkit/listeners/PlayerEvents.java | 10 +- .../bukkit/titles/DefaultTitleManager.java | 25 ++-- .../titles/DefaultTitleManager_183.java | 111 +++++++----------- .../bukkit/titles/HackTitleManager.java | 1 - .../com/plotsquared/bukkit/util/Metrics.java | 21 ++-- .../plotsquared/bukkit/util/NbtFactory.java | 4 +- .../bukkit/util/OfflinePlayerUtil.java | 2 +- .../plotsquared/bukkit/util/SendChunk.java | 4 +- .../configuration/MemorySection.java | 40 ------- .../jnbt/NBTOutputStream.java | 100 ++++++++-------- .../com/intellectualcrafters/json/JSONML.java | 21 ++-- .../com/intellectualcrafters/plot/PS.java | 2 +- .../plot/commands/Area.java | 4 +- .../plot/commands/Owner.java | 2 +- .../plot/commands/SchematicCmd.java | 7 +- .../plot/database/SQLManager.java | 4 +- .../intellectualcrafters/plot/flag/Flag.java | 57 ++++----- .../plot/object/Plot.java | 17 +-- .../plot/object/PlotArea.java | 4 +- .../plot/object/PlotCluster.java | 83 ++++++------- .../plot/object/PlotInventory.java | 81 +++++++------ .../plot/object/schematic/ItemType.java | 40 +++---- .../plot/util/MainUtil.java | 6 +- .../plot/util/helpmenu/HelpMenu.java | 48 ++++---- .../plot/util/helpmenu/HelpPage.java | 20 ++-- .../com/plotsquared/sponge/SpongeMain.java | 4 +- .../sponge/events/PlotClearEvent.java | 19 ++- .../sponge/listener/MainListener.java | 23 ++-- .../sponge/util/block/FastChunk.java | 101 ++++++++-------- .../sponge/util/block/FastQueue.java | 10 +- .../sponge/util/block/SlowChunk.java | 25 ++-- .../sponge/util/block/SlowQueue.java | 63 +++++----- 34 files changed, 456 insertions(+), 540 deletions(-) diff --git a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index d6c6b3b91..76d130ed1 100644 --- a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -39,19 +39,20 @@ import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.uuid.UUIDWrapper; 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.OfflinePlayer; import org.bukkit.World; import org.bukkit.entity.Player; 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
+ * PlotSquared API. *
* @version API 3.3.1 *
@@ -95,7 +96,7 @@ public class PlotAPI { } /** - * Get all plots + * Get 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 * @@ -117,7 +118,7 @@ public class PlotAPI { } /** - * Add a plot world + * Add a plot world. * * @param plotArea Plot World Object * @see PS#addPlotArea(PlotArea) @@ -491,7 +492,7 @@ public class PlotAPI { */ @Deprecated 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)) { pPlots.add(plot); } - } else { - if (plot.isAdded(uuid)) { - pPlots.add(plot); - } + } else if (plot.isAdded(uuid)) { + pPlots.add(plot); } } return pPlots.toArray(new Plot[pPlots.size()]); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java index 6fe69b265..823511bb1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java @@ -14,10 +14,10 @@ import java.util.Map; */ final class JsonString implements JsonRepresentedObject, ConfigurationSerializable { - private final String _value; + private final String value; public JsonString(CharSequence value) { - this._value = value == null ? null : value.toString(); + this.value = value == null ? null : value.toString(); } public static JsonString deserialize(Map map) { @@ -30,18 +30,18 @@ final class JsonString implements JsonRepresentedObject, ConfigurationSerializab } public String getValue() { - return this._value; + return this.value; } @Override public Map serialize() { HashMap theSingleValue = new HashMap<>(); - theSingleValue.put("stringValue", this._value); + theSingleValue.put("stringValue", this.value); return theSingleValue; } @Override public String toString() { - return this._value; + return this.value; } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 4e6e3deaf..8dcda91da 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -835,14 +835,14 @@ public class PlayerEvents extends PlotListener implements Listener { public void onChange(BlockFromToEvent e) { Block from = e.getBlock(); Block to = e.getToBlock(); - Location tloc = BukkitUtil.getLocation(to.getLocation()); - PlotArea area = tloc.getPlotArea(); + Location tLocation = BukkitUtil.getLocation(to.getLocation()); + PlotArea area = tLocation.getPlotArea(); if (area == null) { return; } - Plot plot = area.getOwnedPlot(tloc); - Location floc = BukkitUtil.getLocation(from.getLocation()); - if (!area.contains(floc.getX(), floc.getZ()) || !Objects.equals(plot, area.getOwnedPlot(floc)) || (plot != null && FlagManager + Plot plot = area.getOwnedPlot(tLocation); + Location fLocation = BukkitUtil.getLocation(from.getLocation()); + if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation)) || (plot != null && FlagManager .isPlotFlagTrue(plot, "disable-physics"))) { e.setCancelled(true); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java index 907ab7d80..4d34be9c6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java @@ -40,10 +40,9 @@ public class DefaultTitleManager { private boolean ticks = false; /** - * Create a new 1.8 title + * Create a new 1.8 title. * - * @param title - * Title + * @param title 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 - * Title text - * @param subtitle - * Subtitle text + * @param title Title text + * @param subtitle Subtitle text * @throws ClassNotFoundException */ public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException { @@ -118,8 +115,7 @@ public class DefaultTitleManager { } /** - * Load spigot and NMS classes - * @throws ClassNotFoundException + * Load spigot and NMS classes. */ private void loadClasses() { this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle"); @@ -129,7 +125,7 @@ public class DefaultTitleManager { } /** - * Get title text + * Get title text. * * @return Title text */ @@ -138,17 +134,16 @@ public class DefaultTitleManager { } /** - * Set title text + * Set title text. * - * @param title - * Title + * @param title Title */ public void setTitle(String title) { this.title = title; } /** - * Get subtitle text + * Get subtitle text. * * @return Subtitle text */ diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java index b21df89fd..e0ee10b99 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java @@ -6,7 +6,6 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; 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 - * Title text - * @param subtitle - * Subtitle text + * @param title Title text + * @param subtitle Subtitle text * @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 - * Title + * @param title 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 - * 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 * @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 - * @throws ClassNotFoundException + * Load spigot and NMS classes. */ private void loadClasses() { this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle"); @@ -136,7 +126,7 @@ public class DefaultTitleManager_183 { } /** - * Get title text + * Get title text. * * @return Title text */ @@ -145,17 +135,16 @@ public class DefaultTitleManager_183 { } /** - * Set title text + * Set title text. * - * @param title - * Title + * @param title Title */ public void setTitle(String title) { this.title = title; } /** - * Get subtitle text + * Get subtitle text. * * @return Subtitle text */ @@ -164,37 +153,34 @@ public class DefaultTitleManager_183 { } /** - * Set subtitle text + * Set subtitle text. * - * @param subtitle - * Subtitle text + * @param subtitle Subtitle text */ public void setSubtitle(String subtitle) { this.subtitle = subtitle; } /** - * Set the title color + * Set the title color. * - * @param color - * Chat color + * @param color Chat color */ public void setTitleColor(ChatColor color) { this.titleColor = color; } /** - * Set the subtitle color + * Set the subtitle color. * - * @param color - * Chat color + * @param color Chat color */ public void setSubtitleColor(ChatColor color) { this.subtitleColor = color; } /** - * Set title fade in time + * Set title fade in time. * * @param time * Time @@ -204,47 +190,42 @@ public class DefaultTitleManager_183 { } /** - * Set title fade out time + * Set title fade out time. * - * @param time - * Time + * @param time Time */ public void setFadeOutTime(int time) { this.fadeOutTime = time; } /** - * Set title stay time + * Set title stay time. * - * @param time - * Time + * @param time Time */ public void setStayTime(int time) { this.stayTime = time; } /** - * Set timings to ticks + * Set timings to ticks. */ public void setTimingsToTicks() { this.ticks = true; } /** - * Set timings to seconds + * Set timings to seconds. */ public void setTimingsToSeconds() { this.ticks = false; } /** - * Send the title to a player + * Send the title to a player. * - * @param player - * Player - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException + * @param player Player + * @throws Exception */ public void send(Player player) throws Exception { if (this.packetTitle != null) { @@ -258,11 +239,7 @@ public class DefaultTitleManager_183 { Object packet = this.packetTitle .getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE) .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)); // Send if set 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 */ public void broadcast() throws Exception { @@ -295,12 +272,10 @@ public class DefaultTitleManager_183 { } /** - * Clear the title + * Clear the title. * - * @param player - * Player - * @throws IllegalAccessException - * @throws IllegalArgumentException + * @param player Player + * @throws Exception */ public void clearTitle(Player player) throws Exception { // Send timings first @@ -313,16 +288,10 @@ public class DefaultTitleManager_183 { } /** - * Reset the title settings + * Reset the title settings. * - * @param player - * Player - * @throws SecurityException - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException - * @throws InstantiationException + * @param player Player + * @throws Exception */ public void resetTitle(Player player) throws Exception { // Send timings first diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java index 8a3f67bf7..5fd787a86 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java @@ -114,7 +114,6 @@ public class HackTitleManager { /** * Load spigot and NMS classes. - * @throws ClassNotFoundException Spigot Error. */ private void loadClasses() { this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle"); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java index d9d304404..7b1d6dc78 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java @@ -51,39 +51,39 @@ import java.util.zip.GZIPOutputStream; public class Metrics { /** - * The current revision number + * The current revision number. */ 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"; /** - * 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"; /** - * Interval of time to ping (in minutes) + * Interval of time to ping (in minutes). */ private static final int PING_INTERVAL = 15; /** - * The plugin this metrics submits for + * The plugin this metrics submits for. */ 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 graphs = Collections.synchronizedSet(new HashSet()); /** - * Unique server id + * Unique server id. */ private final String guid; /** - * Debug mode + * Debug mode. */ private final boolean debug; /** - * The scheduled task + * The scheduled task. */ 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 * @@ -129,7 +129,6 @@ public class Metrics { * @param key * @param value * - * @throws UnsupportedEncodingException */ private static void appendJSONPair(StringBuilder json, String key, String value) { boolean isValueNumeric = false; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java index 09a99dabf..d899ca8f5 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java @@ -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 bannedMod - modifiers that are banned. * @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 clazz - an optional class to start with, or NULL to deduce it from instance. * @param fieldName - the field name. diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java index 17b15e224..ae235b3b0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java @@ -56,7 +56,7 @@ public class OfflinePlayerUtil { return name; } 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); return callConstructor(gameProfileConstructor, id.toString(), name); } else { //Version has uuid constructor diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java index 362c6083a..1f446060c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java @@ -127,10 +127,10 @@ public class SendChunk { } } - public void sendChunk(String worldname, Collection locs) { + public void sendChunk(String worldname, Collection chunkLocs) { World myworld = Bukkit.getWorld(worldname); ArrayList chunks = new ArrayList<>(); - for (ChunkLoc loc : locs) { + for (ChunkLoc loc : chunkLocs) { if (myworld.isChunkLoaded(loc.x, loc.z)) { chunks.add(myworld.getChunkAt(loc.x, loc.z)); } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java index b170567ac..4b69c9787 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java @@ -539,10 +539,6 @@ public class MemorySection implements ConfigurationSection { public List getStringList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -558,10 +554,6 @@ public class MemorySection implements ConfigurationSection { public List getIntegerList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -586,10 +578,6 @@ public class MemorySection implements ConfigurationSection { public List getBooleanList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -611,10 +599,6 @@ public class MemorySection implements ConfigurationSection { public List getDoubleList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -639,10 +623,6 @@ public class MemorySection implements ConfigurationSection { public List getFloatList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -667,10 +647,6 @@ public class MemorySection implements ConfigurationSection { public List getLongList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -695,10 +671,6 @@ public class MemorySection implements ConfigurationSection { public List getByteList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -723,10 +695,6 @@ public class MemorySection implements ConfigurationSection { public List getCharacterList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -750,10 +718,6 @@ public class MemorySection implements ConfigurationSection { public List getShortList(String path) { List list = getList(path); - if (list == null) { - return new ArrayList<>(0); - } - List result = new ArrayList<>(); for (Object object : list) { @@ -779,10 +743,6 @@ public class MemorySection implements ConfigurationSection { List list = getList(path); List> result = new ArrayList<>(); - if (list == null) { - return result; - } - for (Object object : list) { if (object instanceof Map) { result.add((Map) object); diff --git a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java index cd11ccbb7..0894f8c54 100644 --- a/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/Core/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -48,7 +48,7 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - public NBTOutputStream(final OutputStream os) { + public NBTOutputStream(OutputStream os) { this.os = new DataOutputStream(os); } @@ -59,13 +59,13 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - public void writeTag(final Tag tag) throws IOException { - final int type = NBTUtils.getTypeCode(tag.getClass()); - final String name = tag.getName(); - final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET); - os.writeByte(type); - os.writeShort(nameBytes.length); - os.write(nameBytes); + public void writeTag(Tag tag) throws IOException { + int type = NBTUtils.getTypeCode(tag.getClass()); + String name = tag.getName(); + byte[] nameBytes = name.getBytes(NBTConstants.CHARSET); + this.os.writeByte(type); + this.os.writeShort(nameBytes.length); + this.os.write(nameBytes); if (type == NBTConstants.TYPE_END) { throw new IOException("Named TAG_End not permitted."); } @@ -79,8 +79,8 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeTagPayload(final Tag tag) throws IOException { - final int type = NBTUtils.getTypeCode(tag.getClass()); + private void writeTagPayload(Tag tag) throws IOException { + int type = NBTUtils.getTypeCode(tag.getClass()); switch (type) { case NBTConstants.TYPE_END: writeEndTagPayload((EndTag) tag); @@ -130,8 +130,8 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeByteTagPayload(final ByteTag tag) throws IOException { - os.writeByte(tag.getValue()); + private void writeByteTagPayload(ByteTag tag) throws IOException { + this.os.writeByte(tag.getValue()); } /** @@ -141,10 +141,10 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeByteArrayTagPayload(final ByteArrayTag tag) throws IOException { - final byte[] bytes = tag.getValue(); - os.writeInt(bytes.length); - os.write(bytes); + private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException { + byte[] bytes = tag.getValue(); + this.os.writeInt(bytes.length); + this.os.write(bytes); } /** @@ -154,11 +154,11 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeCompoundTagPayload(final CompoundTag tag) throws IOException { - for (final Tag childTag : tag.getValue().values()) { + private void writeCompoundTagPayload(CompoundTag tag) throws IOException { + for (Tag childTag : tag.getValue().values()) { 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. */ - private void writeListTagPayload(final ListTag tag) throws IOException { - final Class clazz = tag.getType(); - final List tags = tag.getValue(); - final int size = tags.size(); - os.writeByte(NBTUtils.getTypeCode(clazz)); - os.writeInt(size); - for (final Tag tag1 : tags) { + private void writeListTagPayload(ListTag tag) throws IOException { + Class clazz = tag.getType(); + List tags = tag.getValue(); + int size = tags.size(); + this.os.writeByte(NBTUtils.getTypeCode(clazz)); + this.os.writeInt(size); + for (Tag tag1 : tags) { writeTagPayload(tag1); } } @@ -186,10 +186,10 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeStringTagPayload(final StringTag tag) throws IOException { - final byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET); - os.writeShort(bytes.length); - os.write(bytes); + private void writeStringTagPayload(StringTag tag) throws IOException { + byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET); + this.os.writeShort(bytes.length); + this.os.write(bytes); } /** @@ -199,8 +199,8 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeDoubleTagPayload(final DoubleTag tag) throws IOException { - os.writeDouble(tag.getValue()); + private void writeDoubleTagPayload(DoubleTag tag) throws IOException { + this.os.writeDouble(tag.getValue()); } /** @@ -210,8 +210,8 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeFloatTagPayload(final FloatTag tag) throws IOException { - os.writeFloat(tag.getValue()); + private void writeFloatTagPayload(FloatTag tag) throws IOException { + this.os.writeFloat(tag.getValue()); } /** @@ -221,8 +221,8 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeLongTagPayload(final LongTag tag) throws IOException { - os.writeLong(tag.getValue()); + private void writeLongTagPayload(LongTag tag) throws IOException { + this.os.writeLong(tag.getValue()); } /** @@ -232,8 +232,8 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeIntTagPayload(final IntTag tag) throws IOException { - os.writeInt(tag.getValue()); + private void writeIntTagPayload(IntTag tag) throws IOException { + this.os.writeInt(tag.getValue()); } /** @@ -243,32 +243,30 @@ public final class NBTOutputStream implements Closeable { * * @throws IOException if an I/O error occurs. */ - private void writeShortTagPayload(final ShortTag tag) throws IOException { - os.writeShort(tag.getValue()); + private void writeShortTagPayload(ShortTag tag) throws IOException { + this.os.writeShort(tag.getValue()); } /** * Writes a TAG_Empty tag. * * @param tag The tag. - * - * @throws IOException if an I/O error occurs. */ - private void writeEndTagPayload(final EndTag tag) { + private void writeEndTagPayload(EndTag tag) { /* empty */ } - - private void writeIntArrayTagPayload(final IntArrayTag tag) throws IOException { - final int[] data = tag.getValue(); - os.writeInt(data.length); - for (final int element : data) { - os.writeInt(element); + + private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException { + int[] data = tag.getValue(); + this.os.writeInt(data.length); + for (int element : data) { + this.os.writeInt(element); } } @Override public void close() throws IOException { - os.close(); + this.os.close(); } /** @@ -276,6 +274,6 @@ public final class NBTOutputStream implements Closeable { * @throws IOException */ public void flush() throws IOException { - os.flush(); + this.os.flush(); } } diff --git a/Core/src/main/java/com/intellectualcrafters/json/JSONML.java b/Core/src/main/java/com/intellectualcrafters/json/JSONML.java index 43d2431d5..0b1f9ece4 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/JSONML.java +++ b/Core/src/main/java/com/intellectualcrafters/json/JSONML.java @@ -21,7 +21,7 @@ public class JSONML { * * @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; char c; String closeTag = null; @@ -114,9 +114,6 @@ public class JSONML { if (token == null) { token = x.nextToken(); } - if (token == null) { - throw x.syntaxError("Misshaped tag"); - } if (!(token instanceof String)) { break; } @@ -195,7 +192,7 @@ public class JSONML { * * @throws JSONException */ - public static JSONArray toJSONArray(final String string) throws JSONException { + public static JSONArray toJSONArray(String string) throws JSONException { return toJSONArray(new XMLTokener(string)); } @@ -212,7 +209,7 @@ public class JSONML { * * @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); } @@ -230,7 +227,7 @@ public class JSONML { * * @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); } @@ -248,7 +245,7 @@ public class JSONML { * * @throws JSONException */ - public static JSONObject toJSONObject(final String string) throws JSONException { + public static JSONObject toJSONObject(String string) throws JSONException { return toJSONObject(new XMLTokener(string)); } @@ -261,14 +258,14 @@ public class JSONML { * * @throws JSONException */ - public static String toString(final JSONArray ja) throws JSONException { + public static String toString(JSONArray ja) throws JSONException { int i; JSONObject jo; String key; Iterator keys; int length; Object object; - final StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); String tagName; String value; // Emit o = new HashMap<>(); + Map o = new HashMap<>(4); o.put("color.1", "6"); o.put("color.2", "7"); o.put("color.3", "8"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java index f5267a008..0be86107b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -137,7 +137,7 @@ public class Area extends SubCommand { }, null); } } 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); plr.teleport(WorldUtil.IMP.getSpawn(world)); } 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 { PS.get().config.save(PS.get().configFile); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java index 3e43d170d..76f87fd6f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Owner.java @@ -42,7 +42,7 @@ import java.util.UUID; aliases = {"owner", "so", "seto"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, - confirmation=true) + confirmation = true) public class Owner extends SetCommand { @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index d2fb04e54..32c30e03b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -189,8 +189,8 @@ public class SchematicCmd extends SubCommand { MainUtil.sendMessage(plr, "&cTask is already running."); return false; } else { - MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&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: &7Mass export has started. This may take a while."); + MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots..."); } break; } @@ -204,7 +204,6 @@ public class SchematicCmd extends SubCommand { MainUtil.sendMessage(plr, "&cTask is already running."); return false; } - Plot p2; Location loc = plr.getLocation(); Plot plot = loc.getPlotAbs(); if (plot == null) { @@ -218,7 +217,7 @@ public class SchematicCmd extends SubCommand { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } - p2 = plot; + Plot p2 = plot; loc.getWorld(); Collection plots = new ArrayList(); plots.add(p2); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 8a9f2ba56..587f356d7 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -954,7 +954,7 @@ public class SQLManager implements AbstractDB { } /** - * Create a plot + * Create a plot. * * @param plot */ @@ -1038,7 +1038,7 @@ public class SQLManager implements AbstractDB { } /** - * Create tables + * Create tables. * * @throws SQLException */ diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index c72720461..cde856235 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -31,15 +31,16 @@ public class Flag implements Cloneable { 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 - * player, you need to register it with PlotSquared. + * 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 */ - public Flag(final AbstractFlag key, final String value) { + public Flag(AbstractFlag key, String value) { if (!StringMan.isAsciiPrintable(value)) { throw new IllegalArgumentException("Flag must be ascii"); } @@ -55,8 +56,10 @@ public class Flag implements Cloneable { /** * Warning: Unchecked + * @param key + * @param value */ - public Flag(final AbstractFlag key, final Object value) { + public Flag(AbstractFlag key, Object value) { this.key = key; this.value = value; } @@ -66,53 +69,53 @@ public class Flag implements Cloneable { } /** - * Get the AbstractFlag used in creating the flag + * Get the AbstractFlag used in creating the flag. * * @return AbstractFlag */ public AbstractFlag getAbstractFlag() { - return key; + return this.key; } /** - * Get the key for the AbstractFlag + * Get the key for the AbstractFlag. * * @return String */ public String getKey() { - return key.getKey(); + return this.key.getKey(); } - public void setKey(final AbstractFlag key) { + public void setKey(AbstractFlag key) { this.key = key; - if (value instanceof String) { - value = key.parseValueRaw((String) value); + if (this.value instanceof String) { + this.value = key.parseValueRaw((String) this.value); } } /** - * Get the value + * Get the value. * * @return String */ public Object getValue() { - return value; + return this.value; } public String getValueString() { - return key.toString(value); + return this.key.toString(this.value); } @Override public String toString() { - if ("".equals(value)) { - return key.getKey(); + if ("".equals(this.value)) { + return this.key.getKey(); } - return key + ":" + getValueString(); + return this.key + ":" + getValueString(); } @Override - public boolean equals(final Object obj) { + public boolean equals(Object obj) { if (this == obj) { return true; } @@ -122,29 +125,29 @@ public class Flag implements Cloneable { if (getClass() != obj.getClass()) { return false; } - final Flag other = (Flag) obj; - return key.getKey().equals(other.key.getKey()) && value.equals(other.value); + Flag other = (Flag) obj; + return this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value); } @Override public int hashCode() { - return key.getKey().hashCode(); + return this.key.getKey().hashCode(); } @Override protected Object clone() { try { - if (value == null) { + if (this.value == null) { return super.clone(); } - if (value instanceof Cloneable) { - Method method = value.getClass().getDeclaredMethod("clone"); + if (this.value instanceof Cloneable) { + Method method = this.value.getClass().getDeclaredMethod("clone"); if (!method.isAccessible()) { 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) { e.printStackTrace(); } @@ -152,6 +155,6 @@ public class Flag implements Cloneable { } public String getName() { - return name; + return this.name; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index ed94e7087..0462c73ae 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -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 */ public HashSet getOwners() { @@ -474,7 +474,7 @@ public class Plot { } /** - * Get or create plot settings + * Get or create plot settings. * @return PlotSettings * @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 */ 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 */ public boolean isMerged() { @@ -603,7 +604,7 @@ public class Plot { } /** - * Get the denied users + * Get the denied users. * @return */ public HashSet getDenied() { @@ -614,7 +615,7 @@ public class Plot { } /** - * Set the denied users for this plot + * Set the denied users for this plot. * @param uuids */ public void setDenied(Set uuids) { @@ -633,7 +634,7 @@ public class Plot { } /** - * Get the trusted users + * Get the trusted users. * @return */ public HashSet getTrusted() { @@ -644,7 +645,7 @@ public class Plot { } /** - * Set the trusted users for this plot + * Set the trusted users for this plot. * @param uuids */ public void setTrusted(Set uuids) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index e8ad7fd33..082a9ecb2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -294,9 +294,9 @@ public abstract class PlotArea { } List flags = config.getStringList("flags.default"); - if (flags == null || flags.isEmpty()) { + if (flags.isEmpty()) { flags = config.getStringList("flags"); - if (flags == null || flags.isEmpty()) { + if (flags.isEmpty()) { flags = new ArrayList<>(); ConfigurationSection section = config.getConfigurationSection("flags"); Set keys = section.getKeys(false); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java index dc1e116c5..e86db5f43 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java @@ -17,71 +17,72 @@ public class PlotCluster { private PlotId pos2; 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.pos1 = pos1; this.pos2 = pos2; this.owner = owner; - settings = new PlotSettings(); + this.settings = new PlotSettings(); this.temp = -1; 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.pos1 = pos1; this.pos2 = pos2; this.owner = owner; - settings = new PlotSettings(); + this.settings = new PlotSettings(); this.temp = temp; setRegion(); } public PlotId getP1() { - return pos1; + return this.pos1; } - public void setP1(final PlotId id) { - pos1 = id; + public void setP1(PlotId id) { + this.pos1 = id; setRegion(); } public PlotId getP2() { - return pos2; + return this.pos2; } - public void setP2(final PlotId id) { - pos2 = id; + public void setP2(PlotId id) { + this.pos2 = id; 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() { - return region; + return this.region; } - public boolean isAdded(final UUID uuid) { - return owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers + public boolean isAdded(UUID uuid) { + return this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid) + || this.helpers .contains(DBFunc.everyone); } - - public boolean hasHelperRights(final UUID uuid) { - return owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone); + + public boolean hasHelperRights(UUID uuid) { + return this.owner.equals(uuid) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone); } public String getName() { - return settings.getAlias(); + return this.settings.getAlias(); } /** - * Get the area (in plots) + * Get the area (in plots). * @return */ 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) { @@ -94,11 +95,11 @@ public class PlotCluster { @Override public int hashCode() { - return pos1.hashCode(); + return this.pos1.hashCode(); } @Override - public boolean equals(final Object obj) { + public boolean equals(Object obj) { if (this == obj) { return true; } @@ -108,31 +109,31 @@ public class PlotCluster { if (getClass() != obj.getClass()) { return false; } - final PlotCluster other = (PlotCluster) obj; - return pos1.equals(other.pos1) && pos2.equals(other.pos2) && area.equals(other.area); + PlotCluster other = (PlotCluster) obj; + return this.pos1.equals(other.pos1) && this.pos2.equals(other.pos2) && this.area.equals(other.area); } @Override 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() { - final BlockLoc home = settings.getPosition(); + BlockLoc home = this.settings.getPosition(); Location toReturn; if (home.y == 0) { // default pos - final Plot center = getCenterPlot(); + Plot center = getCenterPlot(); toReturn = center.getHome(); if (toReturn.getY() == 0) { - final PlotManager manager = area.getPlotManager(); - final Location loc = manager.getSignLoc(area, center); + PlotManager manager = this.area.getPlotManager(); + Location loc = manager.getSignLoc(this.area, center); toReturn.setY(loc.getY()); } } else { 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()) { toReturn.setY(max); } @@ -140,30 +141,30 @@ public class PlotCluster { } public PlotId getCenterPlotId() { - final PlotId bot = getP1(); - final PlotId top = getP2(); + PlotId bot = getP1(); + PlotId top = getP2(); return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); } public Plot getCenterPlot() { - return area.getPlotAbs(getCenterPlotId()); + return this.area.getPlotAbs(getCenterPlotId()); } public Location getClusterBottom() { - final PlotManager manager = area.getPlotManager(); - return manager.getPlotBottomLocAbs(area, getP1()); + PlotManager manager = this.area.getPlotManager(); + return manager.getPlotBottomLocAbs(this.area, getP1()); } public Location getClusterTop() { - final PlotManager manager = area.getPlotManager(); - return manager.getPlotTopLocAbs(area, getP2()); + PlotManager manager = this.area.getPlotManager(); + return manager.getPlotTopLocAbs(this.area, getP2()); } 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; } - - public boolean contains(final PlotId id) { - return pos1.x <= id.x && pos1.y <= id.y && pos2.x >= id.x && pos2.y >= id.y; + + public boolean contains(PlotId id) { + return this.pos1.x <= id.x && this.pos1.y <= id.y && this.pos2.x >= id.x && this.pos2.y >= id.y; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java index 662b9aa9a..a2bc9760b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java @@ -3,82 +3,81 @@ package com.intellectualcrafters.plot.object; import com.intellectualcrafters.plot.util.InventoryUtil; public class PlotInventory { - + public final PlotPlayer player; public final int size; - private String title; private final PlotItemStack[] items; - + private String title; private boolean open = false; - - public PlotInventory(final PlotPlayer player) { - size = 4; - title = null; + + public PlotInventory(PlotPlayer player) { + this.size = 4; + this.title = null; 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; - title = name == null ? "" : name; + this.title = name == null ? "" : name; 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; } - + public void openInventory() { - if (title == null) { + if (this.title == null) { return; } - open = true; + this.open = true; InventoryUtil.manager.open(this); } - + public void close() { - if (title == null) { + if (this.title == null) { return; } InventoryUtil.manager.close(this); - open = false; + this.open = false; } - - public void setItem(final int index, final PlotItemStack item) { - items[index] = item; + + public void setItem(int index, PlotItemStack item) { + this.items[index] = item; InventoryUtil.manager.setItem(this, index, item); } - - public PlotItemStack getItem(final int index) { - if ((index < 0) || (index >= items.length)) { + + public PlotItemStack getItem(int index) { + if ((index < 0) || (index >= this.items.length)) { 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) { return; } - final boolean tmp = open; + boolean tmp = this.open; close(); this.title = title; if (tmp) { openInventory(); } } - - public PlotItemStack[] getItems() { - return items; - } - - public String getTitle() { - return title; - } - + public boolean isOpen() { - return open; + return this.open; } - + } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/schematic/ItemType.java b/Core/src/main/java/com/intellectualcrafters/plot/object/schematic/ItemType.java index 929c91a55..096479827 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/schematic/ItemType.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/schematic/ItemType.java @@ -599,43 +599,43 @@ public enum ItemType { WARD_DISC("record_ward", 2265), DISC_11("record_11", 2266), WAIT_DISC("record_wait", 2267); - - private static final Map ids = new HashMap(); - private static final Map datas = new HashMap(); - - private final int id; - private final byte data; - private final String name; - + + private static final Map ids = new HashMap<>(); + private static final Map datas = new HashMap<>(); + static { - for (final ItemType type : EnumSet.allOf(ItemType.class)) { + for (ItemType type : EnumSet.allOf(ItemType.class)) { ids.put(type.name, type.id); 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; - data = 0; + this.data = 0; this.name = name; } - - ItemType(final String name, final int id, final int data) { + + ItemType(String name, int id, int data) { this.id = id; this.data = (byte) data; this.name = name; } - - public static int getId(final String name) { - final Integer value = ids.get(name); + + public static int getId(String name) { + Integer value = ids.get(name); if (value == null) { return 0; } return value; } - - public static byte getData(final String name) { - final Byte value = datas.get(name); + + public static byte getData(String name) { + Byte value = datas.get(name); if (value == null) { return 0; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index c27671b7c..d8577e438 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -229,17 +229,13 @@ public class MainUtil { if (MathMan.isInteger(string)) { return Long.parseLong(string); } - if (string == null) { - return 0; - } string = string.toLowerCase().trim().toLowerCase(); if (string.equalsIgnoreCase("false")) { return 0; } String[] split = string.split(" "); long time = 0; - for (int i = 0; i < split.length; i++) { - String value = split[i]; + for (String value : split) { int nums = Integer.parseInt(value.replaceAll("[^\\d]", "")); String letters = value.replaceAll("[^a-z]", ""); switch (letters) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpMenu.java b/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpMenu.java index c894f5c9d..43aa936d3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpMenu.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpMenu.java @@ -1,58 +1,58 @@ package com.intellectualcrafters.plot.util.helpmenu; -import java.util.List; - import com.intellectualcrafters.plot.commands.CommandCategory; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.general.commands.Command; +import java.util.List; + public class HelpMenu { public static final int PER_PAGE = 5; - - private final PlotPlayer _player; - private HelpPage _page = new HelpPage(CommandCategory.INFO, 0, 0); - private int _maxPage; - private CommandCategory _commandCategory; - private List _commands; - - public HelpMenu(final PlotPlayer player) { - _player = player; + + private final PlotPlayer player; + private HelpPage page = new HelpPage(CommandCategory.INFO, 0, 0); + private int maxPage; + private CommandCategory commandCategory; + private List commands; + + public HelpMenu(PlotPlayer player) { + this.player = player; } - - public HelpMenu setCategory(final CommandCategory commandCategory) { - _commandCategory = commandCategory; + + public HelpMenu setCategory(CommandCategory commandCategory) { + this.commandCategory = commandCategory; return this; } public HelpMenu getCommands() { - _commands = MainCommand.getInstance().getCommands(_commandCategory, _player); + this.commands = MainCommand.getInstance().getCommands(this.commandCategory, this.player); return this; } 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; } - - public HelpMenu generatePage(int currentPage, final String label) { - if (currentPage > _maxPage) { - currentPage = _maxPage; + + public HelpMenu generatePage(int currentPage, String label) { + if (currentPage > this.maxPage) { + currentPage = this.maxPage; } if (currentPage < 0) { currentPage = 0; } - _page = new HelpPage(_commandCategory, currentPage, _maxPage); - final int max = Math.min((currentPage * PER_PAGE) + (PER_PAGE - 1), _commands.size()); + this.page = new HelpPage(this.commandCategory, currentPage, this.maxPage); + int max = Math.min((currentPage * PER_PAGE) + (PER_PAGE - 1), this.commands.size()); 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; } public void render() { - _page.render(_player); + this.page.render(this.player); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpPage.java b/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpPage.java index d6875c8d4..bbb3571bc 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpPage.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/helpmenu/HelpPage.java @@ -5,29 +5,31 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringMan; + import java.util.ArrayList; import java.util.List; public class HelpPage { private final List helpObjects; - private final String _header; + private final String header; - public HelpPage(final CommandCategory category, final int currentPage, final int maxPages) { - helpObjects = new ArrayList<>(); - _header = C.HELP_PAGE_HEADER.s().replace("%category%", category == null ? "ALL" : category.toString()).replace("%current%", (currentPage + 1) + "").replace("%max%", (maxPages + 1) + ""); + public HelpPage(CommandCategory category, int currentPage, int maxPages) { + this.helpObjects = new ArrayList<>(); + 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) { - if (helpObjects.size() < 1) { + public void render(PlotPlayer player) { + if (this.helpObjects.size() < 1) { MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0)"); } 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); } } - public void addHelpItem(final HelpObject object) { - helpObjects.add(object); + public void addHelpItem(HelpObject object) { + this.helpObjects.add(object); } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 15ea7e549..fc314cbf3 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -143,7 +143,7 @@ public class SpongeMain implements IPlotMain { if (!Settings.CONSOLE_COLOR) { message = message.replaceAll('\u00a7' + "[a-z|0-9]", ""); } - if (this.server == null || this.server.getConsole() == null) { + if (this.server == null) { this.logger.info(message); return; } @@ -306,7 +306,7 @@ public class SpongeMain implements IPlotMain { @Override public void startMetrics() { try { - Metrics metrics = new Metrics(this.game, plugin); + Metrics metrics = new Metrics(this.game, this.plugin); metrics.start(); log(C.PREFIX.s() + "&6Metrics enabled."); } catch (IOException e) { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java b/Sponge/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java index 9dd91f05d..8e545e84c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java @@ -1,16 +1,15 @@ package com.plotsquared.sponge.events; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; import org.spongepowered.api.event.Cancellable; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.impl.AbstractEvent; -import com.intellectualcrafters.plot.object.PlotId; - public class PlotClearEvent extends AbstractEvent implements Cancellable { + private final Plot plot; private boolean cancelled; - private Plot plot; /** * 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 */ public PlotId getPlotId() { - return plot.getId(); + return this.plot.getId(); } /** - * Get the world name + * Get the world name. * * @return String */ public String getWorld() { - return plot.getArea().worldname; + return this.plot.getArea().worldname; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override - public void setCancelled(final boolean cancel) { - cancelled = cancel; + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @Override diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java index ded58815a..15a7ecd85 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -24,14 +24,6 @@ import com.plotsquared.listener.PlotListener; import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; 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.BlockState; 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.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 { /* @@ -159,7 +160,7 @@ public class MainListener { } ((SpongePlayer) user).player.sendMessage(Text.join(components)); } - event.setMessage(null); + //event.setMessage(null); } @Listener @@ -185,7 +186,7 @@ public class MainListener { @Listener public void onSpawnEntity(SpawnEntityEvent event) throws Exception { World world = event.getTargetWorld(); - event.filterEntities((Predicate) entity -> { + event.filterEntities(entity -> { if (entity instanceof Player) { return true; } @@ -396,7 +397,7 @@ public class MainListener { return; } } - if (currentPlot == null || !FlagManager.isPlotFlagTrue(currentPlot, "explosion")) { + if (!FlagManager.isPlotFlagTrue(currentPlot, "explosion")) { event.filterAll(); return; } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastChunk.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastChunk.java index a7652c4d2..646c8cf56 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastChunk.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastChunk.java @@ -16,12 +16,13 @@ public class FastChunk extends PlotChunk { public short[] relight; public int[][] biomes; public Chunk chunk; - public FastChunk(final ChunkWrapper chunk) { + + public FastChunk(ChunkWrapper chunk) { super(chunk); - ids = new char[16][]; - count = new short[16]; - air = new short[16]; - relight = new short[16]; + this.ids = new char[16][]; + this.count = new short[16]; + this.air = new short[16]; + this.relight = new short[16]; } @Override @@ -32,89 +33,89 @@ public class FastChunk extends PlotChunk { @Override public Chunk getChunk() { - if (chunk == null) { - final ChunkWrapper cl = getChunkWrapper(); - chunk = SpongeUtil.getWorld(cl.world).getChunk(cl.x, 0, cl.z).get(); + if (this.chunk == null) { + ChunkWrapper cl = getChunkWrapper(); + this.chunk = SpongeUtil.getWorld(cl.world).getChunk(cl.x, 0, cl.z).get(); } - return chunk; + return this.chunk; } @Override - public void setChunkWrapper(final ChunkWrapper loc) { + public void setChunkWrapper(ChunkWrapper 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 * @return */ - public int getCount(final int i) { - return count[i]; + public int getCount(int i) { + return this.count[i]; } - public int getAir(final int i) { - return air[i]; + public int getAir(int i) { + return this.air[i]; } 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 * @return */ - public int getRelight(final int i) { - return relight[i]; + public int getRelight(int i) { + return this.relight[i]; } public int getTotalCount() { int total = 0; for (int i = 0; i < 16; i++) { - total += count[i]; + total += this.count[i]; } return total; } public int getTotalRelight() { if (getTotalCount() == 0) { - Arrays.fill(count, (short) 1); - Arrays.fill(relight, Short.MAX_VALUE); + Arrays.fill(this.count, (short) 1); + Arrays.fill(this.relight, Short.MAX_VALUE); return Short.MAX_VALUE; } int total = 0; for (int i = 0; i < 16; i++) { - total += relight[i]; + total += this.relight[i]; } return total; } /** - * Get the raw data for a section + * Get the raw data for a section. * @param i * @return */ - public char[] getIdArray(final int i) { - return ids[i]; + public char[] getIdArray(int i) { + return this.ids[i]; } @Override - public void setBlock(final int x, final int y, final int z, final int id, byte data) { - final int i = MainUtil.CACHE_I[y][x][z]; - final int j = MainUtil.CACHE_J[y][x][z]; - char[] vs = ids[i]; + public void setBlock(int x, int y, int z, int id, byte data) { + int i = MainUtil.CACHE_I[y][x][z]; + int j = MainUtil.CACHE_J[y][x][z]; + char[] vs = this.ids[i]; if (vs == null) { - vs = ids[i] = new char[4096]; - count[i]++; + vs = this.ids[i] = new char[4096]; + this.count[i]++; } else if (vs[j] == 0) { - count[i]++; + this.count[i]++; } switch (id) { case 0: - air[i]++; + this.air[i]++; vs[j] = (char) 1; return; case 10: @@ -128,7 +129,7 @@ public class FastChunk extends PlotChunk { case 124: case 138: case 169: - relight[i]++; + this.relight[i]++; case 2: case 4: case 13: @@ -192,7 +193,7 @@ public class FastChunk extends PlotChunk { case 130: case 76: case 62: - relight[i]++; + this.relight[i]++; case 54: case 146: case 61: @@ -211,12 +212,12 @@ public class FastChunk extends PlotChunk { @Override public PlotChunk clone() { FastChunk toReturn = new FastChunk(getChunkWrapper()); - toReturn.air = air.clone(); - toReturn.count = count.clone(); - toReturn.relight = relight.clone(); - toReturn.ids = new char[ids.length][]; - for (int i = 0; i < ids.length; i++) { - char[] matrix = ids[i]; + toReturn.air = this.air.clone(); + toReturn.count = this.count.clone(); + toReturn.relight = this.relight.clone(); + toReturn.ids = new char[this.ids.length][]; + for (int i = 0; i < this.ids.length; i++) { + char[] matrix = this.ids[i]; if (matrix != null) { toReturn.ids[i] = new char[matrix.length]; System.arraycopy(matrix, 0, toReturn.ids[i], 0, matrix.length); @@ -228,18 +229,18 @@ public class FastChunk extends PlotChunk { @Override public PlotChunk shallowClone() { FastChunk toReturn = new FastChunk(getChunkWrapper()); - toReturn.air = air; - toReturn.count = count; - toReturn.relight = relight; - toReturn.ids = ids; + toReturn.air = this.air; + toReturn.count = this.count; + toReturn.relight = this.relight; + toReturn.ids = this.ids; return toReturn; } @Override public void setBiome(int x, int z, int biome) { - if (biomes == null) { - biomes = new int[16][16]; + if (this.biomes == null) { + this.biomes = new int[16][16]; } - biomes[x][z] = biome; + this.biomes[x][z] = biome; } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastQueue.java index 0abd7d481..811946123 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/FastQueue.java @@ -76,14 +76,14 @@ public class FastQueue extends SlowQueue { /** * This should be overridden by any specialized queues. - * @param pc + * @param plotChunk */ @Override - public void execute(PlotChunk pc) { - FastChunk fs = (FastChunk) pc; - Chunk spongeChunk = pc.getChunk(); + public void execute(PlotChunk plotChunk) { + FastChunk fs = (FastChunk) plotChunk; + Chunk spongeChunk = plotChunk.getChunk(); net.minecraft.world.World nmsWorld = (net.minecraft.world.World) spongeChunk.getWorld(); - ChunkWrapper wrapper = pc.getChunkWrapper(); + ChunkWrapper wrapper = plotChunk.getChunkWrapper(); if (!this.toUpdate.containsKey(wrapper)) { this.toUpdate.put(wrapper, spongeChunk); } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowChunk.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowChunk.java index 0fb6dba20..f8e789407 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowChunk.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowChunk.java @@ -1,12 +1,11 @@ package com.plotsquared.sponge.util.block; -import org.spongepowered.api.world.Chunk; - import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.PlotChunk; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.plotsquared.sponge.util.SpongeUtil; +import org.spongepowered.api.world.Chunk; public class SlowChunk extends PlotChunk { @@ -26,29 +25,29 @@ public class SlowChunk extends PlotChunk { @Override public void setBiome(int x, int z, int biome) { - if (biomes == null) { - biomes = new int[16][16]; + if (this.biomes == null) { + this.biomes = new int[16][16]; } - biomes[x][z] = biome; + this.biomes[x][z] = biome; } @Override public void setBlock(int x, int y, int z, int id, byte data) { - if (result[y >> 4] == null) { - result[y >> 4] = new PlotBlock[4096]; + if (this.result[y >> 4] == null) { + this.result[y >> 4] = new PlotBlock[4096]; } - if (id == lastBlock.id && data == lastBlock.data) { - result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = lastBlock; + if (id == this.lastBlock.id && data == this.lastBlock.data) { + this.result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = this.lastBlock; } 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 public PlotChunk clone() { SlowChunk toReturn = new SlowChunk(getChunkWrapper()); - for (int i = 0; i < result.length; i++) { - PlotBlock[] matrix = result[i]; + for (int i = 0; i < this.result.length; i++) { + PlotBlock[] matrix = this.result[i]; if (matrix != null) { toReturn.result[i] = new PlotBlock[matrix.length]; System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length); @@ -60,7 +59,7 @@ public class SlowChunk extends PlotChunk { @Override public PlotChunk shallowClone() { SlowChunk toReturn = new SlowChunk(getChunkWrapper()); - toReturn.result = result; + toReturn.result = this.result; return toReturn; } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java index b478f15a5..6e7ceda80 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java @@ -1,13 +1,5 @@ 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.intellectualcrafters.plot.PS; 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.ChunkWrapper; 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 { @@ -28,18 +27,18 @@ public class SlowQueue implements PlotQueue { if (y > 255 || y < 0) { 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; z = z & 15; - PlotChunk result = blocks.get(wrap); + PlotChunk result = this.blocks.get(wrap); if (result == null) { result = getChunk(wrap); result.setBlock(x, y, z, id, data); - final PlotChunk previous = blocks.put(wrap, result); + PlotChunk previous = this.blocks.put(wrap, result); if (previous == null) { return true; } - blocks.put(wrap, previous); + this.blocks.put(wrap, previous); result = previous; } result.setBlock(x, y, z, id, data); @@ -48,7 +47,7 @@ public class SlowQueue implements PlotQueue { @Override public void setChunk(PlotChunk chunk) { - blocks.put(chunk.getChunkWrapper(), chunk); + this.blocks.put(chunk.getChunkWrapper(), chunk); } @Override @@ -57,11 +56,11 @@ public class SlowQueue implements PlotQueue { throw new IllegalStateException("Must be called from main thread!"); } try { - if (blocks.isEmpty()) { + if (this.blocks.isEmpty()) { return null; } - final Iterator>> iter = blocks.entrySet().iterator(); - final PlotChunk toReturn = iter.next().getValue(); + Iterator>> iter = this.blocks.entrySet().iterator(); + PlotChunk toReturn = iter.next().getValue(); if (SetQueue.IMP.isWaiting()) { return null; } @@ -69,7 +68,7 @@ public class SlowQueue implements PlotQueue { execute(toReturn); fixLighting(toReturn, true); return toReturn; - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); return null; } @@ -81,17 +80,17 @@ public class SlowQueue implements PlotQueue { throw new IllegalStateException("Must be called from main thread!"); } try { - if (blocks.isEmpty()) { + if (this.blocks.isEmpty()) { return null; } - final PlotChunk toReturn = blocks.remove(wrap); + PlotChunk toReturn = this.blocks.remove(wrap); if (toReturn == null) { return null; } execute(toReturn); fixLighting(toReturn, fixLighting); return toReturn; - } catch (final Throwable e) { + } catch (Throwable e) { e.printStackTrace(); return null; } @@ -99,16 +98,16 @@ public class SlowQueue implements PlotQueue { @Override public void clear() { - blocks.clear(); + this.blocks.clear(); } /** - * This should be overriden by any specialized queues - * @param pc + * This should be overriden by any specialized queues. + * @param plotChunk */ - public void execute(PlotChunk pc) { - SlowChunk sc = (SlowChunk) pc; - Chunk chunk = pc.getChunk(); + public void execute(PlotChunk plotChunk) { + SlowChunk sc = (SlowChunk) plotChunk; + Chunk chunk = plotChunk.getChunk(); chunk.loadChunk(true); Vector3i min = chunk.getBlockMin(); int bx = min.getX(); @@ -119,9 +118,9 @@ public class SlowQueue implements PlotQueue { continue; } for (int j = 0; j < 4096; j++) { - final int x = MainUtil.x_loc[i][j]; - final int y = MainUtil.y_loc[i][j]; - final int z = MainUtil.z_loc[i][j]; + int x = MainUtil.x_loc[i][j]; + int y = MainUtil.y_loc[i][j]; + int z = MainUtil.z_loc[i][j]; PlotBlock newBlock = result2[j]; BlockState state = SpongeUtil.getBlockState(newBlock.id, newBlock.data); chunk.setBlock(bx + x, y, bz + z, state, false); @@ -146,7 +145,7 @@ public class SlowQueue implements PlotQueue { } /** - * This should be overriden by any specialized queues + * This should be overriden by any specialized queues. * @param wrap */ @Override @@ -155,7 +154,7 @@ public class SlowQueue implements PlotQueue { } /** - * This should be overriden by any specialized queues + * This should be overriden by any specialized queues. * @param fixAll */ @Override @@ -165,7 +164,7 @@ public class SlowQueue implements PlotQueue { } /** - * This should be overriden by any specialized queues + * This should be overriden by any specialized queues. * @param locs */ @Override