diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 88b4bdb3e..a9434fd67 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -56,8 +56,7 @@ dependencies { "implementation"("org.inventivetalent:mapmanager:1.7.3-SNAPSHOT") { isTransitive = false } "implementation"("org.inventivetalent:mapmanager:1.7.3-SNAPSHOT") { isTransitive = false } - "implementation"("com.massivecraft:factions:2.8.0") { isTransitive = false } - "implementation"("com.drtshock:factions:1.6.9.5") { isTransitive = false } + "implementation"("com.massivecraft:Factions:1.6.9.5-U0.2.1-SNAPSHOT") { isTransitive = false } "implementation"("com.github.TechFortress:GriefPrevention:16.12.0") { isTransitive = false } "implementation"("com.massivecraft:mcore:7.0.1") { isTransitive = false } "implementation"("net.jzx7:regios:5.9.9") { isTransitive = false } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 1bc5ed32d..cc6c94690 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -13,7 +13,6 @@ import com.boydti.fawe.bukkit.listener.ChunkListener_8; import com.boydti.fawe.bukkit.listener.ChunkListener_9; import com.boydti.fawe.bukkit.listener.RenderListener; import com.boydti.fawe.bukkit.regions.ASkyBlockHook; -import com.boydti.fawe.bukkit.regions.FactionsFeature; import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature; import com.boydti.fawe.bukkit.regions.FreeBuildRegion; import com.boydti.fawe.bukkit.regions.GriefPreventionFeature; @@ -269,14 +268,9 @@ public class FaweBukkit implements IFawe, Listener { final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions"); if (factionsPlugin != null && factionsPlugin.isEnabled()) { try { - managers.add(new FactionsFeature(factionsPlugin)); - log.debug("Attempting to use plugin 'Factions'"); - } catch (Throwable e) { - try { - managers.add(new FactionsUUIDFeature(factionsPlugin, this)); - log.debug("Attempting to use plugin 'FactionsUUID'"); - } catch (Throwable ignored) { - } + managers.add(new FactionsUUIDFeature(factionsPlugin, this)); + log.debug("Attempting to use plugin 'FactionsUUID'"); + } catch (Throwable ignored) { } } final Plugin residencePlugin = Bukkit.getServer().getPluginManager().getPlugin("Residence"); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitGetBlocks_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitGetBlocks_1_13.java index cae2c9e2f..93e480e21 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitGetBlocks_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitGetBlocks_1_13.java @@ -94,7 +94,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks { } @Override - public CompoundTag getTag(int x, int y, int z) { + public CompoundTag getTile(int x, int y, int z) { TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4))); if (tileEntity == null) { return null; 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 73cf2c62f..47946ee01 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 @@ -101,7 +101,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { } @Override - public CompoundTag getTag(int x, int y, int z) { + public CompoundTag getTile(int x, int y, int z) { TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4))); if (tileEntity == null) { return null; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java deleted file mode 100644 index 042d315bf..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.boydti.fawe.bukkit.regions; - -import com.boydti.fawe.regions.FaweMask; -import com.massivecraft.factions.entity.BoardColl; -import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.ps.PS; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.math.BlockVector3; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; - -public class FactionsFeature extends BukkitMaskManager implements Listener { - - public FactionsFeature(final Plugin factionsPlugin) { - super(factionsPlugin.getName()); - } - - @Override - public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) { - final Player player = BukkitAdapter.adapt(p); - final Location loc = player.getLocation(); - final PS ps = PS.valueOf(loc); - final Faction fac = BoardColl.get().getFactionAt(ps); - if (fac != null) { - if (type == MaskType.OWNER) { - MPlayer leader = fac.getLeader(); - if (leader != null && p.getUniqueId().equals(leader.getUuid())) { - final Chunk chunk = loc.getChunk(); - final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16); - final BlockVector3 pos2 = BlockVector3 - .at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new FaweMask(pos1, pos2); - } - } else if (fac.getOnlinePlayers().contains(player)) { - if (!fac.getComparisonName().equals("wilderness")) { - final Chunk chunk = loc.getChunk(); - final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16); - final BlockVector3 pos2 = BlockVector3.at((chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new FaweMask(pos1, pos2); - } - } - } - return null; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index 70ec97f17..5084da323 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -4,6 +4,10 @@ import static com.google.common.base.Preconditions.checkNotNull; import static org.slf4j.LoggerFactory.getLogger; import com.boydti.fawe.beta.Trimable; +import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.BitArray4096; @@ -48,6 +52,7 @@ 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 { @@ -194,6 +199,24 @@ public enum FaweCache implements Trimable { 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 */ 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 6e3066c1b..70fca8875 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 @@ -51,7 +51,7 @@ public class CombinedBlocks implements IBlocks { public char[] load(int layer) { if (primary.hasSection(layer)) { char[] blocks = primary.load(layer); - if (secondary.hasSection(layer)) { + if (secondary.hasSection(layer) && primary != secondary) { int i = 0; for (; i < 4096; i++) { if (blocks[i] == 0) { @@ -75,42 +75,55 @@ public class CombinedBlocks implements IBlocks { @Override public BlockState getBlock(int x, int y, int z) { BlockState block = primary.getBlock(x, y, z); - if (block == null) { + if (block.getBlockType() == BlockTypes.__RESERVED__) { return secondary.getBlock(x, y, z); } - return BlockTypes.__RESERVED__.getDefaultState(); + return block; } @Override public Map getTiles() { Map tiles = primary.getTiles(); - if (tiles.isEmpty()) { - return secondary.getTiles(); - } - Map otherTiles = secondary.getTiles(); - if (!otherTiles.isEmpty()) { - HashMap copy = null; - for (Map.Entry entry : otherTiles.entrySet()) { - BlockVector3 pos = entry.getKey(); - BlockState block = primary.getBlock(pos.getX(), pos.getY(), pos.getZ()); - if (block.getBlockType() == BlockTypes.__RESERVED__) { - if (copy == null) copy = new HashMap<>(tiles); - copy.put(pos, entry.getValue()); - } + if (primary != secondary) { + if (tiles.isEmpty()) { + return secondary.getTiles(); + } + Map otherTiles = secondary.getTiles(); + if (!otherTiles.isEmpty()) { + HashMap copy = null; + for (Map.Entry entry : otherTiles.entrySet()) { + BlockVector3 pos = entry.getKey(); + BlockState block = primary.getBlock(pos.getX(), pos.getY(), pos.getZ()); + if (block.getBlockType() == BlockTypes.__RESERVED__) { + if (copy == null) copy = new HashMap<>(tiles); + copy.put(pos, entry.getValue()); + } + } + if (copy != null) return copy; } - if (copy != null) return copy; } return tiles; } + @Override + public CompoundTag getTile(int x, int y, int z) { + CompoundTag tile = primary.getTile(x, y, z); + if (tile != null) { + return tile; + } + return secondary.getTile(x, y, z); + } + @Override public Set getEntities() { - Set ents1 = primary.getEntities(); - Set ents2 = secondary.getEntities(); - if (ents1.isEmpty()) return ents2; - if (ents2.isEmpty()) return ents1; - HashSet joined = new HashSet<>(ents1); - joined.addAll(ents2); + Set joined = primary.getEntities(); + if (primary != secondary) { + Set ents2 = secondary.getEntities(); + if (joined.isEmpty()) return ents2; + if (ents2.isEmpty()) return joined; + joined = new HashSet<>(joined); + joined.addAll(ents2); + } return joined; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java index 44eea1977..97870cc2a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java @@ -1,5 +1,6 @@ package com.boydti.fawe.beta; +import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.regions.Region; import javax.annotation.Nullable; 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 910d286dc..8bd9b9e33 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java @@ -1,6 +1,9 @@ package com.boydti.fawe.beta; import com.boydti.fawe.FaweCache; +import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor; import com.sk89q.jnbt.CompoundTag; 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 2aa9bd34a..ca2202226 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 @@ -31,6 +31,8 @@ public interface IBlocks extends Trimable { Map getTiles(); + CompoundTag getTile(int x, int y, int z); + Set getEntities(); BiomeType getBiomeType(int x, int z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java index 97451fdda..f9391368d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java @@ -90,7 +90,7 @@ public interface IChunk extends Trimable, IChunkGet, IChunkSet { BaseBlock getFullBlock(int x, int y, int z); @Override - CompoundTag getTag(int x, int y, int z); + CompoundTag getTile(int x, int y, int z); @Override default IChunk reset() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java index 073f660c2..97c6dd008 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java @@ -26,9 +26,6 @@ public interface IChunkGet extends IBlocks, Trimable, InputExtent, ITileInput { @Override BlockState getBlock(int x, int y, int z); - @Override - CompoundTag getTag(int x, int y, int z); - @Override Map getTiles(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java index 02b431a15..30dddbf19 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java @@ -54,6 +54,11 @@ public interface IDelegateChunk extends IQueueChunk { // getParent().flood(flood, mask, block); // } + @Override + default CompoundTag getTile(int x, int y, int z) { + return getParent().getTile(x, y, z); + } + @Override default boolean setTile(int x, int y, int z, CompoundTag tag) { return getParent().setTile(x, y, z, tag); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ITileInput.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ITileInput.java index 99bf4644e..4708fbd45 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ITileInput.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ITileInput.java @@ -3,5 +3,5 @@ package com.boydti.fawe.beta; import com.sk89q.jnbt.CompoundTag; public interface ITileInput { - CompoundTag getTag(int x, int y, int z); + CompoundTag getTile(int x, int y, int z); } 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 2f237324b..a3abe7806 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 @@ -12,6 +12,7 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.Arrays; +import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -26,6 +27,11 @@ public class BitSetBlocks implements IChunkSet { this.blockState = blockState; } + @Override + public boolean hasSection(int layer) { + return row.rows[layer] != MemBlockSet.NULL_ROW_Y; + } + @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { @@ -122,12 +128,17 @@ public class BitSetBlocks implements IChunkSet { @Override public Map getTiles() { + return Collections.emptyMap(); + } + + @Override + public CompoundTag getTile(int x, int y, int z) { return null; } @Override public Set getEntities() { - return null; + return Collections.emptySet(); } @Override @@ -135,11 +146,6 @@ public class BitSetBlocks implements IChunkSet { return null; } - @Override - public boolean hasSection(int layer) { - return false; - } - @Override public IChunkSet reset() { row.reset(); 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 353f22cb7..853b6d15f 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 @@ -55,6 +55,11 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { return tiles == null ? Collections.emptyMap() : tiles; } + @Override + public CompoundTag getTile(int x, int y, int z) { + return tiles == null ? null : tiles.get(x, y, z); + } + @Override public Set getEntities() { return entities == null ? Collections.emptySet() : entities; 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 0e0c81100..09d4f1b38 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 @@ -42,7 +42,7 @@ public class FallbackChunkGet implements IChunkGet { } @Override - public CompoundTag getTag(int x, int y, int z) { + public CompoundTag getTile(int x, int y, int z) { return extent.getFullBlock(bx + x, y, bz + z).getNbtData(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java index ffdb8ecc8..49ad3432b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java @@ -37,13 +37,13 @@ public enum NullChunkGet implements IChunkGet { } @Override - public CompoundTag getTag(int x, int y, int z) { - return null; + public Map getTiles() { + return Collections.emptyMap(); } @Override - public Map getTiles() { - return Collections.emptyMap(); + public CompoundTag getTile(int x, int y, int z) { + return null; } @Override 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 2aea39ee4..77eea1556 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 @@ -1,8 +1,6 @@ package com.boydti.fawe.beta.implementation.chunk; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.CombinedBlocks; -import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IQueueChunk; import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; @@ -65,6 +63,11 @@ public class ChunkHolder> implements IQueueChunk { return delegate.set(this).setTile(x, y, z, tag); } + @Override + public CompoundTag getTile(int x, int y, int z) { + return delegate.set(this).getTile(x, y, z); + } + @Override public void setEntity(CompoundTag tag) { delegate.set(this).setEntity(tag); @@ -316,18 +319,7 @@ public class ChunkHolder> implements IQueueChunk { final IChunkGet get = getOrCreateGet(); final IChunkSet set = getOrCreateSet(); try { - block = block.init(chunkX, chunkZ, get); - if (region != null) { - region.filter(this, filter, block, get, set, full); - } else { - for (int layer = 0; layer < 16; layer++) { - if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(this, layer)) { - continue; - } - block.init(get, set, layer); - block.filter(filter); - } - } + block.filter(this, get, set, filter, region, full); } finally { filter.finishChunk(this); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java index 108c55fc4..9932618b1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java @@ -122,6 +122,11 @@ public enum NullChunk implements IQueueChunk { return Collections.emptyMap(); } + @Override + public CompoundTag getTile(int x, int y, int z) { + return null; + } + @Override public Set getEntities() { return Collections.emptySet(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SimpleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractExtentFilterBlock.java similarity index 61% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SimpleFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractExtentFilterBlock.java index a709f337a..7f1b74873 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SimpleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractExtentFilterBlock.java @@ -2,11 +2,14 @@ package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.worldedit.extent.Extent; -public abstract class SimpleFilterBlock extends FilterBlock { +/** + * Filter block with an extent + */ +public abstract class AbstractExtentFilterBlock extends FilterBlock { private final Extent extent; - public SimpleFilterBlock(Extent extent) { + public AbstractExtentFilterBlock(Extent extent) { this.extent = extent; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java index 851a4ec92..f73f02bf8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java @@ -8,12 +8,11 @@ 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 com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; import javax.annotation.Nullable; -public class ArrayFilterBlock extends SimpleFilterBlock { +public class ArrayFilterBlock extends AbstractExtentFilterBlock { private final char[] blocks; private final byte[] heights; @@ -22,6 +21,7 @@ public class ArrayFilterBlock extends SimpleFilterBlock { private int x, z, index; private char ordinal; + // TODO use in CFI public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length, int yOffset) { super(extent); 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 63bb9ecc4..c3eeb4eb3 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 @@ -6,9 +6,9 @@ import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.FilterBlockMask; import com.boydti.fawe.beta.Flood; +import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; @@ -38,6 +38,7 @@ public class CharFilterBlock extends ChunkFilterBlock { block.initSet().set(block, value); } }; + private CharGetBlocks get; private IChunkSet set; private char[] getArr; @@ -47,13 +48,12 @@ public class CharFilterBlock extends ChunkFilterBlock { // local private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ; - public CharFilterBlock(IQueueExtent queueExtent) { - super(queueExtent); + public CharFilterBlock(Extent extent) { + super(extent); } @Override - public final ChunkFilterBlock init(int chunkX, int chunkZ, IChunkGet chunk) { - this.get = (CharGetBlocks) chunk; + public final ChunkFilterBlock initChunk(int chunkX, int chunkZ) { this.chunkX = chunkX; this.chunkZ = chunkZ; this.xx = chunkX << 4; @@ -61,12 +61,34 @@ public class CharFilterBlock extends ChunkFilterBlock { return this; } + @Override + public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) { + this.get = (CharGetBlocks) iget; + this.layer = layer; + final IBlocks get = (CharGetBlocks) iget; + if (!get.hasSection(layer)) { + getArr = FaweCache.IMP.EMPTY_CHAR_4096; + } else { + getArr = get.load(layer); + } + this.set = iset; + if (set.hasSection(layer)) { + setArr = set.load(layer); + delegate = FULL; + } else { + delegate = NULL; + setArr = null; + } + this.yy = layer << 4; + return this; + } + @Override public void flood(IChunkGet iget, IChunkSet iset, int layer, Flood flood, FilterBlockMask mask) { final int maxDepth = flood.getMaxDepth(); final boolean checkDepth = maxDepth < Character.MAX_VALUE; - if (init(iget, iset, layer) != null) { // TODO replace with hasSection + if (initLayer(iget, iset, layer) != null) { // TODO replace with hasSection while ((index = flood.poll()) != -1) { x = index & 15; z = index >> 4 & 15; @@ -85,27 +107,6 @@ public class CharFilterBlock extends ChunkFilterBlock { } } - @Override - public final ChunkFilterBlock init(IChunkGet iget, IChunkSet iset, int layer) { - this.layer = layer; - final CharGetBlocks get = (CharGetBlocks) iget; - if (!get.hasSection(layer)) { - getArr = FaweCache.IMP.EMPTY_CHAR_4096; - } else { - getArr = get.sections[layer].get(get, layer); - } - this.set = iset; - if (set.hasSection(layer)) { - setArr = set.load(layer); - delegate = FULL; - } else { - delegate = NULL; - setArr = null; - } - this.yy = layer << 4; - return this; - } - @Override public void filter(Filter filter, int x, int y, int z) { this.x = x; @@ -247,7 +248,7 @@ public class CharFilterBlock extends ChunkFilterBlock { final BlockState state = getBlock(); final BlockMaterial material = state.getMaterial(); if (material.hasContainer()) { - final CompoundTag tag = get.getTag(x, y + yy, z); + final CompoundTag tag = get.getTile(x, y + yy, z); return state.toBaseBlock(tag); } return state.toBaseBlock(); @@ -264,7 +265,7 @@ public class CharFilterBlock extends ChunkFilterBlock { @Override public final CompoundTag getNbtData() { - return get.getTag(x, y + yy, z); + return get.getTile(x, y + yy, z); } /* NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1), diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ChunkFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ChunkFilterBlock.java index a254b7f2f..e183c5fc1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ChunkFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ChunkFilterBlock.java @@ -3,34 +3,132 @@ package com.boydti.fawe.beta.implementation.filter.block; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.FilterBlockMask; import com.boydti.fawe.beta.Flood; +import com.boydti.fawe.beta.IBlocks; +import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.regions.Region; -public abstract class ChunkFilterBlock extends SimpleFilterBlock { +/** + * Filter block implementation which uses chunks + * - First call initChunk + * - Then for each layer, call initLayer + * - Then use whatever filter method you want, to iterate over the blocks in that layer + */ +public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock { public ChunkFilterBlock(Extent extent) { super(extent); } - public abstract ChunkFilterBlock init(int chunkX, int chunkZ, IChunkGet chunk); + /** + * Initialize with chunk coordinates + * - The layer must also be initialized + * @param chunkX + * @param chunkZ + * @return + */ + public abstract ChunkFilterBlock initChunk(int chunkX, int chunkZ); - public abstract ChunkFilterBlock init(IChunkGet iget, IChunkSet iset, - int layer); + /** + * Initialize a chunk layer + * - The chunk coordinates must also be initialized first + * @param iget + * @param iset + * @param layer + * @return + */ + public abstract ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer); public abstract void flood(IChunkGet iget, IChunkSet iset, int layer, Flood flood, FilterBlockMask mask); + /** + * filter a single block + * @param filter + * @param x + * @param y + * @param z + */ public abstract void filter(Filter filter, int x, int y, int z); + /** + * Filter a cuboid region + * @param filter + * @param minX + * @param minY + * @param minZ + * @param maxX + * @param maxY + * @param maxZ + */ public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY, int maxZ); + /** + * Filter everything in the layer + * @param filter + */ public abstract void filter(Filter filter); + /** + * Filter everything between y layers + * @param filter + * @param yStart + * @param yEnd + */ public abstract void filter(Filter filter, int yStart, int yEnd); + /** + * Filter with a region + * @param filter + * @param region + */ public abstract void filter(Filter filter, Region region); + + /** + * Filter with a chunk object + * @param chunk + * @param get + * @param set + * @param filter + * @return + */ + public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter) { + initChunk(chunk.getX(), chunk.getZ()); + for (int layer = 0; layer < 16; layer++) { + if (set.hasSection(layer)) { + initLayer(get, set, layer); + filter(filter); + } + } + return set; + } + + /** + * Filter a chunk with a region / filter + * @param chunk + * @param get + * @param set + * @param filter + * @param region + * @param full + * @return + */ + public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter, Region region, boolean full) { + if (region != null) { + region.filter(chunk, filter, this, get, set, full); + } else { + for (int layer = 0; layer < 16; layer++) { + if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) { + continue; + } + initLayer(get, set, layer); + filter(filter); + } + } + return set; + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java index c432a233c..157d04491 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java @@ -12,6 +12,10 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import javax.annotation.Nullable; +/** + * A class representing a block with a position + * - Used for optimized block operations to avoid lookups + */ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEntityBlock { public abstract Extent getExtent(); 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 c89ef3b28..aa724ec05 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 @@ -501,12 +501,8 @@ public class MCAChunk implements IChunk { @Override public BaseBlock getFullBlock(int x, int y, int z) { - return null; - } - - @Override - public CompoundTag getTag(int x, int y, int z) { - return null; + BlockState block = getBlock(x, y, z); + return block.toBaseBlock(this, x, y, z); } @Override @@ -570,18 +566,7 @@ public class MCAChunk implements IChunk { @Override public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) { try { - if (region != null) { - region.filter(this, filter, block, this, this, full); - } else { - block = block.init(chunkX, chunkZ, this); - for (int layer = 0; layer < 16; layer++) { - if ((!full && !this.hasSection(layer)) || !filter.appliesLayer(this, layer)) { - continue; - } - block.init(this, this, layer); - block.filter(filter); - } - } + block.filter(this, this, this, filter, region, full); } finally { filter.finishChunk(this); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java index 07bfbcb45..60317307e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java @@ -47,6 +47,12 @@ public class BlockVector3ChunkMap implements Map, IAdaptedMa return map.put(key, value); } + + public T get(int x, int y, int z) { + short key = MathMan.tripleBlockCoord(x, y, z); + return map.get(key); + } + public T remove(int x, int y, int z) { short key = MathMan.tripleBlockCoord(x, y, z); return map.remove(key); 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 94e3a8524..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 @@ -824,7 +824,7 @@ public final class MemBlockSet extends BlockSet { } public static final class RowZ implements IRow { - private final IRow[] rows; + public final IRow[] rows; public RowZ() { this.rows = new IRow[FaweCache.IMP.CHUNK_LAYERS]; 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 5fc3fbcc2..c2688eab8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -313,7 +313,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { private final List watchdogExtents = new ArrayList<>(2); public void setExtent(AbstractDelegateExtent extent) { - new ExtentTraverser<>(getExtent()).setNext(extent); + new ExtentTraverser(this).setNext(extent); } /** @@ -484,7 +484,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { checkNotNull(transform); wrapped = true; transform.setExtent(getExtent()); - new ExtentTraverser<>(getExtent()).setNext(transform); + new ExtentTraverser(this).setNext(transform); } public @Nullable ResettableExtent getTransform() { @@ -515,7 +515,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { maskingExtent.get().setMask(mask); } else if (mask != Masks.alwaysTrue()) { SourceMaskExtent next = new SourceMaskExtent(getExtent(), mask); - new ExtentTraverser<>(getExtent()).setNext(next); + new ExtentTraverser(this).setNext(next); } } @@ -554,8 +554,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } maskingExtent.get().setMask(mask); } else if (mask != Masks.alwaysTrue()) { - MaskingExtent next = new MaskingExtent(getExtent(), mask); - new ExtentTraverser<>(getExtent()).setNext(next); + addProcessor(new MaskingExtent(getExtent(), mask)); } } 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 5447d96a2..6c5ecc83d 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 @@ -138,9 +138,8 @@ public class RegionCommands { ) @CommandPermissions("worldedit.region.test") @Logging(REGION) - public void test(Player player, EditSession editSession, @Arg(desc = "test") String worldName, BlockVector2 mcaFile) throws WorldEditException { -// file = new File(world, "region" + File.separator) - + public void test(Player player, EditSession editSession, @Arg(desc = "test") double testValue) throws WorldEditException { + player.print("" + testValue); } @Command( 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 57c6bf390..691ca6eee 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 @@ -21,6 +21,20 @@ package com.sk89q.worldedit.extent; import static com.google.common.base.Preconditions.checkNotNull; +import com.boydti.fawe.FaweCache; +import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.IBatchProcessor; +import com.boydti.fawe.beta.IChunk; +import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; +import com.boydti.fawe.util.ExtentTraverser; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector2; @@ -28,12 +42,16 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + /** * Requires that all mutating methods pass a given {@link Mask}. */ -public class MaskingExtent extends AbstractDelegateExtent { +public class MaskingExtent extends AbstractDelegateExtent implements IBatchProcessor, Filter { private Mask mask; + private LoadingCache threadIdToFilter = FaweCache.IMP.createCache(() -> new CharFilterBlock(getExtent())); /** * Create a new instance. @@ -81,6 +99,23 @@ public class MaskingExtent extends AbstractDelegateExtent { return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome); } + @Override + public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) { + ChunkFilterBlock filter = threadIdToFilter.getUnchecked(Thread.currentThread().getId()); + return filter.filter(chunk, get, set, this); + } + @Override + public void applyBlock(FilterBlock block) { + int ordinal = block.getOrdinal(); + if (ordinal != 0 && !mask.test(block)) { + block.setOrdinal(0); + } + } + @Override + public Extent construct(Extent child) { + if (child == getExtent()) return this; + return new MaskingExtent(child, mask); + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java index c4dad4dc1..bce8f1c34 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java @@ -23,6 +23,7 @@ import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; +import java.util.function.Consumer; /** * Tests whether a given vector meets a criteria. @@ -92,12 +93,12 @@ public interface Mask { return new InverseMask(this); } - default Filter toFilter(Runnable run) { + default Filter toFilter(Consumer run) { return new Filter() { @Override public void applyBlock(FilterBlock block) { if (test(block)) { - run.run(); + run.accept(block); } } }; 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 3882bfec3..09f6ad2ee 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 @@ -674,7 +674,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, boolean full) { int chunkX = chunk.getX(); int chunkZ = chunk.getZ(); - block = block.init(chunkX, chunkZ, get); + block = block.initChunk(chunkX, chunkZ); if ((minX + 15) >> 4 <= chunkX && (maxX - 15) >> 4 >= chunkX && (minZ + 15) >> 4 <= chunkZ && (maxZ - 15) >> 4 >= chunkZ) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index 7ce001c5a..544fc560a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -303,6 +303,11 @@ public class EllipsoidRegion extends AbstractRegion { int sectionStart = y1 >> 4; int sectionEnd = y2 >> 4; + for (int layer = sectionStart; layer < sectionEnd; layer++) { + int yStart = Math.max(layer << 4, y1); + int yEnd = Math.min((layer << 4) + 15, y2); + filterSpherePartial(layer, yStart, yEnd, bx, bz, filter, block, get, set); + } } private void filterSpherePartial(int layer, int y1, int y2, int bx, int bz, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set) { @@ -310,7 +315,7 @@ public class EllipsoidRegion extends AbstractRegion { int cy = center.getBlockY(); int cz = center.getBlockZ(); - block.init(get, set, layer); + block.initLayer(get, set, layer); int by = layer << 4; int diffY; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index 98da40cc5..c0a54552e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -208,7 +208,7 @@ public interface Region extends Iterable, Cloneable, IBatchProcess int maxSection = Math.min(15, getMaximumY() >> 4); for (int layer = minSection; layer <= maxSection; layer++) { if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return; - block = block.init(get, set, layer); + block = block.initLayer(get, set, layer); block.filter(filter, this); } } @@ -238,19 +238,19 @@ public interface Region extends Iterable, Cloneable, IBatchProcess default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, boolean full) { if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return; - block = block.init(get, set, layer); + block = block.initLayer(get, set, layer); block.filter(filter); } default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean full) { if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return; - block = block.init(get, set, layer); + block = block.initLayer(get, set, layer); block.filter(filter, minX, minY, minZ, maxX, maxY, maxZ); } default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int yStart, int yEnd, boolean full) { if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return; - block = block.init(get, set, layer); + block = block.initLayer(get, set, layer); block.filter(filter, yStart, yEnd); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java index 1e2b0728e..e448926fc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java @@ -35,7 +35,7 @@ public class WorldEditText { } public static Component format(Component component, Locale locale) { - return CONFIG_HOLDER.replace(WorldEdit.getInstance().getTranslationManager().convertText(component, locale)); + return WorldEdit.getInstance().getTranslationManager().convertText(CONFIG_HOLDER.replace(component), locale); } public static String reduceToText(Component component, Locale locale) { diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 6eb93906b..6633b240e 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -3,13 +3,7 @@ "fawe.error": "&c{0}", "fawe.info": "&7{0}", "fawe.debug": "&3{0}", - - "piston.style.help.text": "Help: {0}", - "piston.style.text.modifier": "TODO modifier: {0}, {1}, {2}", - "piston.style.main.text": "{0}", - "piston.style.part.wrapping": "&8{0}&e{1}&8{2}", - "piston.text.command.prefix": "TODO prefix", - + "fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}", "fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info", @@ -265,7 +259,7 @@ "fawe.cancel.worldedit.cancel.reason.low.memory": "Low memory", "fawe.cancel.worldedit.cancel.reason.max.changes": "Too many blocks changed", "fawe.cancel.worldedit.cancel.reason.max.checks": "Too many block checks", - "fawe.cancel.worldedit.cancel.reason.max.tiles": "Too many blockstates", + "fawe.cancel.worldedit.cancel.reason.max.tiles": "Too many block entities", "fawe.cancel.worldedit.cancel.reason.max.entities": "Too many entities", "fawe.cancel.worldedit.cancel.reason.max.iterations": "Max iterations", "fawe.cancel.worldedit.cancel.reason.outside.level": "Outside world",