Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 08:02:50 +02:00
schem list is still broken
clickEvent and hoverEvent don't seem to work, I'm probably doing something wrong
Dieser Commit ist enthalten in:
Ursprung
d904270a3d
Commit
8768085479
@ -1,9 +1,13 @@
|
||||
package com.boydti.fawe;
|
||||
|
||||
import com.boydti.fawe.beta.Trimable;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.collection.BitArray4096;
|
||||
import com.boydti.fawe.object.collection.CleanableThreadLocal;
|
||||
import com.boydti.fawe.object.exception.FaweBlockBagException;
|
||||
import com.boydti.fawe.object.exception.FaweChunkLoadException;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.IOUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.ByteArrayTag;
|
||||
@ -180,6 +184,24 @@ public enum FaweCache implements Trimable {
|
||||
return pool;
|
||||
}
|
||||
|
||||
/*
|
||||
Exceptions
|
||||
*/
|
||||
public static final FaweChunkLoadException CHUNK = new FaweChunkLoadException();
|
||||
public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException();
|
||||
public static final FaweException MANUAL = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
||||
public static final FaweException NO_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_NO_REGION);
|
||||
public static final FaweException OUTSIDE_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
|
||||
public static final FaweException MAX_CHECKS = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
public static final FaweException MAX_CHANGES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
public static final FaweException LOW_MEMORY = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY);
|
||||
public static final FaweException MAX_ENTITIES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ENTITIES);
|
||||
public static final FaweException MAX_TILES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_TILES);
|
||||
|
||||
/*
|
||||
thread cache
|
||||
*/
|
||||
|
||||
public final CleanableThreadLocal<int[]> BLOCK_TO_PALETTE = new CleanableThreadLocal<>(() -> {
|
||||
int[] result = new int[BlockTypes.states.length];
|
||||
Arrays.fill(result, Integer.MAX_VALUE);
|
||||
|
@ -20,7 +20,11 @@ public interface IBatchProcessor {
|
||||
* @param set
|
||||
* @return
|
||||
*/
|
||||
IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set);
|
||||
IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set);
|
||||
|
||||
default boolean processGet(int chunkX, int chunkZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert this processor into an Extent based processor instead of a queue batch based on
|
||||
|
@ -10,7 +10,7 @@ public enum EmptyBatchProcessor implements IBatchProcessor {
|
||||
INSTANCE
|
||||
;
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return set;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,13 @@ public interface IBatchProcessorHolder extends IBatchProcessor {
|
||||
void setProcessor(IBatchProcessor set);
|
||||
|
||||
@Override
|
||||
default IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return getProcessor().processBatch(chunk, get, set);
|
||||
default IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return getProcessor().processSet(chunk, get, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean processGet(int chunkX, int chunkZ) {
|
||||
return getProcessor().processGet(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,6 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class MultiBatchProcessor implements IBatchProcessor {
|
||||
private IBatchProcessor[] processors;
|
||||
@ -55,9 +54,9 @@ public class MultiBatchProcessor implements IBatchProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
for (IBatchProcessor processor : this.processors) {
|
||||
set = processor.processBatch(chunk, get, set);
|
||||
set = processor.processSet(chunk, get, set);
|
||||
if (set == null) {
|
||||
return null;
|
||||
}
|
||||
@ -65,6 +64,16 @@ public class MultiBatchProcessor implements IBatchProcessor {
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processGet(int chunkX, int chunkZ) {
|
||||
for (IBatchProcessor processor : this.processors) {
|
||||
if (!processor.processGet(chunkX, chunkZ)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent construct(Extent child) {
|
||||
for (IBatchProcessor processor : processors) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.beta.implementation;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.CharFilterBlock;
|
||||
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||
import com.boydti.fawe.beta.IBatchProcessor;
|
||||
@ -13,6 +14,7 @@ import com.boydti.fawe.beta.implementation.holder.ChunkHolder;
|
||||
import com.boydti.fawe.beta.implementation.holder.ReferenceChunk;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.MemUtil;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
@ -219,6 +221,9 @@ public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQu
|
||||
|
||||
@Override
|
||||
public final IChunk getOrCreateChunk(int x, int z) {
|
||||
if (!processGet(x, z)) {
|
||||
throw FaweCache.CHUNK;
|
||||
}
|
||||
final long pair = (long) x << 32 | z & 0xffffffffL;
|
||||
if (pair == lastPair) {
|
||||
return lastChunk;
|
||||
|
@ -414,7 +414,7 @@ public class ChunkHolder<T extends Future<T>> implements IChunk {
|
||||
public T call(IChunkSet set, Runnable finalize) {
|
||||
if (set != null) {
|
||||
IChunkGet get = getOrCreateGet();
|
||||
set = getExtent().processBatch(this, get, set);
|
||||
set = getExtent().processSet(this, get, set);
|
||||
if (set != null) {
|
||||
return get.call(set, finalize);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.jnbt;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
|
||||
@ -40,7 +41,7 @@ public class NBTStreamer {
|
||||
try {
|
||||
is.readNamedTagLazy(node -> {
|
||||
if (readers.isEmpty()) {
|
||||
throw FaweException.MANUAL;
|
||||
throw FaweCache.MANUAL;
|
||||
}
|
||||
return readers.remove(node);
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.brush;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
@ -62,7 +63,7 @@ public class SplineBrush implements Brush, ResettableTool {
|
||||
this.position = position;
|
||||
if (newPos) {
|
||||
if (positionSets.size() >= MAX_POINTS) {
|
||||
throw FaweException.MAX_CHECKS;
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
final ArrayList<BlockVector3> points = new ArrayList<>();
|
||||
if (size > 0) {
|
||||
|
@ -14,6 +14,7 @@ import com.boydti.fawe.object.collection.DifferentialArray;
|
||||
import com.boydti.fawe.object.collection.DifferentialBlockBuffer;
|
||||
import com.boydti.fawe.object.collection.LocalBlockVector2DSet;
|
||||
import com.boydti.fawe.object.collection.SummedAreaTable;
|
||||
import com.boydti.fawe.object.exception.FaweChunkLoadException;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.boydti.fawe.util.CachedTextureUtil;
|
||||
@ -883,14 +884,14 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweChunkLoadException {
|
||||
int index = z * getWidth() + x;
|
||||
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
|
||||
return BiomeTypes.get(biomes.getByte(index));
|
||||
}
|
||||
|
||||
// @Override
|
||||
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||
public int getCombinedId4Data(int x, int y, int z) throws FaweChunkLoadException {
|
||||
int index = z * getWidth() + x;
|
||||
if (y < 0) return 0;
|
||||
if (index < 0 || index >= getArea() || x < 0 || x >= getWidth()) return 0;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.changeset;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -87,10 +88,10 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
|
||||
try {
|
||||
blockBag.fetchPlacedBlock(typeTo.getDefaultState());
|
||||
} catch (UnplaceableBlockException e) {
|
||||
throw FaweException.BLOCK_BAG;
|
||||
throw FaweCache.BLOCK_BAG;
|
||||
} catch (BlockBagException e) {
|
||||
missingBlocks[typeTo.getInternalId()]++;
|
||||
throw FaweException.BLOCK_BAG;
|
||||
throw FaweCache.BLOCK_BAG;
|
||||
}
|
||||
}
|
||||
if (mine) {
|
||||
|
@ -134,7 +134,7 @@ public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
public synchronized IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
int bx = chunk.getX() << 4;
|
||||
int bz = chunk.getZ() << 4;
|
||||
|
||||
|
@ -9,6 +9,8 @@ import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.boydti.fawe.object.exception;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
|
||||
public class FaweBlockBagException extends FaweException {
|
||||
public FaweBlockBagException() {
|
||||
super(BBC.WORLDEDIT_SOME_FAILS_BLOCKBAG);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.boydti.fawe.object.exception;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
|
||||
public class FaweChunkLoadException extends FaweException {
|
||||
public FaweChunkLoadException() {
|
||||
super(BBC.WORLDEDIT_FAILED_LOAD_CHUNK);
|
||||
}
|
||||
}
|
@ -4,17 +4,6 @@ import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
public class FaweException extends RuntimeException {
|
||||
public static final FaweChunkLoadException CHUNK = new FaweChunkLoadException();
|
||||
public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException();
|
||||
public static final FaweException MANUAL = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
||||
public static final FaweException NO_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_NO_REGION);
|
||||
public static final FaweException OUTSIDE_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
|
||||
public static final FaweException MAX_CHECKS = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
public static final FaweException MAX_CHANGES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
public static final FaweException LOW_MEMORY = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY);
|
||||
public static final FaweException MAX_ENTITIES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ENTITIES);
|
||||
public static final FaweException MAX_TILES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_TILES);
|
||||
|
||||
// DEBUG
|
||||
public static final FaweException _enableQueue;
|
||||
public static final FaweException _disableQueue;
|
||||
@ -55,22 +44,6 @@ public class FaweException extends RuntimeException {
|
||||
return get(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* This exception is thrown when a chunk fails to load in time
|
||||
* - Chunks are loaded on the main thread to be accessed async
|
||||
*/
|
||||
public static class FaweChunkLoadException extends FaweException {
|
||||
public FaweChunkLoadException() {
|
||||
super(BBC.WORLDEDIT_FAILED_LOAD_CHUNK);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FaweBlockBagException extends FaweException {
|
||||
public FaweBlockBagException() {
|
||||
super(BBC.WORLDEDIT_SOME_FAILS_BLOCKBAG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Faster exception throwing/handling if you don't fill the stacktrace
|
||||
*
|
||||
|
@ -76,7 +76,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -87,7 +87,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
if (!contains(position)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -109,7 +109,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public BiomeType getBiomeType(int x, int z) {
|
||||
if (!contains(x, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -120,7 +120,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
if (!contains(position)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
@ -131,7 +131,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
if (!contains(position)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
@ -142,7 +142,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public int getBlockLight(int x, int y, int z) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -153,7 +153,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public int getBrightness(int x, int y, int z) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -164,7 +164,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public int getLight(int x, int y, int z) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -175,7 +175,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public int getOpacity(int x, int y, int z) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -186,7 +186,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -198,7 +198,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class HeightBoundExtent extends FaweRegionExtent implements IBatchProcess
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
if (trimY(set, min, max) | trimNBT(set, this::contains)) {
|
||||
return set;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.MemUtil;
|
||||
@ -26,7 +27,7 @@ public class MemoryCheckingExtent extends PassthroughExtent {
|
||||
BBC.WORLDEDIT_OOM_ADMIN.send(this.player);
|
||||
}
|
||||
}
|
||||
WEManager.IMP.cancelEdit(this, FaweException.LOW_MEMORY);
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY);
|
||||
}
|
||||
return super.getExtent();
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||
|
||||
@ -50,6 +49,16 @@ public class MultiRegionExtent extends FaweRegionExtent {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processGet(int chunkX, int chunkZ) {
|
||||
for (Region region : regions) {
|
||||
if (region.containsChunk(chunkX, chunkZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int z) {
|
||||
if (region.contains(x, z)) {
|
||||
@ -74,7 +83,7 @@ public class MultiRegionExtent extends FaweRegionExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return intersection.processBatch(chunk, get, set);
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return intersection.processSet(chunk, get, set);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
@ -52,7 +53,7 @@ public class NullExtent extends FaweRegionExtent {
|
||||
}
|
||||
|
||||
public NullExtent() {
|
||||
this(new com.sk89q.worldedit.extent.NullExtent(), FaweException.MANUAL);
|
||||
this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.MANUAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -326,7 +327,12 @@ public class NullExtent extends FaweRegionExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processGet(int chunkX, int chunkZ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
@ -37,7 +38,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
return null;
|
||||
}
|
||||
if (!limit.MAX_ENTITIES()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_ENTITIES);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_ENTITIES);
|
||||
return null;
|
||||
}
|
||||
return super.createEntity(location, entity);
|
||||
@ -46,7 +47,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
if (!limit.MAX_CHECKS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHECKS);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS);
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
} else {
|
||||
return extent.getBlock(x, y, z);
|
||||
@ -56,7 +57,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 pos) {
|
||||
if (!limit.MAX_CHECKS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHECKS);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS);
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
} else {
|
||||
return extent.getFullBlock(pos);
|
||||
@ -78,18 +79,18 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
if (hasNbt) {
|
||||
if (!limit.MAX_BLOCKSTATES()) {
|
||||
WEManager.IMP.cancelEdit(this, FaweException.MAX_TILES);
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.MAX_TILES);
|
||||
return false;
|
||||
} else {
|
||||
if (!limit.MAX_CHANGES()) {
|
||||
WEManager.IMP.cancelEdit(this, FaweException.MAX_CHANGES);
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES);
|
||||
return false;
|
||||
}
|
||||
return extent.setBlock(x, y, z, block);
|
||||
}
|
||||
}
|
||||
if (!limit.MAX_CHANGES()) {
|
||||
WEManager.IMP.cancelEdit(this, FaweException.MAX_CHANGES);
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES);
|
||||
return false;
|
||||
} else {
|
||||
return extent.setBlock(x, y, z, block);
|
||||
@ -99,7 +100,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
if (!limit.MAX_CHANGES()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHANGES);
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHANGES);
|
||||
return false;
|
||||
}
|
||||
return super.setBiome(position, biome);
|
||||
|
@ -6,7 +6,7 @@ import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import java.util.Arrays;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@ -40,7 +40,12 @@ public class SingleRegionExtent extends FaweRegionExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return region.processBatch(chunk, get, set);
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
return region.processSet(chunk, get, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processGet(int chunkX, int chunkZ) {
|
||||
return region.containsChunk(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.boydti.fawe.object.function;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface QuadFunction<T, U, V, W, R> {
|
||||
R apply(T t, U u, V v, W w);
|
||||
}
|
@ -551,13 +551,13 @@
|
||||
// public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ }
|
||||
//
|
||||
// @Override
|
||||
// public BiomeType getBiomeType(int x, int z) throws FaweException.CHUNK {
|
||||
// public BiomeType getBiomeType(int x, int z) throws FaweCache.CHUNK {
|
||||
// // TODO later (currently not used)
|
||||
// return BiomeTypes.FOREST;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getCombinedId4Data(int x, int y, int z) throws FaweException.CHUNK {
|
||||
// public int getCombinedId4Data(int x, int y, int z) throws FaweCache.CHUNK {
|
||||
// MCAChunk chunk = getChunk(x >> 4, z >> 4);
|
||||
// if (y < 0 || y > 255) return 0;
|
||||
// return chunk.getBlockCombinedId(x & 15, y, z & 15);
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.beta.implementation.ParallelQueueExtent;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
@ -223,11 +224,11 @@ public class EditSessionBuilder {
|
||||
event.setExtent(extent);
|
||||
eventBus.post(event);
|
||||
if (event.isCancelled()) {
|
||||
return new NullExtent(extent, FaweException.MANUAL);
|
||||
return new NullExtent(extent, FaweCache.MANUAL);
|
||||
}
|
||||
final Extent toReturn = event.getExtent();
|
||||
if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
|
||||
return new NullExtent(toReturn, FaweException.MANUAL);
|
||||
return new NullExtent(toReturn, FaweCache.MANUAL);
|
||||
}
|
||||
// if (!(toReturn instanceof AbstractDelegateExtent)) {
|
||||
// Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
||||
@ -307,7 +308,7 @@ public class EditSessionBuilder {
|
||||
if (Permission.hasPermission(player, "worldedit.fast")) {
|
||||
BBC.WORLDEDIT_OOM_ADMIN.send(player);
|
||||
}
|
||||
throw FaweException.LOW_MEMORY;
|
||||
throw FaweCache.LOW_MEMORY;
|
||||
}
|
||||
}
|
||||
// this.originalLimit = limit;
|
||||
@ -409,7 +410,7 @@ public class EditSessionBuilder {
|
||||
FaweRegionExtent regionExtent = null;
|
||||
if (allowedRegions != null) {
|
||||
if (allowedRegions.length == 0) {
|
||||
regionExtent = new NullExtent(this.extent, FaweException.NO_REGION);
|
||||
regionExtent = new NullExtent(this.extent, FaweCache.NO_REGION);
|
||||
} else {
|
||||
// this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||
if (allowedRegions.length == 1) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.web;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
@ -57,7 +58,7 @@ public class SchemSync implements Runnable {
|
||||
|
||||
private void close(Error error) throws IOException {
|
||||
this.clientSocket.getOutputStream().write(error.ordinal());
|
||||
throw FaweException.MANUAL;
|
||||
throw FaweCache.MANUAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,6 +25,7 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
@ -332,7 +333,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
public boolean cancel() {
|
||||
ExtentTraverser traverser = new ExtentTraverser<>(getExtent());
|
||||
NullExtent nullExtent = new NullExtent(world, FaweException.MANUAL);
|
||||
NullExtent nullExtent = new NullExtent(world, FaweCache.MANUAL);
|
||||
while (traverser != null) {
|
||||
Extent get = traverser.get();
|
||||
ExtentTraverser next = traverser.next();
|
||||
@ -2844,7 +2845,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ())) {
|
||||
throw FaweException.OUTSIDE_REGION;
|
||||
throw FaweCache.OUTSIDE_REGION;
|
||||
}
|
||||
}
|
||||
final Set<BlockVector2> chunks = region.getChunks();
|
||||
|
@ -29,7 +29,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
@ -82,7 +81,6 @@ public class BiomeCommands {
|
||||
public void biomeList(Actor actor,
|
||||
@ArgFlag(name = 'p', desc = "Page number.", def = "1")
|
||||
int page) {
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
|
||||
@ -99,8 +97,7 @@ public class BiomeCommands {
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
return paginationBox.create(page);
|
||||
}, null);
|
||||
actor.print(paginationBox.create(page));
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -30,7 +30,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
|
||||
@ -98,9 +97,8 @@ public class ChunkCommands {
|
||||
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
|
||||
final Region region = session.getSelection(world);
|
||||
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor,
|
||||
() -> new ChunkListPaginationBox(region).create(page),
|
||||
"Listing chunks for " + actor.getName());
|
||||
actor.print("Listing chunks for " + actor.getName());
|
||||
actor.print(new ChunkListPaginationBox(region).create(page));
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -24,6 +24,7 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
@ -135,7 +136,7 @@ public class ClipboardCommands {
|
||||
((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
|
||||
FaweLimit limit = actor.getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw FaweException.MAX_CHECKS;
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
actor.checkConfirmationRegion(() -> {
|
||||
session.setClipboard(null);
|
||||
@ -216,10 +217,10 @@ public class ClipboardCommands {
|
||||
long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
|
||||
FaweLimit limit = actor.getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw FaweException.MAX_CHECKS;
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw FaweException.MAX_CHANGES;
|
||||
throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
session.setClipboard(null);
|
||||
|
||||
@ -255,10 +256,10 @@ public class ClipboardCommands {
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = actor.getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw FaweException.MAX_CHECKS;
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw FaweException.MAX_CHANGES;
|
||||
throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
actor.checkConfirmationRegion(() -> {
|
||||
session.setClipboard(null);
|
||||
@ -378,19 +379,19 @@ public class ClipboardCommands {
|
||||
}
|
||||
url = FaweAPI.upload(target, format);
|
||||
}
|
||||
if (url == null) {
|
||||
BBC.GENERATING_LINK_FAILED.send(player);
|
||||
} else {
|
||||
String urlText = url.toString();
|
||||
if (Settings.IMP.WEB.SHORTEN_URLS) {
|
||||
try {
|
||||
urlText = MainUtil.getText("https://empcraft.com/s/?" + URLEncoder.encode(url.toString(), "UTF-8"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (url == null) {
|
||||
BBC.GENERATING_LINK_FAILED.send(player);
|
||||
} else {
|
||||
String urlText = url.toString();
|
||||
if (Settings.IMP.WEB.SHORTEN_URLS) {
|
||||
try {
|
||||
urlText = MainUtil.getText("https://empcraft.com/s/?" + URLEncoder.encode(url.toString(), "UTF-8"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
BBC.DOWNLOAD_LINK.send(player, urlText);
|
||||
}
|
||||
BBC.DOWNLOAD_LINK.send(player, urlText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ public class GeneralCommands {
|
||||
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
|
||||
int page,
|
||||
@Arg(desc = "Search query", variable = true)
|
||||
List<String> query) {
|
||||
List<String> query) throws Exception {
|
||||
String search = String.join(" ", query);
|
||||
if (search.length() <= 2) {
|
||||
actor.printError("Enter a longer search string (len > 2).");
|
||||
@ -263,8 +263,7 @@ public class GeneralCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, new ItemSearcher(search, blocksOnly, itemsOnly, page),
|
||||
"(Please wait... searching items.)");
|
||||
actor.print(new ItemSearcher(search, blocksOnly, itemsOnly, page).call());
|
||||
}
|
||||
|
||||
public static class ItemSearcher implements Callable<Component> {
|
||||
|
@ -30,6 +30,7 @@ import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
@ -410,7 +411,7 @@ public class RegionCommands {
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = fp.getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw FaweException.MAX_CHECKS;
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
|
@ -19,25 +19,25 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||
import com.boydti.fawe.object.function.QuadFunction;
|
||||
import com.boydti.fawe.object.schematic.MinecraftStructure;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
|
||||
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.ActorSaveClipboardEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
@ -59,6 +59,16 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.util.io.Closer;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@ -77,17 +87,14 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.regex.Pattern;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
//import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
||||
|
||||
@ -572,68 +579,109 @@ public class SchematicCommands {
|
||||
descFooter = "Note: Format is not fully verified until loading."
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.list")
|
||||
public void list(Actor actor,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "1")
|
||||
public void list(Actor actor, LocalSession session, @Arg(name = "filter", desc = "Filter for schematics", def = "all")
|
||||
String filter, @ArgFlag(name = 'f', desc = "Restricts by format.", def = "")
|
||||
String formatName,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "-1")
|
||||
int page,
|
||||
@Switch(name = 'd', desc = "Sort by date, oldest first")
|
||||
boolean oldFirst,
|
||||
@Switch(name = 'n', desc = "Sort by date, newest first")
|
||||
boolean newFirst,
|
||||
@ArgFlag(name = 'f', desc = "Restricts by format.")
|
||||
String formatName,
|
||||
@Arg(name = "filter", desc = "Filter for schematics", def = "all")
|
||||
String filter) throws WorldEditException {
|
||||
Arguments arguments
|
||||
) throws WorldEditException {
|
||||
if (oldFirst && newFirst) {
|
||||
throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest."));
|
||||
}
|
||||
final String saveDir = worldEdit.getConfiguration().saveDir;
|
||||
final int sortType = oldFirst ? -1 : newFirst ? 1 : 0;
|
||||
String pageCommand = arguments.get();
|
||||
if (pageCommand.contains("-p ")) {
|
||||
pageCommand = pageCommand.replaceAll("-p [0-9]+", "-p %page%");
|
||||
} else{
|
||||
pageCommand = pageCommand + " -p %page%";
|
||||
}
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
|
||||
final String pageCommand = actor.isPlayer()
|
||||
? "//schem list -p %page%" + (sortType == -1 ? " -d" : sortType == 1 ? " -n" : "") : null;
|
||||
String schemCmd = "/schematic";
|
||||
String loadSingle = schemCmd + " " + "load";
|
||||
String loadMulti = schemCmd + " " + "loadall";
|
||||
String unload = schemCmd + " " + "unload";
|
||||
String delete = schemCmd + " " + "delete";
|
||||
String list = schemCmd + " " + "list";
|
||||
String showCmd = schemCmd + " " + "show";
|
||||
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor,
|
||||
new SchematicListTask(saveDir, sortType, page, pageCommand, filter, formatName), "(Please wait... gathering schematic list.)");
|
||||
List<String> args = filter.isEmpty() ? Collections.emptyList() : Arrays.asList(filter.split(" "));
|
||||
|
||||
// UtilityCommands.list(dir, actor, args, page, -1, formatName, Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS, new RunnableVal3<Message, URI, String>() {
|
||||
// @Override
|
||||
// public void run(Message msg, URI uri, String relFilePath) {
|
||||
// boolean isDir = false;
|
||||
// boolean loaded = multi != null && multi.contains(uri);
|
||||
//
|
||||
// String name = relFilePath;
|
||||
// String uriStr = uri.toString();
|
||||
// if (uriStr.startsWith("file:/")) {
|
||||
// File file1 = new File(uri.getPath());
|
||||
// name = file1.getName();
|
||||
// try {
|
||||
// if (!MainUtil.isInSubDirectory(dir, file1)) {
|
||||
// throw new RuntimeException(new CommandException("Invalid path"));
|
||||
// }
|
||||
// } catch (IOException ignore) {}
|
||||
// if (file1.isDirectory()) {
|
||||
// isDir = true;
|
||||
// } else if (name.indexOf('.') != -1) {
|
||||
// name = name.substring(0, name.lastIndexOf('.'));
|
||||
// }
|
||||
// } // url
|
||||
//
|
||||
// msg.text(" - ");
|
||||
//
|
||||
// if (loaded) {
|
||||
// msg.text("[-]").command(unload + " " + relFilePath).tooltip("Unload");
|
||||
// } else {
|
||||
// msg.text("[+]").command(loadMulti + " " + relFilePath).tooltip("Add to clipboard");
|
||||
// }
|
||||
// if (!isDir) msg.text("[X]").suggest("/" + delete + " " + relFilePath).tooltip("Delete");
|
||||
// msg.text(name);
|
||||
// if (isDir) {
|
||||
// msg.command(list + " " + relFilePath).tooltip("List");
|
||||
// } else {
|
||||
// msg.command(loadSingle + " " + relFilePath).tooltip("Load");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
URIClipboardHolder multi = as(URIClipboardHolder.class, session.getExistingClipboard());
|
||||
|
||||
final boolean hasShow = false;
|
||||
|
||||
//If player forgot -p argument
|
||||
if (page == -1) {
|
||||
page = 1;
|
||||
if (args.size() != 0) {
|
||||
String lastArg = args.get(args.size() - 1);
|
||||
if (MathMan.isInteger(lastArg)) {
|
||||
page = Integer.parseInt(lastArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean playerFolder = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS;
|
||||
UUID uuid = playerFolder ? actor.getUniqueId() : null;
|
||||
List<File> files = UtilityCommands.getFiles(dir, actor, args, formatName, playerFolder, oldFirst, newFirst);
|
||||
List<Map.Entry<URI, String>> entries = UtilityCommands.filesToEntry(dir, files, uuid);
|
||||
|
||||
Function<URI, Boolean> isLoaded = multi == null ? f -> false : multi::contains;
|
||||
|
||||
List<Component> components = UtilityCommands.entryToComponent(dir, entries, isLoaded, new QuadFunction<String, String, UtilityCommands.URIType, Boolean, Component>() {
|
||||
@Override
|
||||
public Component apply(String name, String path, UtilityCommands.URIType type, Boolean loaded) {
|
||||
TextColor color = TextColor.GRAY;
|
||||
switch (type) {
|
||||
case URL:
|
||||
color = TextColor.DARK_GRAY;
|
||||
break;
|
||||
case FILE:
|
||||
color = TextColor.GREEN;
|
||||
break;
|
||||
case DIRECTORY:
|
||||
color = TextColor.GOLD;
|
||||
break;
|
||||
}
|
||||
|
||||
TextComponent.Builder msg = TextComponent.builder();
|
||||
|
||||
msg.append(TextComponent.of(" - ", color));
|
||||
|
||||
if (loaded) {
|
||||
msg.append(TextComponent.of("[-]", TextColor.RED)
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, unload + " " + path))
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Unload"))));
|
||||
} else {
|
||||
msg.append(TextComponent.of("[+]", TextColor.GREEN)
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, loadMulti + " " + path))
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Add to clipboard"))));
|
||||
}
|
||||
if (type != UtilityCommands.URIType.DIRECTORY) {
|
||||
msg.append(TextComponent.of("[X]", TextColor.DARK_RED).clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, delete + " " + path)));
|
||||
} else if (hasShow) {
|
||||
msg.append(TextComponent.of("[O]", TextColor.DARK_AQUA).clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, showCmd + " " + path)));
|
||||
}
|
||||
TextComponent msgElem = TextComponent.of(name, color);
|
||||
if (type != UtilityCommands.URIType.DIRECTORY) {
|
||||
msgElem.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, loadSingle + " " + path))
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Load")));
|
||||
} else {
|
||||
msgElem.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, list + " " + path))
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("List")));
|
||||
}
|
||||
msg.append(msgElem);
|
||||
|
||||
return msg.build();
|
||||
}
|
||||
});
|
||||
PaginationBox paginationBox = PaginationBox.fromStrings("Available schematics", pageCommand, components);
|
||||
actor.print(paginationBox.create(page));
|
||||
}
|
||||
|
||||
private static class SchematicLoadTask implements Callable<ClipboardHolder> {
|
||||
|
@ -19,17 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.DelegateConsumer;
|
||||
import com.boydti.fawe.object.RunnableVal3;
|
||||
import com.boydti.fawe.object.function.QuadFunction;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
@ -39,12 +38,11 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.SkipQueue;
|
||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||
import com.sk89q.worldedit.command.util.EntityRemover;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.command.util.SkipQueue;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
@ -65,13 +63,18 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent.Builder;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
@ -80,19 +83,18 @@ import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
|
||||
/**
|
||||
* Utility commands.
|
||||
@ -651,7 +653,7 @@ public class UtilityCommands {
|
||||
@CommandPermissions("worldedit.calc")
|
||||
public void calc(Actor actor,
|
||||
@Arg(desc = "Expression to evaluate", variable = true)
|
||||
List<String> input) {
|
||||
List<String> input) throws EvaluationException {
|
||||
Expression expression;
|
||||
try {
|
||||
expression = Expression.compile(String.join(" ", input));
|
||||
@ -660,12 +662,11 @@ public class UtilityCommands {
|
||||
"'%s' could not be parsed as a valid expression", input));
|
||||
return;
|
||||
}
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
||||
double result = expression.evaluate(
|
||||
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
||||
String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result);
|
||||
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
|
||||
}, null);
|
||||
double result = expression.evaluate(
|
||||
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
||||
String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result);
|
||||
TextComponent msg = SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
|
||||
actor.print(msg);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -695,36 +696,64 @@ public class UtilityCommands {
|
||||
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "//help");
|
||||
}
|
||||
|
||||
public static void list(File dir, Actor actor, List<String> args, @Range(min = 0) int page, String formatName, boolean playerFolder, String onClickCmd) {
|
||||
list(dir, actor, args, page, -1, formatName, playerFolder, false, false, new RunnableVal3<Builder, URI, String>() {
|
||||
@Override
|
||||
public void run(Builder m, URI uri, String fileName) {
|
||||
m.append(BBC.SCHEMATIC_LIST_ELEM.format(fileName, ""));
|
||||
if (onClickCmd != null) { m.hoverEvent(HoverEvent.showText(TextComponent.of(onClickCmd + " " + fileName)))
|
||||
.clickEvent(ClickEvent.runCommand(onClickCmd + " " + fileName));
|
||||
}
|
||||
}
|
||||
public static List<Map.Entry<URI, String>> filesToEntry(final File root, final List<File> files, final UUID uuid) {
|
||||
return Lists.transform(files, input -> { // Keep this functional, as transform is evaluated lazily
|
||||
URI uri = input.toURI();
|
||||
String path = getPath(root, input, uuid);
|
||||
return new AbstractMap.SimpleEntry<>(uri, path);
|
||||
});
|
||||
}
|
||||
|
||||
public static void list(File dir, Actor actor, List<String> args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, boolean oldFirst, boolean newFirst, RunnableVal3<Builder, URI, String> eachMsg) {
|
||||
List<File> fileList = new ArrayList<>();
|
||||
if (perPage == -1) perPage = actor instanceof Player ? 12 : 20; // More pages for console
|
||||
page = getFiles(dir, actor, args, page, perPage, formatName, playerFolder, fileList::add);
|
||||
public static enum URIType {
|
||||
URL,
|
||||
FILE,
|
||||
DIRECTORY,
|
||||
OTHER
|
||||
}
|
||||
|
||||
public static List<Component> entryToComponent(File root, List<Map.Entry<URI, String>> entries, Function<URI, Boolean> isLoaded, QuadFunction<String, String, URIType, Boolean, Component> adapter) {
|
||||
return Lists.transform(entries, input -> {
|
||||
URI uri = input.getKey();
|
||||
String path = input.getValue();
|
||||
|
||||
boolean url = false;
|
||||
boolean loaded = isLoaded.apply(uri);
|
||||
|
||||
URIType type = URIType.FILE;
|
||||
|
||||
String name = path;
|
||||
String uriStr = uri.toString();
|
||||
if (uriStr.startsWith("file:/")) {
|
||||
File file = new File(uri.getPath());
|
||||
name = file.getName();
|
||||
if (file.isDirectory()) {
|
||||
type = URIType.DIRECTORY;
|
||||
} else {
|
||||
if (name.indexOf('.') != -1) name = name.substring(0, name.lastIndexOf('.'));
|
||||
}
|
||||
try {
|
||||
if (!MainUtil.isInSubDirectory(root, file)) {
|
||||
throw new RuntimeException(new CommandException("Invalid path"));
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
} else if (uriStr.startsWith("http://") || uriStr.startsWith("https://")) {
|
||||
type = URIType.URL;
|
||||
} else {
|
||||
type = URIType.OTHER;
|
||||
}
|
||||
|
||||
return adapter.apply(name, path, type, loaded);
|
||||
});
|
||||
}
|
||||
|
||||
public static List<File> getFiles(File dir, Actor actor, List<String> args, String formatName, boolean playerFolder, boolean oldFirst, boolean newFirst) {
|
||||
List<File> fileList = new LinkedList<>();
|
||||
getFiles(dir, actor, args, formatName, playerFolder, fileList::add);
|
||||
|
||||
if (fileList.isEmpty()) {
|
||||
BBC.SCHEMATIC_NONE.send(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
int pageCount = (fileList.size() + perPage - 1) / perPage;
|
||||
if (page < 1) {
|
||||
BBC.SCHEMATIC_PAGE.send(actor, ">0");
|
||||
return;
|
||||
}
|
||||
if (page > pageCount) {
|
||||
BBC.SCHEMATIC_PAGE.send(actor, "<" + (pageCount + 1));
|
||||
return;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final int sortType = oldFirst ? -1 : newFirst ? 1 : 0;
|
||||
@ -750,30 +779,10 @@ public class UtilityCommands {
|
||||
return res;
|
||||
});
|
||||
|
||||
int offset = (page - 1) * perPage;
|
||||
|
||||
int limit = Math.min(offset + perPage, fileList.size());
|
||||
|
||||
// String fullArgs = (String) args.getLocals().get("arguments");
|
||||
// String baseCmd = null;
|
||||
// if (fullArgs != null) {
|
||||
// baseCmd = fullArgs.endsWith(" " + page) ? fullArgs.substring(0, fullArgs.length() - (" " + page).length()) : fullArgs;
|
||||
// }
|
||||
@NotNull Builder m = TextComponent.builder(BBC.SCHEMATIC_LIST.format(page, pageCount));
|
||||
|
||||
UUID uuid = playerFolder ? actor.getUniqueId() : null;
|
||||
for (int i = offset; i < limit; i++) {
|
||||
m.append(newline());
|
||||
File file = fileList.get(i);
|
||||
eachMsg.run(m, file.toURI(), getPath(dir, file, uuid));
|
||||
}
|
||||
// if (baseCmd != null) {
|
||||
// //TODO m.newline().paginate(baseCmd, page, pageCount);
|
||||
// }
|
||||
actor.print(m.build());
|
||||
return fileList;
|
||||
}
|
||||
|
||||
public static int getFiles(File dir, Actor actor, List<String> args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
|
||||
public static void getFiles(File dir, Actor actor, List<String> args, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
|
||||
Consumer<File> rootFunction = forEachFile;
|
||||
//schem list all <path>
|
||||
|
||||
@ -785,10 +794,6 @@ public class UtilityCommands {
|
||||
boolean listMine = false;
|
||||
boolean listGlobal = !Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS;
|
||||
if (len > 0) {
|
||||
int max = len;
|
||||
if (MathMan.isInteger(args.get(len - 1))) {
|
||||
page = Integer.parseInt(args.get(--len));
|
||||
}
|
||||
for (int i = 0; i < len; i++) {
|
||||
String arg = "";
|
||||
switch (arg.toLowerCase()) {
|
||||
@ -872,7 +877,7 @@ public class UtilityCommands {
|
||||
public void accept(File f) {
|
||||
try {
|
||||
if (f.isDirectory()) {
|
||||
UUID uuid = UUID.fromString(f.getName());
|
||||
UUID.fromString(f.getName());
|
||||
return;
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
@ -889,7 +894,6 @@ public class UtilityCommands {
|
||||
List<File> result = filter(toFilter, filters);
|
||||
for (File file : result) rootFunction.accept(file);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
private static List<File> filter(List<File> fileList, List<String> filters) {
|
||||
@ -946,7 +950,7 @@ public class UtilityCommands {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPath(File root, File file, UUID uuid) {
|
||||
public static String getPath(File root, File file, UUID uuid) {
|
||||
File dir;
|
||||
if (uuid != null) {
|
||||
dir = new File(root, uuid.toString());
|
||||
|
@ -99,7 +99,6 @@ public class ProvideBindings extends Bindings {
|
||||
if (extent != null) {
|
||||
return extent;
|
||||
}
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
|
||||
Player plr = getPlayer(actor);
|
||||
EditSession editSession = editSession(getLocalSession(plr), plr);
|
||||
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.inventory;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
@ -106,10 +107,10 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
blockBag.fetchPlacedBlock(block.toImmutableState());
|
||||
} catch (UnplaceableBlockException e) {
|
||||
throw FaweException.BLOCK_BAG;
|
||||
throw FaweCache.BLOCK_BAG;
|
||||
} catch (BlockBagException e) {
|
||||
missingBlocks[block.getBlockType().getInternalId()]++;
|
||||
throw FaweException.BLOCK_BAG;
|
||||
throw FaweCache.BLOCK_BAG;
|
||||
}
|
||||
}
|
||||
if (mine) {
|
||||
|
@ -670,7 +670,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
int bx = chunk.getX() << 4;
|
||||
int bz = chunk.getZ() << 4;
|
||||
int tx = bx + 15;
|
||||
|
@ -265,7 +265,17 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
||||
contains(tx, ty, tz);
|
||||
}
|
||||
|
||||
default IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
default boolean containsChunk(int chunkX, int chunkZ) {
|
||||
int bx = chunkX << 4;
|
||||
int bz = chunkZ << 4;
|
||||
int tx = bx + 15;
|
||||
int tz = bz + 15;
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
return tx >= min.getX() && bx <= max.getX() && tx >= min.getZ() && bx <= max.getZ();
|
||||
}
|
||||
|
||||
default IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
int bx = chunk.getX() << 4;
|
||||
int bz = chunk.getZ() << 4;
|
||||
int tx = bx + 15;
|
||||
|
@ -155,7 +155,7 @@ public class RegionIntersection extends AbstractRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
int bx = chunk.getX() << 4;
|
||||
int bz = chunk.getZ() << 4;
|
||||
int tx = bx + 15;
|
||||
@ -164,7 +164,7 @@ public class RegionIntersection extends AbstractRegion {
|
||||
BlockVector3 regMin = region.getMinimumPoint();
|
||||
BlockVector3 regMax = region.getMaximumPoint();
|
||||
if (tx >= regMin.getX() && bx <= regMax.getX() && tz >= regMin.getZ() && bz <= regMax.getZ()) {
|
||||
return region.processBatch(chunk, get, set);
|
||||
return region.processSet(chunk, get, set);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.util.formatting.component;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
@ -31,7 +32,10 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.CommandParameters;
|
||||
import org.enginehub.piston.NoInputCommandParameters;
|
||||
import org.enginehub.piston.config.ColorConfig;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.part.CommandPart;
|
||||
import org.enginehub.piston.util.HelpGenerator;
|
||||
|
||||
/**
|
||||
|
@ -168,7 +168,10 @@ public abstract class PaginationBox extends MessageBox {
|
||||
iterIndex++;
|
||||
} while (iterIndex < number);
|
||||
}
|
||||
return TextComponent.of(obj.toString());
|
||||
if (obj instanceof Component) {
|
||||
return (Component) obj;
|
||||
}
|
||||
return TextComponent.of(obj + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren