From 020c674c0149ff3ff870c78397d8f5090753d6a4 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 29 Jan 2020 15:01:38 -0500 Subject: [PATCH] Revert migration of FaweCache to Kotlin --- .../fawe/bukkit/adapter/FaweAdapter_All.java | 2 +- .../adapter/mc1_14/BukkitAdapter_1_14.java | 8 +- .../adapter/mc1_14/BukkitGetBlocks_1_14.java | 10 +- .../adapter/mc1_15/BukkitAdapter_1_15.java | 8 +- .../adapter/mc1_15/BukkitGetBlocks_1_15.java | 14 +- .../bukkit/listener/CFIPacketListener.java | 2 +- .../wrapper/state/AsyncDataContainer.java | 2 +- .../adapter/impl/FAWE_Spigot_v1_14_R4.java | 4 +- .../adapter/impl/FAWE_Spigot_v1_15_R1.java | 4 +- .../main/java/com/boydti/fawe/FaweCache.java | 481 +++++++++++++++++ .../main/java/com/boydti/fawe/FaweCache.kt | 507 ------------------ .../com/boydti/fawe/beta/CombinedBlocks.java | 2 +- .../com/boydti/fawe/beta/IBatchProcessor.java | 2 +- .../java/com/boydti/fawe/beta/IBlocks.java | 20 +- .../com/boydti/fawe/beta/IQueueExtent.java | 2 +- .../implementation/blocks/BitSetBlocks.java | 2 +- .../implementation/blocks/CharSetBlocks.java | 2 +- .../blocks/FallbackChunkGet.java | 2 +- .../implementation/blocks/NullChunkGet.kt | 2 +- .../implementation/chunk/ChunkHolder.java | 2 +- .../filter/block/CharFilterBlock.java | 2 +- .../implementation/packet/ChunkPacket.java | 6 +- .../processors/LimitExtent.java | 16 +- .../queue/ParallelQueueExtent.java | 2 +- .../implementation/queue/QueueHandler.java | 2 +- .../boydti/fawe/command/AnvilCommands.java | 2 +- .../com/boydti/fawe/jnbt/anvil/MCAChunk.java | 18 +- .../com/boydti/fawe/jnbt/anvil/MCAFile.java | 12 +- .../boydti/fawe/logging/LoggingChangeSet.java | 8 +- .../com/boydti/fawe/object/FaweLimit.java | 24 +- .../boydti/fawe/object/brush/SplineBrush.java | 2 +- .../cfi/HeightMapMCAGenerator.java | 4 +- .../object/changeset/AbstractChangeSet.java | 2 +- .../object/changeset/BlockBagChangeSet.java | 4 +- .../clipboard/remap/ClipboardRemapper.java | 4 +- .../fawe/object/collection/MemBlockSet.java | 10 +- .../fawe/object/extent/FaweRegionExtent.java | 24 +- .../object/extent/MemoryCheckingExtent.java | 2 +- .../boydti/fawe/object/extent/NullExtent.java | 2 +- .../fawe/object/extent/ProcessedWEExtent.java | 14 +- .../fawe/object/mask/FaweBlockMatcher.java | 18 +- .../object/schematic/MinecraftStructure.java | 10 +- .../plotquared/FaweLocalBlockQueue.java | 2 +- .../plotquared/FaweSchematicHandler.java | 2 +- .../java/com/boydti/fawe/util/BrushCache.java | 2 +- .../boydti/fawe/util/EditSessionBuilder.java | 8 +- .../java/com/boydti/fawe/web/SchemSync.java | 2 +- .../java/com/sk89q/worldedit/EditSession.java | 2 +- .../worldedit/command/ClipboardCommands.java | 6 +- .../worldedit/command/RegionCommands.java | 2 +- .../com/sk89q/worldedit/extent/Extent.java | 2 +- .../sk89q/worldedit/extent/MaskingExtent.java | 2 +- .../clipboard/io/FastSchematicReader.java | 4 +- .../extent/clipboard/io/SchematicReader.java | 4 +- .../extent/inventory/BlockBagExtent.java | 4 +- .../worldedit/math/MutableBlockVector3.java | 2 +- .../sk89q/worldedit/math/MutableVector3.java | 4 +- .../sk89q/worldedit/regions/CuboidRegion.java | 6 +- 58 files changed, 647 insertions(+), 673 deletions(-) create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/FaweAdapter_All.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/FaweAdapter_All.java index 8c4e41d25..d4aa283d1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/FaweAdapter_All.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/FaweAdapter_All.java @@ -382,7 +382,7 @@ // int z = location.getBlockZ(); // // org.bukkit.block.Block bukkitBlock = location.getBlock(); -// BaseBlock block = FaweCache.INSTANCE.getBlock(bukkitBlock.getTypeId(), bukkitBlock.getData()); +// BaseBlock block = FaweCache.IMP.getBlock(bukkitBlock.getTypeId(), bukkitBlock.getData()); // // // Read the NBT data // Object nmsWorld = getHandleWorld.invoke(craftWorld); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java index 64e2a12c5..3c3a2f551 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java @@ -201,10 +201,10 @@ public final class BukkitAdapter_1_14 extends NMSAdapter { if (set == null) { return newChunkSection(layer); } - final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get(); - final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get(); - final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get(); + final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get(); + final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get(); + final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get(); + final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get(); try { int[] num_palette_buffer = new int[1]; int air; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java index 652ed9bc8..a78d322e7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java @@ -490,9 +490,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { ChunkSection section = getSections()[layer]; // Section is null, return empty array if (section == null) { - return FaweCache.INSTANCE.getEMPTY_CHAR_4096(); + return FaweCache.IMP.EMPTY_CHAR_4096; } - if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) { + if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { data = new char[4096]; } DelegateLock lock = BukkitAdapter_1_14.applyLock(section); @@ -519,8 +519,8 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { num_palette = ((DataPaletteHash) palette).b(); } else { num_palette = 0; - int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get(); + int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get(); + char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); try { for (int i = 0; i < 4096; i++) { char paletteVal = data[i]; @@ -546,7 +546,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { return data; } - char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get(); + char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); try { if (num_palette != 1) { for (int i = 0; i < num_palette; i++) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java index 7e89ec3a6..b00001bd5 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java @@ -179,10 +179,10 @@ public final class BukkitAdapter_1_15 extends NMSAdapter { if (set == null) { return newChunkSection(layer); } - final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get(); - final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get(); - final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get(); + final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get(); + final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get(); + final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get(); + final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get(); try { int[] num_palette_buffer = new int[1]; int air; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java index 24102e985..02caa2818 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java @@ -96,7 +96,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { BiomeStorage index = getChunk().getBiomeIndex(); BiomeBase base = null; if (y == -1) { - for (y = 0; y < FaweCache.WORLD_HEIGHT; y++) { + for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) { base = index.getBiome(x, y, z); if (base != null) break; } @@ -324,7 +324,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { if (biome != null) { final Biome craftBiome = BukkitAdapter.adapt(biome); BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome); - for (int y = 0; y < FaweCache.WORLD_HEIGHT; y++) { + for (int y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) { currentBiomes.setBiome(x, y, z, nmsBiome); } } @@ -502,9 +502,9 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { ChunkSection section = getSections()[layer]; // Section is null, return empty array if (section == null) { - return FaweCache.INSTANCE.getEMPTY_CHAR_4096(); + return FaweCache.IMP.EMPTY_CHAR_4096; } - if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) { + if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { data = new char[4096]; } DelegateLock lock = BukkitAdapter_1_15.applyLock(section); @@ -531,8 +531,8 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { num_palette = ((DataPaletteHash) palette).b(); } else { num_palette = 0; - int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get(); + int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get(); + char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); try { for (int i = 0; i < 4096; i++) { char paletteVal = data[i]; @@ -558,7 +558,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { return data; } - char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get(); + char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); try { if (num_palette != 1) { for (int i = 0; i < num_palette; i++) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java index 0a89e1657..84d84bbda 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java @@ -123,7 +123,7 @@ public class CFIPacketListener implements Listener { protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) { @Override public void onPacketSending(PacketEvent event) { - if (!event.isServerPacket() || FaweCache.INSTANCE.getCHUNK_FLAG().get().get()) return; + if (!event.isServerPacket() || FaweCache.IMP.CHUNK_FLAG.get().get()) return; VirtualWorld gen = getGenerator(event); if (gen != null) { BlockVector3 origin = gen.getOrigin().toBlockPoint(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/state/AsyncDataContainer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/state/AsyncDataContainer.java index e41e17f5a..e2bc8ce64 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/state/AsyncDataContainer.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/state/AsyncDataContainer.java @@ -54,7 +54,7 @@ public final class AsyncDataContainer implements PersistentDataContainer { Validate.notNull(key, "The provided key for the custom value was null"); Validate.notNull(type, "The provided type for the custom value was null"); Validate.notNull(value, "The provided value for the custom value was null"); - get().put(key.toString(), FaweCache.INSTANCE.asTag(type.toPrimitive(value, null))); + get().put(key.toString(), FaweCache.IMP.asTag(type.toPrimitive(value, null))); } public boolean has(NamespacedKey key, PersistentDataType type) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java index 73148a4e8..0c1055d68 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java @@ -347,10 +347,10 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I packet.setNativePacket(nmsPacket); } try { - FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true); + FaweCache.IMP.CHUNK_FLAG.get().set(true); entityPlayer.playerConnection.sendPacket(nmsPacket); } finally { - FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false); + FaweCache.IMP.CHUNK_FLAG.get().set(false); } } }); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R1.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R1.java index ed2dc78d0..0a3cc7da1 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R1.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R1.java @@ -345,10 +345,10 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I packet.setNativePacket(nmsPacket); } try { - FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true); + FaweCache.IMP.CHUNK_FLAG.get().set(true); entityPlayer.playerConnection.sendPacket(nmsPacket); } finally { - FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false); + FaweCache.IMP.CHUNK_FLAG.get().set(false); } } }); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java new file mode 100644 index 000000000..bf6e5c888 --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -0,0 +1,481 @@ +package com.boydti.fawe; + +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.queue.Pool; +import com.boydti.fawe.beta.implementation.queue.QueuePool; +import com.boydti.fawe.config.Settings; +import com.boydti.fawe.object.collection.BitArray4096; +import com.boydti.fawe.object.collection.CleanableThreadLocal; +import com.boydti.fawe.object.collection.VariableThreadLocal; +import com.boydti.fawe.object.exception.FaweBlockBagException; +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; +import com.sk89q.jnbt.DoubleTag; +import com.sk89q.jnbt.EndTag; +import com.sk89q.jnbt.FloatTag; +import com.sk89q.jnbt.IntArrayTag; +import com.sk89q.jnbt.IntTag; +import com.sk89q.jnbt.ListTag; +import com.sk89q.jnbt.LongArrayTag; +import com.sk89q.jnbt.LongTag; +import com.sk89q.jnbt.ShortTag; +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; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Function; +import java.util.function.Supplier; + +public enum FaweCache implements Trimable { + IMP + ; // singleton + + public final int BLOCKS_PER_LAYER = 4096; + public final int CHUNK_LAYERS = 16; + public final int WORLD_HEIGHT = CHUNK_LAYERS << 4; + public final int WORLD_MAX_Y = WORLD_HEIGHT - 1; + + public final char[] EMPTY_CHAR_4096 = new char[4096]; + + private final IdentityHashMap, CleanableThreadLocal> REGISTERED_SINGLETONS = new IdentityHashMap<>(); + private final IdentityHashMap, Pool> REGISTERED_POOLS = new IdentityHashMap<>(); + + /* + Palette buffers / cache + */ + + @Override + public synchronized boolean trim(boolean aggressive) { + if (aggressive) { + CleanableThreadLocal.cleanAll(); + } else { + CHUNK_FLAG.clean(); + BYTE_BUFFER_8192.clean(); + BLOCK_TO_PALETTE.clean(); + PALETTE_TO_BLOCK.clean(); + BLOCK_STATES.clean(); + SECTION_BLOCKS.clean(); + PALETTE_CACHE.clean(); + PALETTE_TO_BLOCK_CHAR.clean(); + INDEX_STORE.clean(); + + MUTABLE_VECTOR3.clean(); + MUTABLE_BLOCKVECTOR3.clean(); + SECTION_BITS_TO_CHAR.clean(); + for (Map.Entry, CleanableThreadLocal> entry : REGISTERED_SINGLETONS.entrySet()) { + entry.getValue().clean(); + } + } + for (Map.Entry, Pool> entry : REGISTERED_POOLS.entrySet()) { + Pool pool = entry.getValue(); + pool.clear(); + } + + return false; + } + + public synchronized Pool registerPool(Class clazz, Supplier cache, boolean buffer) { + checkNotNull(cache); + Pool pool; + if (buffer) { + pool = new QueuePool<>(cache); + } else { + pool = cache::get; + } + Pool previous = REGISTERED_POOLS.putIfAbsent(clazz, pool); + if (previous != null) { + throw new IllegalStateException("Previous key"); + } + return pool; + } + + public LoadingCache createCache(Supplier withInitial) { + return CacheBuilder.newBuilder().build(new CacheLoader() { + @Override + public V load(T key) { + return withInitial.get(); + } + }); + } + + public LoadingCache createCache(Function withInitial) { + return CacheBuilder.newBuilder().build(new CacheLoader() { + @Override + public V load(T key) { + return withInitial.apply(key); + } + }); + } + + /* + Exceptions + */ + public static final FaweChunkLoadException CHUNK = new FaweChunkLoadException(); + public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException(); + public static final FaweException MANUAL = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual")); + public static final FaweException NO_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region")); + public static final FaweException OUTSIDE_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region")); + public static final FaweException MAX_CHECKS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks")); + public static final FaweException MAX_CHANGES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes")); + public static final FaweException LOW_MEMORY = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory")); + public static final FaweException MAX_ENTITIES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities")); + public static final FaweException MAX_TILES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles")); + public static final FaweException MAX_ITERATIONS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations")); + + /* + thread cache + */ + public final CleanableThreadLocal CHUNK_FLAG = new CleanableThreadLocal<>(AtomicBoolean::new); // resets to false + + public final CleanableThreadLocal LONG_BUFFER_1024 = new CleanableThreadLocal<>(() -> new long[1024]); + + public final CleanableThreadLocal BYTE_BUFFER_8192 = new CleanableThreadLocal<>(() -> new byte[8192]); + + public final VariableThreadLocal BYTE_BUFFER_VAR = new VariableThreadLocal(); + + public final CleanableThreadLocal BLOCK_TO_PALETTE = new CleanableThreadLocal<>(() -> { + int[] result = new int[BlockTypesCache.states.length]; + Arrays.fill(result, Integer.MAX_VALUE); + return result; + }); + + public final CleanableThreadLocal SECTION_BITS_TO_CHAR = new CleanableThreadLocal<>(() -> new char[4096]); + + public final CleanableThreadLocal PALETTE_TO_BLOCK = new CleanableThreadLocal<>(() -> new int[Character.MAX_VALUE + 1]); + + public final CleanableThreadLocal PALETTE_TO_BLOCK_CHAR = new CleanableThreadLocal<>( + () -> new char[Character.MAX_VALUE + 1], a -> { + Arrays.fill(a, Character.MAX_VALUE); + } + ); + + public final CleanableThreadLocal BLOCK_STATES = new CleanableThreadLocal<>(() -> new long[2048]); + + public final CleanableThreadLocal SECTION_BLOCKS = new CleanableThreadLocal<>(() -> new int[4096]); + + public final CleanableThreadLocal INDEX_STORE = new CleanableThreadLocal<>(() -> new int[256]); + + public final CleanableThreadLocal HEIGHT_STORE = new CleanableThreadLocal<>(() -> new int[256]); + + /** + * Holds data for a palette used in a chunk section + */ + public static final class Palette { + public int bitsPerEntry; + + public int paletteToBlockLength; + /** + * Reusable buffer array, MUST check paletteToBlockLength for actual length + */ + public int[] paletteToBlock; + + public int blockStatesLength; + /** + * Reusable buffer array, MUST check blockStatesLength for actual length + */ + public long[] blockStates; + } + + private final CleanableThreadLocal PALETTE_CACHE = new CleanableThreadLocal<>(Palette::new); + + /** + * Convert raw char array to palette + * @param layerOffset + * @param blocks + * @return palette + */ + public Palette toPalette(int layerOffset, char[] blocks) { + return toPalette(layerOffset, null, blocks); + } + + /** + * Convert raw int array to palette + * @param layerOffset + * @param blocks + * @return palette + */ + public Palette toPalette(int layerOffset, int[] blocks) { + return toPalette(layerOffset, blocks, null); + } + + private Palette toPalette(int layerOffset, int[] blocksInts, char[] blocksChars) { + int[] blockToPalette = BLOCK_TO_PALETTE.get(); + int[] paletteToBlock = PALETTE_TO_BLOCK.get(); + long[] blockStates = BLOCK_STATES.get(); + int[] blocksCopy = SECTION_BLOCKS.get(); + + int blockIndexStart = layerOffset << 12; + int blockIndexEnd = blockIndexStart + 4096; + int num_palette = 0; + try { + if (blocksChars != null) { + for (int i = blockIndexStart, j = 0; i < blockIndexEnd; i++, j++) { + int ordinal = blocksChars[i]; + int palette = blockToPalette[ordinal]; + if (palette == Integer.MAX_VALUE) { + blockToPalette[ordinal] = palette = num_palette; + paletteToBlock[num_palette] = ordinal; + num_palette++; + } + blocksCopy[j] = palette; + } + } else if (blocksInts != null) { + for (int i = blockIndexStart, j = 0; i < blockIndexEnd; i++, j++) { + int ordinal = blocksInts[i]; + int palette = blockToPalette[ordinal]; + if (palette == Integer.MAX_VALUE) { +// BlockState state = BlockTypesCache.states[ordinal]; + blockToPalette[ordinal] = palette = num_palette; + paletteToBlock[num_palette] = ordinal; + num_palette++; + } + blocksCopy[j] = palette; + } + } else { + throw new IllegalArgumentException(); + } + + for (int i = 0; i < num_palette; i++) { + blockToPalette[paletteToBlock[i]] = Integer.MAX_VALUE; + } + + // BlockStates + int bitsPerEntry = MathMan.log2nlz(num_palette - 1); + if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { + bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry + } else { + bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries + } + int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6; + if (num_palette == 1) { + // Set a value, because minecraft needs it for some reason + blockStates[0] = 0; + blockBitArrayEnd = 1; + } else { + BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry); + bitArray.fromRaw(blocksCopy); + } + + // Construct palette + Palette palette = PALETTE_CACHE.get(); + palette.bitsPerEntry = bitsPerEntry; + palette.paletteToBlockLength = num_palette; + palette.paletteToBlock = paletteToBlock; + + palette.blockStatesLength = blockBitArrayEnd; + palette.blockStates = blockStates; + + return palette; + } catch (Throwable e) { + e.printStackTrace(); + Arrays.fill(blockToPalette, Integer.MAX_VALUE); + throw e; + } + } + + /* + * Vector cache + */ + + public CleanableThreadLocal MUTABLE_BLOCKVECTOR3 = new CleanableThreadLocal<>(MutableBlockVector3::new); + + public CleanableThreadLocal MUTABLE_VECTOR3 = new CleanableThreadLocal(MutableVector3::new) { + @Override + public MutableVector3 init() { + return new MutableVector3(); + } + }; + + /* + Conversion methods between JNBT tags and raw values + */ + public Map asMap(Object... pairs) { + HashMap map = new HashMap<>(pairs.length >> 1); + for (int i = 0; i < pairs.length; i += 2) { + String key = (String) pairs[i]; + Object value = pairs[i + 1]; + map.put(key, value); + } + return map; + } + + public ShortTag asTag(short value) { + return new ShortTag(value); + } + + public IntTag asTag(int value) { + return new IntTag(value); + } + + public DoubleTag asTag(double value) { + return new DoubleTag(value); + } + + public ByteTag asTag(byte value) { + return new ByteTag(value); + } + + public FloatTag asTag(float value) { + return new FloatTag(value); + } + + public LongTag asTag(long value) { + return new LongTag(value); + } + + public ByteArrayTag asTag(byte[] value) { + return new ByteArrayTag(value); + } + + public IntArrayTag asTag(int[] value) { + return new IntArrayTag(value); + } + + public LongArrayTag asTag(long[] value) { + return new LongArrayTag(value); + } + + public StringTag asTag(String value) { + return new StringTag(value); + } + + public CompoundTag asTag(Map value) { + HashMap map = new HashMap<>(); + for (Map.Entry entry : value.entrySet()) { + Object child = entry.getValue(); + Tag tag = asTag(child); + map.put(entry.getKey(), tag); + } + return new CompoundTag(map); + } + + public Tag asTag(Object value) { + if (value instanceof Integer) { + return asTag((int) value); + } else if (value instanceof Short) { + return asTag((short) value); + } else if (value instanceof Double) { + return asTag((double) value); + } else if (value instanceof Byte) { + return asTag((byte) value); + } else if (value instanceof Float) { + return asTag((float) value); + } else if (value instanceof Long) { + return asTag((long) value); + } else if (value instanceof String) { + return asTag((String) value); + } else if (value instanceof Map) { + return asTag((Map) value); + } else if (value instanceof Collection) { + return asTag((Collection) value); + } else if (value instanceof Object[]) { + return asTag((Object[]) value); + } else if (value instanceof byte[]) { + return asTag((byte[]) value); + } else if (value instanceof int[]) { + return asTag((int[]) value); + } else if (value instanceof long[]) { + return asTag((long[]) value); + } else if (value instanceof Tag) { + return (Tag) value; + } else if (value instanceof Boolean) { + return asTag((byte) ((boolean) value ? 1 : 0)); + } + System.out.println("Invalid nbt: " + value); + return null; + } + + public ListTag asTag(Object... values) { + Class clazz = null; + List list = new ArrayList<>(values.length); + for (Object value : values) { + Tag tag = asTag(value); + if (clazz == null) { + clazz = tag.getClass(); + } + list.add(tag); + } + if (clazz == null) clazz = EndTag.class; + return new ListTag(clazz, list); + } + + public ListTag asTag(Collection values) { + Class clazz = null; + List list = new ArrayList<>(values.size()); + for (Object value : values) { + Tag tag = asTag(value); + if (clazz == null) { + clazz = tag.getClass(); + } + list.add(tag); + } + if (clazz == null) clazz = EndTag.class; + return new ListTag(clazz, list); + } + + /* + Thread stuff + */ + public ThreadPoolExecutor newBlockingExecutor() { + int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS; + ArrayBlockingQueue queue = new ArrayBlockingQueue<>(nThreads); + return new ThreadPoolExecutor(nThreads, nThreads, + 0L, TimeUnit.MILLISECONDS, queue + , Executors.defaultThreadFactory(), + new ThreadPoolExecutor.CallerRunsPolicy()) { + protected void afterExecute(Runnable r, Throwable t) { + try { + super.afterExecute(r, t); + if (t == null && r instanceof Future) { + try { + Future future = (Future) r; + if (future.isDone()) { + future.get(); + } + } catch (CancellationException ce) { + t = ce; + } catch (ExecutionException ee) { + t = ee.getCause(); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + } + } + if (t != null) { + t.printStackTrace(); + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + }; + } +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt deleted file mode 100644 index 073314c67..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt +++ /dev/null @@ -1,507 +0,0 @@ -package com.boydti.fawe - -import com.boydti.fawe.`object`.collection.BitArray4096 -import com.boydti.fawe.`object`.collection.CleanableThreadLocal -import com.boydti.fawe.`object`.collection.VariableThreadLocal -import com.boydti.fawe.`object`.exception.FaweBlockBagException -import com.boydti.fawe.`object`.exception.FaweChunkLoadException -import com.boydti.fawe.`object`.exception.FaweException -import com.boydti.fawe.beta.Trimable -import com.boydti.fawe.beta.implementation.queue.Pool -import com.boydti.fawe.beta.implementation.queue.QueuePool -import com.boydti.fawe.config.Settings -import com.boydti.fawe.util.IOUtil -import com.boydti.fawe.util.MathMan -import com.google.common.base.Preconditions.checkNotNull -import com.google.common.cache.CacheBuilder -import com.google.common.cache.CacheLoader -import com.google.common.cache.LoadingCache -import com.sk89q.jnbt.* -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 org.slf4j.LoggerFactory.getLogger -import java.util.* -import java.util.concurrent.* -import java.util.concurrent.atomic.AtomicBoolean -import java.util.function.Function -import java.util.function.Supplier - -object FaweCache : Trimable { - - const val BLOCKS_PER_LAYER = 4096 - const val CHUNK_LAYERS = 16 - const val WORLD_HEIGHT = CHUNK_LAYERS shl 4 - const val WORLD_MAX_Y = WORLD_HEIGHT - 1 - - val EMPTY_CHAR_4096 = CharArray(4096) - - private val REGISTERED_SINGLETONS = IdentityHashMap, CleanableThreadLocal<*>>() - private val REGISTERED_POOLS = IdentityHashMap, Pool<*>>() - - /* - thread cache - */ - val CHUNK_FLAG = CleanableThreadLocal(Supplier { AtomicBoolean() }) // resets to false - - val LONG_BUFFER_1024 = CleanableThreadLocal { LongArray(1024) } - - val BYTE_BUFFER_8192 = CleanableThreadLocal { ByteArray(8192) } - - val BYTE_BUFFER_VAR = VariableThreadLocal() - - val BLOCK_TO_PALETTE = CleanableThreadLocal { - val result = IntArray(BlockTypesCache.states.size) - Arrays.fill(result, Integer.MAX_VALUE) - result - } - - val SECTION_BITS_TO_CHAR = CleanableThreadLocal { CharArray(4096) } - - val PALETTE_TO_BLOCK = CleanableThreadLocal { IntArray(Character.MAX_VALUE.toInt() + 1) } - - val PALETTE_TO_BLOCK_CHAR = CleanableThreadLocal( - fun(): CharArray { - return CharArray(Char.MAX_VALUE.toInt() + 1) - }, fun(a: CharArray): Unit = Arrays.fill(a, Char.MAX_VALUE) - ) - - val BLOCK_STATES = CleanableThreadLocal { LongArray(2048) } - - val SECTION_BLOCKS = CleanableThreadLocal { IntArray(4096) } - - val INDEX_STORE = CleanableThreadLocal { IntArray(256) } - - val HEIGHT_STORE = CleanableThreadLocal { IntArray(256) } - - private val PALETTE_CACHE = CleanableThreadLocal(Supplier { Palette() }) - - /* - * Vector cache - */ - - var MUTABLE_BLOCKVECTOR3 = CleanableThreadLocal(Supplier { MutableBlockVector3() }) - - var MUTABLE_VECTOR3: CleanableThreadLocal = object : CleanableThreadLocal(Supplier { MutableVector3() }) { - override fun init(): MutableVector3 { - return MutableVector3() - } - } - - /* - Palette buffers / cache - */ - - @Synchronized - override fun trim(aggressive: Boolean): Boolean { - if (aggressive) { - CleanableThreadLocal.cleanAll() - } else { - CHUNK_FLAG.clean() - BYTE_BUFFER_8192.clean() - BLOCK_TO_PALETTE.clean() - PALETTE_TO_BLOCK.clean() - BLOCK_STATES.clean() - SECTION_BLOCKS.clean() - PALETTE_CACHE.clean() - PALETTE_TO_BLOCK_CHAR.clean() - INDEX_STORE.clean() - - MUTABLE_VECTOR3.clean() - MUTABLE_BLOCKVECTOR3.clean() - SECTION_BITS_TO_CHAR.clean() - for ((_, value) in REGISTERED_SINGLETONS) { - value.clean() - } - } - for ((_, pool) in REGISTERED_POOLS) { - pool.clear() - } - - return false - } - - fun getPool(clazz: Class): Pool? { - var pool: Pool? = REGISTERED_POOLS[clazz] as Pool? - if (pool == null) { - synchronized(this) { - pool = REGISTERED_POOLS[clazz] as Pool? - if (pool == null) { - getLogger(FaweCache::class.java).debug("Not registered $clazz") - val supplier = IOUtil.supplier { clazz.newInstance() } - pool = Pool { supplier.get() } - REGISTERED_POOLS[clazz] = pool - } - } - } - return pool - } - - fun getFromPool(clazz: Class): T? { - val pool = getPool(clazz) - return pool?.poll() - } - - fun getSingleton(clazz: Class): T { - var cache: CleanableThreadLocal? = REGISTERED_SINGLETONS[clazz] as CleanableThreadLocal? - if (cache == null) { - synchronized(this) { - cache = REGISTERED_SINGLETONS[clazz] as CleanableThreadLocal? - if (cache == null) { - getLogger(FaweCache::class.java).debug("Not registered $clazz") - cache = CleanableThreadLocal(IOUtil.supplier { clazz.newInstance() }) - REGISTERED_SINGLETONS[clazz] = cache - } - } - } - return cache!!.get() - } - - @Synchronized - fun registerSingleton(clazz: Class, cache: Supplier): CleanableThreadLocal { - checkNotNull(cache) - val local = CleanableThreadLocal(cache) - val previous = (REGISTERED_SINGLETONS as java.util.Map, CleanableThreadLocal<*>>).putIfAbsent(clazz, local) - check(previous == null) { "Previous key" } - return local - } - - @Synchronized - fun registerPool(clazz: Class, cache: Supplier, buffer: Boolean): Pool { - checkNotNull(cache) - val pool: Pool - if (buffer) { - pool = QueuePool(cache) - } else { - pool = Pool { cache.get() } - } - val previous = (REGISTERED_POOLS as java.util.Map, Pool<*>>).putIfAbsent(clazz, pool) - check(previous == null) { "Previous key" } - return pool - } - - fun createCache(withInitial: Supplier): LoadingCache { - return CacheBuilder.newBuilder().build(object : CacheLoader() { - override fun load(key: T): V { - return withInitial.get() - } - }) - } - - fun createCache(withInitial: Function): LoadingCache { - return CacheBuilder.newBuilder().build(object : CacheLoader() { - override fun load(key: T): V { - return withInitial.apply(key) - } - }) - } - - /** - * Holds data for a palette used in a chunk section - */ - class Palette { - var bitsPerEntry: Int = 0 - - var paletteToBlockLength: Int = 0 - /** - * Reusable buffer array, MUST check paletteToBlockLength for actual length - */ - var paletteToBlock: IntArray? = null - - var blockStatesLength: Int = 0 - /** - * Reusable buffer array, MUST check blockStatesLength for actual length - */ - var blockStates: LongArray? = null - } - - /** - * Convert raw char array to palette - * @param layerOffset - * @param blocks - * @return palette - */ - fun toPalette(layerOffset: Int, blocks: CharArray): Palette { - return toPalette(layerOffset, null, blocks) - } - - /** - * Convert raw int array to palette - * @param layerOffset - * @param blocks - * @return palette - */ - fun toPalette(layerOffset: Int, blocks: IntArray): Palette { - return toPalette(layerOffset, blocks, null) - } - - private fun toPalette(layerOffset: Int, blocksInts: IntArray?, blocksChars: CharArray?): Palette { - val blockToPalette = BLOCK_TO_PALETTE.get() - val paletteToBlock = PALETTE_TO_BLOCK.get() - val blockStates = BLOCK_STATES.get() - val blocksCopy = SECTION_BLOCKS.get() - - val blockIndexStart = layerOffset shl 12 - val blockIndexEnd = blockIndexStart + 4096 - var num_palette = 0 - try { - if (blocksChars != null) { - var i = blockIndexStart - var j = 0 - while (i < blockIndexEnd) { - val ordinal = blocksChars[i].toInt() - var palette = blockToPalette[ordinal] - if (palette == Integer.MAX_VALUE) { - palette = num_palette - blockToPalette[ordinal] = palette - paletteToBlock[num_palette] = ordinal - num_palette++ - } - blocksCopy[j] = palette - i++ - j++ - } - } else if (blocksInts != null) { - var i = blockIndexStart - var j = 0 - while (i < blockIndexEnd) { - val ordinal = blocksInts[i] - var palette = blockToPalette[ordinal] - if (palette == Integer.MAX_VALUE) { - // BlockState state = BlockTypesCache.states[ordinal]; - palette = num_palette - blockToPalette[ordinal] = palette - paletteToBlock[num_palette] = ordinal - num_palette++ - } - blocksCopy[j] = palette - i++ - j++ - } - } else { - throw IllegalArgumentException() - } - - for (i in 0 until num_palette) { - blockToPalette[paletteToBlock[i]] = Integer.MAX_VALUE - } - - // BlockStates - var bitsPerEntry = MathMan.log2nlz(num_palette - 1) - if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { - bitsPerEntry = Math.max(bitsPerEntry, 4) // Protocol support breaks <4 bits per entry - } else { - bitsPerEntry = Math.max(bitsPerEntry, 1) // For some reason minecraft needs 4096 bits to store 0 entries - } - var blockBitArrayEnd = bitsPerEntry * 4096 shr 6 - if (num_palette == 1) { - // Set a value, because minecraft needs it for some reason - blockStates[0] = 0 - blockBitArrayEnd = 1 - } else { - val bitArray = BitArray4096(blockStates, bitsPerEntry) - bitArray.fromRaw(blocksCopy) - } - - // Construct palette - val palette = PALETTE_CACHE.get() - palette.bitsPerEntry = bitsPerEntry - palette.paletteToBlockLength = num_palette - palette.paletteToBlock = paletteToBlock - - palette.blockStatesLength = blockBitArrayEnd - palette.blockStates = blockStates - - return palette - } catch (e: Throwable) { - e.printStackTrace() - Arrays.fill(blockToPalette, Integer.MAX_VALUE) - throw e - } - - } - - /* - Conversion methods between JNBT tags and raw values - */ - fun asMap(vararg pairs: Any): Map { - val map = HashMap(pairs.size shr 1) - var i = 0 - while (i < pairs.size) { - val key = pairs[i] as String - val value = pairs[i + 1] - map[key] = value - i += 2 - } - return map - } - - fun asTag(value: Short): ShortTag { - return ShortTag(value) - } - - fun asTag(value: Int): IntTag { - return IntTag(value) - } - - fun asTag(value: Double): DoubleTag { - return DoubleTag(value) - } - - fun asTag(value: Byte): ByteTag { - return ByteTag(value) - } - - fun asTag(value: Float): FloatTag { - return FloatTag(value) - } - - fun asTag(value: Long): LongTag { - return LongTag(value) - } - - fun asTag(value: ByteArray): ByteArrayTag { - return ByteArrayTag(value) - } - - fun asTag(value: IntArray): IntArrayTag { - return IntArrayTag(value) - } - - fun asTag(value: LongArray): LongArrayTag { - return LongArrayTag(value) - } - - fun asTag(value: String): StringTag { - return StringTag(value) - } - - fun asTag(value: Map): CompoundTag { - val map = HashMap() - for ((key, child) in value) { - val tag = asTag(child) - map[key] = tag - } - return CompoundTag(map) - } - - fun asTag(value: Any?): Tag? { - if (value is Int) { - return asTag(value) - } else if (value is Short) { - return asTag(value) - } else if (value is Double) { - return asTag(value) - } else if (value is Byte) { - return asTag(value) - } else if (value is Float) { - return asTag(value) - } else if (value is Long) { - return asTag(value) - } else if (value is String) { - return asTag(value as String?) - } else if (value is Map<*, *>) { - return asTag((value as Map?)!!) - } else if (value is Collection<*>) { - return asTag((value as Collection<*>?)!!) - } else if (value is Array<*>) { - return asTag(*(value as Array?)!!) - } else if (value is ByteArray) { - return asTag(value as ByteArray?) - } else if (value is IntArray) { - return asTag(value as IntArray?) - } else if (value is LongArray) { - return asTag(value as LongArray?) - } else if (value is Tag) { - return value - } else if (value is Boolean) { - return asTag((if (value) 1 else 0).toByte()) - } else if (value == null) { - println("Invalid nbt: " + value!!) - return null - } else { - val clazz = value.javaClass - println("Invalid nbt: $value") - return null - } - } - - fun asTag(vararg values: Any): ListTag { - var clazz: Class? = null - val list = ArrayList(values.size) - for (value in values) { - val tag = asTag(value) - if (clazz == null) { - clazz = tag.javaClass - } - list.add(tag) - } - if (clazz == null) clazz = EndTag::class.java - return ListTag(clazz, list) - } - - fun asTag(values: Collection<*>): ListTag { - var clazz: Class? = null - val list: ArrayList = ArrayList(values.size) - for (value in values) { - val tag = asTag(value) - if (clazz == null) { - clazz = tag!!.javaClass - } - if (tag != null) { - list.add(tag) - } - } - if (clazz == null) clazz = EndTag::class.java - return ListTag(clazz, list) - } - - /* - Thread stuff - */ - fun newBlockingExecutor(): ThreadPoolExecutor { - val nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS - val queue = ArrayBlockingQueue(nThreads) - return object : ThreadPoolExecutor(nThreads, nThreads, - 0L, TimeUnit.MILLISECONDS, queue, Executors.defaultThreadFactory(), CallerRunsPolicy()) { - override fun afterExecute(r: Runnable?, t: Throwable?) { - var throwable = t - try { - super.afterExecute(r, throwable) - if (t == null && r is Future<*>) { - try { - val future = r as Future<*>? - if (future!!.isDone) { - future.get() - } - } catch (ce: CancellationException) { - throwable = ce - } catch (ee: ExecutionException) { - throwable = ee.cause - } catch (ie: InterruptedException) { - Thread.currentThread().interrupt() - } - - } - throwable?.printStackTrace() - } catch (e: Throwable) { - e.printStackTrace() - } - - } - } - } - - val CHUNK = FaweChunkLoadException() - val BLOCK_BAG = FaweBlockBagException() - val MANUAL = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual")) - val NO_REGION = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region")) - val OUTSIDE_REGION = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region")) - val MAX_CHECKS = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks")) - val MAX_CHANGES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes")) - val LOW_MEMORY = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory")) - val MAX_ENTITIES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities")) - val MAX_TILES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles")) - val MAX_ITERATIONS = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations")) -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java index 089533d96..0915fed10 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java @@ -34,7 +34,7 @@ public class CombinedBlocks implements IBlocks { @Override public int getBitMask() { int bitMask = addMask; - for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) { if (primary.hasSection(layer)) { bitMask |= (1 << layer); } 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 8bce0c6d0..7f913b5d1 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 @@ -56,7 +56,7 @@ public interface IBatchProcessor { } } int maxLayer = (maxY + 1) >> 4; - for (int layer = maxLayer; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = maxLayer; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) { if (set.hasSection(layer)) { if (layer == minLayer) { char[] arr = set.load(layer); 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 220a165a9..b175b62d3 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 @@ -36,7 +36,7 @@ public interface IBlocks extends Trimable { BiomeType getBiomeType(int x, int y, int z); default int getBitMask() { - return IntStream.range(0, FaweCache.CHUNK_LAYERS).filter(this::hasSection) + return IntStream.range(0, FaweCache.IMP.CHUNK_LAYERS).filter(this::hasSection) .map(layer -> (1 << layer)).sum(); } @@ -56,7 +56,7 @@ public interface IBlocks extends Trimable { FaweOutputStream sectionWriter = new FaweOutputStream(sectionByteArray); try { - for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) { if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue; char[] ids = this.load(layer); @@ -92,12 +92,12 @@ public interface IBlocks extends Trimable { // } // sectionWriter.write(bits.getData()); // } else { - FaweCache.Palette palette = FaweCache.INSTANCE.toPalette(0, ids); + FaweCache.Palette palette = FaweCache.IMP.toPalette(0, ids); - sectionWriter.writeByte(palette.getBitsPerEntry()); // bits per block - sectionWriter.writeVarInt(palette.getPaletteToBlockLength()); - for (int i = 0; i < palette.getPaletteToBlockLength(); i++) { - int ordinal = palette.getPaletteToBlock()[i]; + sectionWriter.writeByte(palette.bitsPerEntry); // bits per block + sectionWriter.writeVarInt(palette.paletteToBlockLength); + for (int i = 0; i < palette.paletteToBlockLength; i++) { + int ordinal = palette.paletteToBlock[i]; switch (ordinal) { case BlockID.__RESERVED__: case BlockID.CAVE_AIR: @@ -112,9 +112,9 @@ public interface IBlocks extends Trimable { break; } } - sectionWriter.writeVarInt(palette.getBlockStatesLength()); - for (int i = 0; i < palette.getBlockStatesLength(); i++) { - sectionWriter.writeLong(palette.getBlockStates()[i]); + sectionWriter.writeVarInt(palette.blockStatesLength); + for (int i = 0; i < palette.blockStatesLength; i++) { + sectionWriter.writeLong(palette.blockStates[i]); } // } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index bdb431bae..8a5a2c2e5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -78,7 +78,7 @@ public interface IQueueExtent extends Flushable, Trimable, ICh @Override default BlockVector3 getMaximumPoint() { - return BlockVector3.at(30000000, FaweCache.WORLD_MAX_Y, 30000000); + return BlockVector3.at(30000000, FaweCache.IMP.WORLD_MAX_Y, 30000000); } /** 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 ab0c98ba9..a3712a053 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 @@ -84,7 +84,7 @@ public class BitSetBlocks implements IChunkSet { @Override public char[] load(int layer) { - char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get(); MemBlockSet.IRow nullRowY = row.getRow(layer); if (nullRowY instanceof MemBlockSet.RowY) { char value = blockState.getOrdinalChar(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java index f186861d9..20c2554aa 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java @@ -25,7 +25,7 @@ import java.util.stream.IntStream; import org.jetbrains.annotations.Range; public class CharSetBlocks extends CharBlocks implements IChunkSet { - private static Pool POOL = FaweCache.INSTANCE.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL); + private static Pool POOL = FaweCache.IMP.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL); public static CharSetBlocks newInstance() { return POOL.poll(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java index a0e98f71c..0c0ab3d44 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java @@ -142,7 +142,7 @@ public class FallbackChunkGet implements IChunkGet { @Override public char[] load(int layer) { - char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get(); int by = layer << 4; for (int y = 0, i = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt index ac154a3e7..77e85f715 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt @@ -55,7 +55,7 @@ object NullChunkGet : IChunkGet { } override fun load(layer: Int): CharArray { - return FaweCache.EMPTY_CHAR_4096 + return FaweCache.IMP.EMPTY_CHAR_4096 } override fun hasSection(layer: Int): Boolean { 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 6f781c210..42adcb485 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 @@ -30,7 +30,7 @@ import org.jetbrains.annotations.Range; */ public class ChunkHolder> implements IQueueChunk { - private static Pool POOL = FaweCache.INSTANCE.registerPool(ChunkHolder.class, ChunkHolder::new, Settings.IMP.QUEUE.POOL); + private static Pool POOL = FaweCache.IMP.registerPool(ChunkHolder.class, ChunkHolder::new, Settings.IMP.QUEUE.POOL); public static ChunkHolder newInstance() { return POOL.poll(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java index 8c9000e50..7fa28bbfe 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java @@ -67,7 +67,7 @@ public class CharFilterBlock extends ChunkFilterBlock { this.layer = layer; final IBlocks get = (CharGetBlocks) iget; if (!get.hasSection(layer)) { - getArr = FaweCache.INSTANCE.getEMPTY_CHAR_4096(); + getArr = FaweCache.IMP.EMPTY_CHAR_4096; } else { getArr = get.load(layer); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java index 9ed925870..b904c5cd6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java @@ -63,7 +63,7 @@ public class ChunkPacket implements Function, Supplier { synchronized (this) { if (sectionBytes == null) { IBlocks tmpChunk = getChunk(); - byte[] buf = FaweCache.INSTANCE.getBYTE_BUFFER_8192().get(); + byte[] buf = FaweCache.IMP.BYTE_BUFFER_8192.get(); sectionBytes = tmpChunk.toByteArray(buf, tmpChunk.getBitMask(), this.full); } tmp = sectionBytes; @@ -83,13 +83,13 @@ public class ChunkPacket implements Function, Supplier { @Override @Deprecated public byte[] get() { - return apply(FaweCache.INSTANCE.getBYTE_BUFFER_8192().get()); + return apply(FaweCache.IMP.BYTE_BUFFER_8192.get()); } public CompoundTag getHeightMap() { HashMap map = new HashMap<>(); map.put("MOTION_BLOCKING", new long[36]); - CompoundTag tag = FaweCache.INSTANCE.asTag(map); + CompoundTag tag = FaweCache.IMP.asTag(map); // TODO return tag; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java index 28982600c..1c59fc96d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java @@ -119,7 +119,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getHighestTerrainBlock(x, z, minY, maxY); } catch (FaweException e) { @@ -132,7 +132,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getHighestTerrainBlock(x, z, minY, maxY, filter); } catch (FaweException e) { @@ -145,7 +145,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getNearestSurfaceLayer(x, z, y, minY, maxY); } catch (FaweException e) { @@ -158,7 +158,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir); } catch (FaweException e) { @@ -171,7 +171,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY); } catch (FaweException e) { @@ -184,7 +184,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax); } catch (FaweException e) { @@ -197,7 +197,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); } catch (FaweException e) { @@ -210,7 +210,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); } catch (FaweException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java index f6e0a2023..3300a501a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java @@ -58,7 +58,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap @Override public boolean cancel() { if (super.cancel()) { - processor.setProcessor(new NullExtent(this, FaweCache.INSTANCE.getMANUAL())); + processor.setProcessor(new NullExtent(this, FaweCache.MANUAL)); return true; } return false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java index 03dd8424d..343d4b484 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java @@ -40,7 +40,7 @@ public abstract class QueueHandler implements Trimable, Runnable { private ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool(); private ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool(); - private ThreadPoolExecutor blockingExecutor = FaweCache.INSTANCE.newBlockingExecutor(); + private ThreadPoolExecutor blockingExecutor = FaweCache.IMP.newBlockingExecutor(); private ConcurrentLinkedQueue syncTasks = new ConcurrentLinkedQueue<>(); private ConcurrentLinkedQueue syncWhenFree = new ConcurrentLinkedQueue<>(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index 381da4689..295ff09be 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -475,7 +475,7 @@ public class AnvilCommands { // }); // if (useData) { // for (long[] c : map) { -// BaseBlock block = FaweCache.INSTANCE.CACHE_BLOCK[(int) c[0]]; +// BaseBlock block = FaweCache.IMP.CACHE_BLOCK[(int) c[0]]; // String name = BlockType.fromID(block.getId()).getName(); // String str = String.format("%-7s (%.3f%%) %s #%d:%d", // String.valueOf(c[1]), 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 522b90e32..16cc9f06d 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 @@ -72,7 +72,7 @@ public class MCAChunk implements IChunk { int bitsPerEntry = MathMan.log2nlz(section.palette.length - 1); BitArray4096 bitArray = new BitArray4096(section.blocks, bitsPerEntry); - char[] buffer = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] buffer = FaweCache.IMP.SECTION_BITS_TO_CHAR.get(); bitArray.toRaw(buffer); int offset = section.layer << 12; for (int i = 0; i < buffer.length; i++) { @@ -152,20 +152,20 @@ public class MCAChunk implements IChunk { StreamDelegate blockStates = layer.add("BlockStates"); blockStates.withInfo((length, type) -> { if (section.blocks == null) { - section.blocks = FaweCache.INSTANCE.getLONG_BUFFER_1024().get(); + section.blocks = FaweCache.IMP.LONG_BUFFER_1024.get(); } section.blocksLength = length; }); blockStates.withLong((index, value) -> section.blocks[index] = value); level.add("TileEntities").withElem((ValueReader>) (index, value) -> { - CompoundTag tile = FaweCache.INSTANCE.asTag(value); + CompoundTag tile = FaweCache.IMP.asTag(value); int x = tile.getInt("x") & 15; int y = tile.getInt("y"); int z = tile.getInt("z") & 15; tiles.put(x, y, z, tile); }); level.add("Entities").withElem((ValueReader>) (index, value) -> { - CompoundTag entity = FaweCache.INSTANCE.asTag(value); + CompoundTag entity = FaweCache.IMP.asTag(value); entities.put(entity.getUUID(), entity); }); level.add("Biomes").withInt((index, value) -> biomes[index] = BiomeTypes.getLegacy(value)); @@ -218,10 +218,10 @@ public class MCAChunk implements IChunk { } public void write(NBTOutputStream nbtOut) throws IOException { - int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get(); - int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - long[] blockstates = FaweCache.INSTANCE.getBLOCK_STATES().get(); - int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get(); + int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get(); + int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get(); + long[] blockstates = FaweCache.IMP.BLOCK_STATES.get(); + int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get(); nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND); nbtOut.writeNamedTag("DataVersion", 1631); @@ -524,7 +524,7 @@ public class MCAChunk implements IChunk { @Override public char[] load(int layer) { - char[] tmp = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get(); int offset = layer << 12; System.arraycopy(blocks, offset, tmp, 0, 4096); return tmp; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java index 76c4050c4..f8ceb5f10 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java @@ -138,7 +138,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh @Override public BlockVector3 getMaximumPoint() { - return BlockVector3.at((this.X << 9) + 511, FaweCache.WORLD_MAX_Y, (this.Z << 9) + 511); + return BlockVector3.at((this.X << 9) + 511, FaweCache.IMP.WORLD_MAX_Y, (this.Z << 9) + 511); } @Override @@ -361,7 +361,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh raf.seek(offset); int size = raf.readInt(); int compression = raf.read(); - byte[] data = FaweCache.INSTANCE.getBYTE_BUFFER_VAR().get(size); + byte[] data = FaweCache.IMP.BYTE_BUFFER_VAR.get(size); raf.readFully(data, 0, size); FastByteArrayInputStream result = new FastByteArrayInputStream(data, 0, size); return result; @@ -379,7 +379,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh private NBTInputStream getChunkIS(InputStream is) throws IllegalAccessException { InflaterInputStream iis = new InflaterInputStream(is, new Inflater(), 1); - fieldBuf2.set(iis, FaweCache.INSTANCE.getBYTE_BUFFER_8192().get()); + fieldBuf2.set(iis, FaweCache.IMP.BYTE_BUFFER_8192.get()); BufferedInputStream bis = new BufferedInputStream(iis); NBTInputStream nis = new NBTInputStream(bis); return nis; @@ -414,13 +414,13 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh if (chunk.isDeleted()) { return null; } - byte[] writeBuffer = FaweCache.INSTANCE.getBYTE_BUFFER_VAR().get(4096); + byte[] writeBuffer = FaweCache.IMP.BYTE_BUFFER_VAR.get(4096); FastByteArrayOutputStream uncompressed = chunk.toBytes(writeBuffer); if (uncompressed.array.length > writeBuffer.length) { - FaweCache.INSTANCE.getBYTE_BUFFER_VAR().set(uncompressed.array); + FaweCache.IMP.BYTE_BUFFER_VAR.set(uncompressed.array); } writeBuffer = uncompressed.array; - byte[] buffer = FaweCache.INSTANCE.getBYTE_BUFFER_8192().get(); + byte[] buffer = FaweCache.IMP.BYTE_BUFFER_8192.get(); int length = uncompressed.length; uncompressed.reset(); // cheat, reusing the same buffer to read/write diff --git a/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java index 7ab8746ec..bbd71dae8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java @@ -55,10 +55,10 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet { // loc.x = x; // loc.y = y; // loc.z = z; -// oldBlock.id = FaweCache.INSTANCE.getId(combinedId4DataFrom); -// oldBlock.data = FaweCache.INSTANCE.getData(combinedId4DataFrom); -// newBlock.id = FaweCache.INSTANCE.getId(combinedId4DataTo); -// newBlock.data = FaweCache.INSTANCE.getData(combinedId4DataTo); +// oldBlock.id = FaweCache.IMP.getId(combinedId4DataFrom); +// oldBlock.data = FaweCache.IMP.getData(combinedId4DataFrom); +// newBlock.id = FaweCache.IMP.getId(combinedId4DataTo); +// newBlock.data = FaweCache.IMP.getData(combinedId4DataTo); // // Log to BlocksHub and parent // api.logBlock(loc, player, world, oldBlock, newBlock); parent.add(x, y, z, combinedId4DataFrom, combinedId4DataTo); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java index 179403f20..d3f366538 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java @@ -136,51 +136,51 @@ public class FaweLimit { } public void THROW_MAX_CHANGES() { - if (MAX_CHANGES-- <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES(); + if (MAX_CHANGES-- <= 0) throw FaweCache.MAX_CHANGES; } public void THROW_MAX_FAILS() { - if (MAX_FAILS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if (MAX_FAILS-- <= 0) throw FaweCache.MAX_CHECKS; } public void THROW_MAX_CHECKS() { - if (MAX_CHECKS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if (MAX_CHECKS-- <= 0) throw FaweCache.MAX_CHECKS; } public void THROW_MAX_ITERATIONS() { - if (MAX_ITERATIONS-- <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS(); + if (MAX_ITERATIONS-- <= 0) throw FaweCache.MAX_ITERATIONS; } public void THROW_MAX_BLOCKSTATES() { - if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.INSTANCE.getMAX_TILES(); + if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.MAX_TILES; } public void THROW_MAX_ENTITIES() { - if (MAX_ENTITIES-- <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES(); + if (MAX_ENTITIES-- <= 0) throw FaweCache.MAX_ENTITIES; } public void THROW_MAX_CHANGES(int amt) { - if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES(); + if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES; } public void THROW_MAX_FAILS(int amt) { - if ((MAX_FAILS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS; } public void THROW_MAX_CHECKS(int amt) { - if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS; } public void THROW_MAX_ITERATIONS(int amt) { - if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS(); + if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS; } public void THROW_MAX_BLOCKSTATES(int amt) { - if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_TILES(); + if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.MAX_TILES; } public void THROW_MAX_ENTITIES(int amt) { - if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES(); + if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.MAX_ENTITIES; } public boolean isUnlimited() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index fadad9001..938344f27 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java @@ -63,7 +63,7 @@ public class SplineBrush implements Brush, ResettableTool { this.position = position; if (newPos) { if (positionSets.size() >= MAX_POINTS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.MAX_CHECKS; } final ArrayList points = new ArrayList<>(); if (size > 0) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index c5cd08d7a..460ce7402 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -1563,12 +1563,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr char[] floor = this.floor.get(); char[] overlay = this.overlay != null ? this.overlay.get() : null; try { - int[] indexes = FaweCache.INSTANCE.getINDEX_STORE().get(); + int[] indexes = FaweCache.IMP.INDEX_STORE.get(); int index; int maxY = 0; int minY = Integer.MAX_VALUE; - int[] heightMap = FaweCache.INSTANCE.getHEIGHT_STORE().get(); + int[] heightMap = FaweCache.IMP.HEIGHT_STORE.get(); int globalIndex; for (int z = csz; z <= cez; z++) { globalIndex = z * getWidth() + csx; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java index 8fb85e0da..d2ce6f254 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java @@ -171,7 +171,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor, C // add each block and tile char[] blocksGet = get.load(layer); if (blocksGet == null) { - blocksGet = FaweCache.INSTANCE.getEMPTY_CHAR_4096(); + blocksGet = FaweCache.IMP.EMPTY_CHAR_4096; } char[] blocksSet = set.load(layer); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java index c527c560f..dee7d30bb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java @@ -87,10 +87,10 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet { try { blockBag.fetchPlacedBlock(typeTo.getDefaultState()); } catch (UnplaceableBlockException e) { - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.IMP.BLOCK_BAG; } catch (BlockBagException e) { missingBlocks[typeTo.getInternalId()]++; - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.IMP.BLOCK_BAG; } } if (mine) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java index f506554d8..e2c00c8e5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/ClipboardRemapper.java @@ -223,7 +223,7 @@ public class ClipboardRemapper { // String name = entry.getKey(); // int id = value.get("id").getAsInt(); // int data = value.get("data").getAsInt(); -// int combined = FaweCache.INSTANCE.getCombined(id, data); +// int combined = FaweCache.IMP.getCombined(id, data); // map.putIfAbsent(name, new ArrayList<>()); // map.get(name).add(combined); // } @@ -496,7 +496,7 @@ public class ClipboardRemapper { // int combined = block.getCombined(); // if (remap[combined]) { // char value = remapCombined[combined]; -// BaseBlock newBlock = FaweCache.INSTANCE.CACHE_BLOCK[value]; +// BaseBlock newBlock = FaweCache.IMP.CACHE_BLOCK[value]; // newBlock.setNbtData(block.getNbtData()); // return newBlock; // } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java index 3a7735439..332643e57 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull; */ public final class MemBlockSet extends BlockSet { public final static int BITS_PER_WORD = 6; - public final static int WORDS = FaweCache.BLOCKS_PER_LAYER >> BITS_PER_WORD; + public final static int WORDS = FaweCache.IMP.BLOCKS_PER_LAYER >> BITS_PER_WORD; public final static IRow NULL_ROW_X = new NullRowX(); public final static IRow NULL_ROW_Z = new NullRowZ(); public final static IRow NULL_ROW_Y = new NullRowY(); @@ -357,8 +357,8 @@ public final class MemBlockSet extends BlockSet { maxy = y + 1; } by = (Y << 4) + y; - if (by == FaweCache.WORLD_MAX_Y) - return FaweCache.WORLD_MAX_Y; + if (by == FaweCache.IMP.WORLD_MAX_Y) + return FaweCache.IMP.WORLD_MAX_Y; break outer; } } @@ -827,7 +827,7 @@ public final class MemBlockSet extends BlockSet { public final IRow[] rows; public RowZ() { - this.rows = new IRow[FaweCache.CHUNK_LAYERS]; + this.rows = new IRow[FaweCache.IMP.CHUNK_LAYERS]; reset(); } @@ -874,7 +874,7 @@ public final class MemBlockSet extends BlockSet { } public void reset() { - for (int i = 0; i < FaweCache.CHUNK_LAYERS; i++) rows[i] = NULL_ROW_Y; + for (int i = 0; i < FaweCache.IMP.CHUNK_LAYERS; i++) rows[i] = NULL_ROW_Y; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java index e4eeba80a..f67b3b3e9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java @@ -71,7 +71,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return false; } @@ -82,7 +82,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public boolean setBiome(int x, int y, int z, BiomeType biome) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return false; } @@ -93,7 +93,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BiomeType getBiome(BlockVector2 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return null; } @@ -104,7 +104,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BiomeType getBiomeType(int x, int y, int z) { if (!contains(x, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return null; } @@ -115,7 +115,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BaseBlock getFullBlock(BlockVector3 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return BlockTypes.AIR.getDefaultState().toBaseBlock(); } @@ -126,7 +126,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BlockState getBlock(BlockVector3 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return BlockTypes.AIR.getDefaultState(); } @@ -137,7 +137,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getBlockLight(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return 0; } @@ -148,7 +148,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getBrightness(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return 0; } @@ -159,7 +159,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getLight(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return 0; } @@ -170,7 +170,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getOpacity(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return 0; } @@ -181,7 +181,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getSkyLight(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return 0; } @@ -193,7 +193,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public Entity createEntity(Location location, BaseEntity entity) { if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java index cab4422f4..d5c309a1c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java @@ -26,7 +26,7 @@ public class MemoryCheckingExtent extends PassthroughExtent { this.player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin")); } } - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getLOW_MEMORY()); + WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY); } return super.getExtent(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java index 670186c6e..e796c2b20 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java @@ -54,7 +54,7 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor { } public NullExtent() { - this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.INSTANCE.getMANUAL()); + this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.MANUAL); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java index 3586e4590..948bd3fd1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java @@ -38,7 +38,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { return null; } if (!limit.MAX_ENTITIES()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_ENTITIES()); + WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_ENTITIES); return null; } return super.createEntity(location, entity); @@ -47,7 +47,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public BlockState getBlock(int x, int y, int z) { if (!limit.MAX_CHECKS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS()); + WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS); return BlockTypes.AIR.getDefaultState(); } else { return extent.getBlock(x, y, z); @@ -57,7 +57,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public BaseBlock getFullBlock(BlockVector3 pos) { if (!limit.MAX_CHECKS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS()); + WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS); return BlockTypes.AIR.getDefaultState().toBaseBlock(); } else { return extent.getFullBlock(pos); @@ -79,18 +79,18 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { boolean hasNbt = block instanceof BaseBlock && block.hasNbtData(); if (hasNbt) { if (!limit.MAX_BLOCKSTATES()) { - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_TILES()); + WEManager.IMP.cancelEdit(this, FaweCache.MAX_TILES); return false; } else { if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES()); + WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES); return false; } return extent.setBlock(x, y, z, block); } } if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES()); + WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES); return false; } else { return extent.setBlock(x, y, z, block); @@ -100,7 +100,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHANGES()); + WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHANGES); return false; } return super.setBiome(position, biome); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java index 45bd489df..84f3e7aca 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java @@ -31,10 +31,10 @@ public abstract class FaweBlockMatcher { // public boolean apply(BaseBlock oldBlock) { // int currentId = oldBlock.getId(); // oldBlock.setId(id); -// if (FaweCache.INSTANCE.hasData(currentId)) { +// if (FaweCache.IMP.hasData(currentId)) { // oldBlock.setData(0); // } -// if (FaweCache.INSTANCE.hasNBT(currentId)) { +// if (FaweCache.IMP.hasNBT(currentId)) { // oldBlock.setNbtData(null); // } // return true; @@ -47,7 +47,7 @@ public abstract class FaweBlockMatcher { // int currentId = oldBlock.getId(); // oldBlock.setId(id); // oldBlock.setData(data); -// if (FaweCache.INSTANCE.hasNBT(currentId)) { +// if (FaweCache.IMP.hasNBT(currentId)) { // oldBlock.setNbtData(null); // } // return true; @@ -67,10 +67,10 @@ public abstract class FaweBlockMatcher { // BaseBlock replace = array[random.random(size)]; // int currentId = block.getId(); // block.setId(replace.getId()); -// if (FaweCache.INSTANCE.hasNBT(currentId)) { +// if (FaweCache.IMP.hasNBT(currentId)) { // block.setNbtData(null); // } -// if (FaweCache.INSTANCE.hasData(currentId) || replace.getData() != 0) { +// if (FaweCache.IMP.hasData(currentId) || replace.getData() != 0) { // block.setData(replace.getData()); // } // return true; @@ -82,7 +82,7 @@ public abstract class FaweBlockMatcher { public static FaweBlockMatcher fromBlock(BaseBlock block, boolean checkData) { // final int id = block.getId(); // final int data = block.getData(); -// if (checkData && FaweCache.INSTANCE.hasData(id)) { +// if (checkData && FaweCache.IMP.hasData(id)) { // return new FaweBlockMatcher() { // @Override // public boolean apply(BaseBlock block) { @@ -104,13 +104,13 @@ public abstract class FaweBlockMatcher { // if (searchBlocks.size() == 1) { // return fromBlock(searchBlocks.iterator().next(), checkData); // } -// final boolean[] allowedId = new boolean[FaweCache.INSTANCE.getId(Character.MAX_VALUE)]; +// final boolean[] allowedId = new boolean[FaweCache.IMP.getId(Character.MAX_VALUE)]; // for (BaseBlock block : searchBlocks) { // allowedId[block.getId()] = true; // } // final boolean[] allowed = new boolean[Character.MAX_VALUE]; // for (BaseBlock block : searchBlocks) { -// allowed[FaweCache.INSTANCE.getCombined(block)] = true; +// allowed[FaweCache.IMP.getCombined(block)] = true; // } // if (checkData) { // return new FaweBlockMatcher() { @@ -118,7 +118,7 @@ public abstract class FaweBlockMatcher { // public boolean apply(BaseBlock block) { // int id = block.getId(); // if (allowedId[id]) { -// if (FaweCache.INSTANCE.hasData(id)) { +// if (FaweCache.IMP.hasData(id)) { // return allowed[(id << 4) + block.getData()]; // } // return true; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java index 7b8ce41fd..ef83c1285 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java @@ -162,7 +162,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { if (width > WARN_SIZE || height > WARN_SIZE || length > WARN_SIZE) { getLogger(MinecraftStructure.class).debug("A structure longer than 32 is unsupported by minecraft (but probably still works)"); } - Map structure = FaweCache.INSTANCE.asMap("version", 1, "author", owner); + Map structure = FaweCache.IMP.asMap("version", 1, "author", owner); // ignored: version / owner MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); Int2ObjectArrayMap indexes = new Int2ObjectArrayMap<>(); @@ -212,10 +212,10 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { List pos = Arrays.asList(point.getX() - min.getX(), point.getY() - min.getY(), point.getZ() - min.getZ()); if (!block.hasNbtData()) { - blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos)); + blocks.add(FaweCache.IMP.asMap("state", index, "pos", pos)); } else { blocks.add( - FaweCache.INSTANCE.asMap("state", index, "pos", pos, "nbt", block.getNbtData())); + FaweCache.IMP.asMap("state", index, "pos", pos, "nbt", block.getNbtData())); } } } @@ -235,14 +235,14 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { // Replace rotation data nbtMap.put("Rotation", writeRotation(entity.getLocation())); nbtMap.put("id", new StringTag(state.getType().getId())); - Map entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt); + Map entityMap = FaweCache.IMP.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt); entities.add(entityMap); } } if (!entities.isEmpty()) { structure.put("entities", entities); } - out.writeNamedTag("", FaweCache.INSTANCE.asTag(structure)); + out.writeNamedTag("", FaweCache.IMP.asTag(structure)); close(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweLocalBlockQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweLocalBlockQueue.java index 8047612f7..ed10b172d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweLocalBlockQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweLocalBlockQueue.java @@ -124,7 +124,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue { @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - IMP.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.INSTANCE.asTag(tag)); + IMP.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag)); return true; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweSchematicHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweSchematicHandler.java index 553a0b891..3a3eec8ff 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweSchematicHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweSchematicHandler.java @@ -108,7 +108,7 @@ public class FaweSchematicHandler extends SchematicHandler { com.github.intellectualsites.plotsquared.plot.util.TaskManager.runTask(whenDone); return; } - CompoundTag weTag = (CompoundTag) FaweCache.INSTANCE.asTag(tag); + CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag); if (weTag instanceof CompressedSchematicTag) { Clipboard clipboard = ((CompressedSchematicTag) weTag).getSource(); URL url = FaweAPI.upload(clipboard, BuiltInClipboardFormat.SPONGE_SCHEMATIC); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java index db36de331..8964a5ebe 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java @@ -92,7 +92,7 @@ public final class BrushCache { } else { displayMap = ReflectionUtils.getMap(display.getValue()); } - displayMap.put("Lore", FaweCache.INSTANCE.asTag(json.split("\\r?\\n"))); + displayMap.put("Lore", FaweCache.IMP.asTag(json.split("\\r?\\n"))); String primary = (String) tool.getPrimary().getSettings().get(BrushSettings.SettingType.BRUSH); String secondary = (String) tool.getSecondary().getSettings().get(BrushSettings.SettingType.BRUSH); if (primary == null) primary = secondary; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java index 7b2b52b79..cc29e7479 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java @@ -232,11 +232,11 @@ public class EditSessionBuilder { event.setExtent(extent); eventBus.post(event); if (event.isCancelled()) { - return new NullExtent(extent, FaweCache.INSTANCE.getMANUAL()); + return new NullExtent(extent, FaweCache.MANUAL); } final Extent toReturn = event.getExtent(); if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) { - return new NullExtent(toReturn, FaweCache.INSTANCE.getMANUAL()); + return new NullExtent(toReturn, FaweCache.MANUAL); } // if (!(toReturn instanceof AbstractDelegateExtent)) { // Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent"); @@ -316,7 +316,7 @@ public class EditSessionBuilder { if (Permission.hasPermission(player, "worldedit.fast")) { player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin")); } - throw FaweCache.INSTANCE.getLOW_MEMORY(); + throw FaweCache.LOW_MEMORY; } } // this.originalLimit = limit; @@ -420,7 +420,7 @@ public class EditSessionBuilder { FaweRegionExtent regionExtent = null; if (allowedRegions != null) { if (allowedRegions.length == 0) { - regionExtent = new NullExtent(this.extent, FaweCache.INSTANCE.getNO_REGION()); + regionExtent = new NullExtent(this.extent, FaweCache.NO_REGION); } else { // this.extent = new ProcessedWEExtent(this.extent, this.limit); if (allowedRegions.length == 1) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java b/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java index a1f71161c..b721ee2b3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java @@ -58,7 +58,7 @@ public class SchemSync implements Runnable { private void close(Error error) throws IOException { this.clientSocket.getOutputStream().write(error.ordinal()); - throw FaweCache.INSTANCE.getMANUAL(); + throw FaweCache.MANUAL; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 2a5cc5d7b..77509df7b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2803,7 +2803,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { BlockVector3 max = region.getMaximumPoint(); BlockVector3 min = region.getMinimumPoint(); if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ())) { - throw FaweCache.INSTANCE.getOUTSIDE_REGION(); + throw FaweCache.OUTSIDE_REGION; } } final Set chunks = region.getChunks(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index f783d8f4e..bda07a08d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -128,7 +128,7 @@ public class ClipboardCommands { ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.MAX_CHECKS; } session.setClipboard(null); @@ -235,10 +235,10 @@ public class ClipboardCommands { long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.MAX_CHECKS; } if (volume >= limit.MAX_CHANGES) { - throw FaweCache.INSTANCE.getMAX_CHANGES(); + throw FaweCache.MAX_CHANGES; } session.setClipboard(null); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 59ab8465e..8f5d8f51b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -422,7 +422,7 @@ public class RegionCommands { long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.MAX_CHECKS; } int affected = 0; try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 1f2f2b7f6..520a6c496 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -457,7 +457,7 @@ public interface Extent extends InputExtent, OutputExtent { default boolean cancel() { ExtentTraverser traverser = new ExtentTraverser<>(this); - NullExtent nullExtent = new NullExtent(this, FaweCache.INSTANCE.getMANUAL()); + NullExtent nullExtent = new NullExtent(this, FaweCache.MANUAL); ExtentTraverser next = traverser.next(); if (next != null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 7daad2b45..7aea7c97a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -51,7 +51,7 @@ import java.util.concurrent.ConcurrentHashMap; public class MaskingExtent extends AbstractDelegateExtent implements IBatchProcessor, Filter { private Mask mask; - private LoadingCache threadIdToFilter = FaweCache.INSTANCE.createCache(() -> new CharFilterBlock(getExtent())); + private LoadingCache threadIdToFilter = FaweCache.IMP.createCache(() -> new CharFilterBlock(getExtent())); /** * Create a new instance. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java index c824da795..a3957ada3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java @@ -268,7 +268,7 @@ public class FastSchematicReader extends NBTSchematicReader { // tiles if (tiles != null && !tiles.isEmpty()) { for (Map tileRaw : tiles) { - CompoundTag tile = FaweCache.INSTANCE.asTag(tileRaw); + CompoundTag tile = FaweCache.IMP.asTag(tileRaw); int[] pos = tile.getIntArray("Pos"); int x,y,z; @@ -303,7 +303,7 @@ public class FastSchematicReader extends NBTSchematicReader { // entities if (entities != null && !entities.isEmpty()) { for (Map entRaw : entities) { - CompoundTag ent = FaweCache.INSTANCE.asTag(entRaw); + CompoundTag ent = FaweCache.IMP.asTag(entRaw); Map value = ent.getValue(); StringTag id = (StringTag) value.get("Id"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java index 36918bee9..6625aad43 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java @@ -322,7 +322,7 @@ public class SchematicReader implements ClipboardReader { if (tiles != null && !tiles.isEmpty()) { outer: for (Map tileRaw : tiles) { - CompoundTag tile = FaweCache.INSTANCE.asTag(tileRaw); + CompoundTag tile = FaweCache.IMP.asTag(tileRaw); int x = (int) tileRaw.get("x"); int y = (int) tileRaw.get("y"); int z = (int) tileRaw.get("z"); @@ -350,7 +350,7 @@ public class SchematicReader implements ClipboardReader { entRaw.put("Id", id); EntityType type = EntityTypes.parse(id); if (type != null) { - CompoundTag ent = FaweCache.INSTANCE.asTag(entRaw); + CompoundTag ent = FaweCache.IMP.asTag(entRaw); for (EntityNBTCompatibilityHandler compat : ENTITY_COMPATIBILITY_HANDLERS) { if (compat.isAffectedEntity(type, ent)) { ent = compat.updateNBT(type, ent); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index 3ca0aefc2..c2187ff1b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -107,10 +107,10 @@ public class BlockBagExtent extends AbstractDelegateExtent { try { blockBag.fetchPlacedBlock(block.toImmutableState()); } catch (UnplaceableBlockException e) { - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.BLOCK_BAG; } catch (BlockBagException e) { missingBlocks[block.getBlockType().getInternalId()]++; - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.BLOCK_BAG; } } if (mine) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java index 012431c73..cbee3feb9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java @@ -13,7 +13,7 @@ public class MutableBlockVector3 extends BlockVector3 { } public static MutableBlockVector3 get(int x, int y, int z) { - return FaweCache.INSTANCE.getMUTABLE_BLOCKVECTOR3().get().setComponents(x, y, z); + return FaweCache.IMP.MUTABLE_BLOCKVECTOR3.get().setComponents(x, y, z); } public MutableBlockVector3() {} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java index e3ff705c1..4c38e9ea1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java @@ -10,11 +10,11 @@ public class MutableVector3 extends Vector3 { } public static MutableVector3 get(int x, int y, int z) { - return FaweCache.INSTANCE.getMUTABLE_VECTOR3().get().setComponents(x, y, z); + return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z); } public static MutableVector3 get(double x, double y, double z) { - return FaweCache.INSTANCE.getMUTABLE_VECTOR3().get().setComponents(x, y, z); + return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z); } public MutableVector3(double x, double y, double z) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 6552c948c..03b6fdc6c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -124,8 +124,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { if (pos1 == null || pos2 == null) { return; } - pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.WORLD_MAX_Y : world.getMaxY()); - pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.WORLD_MAX_Y : world.getMaxY()); + pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY()); + pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY()); minX = Math.min(pos1.getX(), pos2.getX()); minY = Math.min(pos1.getY(), pos2.getY()); minZ = Math.min(pos1.getZ(), pos2.getZ()); @@ -730,7 +730,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { boolean trimZ = lowerZ != 0 || upperZ != 15; int indexY, index; - for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) { if (set.hasSection(layer)) { char[] arr = set.load(layer); if (trimX || trimZ) {