From 9a4473b73f3f5be9585a339c05912fef9868a0b9 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Thu, 25 Jul 2019 15:09:12 -0400 Subject: [PATCH] Formatting --- .../fawe/bukkit/beta/BukkitChunkHolder.java | 6 ++-- .../java/com/boydti/fawe/beta/Filter.java | 10 +++---- .../main/java/com/boydti/fawe/beta/Flood.java | 28 +++++++++---------- .../java/com/boydti/fawe/beta/IChunk.java | 10 +++---- .../com/boydti/fawe/beta/IDelegateChunk.java | 4 +-- .../com/boydti/fawe/beta/IDelegateFilter.java | 4 +-- .../fawe/beta/filters/ArrayImageMask.java | 16 +++++------ .../beta/implementation/QueueHandler.java | 8 ++---- .../SingleThreadQueueExtent.java | 11 ++++---- .../implementation/holder/ChunkHolder.java | 17 +++++------ .../boydti/fawe/object/mask/SkyLightMask.java | 6 ++-- 11 files changed, 57 insertions(+), 63 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java index b9767bbef..ccdd3da81 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java @@ -41,8 +41,8 @@ import java.util.concurrent.Future; public class BukkitChunkHolder> extends ChunkHolder { @Override - public void init(final IQueueExtent extent, final int X, final int Z) { - super.init(extent, X, Z); + public void init(final IQueueExtent extent, final int x, final int z) { + super.init(extent, x, z); } @Override @@ -353,4 +353,4 @@ public class BukkitChunkHolder> extends ChunkHolder { return null; } } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java index 2f19852c3..bb4da31f7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java @@ -1,8 +1,6 @@ package com.boydti.fawe.beta; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.block.BaseBlock; - import javax.annotation.Nullable; /** @@ -10,13 +8,13 @@ import javax.annotation.Nullable; */ public interface Filter { /** - * Check whether a chunk should be read + * Checks whether a chunk should be read. * - * @param cx - * @param cz + * @param chunkX + * @param chunkZ * @return */ - default boolean appliesChunk(final int cx, final int cz) { + default boolean appliesChunk(final int chunkX, final int chunkZ) { return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java index bfc567181..e8773e5c5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java @@ -2,12 +2,10 @@ package com.boydti.fawe.beta; import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.implementation.QueueHandler; -import com.boydti.fawe.beta.implementation.WorldChunkCache; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.World; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -22,7 +20,9 @@ public class Flood { private int[][] queues; private long[][] visits; - private int X, Y, Z; + private int x; + private int y; + private int z; private ConcurrentLinkedQueue queuePool = new ConcurrentLinkedQueue<>(); private final Long2ObjectLinkedOpenHashMap chunkVisits; @@ -45,17 +45,17 @@ public class Flood { IQueueExtent fq = queueHandler.getQueue(world); while (!chunkQueues.isEmpty()) { long firstKey = chunkQueues.firstLongKey(); - int X = MathMan.unpairIntX(firstKey); - int Z = MathMan.unpairIntY(firstKey); + int x = MathMan.unpairIntX(firstKey); + int z = MathMan.unpairIntY(firstKey); int[][] chunkQueue = chunkQueues.get(firstKey); // apply } } - private void init(int X, int Y, int Z) { - this.X = X; - this.Y = Y; - this.Z = Z; + private void init(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; } public void start(int x, int y, int z) { @@ -63,9 +63,9 @@ public class Flood { } private void push(int x, int y, int z, int depth) { - int X = x >> 4; - int Z = z >> 4; - long pair = MathMan.pairInt(X, Z); + int chunkX = x >> 4; + int chunkZ = z >> 4; + long pair = MathMan.pairInt(chunkX, chunkZ); int layer = y >> 4; int[] section = getOrCreateQueue(pair, layer); int val = (x & 15) + ((z & 15) << 4) + ((y & 15) << 8) + (depth << 12); @@ -154,8 +154,8 @@ public class Flood { visit = visits[sectionIndex]; queue = queues[sectionIndex]; if (visit == null || queue == null) { - long pair = MathMan.pairInt(X + nextX, Z + nextZ); - int layer = Y + nextY; + long pair = MathMan.pairInt(this.x + nextX, this.z + nextZ); + int layer = this.y + nextY; if (layer < 0 || layer > 15) { continue; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java index 1045612e3..2a643d6fe 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java @@ -1,17 +1,15 @@ package com.boydti.fawe.beta; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; - -import javax.annotation.Nullable; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import javax.annotation.Nullable; /** * Represents a chunk in the queue {@link IQueueExtent} @@ -21,10 +19,10 @@ public interface IChunk> extends Trimable, Callable, IChu /** * Initialize at the location * @param extent - * @param X - * @param Z + * @param x + * @param z */ - void init(IQueueExtent extent, int X, int Z); + void init(IQueueExtent extent, int x, int z); IQueueExtent getQueue(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java index 7c8086ae0..e4bf6237f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java @@ -73,8 +73,8 @@ public interface IDelegateChunk extends IChunk { } @Override - default void init(final IQueueExtent extent, final int X, final int Z) { - getParent().init(extent, X, Z); + default void init(final IQueueExtent extent, final int x, final int z) { + getParent().init(extent, x, z); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java index e39b1b703..5736290e7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java @@ -8,8 +8,8 @@ public interface IDelegateFilter extends Filter { Filter getParent(); @Override - default boolean appliesChunk(int cx, int cz) { - return getParent().appliesChunk(cx, cz); + default boolean appliesChunk(int chunkX, int chunkZ) { + return getParent().appliesChunk(chunkX, chunkZ); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java index 41ceed910..26c2e4e98 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java @@ -1,7 +1,5 @@ package com.boydti.fawe.beta.filters; -import com.boydti.fawe.beta.DelegateFilter; -import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.FilterBlock; import com.boydti.fawe.beta.FilterBlockMask; @@ -9,18 +7,18 @@ import java.awt.image.BufferedImage; import java.util.concurrent.ThreadLocalRandom; public class ArrayImageMask implements FilterBlockMask { - private final ThreadLocalRandom r; + private final ThreadLocalRandom random; private final boolean white; - private final BufferedImage img; + private final BufferedImage image; - public ArrayImageMask(BufferedImage img, boolean white) { - this.img = img; + public ArrayImageMask(BufferedImage image, boolean white) { + this.image = image; this.white = white; - this.r = ThreadLocalRandom.current(); + this.random = ThreadLocalRandom.current(); } @Override public boolean applyBlock(FilterBlock block) { - int height = img.getRGB(block.getX(), block.getZ()) & 0xFF; - return ((height == 255 || height > 0 && !white && r.nextInt(256) <= height)); + int height = image.getRGB(block.getX(), block.getZ()) & 0xFF; + return ((height == 255 || height > 0 && !white && random.nextInt(256) <= height)); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java index 4e73468b9..374018e26 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java @@ -34,7 +34,7 @@ public abstract class QueueHandler implements Trimable, Runnable { private ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool(); private ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool(); private ThreadPoolExecutor blockingExecutor = FaweCache.newBlockingExecutor(); - private ConcurrentLinkedQueue syncTasks = new ConcurrentLinkedQueue(); + private ConcurrentLinkedQueue syncTasks = new ConcurrentLinkedQueue<>(); private Map> chunkCache = new HashMap<>(); private IterableThreadLocal queuePool = new IterableThreadLocal() { @@ -114,9 +114,7 @@ public abstract class QueueHandler implements Trimable, Runnable { while (task != null) { task = task.get(); } - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { + } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } @@ -244,4 +242,4 @@ public abstract class QueueHandler implements Trimable, Runnable { } return result; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java index 96cfaa980..814cd1146 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java @@ -1,5 +1,7 @@ package com.boydti.fawe.beta.implementation; +import static com.google.common.base.Preconditions.checkNotNull; + import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; @@ -10,14 +12,11 @@ import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MemUtil; import com.google.common.util.concurrent.Futures; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; - import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.function.Supplier; -import static com.google.common.base.Preconditions.checkNotNull; - /** * Single threaded implementation for IQueueExtent (still abstract) * - Does not implement creation of chunks (that has to implemented by the platform e.g. Bukkit) @@ -30,7 +29,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { private ConcurrentLinkedQueue submissions = new ConcurrentLinkedQueue<>(); /** - * Safety check to ensure that the thread being used matches the one being initialized on + * Safety check to ensure that the thread being used matches the one being initialized on. * - Can be removed later */ private void checkThread() { @@ -45,7 +44,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { } /** - * Reset the queue + * Resets the queue. */ protected synchronized void reset() { checkThread(); @@ -261,4 +260,4 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { pollSubmissions(0, true); reset(); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java index 4d702e7cc..dd889fd80 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java @@ -28,7 +28,8 @@ public abstract class ChunkHolder implements IChunk, Supplier { private IChunkSet set; private IBlockDelegate delegate; private IQueueExtent extent; - private int X,Z; + private int x; + private int z; public ChunkHolder() { this.delegate = NULL; @@ -61,7 +62,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { if (region != null) { region.filter(this, filter, block, get, set); } else { - block = block.init(X, Z, get); + block = block.init(x, z, get); for (int layer = 0; layer < 16; layer++) { if (!get.hasSection(layer) || !filter.appliesLayer(this, layer)) continue; block.init(get, set, layer); @@ -118,7 +119,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { private IChunkGet newGet() { if (extent instanceof SingleThreadQueueExtent) { - IChunkGet newGet = extent.getCachedGet(X, Z, this); + IChunkGet newGet = extent.getCachedGet(x, z, this); if (newGet != null) { return newGet; } @@ -127,10 +128,10 @@ public abstract class ChunkHolder implements IChunk, Supplier { } @Override - public void init(final IQueueExtent extent, final int X, final int Z) { + public void init(final IQueueExtent extent, final int x, final int z) { this.extent = extent; - this.X = X; - this.Z = Z; + this.x = x; + this.z = z; if (set != null) { set.reset(); delegate = SET; @@ -146,12 +147,12 @@ public abstract class ChunkHolder implements IChunk, Supplier { @Override public int getX() { - return X; + return x; } @Override public int getZ() { - return Z; + return z; } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SkyLightMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SkyLightMask.java index bd014ed71..9b49b58e4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SkyLightMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SkyLightMask.java @@ -7,7 +7,8 @@ import com.sk89q.worldedit.math.BlockVector3; public class SkyLightMask extends AbstractExtentMask { - private final int min, max; + private final int min; + private final int max; public SkyLightMask(Extent extent, int min, int max) { super(extent); @@ -18,7 +19,8 @@ public class SkyLightMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { if (getExtent() instanceof LightingExtent) { - int light = ((LightingExtent) getExtent()).getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); + int light = ((LightingExtent) getExtent()) + .getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); return light >= min && light <= max; } return false;