diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java
index 814cd1146..31d2946b4 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java
@@ -18,29 +18,38 @@ import java.util.concurrent.Future;
import java.util.function.Supplier;
/**
- * Single threaded implementation for IQueueExtent (still abstract)
- * - Does not implement creation of chunks (that has to implemented by the platform e.g. Bukkit)
- *
- * This queue is reusable {@link #init(WorldChunkCache)}
+ * Single threaded implementation for IQueueExtent (still abstract) - Does not implement creation of
+ * chunks (that has to implemented by the platform e.g. Bukkit)
+ *
+ * This queue is reusable {@link #init(WorldChunkCache)}
*/
public abstract class SingleThreadQueueExtent implements IQueueExtent {
+
+ // Pool discarded chunks for reuse (can safely be cleared by another thread)
+ private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>();
+ // Chunks currently being queued / worked on
+ private final Long2ObjectLinkedOpenHashMap chunks = new Long2ObjectLinkedOpenHashMap<>();
private WorldChunkCache cache;
private Thread currentThread;
private ConcurrentLinkedQueue submissions = new ConcurrentLinkedQueue<>();
+ // Last access pointers
+ private IChunk lastChunk;
+ private long lastPair = Long.MAX_VALUE;
/**
- * Safety check to ensure that the thread being used matches the one being initialized on.
- * - Can be removed later
+ * Safety check to ensure that the thread being used matches the one being initialized on. - Can
+ * be removed later
*/
private void checkThread() {
if (Thread.currentThread() != currentThread && currentThread != null) {
- throw new UnsupportedOperationException("This class must be used from a single thread. Use multiple queues for concurrent operations");
+ throw new UnsupportedOperationException(
+ "This class must be used from a single thread. Use multiple queues for concurrent operations");
}
}
@Override
- public IChunkGet getCachedGet(int X, int Z, Supplier supplier) {
- return cache.get(MathMan.pairInt(X, Z), supplier);
+ public IChunkGet getCachedGet(int x, int z, Supplier supplier) {
+ return cache.get(MathMan.pairInt(x, z), supplier);
}
/**
@@ -60,10 +69,11 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
/**
* Initialize the queue
+ *
* @param cache
*/
@Override
- public synchronized void init(final WorldChunkCache cache) {
+ public synchronized void init(WorldChunkCache cache) {
if (this.cache != null) {
reset();
}
@@ -72,15 +82,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
this.cache = cache;
}
- // Last access pointers
- private IChunk lastChunk;
- private long lastPair = Long.MAX_VALUE;
- // Chunks currently being queued / worked on
- private final Long2ObjectLinkedOpenHashMap chunks = new Long2ObjectLinkedOpenHashMap<>();
- // Pool discarded chunks for reuse (can safely be cleared by another thread)
- private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>();
-
- public void returnToPool(final IChunk chunk) {
+ public void returnToPool(IChunk chunk) {
CHUNK_POOL.add(chunk);
}
@@ -95,7 +97,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
}
@Override
- public > T submit(final IChunk chunk) {
+ public > T submit(IChunk chunk) {
if (lastChunk == chunk) {
lastPair = Long.MAX_VALUE;
lastChunk = null;
@@ -107,11 +109,12 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
/**
* Submit without first checking that it has been removed from the chunk map
+ *
* @param chunk
* @param
* @return
*/
- private > T submitUnchecked(final IChunk chunk) {
+ private > T submitUnchecked(IChunk chunk) {
if (chunk.isEmpty()) {
CHUNK_POOL.add(chunk);
return (T) (Future) Futures.immediateFuture(null);
@@ -125,7 +128,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
}
@Override
- public synchronized boolean trim(final boolean aggressive) {
+ public synchronized boolean trim(boolean aggressive) {
// TODO trim individial chunk sections
CHUNK_POOL.clear();
if (Thread.currentThread() == currentThread) {
@@ -146,13 +149,14 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
}
/**
- * Get a new IChunk from either the pool, or create a new one
- * + Initialize it at the coordinates
+ * Get a new IChunk from either the pool, or create a new one
+ Initialize it at the
+ * coordinates
+ *
* @param X
* @param Z
* @return IChunk
*/
- private IChunk poolOrCreate(final int X, final int Z) {
+ private IChunk poolOrCreate(int X, int Z) {
IChunk next = CHUNK_POOL.poll();
if (next == null) {
next = create(false);
@@ -162,21 +166,23 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
}
@Override
- public final IChunk getCachedChunk(final int X, final int Z) {
- final long pair = (((long) X) << 32) | (Z & 0xffffffffL);
+ public final IChunk getCachedChunk(int x, int z) {
+ final long pair = (long) x << 32 | z & 0xffffffffL;
if (pair == lastPair) {
return lastChunk;
}
IChunk chunk = chunks.get(pair);
if (chunk instanceof ReferenceChunk) {
- chunk = ((ReferenceChunk) (chunk)).getParent();
+ chunk = ((ReferenceChunk) chunk).getParent();
}
if (chunk != null) {
lastPair = pair;
lastChunk = chunk;
}
- if (chunk != null) return chunk;
+ if (chunk != null) {
+ return chunk;
+ }
checkThread();
final int size = chunks.size();
@@ -195,7 +201,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
submissions.add(future);
}
}
- chunk = poolOrCreate(X, Z);
+ chunk = poolOrCreate(x, z);
chunk = wrap(chunk);
chunks.put(pair, chunk);
@@ -205,14 +211,15 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
return chunk;
}
- private void pollSubmissions(final int targetSize, final boolean aggressive) {
+ private void pollSubmissions(int targetSize, boolean aggressive) {
final int overflow = submissions.size() - targetSize;
if (aggressive) {
for (int i = 0; i < overflow; i++) {
Future first = submissions.poll();
try {
- while ((first = (Future) first.get()) != null) ;
- } catch (final InterruptedException | ExecutionException e) {
+ while ((first = (Future) first.get()) != null) {
+ }
+ } catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
@@ -223,7 +230,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
if (next.isDone()) {
try {
next = (Future) next.get();
- } catch (final InterruptedException | ExecutionException e) {
+ } catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
} else {
@@ -240,7 +247,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
checkThread();
if (!chunks.isEmpty()) {
if (MemUtil.isMemoryLimited()) {
- for (final IChunk chunk : chunks.values()) {
+ for (IChunk chunk : chunks.values()) {
final Future future = submitUnchecked(chunk);
if (future != null && !future.isDone()) {
pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, true);
@@ -248,7 +255,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
}
}
} else {
- for (final IChunk chunk : chunks.values()) {
+ for (IChunk chunk : chunks.values()) {
final Future future = submitUnchecked(chunk);
if (future != null && !future.isDone()) {
submissions.add(future);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java
index 243bc23c5..08c3e050e 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/WorldChunkCache.java
@@ -6,19 +6,19 @@ import com.sk89q.worldedit.world.World;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
-
import java.lang.ref.WeakReference;
import java.util.function.Supplier;
/**
- * IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple IQueueExtents
- * - avoids conversion between palette and raw data on every block get
+ * IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple
+ * IQueueExtents - avoids conversion between palette and raw data on every block get
*/
public class WorldChunkCache implements Trimable {
+
protected final Long2ObjectLinkedOpenHashMap> getCache;
private final World world;
- protected WorldChunkCache(final World world) {
+ protected WorldChunkCache(World world) {
this.world = world;
this.getCache = new Long2ObjectLinkedOpenHashMap<>();
}
@@ -33,15 +33,18 @@ public class WorldChunkCache implements Trimable {
/**
* Get or create the IGetBlocks
- * @param index chunk index {@link com.boydti.fawe.util.MathMan#pairInt(int, int)}
+ *
+ * @param index chunk index {@link com.boydti.fawe.util.MathMan#pairInt(int, int)}
* @param provider used to create if it isn't already cached
* @return cached IGetBlocks
*/
- public synchronized IChunkGet get(final long index, final Supplier provider) {
+ public synchronized IChunkGet get(long index, Supplier provider) {
final WeakReference ref = getCache.get(index);
if (ref != null) {
final IChunkGet blocks = ref.get();
- if (blocks != null) return blocks;
+ if (blocks != null) {
+ return blocks;
+ }
}
final IChunkGet blocks = provider.get();
getCache.put(index, new WeakReference<>(blocks));
@@ -49,18 +52,22 @@ public class WorldChunkCache implements Trimable {
}
@Override
- public synchronized boolean trim(final boolean aggressive) {
+ public synchronized boolean trim(boolean aggressive) {
boolean result = true;
if (!getCache.isEmpty()) {
- final ObjectIterator>> iter = getCache.long2ObjectEntrySet().fastIterator();
+ final ObjectIterator>> iter = getCache
+ .long2ObjectEntrySet().fastIterator();
while (iter.hasNext()) {
final Long2ObjectMap.Entry> entry = iter.next();
final WeakReference value = entry.getValue();
final IChunkGet igb = value.get();
- if (igb == null) iter.remove();
- else {
+ if (igb == null) {
+ iter.remove();
+ } else {
result = false;
- if (!aggressive) return result;
+ if (!aggressive) {
+ return result;
+ }
synchronized (igb) {
igb.trim(aggressive);
}
@@ -69,4 +76,4 @@ public class WorldChunkCache implements Trimable {
}
return result;
}
-}
\ No newline at end of file
+}
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 cba3e70bc..9303b4a44 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
@@ -1,22 +1,17 @@
package com.boydti.fawe.beta.implementation.blocks;
-import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
-import com.boydti.fawe.object.collection.BitArray4096;
-import com.boydti.fawe.object.collection.BlockSet;
import com.boydti.fawe.object.collection.MemBlockSet;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.biome.BiomeType;
-import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
-
-import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
public class BitSetBlocks implements IChunkSet {
+
private final MemBlockSet.RowZ row;
private final BlockState blockState;
@@ -43,13 +38,16 @@ public class BitSetBlocks implements IChunkSet {
}
@Override
- public void setTile(int x, int y, int z, CompoundTag tile) {}
+ public void setTile(int x, int y, int z, CompoundTag tile) {
+ }
@Override
- public void setEntity(CompoundTag tag) {}
+ public void setEntity(CompoundTag tag) {
+ }
@Override
- public void removeEntity(UUID uuid) {}
+ public void removeEntity(UUID uuid) {
+ }
@Override
public BlockState getBlock(int x, int y, int z) {
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java
index 371f51081..60cb7e6f7 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java
@@ -4,6 +4,26 @@ import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkSet;
public class CharBlocks implements IBlocks {
+
+ public static final Section FULL = new Section() {
+ @Override
+ public final char[] get(CharBlocks blocks, int layer) {
+ return blocks.blocks[layer];
+ }
+ };
+ public static final Section EMPTY = new Section() {
+ @Override
+ public final char[] get(CharBlocks blocks, int layer) {
+ blocks.sections[layer] = FULL;
+ char[] arr = blocks.blocks[layer];
+ if (arr == null) {
+ arr = blocks.blocks[layer] = blocks.load(layer);
+ } else {
+ blocks.blocks[layer] = blocks.load(layer, arr);
+ }
+ return arr;
+ }
+ };
public final char[][] blocks;
public final Section[] sections;
@@ -15,11 +35,13 @@ public class CharBlocks implements IBlocks {
public CharBlocks() {
blocks = new char[16][];
sections = new Section[16];
- for (int i = 0; i < 16; i++) sections[i] = EMPTY;
+ for (int i = 0; i < 16; i++) {
+ sections[i] = EMPTY;
+ }
}
@Override
- public boolean trim(final boolean aggressive) {
+ public boolean trim(boolean aggressive) {
boolean result = true;
for (int i = 0; i < 16; i++) {
if (sections[i] == EMPTY) {
@@ -33,82 +55,67 @@ public class CharBlocks implements IBlocks {
@Override
public IChunkSet reset() {
- for (int i = 0; i < 16; i++) sections[i] = EMPTY;
+ for (int i = 0; i < 16; i++) {
+ sections[i] = EMPTY;
+ }
return null;
}
- public void reset(final int layer) {
+ public void reset(int layer) {
sections[layer] = EMPTY;
}
- public char[] load(final int layer) {
+ public char[] load(int layer) {
return new char[4096];
}
- public char[] load(final int layer, final char[] data) {
- for (int i = 0; i < 4096; i++) data[i] = 0;
+ public char[] load(int layer, char[] data) {
+ for (int i = 0; i < 4096; i++) {
+ data[i] = 0;
+ }
return data;
}
@Override
- public boolean hasSection(final int layer) {
+ public boolean hasSection(int layer) {
return sections[layer] == FULL;
}
- public char get(final int x, final int y, final int z) {
+ public char get(int x, int y, int z) {
final int layer = y >> 4;
- final int index = ((y & 15) << 8) | (z << 4) | (x);
+ final int index = (y & 15) << 8 | z << 4 | x;
return sections[layer].get(this, layer, index);
}
- public void set(final int x, final int y, final int z, final char value) {
+ public void set(int x, int y, int z, char value) {
final int layer = y >> 4;
- final int index = ((y & 15) << 8) | (z << 4) | (x);
+ final int index = (y & 15) << 8 | z << 4 | x;
set(layer, index, value);
}
- public final char get(final int layer, final int index) {
- return sections[layer].get(this, layer, index);
- }
-
- public final void set(final int layer, final int index, final char value) {
- sections[layer].set(this, layer, index, value);
- }
-
/*
Section
*/
+ public final char get(int layer, int index) {
+ return sections[layer].get(this, layer, index);
+ }
+
+ public final void set(int layer, int index, char value) {
+ sections[layer].set(this, layer, index, value);
+ }
+
public static abstract class Section {
+
public abstract char[] get(CharBlocks blocks, int layer);
- public final char get(final CharBlocks blocks, final int layer, final int index) {
+ public final char get(CharBlocks blocks, int layer, int index) {
return get(blocks, layer)[index];
}
- public final void set(final CharBlocks blocks, final int layer, final int index, final char value) {
+ public final void set(CharBlocks blocks, int layer, int index,
+ char value) {
get(blocks, layer)[index] = value;
}
}
-
- public static final Section EMPTY = new Section() {
- @Override
- public final char[] get(final CharBlocks blocks, final int layer) {
- blocks.sections[layer] = FULL;
- char[] arr = blocks.blocks[layer];
- if (arr == null) {
- arr = blocks.blocks[layer] = blocks.load(layer);
- } else {
- blocks.blocks[layer] = blocks.load(layer, arr);
- }
- return arr;
- }
- };
-
- public static final Section FULL = new Section() {
- @Override
- public final char[] get(final CharBlocks blocks, final int layer) {
- return blocks.blocks[layer];
- }
- };
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java
index 7c5dcf613..84b857470 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java
@@ -7,18 +7,19 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
+
@Override
- public BaseBlock getFullBlock(final int x, final int y, final int z) {
+ public BaseBlock getFullBlock(int x, int y, int z) {
return BlockTypes.states[get(x, y, z)].toBaseBlock();
}
@Override
- public BlockState getBlock(final int x, final int y, final int z) {
+ public BlockState getBlock(int x, int y, int z) {
return BlockTypes.states[get(x, y, z)];
}
@Override
- public boolean trim(final boolean aggressive) {
+ public boolean trim(boolean aggressive) {
for (int i = 0; i < 16; i++) {
sections[i] = EMPTY;
blocks[i] = null;
@@ -31,4 +32,4 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
super.reset();
return null;
}
-}
\ No newline at end of file
+}
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 23db45a27..02ff245a2 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
@@ -7,7 +7,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -15,6 +14,7 @@ import java.util.Set;
import java.util.UUID;
public class CharSetBlocks extends CharBlocks implements IChunkSet {
+
public BiomeType[] biomes;
public HashMap tiles;
public HashSet entities;
@@ -57,7 +57,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
@Override
- public boolean setBiome(final int x, final int y, final int z, final BiomeType biome) {
+ public boolean setBiome(int x, int y, int z, BiomeType biome) {
if (biomes == null) {
biomes = new BiomeType[256];
}
@@ -71,13 +71,13 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
@Override
- public boolean setBlock(final int x, final int y, final int z, final BlockStateHolder holder) {
+ public boolean setBlock(int x, int y, int z, BlockStateHolder holder) {
set(x, y, z, holder.getOrdinalChar());
return true;
}
@Override
- public void setTile(final int x, final int y, final int z, final CompoundTag tile) {
+ public void setTile(int x, int y, int z, CompoundTag tile) {
if (tiles == null) {
tiles = new HashMap<>();
}
@@ -86,7 +86,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
@Override
- public void setEntity(final CompoundTag tag) {
+ public void setEntity(CompoundTag tag) {
if (entities == null) {
entities = new HashSet<>();
}
@@ -94,7 +94,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
@Override
- public void removeEntity(final UUID uuid) {
+ public void removeEntity(UUID uuid) {
if (entityRemoves == null) {
entityRemoves = new HashSet<>();
}
@@ -103,7 +103,9 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public boolean isEmpty() {
- if (biomes != null) return false;
+ if (biomes != null) {
+ return false;
+ }
for (int i = 0; i < 16; i++) {
if (hasSection(i)) {
return false;
@@ -121,4 +123,4 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
super.reset();
return null;
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java
index 2e8c320cb..c966df483 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java
@@ -16,14 +16,150 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
-
-import javax.annotation.Nullable;
import java.util.function.Supplier;
+import javax.annotation.Nullable;
/**
- * Abstract IChunk class that implements basic get/set blocks
+ * An abstract {@link IChunk} class that implements basic get/set blocks
*/
public abstract class ChunkHolder implements IChunk, Supplier {
+
+ public static final IBlockDelegate BOTH = new IBlockDelegate() {
+ @Override
+ public boolean setBiome(ChunkHolder chunk, int x, int y, int z,
+ BiomeType biome) {
+ return chunk.set.setBiome(x, y, z, biome);
+ }
+
+ @Override
+ public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
+ BlockStateHolder block) {
+ return chunk.set.setBlock(x, y, z, block);
+ }
+
+ @Override
+ public BiomeType getBiome(ChunkHolder chunk, int x, int z) {
+ return chunk.get.getBiomeType(x, z);
+ }
+
+ @Override
+ public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) {
+ return chunk.get.getBlock(x, y, z);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y,
+ int z) {
+ return chunk.get.getFullBlock(x, y, z);
+ }
+ };
+ public static final IBlockDelegate GET = new IBlockDelegate() {
+ @Override
+ public boolean setBiome(ChunkHolder chunk, int x, int y, int z,
+ BiomeType biome) {
+ chunk.getOrCreateSet();
+ chunk.delegate = BOTH;
+ return chunk.setBiome(x, y, z, biome);
+ }
+
+ @Override
+ public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
+ BlockStateHolder block) {
+ chunk.getOrCreateSet();
+ chunk.delegate = BOTH;
+ return chunk.setBlock(x, y, z, block);
+ }
+
+ @Override
+ public BiomeType getBiome(ChunkHolder chunk, int x, int z) {
+ return chunk.get.getBiomeType(x, z);
+ }
+
+ @Override
+ public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) {
+ return chunk.get.getBlock(x, y, z);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y,
+ int z) {
+ return chunk.get.getFullBlock(x, y, z);
+ }
+ };
+ public static final IBlockDelegate SET = new IBlockDelegate() {
+ @Override
+ public boolean setBiome(ChunkHolder chunk, int x, int y, int z,
+ BiomeType biome) {
+ return chunk.set.setBiome(x, y, z, biome);
+ }
+
+ @Override
+ public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
+ BlockStateHolder block) {
+ return chunk.set.setBlock(x, y, z, block);
+ }
+
+ @Override
+ public BiomeType getBiome(ChunkHolder chunk, int x, int z) {
+ chunk.getOrCreateGet();
+ chunk.delegate = BOTH;
+ return chunk.getBiomeType(x, z);
+ }
+
+ @Override
+ public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) {
+ chunk.getOrCreateGet();
+ chunk.delegate = BOTH;
+ return chunk.getBlock(x, y, z);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y,
+ int z) {
+ chunk.getOrCreateGet();
+ chunk.delegate = BOTH;
+ return chunk.getFullBlock(x, y, z);
+ }
+ };
+ public static final IBlockDelegate NULL = new IBlockDelegate() {
+ @Override
+ public boolean setBiome(ChunkHolder chunk, int x, int y, int z,
+ BiomeType biome) {
+ chunk.getOrCreateSet();
+ chunk.delegate = SET;
+ return chunk.setBiome(x, y, z, biome);
+ }
+
+ @Override
+ public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
+ BlockStateHolder block) {
+ chunk.getOrCreateSet();
+ chunk.delegate = SET;
+ return chunk.setBlock(x, y, z, block);
+ }
+
+ @Override
+ public BiomeType getBiome(ChunkHolder chunk, int x, int z) {
+ chunk.getOrCreateGet();
+ chunk.delegate = GET;
+ return chunk.getBiomeType(x, z);
+ }
+
+ @Override
+ public BlockState getBlock(ChunkHolder chunk, int x, int y, int z) {
+ chunk.getOrCreateGet();
+ chunk.delegate = GET;
+ return chunk.getBlock(x, y, z);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y,
+ int z) {
+ chunk.getOrCreateGet();
+ chunk.delegate = GET;
+ return chunk.getFullBlock(x, y, z);
+ }
+ };
private IChunkGet get;
private IChunkSet set;
private IBlockDelegate delegate;
@@ -35,7 +171,7 @@ public abstract class ChunkHolder implements IChunk, Supplier {
this.delegate = NULL;
}
- public ChunkHolder(final IBlockDelegate delegate) {
+ public ChunkHolder(IBlockDelegate delegate) {
this.delegate = delegate;
}
@@ -46,7 +182,8 @@ public abstract class ChunkHolder implements IChunk, Supplier {
@Override
public CompoundTag getTag(int x, int y, int z) {
- return delegate.getFullBlock(this, x, y, z).getNbtData(); // TODO NOT IMPLEMENTED (add getTag delegate)
+ return delegate.getFullBlock(this, x, y, z)
+ .getNbtData(); // TODO NOT IMPLEMENTED (add getTag delegate)
}
@Override
@@ -55,7 +192,7 @@ public abstract class ChunkHolder implements IChunk, Supplier {
}
@Override
- public void filterBlocks(final Filter filter, ChunkFilterBlock block, @Nullable Region region) {
+ public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
final IChunkGet get = getOrCreateGet();
final IChunkSet set = getOrCreateSet();
try {
@@ -64,7 +201,9 @@ public abstract class ChunkHolder implements IChunk, Supplier {
} else {
block = block.init(chunkX, chunkZ, get);
for (int layer = 0; layer < 16; layer++) {
- if (!get.hasSection(layer) || !filter.appliesLayer(this, layer)) continue;
+ if (!get.hasSection(layer) || !filter.appliesLayer(this, layer)) {
+ continue;
+ }
block.init(get, set, layer);
block.filter(filter);
}
@@ -75,7 +214,7 @@ public abstract class ChunkHolder implements IChunk, Supplier {
}
@Override
- public boolean trim(final boolean aggressive) {
+ public boolean trim(boolean aggressive) {
if (set != null) {
final boolean result = set.trim(aggressive);
if (result) {
@@ -104,12 +243,16 @@ public abstract class ChunkHolder implements IChunk, Supplier {
}
public final IChunkGet getOrCreateGet() {
- if (get == null) get = newGet();
+ if (get == null) {
+ get = newGet();
+ }
return get;
}
public final IChunkSet getOrCreateSet() {
- if (set == null) set = set();
+ if (set == null) {
+ set = set();
+ }
return set;
}
@@ -128,7 +271,7 @@ public abstract class ChunkHolder implements IChunk, Supplier {
}
@Override
- public void init(final IQueueExtent extent, final int chunkX, final int chunkZ) {
+ public void init(IQueueExtent extent, int chunkX, int chunkZ) {
this.extent = extent;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
@@ -156,167 +299,42 @@ public abstract class ChunkHolder implements IChunk, Supplier {
}
@Override
- public boolean setBiome(final int x, final int y, final int z, final BiomeType biome) {
+ public boolean setBiome(int x, int y, int z, BiomeType biome) {
return delegate.setBiome(this, x, y, z, biome);
}
@Override
- public boolean setBlock(final int x, final int y, final int z, final BlockStateHolder block) {
+ public boolean setBlock(int x, int y, int z, BlockStateHolder block) {
return delegate.setBlock(this, x, y, z, block);
}
@Override
- public BiomeType getBiomeType(final int x, final int z) {
+ public BiomeType getBiomeType(int x, int z) {
return delegate.getBiome(this, x, z);
}
@Override
- public BlockState getBlock(final int x, final int y, final int z) {
+ public BlockState getBlock(int x, int y, int z) {
return delegate.getBlock(this, x, y, z);
}
@Override
- public BaseBlock getFullBlock(final int x, final int y, final int z) {
+ public BaseBlock getFullBlock(int x, int y, int z) {
return delegate.getFullBlock(this, x, y, z);
}
public interface IBlockDelegate {
- boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome);
- boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder holder);
+ boolean setBiome(ChunkHolder chunk, int x, int y, int z,
+ BiomeType biome);
- BiomeType getBiome(final ChunkHolder chunk, final int x, final int z);
+ boolean setBlock(ChunkHolder chunk, int x, int y, int z,
+ BlockStateHolder holder);
- BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z);
+ BiomeType getBiome(ChunkHolder chunk, int x, int z);
- BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z);
+ BlockState getBlock(ChunkHolder chunk, int x, int y, int z);
+
+ BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, int z);
}
-
- public static final IBlockDelegate NULL = new IBlockDelegate() {
- @Override
- public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) {
- chunk.getOrCreateSet();
- chunk.delegate = SET;
- return chunk.setBiome(x, y, z, biome);
- }
-
- @Override
- public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) {
- chunk.getOrCreateSet();
- chunk.delegate = SET;
- return chunk.setBlock(x, y, z, block);
- }
-
- @Override
- public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) {
- chunk.getOrCreateGet();
- chunk.delegate = GET;
- return chunk.getBiomeType(x, z);
- }
-
- @Override
- public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- chunk.getOrCreateGet();
- chunk.delegate = GET;
- return chunk.getBlock(x, y, z);
- }
-
- @Override
- public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- chunk.getOrCreateGet();
- chunk.delegate = GET;
- return chunk.getFullBlock(x, y, z);
- }
- };
-
- public static final IBlockDelegate GET = new IBlockDelegate() {
- @Override
- public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) {
- chunk.getOrCreateSet();
- chunk.delegate = BOTH;
- return chunk.setBiome(x, y, z, biome);
- }
-
- @Override
- public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) {
- chunk.getOrCreateSet();
- chunk.delegate = BOTH;
- return chunk.setBlock(x, y, z, block);
- }
-
- @Override
- public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) {
- return chunk.get.getBiomeType(x, z);
- }
-
- @Override
- public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- return chunk.get.getBlock(x, y, z);
- }
-
- @Override
- public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- return chunk.get.getFullBlock(x, y, z);
- }
- };
-
- public static final IBlockDelegate SET = new IBlockDelegate() {
- @Override
- public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) {
- return chunk.set.setBiome(x, y, z, biome);
- }
-
- @Override
- public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) {
- return chunk.set.setBlock(x, y, z, block);
- }
-
- @Override
- public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) {
- chunk.getOrCreateGet();
- chunk.delegate = BOTH;
- return chunk.getBiomeType(x, z);
- }
-
- @Override
- public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- chunk.getOrCreateGet();
- chunk.delegate = BOTH;
- return chunk.getBlock(x, y, z);
- }
-
- @Override
- public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- chunk.getOrCreateGet();
- chunk.delegate = BOTH;
- return chunk.getFullBlock(x, y, z);
- }
- };
-
- public static final IBlockDelegate BOTH = new IBlockDelegate() {
- @Override
- public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) {
- return chunk.set.setBiome(x, y, z, biome);
- }
-
- @Override
- public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) {
- return chunk.set.setBlock(x, y, z, block);
- }
-
- @Override
- public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) {
- return chunk.get.getBiomeType(x, z);
- }
-
- @Override
- public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- return chunk.get.getBlock(x, y, z);
- }
-
- @Override
- public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) {
- return chunk.get.getFullBlock(x, y, z);
- }
- };
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java
index 88c6269db..6c285b320 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java
@@ -1,33 +1,27 @@
package com.boydti.fawe.beta.implementation.holder;
-import com.boydti.fawe.beta.ChunkFilterBlock;
-import com.boydti.fawe.beta.Filter;
-import com.boydti.fawe.beta.FilterBlock;
-import com.boydti.fawe.beta.FilterBlockMask;
-import com.boydti.fawe.beta.Flood;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IDelegateChunk;
-import com.sk89q.worldedit.math.MutableBlockVector3;
-import com.sk89q.worldedit.regions.Region;
-
-import javax.annotation.Nullable;
/**
* Implementation of IDelegateChunk
+ *
* @param
*/
public class DelegateChunk implements IDelegateChunk {
+
private T parent;
- public DelegateChunk(final T parent) {
+ public DelegateChunk(T parent) {
this.parent = parent;
}
+ @Override
public final T getParent() {
return parent;
}
- public final void setParent(final T parent) {
+ public final void setParent(T parent) {
this.parent = parent;
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java
index ca599ae94..cc0d59fdb 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java
@@ -1,22 +1,24 @@
package com.boydti.fawe.beta.implementation.holder;
-import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.IChunk;
+import com.boydti.fawe.beta.IQueueExtent;
/**
- * Used by {@link ReferenceChunk} to allow the chunk to be garbage collected
- * - When the object is finalized, add it to the queue
+ * Used by {@link ReferenceChunk} to allow the chunk to be garbage collected. - When the object is
+ * finalized, add it to the queue
*/
public class FinalizedChunk extends DelegateChunk {
+
private final IQueueExtent queueExtent;
- public FinalizedChunk(final IChunk parent, final IQueueExtent queueExtent) {
+ public FinalizedChunk(IChunk parent, IQueueExtent queueExtent) {
super(parent);
this.queueExtent = queueExtent;
}
/**
* Submit the chunk to the queue
+ *
* @throws Throwable
*/
@Override
@@ -28,4 +30,4 @@ public class FinalizedChunk extends DelegateChunk {
}
super.finalize();
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java
index cb88a839e..4e5c799c8 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java
@@ -3,26 +3,26 @@ package com.boydti.fawe.beta.implementation.holder;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IDelegateChunk;
import com.boydti.fawe.beta.IQueueExtent;
-
import java.lang.ref.Reference;
/**
- * An IChunk may be wrapped by a ReferenceChunk if there is low memory
- * A reference chunk stores a reference (for garbage collection purposes)
- * - If it is garbage collected, the {@link FinalizedChunk} logic is run
+ * An {@link IChunk} may be wrapped by a ReferenceChunk if there is low memory. This class stores a
+ * reference for garbage collection purposes. If it cleaned by garbage collection, the {@link
+ * FinalizedChunk} logic is run.
*/
public abstract class ReferenceChunk implements IDelegateChunk {
- private final Reference ref;
- public ReferenceChunk(final IChunk parent, final IQueueExtent queueExtent) {
- this.ref = toRef(new FinalizedChunk(parent, queueExtent));
+ private final Reference reference;
+
+ public ReferenceChunk(IChunk parent, IQueueExtent queueExtent) {
+ this.reference = toReference(new FinalizedChunk(parent, queueExtent));
}
- protected abstract Reference toRef(FinalizedChunk parent);
+ protected abstract Reference toReference(FinalizedChunk parent);
@Override
public IChunk getParent() {
- final FinalizedChunk finalized = ref.get();
+ final FinalizedChunk finalized = reference.get();
return finalized != null ? finalized.getParent() : null;
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java
index 361b7083d..29ea78386 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java
@@ -2,7 +2,6 @@ package com.boydti.fawe.beta.implementation.holder;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IQueueExtent;
-
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
@@ -11,12 +10,12 @@ import java.lang.ref.SoftReference;
*/
public class SoftChunk extends ReferenceChunk {
- public SoftChunk(final IChunk parent, final IQueueExtent queueExtent) {
+ public SoftChunk(IChunk parent, IQueueExtent queueExtent) {
super(parent, queueExtent);
}
@Override
- protected Reference toRef(final FinalizedChunk parent) {
+ protected Reference toReference(FinalizedChunk parent) {
return new SoftReference<>(parent);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java
index 46b5fa8f6..12394302d 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java
@@ -2,21 +2,20 @@ package com.boydti.fawe.beta.implementation.holder;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IQueueExtent;
-import com.sk89q.jnbt.CompoundTag;
-
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
/**
- * Weak reference implementation of {@link ReferenceChunk}
+ * A {@link ReferenceChunk} using {@link WeakReference} to hold the chunk.
*/
public class WeakChunk extends ReferenceChunk {
- public WeakChunk(final IChunk parent, final IQueueExtent queueExtent) {
+
+ public WeakChunk(IChunk parent, IQueueExtent queueExtent) {
super(parent, queueExtent);
}
@Override
- protected Reference toRef(final FinalizedChunk parent) {
+ protected Reference toReference(FinalizedChunk parent) {
return new WeakReference<>(parent);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java
index 374005175..a536d14aa 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java
@@ -4,21 +4,13 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.configuration.MemorySection;
import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.boydti.fawe.object.FawePlayer;
-import com.boydti.fawe.object.RunnableVal3;
-import com.boydti.fawe.util.StringMan;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.extension.platform.Actor;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
@@ -28,10 +20,9 @@ public enum BBC {
* Things to note about this class:
* Can use multiple arguments %s, %s1, %s2, %s3 etc
*/
- PREFIX("(FAWE)", "Info"),
FILE_DELETED("%s0 has been deleted.", "Info"),
SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "Info"),
- LIGHTING_PROPOGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"),
+ LIGHTING_PROPAGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"),
UPDATED_LIGHTING_SELECTION("Lighting has been updated in %s0 chunks. (It may take a second for the packets to send)", "Info"),
SET_REGION("Selection set to your current allowed region", "Info"),
WORLDEDIT_COMMAND_LIMIT("Please wait until your current action completes", "Info"),
@@ -304,7 +295,7 @@ public enum BBC {
SEL_CUBOID("Cuboid: left click for point 1, right click for point 2", "Selection"),
SEL_CUBOID_EXTEND("Cuboid: left click for a starting point, right click to extend", "Selection"),
SEL_2D_POLYGON("2D polygon selector: Left/right click to add a point.", "Selection"),
- SEL_ELLIPSIOD("Ellipsoid selector: left click=center, right click to extend", "Selection"),
+ SAL_ELLIPSOID("Ellipsoid selector: left click=center, right click to extend", "Selection"),
SEL_SPHERE("Sphere selector: left click=center, right click to set radius", "Selection"),
SEL_CYLINDRICAL("Cylindrical selector: Left click=center, right click to extend.", "Selection"),
SEL_MAX("%s0 points maximum.", "Selection"),
@@ -365,16 +356,6 @@ public enum BBC {
TIP_BIOME_PATTERN("Tip: The #biome[forest] pattern can be used in any command", "Tips"),
TIP_BIOME_MASK("Tip: Restrict to a biome with the `$jungle` mask", "Tips"),;
-
- private static final HashMap replacements = new HashMap<>();
- static {
- for (char letter : "1234567890abcdefklmnor".toCharArray()) {
- replacements.put("&" + letter, "\u00a7" + letter);
- }
- replacements.put("\\\\n", "\n");
- replacements.put("\\n", "\n");
- replacements.put("&-", "\n");
- }
/**
* Translated
*/
@@ -460,7 +441,6 @@ public enum BBC {
changed = true;
yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), caption.defaultMessage);
}
- caption.translatedMessage = StringMan.replaceFromMap(caption.translatedMessage, replacements);
}
if (changed) {
yml.save(file);
@@ -483,15 +463,6 @@ public enum BBC {
return toString().length();
}
- public static String color(String string) {
- return StringMan.replaceFromMap(string, replacements);
- }
-
- public static String stripColor(String string) {
-
- return StringMan.removeFromSet(string, replacements.values());
- }
-
public String s() {
return this.translatedMessage;
}
@@ -519,17 +490,13 @@ public enum BBC {
try {
Method method = actor.getClass().getMethod("print", String.class);
method.setAccessible(true);
- method.invoke(actor, (PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args));
+ method.invoke(actor, this.format(args));
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
- public static String getPrefix() {
- return PREFIX.isEmpty() ? "" : PREFIX.s() + " ";
- }
-
public void send(FawePlayer> player, Object... args) {
if (isEmpty()) {
return;
@@ -537,7 +504,7 @@ public enum BBC {
if (player == null) {
Fawe.debug(this.format(args));
} else {
- player.sendMessage((PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args));
+ player.sendMessage(this.format(args));
}
}
public void send(Actor player, Object... args) {
@@ -551,189 +518,4 @@ public enum BBC {
}
}
- public static char getCode(String name) {
- switch (name) {
- case "BLACK":
- return '0';
- case "DARK_BLUE":
- return '1';
- case "DARK_GREEN":
- return '2';
- case "DARK_AQUA":
- return '3';
- case "DARK_RED":
- return '4';
- case "DARK_PURPLE":
- return '5';
- case "GOLD":
- return '6';
- case "GRAY":
- return '7';
- case "DARK_GRAY":
- return '8';
- case "BLUE":
- return '9';
- case "GREEN":
- return 'a';
- case "AQUA":
- return 'b';
- case "RED":
- return 'c';
- case "LIGHT_PURPLE":
- return 'd';
- case "YELLOW":
- return 'e';
- case "WHITE":
- return 'f';
- case "OBFUSCATED":
- return 'k';
- case "BOLD":
- return 'l';
- case "STRIKETHROUGH":
- return 'm';
- case "UNDERLINE":
- return 'n';
- case "ITALIC":
- return 'o';
- default:
- case "RESET":
- return 'r';
- }
- }
-
- public static String getColorName(char code) {
- switch (code) {
- case '0':
- return "BLACK";
- case '1':
- return "DARK_BLUE";
- case '2':
- return "DARK_GREEN";
- case '3':
- return "DARK_AQUA";
- case '4':
- return "DARK_RED";
- case '5':
- return "DARK_PURPLE";
- case '6':
- return "GOLD";
- case '7':
- return "GRAY";
- case '8':
- return "DARK_GRAY";
- case '9':
- return "BLUE";
- case 'a':
- return "GREEN";
- case 'b':
- return "AQUA";
- case 'c':
- return "RED";
- case 'd':
- return "LIGHT_PURPLE";
- case 'e':
- return "YELLOW";
- case 'f':
- return "WHITE";
- case 'k':
- return "OBFUSCATED";
- case 'l':
- return "BOLD";
- case 'm':
- return "STRIKETHROUGH";
- case 'n':
- return "UNDERLINE";
- case 'o':
- return "ITALIC";
- case 'r':
- return "RESET";
- default:
- return "GRAY";
- }
- }
-
- private static Object[] append(StringBuilder builder, Map obj, String color, Map properties) {
- Object[] style = new Object[] { color, properties };
- for (Map.Entry entry : obj.entrySet()) {
- switch (entry.getKey()) {
- case "text":
- String text = (String) entry.getValue();
- String newColor = (String) obj.get("color");
- String newBold = (String) obj.get("bold");
- int index = builder.length();
- if (!Objects.equals(color, newColor)) {
- style[0] = newColor;
- char code = BBC.getCode(newColor.toUpperCase(Locale.ROOT));
- builder.append('\u00A7').append(code);
- }
- for (Map.Entry entry2 : obj.entrySet()) {
- if (StringMan.isEqualIgnoreCaseToAny(entry2.getKey(), "bold", "italic", "underlined", "strikethrough", "obfuscated")) {
- boolean newValue = Boolean.parseBoolean((String) entry2.getValue());
- if (properties.put(entry2.getKey(), newValue) != newValue) {
- if (newValue) {
- char code = BBC.getCode(entry2.getKey().toUpperCase(Locale.ROOT));
- builder.append('\u00A7').append(code);
- } else {
- builder.insert(index, '\u00A7').append('r');
- if (Objects.equals(color, newColor) && newColor != null) {
- builder.append('\u00A7').append(BBC.getCode(newColor.toUpperCase(Locale.ROOT)));
- }
- }
- }
- }
- }
- builder.append(text);
- break;
- case "extra":
- List