variable renames

This commit is contained in:
MattBDev 2019-05-17 15:32:05 -04:00
parent 6f5cb30734
commit 595a68ecba
10 changed files with 75 additions and 63 deletions

View File

@ -124,9 +124,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
GenChunk result = new GenChunk(); GenChunk result = new GenChunk();
if (this.getPlotGenerator() instanceof SingleWorldGenerator) { if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
if (result.getChunkData() != null) { if (result.getChunkData() != null) {
for (int cx = 0; cx < 16; cx++) { for (int chunkX = 0; chunkX < 16; chunkX++) {
for (int cz = 0; cz < 16; cz++) { for (int chunkZ = 0; chunkZ < 16; chunkZ++) {
biome.setBiome(cx, cz, Biome.PLAINS); biome.setBiome(chunkX, chunkZ, Biome.PLAINS);
} }
} }
return result.getChunkData(); return result.getChunkData();

View File

@ -88,14 +88,14 @@ public class SendChunk {
if (location == null) { if (location == null) {
location = pp.getLocation(); location = pp.getLocation();
} }
int cx = location.getX() >> 4; int chunkX = location.getX() >> 4;
int cz = location.getZ() >> 4; int chunkZ = location.getZ() >> 4;
Player player = ((BukkitPlayer) pp).player; Player player = ((BukkitPlayer) pp).player;
Object entity = this.methodGetHandlePlayer.of(player).call(); Object entity = this.methodGetHandlePlayer.of(player).call();
for (Chunk chunk : list) { for (Chunk chunk : list) {
int dx = Math.abs(cx - chunk.getX()); int dx = Math.abs(chunkX - chunk.getX());
int dz = Math.abs(cz - chunk.getZ()); int dz = Math.abs(chunkZ - chunk.getZ());
if ((dx > view) || (dz > view)) { if ((dx > view) || (dz > view)) {
continue; continue;
} }

View File

@ -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.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.util.*; 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 com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import java.util.ArrayList; import java.util.ArrayList;
@ -60,8 +69,6 @@ import java.util.stream.IntStream;
MainUtil.sendMessage(player, Captions.NEED_BLOCK); MainUtil.sendMessage(player, Captions.NEED_BLOCK);
return true; return true;
} }
String[] split = material.split(",");
// blocks = Configuration.BLOCKLIST.parseString(material);
try { try {
bucket = Configuration.BLOCK_BUCKET.parseString(material); bucket = Configuration.BLOCK_BUCKET.parseString(material);

View File

@ -95,8 +95,7 @@ import java.util.Set;
return false; return false;
} }
MainUtil.sendMessage(null, "Collecting region data..."); MainUtil.sendMessage(null, "Collecting region data...");
ArrayList<Plot> plots = new ArrayList<>(); ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots(world));
plots.addAll(PlotSquared.get().getPlots(world));
if (ExpireManager.IMP != null) { if (ExpireManager.IMP != null) {
plots.removeAll(ExpireManager.IMP.getPendingExpired()); plots.removeAll(ExpireManager.IMP.getPendingExpired());
} }

View File

@ -25,15 +25,15 @@ public class AugmentedUtils {
enabled = true; 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) { LocalBlockQueue queue) {
if (!enabled) { if (!enabled) {
return false; return false;
} }
final int bx = cx << 4; final int blockX = chunkX << 4;
final int bz = cz << 4; final int blockZ = chunkZ << 4;
RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15); RegionWrapper region = new RegionWrapper(blockX, blockX + 15, blockZ, blockZ + 15);
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region); Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region);
if (areas.isEmpty()) { if (areas.isEmpty()) {
return false; return false;
@ -62,10 +62,10 @@ public class AugmentedUtils {
int tzz; int tzz;
// gen // gen
if (area.TYPE == 2) { if (area.TYPE == 2) {
bxx = Math.max(0, area.getRegion().minX - bx); bxx = Math.max(0, area.getRegion().minX - blockX);
bzz = Math.max(0, area.getRegion().minZ - bz); bzz = Math.max(0, area.getRegion().minZ - blockZ);
txx = Math.min(15, area.getRegion().maxX - bx); txx = Math.min(15, area.getRegion().maxX - blockX);
tzz = Math.min(15, area.getRegion().maxZ - bz); tzz = Math.min(15, area.getRegion().maxZ - blockZ);
primaryMask = new DelegateLocalBlockQueue(queue) { primaryMask = new DelegateLocalBlockQueue(queue) {
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) { @Override public boolean setBlock(int x, int y, int z, PlotBlock id) {
if (area.contains(x, z)) { if (area.contains(x, z)) {
@ -94,8 +94,8 @@ public class AugmentedUtils {
boolean has = false; boolean has = false;
for (int x = bxx; x <= txx; x++) { for (int x = bxx; x <= txx; x++) {
for (int z = bzz; z <= tzz; z++) { for (int z = bzz; z <= tzz; z++) {
int rx = x + bx; int rx = x + blockX;
int rz = z + bz; int rz = z + blockZ;
boolean can = manager.getPlotId(area, rx, 0, rz) == null; boolean can = manager.getPlotId(area, rx, 0, rz) == null;
if (can) { if (can) {
for (int y = 1; y < 128; y++) { for (int y = 1; y < 128; y++) {
@ -112,7 +112,7 @@ public class AugmentedUtils {
toReturn = true; toReturn = true;
secondaryMask = new DelegateLocalBlockQueue(primaryMask) { secondaryMask = new DelegateLocalBlockQueue(primaryMask) {
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) { @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 super.setBlock(x, y, z, id);
} }
return false; return false;
@ -127,15 +127,15 @@ public class AugmentedUtils {
for (int x = bxx; x <= txx; x++) { for (int x = bxx; x <= txx; x++) {
for (int z = bzz; z <= tzz; z++) { for (int z = bzz; z <= tzz; z++) {
for (int y = 1; y < 128; y++) { 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; toReturn = true;
} }
ScopedLocalBlockQueue scoped = ScopedLocalBlockQueue scoped = new ScopedLocalBlockQueue(secondaryMask,
new ScopedLocalBlockQueue(secondaryMask, new Location(area.worldname, bx, 0, bz), new Location(area.worldname, blockX, 0, blockZ),
new Location(area.worldname, bx + 15, 255, bz + 15)); new Location(area.worldname, blockX + 15, 255, blockZ + 15));
generator.generateChunk(scoped, area); generator.generateChunk(scoped, area);
generator.populateChunk(scoped, area); generator.populateChunk(scoped, area);
} }

View File

@ -249,7 +249,6 @@ public class ClassicPlotManager extends SquarePlotManager {
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0, .subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
plot.getMerged(Direction.NORTH) ? 0 : 1); plot.getMerged(Direction.NORTH) ? 0 : 1);
Location top = plot.getExtendedTopAbs().add(1, 0, 1); Location top = plot.getExtendedTopAbs().add(1, 0, 1);
PseudoRandom random = new PseudoRandom();
LocalBlockQueue queue = plotArea.getQueue(false); LocalBlockQueue queue = plotArea.getQueue(false);
int y = dpw.WALL_HEIGHT + 1; int y = dpw.WALL_HEIGHT + 1;
if (!plot.getMerged(Direction.NORTH)) { if (!plot.getMerged(Direction.NORTH)) {

View File

@ -2410,9 +2410,7 @@ public class Plot {
if (this.settings == null) { if (this.settings == null) {
return Collections.singleton(this); return Collections.singleton(this);
} }
boolean[] merged = this.getMerged(); if (!this.isMerged()) {
int hash = MainUtil.hash(merged);
if (hash == 0) {
return Collections.singleton(this); return Collections.singleton(this);
} }
if (connected_cache != null && connected_cache.contains(this)) { if (connected_cache != null && connected_cache.contains(this)) {
@ -2425,7 +2423,7 @@ public class Plot {
Plot tmp; Plot tmp;
HashSet<Object> queuecache = new HashSet<>(); HashSet<Object> queuecache = new HashSet<>();
ArrayDeque<Plot> frontier = new ArrayDeque<>(); ArrayDeque<Plot> frontier = new ArrayDeque<>();
if (merged[0]) { if (this.getMerged(Direction.NORTH)) {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH)); tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH));
if (!tmp.getMerged(Direction.SOUTH)) { if (!tmp.getMerged(Direction.SOUTH)) {
// invalid merge // invalid merge
@ -2441,7 +2439,7 @@ public class Plot {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
if (merged[1]) { if (this.getMerged(Direction.EAST)) {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.EAST)); tmp = this.area.getPlotAbs(this.id.getRelative(Direction.EAST));
if (!tmp.getMerged(Direction.WEST)) { if (!tmp.getMerged(Direction.WEST)) {
// invalid merge // invalid merge
@ -2457,7 +2455,7 @@ public class Plot {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
if (merged[2]) { if (this.getMerged(Direction.SOUTH)) {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.SOUTH)); tmp = this.area.getPlotAbs(this.id.getRelative(Direction.SOUTH));
if (!tmp.getMerged(Direction.NORTH)) { if (!tmp.getMerged(Direction.NORTH)) {
// invalid merge // invalid merge
@ -2473,7 +2471,7 @@ public class Plot {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
if (merged[3]) { if (this.getMerged(Direction.WEST)) {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST)); tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST));
if (!tmp.getMerged(Direction.EAST)) { if (!tmp.getMerged(Direction.EAST)) {
// invalid merge // invalid merge
@ -2500,29 +2498,28 @@ public class Plot {
} }
tmpSet.add(current); tmpSet.add(current);
queuecache.remove(current); queuecache.remove(current);
merged = current.getMerged(); if (current.getMerged(Direction.NORTH)) {
if (merged[0]) {
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.NORTH)); tmp = current.area.getPlotAbs(current.id.getRelative(Direction.NORTH));
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
} }
if (merged[1]) { if (current.getMerged(Direction.EAST)) {
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.EAST)); tmp = current.area.getPlotAbs(current.id.getRelative(Direction.EAST));
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
} }
if (merged[2]) { if (current.getMerged(Direction.SOUTH)) {
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.SOUTH)); tmp = current.area.getPlotAbs(current.id.getRelative(Direction.SOUTH));
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);
frontier.add(tmp); frontier.add(tmp);
} }
} }
if (merged[3]) { if (current.getMerged(Direction.WEST)) {
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.WEST)); tmp = current.area.getPlotAbs(current.id.getRelative(Direction.WEST));
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) { if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
queuecache.add(tmp); queuecache.add(tmp);

View File

@ -1,13 +1,21 @@
package com.github.intellectualsites.plotsquared.plot.util; package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; 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.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import java.io.File; 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; import java.util.concurrent.ConcurrentHashMap;
public abstract class ChunkManager { public abstract class ChunkManager {
@ -28,11 +36,11 @@ public abstract class ChunkManager {
RunnableVal<ScopedLocalBlockQueue> add, String world, ChunkLoc loc) { RunnableVal<ScopedLocalBlockQueue> add, String world, ChunkLoc loc) {
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false); LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
if (PlotSquared.get().isAugmented(world)) { if (PlotSquared.get().isAugmented(world)) {
int bx = loc.x << 4; int blockX = loc.x << 4;
int bz = loc.z << 4; int blockZ = loc.z << 4;
ScopedLocalBlockQueue scoped = ScopedLocalBlockQueue scoped =
new ScopedLocalBlockQueue(queue, new Location(world, bx, 0, bz), new ScopedLocalBlockQueue(queue, new Location(world, blockX, 0, blockZ),
new Location(world, bx + 15, 255, bz + 15)); new Location(world, blockX + 15, 255, blockZ + 15));
if (force != null) { if (force != null) {
force.run(scoped); force.run(scoped);
} else { } else {
@ -212,11 +220,11 @@ public abstract class ChunkManager {
File folder = File folder =
new File(PlotSquared.get().IMP.getWorldContainer(), world + File.separator + "region"); new File(PlotSquared.get().IMP.getWorldContainer(), world + File.separator + "region");
File[] regionFiles = folder.listFiles(); File[] regionFiles = folder.listFiles();
HashSet<ChunkLoc> chunks = new HashSet<>();
if (regionFiles == null) { if (regionFiles == null) {
throw new RuntimeException( throw new RuntimeException(
"Could not find worlds folder: " + folder + " ? (no read access?)"); "Could not find worlds folder: " + folder + " ? (no read access?)");
} }
HashSet<ChunkLoc> chunks = new HashSet<>();
for (File file : regionFiles) { for (File file : regionFiles) {
String name = file.getName(); String name = file.getName();
if (name.endsWith("mca")) { if (name.endsWith("mca")) {

View File

@ -92,12 +92,12 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
return false; return false;
} }
baseBlocks = true; baseBlocks = true;
int cx = x >> 4; int chunkX = x >> 4;
int cz = z >> 4; int chunkZ = z >> 4;
if (cx != lastX || cz != lastZ) { if (chunkX != lastX || chunkZ != lastZ) {
lastX = cx; lastX = chunkX;
lastZ = cz; lastZ = chunkZ;
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL; long pair = (long) (chunkX) << 32 | (chunkZ) & 0xFFFFFFFFL;
lastWrappedChunk = this.blockChunks.get(pair); lastWrappedChunk = this.blockChunks.get(pair);
if (lastWrappedChunk == null) { if (lastWrappedChunk == null) {
lastWrappedChunk = this.getLocalChunk(x >> 4, z >> 4); lastWrappedChunk = this.getLocalChunk(x >> 4, z >> 4);
@ -121,12 +121,12 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
} else if (y < 0) { } else if (y < 0) {
return false; return false;
} }
int cx = x >> 4; int chunkX = x >> 4;
int cz = z >> 4; int chunkZ = z >> 4;
if (cx != lastX || cz != lastZ) { if (chunkX != lastX || chunkZ != lastZ) {
lastX = cx; lastX = chunkX;
lastZ = cz; lastZ = chunkZ;
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL; long pair = (long) (chunkX) << 32 | (chunkZ) & 0xFFFFFFFFL;
lastWrappedChunk = this.blockChunks.get(pair); lastWrappedChunk = this.blockChunks.get(pair);
if (lastWrappedChunk == null) { if (lastWrappedChunk == null) {
lastWrappedChunk = this.getLocalChunk(x >> 4, z >> 4); lastWrappedChunk = this.getLocalChunk(x >> 4, z >> 4);

View File

@ -1,6 +1,10 @@
package com.github.intellectualsites.plotsquared.plot.util.block; 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.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; 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 y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) {
for (int x = pos1.getX(); x <= pos2.getX(); x++) { for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) { 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()); setBlock(x, y, z, blocks.getBlock());
} }
} }