idk it compiles now
This commit is contained in:
Jesse Boyd 2019-08-10 16:01:42 +10:00
parent 3b879477b6
commit 7a57a5dd8c
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
35 changed files with 310 additions and 312 deletions

View File

@ -77,44 +77,44 @@ public class FaweAPI {
return TaskManager.IMP;
}
/**
* Add a custom mask for use in e.g {@literal //mask #id:<input>}
*
* @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:<input>}
*
* @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:<input>}
// *
// * @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:<input>}
// *
// * @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> T getParser(Class<T> parserClass) {
try {

View File

@ -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<BaseBlock> searchBlocks) {
return parent.countBlocks(region, searchBlocks);
}
@Override
public int countBlocks(Region region, Mask searchMask) {
return parent.countBlocks(region, searchMask);
}
@Override
public <B extends BlockStateHolder<B>> 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 <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
return parent.replaceBlocks(region, filter, replacement);
}
@Override
public int replaceBlocks(Region region, Set<BaseBlock> 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<BlockVector3> 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 <T extends BlockStateHolder<T>> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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() {

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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<Change> getIterator(boolean redo) {
if (redo) throw new UnsupportedOperationException("Only undo operations are supported");
List<File> files = Arrays.asList(folder.listFiles());
final MutableAnvilChange change = new MutableAnvilChange();
return Iterators.transform(files.iterator(), new Function<File, MutableAnvilChange>() {
@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
}
}

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -104,7 +104,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override
public String getWorld() {
return IMP.getWorld().getName();
return IMP.getId();
}
@Override

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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<? extends RegionFunction> 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");
}

View File

@ -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");
}

View File

@ -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 {

View File

@ -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<Object> fp = FawePlayer.wrap(player);
Fawe.get().getVisualQueue().dequeue(fp);
if (visualExtent != null) {
visualExtent.clear(null, fp);
visualExtent.clear();
}
}

View File

@ -49,11 +49,12 @@ public final class SuggestionHelper {
public static Stream<String> 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 <V extends Keyed> Stream<String> getRegistrySuggestions(Registry<V> registry, String input) {
if (registry instanceof NamespacedRegistry) {
return getNamespacedRegistrySuggestions(((NamespacedRegistry<V>) registry), input);
return getNamespacedRegistrySuggestions(((NamespacedRegistry<?>) registry), input);
}
return limitByPrefix(registry.keySet().stream(), input).stream();
}
public static <V extends Keyed> Stream<String> getNamespacedRegistrySuggestions(NamespacedRegistry<V> registry, String input) {
public static <V extends Keyed> Stream<String> getNamespacedRegistrySuggestions(NamespacedRegistry<?> registry, String input) {
if (input.isEmpty() || input.equals(":")) {
final Set<String> namespaces = registry.getKnownNamespaces();
if (namespaces.size() == 1) {
@ -170,4 +171,4 @@ public final class SuggestionHelper {
Predicate<String> search = byPrefix(input.toLowerCase(Locale.ROOT));
return registry.keySet().stream().filter(search);
}
}
}

View File

@ -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;
}
}

View File

@ -123,10 +123,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
}
}
@Override
public World getWorld() {
return getExtent().getWorld();
}
/*
Bounds

View File

@ -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())));

View File

@ -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;

View File

@ -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.
*

View File

@ -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);

View File

@ -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();