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 1f1976889..465fcab20 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 @@ -124,9 +124,9 @@ public class BukkitPlotGenerator extends ChunkGenerator GenChunk result = new GenChunk(); if (this.getPlotGenerator() instanceof SingleWorldGenerator) { if (result.getChunkData() != null) { - for (int cx = 0; cx < 16; cx++) { - for (int cz = 0; cz < 16; cz++) { - biome.setBiome(cx, cz, Biome.PLAINS); + for (int chunkX = 0; chunkX < 16; chunkX++) { + for (int chunkZ = 0; chunkZ < 16; chunkZ++) { + biome.setBiome(chunkX, chunkZ, Biome.PLAINS); } } return result.getChunkData(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/SendChunk.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/SendChunk.java index 62d82cedb..6ed7317b6 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/SendChunk.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/SendChunk.java @@ -88,14 +88,14 @@ public class SendChunk { if (location == null) { location = pp.getLocation(); } - int cx = location.getX() >> 4; - int cz = location.getZ() >> 4; + int chunkX = location.getX() >> 4; + int chunkZ = location.getZ() >> 4; Player player = ((BukkitPlayer) pp).player; Object entity = this.methodGetHandlePlayer.of(player).call(); for (Chunk chunk : list) { - int dx = Math.abs(cx - chunk.getX()); - int dz = Math.abs(cz - chunk.getZ()); + int dx = Math.abs(chunkX - chunk.getX()); + int dz = Math.abs(chunkZ - chunk.getZ()); if ((dx > view) || (dz > view)) { continue; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java index 6f9277166..8a3406cda 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java @@ -8,8 +8,17 @@ import com.github.intellectualsites.plotsquared.plot.config.Configuration.Unknow import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.Flags; -import com.github.intellectualsites.plotsquared.plot.object.*; -import com.github.intellectualsites.plotsquared.plot.util.*; +import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; +import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; +import com.github.intellectualsites.plotsquared.plot.object.PlotManager; +import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; +import com.github.intellectualsites.plotsquared.plot.util.MainUtil; +import com.github.intellectualsites.plotsquared.plot.util.Permissions; +import com.github.intellectualsites.plotsquared.plot.util.StringComparison; +import com.github.intellectualsites.plotsquared.plot.util.StringMan; +import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import java.util.ArrayList; @@ -60,8 +69,6 @@ import java.util.stream.IntStream; MainUtil.sendMessage(player, Captions.NEED_BLOCK); return true; } - String[] split = material.split(","); - // blocks = Configuration.BLOCKLIST.parseString(material); try { bucket = Configuration.BLOCK_BUCKET.parseString(material); 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 291657454..680a77552 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 @@ -95,8 +95,7 @@ import java.util.Set; return false; } MainUtil.sendMessage(null, "Collecting region data..."); - ArrayList plots = new ArrayList<>(); - plots.addAll(PlotSquared.get().getPlots(world)); + ArrayList plots = new ArrayList<>(PlotSquared.get().getPlots(world)); if (ExpireManager.IMP != null) { plots.removeAll(ExpireManager.IMP.getPendingExpired()); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java index a8fb953d9..998edae06 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java @@ -25,15 +25,15 @@ public class AugmentedUtils { enabled = true; } - public static boolean generate(@NotNull final String world, final int cx, final int cz, + public static boolean generate(@NotNull final String world, final int chunkX, final int chunkZ, LocalBlockQueue queue) { if (!enabled) { return false; } - final int bx = cx << 4; - final int bz = cz << 4; - RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15); + final int blockX = chunkX << 4; + final int blockZ = chunkZ << 4; + RegionWrapper region = new RegionWrapper(blockX, blockX + 15, blockZ, blockZ + 15); Set areas = PlotSquared.get().getPlotAreas(world, region); if (areas.isEmpty()) { return false; @@ -62,10 +62,10 @@ public class AugmentedUtils { int tzz; // gen if (area.TYPE == 2) { - bxx = Math.max(0, area.getRegion().minX - bx); - bzz = Math.max(0, area.getRegion().minZ - bz); - txx = Math.min(15, area.getRegion().maxX - bx); - tzz = Math.min(15, area.getRegion().maxZ - bz); + bxx = Math.max(0, area.getRegion().minX - blockX); + bzz = Math.max(0, area.getRegion().minZ - blockZ); + txx = Math.min(15, area.getRegion().maxX - blockX); + tzz = Math.min(15, area.getRegion().maxZ - blockZ); primaryMask = new DelegateLocalBlockQueue(queue) { @Override public boolean setBlock(int x, int y, int z, PlotBlock id) { if (area.contains(x, z)) { @@ -94,8 +94,8 @@ public class AugmentedUtils { boolean has = false; for (int x = bxx; x <= txx; x++) { for (int z = bzz; z <= tzz; z++) { - int rx = x + bx; - int rz = z + bz; + int rx = x + blockX; + int rz = z + blockZ; boolean can = manager.getPlotId(area, rx, 0, rz) == null; if (can) { for (int y = 1; y < 128; y++) { @@ -112,7 +112,7 @@ public class AugmentedUtils { toReturn = true; secondaryMask = new DelegateLocalBlockQueue(primaryMask) { @Override public boolean setBlock(int x, int y, int z, PlotBlock id) { - if (canPlace[x - bx][z - bz]) { + if (canPlace[x - blockX][z - blockZ]) { return super.setBlock(x, y, z, id); } return false; @@ -127,15 +127,15 @@ public class AugmentedUtils { for (int x = bxx; x <= txx; x++) { for (int z = bzz; z <= tzz; z++) { for (int y = 1; y < 128; y++) { - queue.setBlock(bx + x, y, bz + z, air); + queue.setBlock(blockX + x, y, blockZ + z, air); } } } toReturn = true; } - ScopedLocalBlockQueue scoped = - new ScopedLocalBlockQueue(secondaryMask, new Location(area.worldname, bx, 0, bz), - new Location(area.worldname, bx + 15, 255, bz + 15)); + ScopedLocalBlockQueue scoped = new ScopedLocalBlockQueue(secondaryMask, + new Location(area.worldname, blockX, 0, blockZ), + new Location(area.worldname, blockX + 15, 255, blockZ + 15)); generator.generateChunk(scoped, area); generator.populateChunk(scoped, area); } 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 bd465a12f..2ae0ca358 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 @@ -249,7 +249,6 @@ public class ClassicPlotManager extends SquarePlotManager { .subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0, plot.getMerged(Direction.NORTH) ? 0 : 1); Location top = plot.getExtendedTopAbs().add(1, 0, 1); - PseudoRandom random = new PseudoRandom(); LocalBlockQueue queue = plotArea.getQueue(false); int y = dpw.WALL_HEIGHT + 1; if (!plot.getMerged(Direction.NORTH)) { 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 78c7675d2..479bfb923 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 @@ -2410,9 +2410,7 @@ public class Plot { if (this.settings == null) { return Collections.singleton(this); } - boolean[] merged = this.getMerged(); - int hash = MainUtil.hash(merged); - if (hash == 0) { + if (!this.isMerged()) { return Collections.singleton(this); } if (connected_cache != null && connected_cache.contains(this)) { @@ -2425,7 +2423,7 @@ public class Plot { Plot tmp; HashSet queuecache = new HashSet<>(); ArrayDeque frontier = new ArrayDeque<>(); - if (merged[0]) { + if (this.getMerged(Direction.NORTH)) { tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH)); if (!tmp.getMerged(Direction.SOUTH)) { // invalid merge @@ -2441,7 +2439,7 @@ public class Plot { queuecache.add(tmp); frontier.add(tmp); } - if (merged[1]) { + if (this.getMerged(Direction.EAST)) { tmp = this.area.getPlotAbs(this.id.getRelative(Direction.EAST)); if (!tmp.getMerged(Direction.WEST)) { // invalid merge @@ -2457,7 +2455,7 @@ public class Plot { queuecache.add(tmp); frontier.add(tmp); } - if (merged[2]) { + if (this.getMerged(Direction.SOUTH)) { tmp = this.area.getPlotAbs(this.id.getRelative(Direction.SOUTH)); if (!tmp.getMerged(Direction.NORTH)) { // invalid merge @@ -2473,7 +2471,7 @@ public class Plot { queuecache.add(tmp); frontier.add(tmp); } - if (merged[3]) { + if (this.getMerged(Direction.WEST)) { tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST)); if (!tmp.getMerged(Direction.EAST)) { // invalid merge @@ -2500,29 +2498,28 @@ public class Plot { } tmpSet.add(current); queuecache.remove(current); - merged = current.getMerged(); - if (merged[0]) { + if (current.getMerged(Direction.NORTH)) { tmp = current.area.getPlotAbs(current.id.getRelative(Direction.NORTH)); if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { queuecache.add(tmp); frontier.add(tmp); } } - if (merged[1]) { + if (current.getMerged(Direction.EAST)) { tmp = current.area.getPlotAbs(current.id.getRelative(Direction.EAST)); if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { queuecache.add(tmp); frontier.add(tmp); } } - if (merged[2]) { + if (current.getMerged(Direction.SOUTH)) { tmp = current.area.getPlotAbs(current.id.getRelative(Direction.SOUTH)); if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { queuecache.add(tmp); frontier.add(tmp); } } - if (merged[3]) { + if (current.getMerged(Direction.WEST)) { tmp = current.area.getPlotAbs(current.id.getRelative(Direction.WEST)); if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { queuecache.add(tmp); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java index a7c39cf18..101ec301a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java @@ -1,13 +1,21 @@ package com.github.intellectualsites.plotsquared.plot.util; import com.github.intellectualsites.plotsquared.plot.PlotSquared; -import com.github.intellectualsites.plotsquared.plot.object.*; +import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc; +import com.github.intellectualsites.plotsquared.plot.object.Location; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; +import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public abstract class ChunkManager { @@ -28,11 +36,11 @@ public abstract class ChunkManager { RunnableVal add, String world, ChunkLoc loc) { LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false); if (PlotSquared.get().isAugmented(world)) { - int bx = loc.x << 4; - int bz = loc.z << 4; + int blockX = loc.x << 4; + int blockZ = loc.z << 4; ScopedLocalBlockQueue scoped = - new ScopedLocalBlockQueue(queue, new Location(world, bx, 0, bz), - new Location(world, bx + 15, 255, bz + 15)); + new ScopedLocalBlockQueue(queue, new Location(world, blockX, 0, blockZ), + new Location(world, blockX + 15, 255, blockZ + 15)); if (force != null) { force.run(scoped); } else { @@ -212,11 +220,11 @@ public abstract class ChunkManager { File folder = new File(PlotSquared.get().IMP.getWorldContainer(), world + File.separator + "region"); File[] regionFiles = folder.listFiles(); - HashSet chunks = new HashSet<>(); if (regionFiles == null) { throw new RuntimeException( "Could not find worlds folder: " + folder + " ? (no read access?)"); } + HashSet chunks = new HashSet<>(); for (File file : regionFiles) { String name = file.getName(); if (name.endsWith("mca")) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java index 282c21bc4..6bad71051 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/BasicLocalBlockQueue.java @@ -92,12 +92,12 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue { return false; } baseBlocks = true; - int cx = x >> 4; - int cz = z >> 4; - if (cx != lastX || cz != lastZ) { - lastX = cx; - lastZ = cz; - long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL; + int chunkX = x >> 4; + int chunkZ = z >> 4; + if (chunkX != lastX || chunkZ != lastZ) { + lastX = chunkX; + lastZ = chunkZ; + long pair = (long) (chunkX) << 32 | (chunkZ) & 0xFFFFFFFFL; lastWrappedChunk = this.blockChunks.get(pair); if (lastWrappedChunk == null) { lastWrappedChunk = this.getLocalChunk(x >> 4, z >> 4); @@ -121,12 +121,12 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue { } else if (y < 0) { return false; } - int cx = x >> 4; - int cz = z >> 4; - if (cx != lastX || cz != lastZ) { - lastX = cx; - lastZ = cz; - long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL; + int chunkX = x >> 4; + int chunkZ = z >> 4; + if (chunkX != lastX || chunkZ != lastZ) { + lastX = chunkX; + lastZ = chunkZ; + long pair = (long) (chunkX) << 32 | (chunkZ) & 0xFFFFFFFFL; lastWrappedChunk = this.blockChunks.get(pair); if (lastWrappedChunk == null) { lastWrappedChunk = this.getLocalChunk(x >> 4, z >> 4); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java index 16538784f..87c0fec56 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/block/LocalBlockQueue.java @@ -1,6 +1,10 @@ package com.github.intellectualsites.plotsquared.plot.util.block; -import com.github.intellectualsites.plotsquared.plot.object.*; +import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; +import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc; +import com.github.intellectualsites.plotsquared.plot.object.Location; +import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; +import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; @@ -106,8 +110,6 @@ public abstract class LocalBlockQueue { for (int y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) { for (int x = pos1.getX(); x <= pos2.getX(); x++) { for (int z = pos1.getZ(); z <= pos2.getZ(); z++) { - // int i = PseudoRandom.random.random(blocks.length); - // PlotBlock block = blocks[i]; setBlock(x, y, z, blocks.getBlock()); } }