schem list is still broken

clickEvent and hoverEvent don't seem to work, I'm probably doing something wrong
Dieser Commit ist enthalten in:
Jesse Boyd 2019-10-23 15:35:04 +01:00
Ursprung d904270a3d
Commit 8768085479
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
42 geänderte Dateien mit 394 neuen und 256 gelöschten Zeilen

Datei anzeigen

@ -1,9 +1,13 @@
package com.boydti.fawe; package com.boydti.fawe;
import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.beta.Trimable;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.CleanableThreadLocal; 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.IOUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.ByteArrayTag;
@ -180,6 +184,24 @@ public enum FaweCache implements Trimable {
return pool; 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<>(() -> { public final CleanableThreadLocal<int[]> BLOCK_TO_PALETTE = new CleanableThreadLocal<>(() -> {
int[] result = new int[BlockTypes.states.length]; int[] result = new int[BlockTypes.states.length];
Arrays.fill(result, Integer.MAX_VALUE); Arrays.fill(result, Integer.MAX_VALUE);

Datei anzeigen

@ -20,7 +20,11 @@ public interface IBatchProcessor {
* @param set * @param set
* @return * @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 * Convert this processor into an Extent based processor instead of a queue batch based on

Datei anzeigen

@ -10,7 +10,7 @@ public enum EmptyBatchProcessor implements IBatchProcessor {
INSTANCE INSTANCE
; ;
@Override @Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) { public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
return set; return set;
} }

Datei anzeigen

@ -20,8 +20,13 @@ public interface IBatchProcessorHolder extends IBatchProcessor {
void setProcessor(IBatchProcessor set); void setProcessor(IBatchProcessor set);
@Override @Override
default IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) { default IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
return getProcessor().processBatch(chunk, get, set); return getProcessor().processSet(chunk, get, set);
}
@Override
default boolean processGet(int chunkX, int chunkZ) {
return getProcessor().processGet(chunkX, chunkZ);
} }
@Override @Override

Datei anzeigen

@ -10,7 +10,6 @@ import com.sk89q.worldedit.extent.Extent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
public class MultiBatchProcessor implements IBatchProcessor { public class MultiBatchProcessor implements IBatchProcessor {
private IBatchProcessor[] processors; private IBatchProcessor[] processors;
@ -55,9 +54,9 @@ public class MultiBatchProcessor implements IBatchProcessor {
} }
@Override @Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) { public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
for (IBatchProcessor processor : this.processors) { for (IBatchProcessor processor : this.processors) {
set = processor.processBatch(chunk, get, set); set = processor.processSet(chunk, get, set);
if (set == null) { if (set == null) {
return null; return null;
} }
@ -65,6 +64,16 @@ public class MultiBatchProcessor implements IBatchProcessor {
return set; 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 @Override
public Extent construct(Extent child) { public Extent construct(Extent child) {
for (IBatchProcessor processor : processors) { for (IBatchProcessor processor : processors) {

Datei anzeigen

@ -1,6 +1,7 @@
package com.boydti.fawe.beta.implementation; package com.boydti.fawe.beta.implementation;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.CharFilterBlock; import com.boydti.fawe.beta.CharFilterBlock;
import com.boydti.fawe.beta.ChunkFilterBlock; import com.boydti.fawe.beta.ChunkFilterBlock;
import com.boydti.fawe.beta.IBatchProcessor; 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.beta.implementation.holder.ReferenceChunk;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.changeset.FaweChangeSet; 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.MathMan;
import com.boydti.fawe.util.MemUtil; import com.boydti.fawe.util.MemUtil;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
@ -219,6 +221,9 @@ public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQu
@Override @Override
public final IChunk getOrCreateChunk(int x, int z) { public final IChunk getOrCreateChunk(int x, int z) {
if (!processGet(x, z)) {
throw FaweCache.CHUNK;
}
final long pair = (long) x << 32 | z & 0xffffffffL; final long pair = (long) x << 32 | z & 0xffffffffL;
if (pair == lastPair) { if (pair == lastPair) {
return lastChunk; return lastChunk;

Datei anzeigen

@ -414,7 +414,7 @@ public class ChunkHolder<T extends Future<T>> implements IChunk {
public T call(IChunkSet set, Runnable finalize) { public T call(IChunkSet set, Runnable finalize) {
if (set != null) { if (set != null) {
IChunkGet get = getOrCreateGet(); IChunkGet get = getOrCreateGet();
set = getExtent().processBatch(this, get, set); set = getExtent().processSet(this, get, set);
if (set != null) { if (set != null) {
return get.call(set, finalize); return get.call(set, finalize);
} }

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.jnbt; package com.boydti.fawe.jnbt;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
@ -40,7 +41,7 @@ public class NBTStreamer {
try { try {
is.readNamedTagLazy(node -> { is.readNamedTagLazy(node -> {
if (readers.isEmpty()) { if (readers.isEmpty()) {
throw FaweException.MANUAL; throw FaweCache.MANUAL;
} }
return readers.remove(node); return readers.remove(node);
}); });

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
@ -62,7 +63,7 @@ public class SplineBrush implements Brush, ResettableTool {
this.position = position; this.position = position;
if (newPos) { if (newPos) {
if (positionSets.size() >= MAX_POINTS) { if (positionSets.size() >= MAX_POINTS) {
throw FaweException.MAX_CHECKS; throw FaweCache.MAX_CHECKS;
} }
final ArrayList<BlockVector3> points = new ArrayList<>(); final ArrayList<BlockVector3> points = new ArrayList<>();
if (size > 0) { if (size > 0) {

Datei anzeigen

@ -14,6 +14,7 @@ import com.boydti.fawe.object.collection.DifferentialArray;
import com.boydti.fawe.object.collection.DifferentialBlockBuffer; import com.boydti.fawe.object.collection.DifferentialBlockBuffer;
import com.boydti.fawe.object.collection.LocalBlockVector2DSet; import com.boydti.fawe.object.collection.LocalBlockVector2DSet;
import com.boydti.fawe.object.collection.SummedAreaTable; 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.exception.FaweException;
import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.CachedTextureUtil;
@ -883,14 +884,14 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
@Override @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; int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea()); if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
return BiomeTypes.get(biomes.getByte(index)); return BiomeTypes.get(biomes.getByte(index));
} }
// @Override // @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; int index = z * getWidth() + x;
if (y < 0) return 0; if (y < 0) return 0;
if (index < 0 || index >= getArea() || x < 0 || x >= getWidth()) return 0; if (index < 0 || index >= getArea() || x < 0 || x >= getWidth()) return 0;

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.object.changeset; package com.boydti.fawe.object.changeset;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -87,10 +88,10 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
try { try {
blockBag.fetchPlacedBlock(typeTo.getDefaultState()); blockBag.fetchPlacedBlock(typeTo.getDefaultState());
} catch (UnplaceableBlockException e) { } catch (UnplaceableBlockException e) {
throw FaweException.BLOCK_BAG; throw FaweCache.BLOCK_BAG;
} catch (BlockBagException e) { } catch (BlockBagException e) {
missingBlocks[typeTo.getInternalId()]++; missingBlocks[typeTo.getInternalId()]++;
throw FaweException.BLOCK_BAG; throw FaweCache.BLOCK_BAG;
} }
} }
if (mine) { if (mine) {

Datei anzeigen

@ -134,7 +134,7 @@ public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor {
} }
@Override @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 bx = chunk.getX() << 4;
int bz = chunk.getZ() << 4; int bz = chunk.getZ() << 4;

Datei anzeigen

@ -9,6 +9,8 @@ import java.util.Spliterator;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -4,17 +4,6 @@ import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
public class FaweException extends RuntimeException { 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 // DEBUG
public static final FaweException _enableQueue; public static final FaweException _enableQueue;
public static final FaweException _disableQueue; public static final FaweException _disableQueue;
@ -55,22 +44,6 @@ public class FaweException extends RuntimeException {
return get(cause); 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 * Faster exception throwing/handling if you don't fill the stacktrace
* *

Datei anzeigen

@ -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 { public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
if (!contains(x, y, z)) { if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return false; 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) { public boolean setBiome(int x, int y, int z, BiomeType biome) {
if (!contains(x, y, z)) { if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return false; return false;
} }
@ -98,7 +98,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public BiomeType getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
if (!contains(position)) { if (!contains(position)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return null; return null;
} }
@ -109,7 +109,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public BiomeType getBiomeType(int x, int z) { public BiomeType getBiomeType(int x, int z) {
if (!contains(x, z)) { if (!contains(x, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return null; return null;
} }
@ -120,7 +120,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public BaseBlock getFullBlock(BlockVector3 position) { public BaseBlock getFullBlock(BlockVector3 position) {
if (!contains(position)) { if (!contains(position)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return BlockTypes.AIR.getDefaultState().toBaseBlock(); return BlockTypes.AIR.getDefaultState().toBaseBlock();
} }
@ -131,7 +131,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public BlockState getBlock(BlockVector3 position) { public BlockState getBlock(BlockVector3 position) {
if (!contains(position)) { if (!contains(position)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return BlockTypes.AIR.getDefaultState(); 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) { public int getBlockLight(int x, int y, int z) {
if (!contains(x, y, z)) { if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return 0; return 0;
} }
@ -153,7 +153,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public int getBrightness(int x, int y, int z) { public int getBrightness(int x, int y, int z) {
if (!contains(x, y, z)) { if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return 0; return 0;
} }
@ -164,7 +164,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public int getLight(int x, int y, int z) { public int getLight(int x, int y, int z) {
if (!contains(x, y, z)) { if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return 0; return 0;
} }
@ -175,7 +175,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public int getOpacity(int x, int y, int z) { public int getOpacity(int x, int y, int z) {
if (!contains(x, y, z)) { if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return 0; return 0;
} }
@ -186,7 +186,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public int getSkyLight(int x, int y, int z) { public int getSkyLight(int x, int y, int z) {
if (!contains(x, y, z)) { if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return 0; return 0;
} }
@ -198,7 +198,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public Entity createEntity(Location location, BaseEntity entity) { public Entity createEntity(Location location, BaseEntity entity) {
if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) { if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
if (!limit.MAX_FAILS()) { if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.OUTSIDE_REGION); WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
} }
return null; return null;
} }

Datei anzeigen

@ -50,7 +50,7 @@ public class HeightBoundExtent extends FaweRegionExtent implements IBatchProcess
} }
@Override @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)) { if (trimY(set, min, max) | trimNBT(set, this::contains)) {
return set; return set;
} }

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MemUtil; import com.boydti.fawe.util.MemUtil;
@ -26,7 +27,7 @@ public class MemoryCheckingExtent extends PassthroughExtent {
BBC.WORLDEDIT_OOM_ADMIN.send(this.player); BBC.WORLDEDIT_OOM_ADMIN.send(this.player);
} }
} }
WEManager.IMP.cancelEdit(this, FaweException.LOW_MEMORY); WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY);
} }
return super.getExtent(); return super.getExtent();
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionIntersection; import com.sk89q.worldedit.regions.RegionIntersection;
@ -50,6 +49,16 @@ public class MultiRegionExtent extends FaweRegionExtent {
return false; return false;
} }
@Override
public boolean processGet(int chunkX, int chunkZ) {
for (Region region : regions) {
if (region.containsChunk(chunkX, chunkZ)) {
return true;
}
}
return false;
}
@Override @Override
public boolean contains(int x, int z) { public boolean contains(int x, int z) {
if (region.contains(x, z)) { if (region.contains(x, z)) {
@ -74,7 +83,7 @@ public class MultiRegionExtent extends FaweRegionExtent {
} }
@Override @Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) { public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
return intersection.processBatch(chunk, get, set); return intersection.processSet(chunk, get, set);
} }
} }

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
@ -52,7 +53,7 @@ public class NullExtent extends FaweRegionExtent {
} }
public NullExtent() { public NullExtent() {
this(new com.sk89q.worldedit.extent.NullExtent(), FaweException.MANUAL); this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.MANUAL);
} }
@Override @Override
@ -326,7 +327,12 @@ public class NullExtent extends FaweRegionExtent {
} }
@Override @Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) { public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
return null; return null;
} }
@Override
public boolean processGet(int chunkX, int chunkZ) {
return false;
}
} }

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
@ -37,7 +38,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
return null; return null;
} }
if (!limit.MAX_ENTITIES()) { if (!limit.MAX_ENTITIES()) {
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_ENTITIES); WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_ENTITIES);
return null; return null;
} }
return super.createEntity(location, entity); return super.createEntity(location, entity);
@ -46,7 +47,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
if (!limit.MAX_CHECKS()) { if (!limit.MAX_CHECKS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHECKS); WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS);
return BlockTypes.AIR.getDefaultState(); return BlockTypes.AIR.getDefaultState();
} else { } else {
return extent.getBlock(x, y, z); return extent.getBlock(x, y, z);
@ -56,7 +57,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
@Override @Override
public BaseBlock getFullBlock(BlockVector3 pos) { public BaseBlock getFullBlock(BlockVector3 pos) {
if (!limit.MAX_CHECKS()) { if (!limit.MAX_CHECKS()) {
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHECKS); WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS);
return BlockTypes.AIR.getDefaultState().toBaseBlock(); return BlockTypes.AIR.getDefaultState().toBaseBlock();
} else { } else {
return extent.getFullBlock(pos); return extent.getFullBlock(pos);
@ -78,18 +79,18 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData(); boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
if (hasNbt) { if (hasNbt) {
if (!limit.MAX_BLOCKSTATES()) { if (!limit.MAX_BLOCKSTATES()) {
WEManager.IMP.cancelEdit(this, FaweException.MAX_TILES); WEManager.IMP.cancelEdit(this, FaweCache.MAX_TILES);
return false; return false;
} else { } else {
if (!limit.MAX_CHANGES()) { if (!limit.MAX_CHANGES()) {
WEManager.IMP.cancelEdit(this, FaweException.MAX_CHANGES); WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES);
return false; return false;
} }
return extent.setBlock(x, y, z, block); return extent.setBlock(x, y, z, block);
} }
} }
if (!limit.MAX_CHANGES()) { if (!limit.MAX_CHANGES()) {
WEManager.IMP.cancelEdit(this, FaweException.MAX_CHANGES); WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES);
return false; return false;
} else { } else {
return extent.setBlock(x, y, z, block); return extent.setBlock(x, y, z, block);
@ -99,7 +100,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBiome(BlockVector2 position, BiomeType biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
if (!limit.MAX_CHANGES()) { if (!limit.MAX_CHANGES()) {
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHANGES); WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHANGES);
return false; return false;
} }
return super.setBiome(position, biome); return super.setBiome(position, biome);

Datei anzeigen

@ -6,7 +6,7 @@ import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -40,7 +40,12 @@ public class SingleRegionExtent extends FaweRegionExtent {
} }
@Override @Override
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) { public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
return region.processBatch(chunk, get, set); return region.processSet(chunk, get, set);
}
@Override
public boolean processGet(int chunkX, int chunkZ) {
return region.containsChunk(chunkX, chunkZ);
} }
} }

Datei anzeigen

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

Datei anzeigen

@ -551,13 +551,13 @@
// public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ } // public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ }
// //
// @Override // @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) // // TODO later (currently not used)
// return BiomeTypes.FOREST; // return BiomeTypes.FOREST;
// } // }
// //
// @Override // @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); // MCAChunk chunk = getChunk(x >> 4, z >> 4);
// if (y < 0 || y > 255) return 0; // if (y < 0 || y > 255) return 0;
// return chunk.getBlockCombinedId(x & 15, y, z & 15); // return chunk.getBlockCombinedId(x & 15, y, z & 15);

Datei anzeigen

@ -2,6 +2,7 @@ package com.boydti.fawe.util;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.ParallelQueueExtent; import com.boydti.fawe.beta.implementation.ParallelQueueExtent;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
@ -223,11 +224,11 @@ public class EditSessionBuilder {
event.setExtent(extent); event.setExtent(extent);
eventBus.post(event); eventBus.post(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return new NullExtent(extent, FaweException.MANUAL); return new NullExtent(extent, FaweCache.MANUAL);
} }
final Extent toReturn = event.getExtent(); final Extent toReturn = event.getExtent();
if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) { if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
return new NullExtent(toReturn, FaweException.MANUAL); return new NullExtent(toReturn, FaweCache.MANUAL);
} }
// if (!(toReturn instanceof AbstractDelegateExtent)) { // if (!(toReturn instanceof AbstractDelegateExtent)) {
// Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent"); // Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
@ -307,7 +308,7 @@ public class EditSessionBuilder {
if (Permission.hasPermission(player, "worldedit.fast")) { if (Permission.hasPermission(player, "worldedit.fast")) {
BBC.WORLDEDIT_OOM_ADMIN.send(player); BBC.WORLDEDIT_OOM_ADMIN.send(player);
} }
throw FaweException.LOW_MEMORY; throw FaweCache.LOW_MEMORY;
} }
} }
// this.originalLimit = limit; // this.originalLimit = limit;
@ -409,7 +410,7 @@ public class EditSessionBuilder {
FaweRegionExtent regionExtent = null; FaweRegionExtent regionExtent = null;
if (allowedRegions != null) { if (allowedRegions != null) {
if (allowedRegions.length == 0) { if (allowedRegions.length == 0) {
regionExtent = new NullExtent(this.extent, FaweException.NO_REGION); regionExtent = new NullExtent(this.extent, FaweCache.NO_REGION);
} else { } else {
// this.extent = new ProcessedWEExtent(this.extent, this.limit); // this.extent = new ProcessedWEExtent(this.extent, this.limit);
if (allowedRegions.length == 1) { if (allowedRegions.length == 1) {

Datei anzeigen

@ -1,6 +1,7 @@
package com.boydti.fawe.web; package com.boydti.fawe.web;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
@ -57,7 +58,7 @@ public class SchemSync implements Runnable {
private void close(Error error) throws IOException { private void close(Error error) throws IOException {
this.clientSocket.getOutputStream().write(error.ordinal()); this.clientSocket.getOutputStream().write(error.ordinal());
throw FaweException.MANUAL; throw FaweCache.MANUAL;
} }
@Override @Override

Datei anzeigen

@ -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.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY; import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
@ -332,7 +333,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
public boolean cancel() { public boolean cancel() {
ExtentTraverser traverser = new ExtentTraverser<>(getExtent()); ExtentTraverser traverser = new ExtentTraverser<>(getExtent());
NullExtent nullExtent = new NullExtent(world, FaweException.MANUAL); NullExtent nullExtent = new NullExtent(world, FaweCache.MANUAL);
while (traverser != null) { while (traverser != null) {
Extent get = traverser.get(); Extent get = traverser.get();
ExtentTraverser next = traverser.next(); ExtentTraverser next = traverser.next();
@ -2844,7 +2845,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ())) { 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(); final Set<BlockVector2> chunks = region.getChunks();

Datei anzeigen

@ -29,7 +29,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
@ -82,7 +81,6 @@ public class BiomeCommands {
public void biomeList(Actor actor, public void biomeList(Actor actor,
@ArgFlag(name = 'p', desc = "Page number.", def = "1") @ArgFlag(name = 'p', desc = "Page number.", def = "1")
int page) { int page) {
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
@ -99,8 +97,7 @@ public class BiomeCommands {
} }
}) })
.collect(Collectors.toList())); .collect(Collectors.toList()));
return paginationBox.create(page); actor.print(paginationBox.create(page));
}, null);
} }
@Command( @Command(

Datei anzeigen

@ -30,7 +30,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.anvil.ChunkDeleter; 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 { @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
final Region region = session.getSelection(world); final Region region = session.getSelection(world);
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, actor.print("Listing chunks for " + actor.getName());
() -> new ChunkListPaginationBox(region).create(page), actor.print(new ChunkListPaginationBox(region).create(page));
"Listing chunks for " + actor.getName());
} }
@Command( @Command(

Datei anzeigen

@ -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 static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; 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); ((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(); FaweLimit limit = actor.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweCache.MAX_CHECKS;
} }
actor.checkConfirmationRegion(() -> { actor.checkConfirmationRegion(() -> {
session.setClipboard(null); 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); 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(); FaweLimit limit = actor.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweCache.MAX_CHECKS;
} }
if (volume >= limit.MAX_CHANGES) { if (volume >= limit.MAX_CHANGES) {
throw FaweException.MAX_CHANGES; throw FaweCache.MAX_CHANGES;
} }
session.setClipboard(null); 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)); 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(); FaweLimit limit = actor.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweCache.MAX_CHECKS;
} }
if (volume >= limit.MAX_CHANGES) { if (volume >= limit.MAX_CHANGES) {
throw FaweException.MAX_CHANGES; throw FaweCache.MAX_CHANGES;
} }
actor.checkConfirmationRegion(() -> { actor.checkConfirmationRegion(() -> {
session.setClipboard(null); session.setClipboard(null);
@ -378,6 +379,7 @@ public class ClipboardCommands {
} }
url = FaweAPI.upload(target, format); url = FaweAPI.upload(target, format);
} }
}
if (url == null) { if (url == null) {
BBC.GENERATING_LINK_FAILED.send(player); BBC.GENERATING_LINK_FAILED.send(player);
} else { } else {
@ -392,7 +394,6 @@ public class ClipboardCommands {
BBC.DOWNLOAD_LINK.send(player, urlText); BBC.DOWNLOAD_LINK.send(player, urlText);
} }
} }
}
@Command( @Command(
name = "asset", name = "asset",

Datei anzeigen

@ -252,7 +252,7 @@ public class GeneralCommands {
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1") @ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
int page, int page,
@Arg(desc = "Search query", variable = true) @Arg(desc = "Search query", variable = true)
List<String> query) { List<String> query) throws Exception {
String search = String.join(" ", query); String search = String.join(" ", query);
if (search.length() <= 2) { if (search.length() <= 2) {
actor.printError("Enter a longer search string (len > 2)."); actor.printError("Enter a longer search string (len > 2).");
@ -263,8 +263,7 @@ public class GeneralCommands {
return; return;
} }
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, new ItemSearcher(search, blocksOnly, itemsOnly, page), actor.print(new ItemSearcher(search, blocksOnly, itemsOnly, page).call());
"(Please wait... searching items.)");
} }
public static class ItemSearcher implements Callable<Component> { public static class ItemSearcher implements Callable<Component> {

Datei anzeigen

@ -30,6 +30,7 @@ import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY; import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException; 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)); 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(); FaweLimit limit = fp.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweCache.MAX_CHECKS;
} }
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
try { try {

Datei anzeigen

@ -19,25 +19,25 @@
package com.sk89q.worldedit.command; 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.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper; 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.object.schematic.MinecraftStructure;
import com.boydti.fawe.util.MainUtil; 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.google.common.collect.Multimap;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; 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.AsyncCommandBuilder;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.ActorSaveClipboardEvent; import com.sk89q.worldedit.event.extent.ActorSaveClipboardEvent;
import com.sk89q.worldedit.extension.platform.Actor; 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.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.Closer;
import com.sk89q.worldedit.util.io.file.FilenameException; 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.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
@ -77,17 +87,14 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import static com.boydti.fawe.util.ReflectionUtils.as;
import org.enginehub.piston.annotation.param.Arg; import static com.google.common.base.Preconditions.checkArgument;
import org.enginehub.piston.annotation.param.ArgFlag; import static com.google.common.base.Preconditions.checkNotNull;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.exception.StopExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import com.boydti.fawe.object.schematic.visualizer.SchemVis; //import com.boydti.fawe.object.schematic.visualizer.SchemVis;
@ -572,68 +579,109 @@ public class SchematicCommands {
descFooter = "Note: Format is not fully verified until loading." descFooter = "Note: Format is not fully verified until loading."
) )
@CommandPermissions("worldedit.schematic.list") @CommandPermissions("worldedit.schematic.list")
public void list(Actor actor, public void list(Actor actor, LocalSession session, @Arg(name = "filter", desc = "Filter for schematics", def = "all")
@ArgFlag(name = 'p', desc = "Page to view.", def = "1") String filter, @ArgFlag(name = 'f', desc = "Restricts by format.", def = "")
String formatName,
@ArgFlag(name = 'p', desc = "Page to view.", def = "-1")
int page, int page,
@Switch(name = 'd', desc = "Sort by date, oldest first") @Switch(name = 'd', desc = "Sort by date, oldest first")
boolean oldFirst, boolean oldFirst,
@Switch(name = 'n', desc = "Sort by date, newest first") @Switch(name = 'n', desc = "Sort by date, newest first")
boolean newFirst, boolean newFirst,
@ArgFlag(name = 'f', desc = "Restricts by format.") Arguments arguments
String formatName, ) throws WorldEditException {
@Arg(name = "filter", desc = "Filter for schematics", def = "all")
String filter) throws WorldEditException {
if (oldFirst && newFirst) { if (oldFirst && newFirst) {
throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest.")); throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest."));
} }
final String saveDir = worldEdit.getConfiguration().saveDir; String pageCommand = arguments.get();
final int sortType = oldFirst ? -1 : newFirst ? 1 : 0; 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() String schemCmd = "/schematic";
? "//schem list -p %page%" + (sortType == -1 ? " -d" : sortType == 1 ? " -n" : "") : null; 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, List<String> args = filter.isEmpty() ? Collections.emptyList() : Arrays.asList(filter.split(" "));
new SchematicListTask(saveDir, sortType, page, pageCommand, filter, formatName), "(Please wait... gathering schematic list.)");
// UtilityCommands.list(dir, actor, args, page, -1, formatName, Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS, new RunnableVal3<Message, URI, String>() { URIClipboardHolder multi = as(URIClipboardHolder.class, session.getExistingClipboard());
// @Override
// public void run(Message msg, URI uri, String relFilePath) { final boolean hasShow = false;
// boolean isDir = false;
// boolean loaded = multi != null && multi.contains(uri); //If player forgot -p argument
// if (page == -1) {
// String name = relFilePath; page = 1;
// String uriStr = uri.toString(); if (args.size() != 0) {
// if (uriStr.startsWith("file:/")) { String lastArg = args.get(args.size() - 1);
// File file1 = new File(uri.getPath()); if (MathMan.isInteger(lastArg)) {
// name = file1.getName(); page = Integer.parseInt(lastArg);
// try { }
// if (!MainUtil.isInSubDirectory(dir, file1)) { }
// throw new RuntimeException(new CommandException("Invalid path")); }
// } boolean playerFolder = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS;
// } catch (IOException ignore) {} UUID uuid = playerFolder ? actor.getUniqueId() : null;
// if (file1.isDirectory()) { List<File> files = UtilityCommands.getFiles(dir, actor, args, formatName, playerFolder, oldFirst, newFirst);
// isDir = true; List<Map.Entry<URI, String>> entries = UtilityCommands.filesToEntry(dir, files, uuid);
// } else if (name.indexOf('.') != -1) {
// name = name.substring(0, name.lastIndexOf('.')); Function<URI, Boolean> isLoaded = multi == null ? f -> false : multi::contains;
// }
// } // url List<Component> components = UtilityCommands.entryToComponent(dir, entries, isLoaded, new QuadFunction<String, String, UtilityCommands.URIType, Boolean, Component>() {
// @Override
// msg.text(" - "); public Component apply(String name, String path, UtilityCommands.URIType type, Boolean loaded) {
// TextColor color = TextColor.GRAY;
// if (loaded) { switch (type) {
// msg.text("[-]").command(unload + " " + relFilePath).tooltip("Unload"); case URL:
// } else { color = TextColor.DARK_GRAY;
// msg.text("[+]").command(loadMulti + " " + relFilePath).tooltip("Add to clipboard"); break;
// } case FILE:
// if (!isDir) msg.text("[X]").suggest("/" + delete + " " + relFilePath).tooltip("Delete"); color = TextColor.GREEN;
// msg.text(name); break;
// if (isDir) { case DIRECTORY:
// msg.command(list + " " + relFilePath).tooltip("List"); color = TextColor.GOLD;
// } else { break;
// msg.command(loadSingle + " " + relFilePath).tooltip("Load"); }
// }
// } 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> { private static class SchematicLoadTask implements Callable<ClipboardHolder> {

Datei anzeigen

@ -19,17 +19,16 @@
package com.sk89q.worldedit.command; 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.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer; 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.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.image.ImageUtil; 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.EditSession;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
@ -39,12 +38,11 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; 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.CreatureButcher;
import com.sk89q.worldedit.command.util.EntityRemover; import com.sk89q.worldedit.command.util.EntityRemover;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.command.util.PrintCommandHelp; 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.Entity;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; 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.CylinderRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat; 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;
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.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockTypes; 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.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
@ -80,19 +83,18 @@ import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.imageio.ImageIO;
import org.enginehub.piston.annotation.Command; import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
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;
/** /**
* Utility commands. * Utility commands.
@ -651,7 +653,7 @@ public class UtilityCommands {
@CommandPermissions("worldedit.calc") @CommandPermissions("worldedit.calc")
public void calc(Actor actor, public void calc(Actor actor,
@Arg(desc = "Expression to evaluate", variable = true) @Arg(desc = "Expression to evaluate", variable = true)
List<String> input) { List<String> input) throws EvaluationException {
Expression expression; Expression expression;
try { try {
expression = Expression.compile(String.join(" ", input)); expression = Expression.compile(String.join(" ", input));
@ -660,12 +662,11 @@ public class UtilityCommands {
"'%s' could not be parsed as a valid expression", input)); "'%s' could not be parsed as a valid expression", input));
return; return;
} }
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
double result = expression.evaluate( double result = expression.evaluate(
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout()); new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result); String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result);
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE)); TextComponent msg = SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
}, null); actor.print(msg);
} }
@Command( @Command(
@ -695,36 +696,64 @@ public class UtilityCommands {
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "//help"); 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) { public static List<Map.Entry<URI, String>> filesToEntry(final File root, final List<File> files, final UUID uuid) {
list(dir, actor, args, page, -1, formatName, playerFolder, false, false, new RunnableVal3<Builder, URI, String>() { return Lists.transform(files, input -> { // Keep this functional, as transform is evaluated lazily
@Override URI uri = input.toURI();
public void run(Builder m, URI uri, String fileName) { String path = getPath(root, input, uuid);
m.append(BBC.SCHEMATIC_LIST_ELEM.format(fileName, "")); return new AbstractMap.SimpleEntry<>(uri, path);
if (onClickCmd != null) { m.hoverEvent(HoverEvent.showText(TextComponent.of(onClickCmd + " " + fileName)))
.clickEvent(ClickEvent.runCommand(onClickCmd + " " + fileName));
}
}
}); });
} }
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) { public static enum URIType {
List<File> fileList = new ArrayList<>(); URL,
if (perPage == -1) perPage = actor instanceof Player ? 12 : 20; // More pages for console FILE,
page = getFiles(dir, actor, args, page, perPage, formatName, playerFolder, fileList::add); 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()) { if (fileList.isEmpty()) {
BBC.SCHEMATIC_NONE.send(actor); BBC.SCHEMATIC_NONE.send(actor);
return; return Collections.emptyList();
}
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;
} }
final int sortType = oldFirst ? -1 : newFirst ? 1 : 0; final int sortType = oldFirst ? -1 : newFirst ? 1 : 0;
@ -750,30 +779,10 @@ public class UtilityCommands {
return res; return res;
}); });
int offset = (page - 1) * perPage; return fileList;
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());
} }
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; Consumer<File> rootFunction = forEachFile;
//schem list all <path> //schem list all <path>
@ -785,10 +794,6 @@ public class UtilityCommands {
boolean listMine = false; boolean listMine = false;
boolean listGlobal = !Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS; boolean listGlobal = !Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS;
if (len > 0) { 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++) { for (int i = 0; i < len; i++) {
String arg = ""; String arg = "";
switch (arg.toLowerCase()) { switch (arg.toLowerCase()) {
@ -872,7 +877,7 @@ public class UtilityCommands {
public void accept(File f) { public void accept(File f) {
try { try {
if (f.isDirectory()) { if (f.isDirectory()) {
UUID uuid = UUID.fromString(f.getName()); UUID.fromString(f.getName());
return; return;
} }
} catch (IllegalArgumentException ignored) {} } catch (IllegalArgumentException ignored) {}
@ -889,7 +894,6 @@ public class UtilityCommands {
List<File> result = filter(toFilter, filters); List<File> result = filter(toFilter, filters);
for (File file : result) rootFunction.accept(file); for (File file : result) rootFunction.accept(file);
} }
return page;
} }
private static List<File> filter(List<File> fileList, List<String> filters) { 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; File dir;
if (uuid != null) { if (uuid != null) {
dir = new File(root, uuid.toString()); dir = new File(root, uuid.toString());

Datei anzeigen

@ -99,7 +99,6 @@ public class ProvideBindings extends Bindings {
if (extent != null) { if (extent != null) {
return extent; return extent;
} }
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
Player plr = getPlayer(actor); Player plr = getPlayer(actor);
EditSession editSession = editSession(getLocalSession(plr), plr); EditSession editSession = editSession(getLocalSession(plr), plr);
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession)); store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.extent.inventory; package com.sk89q.worldedit.extent.inventory;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
@ -106,10 +107,10 @@ public class BlockBagExtent extends AbstractDelegateExtent {
try { try {
blockBag.fetchPlacedBlock(block.toImmutableState()); blockBag.fetchPlacedBlock(block.toImmutableState());
} catch (UnplaceableBlockException e) { } catch (UnplaceableBlockException e) {
throw FaweException.BLOCK_BAG; throw FaweCache.BLOCK_BAG;
} catch (BlockBagException e) { } catch (BlockBagException e) {
missingBlocks[block.getBlockType().getInternalId()]++; missingBlocks[block.getBlockType().getInternalId()]++;
throw FaweException.BLOCK_BAG; throw FaweCache.BLOCK_BAG;
} }
} }
if (mine) { if (mine) {

Datei anzeigen

@ -670,7 +670,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
} }
@Override @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 bx = chunk.getX() << 4;
int bz = chunk.getZ() << 4; int bz = chunk.getZ() << 4;
int tx = bx + 15; int tx = bx + 15;

Datei anzeigen

@ -265,7 +265,17 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
contains(tx, ty, tz); 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 bx = chunk.getX() << 4;
int bz = chunk.getZ() << 4; int bz = chunk.getZ() << 4;
int tx = bx + 15; int tx = bx + 15;

Datei anzeigen

@ -155,7 +155,7 @@ public class RegionIntersection extends AbstractRegion {
} }
@Override @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 bx = chunk.getX() << 4;
int bz = chunk.getZ() << 4; int bz = chunk.getZ() << 4;
int tx = bx + 15; int tx = bx + 15;
@ -164,7 +164,7 @@ public class RegionIntersection extends AbstractRegion {
BlockVector3 regMin = region.getMinimumPoint(); BlockVector3 regMin = region.getMinimumPoint();
BlockVector3 regMax = region.getMaximumPoint(); BlockVector3 regMax = region.getMaximumPoint();
if (tx >= regMin.getX() && bx <= regMax.getX() && tz >= regMin.getZ() && bz <= regMax.getZ()) { 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; return null;

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.util.formatting.component;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands; import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
@ -31,7 +32,10 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.enginehub.piston.Command; import org.enginehub.piston.Command;
import org.enginehub.piston.CommandParameters; import org.enginehub.piston.CommandParameters;
import org.enginehub.piston.NoInputCommandParameters;
import org.enginehub.piston.config.ColorConfig; import org.enginehub.piston.config.ColorConfig;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.part.CommandPart;
import org.enginehub.piston.util.HelpGenerator; import org.enginehub.piston.util.HelpGenerator;
/** /**

Datei anzeigen

@ -168,7 +168,10 @@ public abstract class PaginationBox extends MessageBox {
iterIndex++; iterIndex++;
} while (iterIndex < number); } while (iterIndex < number);
} }
return TextComponent.of(obj.toString()); if (obj instanceof Component) {
return (Component) obj;
}
return TextComponent.of(obj + "");
} }
@Override @Override