From 7a57a5dd8cf357a3b357abce0a420d1e0d96a70f Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 10 Aug 2019 16:01:42 +1000 Subject: [PATCH] minor idk it compiles now --- .../main/java/com/boydti/fawe/FaweAPI.java | 76 +++++------ .../boydti/fawe/beta/DelegateFilterBlock.java | 120 +++++++++++++++++- .../com/boydti/fawe/beta/FilterBlock.java | 7 + .../java/com/boydti/fawe/beta/IChunkSet.java | 2 +- .../com/boydti/fawe/beta/IQueueExtent.java | 3 +- .../boydti/fawe/beta/SingleFilterBlock.java | 1 + .../beta/implementation/DelegateChunkSet.java | 4 +- .../implementation/blocks/BitSetBlocks.java | 32 ++++- .../implementation/blocks/CharSetBlocks.java | 3 +- .../brush/visualization/VisualChunk.java | 47 ------- .../brush/visualization/VisualExtent.java | 4 +- .../cfi/HeightMapMCAGenerator.java | 6 + .../changeset/AbstractDelegateChangeSet.java | 38 ++++-- .../fawe/object/changeset/AnvilHistory.java | 116 ----------------- .../fawe/object/changeset/CFIChangeSet.java | 2 +- .../fawe/object/clipboard/EmptyClipboard.java | 6 + .../fawe/object/collection/MemBlockSet.java | 8 ++ .../boydti/fawe/object/extent/NullExtent.java | 5 - .../general/plot/FaweLocalBlockQueue.java | 2 +- .../fawe/regions/general/plot/FaweTrim.java | 11 +- .../java/com/boydti/fawe/util/WEManager.java | 45 ------- .../boydti/fawe/wrappers/WorldWrapper.java | 6 + .../com/sk89q/worldedit/LocalSession.java | 4 +- .../worldedit/command/ApplyBrushCommands.java | 4 +- .../worldedit/command/PaintBrushCommands.java | 3 +- .../worldedit/command/SchematicCommands.java | 4 +- .../worldedit/command/tool/BrushTool.java | 8 +- .../command/util/SuggestionHelper.java | 13 +- ...vent.java => ActorSaveClipboardEvent.java} | 13 +- .../extent/AbstractDelegateExtent.java | 5 +- .../com/sk89q/worldedit/extent/Extent.java | 3 +- .../sk89q/worldedit/extent/NullExtent.java | 6 + .../function/visitor/RegionVisitor.java | 3 - .../session/request/RequestExtent.java | 6 + .../com/sk89q/worldedit/world/NullWorld.java | 6 + 35 files changed, 310 insertions(+), 312 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java rename worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/{PlayerSaveClipboardEvent.java => ActorSaveClipboardEvent.java} (72%) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index cdbf7d896..5b95666f4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -77,44 +77,44 @@ public class FaweAPI { return TaskManager.IMP; } - /** - * Add a custom mask for use in e.g {@literal //mask #id:} - * - * @param methods The class with a bunch of mask methods - * @return true if the mask was registered - * @see com.sk89q.worldedit.command.MaskCommands - */ - public static boolean registerMasks(Object methods) { - DefaultMaskParser parser = getParser(DefaultMaskParser.class); - if (parser != null) parser.register(methods); - return parser != null; - } - - /** - * Add a custom material for use in e.g {@literal //material #id:} - * - * @param methods The class with a bunch of pattern methods - * @return true if the mask was registered - * @see com.sk89q.worldedit.command.PatternCommands - */ - public static boolean registerPatterns(Object methods) { - DefaultPatternParser parser = getParser(DefaultPatternParser.class); - if (parser != null) parser.register(methods); - return parser != null; - } - - /** - * Add a custom transform for use in - * - * @param methods The class with a bunch of transform methods - * @return true if the transform was registered - * @see com.sk89q.worldedit.command.TransformCommands - */ - public static boolean registerTransforms(Object methods) { - DefaultTransformParser parser = Fawe.get().getTransformParser(); - if (parser != null) parser.register(methods); - return parser != null; - } +// /** +// * Add a custom mask for use in e.g {@literal //mask #id:} +// * +// * @param methods The class with a bunch of mask methods +// * @return true if the mask was registered +// * @see com.sk89q.worldedit.command.MaskCommands +// */ +// public static boolean registerMasks(Object methods) { +// DefaultMaskParser parser = getParser(DefaultMaskParser.class); +// if (parser != null) parser.register(methods); +// return parser != null; +// } +// +// /** +// * Add a custom material for use in e.g {@literal //material #id:} +// * +// * @param methods The class with a bunch of pattern methods +// * @return true if the mask was registered +// * @see com.sk89q.worldedit.command.PatternCommands +// */ +// public static boolean registerPatterns(Object methods) { +// DefaultPatternParser parser = getParser(DefaultPatternParser.class); +// if (parser != null) parser.register(methods); +// return parser != null; +// } +// +// /** +// * Add a custom transform for use in +// * +// * @param methods The class with a bunch of transform methods +// * @return true if the transform was registered +// * @see com.sk89q.worldedit.command.TransformCommands +// */ +// public static boolean registerTransforms(Object methods) { +// DefaultTransformParser parser = Fawe.get().getTransformParser(); +// if (parser != null) parser.register(methods); +// return parser != null; +// } public static T getParser(Class parserClass) { try { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java index 8aa790db2..61a0d6b4b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java @@ -1,6 +1,7 @@ package com.boydti.fawe.beta; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -26,6 +27,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import java.util.Comparator; import java.util.List; +import java.util.Set; +import java.util.UUID; import javax.annotation.Nullable; public class DelegateFilterBlock extends FilterBlock { @@ -413,6 +416,26 @@ public class DelegateFilterBlock extends FilterBlock { return parent.divide(n); } + @Override + public BlockVector3 shr(int x, int y, int z) { + return parent.shr(x, y, z); + } + + @Override + public BlockVector3 shr(int n) { + return parent.shr(n); + } + + @Override + public BlockVector3 shl(int x, int y, int z) { + return parent.shl(x, y, z); + } + + @Override + public BlockVector3 shl(int n) { + return parent.shl(n); + } + @Override public double length() { return parent.length(); @@ -519,6 +542,11 @@ public class DelegateFilterBlock extends FilterBlock { return parent.toVector3(); } + @Override + public boolean equals(Object obj) { + return parent.equals(obj); + } + @Override public int hashCode() { return parent.hashCode(); @@ -545,6 +573,37 @@ public class DelegateFilterBlock extends FilterBlock { return parent.createEntity(location, entity); } + @Override + @Nullable + public void removeEntity(int x, int y, int z, UUID uuid) { + parent.removeEntity(x, y, z, uuid); + } + + @Override + public boolean isQueueEnabled() { + return parent.isQueueEnabled(); + } + + @Override + public void enableQueue() { + parent.enableQueue(); + } + + @Override + public void disableQueue() { + parent.disableQueue(); + } + + @Override + public boolean isWorld() { + return parent.isWorld(); + } + + @Override + public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) { + return parent.regenerateChunk(x, z, type, seed); + } + @Override public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { return parent.getHighestTerrainBlock(x, z, minY, maxY); @@ -644,12 +703,62 @@ public class DelegateFilterBlock extends FilterBlock { return parent.lazyCopy(region); } + @Override + public int countBlocks(Region region, Set searchBlocks) { + return parent.countBlocks(region, searchBlocks); + } + + @Override + public int countBlocks(Region region, Mask searchMask) { + return parent.countBlocks(region, searchMask); + } + + @Override + public > int setBlocks(Region region, B block) throws MaxChangedBlocksException { + return parent.setBlocks(region, block); + } + + @Override + public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException { + return parent.setBlocks(region, pattern); + } + + @Override + public > int replaceBlocks(Region region, Set filter, B replacement) throws MaxChangedBlocksException { + return parent.replaceBlocks(region, filter, replacement); + } + + @Override + public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException { + return parent.replaceBlocks(region, filter, pattern); + } + + @Override + public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException { + return parent.replaceBlocks(region, mask, pattern); + } + + @Override + public int center(Region region, Pattern pattern) throws MaxChangedBlocksException { + return parent.center(region, pattern); + } + + @Override + public int setBlocks(Set vset, Pattern pattern) { + return parent.setBlocks(vset, pattern); + } + @Override @Nullable public Operation commit() { return parent.commit(); } + @Override + public boolean cancel() { + return parent.cancel(); + } + @Override public int getMaxY() { return parent.getMaxY(); @@ -660,11 +769,6 @@ public class DelegateFilterBlock extends FilterBlock { return parent.getBlock(position); } - @Override - public BlockType getBlockType(BlockVector3 position) { - return parent.getBlockType(position); - } - @Override public BaseBlock getFullBlock(BlockVector3 position) { return parent.getFullBlock(position); @@ -680,6 +784,7 @@ public class DelegateFilterBlock extends FilterBlock { return parent.getBiomeType(x, z); } + @Deprecated @Override public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { @@ -692,6 +797,11 @@ public class DelegateFilterBlock extends FilterBlock { return parent.setBlock(x, y, z, block); } + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return parent.setTile(x, y, z, tile); + } + @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { return parent.setBiome(position, biome); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java index f0ed63fd2..182782e62 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java @@ -1,6 +1,7 @@ package com.boydti.fawe.beta; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; @@ -55,6 +56,12 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn return getExtent().getBlock(x, y, z); } + + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return getExtent().setTile(x, y, z, tile); + } + @Override public BaseBlock getFullBlock(int x, int y, int z) { return getExtent().getFullBlock(x, y, z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java index 5513708a5..2f48cae49 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java @@ -24,7 +24,7 @@ public interface IChunkSet extends IBlocks, OutputExtent { boolean isEmpty(); - void setTile(int x, int y, int z, CompoundTag tile); + boolean setTile(int x, int y, int z, CompoundTag tile); void setEntity(CompoundTag tag); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index d892d47f1..0c78ff4c5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -5,6 +5,7 @@ import com.boydti.fawe.beta.implementation.WorldChunkCache; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -17,7 +18,7 @@ import java.util.function.Supplier; * TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which * uses chunks */ -public interface IQueueExtent extends Flushable, Trimable, Extent { +public interface IQueueExtent extends Flushable, Trimable, Extent, Keyed { @Override default boolean isQueueEnabled() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java index ec4bf5b73..51d718c4d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java @@ -1,6 +1,7 @@ package com.boydti.fawe.beta; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java index b53e12861..64e5ded9d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java @@ -34,8 +34,8 @@ public interface DelegateChunkSet extends IChunkSet { } @Override - default void setTile(int x, int y, int z, CompoundTag tile) { - getParent().setTile(x, y, z, tile); + default boolean setTile(int x, int y, int z, CompoundTag tile) { + return getParent().setTile(x, y, z, tile); } @Override 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 eeb5412e0..74498610a 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 @@ -7,6 +7,8 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; + +import java.util.Arrays; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -39,7 +41,8 @@ public class BitSetBlocks implements IChunkSet { } @Override - public void setTile(int x, int y, int z, CompoundTag tile) { + public boolean setTile(int x, int y, int z, CompoundTag tile) { + return false; } @Override @@ -61,7 +64,32 @@ public class BitSetBlocks implements IChunkSet { @Override public char[] getArray(int layer) { char[] arr = FaweCache.SECTION_BITS_TO_CHAR.get(); - + MemBlockSet.IRow nullRowY = row.getRow(layer); + if (nullRowY instanceof MemBlockSet.RowY) { + char value = blockState.getOrdinalChar(); + MemBlockSet.RowY rowY = (MemBlockSet.RowY) nullRowY; + long[] bits = rowY.getBits(); + for (int y = 0, longIndex = 0, blockIndex = 0; y < 16; y++) { + for (int z = 0; z < 16; z += 4, longIndex++, blockIndex += 64) { + long bitBuffer = bits[longIndex]; + if (bitBuffer != 0) { + if (bitBuffer == -1L) { + Arrays.fill(arr, blockIndex, blockIndex + 64, value); + continue; + } + Arrays.fill(arr, Character.MIN_VALUE); + do { + final long lowBit = Long.lowestOneBit(bitBuffer); + final int bitIndex = Long.bitCount(lowBit - 1); + arr[blockIndex + bitIndex] = value; + bitBuffer = bitBuffer ^ lowBit; + } while (bitBuffer != 0); + } + + } + } + } + return arr; } @Override 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 02ff245a2..aff10f536 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 @@ -77,12 +77,13 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { } @Override - public void setTile(int x, int y, int z, CompoundTag tile) { + public boolean setTile(int x, int y, int z, CompoundTag tile) { if (tiles == null) { tiles = new HashMap<>(); } final short pair = MathMan.tripleBlockCoord(x, y, z); tiles.put(pair, tile); + return true; } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java deleted file mode 100644 index 3d0664404..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.boydti.fawe.object.brush.visualization; - -import com.boydti.fawe.beta.IChunk; -import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.beta.implementation.blocks.BitSetBlocks; -import com.boydti.fawe.beta.implementation.holder.ChunkHolder; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.util.concurrent.Future; - -/** - * FAWE visualizations display glass (20) as a placeholder - * - Using a non transparent block can cause FPS lag - */ -public class VisualChunk extends ChunkHolder { - private final IChunk parent; - private final VisualExtent extent; - - public VisualChunk(IChunk parent, VisualExtent extent) { - this.parent = parent; - this.extent = extent; - } - - public IChunk getParent() { - return parent; - } - - @Override - public Future call() { - return extent.sendChunkUpdate(this); - } - - @Override - public IChunkGet get() { - if (parent instanceof ChunkHolder) { - return ((ChunkHolder) parent).get(); - } - return parent; - } - - @Override - public IChunkSet createSet() { - return new BitSetBlocks(VISUALIZE_BLOCK); - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java index e133fec90..49588cbc3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java @@ -29,11 +29,11 @@ public class VisualExtent extends AbstractDelegateExtent { private final BlockType visualizeBlock; private final Player player; - public VisualExtent(IQueueExtent parent, Player player) { + public VisualExtent(Extent parent, Player player) { this(parent, player, VISUALIZE_BLOCK_DEFAULT); } - public VisualExtent(IQueueExtent parent, Player player, BlockType visualizeBlock) { + public VisualExtent(Extent parent, Player player, BlockType visualizeBlock) { super(parent); this.visualizeBlock = visualizeBlock; this.player = player; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index f5cde0b7f..3d78a73fe 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -22,6 +22,7 @@ import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.image.Drawable; import com.boydti.fawe.util.image.ImageViewer; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEditException; @@ -1929,6 +1930,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } // These aren't implemented yet... + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return false; + } + @Override public int getBlockLightLevel(BlockVector3 position) { return 0; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java index e69c1c41a..56646fdc9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java @@ -4,6 +4,7 @@ import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.beta.IQueueExtent; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.inventory.BlockBag; @@ -17,10 +18,16 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.Iterator; +import java.util.UUID; +import java.util.concurrent.Future; public class AbstractDelegateChangeSet extends FaweChangeSet { public final FaweChangeSet parent; + public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) { + return FaweChangeSet.getDefaultChangeSet(world, uuid); + } + public AbstractDelegateChangeSet(FaweChangeSet parent) { super(parent.getWorld()); this.parent = parent; @@ -28,11 +35,6 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { this.waitingAsync = parent.waitingAsync; } - @Override - public void addChangeTask(IQueueExtent queue) { - super.addChangeTask(queue); - } - @Override public boolean flush() { return parent.flush(); @@ -63,6 +65,11 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { return parent.flushAsync(); } + @Override + public boolean closeAsync() { + return parent.closeAsync(); + } + @Override public void add(int x, int y, int z, int combinedFrom, int combinedTo) { parent.add(x, y, z, combinedFrom, combinedTo); @@ -128,6 +135,11 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { return parent.toEditSession(player); } + @Override + public EditSession toEditSession(FawePlayer player, Region[] regions) { + return parent.toEditSession(player, regions); + } + @Override public void add(EntityCreate change) { parent.add(change); @@ -168,15 +180,23 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { parent.add(x, y, z, combinedFrom, to); } + @Override + public Future addWriteTask(Runnable writeTask) { + return parent.addWriteTask(writeTask); + } + + @Override + public Future addWriteTask(Runnable writeTask, boolean completeNow) { + return parent.addWriteTask(writeTask, completeNow); + } + @Override public boolean isRecordingChanges() { - // TODO Auto-generated method stub - return false; + return parent.isRecordingChanges(); } @Override public void setRecordChanges(boolean recordChanges) { - // TODO Auto-generated method stub - + parent.setRecordChanges(recordChanges); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java deleted file mode 100644 index 190174f8f..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AnvilHistory.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.boydti.fawe.object.changeset; - -import com.boydti.fawe.Fawe; -import com.boydti.fawe.config.Settings; -import com.boydti.fawe.util.MainUtil; -import com.google.common.base.Function; -import com.google.common.collect.Iterators; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.history.change.Change; -import com.sk89q.worldedit.world.biome.BiomeType; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import javax.annotation.Nullable; - -public class AnvilHistory extends FaweChangeSet { - private final File folder; - private int size; - - public AnvilHistory(String world, File folder) { - super(world); - this.folder = folder; - size = -1; - } - - public AnvilHistory(String world, UUID uuid) { - super(world); - File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world + File.separator + uuid); - File destFolder = new File(history, Integer.toString(MainUtil.getMaxFileId(history))); - if (!destFolder.exists()) { - destFolder.mkdirs(); - } - this.folder = destFolder; - this.size = 0; - } - - //@Override - public boolean addFileChange(File originalMCAFile) { - try { - Files.move(originalMCAFile.toPath(), Paths.get(folder.getPath(), originalMCAFile.getName()), StandardCopyOption.ATOMIC_MOVE); - if (size != -1) size++; - } catch (IOException e) { - e.printStackTrace(); - originalMCAFile.delete(); - } - return false; - } - - @Override - public void add(int x, int y, int z, int combinedFrom, int combinedTo) { - throw new UnsupportedOperationException("Only anvil operations are supported"); - } - - @Override - public void addTileCreate(CompoundTag tag) { - throw new UnsupportedOperationException("Only anvil operations are supported"); - } - - @Override - public void addTileRemove(CompoundTag tag) { - throw new UnsupportedOperationException("Only anvil operations are supported"); - } - - @Override - public void addEntityRemove(CompoundTag tag) { - throw new UnsupportedOperationException("Only anvil operations are supported"); - } - - @Override - public void addEntityCreate(CompoundTag tag) { - throw new UnsupportedOperationException("Only anvil operations are supported"); - } - - @Override - public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) { - throw new UnsupportedOperationException("Only anvil operations are supported"); - } - - @Override - public Iterator getIterator(boolean redo) { - if (redo) throw new UnsupportedOperationException("Only undo operations are supported"); - List files = Arrays.asList(folder.listFiles()); - final MutableAnvilChange change = new MutableAnvilChange(); - return Iterators.transform(files.iterator(), new Function() { - @Nullable - @Override - public MutableAnvilChange apply(@Nullable File input) { - change.setSource(input.toPath()); - return change; - } - }); - } - - @Override - public int size() { - return size == -1 ? folder.listFiles().length : size; - } - - @Override - public boolean isRecordingChanges() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void setRecordChanges(boolean recordChanges) { - // TODO Auto-generated method stub - - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java index c5d8f121c..debca3057 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java @@ -20,7 +20,7 @@ public class CFIChangeSet extends FaweChangeSet { public CFIChangeSet(HeightMapMCAGenerator hmmg, UUID uuid) throws IOException { super(hmmg); - File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + uuid + File.separator + "CFI" + File.separator + hmmg.getWorldName()); + File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + uuid + File.separator + "CFI" + File.separator + hmmg.getId()); int max = MainUtil.getMaxFileId(folder); this.file = new File(folder, max + ".cfi"); File parent = this.file.getParentFile(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java index 1cc2a0329..8a933d9f4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.clipboard; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector2; @@ -68,6 +69,11 @@ public class EmptyClipboard implements Clipboard { return false; } + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return false; + } + @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { return false; 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 ea5102ee6..bb7418ee0 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 @@ -827,6 +827,10 @@ public final class MemBlockSet extends BlockSet { reset(); } + public IRow getRow(int i) { + return rows[i]; + } + @Override public boolean get(IRow[] parent, int x, int y, int z) { return rows[y >> 4].get(this.rows, x, y, z); @@ -873,6 +877,10 @@ public final class MemBlockSet extends BlockSet { this.bits = new long[WORDS]; } + public long[] getBits() { + return bits; + } + @Override public boolean get(IRow[] parent, int x, int y, int z) { int i = ((y & 15) << 8) | ((z & 15) << 4) | (x & 15); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java index e46bf763b..4b198098f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java @@ -254,11 +254,6 @@ public class NullExtent extends FaweRegionExtent { throw reason; } - @Override - public World getWorld() { - throw reason; - } - @Override public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) { throw reason; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java index 02bb87d4e..ea5cb6080 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java @@ -104,7 +104,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue { @Override public String getWorld() { - return IMP.getWorld().getName(); + return IMP.getId(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweTrim.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweTrim.java index 60d1ef422..6f7a3ce37 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweTrim.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweTrim.java @@ -40,11 +40,12 @@ public class FaweTrim extends SubCommand { @Override public void run() { try { - PlotTrim trim = new PlotTrim(plotPlayer, plotPlayer.getPlotAreaAbs(), strings[0], Boolean.parseBoolean(strings[1])); - Location loc = plotPlayer.getLocation(); - trim.setChunk(loc.getX() >> 4, loc.getZ() >> 4); - trim.run(); - plotPlayer.sendMessage("Done!"); + // TODO NOT IMPLEMENTED +// PlotTrim trim = new PlotTrim(plotPlayer, plotPlayer.getPlotAreaAbs(), strings[0], Boolean.parseBoolean(strings[1])); +// Location loc = plotPlayer.getLocation(); +// trim.setChunk(loc.getX() >> 4, loc.getZ() >> 4); +// trim.run(); +// plotPlayer.sendMessage("Done!"); } catch (Throwable e) { e.printStackTrace(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java index 7e4659a9c..e0097cef2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java @@ -165,49 +165,4 @@ public class WEManager { } return false; } - - public boolean delay(FawePlayer player, String command) { - final long start = System.currentTimeMillis(); - return this.delay(player, () -> { - try { - if (System.currentTimeMillis() - start > 1000) { - BBC.WORLDEDIT_RUN.send(FawePlayer.wrap(player)); - } - TaskManager.IMP.task(() -> { - final long start1 = System.currentTimeMillis(); - player.executeCommand(command.substring(1)); - TaskManager.IMP.later(() -> SetQueue.IMP.addEmptyTask(() -> { - if (System.currentTimeMillis() - start1 > 1000) { - BBC.WORLDEDIT_COMPLETE.send(FawePlayer.wrap(player)); - } - }), 2); - }); - } catch (Exception e) { - e.printStackTrace(); - } - }, false, false); - } - - public boolean delay(FawePlayer player, Runnable whenDone, boolean delayed, boolean onlyDelayedExecution) { - final boolean free = SetQueue.IMP.addEmptyTask(null); - if (free) { - if (delayed) { - if (whenDone != null) { - whenDone.run(); - } - } else { - if (whenDone != null && !onlyDelayedExecution) { - whenDone.run(); - } else { - return false; - } - } - } else { - if (!delayed && player != null) { - BBC.WORLDEDIT_DELAYED.send(player); - } - SetQueue.IMP.addEmptyTask(whenDone); - } - return true; - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index 3007c5c74..965e68ee9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -3,6 +3,7 @@ package com.boydti.fawe.wrappers; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.TaskManager; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; @@ -74,6 +75,11 @@ public class WorldWrapper extends AbstractWorld { return parent.setBlock(position, block, notifyAndLight); } + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return parent.setTile(x, y, z, tile); + } + @Override public int getMaxY() { return parent.getMaxY(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index c89e9c502..21f38c0fa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -28,7 +28,6 @@ import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.brush.visualization.VirtualWorld; -import com.boydti.fawe.object.changeset.AnvilHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.clipboard.MultiClipboardHolder; @@ -387,7 +386,8 @@ public class LocalSession implements TextureHolder { File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + currentWorld.getName() + File.separator + uuid); File specific = new File(folder, o.toString()); if (specific.isDirectory()) { - return new AnvilHistory(currentWorld.getName(), specific); + // TODO NOT IMPLEMENTED +// return new AnvilHistory(currentWorld.getName(), specific); } else { return new DiskStorageHistory(currentWorld, this.uuid, (Integer) o); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java index 5a4dd3513..48e3f8d66 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java @@ -40,6 +40,8 @@ import com.sk89q.worldedit.function.factory.Apply; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; +import com.sk89q.worldedit.internal.expression.Expression; +import com.sk89q.worldedit.internal.expression.runtime.Constant; import com.sk89q.worldedit.regions.factory.RegionFactory; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.formatting.text.TextComponent; @@ -96,7 +98,7 @@ public class ApplyBrushCommands { Contextual generatorFactory) throws WorldEditException { double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class)); RegionFactory regionFactory = REGION_FACTORY.value(parameters).asSingle(RegionFactory.class); - BrushCommands.setOperationBasedBrush(player, localSession, radius, + BrushCommands.setOperationBasedBrush(player, localSession, new Expression(radius), new Apply(generatorFactory), regionFactory, "worldedit.brush.apply"); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java index cc0689630..0cda0303b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java @@ -37,6 +37,7 @@ import com.sk89q.worldedit.function.factory.Paint; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; +import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.regions.factory.RegionFactory; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.formatting.text.TextComponent; @@ -103,7 +104,7 @@ public class PaintBrushCommands { double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class)); double density = requireNonNull(DENSITY.value(parameters).asSingle(double.class)) / 100; RegionFactory regionFactory = REGION_FACTORY.value(parameters).asSingle(RegionFactory.class); - BrushCommands.setOperationBasedBrush(player, localSession, radius, + BrushCommands.setOperationBasedBrush(player, localSession, new Expression(radius), new Paint(generatorFactory, density), regionFactory, "worldedit.brush.paint"); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 5e76e2522..c5e174438 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -38,7 +38,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.event.extent.PlayerSaveClipboardEvent; +import com.sk89q.worldedit.event.extent.ActorSaveClipboardEvent; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -698,7 +698,7 @@ public class SchematicCommands { if (holder instanceof URIClipboardHolder) { uri = ((URIClipboardHolder) holder).getURI(clipboard); } - if (new PlayerSaveClipboardEvent(player, clipboard, uri, file.toURI()).call()) { + if (new ActorSaveClipboardEvent(actor, clipboard, uri, file.toURI()).call()) { if (writer instanceof MinecraftStructure) { ((MinecraftStructure) writer).write(target, actor.getName()); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 21cb2136c..73913f423 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -31,7 +31,6 @@ import com.boydti.fawe.object.brush.ResettableTool; import com.boydti.fawe.object.brush.TargetMode; import com.boydti.fawe.object.brush.scroll.ScrollAction; import com.boydti.fawe.object.brush.scroll.ScrollTool; -import com.boydti.fawe.object.brush.visualization.VisualChunk; import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualMode; import com.boydti.fawe.object.extent.ResettableExtent; @@ -48,7 +47,6 @@ import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.MaxBrushRadiusException; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -669,17 +667,17 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } if (visualExtent != null) { // clear old data - visualExtent.clear(newVisualExtent, player); + visualExtent.clear(); } visualExtent = newVisualExtent; - newVisualExtent.visualize(fp); + newVisualExtent.commit(); } public void clear(Player player) { FawePlayer fp = FawePlayer.wrap(player); Fawe.get().getVisualQueue().dequeue(fp); if (visualExtent != null) { - visualExtent.clear(null, fp); + visualExtent.clear(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java index e0014ee56..dab0aae2b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java @@ -49,11 +49,12 @@ public final class SuggestionHelper { public static Stream getBlockCategorySuggestions(String tag, boolean allowRandom) { if (tag.isEmpty() || tag.equals("#")) { - return Stream.of("##", "##*"); + return allowRandom ? Stream.of("##", "##*") : Stream.of("##"); } - if (tag.startsWith("#")) { + if (tag.startsWith("##")) { if (tag.equals("##")) { - return Stream.concat(Stream.of("##*"), getNamespacedRegistrySuggestions(BlockCategory.REGISTRY, tag.substring(2)).map(s -> "##" + s)); + return Stream.concat(allowRandom ? Stream.of("##*") : Stream.empty(), + getNamespacedRegistrySuggestions(BlockCategory.REGISTRY, tag.substring(2)).map(s -> "##" + s)); } else if (tag.equals("##*") && allowRandom) { return getNamespacedRegistrySuggestions(BlockCategory.REGISTRY, tag.substring(3)).map(s -> "##*" + s); } else { @@ -139,12 +140,12 @@ public final class SuggestionHelper { public static Stream getRegistrySuggestions(Registry registry, String input) { if (registry instanceof NamespacedRegistry) { - return getNamespacedRegistrySuggestions(((NamespacedRegistry) registry), input); + return getNamespacedRegistrySuggestions(((NamespacedRegistry) registry), input); } return limitByPrefix(registry.keySet().stream(), input).stream(); } - public static Stream getNamespacedRegistrySuggestions(NamespacedRegistry registry, String input) { + public static Stream getNamespacedRegistrySuggestions(NamespacedRegistry registry, String input) { if (input.isEmpty() || input.equals(":")) { final Set namespaces = registry.getKnownNamespaces(); if (namespaces.size() == 1) { @@ -170,4 +171,4 @@ public final class SuggestionHelper { Predicate search = byPrefix(input.toLowerCase(Locale.ROOT)); return registry.keySet().stream().filter(search); } -} +} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PlayerSaveClipboardEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/ActorSaveClipboardEvent.java similarity index 72% rename from worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PlayerSaveClipboardEvent.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/ActorSaveClipboardEvent.java index cd5a8d5c3..929c3b6aa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PlayerSaveClipboardEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/ActorSaveClipboardEvent.java @@ -3,18 +3,19 @@ package com.sk89q.worldedit.event.extent; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; import java.net.URI; -public class PlayerSaveClipboardEvent extends Event implements Cancellable { - private final Player player; +public class ActorSaveClipboardEvent extends Event implements Cancellable { + private final Actor actor; private final Clipboard clipboard; private final URI source, destination; private boolean cancelled; - public PlayerSaveClipboardEvent(Player player, Clipboard clipboard, URI source, URI destination) { - this.player = player; + public ActorSaveClipboardEvent(Actor actor, Clipboard clipboard, URI source, URI destination) { + this.actor = actor; this.clipboard = clipboard; this.source = source; this.destination = destination; @@ -42,7 +43,7 @@ public class PlayerSaveClipboardEvent extends Event implements Cancellable { return clipboard; } - public Player getPlayer() { - return player; + public Actor getActor() { + return actor; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 0414112a8..f5dcea2e4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -123,10 +123,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent { } } - @Override - public World getWorld() { - return getExtent().getWorld(); - } + /* Bounds diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 3e9ce43a9..f785de7aa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -52,6 +52,7 @@ import com.sk89q.worldedit.registry.state.PropertyGroup; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -609,7 +610,7 @@ public interface Extent extends InputExtent, OutputExtent { Vector3 center = region.getCenter(); Region centerRegion = new CuboidRegion( - getWorld(), // Causes clamping of Y range + this instanceof World ? (World) this : null, // Causes clamping of Y range BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), BlockVector3.at(MathUtils.roundHalfUp(center.getX()), center.getY(), MathUtils.roundHalfUp(center.getZ()))); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java index 52a3d854c..870ed65dc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.extent; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -91,6 +92,11 @@ public class NullExtent implements Extent { return false; } + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return false; + } + @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { return false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java index 8bcea5e28..bda40ee93 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java @@ -59,9 +59,6 @@ public class RegionVisitor implements Operation { this.iterable = iterable; } - public RegionVisitor(Region region, RegionFunction regionFunction, EditSession editSession) { - } - /** * Get the number of affected objects. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java index ab47f7c51..47c72de1b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.session.request; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; @@ -95,6 +96,11 @@ public class RequestExtent implements Extent { return getExtent().setBlock(position, block); } + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return getExtent().setTile(x, y, z, tile); + } + @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { return getExtent().setBiome(position, biome); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index ff1ac5edc..73e5ca207 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.world; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; @@ -146,6 +147,11 @@ public class NullWorld extends AbstractWorld { return false; } + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return false; + } + @Override public BaseBlock getFullBlock(BlockVector3 position) { return getBlock(position).toBaseBlock();