From cfb6e3bca472ce99bf97348c686b881053462fc3 Mon Sep 17 00:00:00 2001
From: MattBDev <4009945+MattBDev@users.noreply.github.com>
Date: Fri, 3 Jan 2020 12:02:18 -0500
Subject: [PATCH] Various debugging and cleaning
---
.../main/java/com/boydti/fawe/FaweAPI.java | 17 +--
.../main/java/com/boydti/fawe/FaweCache.java | 11 +-
.../com/boydti/fawe/beta/IBatchProcessor.java | 7 +-
.../java/com/boydti/fawe/beta/IBlocks.java | 3 -
.../implementation/blocks/BitSetBlocks.java | 3 -
.../implementation/blocks/CharBlocks.java | 13 +-
.../implementation/chunk/ChunkHolder.java | 12 +-
.../queue/SingleThreadQueueExtent.java | 4 +-
.../com/boydti/fawe/jnbt/anvil/MCAChunk.java | 18 +--
.../com/boydti/fawe/jnbt/anvil/MCAFile.java | 7 +-
.../object/clipboard/LinearClipboard.java | 1 -
.../collection/VariableThreadLocal.java | 3 -
.../object/io/LittleEndianOutputStream.java | 67 +++++----
.../fawe/object/regions/PolyhedralRegion.java | 3 +-
.../worldedit/command/UtilityCommands.java | 100 +++++++-------
.../platform/PlatformCommandManager.java | 130 +++++++++++-------
.../platform/binding/ConsumeBindings.java | 11 +-
.../platform/binding/PrimitiveBindings.java | 37 ++---
.../regions/ConvexPolyhedralRegion.java | 6 +-
.../sk89q/worldedit/regions/CuboidRegion.java | 40 ++----
.../net/jpountz/lz4/LZ4JNICompressor.java | 7 +-
21 files changed, 247 insertions(+), 253 deletions(-)
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java
index c2ac04cd8..0855f47ae 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java
@@ -1,8 +1,6 @@
package com.boydti.fawe;
import com.boydti.fawe.beta.IQueueExtent;
-import com.boydti.fawe.config.Caption;
-import com.sk89q.worldedit.util.formatting.text.Component;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
@@ -31,6 +29,7 @@ import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
+import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.io.IOException;
@@ -152,13 +151,12 @@ public class FaweAPI {
* Remember to commit when you're done!
*
* @param world The name of the world
- * @param autoqueue If it should start dispatching before you enqueue it.
- * @return
- * @see IQueueExtent#enqueue()
+ * @param autoQueue If it should start dispatching before you enqueue it.
+ * @return the queue extent
*/
- public static IQueueExtent createQueue(World world, boolean autoqueue) {
+ public static IQueueExtent createQueue(World world, boolean autoQueue) {
IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world);
- if (!autoqueue) {
+ if (!autoQueue) {
queue.disableQueue();
}
return queue;
@@ -189,10 +187,9 @@ public class FaweAPI {
/**
* Just forwards to ClipboardFormat.SCHEMATIC.load(file)
*
- * @param file
- * @return
+ * @param file the file to load
+ * @return a clipboard containing the schematic
* @see ClipboardFormat
- * @see Schematic
*/
public static Clipboard load(File file) throws IOException {
return ClipboardFormats.findByFile(file).load(file);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java
index 5084da323..694ad2959 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java
@@ -4,11 +4,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.beta.Trimable;
-import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.CleanableThreadLocal;
@@ -18,6 +13,9 @@ import com.boydti.fawe.object.exception.FaweChunkLoadException;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.IOUtil;
import com.boydti.fawe.util.MathMan;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
@@ -34,6 +32,7 @@ import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.MutableVector3;
+import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -192,7 +191,7 @@ public enum FaweCache implements Trimable {
} else {
pool = cache::get;
}
- Pool previous = REGISTERED_POOLS.putIfAbsent(clazz, pool);
+ Pool previous = REGISTERED_POOLS.putIfAbsent(clazz, pool);
if (previous != null) {
throw new IllegalStateException("Previous key");
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java
index 8bd9b9e33..c07a60fa2 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java
@@ -1,9 +1,6 @@
package com.boydti.fawe.beta;
import com.boydti.fawe.FaweCache;
-import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
-import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
-import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor;
import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor;
import com.sk89q.jnbt.CompoundTag;
@@ -68,10 +65,12 @@ public interface IBatchProcessor {
}
}
}
- for (int layer = (minY - 15) >> 4; layer < (maxY + 15) >> 4; layer++) {
+ int layer = (minY - 15) >> 4;
+ while (layer < (maxY + 15) >> 4) {
if (set.hasSection(layer)) {
return true;
}
+ layer++;
}
return false;
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java
index 2356fd840..79fb0bc08 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java
@@ -8,12 +8,9 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
-import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState;
-import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BlockRegistry;
-
import java.io.IOException;
import java.util.Map;
import java.util.Set;
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java
index 0c5bb0eff..4989bbb64 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java
@@ -4,13 +4,10 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.collection.MemBlockSet;
import com.sk89q.jnbt.CompoundTag;
-import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java
index d4b0582c3..76156ecaa 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java
@@ -1,9 +1,11 @@
package com.boydti.fawe.beta.implementation.blocks;
+import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkSet;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
+import org.jetbrains.annotations.Range;
public abstract class CharBlocks implements IBlocks {
@@ -66,7 +68,7 @@ public abstract class CharBlocks implements IBlocks {
return null;
}
- public void reset(int layer) {
+ public void reset(@Range(from = 0, to = 15) int layer) {
sections[layer] = EMPTY;
}
@@ -81,12 +83,12 @@ public abstract class CharBlocks implements IBlocks {
}
@Override
- public boolean hasSection(int layer) {
+ public boolean hasSection(@Range(from = 0, to = 15) int layer) {
return sections[layer] == FULL;
}
@Override
- public char[] load(int layer) {
+ public char[] load(@Range(from = 0, to = 15) int layer) {
return sections[layer].get(this, layer);
}
@@ -102,6 +104,7 @@ public abstract class CharBlocks implements IBlocks {
}
public void set(int x, int y, int z, char value) {
+ Fawe.imp().debug("Setting Block at x:" + x + ", y:" + y + " , z:" + z);
final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x;
set(layer, index, value);
@@ -111,11 +114,11 @@ public abstract class CharBlocks implements IBlocks {
Section
*/
- public final char get(int layer, int index) {
+ public final char get(@Range(from = 0, to = 15)int layer, int index) {
return sections[layer].get(this, layer, index);
}
- public final void set(int layer, int index, char value) {
+ public final void set(@Range(from = 0, to = 15) int layer, int index, char value) {
sections[layer].set(this, layer, index, value);
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java
index 2468ec128..2ce534b9b 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java
@@ -250,16 +250,14 @@ public class ChunkHolder> implements IQueueChunk {
}
@Override
- public boolean setBiome(ChunkHolder chunk, int x, int y, int z,
- BiomeType biome) {
+ public boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome) {
chunk.getOrCreateSet();
chunk.delegate = SET;
return chunk.setBiome(x, y, z, biome);
}
@Override
- public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
- BlockStateHolder block) {
+ public boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder block) {
chunk.getOrCreateSet();
chunk.delegate = SET;
return chunk.setBlock(x, y, z, block);
@@ -471,11 +469,9 @@ public class ChunkHolder> implements IQueueChunk {
IChunkGet get(ChunkHolder chunk);
IChunkSet set(ChunkHolder chunk);
- boolean setBiome(ChunkHolder chunk, int x, int y, int z,
- BiomeType biome);
+ boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome);
- boolean setBlock(ChunkHolder chunk, int x, int y, int z,
- BlockStateHolder holder);
+ boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder holder);
BiomeType getBiome(ChunkHolder chunk, int x, int y, int z);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java
index e7cbd42bf..acf2357ee 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java
@@ -33,8 +33,8 @@ import java.util.concurrent.Future;
*/
public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent {
-// // Pool discarded chunks for reuse (can safely be cleared by another thread)
-// private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>();
+ // Pool discarded chunks for reuse (can safely be cleared by another thread)
+ // private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>();
// Chunks currently being queued / worked on
private final Long2ObjectLinkedOpenHashMap chunks = new Long2ObjectLinkedOpenHashMap<>();
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java
index 66997ed4e..34b07dc47 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java
@@ -142,7 +142,7 @@ public class MCAChunk implements IChunk {
for (Map.Entry entry : properties.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
- Property property = type.getProperty(key);
+ Property