diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java index 998e4d118..6658981e3 100644 --- a/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/src/main/java/com/intellectualcrafters/plot/PS.java @@ -879,7 +879,7 @@ public class PS return -1; } else if (b.getTimestamp() > a.getTimestamp()) { - return 1; + return 1; } return 0; } @@ -970,7 +970,7 @@ public class PS return -1; } else if (b.getTimestamp() > a.getTimestamp()) { - return 1; + return 1; } return 0; } @@ -1003,7 +1003,7 @@ public class PS return -1; } else if (b.getTimestamp() > a.getTimestamp()) { - return 1; + return 1; } return 0; } @@ -1150,7 +1150,7 @@ public class PS public int compare(final String a, final String b) { if ((priorityWorld != null) && StringMan.isEqual(a, priorityWorld)) { - return -1; + return -1; } return a.hashCode() - b.hashCode(); } diff --git a/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index d4d64ad32..1acaf78a3 100644 --- a/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -89,9 +89,9 @@ public class PlotAPI * @deprecated Use this class if you just want to do a few simple things.
* - It will remain stable for future versions of the plugin * - The PlotPlayer and Plot class should be considered relatively safe - * - For more advanced/intensive tasks you should consider using other classes - * - * + * - For more advanced/intensive tasks you should consider using other classes + * + * */ @Deprecated public PlotAPI() diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/src/main/java/com/intellectualcrafters/plot/commands/Home.java index a2e509fe0..0627a3b12 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -21,6 +21,8 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; +import java.util.Iterator; +import java.util.Set; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; @@ -51,7 +53,16 @@ public class Home extends SubCommand @Override public boolean onCommand(final PlotPlayer plr, String[] args) { - final ArrayList plots = PS.get().sortPlotsByTemp(PS.get().getPlots(plr));//PS.get().sortPlots(PS.get().getPlots(plr), SortType.CREATION_DATE, null); + final Set all = PS.get().getPlots(plr); + final Iterator iter = all.iterator(); + while (iter.hasNext()) + { + if (!iter.next().isBasePlot()) + { + iter.remove(); + } + } + final ArrayList plots = PS.get().sortPlotsByTemp(all); if (plots.size() == 1) { MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 516b8de2f..00823b6e4 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -159,12 +159,12 @@ public class Info extends SubCommand final UUID uuid = player.getUUID(); final String name = MainUtil.getName(plot.owner); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] { - "&cID: &6" + plot.getId().toString(), - "&cOwner: &6" + name, - "&cAlias: &6" + plot.getSettings().getAlias(), - "&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(), - "&cCan Build: &6" + plot.isAdded(uuid), - "&cIs Denied: &6" + plot.isDenied(uuid) })); + "&cID: &6" + plot.getId().toString(), + "&cOwner: &6" + name, + "&cAlias: &6" + plot.getSettings().getAlias(), + "&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(), + "&cCan Build: &6" + plot.isAdded(uuid), + "&cIs Denied: &6" + plot.isDenied(uuid) })); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] { "&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users" })); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] { "&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members" })); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] { "&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players" })); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 574e3c282..08fa2c4ca 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -61,7 +61,7 @@ public class MusicSubcommand extends SubCommand { final PlotItemStack item = getItem(index); if (item == null) { - return true; + return true; } final int id = item.id == 7 ? 0 : item.id; if (id == 0) diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index c0a10c8d9..59d3e9a5c 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.UUID; @@ -114,6 +115,14 @@ public class Visit extends SubCommand } final Plot plot = plots.get(index); + final Iterator iter = plots.iterator(); + while (iter.hasNext()) + { + if (!iter.next().isBasePlot()) + { + iter.remove(); + } + } if (!plot.hasOwner()) { if (!Permissions.hasPermission(plr, "plots.visit.unowned")) diff --git a/src/main/java/com/intellectualcrafters/plot/commands/list.java b/src/main/java/com/intellectualcrafters/plot/commands/list.java index 5ac8ae5ee..e20ebefdd 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -248,7 +248,7 @@ public class list extends SubCommand if (MathMan.isInteger(va)) { if (MathMan.isInteger(vb)) { - return Integer.parseInt(vb) - Integer.parseInt(va); + return Integer.parseInt(vb) - Integer.parseInt(va); } return -1; } @@ -296,7 +296,7 @@ public class list extends SubCommand v2 += p2s; } if ((v2 == v1) && (v2 != 0)) { - return p2s - p1s; + return p2s - p1s; } return (int) Math.signum(v2 - v1); } diff --git a/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/src/main/java/com/intellectualcrafters/plot/config/Configuration.java index 59005ed1c..ba5cec947 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -148,7 +148,7 @@ public class Configuration public String parseString(final String string) { if (validateValue(string)) { - return string.toUpperCase(); + return string.toUpperCase(); } return "FOREST"; } @@ -209,7 +209,7 @@ public class Configuration } final StringComparison.ComparisonResult value = BlockManager.manager.getClosestBlock(block); if ((value == null) || (value.match > 1)) { - return false; + return false; } } return true; diff --git a/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/src/main/java/com/intellectualcrafters/plot/config/Settings.java index d91b2769f..4a7ef85e6 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -215,9 +215,9 @@ public class Settings * MongoDB enabled? */ public static boolean USE_MONGO = false; /* - * TODO: Implement Mongo - * @Brandon - */ + * TODO: Implement Mongo + * @Brandon + */ /** * SQLite enabled? */ diff --git a/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 8c6dd961b..fd14e5172 100644 --- a/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -2289,9 +2289,9 @@ public class SQLManager implements AbstractDB public PreparedStatement get() throws SQLException { if (plot != null) { - return connection.prepareStatement("DELETE FROM `" - + prefix - + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `comment` = ? AND `inbox` = ? AND `sender` = ?"); + return connection.prepareStatement("DELETE FROM `" + + prefix + + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `comment` = ? AND `inbox` = ? AND `sender` = ?"); } return connection.prepareStatement("DELETE FROM `" + prefix + "plot_comments` WHERE `comment` = ? AND `inbox` = ? AND `sender` = ?"); } @@ -2322,7 +2322,7 @@ public class SQLManager implements AbstractDB public PreparedStatement get() throws SQLException { if (plot != null) { - return connection.prepareStatement("DELETE FROM `" + prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `inbox` = ?"); + return connection.prepareStatement("DELETE FROM `" + prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `inbox` = ?"); } return connection.prepareStatement("DELETE FROM `" + prefix + "plot_comments` `inbox` = ?"); } @@ -2353,7 +2353,7 @@ public class SQLManager implements AbstractDB public PreparedStatement get() throws SQLException { if (plot != null) { - return connection.prepareStatement("SELECT * FROM `" + prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `inbox` = ?"); + return connection.prepareStatement("SELECT * FROM `" + prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `inbox` = ?"); } return connection.prepareStatement("SELECT * FROM `" + prefix + "plot_comments` WHERE `inbox` = ?"); } diff --git a/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 3bf7705eb..9de8e3597 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -144,29 +144,31 @@ public class Plot this.id = id; this.owner = owner; } - + /** * Return a new/cached plot object at a given world/plot id - * + * * @see MainUtil#getPlotSelectionOwned(String world, PlotId bottom, PlotId top) return a list of owned plots between (inclusive) two plot ids. - * + * * @param world * @param id * @return */ - public static Plot getPlot(String world, PlotId id) { + public static Plot getPlot(final String world, final PlotId id) + { return MainUtil.getPlot(world, id); } - + /** * Return a new/cached plot object at a given location - * + * * @see PlotPlayer#getCurrentPlot() if a player is expected here. - * + * * @param loc * @return */ - public static Plot getPlot(Location loc) { + public static Plot getPlot(final Location loc) + { return MainUtil.getPlot(loc); } @@ -192,7 +194,7 @@ public class Plot /** * Constructor for a saved plots (Used by the database manager when plots are fetched) - * + * * @see MainUtil#getPlot(String, PlotId) for existing plots * * @param id @@ -793,7 +795,7 @@ public class Plot /** * Register a plot and create it in the database
* - The plot will not be created if the owner is null
- * - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation. + * - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation. * @return true if plot was created successfully */ public boolean create() diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 1ac4b6559..ae5099b70 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -120,11 +120,11 @@ public abstract class PlotPlayer implements CommandCaller } /** - * Get the number of plots the player owns - * + * Get the number of plots the player owns + * * @see #getPlotCount(String); * @see #getPlots() - * + * * @return number of plots within the scope (globally, or in the player's current world as defined in the settings.yml) */ public int getPlotCount() diff --git a/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java b/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java index 5a8362a87..4595e4108 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java +++ b/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java @@ -72,54 +72,54 @@ public class BO3Handler for (int x = pos1.getX(); x <= pos2.getX(); x++) { final int X = ((x + 7) - cx) >> 4; - final int xx = (x - cx) % 16; - for (int z = pos1.getZ(); z <= pos2.getZ(); z++) + final int xx = (x - cx) % 16; + for (int z = pos1.getZ(); z <= pos2.getZ(); z++) + { + final int Z = ((z + 7) - cz) >> 4; + final int zz = (z - cz) % 16; + final ChunkLoc loc = new ChunkLoc(X, Z); + BO3 bo3 = map.get(loc); + for (int y = 1; y < height; y++) + { + final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z)); + if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) { - final int Z = ((z + 7) - cz) >> 4; - final int zz = (z - cz) % 16; - final ChunkLoc loc = new ChunkLoc(X, Z); - BO3 bo3 = map.get(loc); - for (int y = 1; y < height; y++) + if (bo3 == null) { - final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z)); - if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) - { - if (bo3 == null) - { - bo3 = new BO3(alias, loc); - map.put(loc, bo3); - content = true; - } - bo3.addBlock(xx, y - height - 1, zz, block); - } - } - final PlotBlock floor = BlockManager.manager.getBlock(new Location(plot.world, x, height, z)); - if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) - { - if (bo3 == null) - { - bo3 = new BO3(alias, loc); - map.put(loc, bo3); - content = true; - } - bo3.addBlock(xx, -1, zz, floor); - } - for (int y = height + 1; y < 256; y++) - { - final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z)); - if ((block != null) && (block.id != 0)) - { - if (bo3 == null) - { - bo3 = new BO3(alias, loc); - map.put(loc, bo3); - content = true; - } - bo3.addBlock(xx, y - height - 1, zz, block); - } + bo3 = new BO3(alias, loc); + map.put(loc, bo3); + content = true; } + bo3.addBlock(xx, y - height - 1, zz, block); } } + final PlotBlock floor = BlockManager.manager.getBlock(new Location(plot.world, x, height, z)); + if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) + { + if (bo3 == null) + { + bo3 = new BO3(alias, loc); + map.put(loc, bo3); + content = true; + } + bo3.addBlock(xx, -1, zz, floor); + } + for (int y = height + 1; y < 256; y++) + { + final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z)); + if ((block != null) && (block.id != 0)) + { + if (bo3 == null) + { + bo3 = new BO3(alias, loc); + map.put(loc, bo3); + content = true; + } + bo3.addBlock(xx, y - height - 1, zz, block); + } + } + } + } if (!content) { diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 06233179a..51af4e1ce 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -66,6 +66,9 @@ public class MainUtil public static short[][] y_loc; public static short[][] z_loc; + /** + * This cache is used for world generation and just saves a bit of calculation time when checking if something is in the plot area. + */ public static void initCache() { if (x_loc == null) @@ -602,7 +605,7 @@ public class MainUtil } TaskManager.TELEPORT_QUEUE.remove(name); if (!player.isOnline()) { - return; + return; } sendMessage(player, C.TELEPORTED_TO_PLOT); player.teleport(location); @@ -655,21 +658,21 @@ public class MainUtil final Location top = getPlotTopLoc(plot.world, plot.id); final int bx = bot.getX() >> 4; - final int bz = bot.getZ() >> 4; + final int bz = bot.getZ() >> 4; - final int tx = (top.getX() >> 4); - final int tz = (top.getZ() >> 4); + final int tx = (top.getX() >> 4); + final int tz = (top.getZ() >> 4); - final ArrayList chunks = new ArrayList<>(); + final ArrayList chunks = new ArrayList<>(); - for (int x = bx; x <= tx; x++) - { - for (int z = bz; z <= tz; z++) - { - chunks.add(new ChunkLoc(x, z)); - } - } - BlockUpdateUtil.setBlockManager.update(plot.world, chunks); + for (int x = bx; x <= tx; x++) + { + for (int z = bz; z <= tz; z++) + { + chunks.add(new ChunkLoc(x, z)); + } + } + BlockUpdateUtil.setBlockManager.update(plot.world, chunks); } public static void createWorld(final String world, final String generator) diff --git a/src/main/java/com/intellectualcrafters/plot/util/NbtFactory.java b/src/main/java/com/intellectualcrafters/plot/util/NbtFactory.java index 2487dcb18..77fe1d17a 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/NbtFactory.java +++ b/src/main/java/com/intellectualcrafters/plot/util/NbtFactory.java @@ -381,7 +381,7 @@ public class NbtFactory LOAD_COMPOUND = READ_LIMITER_CLASS != null ? new LoadMethodSkinUpdate(STREAM_TOOLS, READ_LIMITER_CLASS) : - new LoadMethodWorldUpdate(STREAM_TOOLS); + new LoadMethodWorldUpdate(STREAM_TOOLS); SAVE_COMPOUND = getMethod(Modifier.STATIC, 0, STREAM_TOOLS, null, BASE_CLASS, DataOutput.class); } @@ -544,7 +544,7 @@ public class NbtFactory output = stream.getOutput(); data = new DataOutputStream( option == StreamOptions.GZIP_COMPRESSION ? new GZIPOutputStream(output) : output - ); + ); invokeMethod(get().SAVE_COMPOUND, null, source.getHandle(), data); suppress = false; diff --git a/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java b/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java index 22cc17e85..f18d6229e 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java +++ b/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java @@ -99,7 +99,7 @@ public class SetBlockQueue public void run() { if (locked) { - return; + return; } if ((blocks == null) || (blocks.size() == 0)) { @@ -125,7 +125,7 @@ public class SetBlockQueue while ((blocks.size() > 0) && ((System.currentTimeMillis() - last) < (50 + allocate))) { if (locked) { - return; + return; } final Iterator> iter = blocks.entrySet().iterator(); if (!iter.hasNext()) @@ -232,29 +232,29 @@ public class SetBlockQueue init(); } final int X = x >> 4; - final int Z = z >> 4; - x -= X << 4; - z -= Z << 4; + final int Z = z >> 4; + x -= X << 4; + z -= Z << 4; - final ChunkWrapper wrap = new ChunkWrapper(world, X, Z); - PlotBlock[][] result; - result = blocks.get(wrap); - if (!blocks.containsKey(wrap)) - { - result = new PlotBlock[16][]; - blocks.put(wrap, result); - } - if ((y > 255) || (y < 0)) - { - locked = false; - return; - } - if (result[y >> 4] == null) - { - result[y >> 4] = new PlotBlock[4096]; - } - result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = block; - locked = false; + final ChunkWrapper wrap = new ChunkWrapper(world, X, Z); + PlotBlock[][] result; + result = blocks.get(wrap); + if (!blocks.containsKey(wrap)) + { + result = new PlotBlock[16][]; + blocks.put(wrap, result); + } + if ((y > 255) || (y < 0)) + { + locked = false; + return; + } + if (result[y >> 4] == null) + { + result[y >> 4] = new PlotBlock[4096]; + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = block; + locked = false; } public static void setData(final String world, int x, final int y, int z, final byte data) @@ -265,32 +265,32 @@ public class SetBlockQueue init(); } final int X = x >> 4; - final int Z = z >> 4; - x -= X << 4; - z -= Z << 4; - final ChunkWrapper wrap = new ChunkWrapper(world, X, Z); - PlotBlock[][] result; - result = blocks.get(wrap); - if (result == null) - { - if (blocks == null) - { - init(); - } - result = new PlotBlock[16][]; - blocks.put(wrap, result); - } - if ((y > 255) || (y < 0)) - { - locked = false; - return; - } - if (result[y >> 4] == null) - { - result[y >> 4] = new PlotBlock[4096]; - } - result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = new PlotBlock((short) -1, data); - locked = false; + final int Z = z >> 4; + x -= X << 4; + z -= Z << 4; + final ChunkWrapper wrap = new ChunkWrapper(world, X, Z); + PlotBlock[][] result; + result = blocks.get(wrap); + if (result == null) + { + if (blocks == null) + { + init(); + } + result = new PlotBlock[16][]; + blocks.put(wrap, result); + } + if ((y > 255) || (y < 0)) + { + locked = false; + return; + } + if (result[y >> 4] == null) + { + result[y >> 4] = new PlotBlock[4096]; + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = new PlotBlock((short) -1, data); + locked = false; } public static void setBlock(final String world, int x, final int y, int z, final int id) @@ -301,41 +301,41 @@ public class SetBlockQueue init(); } final int X = x >> 4; - final int Z = z >> 4; - x -= X << 4; - z -= Z << 4; - final ChunkWrapper wrap = new ChunkWrapper(world, X, Z); - PlotBlock[][] result; - result = blocks.get(wrap); - if (result == null) - { - if (blocks == null) - { - init(); - } - result = new PlotBlock[16][]; - blocks.put(wrap, result); - } - if ((y > 255) || (y < 0)) - { - locked = false; - return; - } - if (result[y >> 4] == null) - { - result[y >> 4] = new PlotBlock[4096]; - } - if (id == lastInt) - { - result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = lastBlock; - } - else - { - lastInt = id; - lastBlock = new PlotBlock((short) id, (byte) 0); - } - result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = lastBlock; - locked = false; + final int Z = z >> 4; + x -= X << 4; + z -= Z << 4; + final ChunkWrapper wrap = new ChunkWrapper(world, X, Z); + PlotBlock[][] result; + result = blocks.get(wrap); + if (result == null) + { + if (blocks == null) + { + init(); + } + result = new PlotBlock[16][]; + blocks.put(wrap, result); + } + if ((y > 255) || (y < 0)) + { + locked = false; + return; + } + if (result[y >> 4] == null) + { + result[y >> 4] = new PlotBlock[4096]; + } + if (id == lastInt) + { + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = lastBlock; + } + else + { + lastInt = id; + lastBlock = new PlotBlock((short) id, (byte) 0); + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = lastBlock; + locked = false; } public static class ChunkWrapper diff --git a/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java b/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java index 34fc5131e..dbe86c334 100644 --- a/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java +++ b/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java @@ -563,7 +563,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< return this; } - */ + */ /** * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message. diff --git a/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java b/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java index 263f556c6..901a64839 100644 --- a/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java +++ b/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java @@ -372,7 +372,7 @@ public class EntityWrapper } case ARMOR_STAND: { // NEW - // CHECK positions + // CHECK positions final ArmorStand stand = (ArmorStand) entity; inventory = new ItemStack[] { stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(), stand.getLeggings().clone(), stand.getBoots().clone() }; storeLiving((LivingEntity) entity); @@ -665,7 +665,7 @@ public class EntityWrapper } case ARMOR_STAND: { // NEW - // CHECK positions + // CHECK positions final ArmorStand stand = (ArmorStand) entity; if (inventory[0] != null) { diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index e58f968bc..8372d52af 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -315,181 +315,181 @@ public class BukkitChunkManager extends ChunkManager final int p2x = pos2.getX(); final int p2z = pos2.getZ(); final int bcx = p1x >> 4; - final int bcz = p1z >> 4; - final int tcx = p2x >> 4; - final int tcz = p2z >> 4; + final int bcz = p1z >> 4; + final int tcx = p2x >> 4; + final int tcz = p2z >> 4; - final boolean canRegen = ((plotworld.TYPE != 0) && (plotworld.TERRAIN == 0)); + final boolean canRegen = ((plotworld.TYPE != 0) && (plotworld.TERRAIN == 0)); - final ArrayList chunks = new ArrayList(); + final ArrayList chunks = new ArrayList(); - for (int x = bcx; x <= tcx; x++) - { - for (int z = bcz; z <= tcz; z++) - { - chunks.add(new ChunkLoc(x, z)); - } - } - - AugmentedPopulator augpop = null; - final World worldObj = Bukkit.getWorld(world); - final List populators = worldObj.getPopulators(); - for (final BlockPopulator populator : populators) - { - if (populator instanceof AugmentedPopulator) - { - final AugmentedPopulator current = ((AugmentedPopulator) populator); - if (current.cluster == null) + for (int x = bcx; x <= tcx; x++) { - augpop = current; - break; - } - else if (ClusterManager.contains(current.cluster, pos1)) - { - augpop = current; - break; - } - } - } - final Random r = new Random(System.currentTimeMillis()); - final AugmentedPopulator ap = augpop; - TaskManager.runTask(new Runnable() - { - @Override - public void run() - { - final long start = System.currentTimeMillis(); - while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 5)) - { - final ChunkLoc chunk = chunks.remove(0); - final int x = chunk.x; - final int z = chunk.z; - final int xxb = x << 4; - final int zzb = z << 4; - final int xxt = xxb + 15; - final int zzt = zzb + 15; - CURRENT_PLOT_CLEAR = null; - final Chunk chunkObj = worldObj.getChunkAt(x, z); - if (!chunkObj.load(false)) + for (int z = bcz; z <= tcz; z++) { - continue; + chunks.add(new ChunkLoc(x, z)); } - CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); - if ((xxb >= p1x) && (xxt <= p2x) && (zzb >= p1z) && (zzt <= p2z)) + } + + AugmentedPopulator augpop = null; + final World worldObj = Bukkit.getWorld(world); + final List populators = worldObj.getPopulators(); + for (final BlockPopulator populator : populators) + { + if (populator instanceof AugmentedPopulator) { - if (canRegen && (ap != null)) + final AugmentedPopulator current = ((AugmentedPopulator) populator); + if (current.cluster == null) { - ap.populate(worldObj, r, chunkObj); + augpop = current; + break; + } + else if (ClusterManager.contains(current.cluster, pos1)) + { + augpop = current; + break; + } + } + } + final Random r = new Random(System.currentTimeMillis()); + final AugmentedPopulator ap = augpop; + TaskManager.runTask(new Runnable() + { + @Override + public void run() + { + final long start = System.currentTimeMillis(); + while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 5)) + { + final ChunkLoc chunk = chunks.remove(0); + final int x = chunk.x; + final int z = chunk.z; + final int xxb = x << 4; + final int zzb = z << 4; + final int xxt = xxb + 15; + final int zzt = zzb + 15; + CURRENT_PLOT_CLEAR = null; + final Chunk chunkObj = worldObj.getChunkAt(x, z); + if (!chunkObj.load(false)) + { + continue; + } + CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); + if ((xxb >= p1x) && (xxt <= p2x) && (zzb >= p1z) && (zzt <= p2z)) + { + if (canRegen && (ap != null)) + { + ap.populate(worldObj, r, chunkObj); + } + else + { + regenerateChunk(world, chunk); + } + continue; + } + boolean checkX1 = false; + boolean checkX2 = false; + boolean checkZ1 = false; + boolean checkZ2 = false; + + int xxb2; + int zzb2; + int xxt2; + int zzt2; + + if (x == bcx) + { + xxb2 = p1x - 1; + checkX1 = true; + } + else + { + xxb2 = xxb; + } + if (x == tcx) + { + xxt2 = p2x + 1; + checkX2 = true; + } + else + { + xxt2 = xxt; + } + if (z == bcz) + { + zzb2 = p1z - 1; + checkZ1 = true; + } + else + { + zzb2 = zzb; + } + if (z == tcz) + { + zzt2 = p2z + 1; + checkZ2 = true; + } + else + { + zzt2 = zzt; + } + initMaps(); + if (checkX1) + { + saveRegion(worldObj, xxb, xxb2, zzb2, zzt2); // + } + if (checkX2) + { + saveRegion(worldObj, xxt2, xxt, zzb2, zzt2); // + } + if (checkZ1) + { + saveRegion(worldObj, xxb2, xxt2, zzb, zzb2); // + } + if (checkZ2) + { + saveRegion(worldObj, xxb2, xxt2, zzt2, zzt); // + } + if (checkX1 && checkZ1) + { + saveRegion(worldObj, xxb, xxb2, zzb, zzb2); // + } + if (checkX2 && checkZ1) + { + saveRegion(worldObj, xxt2, xxt, zzb, zzb2); // ? + } + if (checkX1 && checkZ2) + { + saveRegion(worldObj, xxb, xxb2, zzt2, zzt); // ? + } + if (checkX2 && checkZ2) + { + saveRegion(worldObj, xxt2, xxt, zzt2, zzt); // + } + saveEntitiesOut(chunkObj, CURRENT_PLOT_CLEAR); + if (canRegen && (ap != null)) + { + ap.populate(worldObj, r, chunkObj); + } + else + { + regenerateChunk(world, chunk); + } + restoreBlocks(worldObj, 0, 0); + restoreEntities(worldObj, 0, 0); + } + CURRENT_PLOT_CLEAR = null; + if (chunks.size() != 0) + { + TaskManager.runTaskLater(this, 1); } else { - regenerateChunk(world, chunk); + TaskManager.runTaskLater(whenDone, 1); } - continue; } - boolean checkX1 = false; - boolean checkX2 = false; - boolean checkZ1 = false; - boolean checkZ2 = false; - - int xxb2; - int zzb2; - int xxt2; - int zzt2; - - if (x == bcx) - { - xxb2 = p1x - 1; - checkX1 = true; - } - else - { - xxb2 = xxb; - } - if (x == tcx) - { - xxt2 = p2x + 1; - checkX2 = true; - } - else - { - xxt2 = xxt; - } - if (z == bcz) - { - zzb2 = p1z - 1; - checkZ1 = true; - } - else - { - zzb2 = zzb; - } - if (z == tcz) - { - zzt2 = p2z + 1; - checkZ2 = true; - } - else - { - zzt2 = zzt; - } - initMaps(); - if (checkX1) - { - saveRegion(worldObj, xxb, xxb2, zzb2, zzt2); // - } - if (checkX2) - { - saveRegion(worldObj, xxt2, xxt, zzb2, zzt2); // - } - if (checkZ1) - { - saveRegion(worldObj, xxb2, xxt2, zzb, zzb2); // - } - if (checkZ2) - { - saveRegion(worldObj, xxb2, xxt2, zzt2, zzt); // - } - if (checkX1 && checkZ1) - { - saveRegion(worldObj, xxb, xxb2, zzb, zzb2); // - } - if (checkX2 && checkZ1) - { - saveRegion(worldObj, xxt2, xxt, zzb, zzb2); // ? - } - if (checkX1 && checkZ2) - { - saveRegion(worldObj, xxb, xxb2, zzt2, zzt); // ? - } - if (checkX2 && checkZ2) - { - saveRegion(worldObj, xxt2, xxt, zzt2, zzt); // - } - saveEntitiesOut(chunkObj, CURRENT_PLOT_CLEAR); - if (canRegen && (ap != null)) - { - ap.populate(worldObj, r, chunkObj); - } - else - { - regenerateChunk(world, chunk); - } - restoreBlocks(worldObj, 0, 0); - restoreEntities(worldObj, 0, 0); - } - CURRENT_PLOT_CLEAR = null; - if (chunks.size() != 0) - { - TaskManager.runTaskLater(this, 1); - } - else - { - TaskManager.runTaskLater(whenDone, 1); - } - } - }); - return true; + }); + return true; } public static void initMaps() @@ -1293,91 +1293,91 @@ public class BukkitChunkManager extends ChunkManager final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); final int bx = bot.getX() >> 4; - final int bz = bot.getZ() >> 4; + final int bz = bot.getZ() >> 4; - final int tx = top.getX() >> 4; - final int tz = top.getZ() >> 4; + final int tx = top.getX() >> 4; + final int tz = top.getZ() >> 4; - final int size = (tx - bx) << 4; + final int size = (tx - bx) << 4; - final HashSet chunks = new HashSet<>(); - for (int X = bx; X <= tx; X++) - { - for (int Z = bz; Z <= tz; Z++) - { - chunks.add(world.getChunkAt(X, Z)); - } - } - - boolean doWhole = false; - List entities = null; - if (size > 200) - { - entities = world.getEntities(); - if (entities.size() < (16 + ((size * size) / 64))) - { - doWhole = true; - } - } - - if (doWhole) - { - for (final Entity entity : entities) - { - if (!((entity instanceof Creature) || (entity instanceof Vehicle))) - { - continue; - } - final org.bukkit.Location loc = entity.getLocation(); - final Chunk chunk = loc.getChunk(); - if (chunks.contains(chunk)) - { - final int X = chunk.getX(); - final int Z = chunk.getX(); - if ((X > bx) && (X < tx) && (Z > bz) && (Z < tz)) - { - count(count, entity); - } - else - { - final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc)); - if (plot.id.equals(id)) + final HashSet chunks = new HashSet<>(); + for (int X = bx; X <= tx; X++) { - count(count, entity); + for (int Z = bz; Z <= tz; Z++) + { + chunks.add(world.getChunkAt(X, Z)); + } } - } - } - } - } - else - { - for (final Chunk chunk : chunks) - { - final int X = chunk.getX(); - final int Z = chunk.getX(); - final Entity[] ents = chunk.getEntities(); - for (final Entity entity : ents) - { - if (!((entity instanceof Creature) || (entity instanceof Vehicle))) - { - continue; - } - if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) - { - final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); - if (plot.id.equals(id)) + + boolean doWhole = false; + List entities = null; + if (size > 200) { - count(count, entity); + entities = world.getEntities(); + if (entities.size() < (16 + ((size * size) / 64))) + { + doWhole = true; + } } - } - else - { - count(count, entity); - } - } - } - } - return count; + + if (doWhole) + { + for (final Entity entity : entities) + { + if (!((entity instanceof Creature) || (entity instanceof Vehicle))) + { + continue; + } + final org.bukkit.Location loc = entity.getLocation(); + final Chunk chunk = loc.getChunk(); + if (chunks.contains(chunk)) + { + final int X = chunk.getX(); + final int Z = chunk.getX(); + if ((X > bx) && (X < tx) && (Z > bz) && (Z < tz)) + { + count(count, entity); + } + else + { + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc)); + if (plot.id.equals(id)) + { + count(count, entity); + } + } + } + } + } + else + { + for (final Chunk chunk : chunks) + { + final int X = chunk.getX(); + final int Z = chunk.getX(); + final Entity[] ents = chunk.getEntities(); + for (final Entity entity : ents) + { + if (!((entity instanceof Creature) || (entity instanceof Vehicle))) + { + continue; + } + if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) + { + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); + if (plot.id.equals(id)) + { + count(count, entity); + } + } + else + { + count(count, entity); + } + } + } + } + return count; } private void count(final int[] count, final Entity entity) diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java b/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java index 67666f586..ac66ccfba 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java @@ -54,7 +54,7 @@ public class BukkitHybridUtils extends HybridUtils final World world = Bukkit.getWorld(plot.world); final ChunkGenerator gen = world.getGenerator(); if (gen == null) { - return; + return; } final BiomeGrid base = new BiomeGrid() { diff --git a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java index fa55aee48..0f724f1f4 100644 --- a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java +++ b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java @@ -79,7 +79,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager public void run() { if (toUpdate.size() == 0) { - return; + return; } int count = 0; final ArrayList chunks = new ArrayList(); @@ -91,7 +91,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager count++; } if (count == 0) { - return; + return; } update(chunks); } @@ -336,24 +336,24 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager // End blockstate workaround // final int X = x >> 4; - final int Z = z >> 4; - final ChunkLoc loc = new ChunkLoc(X, Z); - if (!loc.equals(lastLoc)) - { - Chunk chunk = toUpdate.get(loc); - if (chunk == null) - { - chunk = world.getChunkAt(X, Z); - toUpdate.put(loc, chunk); - } - chunk.load(false); - } - // check sign - final Object w = methodGetHandle.of(world).call(); - final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); - final Object pos = constructorBlockPosition.create(x & 0x0f, y, z & 0x0f); - final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12)); - methodA.of(chunk).call(pos, combined); + final int Z = z >> 4; + final ChunkLoc loc = new ChunkLoc(X, Z); + if (!loc.equals(lastLoc)) + { + Chunk chunk = toUpdate.get(loc); + if (chunk == null) + { + chunk = world.getChunkAt(X, Z); + toUpdate.put(loc, chunk); + } + chunk.load(false); + } + // check sign + final Object w = methodGetHandle.of(world).call(); + final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); + final Object pos = constructorBlockPosition.create(x & 0x0f, y, z & 0x0f); + final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12)); + methodA.of(chunk).call(pos, combined); } @Override diff --git a/src/main/java/com/plotsquared/general/commands/CommandManager.java b/src/main/java/com/plotsquared/general/commands/CommandManager.java index 8cd156b3c..2d784337e 100644 --- a/src/main/java/com/plotsquared/general/commands/CommandManager.java +++ b/src/main/java/com/plotsquared/general/commands/CommandManager.java @@ -79,13 +79,13 @@ public class CommandManager public int compare(final Command a, final Command b) { if (a == b) { - return 0; + return 0; } if (a == null) { - return -1; + return -1; } if (b == null) { - return 1; + return 1; } return a.getCommand().compareTo(b.getCommand()); } diff --git a/src/main/java/com/plotsquared/listener/WESubscriber.java b/src/main/java/com/plotsquared/listener/WESubscriber.java index 32ab675ac..0c43dbacb 100644 --- a/src/main/java/com/plotsquared/listener/WESubscriber.java +++ b/src/main/java/com/plotsquared/listener/WESubscriber.java @@ -36,7 +36,7 @@ public class WESubscriber final WorldEdit worldedit = PS.get().worldedit; if (worldedit == null) { - worldedit.getEventBus().unregister(this); + WorldEdit.getInstance().getEventBus().unregister(this); return; } final World worldObj = event.getWorld(); diff --git a/src/main/java/com/plotsquared/sponge/SpongeMain.java b/src/main/java/com/plotsquared/sponge/SpongeMain.java index 801778de9..b1fffa0ba 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -293,7 +293,7 @@ public class SpongeMain implements IPlotMain, PluginContainer PS.get().loadWorld(world, wrapper); switch (plotworld.TYPE) { - // Normal + // Normal case 0: { modify = new WorldModify(generator, false); diff --git a/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java b/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java index a69fb2ba0..0829b3b85 100644 --- a/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java +++ b/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java @@ -230,18 +230,18 @@ public class AugmentedPopulator implements Populator public void setBlock(final int x, final int y, final int z, final BlockState t) { if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) { - return; + return; } if (p) { if (ChunkManager.CURRENT_PLOT_CLEAR != null) { if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) { - return; + return; } } else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) { - return; + return; } } final PlotBlock block = SpongeMain.THIS.getPlotBlock(t); @@ -315,18 +315,18 @@ public class AugmentedPopulator implements Populator public void setBlockType(final int x, final int y, final int z, final BlockType t) { if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) { - return; + return; } if (p) { if (ChunkManager.CURRENT_PLOT_CLEAR != null) { if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) { - return; + return; } } else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) { - return; + return; } } final PlotBlock block = SpongeMain.THIS.getPlotBlock(t.getDefaultState()); diff --git a/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/src/main/java/com/plotsquared/sponge/listener/MainListener.java index 5498179f8..2a04bd0d5 100644 --- a/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -119,7 +119,7 @@ public class MainListener public boolean apply(final org.spongepowered.api.world.Location loc) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) { - return false; + return false; } return true; } @@ -323,7 +323,7 @@ public class MainListener public boolean apply(final org.spongepowered.api.world.Location loc) { if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) { - return false; + return false; } return true; } @@ -427,7 +427,7 @@ public class MainListener public boolean apply(final org.spongepowered.api.world.Location loc) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) { - return false; + return false; } return true; } @@ -438,7 +438,7 @@ public class MainListener public boolean apply(final Entity entity) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) { - return false; + return false; } return true; } @@ -457,7 +457,7 @@ public class MainListener public boolean apply(final Entity entity) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) { - return false; + return false; } return true; } @@ -474,7 +474,7 @@ public class MainListener public boolean apply(final org.spongepowered.api.world.Location loc) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) { - return false; + return false; } return true; } @@ -485,7 +485,7 @@ public class MainListener public boolean apply(final Entity entity) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) { - return false; + return false; } return true; } diff --git a/target/PlotSquared-Bukkit.jar b/target/PlotSquared-Bukkit.jar index 5cef149ac..a9c3ad84b 100644 Binary files a/target/PlotSquared-Bukkit.jar and b/target/PlotSquared-Bukkit.jar differ diff --git a/target/PlotSquared-Sponge.jar b/target/PlotSquared-Sponge.jar index 66bd2e9d7..2500a629e 100644 Binary files a/target/PlotSquared-Sponge.jar and b/target/PlotSquared-Sponge.jar differ