From 7f14e88c4c9c77539dc8d0c278ec66a6354d3ddd Mon Sep 17 00:00:00 2001 From: matt <4009945+MattBDev@users.noreply.github.com> Date: Thu, 14 Mar 2019 21:49:33 -0400 Subject: [PATCH] last commit before 4.0.0 Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com> --- .../plotsquared/bukkit/BukkitMain.java | 2 +- .../plotsquared/bukkit/chat/Reflection.java | 4 +- .../generator/BukkitAugmentedGenerator.java | 4 +- .../bukkit/generator/BukkitPlotGenerator.java | 6 +- .../bukkit/listeners/ChunkListener.java | 117 +++++----- .../bukkit/listeners/EntitySpawnListener.java | 4 +- .../bukkit/listeners/PlayerEvents.java | 64 +++--- .../bukkit/listeners/PlotPlusListener.java | 70 +++--- .../bukkit/listeners/SingleWorldListener.java | 4 +- .../bukkit/util/BukkitChunkManager.java | 211 +++++++++--------- .../bukkit/util/block/BukkitLocalQueue.java | 7 +- .../plotsquared/plot/commands/DebugExec.java | 10 +- .../plotsquared/plot/commands/Move.java | 4 +- .../plotsquared/plot/commands/Near.java | 4 +- .../plotsquared/plot/commands/Trim.java | 4 +- .../plot/generator/ClassicPlotManager.java | 2 +- .../plotsquared/plot/object/Location.java | 20 +- .../plotsquared/plot/object/Plot.java | 18 +- .../plotsquared/plot/object/PlotManager.java | 2 +- .../plot/object/StringPlotBlock.java | 5 +- .../plot/object/worlds/SinglePlotManager.java | 2 +- .../plotsquared/plot/util/EventUtil.java | 24 +- .../util/block/DelegateLocalBlockQueue.java | 4 +- .../plotsquared/plot/object/LocationTest.java | 21 ++ 24 files changed, 303 insertions(+), 310 deletions(-) create mode 100644 Core/src/test/java/com/github/intellectualsites/plotsquared/plot/object/LocationTest.java diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index de00937f6..5036afae0 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -73,7 +73,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS); } catch (final Throwable throwable) { throw new IllegalStateException( - "Failed to force load WorldEdit." + " Road schematics will fail to generate", + "Failed to force load WorldEdit. Road schematics will fail to generate", throwable); } } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java index 79c445dcc..a92515221 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java @@ -181,13 +181,13 @@ public final class Reflection { */ public synchronized static Method getMethod(Class clazz, String name, Class... args) { if (!_loadedMethods.containsKey(clazz)) { - _loadedMethods.put(clazz, new HashMap>, Method>>()); + _loadedMethods.put(clazz, new HashMap<>()); } Map>, Method>> loadedMethodNames = _loadedMethods.get(clazz); if (!loadedMethodNames.containsKey(name)) { - loadedMethodNames.put(name, new HashMap>, Method>()); + loadedMethodNames.put(name, new HashMap<>()); } Map>, Method> loadedSignatures = loadedMethodNames.get(name); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java index 6022632eb..6942bf6ab 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java @@ -24,7 +24,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator { return generator; } - @Override public void populate(World world, Random r, Chunk chunk) { - AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ(), null); + @Override public void populate(World world, Random random, Chunk source) { + AugmentedUtils.generate(world.getName(), source.getX(), source.getZ(), null); } } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java index affb0461e..947f1c3bb 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -69,12 +69,10 @@ public class BukkitPlotGenerator extends ChunkGenerator + " is already a BukkitPlotGenerator!"); } this.full = false; - PlotSquared.debug("BukkitPlotGenerator does not fully support: " + cg); + //todo figure out why this was put here in the first place: + //PlotSquared.debug("BukkitPlotGenerator does not fully support: " + cg); this.platformGenerator = cg; this.plotGenerator = new IndependentPlotGenerator() { - @Override public void processSetup(SetupObject setup) { - } - @Override public void initialize(PlotArea area) { } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java index 5abbbd378..902aa86b5 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java @@ -59,48 +59,45 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils for (World world : Bukkit.getWorlds()) { world.setAutoSave(false); } - TaskManager.runTaskRepeat(new Runnable() { - @Override public void run() { - try { - HashSet toUnload = new HashSet<>(); - for (World world : Bukkit.getWorlds()) { - String worldName = world.getName(); - if (!PlotSquared.get().hasPlotArea(worldName)) { + TaskManager.runTaskRepeat(() -> { + try { + HashSet toUnload = new HashSet<>(); + for (World world : Bukkit.getWorlds()) { + String worldName = world.getName(); + if (!PlotSquared.get().hasPlotArea(worldName)) { + continue; + } + Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world); + Object chunkMap = w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w); + Method methodIsChunkInUse = + chunkMap.getClass().getDeclaredMethod("isChunkInUse", int.class, int.class); + Chunk[] chunks = world.getLoadedChunks(); + for (Chunk chunk : chunks) { + if ((boolean) methodIsChunkInUse + .invoke(chunkMap, chunk.getX(), chunk.getZ())) { continue; } - Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world); - Object chunkMap = - w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w); - Method methodIsChunkInUse = chunkMap.getClass() - .getDeclaredMethod("isChunkInUse", int.class, int.class); - Chunk[] chunks = world.getLoadedChunks(); - for (Chunk chunk : chunks) { - if ((boolean) methodIsChunkInUse - .invoke(chunkMap, chunk.getX(), chunk.getZ())) { - continue; - } - int x = chunk.getX(); - int z = chunk.getZ(); - if (!shouldSave(worldName, x, z)) { - unloadChunk(worldName, chunk, false); - continue; - } - toUnload.add(chunk); + int x = chunk.getX(); + int z = chunk.getZ(); + if (!shouldSave(worldName, x, z)) { + unloadChunk(worldName, chunk, false); + continue; } + toUnload.add(chunk); } - if (toUnload.isEmpty()) { + } + if (toUnload.isEmpty()) { + return; + } + long start = System.currentTimeMillis(); + for (Chunk chunk : toUnload) { + if (System.currentTimeMillis() - start > 5) { return; } - long start = System.currentTimeMillis(); - for (Chunk chunk : toUnload) { - if (System.currentTimeMillis() - start > 5) { - return; - } - chunk.unload(true, false); - } - } catch (Throwable e) { - e.printStackTrace(); + chunk.unload(true, false); } + } catch (Throwable e) { + e.printStackTrace(); } }, 1); } @@ -222,9 +219,28 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils private void cleanChunk(final Chunk chunk) { TaskManager.index.incrementAndGet(); final Integer currentIndex = TaskManager.index.get(); - Integer task = TaskManager.runTaskRepeat(new Runnable() { - @Override public void run() { - if (!chunk.isLoaded()) { + Integer task = TaskManager.runTaskRepeat(() -> { + if (!chunk.isLoaded()) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + PlotSquared + .debug(Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!"); + chunk.unload(true, true); + return; + } + BlockState[] tiles = chunk.getTileEntities(); + if (tiles.length == 0) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + PlotSquared + .debug(Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!"); + chunk.unload(true, true); + return; + } + long start = System.currentTimeMillis(); + int i = 0; + while (System.currentTimeMillis() - start < 250) { + if (i >= tiles.length) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); PlotSquared.debug( @@ -232,29 +248,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils chunk.unload(true, true); return; } - BlockState[] tiles = chunk.getTileEntities(); - if (tiles.length == 0) { - Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); - TaskManager.tasks.remove(currentIndex); - PlotSquared.debug( - Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!"); - chunk.unload(true, true); - return; - } - long start = System.currentTimeMillis(); - int i = 0; - while (System.currentTimeMillis() - start < 250) { - if (i >= tiles.length) { - Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); - TaskManager.tasks.remove(currentIndex); - PlotSquared.debug( - Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!"); - chunk.unload(true, true); - return; - } - tiles[i].getBlock().setType(Material.AIR, false); - i++; - } + tiles[i].getBlock().setType(Material.AIR, false); + i++; } }, 5); TaskManager.tasks.put(currentIndex, task); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java index 6e167d548..53066f0de 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java @@ -65,10 +65,10 @@ public class EntitySpawnListener implements Listener { Entity entity = event.getEntity(); Location location = BukkitUtil.getLocation(entity.getLocation()); PlotArea area = location.getPlotArea(); - if (area == null) { + if (!location.isPlotArea()) { return; } - Plot plot = area.getOwnedPlotAbs(location); + Plot plot = location.getOwnedPlotAbs(); if (plot == null) { if (!area.MOB_SPAWNING) { EntityType type = entity.getType(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index ac51d4c84..09c9363b8 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -237,26 +237,24 @@ import java.util.regex.Pattern; @EventHandler public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) { if (e.getVehicle().getType() == EntityType.BOAT) { Location location = BukkitUtil.getLocation(e.getEntity()); - if (location.getPlotArea() == null) { - //we don't care about events that happen outside of a plot area. - return; - } - if (e.getEntity() instanceof Player) { - PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity()); - Plot plot = player.getCurrentPlot(); - if (plot != null) { - if (!plot.isAdded(player.getUUID())) { - //Here the event is only canceled if the player is not the owner - //of the property on which he is located. + if (location.isPlotArea()) { + if (e.getEntity() instanceof Player) { + PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity()); + Plot plot = player.getCurrentPlot(); + if (plot != null) { + if (!plot.isAdded(player.getUUID())) { + //Here the event is only canceled if the player is not the owner + //of the property on which he is located. + e.setCancelled(true); + } + } else { e.setCancelled(true); } } else { + //Here the event is cancelled too, otherwise you can move the + //boat with EchoPets or other mobs running around on the plot. e.setCancelled(true); } - } else { - //Here the event is cancelled too, otherwise you can move the - //boat with EchoPets or other mobs running around on the plot. - e.setCancelled(true); } } } @@ -315,7 +313,7 @@ import java.util.regex.Pattern; if (area == null) { return; } - Plot plot = area.getOwnedPlot(loc); + Plot plot = loc.getOwnedPlot(); if (plot == null) { return; } @@ -655,7 +653,7 @@ import java.util.regex.Pattern; Player player = event.getPlayer(); PlotPlayer pp = PlotPlayer.wrap(player); Location loc = BukkitUtil.getLocation(to); - PlotArea area = PlotSquared.get().getPlotAreaAbs(loc); + PlotArea area = loc.getPlotArea(); if (area == null) { return; } @@ -1029,7 +1027,7 @@ import java.util.regex.Pattern; Iterator iterator = event.blockList().iterator(); while (iterator.hasNext()) { iterator.next(); - if (location.getPlotArea() != null) { + if (location.isPlotArea()) { iterator.remove(); } } @@ -1095,13 +1093,12 @@ import java.util.regex.Pattern; pp.deleteMeta("perm"); } Location loc = pp.getLocation(); - PlotArea area = PlotSquared.get().getPlotAreaAbs(loc); - if (area == null) { - return; - } - plot = area.getPlot(loc); - if (plot != null) { - plotEntry(pp, plot); + PlotArea area = loc.getPlotArea(); + if (loc.isPlotArea()) { + plot = loc.getPlot(); + if (plot != null) { + plotEntry(pp, plot); + } } } @@ -1372,8 +1369,7 @@ import java.util.regex.Pattern; return; } for (Block block1 : event.getBlocks()) { - if (BukkitUtil.getLocation(block1.getLocation().add(relative)).getPlotArea() - != null) { + if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) { event.setCancelled(true); return; } @@ -1414,7 +1410,7 @@ import java.util.regex.Pattern; try { for (Block pulled : event.getBlocks()) { location = BukkitUtil.getLocation(pulled.getLocation()); - if (location.getPlotArea() != null) { + if (location.isPlotArea()) { event.setCancelled(true); return; } @@ -1427,7 +1423,7 @@ import java.util.regex.Pattern; BlockFace dir = event.getDirection(); location = BukkitUtil.getLocation(block.getLocation() .add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); - if (location.getPlotArea() != null) { + if (location.isPlotArea()) { event.setCancelled(true); return; } @@ -1512,7 +1508,7 @@ import java.util.regex.Pattern; if (area == null) { for (int i = blocks.size() - 1; i >= 0; i--) { location = BukkitUtil.getLocation(blocks.get(i).getLocation()); - if (location.getPlotArea() != null) { + if (location.isPlotArea()) { blocks.remove(i); } } @@ -1746,7 +1742,7 @@ import java.util.regex.Pattern; Iterator iterator = event.blockList().iterator(); while (iterator.hasNext()) { location = BukkitUtil.getLocation(iterator.next().getLocation()); - if (location.getPlotArea() != null) { + if (location.isPlotArea()) { iterator.remove(); } } @@ -2054,12 +2050,6 @@ import java.util.regex.Pattern; case TNT_MINECART: eventType = PlayerBlockEventType.PLACE_VEHICLE; break; - case ITEM_FRAME: - case PAINTING: - location = BukkitUtil - .getLocation(block.getRelative(event.getBlockFace()).getLocation()); - eventType = PlayerBlockEventType.PLACE_HANGING; - break; default: eventType = PlayerBlockEventType.INTERACT_BLOCK; break; diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java index 4e7c11af7..b4dafdfc2 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java @@ -36,45 +36,43 @@ import java.util.UUID; private static final HashMap healRunnable = new HashMap<>(); public static void startRunnable(JavaPlugin plugin) { - plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { - @Override public void run() { - if (!healRunnable.isEmpty()) { - for (Iterator> iterator = - healRunnable.entrySet().iterator(); iterator.hasNext(); ) { - Entry entry = iterator.next(); - Interval value = entry.getValue(); - ++value.count; - if (value.count == value.interval) { - value.count = 0; - Player player = Bukkit.getPlayer(entry.getKey()); - if (player == null) { - iterator.remove(); - continue; - } - double level = player.getHealth(); - if (level != value.max) { - player.setHealth(Math.min(level + value.amount, value.max)); - } + plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> { + if (!healRunnable.isEmpty()) { + for (Iterator> iterator = + healRunnable.entrySet().iterator(); iterator.hasNext(); ) { + Entry entry = iterator.next(); + Interval value = entry.getValue(); + ++value.count; + if (value.count == value.interval) { + value.count = 0; + Player player = Bukkit.getPlayer(entry.getKey()); + if (player == null) { + iterator.remove(); + continue; + } + double level = player.getHealth(); + if (level != value.max) { + player.setHealth(Math.min(level + value.amount, value.max)); } } } - if (!feedRunnable.isEmpty()) { - for (Iterator> iterator = - feedRunnable.entrySet().iterator(); iterator.hasNext(); ) { - Entry entry = iterator.next(); - Interval value = entry.getValue(); - ++value.count; - if (value.count == value.interval) { - value.count = 0; - Player player = Bukkit.getPlayer(entry.getKey()); - if (player == null) { - iterator.remove(); - continue; - } - int level = player.getFoodLevel(); - if (level != value.max) { - player.setFoodLevel(Math.min(level + value.amount, value.max)); - } + } + if (!feedRunnable.isEmpty()) { + for (Iterator> iterator = + feedRunnable.entrySet().iterator(); iterator.hasNext(); ) { + Entry entry = iterator.next(); + Interval value = entry.getValue(); + ++value.count; + if (value.count == value.interval) { + value.count = 0; + Player player = Bukkit.getPlayer(entry.getKey()); + if (player == null) { + iterator.remove(); + continue; + } + int level = player.getFoodLevel(); + if (level != value.max) { + player.setFoodLevel(Math.min(level + value.amount, value.max)); } } } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java index ed585483d..14567a9b4 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java @@ -33,8 +33,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils this.done = classChunk.getField("done").getRealField(); this.lit = classChunk.getField("lit").getRealField(); this.s = classChunk.getField("s").getRealField(); - } catch (Throwable ignore) { - ignore.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } Bukkit.getPluginManager().registerEvents(this, plugin); } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java index 9063e13a5..c8e5ef3ce 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java @@ -111,10 +111,82 @@ public class BukkitChunkManager extends ChunkManager { return chunks; } - @Override - public boolean copyRegion(com.github.intellectualsites.plotsquared.plot.object.Location pos1, - com.github.intellectualsites.plotsquared.plot.object.Location pos2, - com.github.intellectualsites.plotsquared.plot.object.Location newPos, + @Override public int[] countEntities(Plot plot) { + int[] existing = (int[]) plot.getMeta("EntityCount"); + if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime") + < 1000)) { + return existing; + } + PlotArea area = plot.getArea(); + World world = BukkitUtil.getWorld(area.worldname); + + Location bot = plot.getBottomAbs(); + Location top = plot.getTopAbs(); + int bx = bot.getX() >> 4; + int bz = bot.getZ() >> 4; + + int tx = top.getX() >> 4; + int tz = top.getZ() >> 4; + + int size = tx - bx << 4; + + Set chunks = new HashSet<>(); + for (int X = bx; X <= tx; X++) { + for (int Z = bz; Z <= tz; Z++) { + if (world.isChunkLoaded(X, Z)) { + chunks.add(world.getChunkAt(X, Z)); + } + } + } + + boolean doWhole = false; + List entities = null; + if (size > 200 && chunks.size() > 200) { + entities = world.getEntities(); + if (entities.size() < 16 + size / 8) { + doWhole = true; + } + } + + int[] count = new int[6]; + if (doWhole) { + for (Entity entity : entities) { + org.bukkit.Location location = entity.getLocation(); + Chunk chunk = location.getChunk(); + if (chunks.contains(chunk)) { + int X = chunk.getX(); + int Z = chunk.getZ(); + if (X > bx && X < tx && Z > bz && Z < tz) { + count(count, entity); + } else { + Plot other = area.getPlot(BukkitUtil.getLocation(location)); + if (plot.equals(other)) { + count(count, entity); + } + } + } + } + } else { + for (Chunk chunk : chunks) { + int X = chunk.getX(); + int Z = chunk.getZ(); + Entity[] entities1 = chunk.getEntities(); + for (Entity entity : entities1) { + if (X == bx || X == tx || Z == bz || Z == tz) { + Plot other = area.getPlot(BukkitUtil.getLocation(entity)); + if (plot.equals(other)) { + count(count, entity); + } + } else { + count(count, entity); + } + } + } + } + return count; + } + + @Override public boolean copyRegion(Location pos1, Location pos2, Location newPos, final Runnable whenDone) { final int relX = newPos.getX() - pos1.getX(); final int relZ = newPos.getZ() - pos1.getZ(); @@ -140,7 +212,7 @@ public class BukkitChunkManager extends ChunkManager { map.saveEntitiesIn(chunk, region); for (int x = bx & 15; x <= (tx & 15); x++) { for (int z = bz & 15; z <= (tz & 15); z++) { - map.saveBlocks(oldBukkitWorld, 256, cxx + x, czz + z, relX, relZ); + map.saveBlocks(oldBukkitWorld, cxx + x, czz + z, relX, relZ); } } } @@ -165,9 +237,7 @@ public class BukkitChunkManager extends ChunkManager { return true; } - @Override public boolean regenerateRegion( - final com.github.intellectualsites.plotsquared.plot.object.Location pos1, - final com.github.intellectualsites.plotsquared.plot.object.Location pos2, + @Override public boolean regenerateRegion(final Location pos1, final Location pos2, final boolean ignoreAugment, final Runnable whenDone) { final String world = pos1.getWorld(); @@ -275,8 +345,7 @@ public class BukkitChunkManager extends ChunkManager { AugmentedUtils.bypass(ignoreAugment, () -> setChunkInPlotArea(null, new RunnableVal() { @Override public void run(ScopedLocalBlockQueue value) { - com.github.intellectualsites.plotsquared.plot.object.Location min = - value.getMin(); + Location min = value.getMin(); int bx = min.getX(); int bz = min.getZ(); for (int x1 = 0; x1 < 16; x1++) { @@ -317,9 +386,22 @@ public class BukkitChunkManager extends ChunkManager { return true; } - @Override - public void clearAllEntities(com.github.intellectualsites.plotsquared.plot.object.Location pos1, - com.github.intellectualsites.plotsquared.plot.object.Location pos2) { + @Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) { + return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force); + } + + @SuppressWarnings("deprecation") @Override + public void unloadChunk(final String world, final ChunkLoc loc, final boolean save, + final boolean safe) { + if (!PlotSquared.get().isMainThread(Thread.currentThread())) { + TaskManager + .runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe)); + } else { + BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe); + } + } + + @Override public void clearAllEntities(Location pos1, Location pos2) { String world = pos1.getWorld(); List entities = BukkitUtil.getEntities(world); int bx = pos1.getX(); @@ -340,25 +422,7 @@ public class BukkitChunkManager extends ChunkManager { } } - @Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) { - return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force); - } - - @SuppressWarnings("deprecation") @Override - public void unloadChunk(final String world, final ChunkLoc loc, final boolean save, - final boolean safe) { - if (!PlotSquared.get().isMainThread(Thread.currentThread())) { - TaskManager - .runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe)); - } else { - BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe); - } - } - - @Override public void swap(com.github.intellectualsites.plotsquared.plot.object.Location bot1, - com.github.intellectualsites.plotsquared.plot.object.Location top1, - com.github.intellectualsites.plotsquared.plot.object.Location bot2, - com.github.intellectualsites.plotsquared.plot.object.Location top2, + @Override public void swap(Location bot1, Location top1, Location bot2, Location top2, final Runnable whenDone) { RegionWrapper region1 = new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); @@ -387,81 +451,6 @@ public class BukkitChunkManager extends ChunkManager { }); } - @Override public int[] countEntities(Plot plot) { - int[] existing = (int[]) plot.getMeta("EntityCount"); - if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime") - < 1000)) { - return existing; - } - PlotArea area = plot.getArea(); - World world = BukkitUtil.getWorld(area.worldname); - - com.github.intellectualsites.plotsquared.plot.object.Location bot = plot.getBottomAbs(); - com.github.intellectualsites.plotsquared.plot.object.Location top = plot.getTopAbs(); - int bx = bot.getX() >> 4; - int bz = bot.getZ() >> 4; - - int tx = top.getX() >> 4; - int tz = top.getZ() >> 4; - - int size = tx - bx << 4; - - Set chunks = new HashSet<>(); - for (int X = bx; X <= tx; X++) { - for (int Z = bz; Z <= tz; Z++) { - if (world.isChunkLoaded(X, Z)) { - chunks.add(world.getChunkAt(X, Z)); - } - } - } - - boolean doWhole = false; - List entities = null; - if (size > 200 && chunks.size() > 200) { - entities = world.getEntities(); - if (entities.size() < 16 + size / 8) { - doWhole = true; - } - } - - int[] count = new int[6]; - if (doWhole) { - for (Entity entity : entities) { - org.bukkit.Location location = entity.getLocation(); - Chunk chunk = location.getChunk(); - if (chunks.contains(chunk)) { - int X = chunk.getX(); - int Z = chunk.getZ(); - if (X > bx && X < tx && Z > bz && Z < tz) { - count(count, entity); - } else { - Plot other = area.getPlot(BukkitUtil.getLocation(location)); - if (plot.equals(other)) { - count(count, entity); - } - } - } - } - } else { - for (Chunk chunk : chunks) { - int X = chunk.getX(); - int Z = chunk.getZ(); - Entity[] entities1 = chunk.getEntities(); - for (Entity entity : entities1) { - if (X == bx || X == tx || Z == bz || Z == tz) { - Plot other = area.getPlot(BukkitUtil.getLocation(entity)); - if (plot.equals(other)) { - count(count, entity); - } - } else { - count(count, entity); - } - } - } - } - return count; - } - private void count(int[] count, Entity entity) { switch (entity.getType()) { case PLAYER: @@ -595,6 +584,7 @@ public class BukkitChunkManager extends ChunkManager { count[0]++; } + public static class ContentMap { final Set entities; @@ -629,8 +619,7 @@ public class BukkitChunkManager extends ChunkManager { public void saveEntitiesOut(Chunk chunk, RegionWrapper region) { for (Entity entity : chunk.getEntities()) { - com.github.intellectualsites.plotsquared.plot.object.Location loc = - BukkitUtil.getLocation(entity); + Location loc = BukkitUtil.getLocation(entity); int x = loc.getX(); int z = loc.getZ(); if (isIn(region, x, z)) { @@ -648,8 +637,7 @@ public class BukkitChunkManager extends ChunkManager { public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ, boolean delete) { for (Entity entity : chunk.getEntities()) { - com.github.intellectualsites.plotsquared.plot.object.Location loc = - BukkitUtil.getLocation(entity); + Location loc = BukkitUtil.getLocation(entity); int x = loc.getX(); int z = loc.getZ(); if (!isIn(region, x, z)) { @@ -683,6 +671,7 @@ public class BukkitChunkManager extends ChunkManager { this.entities.clear(); } + //todo optimize maxY public void saveBlocks(BukkitWorld world, int maxY, int x, int z, int offsetX, int offsetZ) { maxY = Math.min(255, maxY); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java index 77518690d..e7e7113db 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java @@ -192,8 +192,7 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { for (int x = 0; x < lc.biomes.length; x++) { String[] biomes2 = lc.biomes[x]; if (biomes2 != null) { - for (int y = 0; y < biomes2.length; y++) { - String biomeStr = biomes2[y]; + for (String biomeStr : biomes2) { if (biomeStr != null) { if (last == null || !StringMan.isEqual(last, biomeStr)) { biome = Biome.valueOf(biomeStr.toUpperCase()); @@ -247,8 +246,8 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { if (disableResult != null) { try { fieldNeighbors.set(disableResult[0], disableResult[1]); - } catch (Throwable ignore) { - ignore.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java index d75084407..4e533fe61 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java @@ -69,7 +69,15 @@ import java.util.*; if (this.engine != null) { return; } - this.engine = new ScriptEngineManager(null).getEngineByName("nashorn"); + //create script engine manager + ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); + //create nashorn engine + this.engine = scriptEngineManager.getEngineByName("nashorn"); + try { + engine.eval("print('PlotSquared Scripting Test');"); + } catch (ScriptException e) { + e.printStackTrace(); + } if (this.engine == null) { this.engine = new ScriptEngineManager(null).getEngineByName("JavaScript"); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Move.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Move.java index 814d6b9cc..9956b6f2e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Move.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Move.java @@ -11,8 +11,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.Permissions; @CommandDeclaration(usage = "/plot move ", command = "move", description = "Move a plot", - aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING, - requiredType = RequiredType.NONE) public class Move extends SubCommand { + aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER) +public class Move extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { Location loc = player.getLocation(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java index 0223245fc..0fa721dff 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java @@ -9,8 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3; import com.github.intellectualsites.plotsquared.plot.util.StringMan; -@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", - usage = "/plot near", category = CommandCategory.INFO) public class Near extends Command { +@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) +public class Near extends Command { public Near() { super(MainCommand.getInstance(), true); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trim.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trim.java index e9b0da288..291657454 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trim.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trim.java @@ -107,8 +107,8 @@ import java.util.Set; MainUtil.sendMessage(null, " - TIME ESTIMATE: 12 Parsecs"); TaskManager.objectTask(plots, new RunnableVal() { @Override public void run(Plot plot) { - Location pos1 = plot.getBottom(); - Location pos2 = plot.getTop(); + Location pos1 = plot.getCorners()[0]; + Location pos2 = plot.getCorners()[1]; int ccx1 = pos1.getX() >> 9; int ccz1 = pos1.getZ() >> 9; int ccx2 = pos2.getX() >> 9; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java index fffe38966..bd465a12f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java @@ -44,7 +44,7 @@ public class ClassicPlotManager extends SquarePlotManager { return false; } - @Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) { + @Override public boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) { ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea; setWallFilling(dpw, plot.getId(), dpw.WALL_FILLING); setWall(dpw, plot.getId(), dpw.WALL_BLOCK); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Location.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Location.java index d787d46e3..2e28594df 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Location.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Location.java @@ -57,7 +57,11 @@ public class Location implements Cloneable, Comparable { } @Override public Location clone() { - return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch); + try { + return (Location) super.clone(); + } catch (CloneNotSupportedException e) { + throw new AssertionError(); //can't happen + } } public PlotArea getPlotArea() { @@ -65,7 +69,7 @@ public class Location implements Cloneable, Comparable { } public Plot getOwnedPlot() { - PlotArea area = PlotSquared.get().getPlotAreaAbs(this); + PlotArea area = getPlotArea(); if (area != null) { return area.getOwnedPlot(this); } else { @@ -74,7 +78,7 @@ public class Location implements Cloneable, Comparable { } public Plot getOwnedPlotAbs() { - PlotArea area = PlotSquared.get().getPlotAreaAbs(this); + PlotArea area = getPlotArea(); if (area != null) { return area.getOwnedPlotAbs(this); } else { @@ -83,16 +87,16 @@ public class Location implements Cloneable, Comparable { } public boolean isPlotArea() { - return PlotSquared.get().getPlotAreaAbs(this) != null; + return getPlotArea() != null; } public boolean isPlotRoad() { - PlotArea area = PlotSquared.get().getPlotAreaAbs(this); + PlotArea area = getPlotArea(); return area != null && area.getPlotAbs(this) == null; } public boolean isUnownedPlotArea() { - PlotArea area = PlotSquared.get().getPlotAreaAbs(this); + PlotArea area = getPlotArea(); return area != null && area.getOwnedPlotAbs(this) == null; } @@ -106,7 +110,7 @@ public class Location implements Cloneable, Comparable { } public Plot getPlotAbs() { - PlotArea area = PlotSquared.get().getPlotAreaAbs(this); + PlotArea area = getPlotArea(); if (area != null) { return area.getPlotAbs(this); } else { @@ -115,7 +119,7 @@ public class Location implements Cloneable, Comparable { } public Plot getPlot() { - PlotArea area = PlotSquared.get().getPlotAreaAbs(this); + PlotArea area = getPlotArea(); if (area != null) { return area.getPlot(this); } else { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index 9733918f3..b6971b44f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -226,7 +226,7 @@ public class Plot { * @see PlotPlayer#getCurrentPlot() if a player is expected here. */ public static Plot getPlot(Location location) { - PlotArea pa = PlotSquared.get().getPlotAreaAbs(location); + PlotArea pa = location.getPlotArea(); if (pa != null) { return pa.getPlot(location); } @@ -457,7 +457,7 @@ public class Plot { * Gets or create plot settings. * * @return PlotSettings - * @deprecated use equivalent plot method; + * @deprecated use equivalent plot method; please file github issue if one does not exist. */ @Deprecated public PlotSettings getSettings() { if (this.settings == null) { @@ -837,7 +837,7 @@ public class Plot { }; for (Plot current : plots) { if (isDelete || current.owner == null) { - manager.unclaimPlot(Plot.this.area, current, null); + manager.unClaimPlot(Plot.this.area, current, null); } else { manager.claimPlot(Plot.this.area, current); } @@ -1567,13 +1567,19 @@ public class Plot { */ public boolean swapData(Plot plot, Runnable whenDone) { if (this.owner == null) { - if (plot != null && plot.hasOwner()) { + if (plot == null) { + return false; + } + if (plot.hasOwner()) { plot.moveData(this, whenDone); return true; } return false; } - if (plot == null || plot.owner == null) { + if (plot == null) { + this.moveData(plot, whenDone); + return true; + } else if (plot.owner == null) { this.moveData(plot, whenDone); return true; } @@ -2900,7 +2906,7 @@ public class Plot { getManager().claimPlot(current.getArea(), current); Plot originPlot = originArea.getPlotAbs( new PlotId(current.id.x - offset.x, current.id.y - offset.y)); - originPlot.getManager().unclaimPlot(originArea, originPlot, null); + originPlot.getManager().unClaimPlot(originArea, originPlot, null); } plot.setSign(); TaskManager.runTask(whenDone); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java index 0e99ce00a..7dc4185c8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java @@ -31,7 +31,7 @@ public abstract class PlotManager { public abstract boolean claimPlot(PlotArea plotArea, Plot plot); - public abstract boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone); + public abstract boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone); public abstract Location getSignLoc(PlotArea plotArea, Plot plot); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java index 7fcb07907..706d1ae06 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java @@ -83,10 +83,7 @@ public class StringPlotBlock extends PlotBlock { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } StringPlotBlock other = (StringPlotBlock) obj; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java index b7b4a1f8a..2b389ca9b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java @@ -46,7 +46,7 @@ public class SinglePlotManager extends PlotManager { return true; } - @Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) { + @Override public boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) { if (whenDone != null) { whenDone.run(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java index 92e3bdcb3..4e1d4fd87 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java @@ -76,11 +76,7 @@ public abstract class EventUtil { } final Plot plot = player.getCurrentPlot(); if (Settings.Teleport.ON_LOGIN && plot != null) { - TaskManager.runTask(new Runnable() { - @Override public void run() { - plot.teleportPlayer(player); - } - }); + TaskManager.runTask(() -> plot.teleportPlayer(player)); MainUtil.sendMessage(player, Captions.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot .getId().y + ")"); @@ -97,19 +93,13 @@ public abstract class EventUtil { public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type, Location location, LazyBlock block, boolean notifyPerms) { - PlotArea area = PlotSquared.get().getPlotAreaAbs(location); - Plot plot; - if (area != null) { - plot = area.getPlot(location); - } else { - plot = null; - } - if (plot == null) { - if (area == null) { + PlotArea area = location.getPlotArea(); + assert area != null; + Plot plot = area.getPlot(location); + if (plot != null) { + if (plot.isAdded(player.getUUID())) { return true; } - } else if (plot.isAdded(player.getUUID())) { - return true; } switch (type) { case TELEPORT_OBJECT: @@ -400,8 +390,6 @@ public abstract class EventUtil { } return true; } - case PLACE_HANGING: // Handled elsewhere - return true; case PLACE_MISC: { if (plot == null) { return Permissions diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java index cd3a4a81d..0c797c706 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/DelegateLocalBlockQueue.java @@ -70,8 +70,8 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue { return parent.getBlock(x, y, z); } - @Override public boolean setBiome(int x, int y, String biome) { - return parent.setBiome(x, y, biome); + @Override public boolean setBiome(int x, int z, String biome) { + return parent.setBiome(x, z, biome); } @Override public String getWorld() { diff --git a/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/object/LocationTest.java b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/object/LocationTest.java new file mode 100644 index 000000000..9f83151a5 --- /dev/null +++ b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/object/LocationTest.java @@ -0,0 +1,21 @@ +package com.github.intellectualsites.plotsquared.plot.object; + +import org.junit.Test; + +import java.util.logging.Logger; + +public class LocationTest { + + private static final Logger logger = Logger.getLogger(LocationTest.class.getName()); + + @Test public void cloning() { + String world = "plotworld"; + Location location1 = new Location(world, 0, 0, 0); + logger.info(location1.toString()); + Location clone = location1.clone(); + world = "normal"; + logger.info(clone.toString()); + location1.getBlockVector3() + + } +}