Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-20 01:40:06 +01:00
feat: improve fawe limits
- add FaweLimit implementations for increasing concurrency levels - allow FaweLimit to perform processing (and forcefully disable as required) to capture [tile] entities - Use `BlockVector3#set(Extent orDefault)` where appropriate to reduce block checks - fixes #2679 - fixes #1874
Dieser Commit ist enthalten in:
Ursprung
ee5d1caa2c
Commit
a5b2a4e968
@ -192,17 +192,22 @@ public enum FaweCache implements Trimable {
|
|||||||
Type.OUTSIDE_REGION
|
Type.OUTSIDE_REGION
|
||||||
);
|
);
|
||||||
public static final FaweException MAX_CHECKS = new FaweException(
|
public static final FaweException MAX_CHECKS = new FaweException(
|
||||||
Caption.of("fawe.cancel.reason.max" + ".checks"),
|
Caption.of("fawe.cancel.reason.max.checks"),
|
||||||
|
Type.MAX_CHECKS,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
public static final FaweException MAX_FAILS = new FaweException(
|
||||||
|
Caption.of("fawe.cancel.reason.max.fails"),
|
||||||
Type.MAX_CHECKS,
|
Type.MAX_CHECKS,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
public static final FaweException MAX_CHANGES = new FaweException(
|
public static final FaweException MAX_CHANGES = new FaweException(
|
||||||
Caption.of("fawe.cancel.reason.max" + ".changes"),
|
Caption.of("fawe.cancel.reason.max.changes"),
|
||||||
Type.MAX_CHANGES,
|
Type.MAX_CHANGES,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
public static final FaweException LOW_MEMORY = new FaweException(
|
public static final FaweException LOW_MEMORY = new FaweException(
|
||||||
Caption.of("fawe.cancel.reason.low" + ".memory"),
|
Caption.of("fawe.cancel.reason.low.memory"),
|
||||||
Type.LOW_MEMORY,
|
Type.LOW_MEMORY,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.fastasyncworldedit.core.extension.platform.binding;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
|
||||||
|
public record EditSessionHolder(EditSession session) {
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,11 @@ package com.fastasyncworldedit.core.extension.platform.binding;
|
|||||||
import com.fastasyncworldedit.core.configuration.Caption;
|
import com.fastasyncworldedit.core.configuration.Caption;
|
||||||
import com.fastasyncworldedit.core.database.DBHandler;
|
import com.fastasyncworldedit.core.database.DBHandler;
|
||||||
import com.fastasyncworldedit.core.database.RollbackDatabase;
|
import com.fastasyncworldedit.core.database.RollbackDatabase;
|
||||||
|
import com.fastasyncworldedit.core.extent.LimitExtent;
|
||||||
|
import com.fastasyncworldedit.core.extent.processor.ExtentBatchProcessorHolder;
|
||||||
|
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||||
import com.fastasyncworldedit.core.regions.FaweMaskManager;
|
import com.fastasyncworldedit.core.regions.FaweMaskManager;
|
||||||
|
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||||
import com.fastasyncworldedit.core.util.TextureUtil;
|
import com.fastasyncworldedit.core.util.TextureUtil;
|
||||||
import com.fastasyncworldedit.core.util.image.ImageUtil;
|
import com.fastasyncworldedit.core.util.image.ImageUtil;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -11,6 +15,7 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.command.argument.Arguments;
|
import com.sk89q.worldedit.command.argument.Arguments;
|
||||||
import com.sk89q.worldedit.command.util.annotation.AllowedRegion;
|
import com.sk89q.worldedit.command.util.annotation.AllowedRegion;
|
||||||
|
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -25,6 +30,7 @@ import org.enginehub.piston.inject.Key;
|
|||||||
import org.enginehub.piston.util.ValueProvider;
|
import org.enginehub.piston.util.ValueProvider;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -52,11 +58,33 @@ public class ProvideBindings extends Bindings {
|
|||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
public EditSession editSession(LocalSession localSession, Actor actor, InjectedValueAccess context) {
|
public EditSession editSession(LocalSession localSession, Actor actor, InjectedValueAccess context) {
|
||||||
|
Method commandMethod =
|
||||||
|
context.injectedValue(Key.of(InjectedValueStore.class)).get().injectedValue(Key.of(Method.class)).get();
|
||||||
|
|
||||||
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
|
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
|
||||||
String command = arguments == null ? null : arguments.get();
|
String command = arguments == null ? null : arguments.get();
|
||||||
EditSession editSession = localSession.createEditSession(actor, command);
|
boolean synchronousSetting = commandMethod.getAnnotation(SynchronousSettingExpected.class) != null;
|
||||||
editSession.enableStandardMode();
|
EditSessionHolder holder = context.injectedValue(Key.of(EditSessionHolder.class)).orElse(null);
|
||||||
Request.request().setEditSession(editSession);
|
EditSession editSession = holder != null ? holder.session() : null;
|
||||||
|
if (editSession == null) {
|
||||||
|
editSession = localSession.createEditSession(actor, command, synchronousSetting);
|
||||||
|
editSession.enableStandardMode();
|
||||||
|
} else {
|
||||||
|
LimitExtent limitExtent = new ExtentTraverser<>(editSession).findAndGet(LimitExtent.class);
|
||||||
|
if (limitExtent != null) {
|
||||||
|
limitExtent.setProcessing(!synchronousSetting);
|
||||||
|
if (!synchronousSetting) {
|
||||||
|
ExtentBatchProcessorHolder processorHolder = new ExtentTraverser<>(editSession).findAndGet(
|
||||||
|
ExtentBatchProcessorHolder.class);
|
||||||
|
if (processorHolder != null) {
|
||||||
|
processorHolder.addProcessor(limitExtent);
|
||||||
|
} else {
|
||||||
|
throw new FaweException(Caption.of("fawe.error.no-process-non-synchronous-edit"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Request.request().setEditSession(editSession);
|
||||||
|
}
|
||||||
return editSession;
|
return editSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package com.fastasyncworldedit.core.extent;
|
package com.fastasyncworldedit.core.extent;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.filter.block.ExtentFilterBlock;
|
import com.fastasyncworldedit.core.extent.filter.block.ExtentFilterBlock;
|
||||||
import com.fastasyncworldedit.core.function.generator.GenBase;
|
import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
||||||
import com.fastasyncworldedit.core.function.generator.Resource;
|
|
||||||
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||||
|
import com.fastasyncworldedit.core.limit.ConcurrentFaweLimit;
|
||||||
import com.fastasyncworldedit.core.limit.FaweLimit;
|
import com.fastasyncworldedit.core.limit.FaweLimit;
|
||||||
|
import com.fastasyncworldedit.core.limit.ProcessorFaweLimit;
|
||||||
import com.fastasyncworldedit.core.queue.Filter;
|
import com.fastasyncworldedit.core.queue.Filter;
|
||||||
|
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||||
|
import com.fastasyncworldedit.core.queue.IChunk;
|
||||||
|
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||||
|
import com.fastasyncworldedit.core.queue.IChunkSet;
|
||||||
|
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -17,7 +23,6 @@ import com.sk89q.worldedit.function.mask.Mask;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
|
||||||
import com.sk89q.worldedit.util.Countable;
|
import com.sk89q.worldedit.util.Countable;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
@ -37,18 +42,22 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class LimitExtent extends AbstractDelegateExtent {
|
public class LimitExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||||
|
|
||||||
private final FaweLimit limit;
|
private final FaweLimit limit;
|
||||||
private final boolean[] faweExceptionReasonsUsed = new boolean[FaweException.Type.values().length];
|
private final boolean[] faweExceptionReasonsUsed = new boolean[FaweException.Type.values().length];
|
||||||
private final Consumer<Component> onErrorMessage;
|
private final Consumer<Component> onErrorMessage;
|
||||||
|
private final int chunk_size;
|
||||||
|
private boolean processing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param limit the limit
|
* @param limit the limit
|
||||||
|
* @deprecated Use {@link LimitExtent#LimitExtent(Extent, FaweLimit, Consumer, boolean, boolean)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "TODO")
|
||||||
public LimitExtent(Extent extent, FaweLimit limit) {
|
public LimitExtent(Extent extent, FaweLimit limit) {
|
||||||
this(extent, limit, c -> {
|
this(extent, limit, c -> {
|
||||||
});
|
});
|
||||||
@ -60,11 +69,41 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param limit the limit
|
* @param limit the limit
|
||||||
* @param onErrorMessage consumer to handle a component generated by exceptions
|
* @param onErrorMessage consumer to handle a component generated by exceptions
|
||||||
|
* @deprecated Use {@link LimitExtent#LimitExtent(Extent, FaweLimit, Consumer, boolean, boolean)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "TODO")
|
||||||
public LimitExtent(Extent extent, FaweLimit limit, Consumer<Component> onErrorMessage) {
|
public LimitExtent(Extent extent, FaweLimit limit, Consumer<Component> onErrorMessage) {
|
||||||
|
this(extent, limit, onErrorMessage, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance.
|
||||||
|
*
|
||||||
|
* @param extent the extent
|
||||||
|
* @param limit the limit
|
||||||
|
* @param onErrorMessage consumer to handle a component generated by exceptions
|
||||||
|
* @param processing if this limit extent is expected to be processing
|
||||||
|
* @param expectSynchronousSetting if synchronous block setting is expected
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public LimitExtent(
|
||||||
|
Extent extent,
|
||||||
|
FaweLimit limit,
|
||||||
|
Consumer<Component> onErrorMessage,
|
||||||
|
boolean processing,
|
||||||
|
boolean expectSynchronousSetting
|
||||||
|
) {
|
||||||
super(extent);
|
super(extent);
|
||||||
this.limit = limit;
|
if (!expectSynchronousSetting) {
|
||||||
|
this.limit = new ConcurrentFaweLimit(limit);
|
||||||
|
} else if (processing) {
|
||||||
|
this.limit = new ProcessorFaweLimit(limit);
|
||||||
|
} else {
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
this.onErrorMessage = onErrorMessage;
|
this.onErrorMessage = onErrorMessage;
|
||||||
|
this.chunk_size = 16 * 16 * (extent.getMaxY() - extent.getMinY());
|
||||||
|
this.processing = !expectSynchronousSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleException(FaweException e) {
|
private void handleException(FaweException e) {
|
||||||
@ -81,7 +120,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public List<? extends Entity> getEntities(Region region) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return super.getEntities(region);
|
return extent.getEntities(region);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@ -92,7 +131,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public List<? extends Entity> getEntities() {
|
public List<? extends Entity> getEntities() {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
return super.getEntities();
|
return extent.getEntities();
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@ -105,7 +144,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
limit.THROW_MAX_ENTITIES();
|
limit.THROW_MAX_ENTITIES();
|
||||||
try {
|
try {
|
||||||
return super.createEntity(location, entity);
|
return extent.createEntity(location, entity);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return null;
|
return null;
|
||||||
@ -118,7 +157,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
limit.THROW_MAX_ENTITIES();
|
limit.THROW_MAX_ENTITIES();
|
||||||
try {
|
try {
|
||||||
return super.createEntity(location, entity, uuid);
|
return extent.createEntity(location, entity, uuid);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return null;
|
return null;
|
||||||
@ -130,7 +169,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
limit.THROW_MAX_ENTITIES();
|
limit.THROW_MAX_ENTITIES();
|
||||||
try {
|
try {
|
||||||
super.removeEntity(x, y, z, uuid);
|
extent.removeEntity(x, y, z, uuid);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
@ -138,9 +177,9 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) {
|
public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) {
|
||||||
limit.THROW_MAX_CHANGES(Character.MAX_VALUE);
|
limit.THROW_MAX_CHANGES(chunk_size);
|
||||||
try {
|
try {
|
||||||
return super.regenerateChunk(x, z, type, seed);
|
return extent.regenerateChunk(x, z, type, seed);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
@ -151,7 +190,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getHighestTerrainBlock(x, z, minY, maxY);
|
return extent.getHighestTerrainBlock(x, z, minY, maxY);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
@ -162,7 +201,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getHighestTerrainBlock(x, z, minY, maxY, filter);
|
return extent.getHighestTerrainBlock(x, z, minY, maxY, filter);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
@ -173,7 +212,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getNearestSurfaceLayer(x, z, y, minY, maxY);
|
return extent.getNearestSurfaceLayer(x, z, y, minY, maxY);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
@ -184,7 +223,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
@ -195,7 +234,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
@ -206,7 +245,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
@ -217,7 +256,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
@ -237,91 +276,47 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
) {
|
) {
|
||||||
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
limit.THROW_MAX_CHECKS(maxY - minY + 1);
|
||||||
try {
|
try {
|
||||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return minY;
|
return minY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCaves(Region region) throws WorldEditException {
|
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
|
||||||
super.addCaves(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generate(Region region, GenBase gen) throws WorldEditException {
|
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
|
||||||
super.generate(region, gen);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws
|
|
||||||
WorldEditException {
|
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
|
||||||
super.addSchems(region, mask, clipboards, rarity, rotate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
|
||||||
super.spawnResource(region, gen, rarity, frequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws
|
|
||||||
WorldEditException {
|
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
|
||||||
super.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addOres(Region region, Mask mask) throws WorldEditException {
|
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
|
||||||
super.addOres(region, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
return super.getBlockDistribution(region);
|
return extent.getBlockDistribution(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
return super.getBlockDistributionWithData(region);
|
return extent.getBlockDistributionWithData(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
return super.countBlocks(region, searchBlocks);
|
return extent.countBlocks(region, searchBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countBlocks(Region region, Mask searchMask) {
|
public int countBlocks(Region region, Mask searchMask) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
return super.countBlocks(region, searchMask);
|
return extent.countBlocks(region, searchMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
return super.setBlocks(region, block);
|
return extent.setBlocks(region, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
return super.setBlocks(region, pattern);
|
return extent.setBlocks(region, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -329,41 +324,34 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
MaxChangedBlocksException {
|
MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
return super.replaceBlocks(region, filter, replacement);
|
return extent.replaceBlocks(region, filter, replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
return super.replaceBlocks(region, filter, pattern);
|
return extent.replaceBlocks(region, filter, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
return super.replaceBlocks(region, mask, pattern);
|
return extent.replaceBlocks(region, mask, pattern);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
|
||||||
return super.center(region, pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int setBlocks(Set<BlockVector3> vset, Pattern pattern) {
|
public int setBlocks(Set<BlockVector3> vset, Pattern pattern) {
|
||||||
limit.THROW_MAX_CHANGES(vset.size());
|
limit.THROW_MAX_CHANGES(vset.size());
|
||||||
return super.setBlocks(vset, pattern);
|
return extent.setBlocks(vset, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
return super.apply(region, filter, full);
|
return extent.apply(region, filter, full);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -393,14 +381,14 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
limit.THROW_MAX_CHECKS(size);
|
limit.THROW_MAX_CHECKS(size);
|
||||||
limit.THROW_MAX_CHANGES(size);
|
limit.THROW_MAX_CHANGES(size);
|
||||||
return super.apply(positions, filter);
|
return extent.apply(positions, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
return super.getBlock(position);
|
return extent.getBlock(position);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return BlockTypes.AIR.getDefaultState();
|
return BlockTypes.AIR.getDefaultState();
|
||||||
@ -411,7 +399,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public BlockState getBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
return super.getBlock(x, y, z);
|
return extent.getBlock(x, y, z);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return BlockTypes.AIR.getDefaultState();
|
return BlockTypes.AIR.getDefaultState();
|
||||||
@ -422,7 +410,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
return super.getFullBlock(position);
|
return extent.getFullBlock(position);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
@ -433,7 +421,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
return super.getFullBlock(x, y, z);
|
return extent.getFullBlock(x, y, z);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
@ -444,7 +432,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public BiomeType getBiome(BlockVector3 position) {
|
public BiomeType getBiome(BlockVector3 position) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
return super.getBiome(position);
|
return extent.getBiome(position);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return BiomeTypes.FOREST;
|
return BiomeTypes.FOREST;
|
||||||
@ -455,7 +443,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public BiomeType getBiomeType(int x, int y, int z) {
|
public BiomeType getBiomeType(int x, int y, int z) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
return super.getBiomeType(x, y, z);
|
return extent.getBiomeType(x, y, z);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return BiomeTypes.FOREST;
|
return BiomeTypes.FOREST;
|
||||||
@ -470,7 +458,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
limit.THROW_MAX_BLOCKSTATES();
|
limit.THROW_MAX_BLOCKSTATES();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return super.setBlock(position, block);
|
return extent.setBlock(position, block);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
@ -484,7 +472,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
limit.THROW_MAX_BLOCKSTATES();
|
limit.THROW_MAX_BLOCKSTATES();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return super.setBlock(x, y, z, block);
|
return extent.setBlock(x, y, z, block);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
@ -494,9 +482,9 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
limit.MAX_BLOCKSTATES();
|
limit.THROW_MAX_BLOCKSTATES();
|
||||||
try {
|
try {
|
||||||
return super.setTile(x, y, z, tile);
|
return extent.setTile(x, y, z, tile);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
@ -507,7 +495,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
try {
|
try {
|
||||||
return super.setBiome(position, biome);
|
return extent.setBiome(position, biome);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
@ -518,11 +506,41 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
try {
|
try {
|
||||||
return super.setBiome(x, y, z, biome);
|
return extent.setBiome(x, y, z, biome);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setProcessing(boolean processing) {
|
||||||
|
this.processing = processing;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||||
|
if (!processing) {
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
int tiles = set.getTiles().size();
|
||||||
|
int ents = set.getEntities().size() + set.getEntityRemoves().size();
|
||||||
|
limit.THROW_MAX_CHANGES(tiles + ents);
|
||||||
|
limit.THROW_MAX_BLOCKSTATES(tiles);
|
||||||
|
limit.THROW_MAX_ENTITIES(ents);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Extent construct(final Extent child) {
|
||||||
|
if (extent != child) {
|
||||||
|
new ExtentTraverser<Extent>(this).setNext(child);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProcessorScope getScope() {
|
||||||
|
return ProcessorScope.READING_SET_BLOCKS;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -170,10 +170,13 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized final void filter(Filter filter) {
|
public synchronized final void filter(Filter filter) {
|
||||||
|
initSet();
|
||||||
for (y = 0, index = 0; y < 16; y++) {
|
for (y = 0, index = 0; y < 16; y++) {
|
||||||
for (z = 0; z < 16; z++) {
|
for (z = 0; z < 16; z++) {
|
||||||
for (x = 0; x < 16; x++, index++) {
|
for (x = 0; x < 16; x++, index++) {
|
||||||
filter.applyBlock(this);
|
if (setArr[index] != BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||||
|
filter.applyBlock(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return test(getExtent().getBlock(vector));
|
return test(vector.getBlock(getExtent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean test(BlockState state);
|
public abstract boolean test(BlockState state);
|
||||||
|
@ -16,9 +16,9 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (data != -1) {
|
if (data != -1) {
|
||||||
return getExtent().getBlock(vector).getInternalPropertiesId() == data;
|
return vector.getBlock(getExtent()).getInternalPropertiesId() == data;
|
||||||
} else {
|
} else {
|
||||||
data = getExtent().getBlock(vector).getInternalPropertiesId();
|
data = vector.getBlock(getExtent()).getInternalPropertiesId();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return test(getExtent(), vector);
|
int blockID = vector.getBlock(getExtent()).getInternalBlockTypeId();
|
||||||
|
int testId = id.compareAndExchange(-1, blockID);
|
||||||
|
return blockID == testId || testId == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@ public class SingleBlockStateMask extends ABlockMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
int test = getExtent().getBlock(vector).getOrdinal();
|
int test = vector.getBlock(getExtent()).getOrdinal();
|
||||||
return ordinal == test || isAir && test == 0;
|
return ordinal == test || isAir && test == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class SplatterBrushMask extends AbstractExtentMask {
|
|||||||
double dist = vector.distanceSq(position);
|
double dist = vector.distanceSq(position);
|
||||||
synchronized (placed) {
|
synchronized (placed) {
|
||||||
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2 && surface.test(vector)) {
|
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2 && surface.test(vector)) {
|
||||||
placed.add(vector);
|
placed.add(vector.toImmutable());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,201 @@
|
|||||||
|
package com.fastasyncworldedit.core.limit;
|
||||||
|
|
||||||
|
import com.fastasyncworldedit.core.FaweCache;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows concurrent limit calculations
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public class ConcurrentFaweLimit extends FaweLimit {
|
||||||
|
|
||||||
|
public AtomicLong ATOMIC_MAX_CHANGES = new AtomicLong();
|
||||||
|
public AtomicInteger ATOMIC_MAX_FAILS = new AtomicInteger();
|
||||||
|
public AtomicLong ATOMIC_MAX_CHECKS = new AtomicLong();
|
||||||
|
public AtomicInteger ATOMIC_MAX_ITERATIONS = new AtomicInteger();
|
||||||
|
public AtomicInteger ATOMIC_MAX_BLOCKSTATES = new AtomicInteger();
|
||||||
|
public AtomicInteger ATOMIC_MAX_ENTITIES = new AtomicInteger();
|
||||||
|
|
||||||
|
public ConcurrentFaweLimit(FaweLimit other) {
|
||||||
|
set(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MAX_CHANGES() {
|
||||||
|
return ATOMIC_MAX_CHANGES.decrementAndGet() < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MAX_FAILS() {
|
||||||
|
return ATOMIC_MAX_FAILS.decrementAndGet() < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MAX_CHECKS() {
|
||||||
|
return ATOMIC_MAX_CHECKS.decrementAndGet() < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MAX_ITERATIONS() {
|
||||||
|
return ATOMIC_MAX_ITERATIONS.decrementAndGet() < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MAX_BLOCKSTATES() {
|
||||||
|
return ATOMIC_MAX_BLOCKSTATES.decrementAndGet() < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MAX_ENTITIES() {
|
||||||
|
return ATOMIC_MAX_ENTITIES.decrementAndGet() < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHANGES() {
|
||||||
|
if (ATOMIC_MAX_CHANGES.decrementAndGet() < 0) {
|
||||||
|
throw FaweCache.MAX_CHANGES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_FAILS() {
|
||||||
|
if (ATOMIC_MAX_FAILS.decrementAndGet() < 0) {
|
||||||
|
throw FaweCache.MAX_FAILS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHECKS() {
|
||||||
|
if (ATOMIC_MAX_CHECKS.decrementAndGet() < 0) {
|
||||||
|
throw FaweCache.MAX_CHECKS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_ITERATIONS() {
|
||||||
|
if (ATOMIC_MAX_ITERATIONS.decrementAndGet() < 0) {
|
||||||
|
throw FaweCache.MAX_ITERATIONS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_BLOCKSTATES() {
|
||||||
|
if (ATOMIC_MAX_BLOCKSTATES.decrementAndGet() < 0) {
|
||||||
|
throw FaweCache.MAX_TILES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_ENTITIES() {
|
||||||
|
if (ATOMIC_MAX_ENTITIES.decrementAndGet() < 0) {
|
||||||
|
throw FaweCache.MAX_ENTITIES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHANGES(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_CHANGES.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_CHANGES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHANGES(long amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_CHANGES.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_CHANGES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_FAILS(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_FAILS.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_FAILS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHECKS(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_CHECKS.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_CHECKS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHECKS(long amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_CHECKS.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_CHECKS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_ITERATIONS(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_ITERATIONS.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_ITERATIONS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_BLOCKSTATES(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_BLOCKSTATES.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_TILES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_ENTITIES(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ATOMIC_MAX_ENTITIES.addAndGet(-amt) < 0) {
|
||||||
|
throw FaweCache.MAX_ENTITIES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(FaweLimit other) {
|
||||||
|
super.set(other);
|
||||||
|
ATOMIC_MAX_CHANGES.set(other.MAX_CHANGES);
|
||||||
|
ATOMIC_MAX_FAILS.set(other.MAX_FAILS);
|
||||||
|
ATOMIC_MAX_CHECKS.set(other.MAX_CHECKS);
|
||||||
|
ATOMIC_MAX_ITERATIONS.set(other.MAX_ITERATIONS);
|
||||||
|
ATOMIC_MAX_BLOCKSTATES.set(other.MAX_BLOCKSTATES);
|
||||||
|
ATOMIC_MAX_ENTITIES.set(other.MAX_ENTITIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FaweLimit getLimitUsed(FaweLimit originalLimit) {
|
||||||
|
FaweLimit newLimit = new FaweLimit();
|
||||||
|
newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - this.ATOMIC_MAX_CHANGES.get();
|
||||||
|
newLimit.MAX_FAILS = originalLimit.MAX_FAILS - this.ATOMIC_MAX_FAILS.get();
|
||||||
|
newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - this.ATOMIC_MAX_CHECKS.get();
|
||||||
|
newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - this.ATOMIC_MAX_ITERATIONS.get();
|
||||||
|
newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - this.ATOMIC_MAX_BLOCKSTATES.get();
|
||||||
|
newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - this.ATOMIC_MAX_ENTITIES.get();
|
||||||
|
return newLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.fastasyncworldedit.core.limit;
|
package com.fastasyncworldedit.core.limit;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.FaweCache;
|
import com.fastasyncworldedit.core.FaweCache;
|
||||||
|
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -8,12 +9,12 @@ import java.util.Set;
|
|||||||
public class FaweLimit {
|
public class FaweLimit {
|
||||||
|
|
||||||
public int MAX_ACTIONS = 0;
|
public int MAX_ACTIONS = 0;
|
||||||
public long MAX_CHANGES = 0;
|
public volatile long MAX_CHANGES = 0;
|
||||||
public int MAX_FAILS = 0;
|
public volatile int MAX_FAILS = 0;
|
||||||
public long MAX_CHECKS = 0;
|
public volatile long MAX_CHECKS = 0;
|
||||||
public int MAX_ITERATIONS = 0;
|
public volatile int MAX_ITERATIONS = 0;
|
||||||
public int MAX_BLOCKSTATES = 0;
|
public volatile int MAX_BLOCKSTATES = 0;
|
||||||
public int MAX_ENTITIES = 0;
|
public volatile int MAX_ENTITIES = 0;
|
||||||
public int MAX_HISTORY = 0;
|
public int MAX_HISTORY = 0;
|
||||||
public int SCHEM_FILE_SIZE_LIMIT = 0;
|
public int SCHEM_FILE_SIZE_LIMIT = 0;
|
||||||
public int SCHEM_FILE_NUM_LIMIT = 0;
|
public int SCHEM_FILE_NUM_LIMIT = 0;
|
||||||
@ -157,85 +158,85 @@ public class FaweLimit {
|
|||||||
return MAX_ENTITIES-- > 0;
|
return MAX_ENTITIES-- > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHANGES() {
|
public void THROW_MAX_CHANGES() throws FaweException {
|
||||||
if (MAX_CHANGES-- <= 0) {
|
if (MAX_CHANGES-- <= 0) {
|
||||||
throw FaweCache.MAX_CHANGES;
|
throw FaweCache.MAX_CHANGES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_FAILS() {
|
public void THROW_MAX_FAILS() throws FaweException {
|
||||||
if (MAX_FAILS-- <= 0) {
|
if (MAX_FAILS-- <= 0) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.MAX_FAILS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHECKS() {
|
public void THROW_MAX_CHECKS() throws FaweException {
|
||||||
if (MAX_CHECKS-- <= 0) {
|
if (MAX_CHECKS-- <= 0) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ITERATIONS() {
|
public void THROW_MAX_ITERATIONS() throws FaweException {
|
||||||
if (MAX_ITERATIONS-- <= 0) {
|
if (MAX_ITERATIONS-- <= 0) {
|
||||||
throw FaweCache.MAX_ITERATIONS;
|
throw FaweCache.MAX_ITERATIONS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_BLOCKSTATES() {
|
public void THROW_MAX_BLOCKSTATES() throws FaweException {
|
||||||
if (MAX_BLOCKSTATES-- <= 0) {
|
if (MAX_BLOCKSTATES-- <= 0) {
|
||||||
throw FaweCache.MAX_TILES;
|
throw FaweCache.MAX_TILES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ENTITIES() {
|
public void THROW_MAX_ENTITIES() throws FaweException {
|
||||||
if (MAX_ENTITIES-- <= 0) {
|
if (MAX_ENTITIES-- <= 0) {
|
||||||
throw FaweCache.MAX_ENTITIES;
|
throw FaweCache.MAX_ENTITIES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHANGES(int amt) {
|
public void THROW_MAX_CHANGES(int amt) throws FaweException {
|
||||||
if ((MAX_CHANGES -= amt) <= 0) {
|
if ((MAX_CHANGES -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_CHANGES;
|
throw FaweCache.MAX_CHANGES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHANGES(long amt) {
|
public void THROW_MAX_CHANGES(long amt) throws FaweException {
|
||||||
if ((MAX_CHANGES -= amt) <= 0) {
|
if ((MAX_CHANGES -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_CHANGES;
|
throw FaweCache.MAX_CHANGES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_FAILS(int amt) {
|
public void THROW_MAX_FAILS(int amt) throws FaweException {
|
||||||
if ((MAX_FAILS -= amt) <= 0) {
|
if ((MAX_FAILS -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.MAX_FAILS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHECKS(int amt) {
|
public void THROW_MAX_CHECKS(int amt) throws FaweException {
|
||||||
if ((MAX_CHECKS -= amt) <= 0) {
|
if ((MAX_CHECKS -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHECKS(long amt) {
|
public void THROW_MAX_CHECKS(long amt) throws FaweException {
|
||||||
if ((MAX_CHECKS -= amt) <= 0) {
|
if ((MAX_CHECKS -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ITERATIONS(int amt) {
|
public void THROW_MAX_ITERATIONS(int amt) throws FaweException {
|
||||||
if ((MAX_ITERATIONS -= amt) <= 0) {
|
if ((MAX_ITERATIONS -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_ITERATIONS;
|
throw FaweCache.MAX_ITERATIONS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_BLOCKSTATES(int amt) {
|
public void THROW_MAX_BLOCKSTATES(int amt) throws FaweException {
|
||||||
if ((MAX_BLOCKSTATES -= amt) <= 0) {
|
if ((MAX_BLOCKSTATES -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_TILES;
|
throw FaweCache.MAX_TILES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ENTITIES(int amt) {
|
public void THROW_MAX_ENTITIES(int amt) throws FaweException {
|
||||||
if ((MAX_ENTITIES -= amt) <= 0) {
|
if ((MAX_ENTITIES -= amt) <= 0) {
|
||||||
throw FaweCache.MAX_ENTITIES;
|
throw FaweCache.MAX_ENTITIES;
|
||||||
}
|
}
|
||||||
@ -266,6 +267,22 @@ public class FaweLimit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an {@link FaweLimit} representing the amount of a limit used from a given "original" limit
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public FaweLimit getLimitUsed(FaweLimit originalLimit) {
|
||||||
|
FaweLimit newLimit = new FaweLimit();
|
||||||
|
newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - this.MAX_CHANGES;
|
||||||
|
newLimit.MAX_FAILS = originalLimit.MAX_FAILS - this.MAX_FAILS;
|
||||||
|
newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - this.MAX_CHECKS;
|
||||||
|
newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - this.MAX_ITERATIONS;
|
||||||
|
newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - this.MAX_BLOCKSTATES;
|
||||||
|
newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - this.MAX_ENTITIES;
|
||||||
|
return newLimit;
|
||||||
|
}
|
||||||
|
|
||||||
public void set(FaweLimit limit) {
|
public void set(FaweLimit limit) {
|
||||||
MAX_ACTIONS = limit.MAX_ACTIONS;
|
MAX_ACTIONS = limit.MAX_ACTIONS;
|
||||||
MAX_CHANGES = limit.MAX_CHANGES;
|
MAX_CHANGES = limit.MAX_CHANGES;
|
||||||
@ -325,4 +342,8 @@ public class FaweLimit {
|
|||||||
return MAX_CHANGES + "";
|
return MAX_CHANGES + "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProcessorFaweLimit toConcurrent() {
|
||||||
|
return new ProcessorFaweLimit(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,135 @@
|
|||||||
|
package com.fastasyncworldedit.core.limit;
|
||||||
|
|
||||||
|
import com.fastasyncworldedit.core.FaweCache;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows concurrent limit calculations for THROW_MAX_XXX(amount) methods. Other methods use the default implementations in
|
||||||
|
* {@link FaweLimit}
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public class ProcessorFaweLimit extends FaweLimit {
|
||||||
|
|
||||||
|
public AtomicLong ATOMIC_MAX_CHANGES = new AtomicLong();
|
||||||
|
public AtomicInteger ATOMIC_MAX_FAILS = new AtomicInteger();
|
||||||
|
public AtomicLong ATOMIC_MAX_CHECKS = new AtomicLong();
|
||||||
|
public AtomicInteger ATOMIC_MAX_ITERATIONS = new AtomicInteger();
|
||||||
|
public AtomicInteger ATOMIC_MAX_BLOCKSTATES = new AtomicInteger();
|
||||||
|
public AtomicInteger ATOMIC_MAX_ENTITIES = new AtomicInteger();
|
||||||
|
|
||||||
|
public ProcessorFaweLimit(FaweLimit other) {
|
||||||
|
set(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHANGES(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final long changes = MAX_CHANGES;
|
||||||
|
if (ATOMIC_MAX_CHANGES.updateAndGet(i -> (MAX_CHANGES = Math.min(i, changes) - amt)) < 0) {
|
||||||
|
throw FaweCache.MAX_CHANGES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHANGES(long amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final long changes = MAX_CHANGES;
|
||||||
|
if (ATOMIC_MAX_CHANGES.updateAndGet(i -> (MAX_CHANGES = Math.min(i, changes) - amt))< 0) {
|
||||||
|
throw FaweCache.MAX_CHANGES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_FAILS(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int fails = MAX_FAILS;
|
||||||
|
if (ATOMIC_MAX_FAILS.updateAndGet(i -> (MAX_FAILS = Math.min(i, fails) - amt)) < 0) {
|
||||||
|
throw FaweCache.MAX_FAILS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHECKS(int amt) {
|
||||||
|
final long checks = MAX_CHECKS;
|
||||||
|
if (ATOMIC_MAX_CHECKS.updateAndGet(i -> (MAX_CHECKS = Math.min(i, checks) - amt)) < 0) {
|
||||||
|
throw FaweCache.MAX_CHECKS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_CHECKS(long amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final long checks = MAX_CHECKS;
|
||||||
|
if (ATOMIC_MAX_CHECKS.updateAndGet(i -> (MAX_CHECKS = Math.min(i, checks) - amt)) < 0) {
|
||||||
|
throw FaweCache.MAX_CHECKS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_ITERATIONS(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int iterations = MAX_ITERATIONS;
|
||||||
|
if (ATOMIC_MAX_ITERATIONS.updateAndGet(i -> (MAX_ITERATIONS = Math.min(i, iterations) - amt)) < 0) {
|
||||||
|
throw FaweCache.MAX_ITERATIONS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_BLOCKSTATES(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int states = MAX_BLOCKSTATES;
|
||||||
|
if (ATOMIC_MAX_BLOCKSTATES.updateAndGet(i -> (MAX_BLOCKSTATES = Math.min(i, states) - amt)) < 0) {
|
||||||
|
throw FaweCache.MAX_TILES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void THROW_MAX_ENTITIES(int amt) {
|
||||||
|
if (amt == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int entities = MAX_ENTITIES;
|
||||||
|
if (ATOMIC_MAX_ENTITIES.updateAndGet(i -> (MAX_ENTITIES = Math.min(i, entities) - amt)) < 0) {
|
||||||
|
throw FaweCache.MAX_ENTITIES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(FaweLimit other) {
|
||||||
|
super.set(other);
|
||||||
|
ATOMIC_MAX_CHANGES.set(other.MAX_CHANGES);
|
||||||
|
ATOMIC_MAX_FAILS.set(other.MAX_FAILS);
|
||||||
|
ATOMIC_MAX_CHECKS.set(other.MAX_CHECKS);
|
||||||
|
ATOMIC_MAX_ITERATIONS.set(other.MAX_ITERATIONS);
|
||||||
|
ATOMIC_MAX_BLOCKSTATES.set(other.MAX_BLOCKSTATES);
|
||||||
|
ATOMIC_MAX_ENTITIES.set(other.MAX_ENTITIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FaweLimit getLimitUsed(FaweLimit originalLimit) {
|
||||||
|
FaweLimit newLimit = new FaweLimit();
|
||||||
|
newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - Math.min(this.ATOMIC_MAX_CHANGES.get(), MAX_CHANGES);
|
||||||
|
newLimit.MAX_FAILS = originalLimit.MAX_FAILS - Math.min(this.ATOMIC_MAX_FAILS.get(), MAX_FAILS);
|
||||||
|
newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - Math.min(this.ATOMIC_MAX_CHECKS.get(), MAX_CHECKS);
|
||||||
|
newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - Math.min(this.ATOMIC_MAX_ITERATIONS.get(), MAX_ITERATIONS);
|
||||||
|
newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - Math.min(this.ATOMIC_MAX_BLOCKSTATES.get(), MAX_BLOCKSTATES);
|
||||||
|
newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - Math.min(this.ATOMIC_MAX_ENTITIES.get(), MAX_ENTITIES);
|
||||||
|
return newLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -50,7 +50,7 @@ public interface IBatchProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 one.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
Extent construct(Extent child);
|
Extent construct(Extent child);
|
||||||
|
@ -308,16 +308,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
* @return Limit remaining
|
* @return Limit remaining
|
||||||
*/
|
*/
|
||||||
public FaweLimit getLimitUsed() {
|
public FaweLimit getLimitUsed() {
|
||||||
FaweLimit newLimit = new FaweLimit();
|
return originalLimit.getLimitUsed(limit);
|
||||||
newLimit.MAX_ACTIONS = originalLimit.MAX_ACTIONS - limit.MAX_ACTIONS;
|
|
||||||
newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - limit.MAX_CHANGES;
|
|
||||||
newLimit.MAX_FAILS = originalLimit.MAX_FAILS - limit.MAX_FAILS;
|
|
||||||
newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - limit.MAX_CHECKS;
|
|
||||||
newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - limit.MAX_ITERATIONS;
|
|
||||||
newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - limit.MAX_BLOCKSTATES;
|
|
||||||
newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - limit.MAX_ENTITIES;
|
|
||||||
newLimit.MAX_HISTORY = limit.MAX_HISTORY;
|
|
||||||
return newLimit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,6 +104,7 @@ public final class EditSessionBuilder {
|
|||||||
private Extent extent;
|
private Extent extent;
|
||||||
private boolean compiled;
|
private boolean compiled;
|
||||||
private boolean wrapped;
|
private boolean wrapped;
|
||||||
|
private boolean expectSynchronousSetting = false;
|
||||||
|
|
||||||
private @Nullable
|
private @Nullable
|
||||||
World world;
|
World world;
|
||||||
@ -415,6 +416,15 @@ public final class EditSessionBuilder {
|
|||||||
return setDirty();
|
return setDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EditSessionBuilder expectSynchronousSetting(boolean expectSynchronousSetting) {
|
||||||
|
this.expectSynchronousSetting = expectSynchronousSetting;
|
||||||
|
return setDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExpectingSynchronousSetting() {
|
||||||
|
return this.expectSynchronousSetting;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile the builder to the settings given. Prepares history, limits, lighting, etc.
|
* Compile the builder to the settings given. Prepares history, limits, lighting, etc.
|
||||||
*/
|
*/
|
||||||
@ -635,7 +645,11 @@ public final class EditSessionBuilder {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (limit != null && !limit.isUnlimited()) {
|
if (limit != null && !limit.isUnlimited()) {
|
||||||
this.extent = new LimitExtent(this.extent, limit, onErrorMessage);
|
this.extent = new LimitExtent(this.extent, limit, onErrorMessage, placeChunks && combineStages, expectSynchronousSetting);
|
||||||
|
// Only process if we're not necessarily going to catch tiles via Extent#setBlock, e.g. because using PQE methods
|
||||||
|
if (placeChunks && combineStages && !expectSynchronousSetting) {
|
||||||
|
queue.addProcessor((LimitExtent) this.extent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
|
this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
|
||||||
}
|
}
|
||||||
|
@ -1728,6 +1728,20 @@ public class LocalSession implements TextureHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EditSession createEditSession(Actor actor, String command) {
|
public EditSession createEditSession(Actor actor, String command) {
|
||||||
|
return createEditSession(actor, command, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new edit session.
|
||||||
|
*
|
||||||
|
* @param actor the actor
|
||||||
|
* @param command the command executed resulting in the creation of the edit session
|
||||||
|
* @param expectSynchronousSetting if it is expected that blocks will only be set synchronously, i.e. from one thread (at a
|
||||||
|
* time)
|
||||||
|
* @return an edit session
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public EditSession createEditSession(Actor actor, String command, boolean expectSynchronousSetting) {
|
||||||
checkNotNull(actor);
|
checkNotNull(actor);
|
||||||
|
|
||||||
World world = null;
|
World world = null;
|
||||||
@ -1748,6 +1762,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
}
|
}
|
||||||
builder.command(command);
|
builder.command(command);
|
||||||
builder.fastMode(!this.sideEffectSet.doesApplyAny());
|
builder.fastMode(!this.sideEffectSet.doesApplyAny());
|
||||||
|
builder.expectSynchronousSetting(expectSynchronousSetting);
|
||||||
|
|
||||||
editSession = builder.build();
|
editSession = builder.build();
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.sk89q.worldedit.command.util.Logging;
|
|||||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||||
import com.sk89q.worldedit.command.util.annotation.Preload;
|
import com.sk89q.worldedit.command.util.annotation.Preload;
|
||||||
|
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
|
||||||
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;
|
||||||
@ -179,6 +180,7 @@ public class BiomeCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected // TODO improve using filter/chunk-based-placement
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
@CommandPermissions("worldedit.biome.set")
|
@CommandPermissions("worldedit.biome.set")
|
||||||
public void setBiome(
|
public void setBiome(
|
||||||
|
@ -992,15 +992,15 @@ public class BrushCommands {
|
|||||||
Expression radius,
|
Expression radius,
|
||||||
@Arg(desc = "Command to run")
|
@Arg(desc = "Command to run")
|
||||||
List<String> input,
|
List<String> input,
|
||||||
@Switch(name = 'p', desc = "Show any printed output")
|
@Switch(name = 'h', desc = "Hide any printed output")
|
||||||
boolean print
|
boolean hide
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(
|
worldEdit.checkMaxBrushRadius(
|
||||||
radius,
|
radius,
|
||||||
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
|
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
|
||||||
);
|
);
|
||||||
String cmd = StringMan.join(input, " ");
|
String cmd = StringMan.join(input, " ");
|
||||||
set(context, new CommandBrush(cmd, print), "worldedit.brush.command").setSize(radius);
|
set(context, new CommandBrush(cmd, !hide), "worldedit.brush.command").setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -47,6 +47,7 @@ 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.annotation.Confirm;
|
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||||
import com.sk89q.worldedit.command.util.annotation.Preload;
|
import com.sk89q.worldedit.command.util.annotation.Preload;
|
||||||
|
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
@ -438,6 +439,7 @@ public class ClipboardCommands {
|
|||||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.place")
|
@CommandPermissions("worldedit.clipboard.place")
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void place(
|
public void place(
|
||||||
Actor actor, World world, LocalSession session, final EditSession editSession,
|
Actor actor, World world, LocalSession session, final EditSession editSession,
|
||||||
@ -502,6 +504,7 @@ public class ClipboardCommands {
|
|||||||
desc = "Paste the clipboard's contents"
|
desc = "Paste the clipboard's contents"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.paste")
|
@CommandPermissions("worldedit.clipboard.paste")
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void paste(
|
public void paste(
|
||||||
Actor actor, World world, LocalSession session, EditSession editSession,
|
Actor actor, World world, LocalSession session, EditSession editSession,
|
||||||
|
@ -38,6 +38,7 @@ 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.annotation.Confirm;
|
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||||
import com.sk89q.worldedit.command.util.annotation.Preload;
|
import com.sk89q.worldedit.command.util.annotation.Preload;
|
||||||
|
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
|
||||||
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.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
@ -104,6 +105,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.cylinder")
|
@CommandPermissions("worldedit.generation.cylinder")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int hcyl(
|
public int hcyl(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The pattern of blocks to generate")
|
@Arg(desc = "The pattern of blocks to generate")
|
||||||
@ -152,6 +154,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.cylinder")
|
@CommandPermissions("worldedit.generation.cylinder")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int cyl(
|
public int cyl(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The pattern of blocks to generate")
|
@Arg(desc = "The pattern of blocks to generate")
|
||||||
@ -197,6 +200,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.cone")
|
@CommandPermissions("worldedit.generation.cone")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int cone(Actor actor, LocalSession session, EditSession editSession,
|
public int cone(Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The pattern of blocks to generate")
|
@Arg(desc = "The pattern of blocks to generate")
|
||||||
Pattern pattern,
|
Pattern pattern,
|
||||||
@ -243,6 +247,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.sphere")
|
@CommandPermissions("worldedit.generation.sphere")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int hsphere(
|
public int hsphere(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The pattern of blocks to generate")
|
@Arg(desc = "The pattern of blocks to generate")
|
||||||
@ -262,6 +267,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.sphere")
|
@CommandPermissions("worldedit.generation.sphere")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int sphere(
|
public int sphere(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The pattern of blocks to generate")
|
@Arg(desc = "The pattern of blocks to generate")
|
||||||
@ -313,6 +319,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.forest")
|
@CommandPermissions("worldedit.generation.forest")
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int forestGen(
|
public int forestGen(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The size of the forest, in blocks", def = "10")
|
@Arg(desc = "The size of the forest, in blocks", def = "10")
|
||||||
@ -337,6 +344,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.pumpkins")
|
@CommandPermissions("worldedit.generation.pumpkins")
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int pumpkins(
|
public int pumpkins(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The size of the patch", def = "10")
|
@Arg(desc = "The size of the patch", def = "10")
|
||||||
@ -357,6 +365,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.pyramid")
|
@CommandPermissions("worldedit.generation.pyramid")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int hollowPyramid(
|
public int hollowPyramid(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The pattern of blocks to set")
|
@Arg(desc = "The pattern of blocks to set")
|
||||||
@ -373,6 +382,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.pyramid")
|
@CommandPermissions("worldedit.generation.pyramid")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int pyramid(
|
public int pyramid(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The pattern of blocks to set")
|
@Arg(desc = "The pattern of blocks to set")
|
||||||
@ -400,6 +410,7 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.shape")
|
@CommandPermissions("worldedit.generation.shape")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int generate(
|
public int generate(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@ -486,6 +497,7 @@ public class GenerationCommands {
|
|||||||
@CommandPermissions("worldedit.generation.shape.biome")
|
@CommandPermissions("worldedit.generation.shape.biome")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int generateBiome(
|
public int generateBiome(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@ -564,6 +576,7 @@ public class GenerationCommands {
|
|||||||
@CommandPermissions("worldedit.generation.caves")
|
@CommandPermissions("worldedit.generation.caves")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public void caves(
|
public void caves(
|
||||||
Actor actor, LocalSession session, EditSession editSession, @Selection Region region,
|
Actor actor, LocalSession session, EditSession editSession, @Selection Region region,
|
||||||
@ -602,6 +615,7 @@ public class GenerationCommands {
|
|||||||
@CommandPermissions("worldedit.generation.ore")
|
@CommandPermissions("worldedit.generation.ore")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public void ores(
|
public void ores(
|
||||||
Actor actor,
|
Actor actor,
|
||||||
@ -621,6 +635,7 @@ public class GenerationCommands {
|
|||||||
desc = "Generate an image"
|
desc = "Generate an image"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.image")
|
@CommandPermissions("worldedit.generation.image")
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void image(
|
public void image(
|
||||||
Actor actor,
|
Actor actor,
|
||||||
@ -685,6 +700,7 @@ public class GenerationCommands {
|
|||||||
@CommandPermissions("worldedit.generation.ore")
|
@CommandPermissions("worldedit.generation.ore")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public void ore(
|
public void ore(
|
||||||
Actor actor,
|
Actor actor,
|
||||||
@ -719,8 +735,9 @@ public class GenerationCommands {
|
|||||||
desc = "Creates a distorted sphere"
|
desc = "Creates a distorted sphere"
|
||||||
)
|
)
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@CommandPermissions("worldedit.generation.blob")
|
@CommandPermissions("worldedit.generation.blob")
|
||||||
public int blobBrush(
|
public int blob(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "Pattern")
|
@Arg(desc = "Pattern")
|
||||||
Pattern pattern,
|
Pattern pattern,
|
||||||
|
@ -27,6 +27,7 @@ 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.annotation.Confirm;
|
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||||
|
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
|
||||||
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.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
@ -61,6 +62,7 @@ public class HistoryCommands {
|
|||||||
desc = "Undoes the last action (from history)"
|
desc = "Undoes the last action (from history)"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"})
|
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"})
|
||||||
|
@SynchronousSettingExpected
|
||||||
public void undo(
|
public void undo(
|
||||||
Actor actor, LocalSession session,
|
Actor actor, LocalSession session,
|
||||||
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1")
|
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1")
|
||||||
@ -108,6 +110,7 @@ public class HistoryCommands {
|
|||||||
desc = "Redoes the last action (from history)"
|
desc = "Redoes the last action (from history)"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"})
|
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"})
|
||||||
|
@SynchronousSettingExpected
|
||||||
public void redo(
|
public void redo(
|
||||||
Actor actor, LocalSession session,
|
Actor actor, LocalSession session,
|
||||||
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1")
|
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1")
|
||||||
|
@ -35,6 +35,7 @@ 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.annotation.Confirm;
|
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||||
import com.sk89q.worldedit.command.util.annotation.Preload;
|
import com.sk89q.worldedit.command.util.annotation.Preload;
|
||||||
|
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
|
||||||
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.function.GroundFunction;
|
import com.sk89q.worldedit.function.GroundFunction;
|
||||||
@ -225,6 +226,7 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.line")
|
@CommandPermissions("worldedit.region.line")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int line(
|
public int line(
|
||||||
Actor actor, EditSession editSession,
|
Actor actor, EditSession editSession,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@ -257,6 +259,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.curve")
|
@CommandPermissions("worldedit.region.curve")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int curve(
|
public int curve(
|
||||||
Actor actor, EditSession editSession,
|
Actor actor, EditSession editSession,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@ -315,6 +318,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.overlay")
|
@CommandPermissions("worldedit.region.overlay")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
|
@SynchronousSettingExpected // TODO improve using filter/chunk-based-placement
|
||||||
public int overlay(
|
public int overlay(
|
||||||
Actor actor, EditSession editSession, @Selection Region region,
|
Actor actor, EditSession editSession, @Selection Region region,
|
||||||
@Arg(desc = "The pattern of blocks to overlay")
|
@Arg(desc = "The pattern of blocks to overlay")
|
||||||
@ -333,6 +337,7 @@ public class RegionCommands {
|
|||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
|
@SynchronousSettingExpected // TODO improve using filter/chunk-based-placement
|
||||||
public void lay(
|
public void lay(
|
||||||
Actor actor,
|
Actor actor,
|
||||||
EditSession editSession,
|
EditSession editSession,
|
||||||
@ -369,6 +374,7 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.region.center")
|
@CommandPermissions("worldedit.region.center")
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int center(
|
public int center(
|
||||||
Actor actor, EditSession editSession, @Selection Region region,
|
Actor actor, EditSession editSession, @Selection Region region,
|
||||||
@Arg(desc = "The pattern of blocks to set")
|
@Arg(desc = "The pattern of blocks to set")
|
||||||
@ -386,6 +392,8 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.naturalize")
|
@CommandPermissions("worldedit.region.naturalize")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
|
@SynchronousSettingExpected // TODO improve using filter/chunk-based-placement
|
||||||
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
public int naturalize(Actor actor, EditSession editSession, @Selection Region region) throws WorldEditException {
|
public int naturalize(Actor actor, EditSession editSession, @Selection Region region) throws WorldEditException {
|
||||||
int affected = editSession.naturalizeCuboidBlocks(region);
|
int affected = editSession.naturalizeCuboidBlocks(region);
|
||||||
actor.print(Caption.of("worldedit.naturalize.naturalized", TextComponent.of(affected)));
|
actor.print(Caption.of("worldedit.naturalize.naturalized", TextComponent.of(affected)));
|
||||||
@ -437,6 +445,7 @@ public class RegionCommands {
|
|||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int smooth(
|
public int smooth(
|
||||||
Actor actor, EditSession editSession, @Selection Region region,
|
Actor actor, EditSession editSession, @Selection Region region,
|
||||||
@Arg(desc = "# of iterations to perform", def = "1")
|
@Arg(desc = "# of iterations to perform", def = "1")
|
||||||
@ -510,6 +519,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.snowsmooth")
|
@CommandPermissions("worldedit.region.snowsmooth")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int snowSmooth(
|
public int snowSmooth(
|
||||||
Actor actor, EditSession editSession, @Selection Region region,
|
Actor actor, EditSession editSession, @Selection Region region,
|
||||||
@ -536,6 +546,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.move")
|
@CommandPermissions("worldedit.region.move")
|
||||||
@Logging(ORIENTATION_REGION)
|
@Logging(ORIENTATION_REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int move(
|
public int move(
|
||||||
Actor actor, World world, EditSession editSession, LocalSession session,
|
Actor actor, World world, EditSession editSession, LocalSession session,
|
||||||
@ -599,6 +610,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.fall")
|
@CommandPermissions("worldedit.region.fall")
|
||||||
@Logging(ORIENTATION_REGION)
|
@Logging(ORIENTATION_REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public void fall(
|
public void fall(
|
||||||
Actor actor, EditSession editSession,
|
Actor actor, EditSession editSession,
|
||||||
@ -618,6 +630,7 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.stack")
|
@CommandPermissions("worldedit.region.stack")
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Logging(ORIENTATION_REGION)
|
@Logging(ORIENTATION_REGION)
|
||||||
public int stack(
|
public int stack(
|
||||||
Actor actor, World world, EditSession editSession, LocalSession session,
|
Actor actor, World world, EditSession editSession, LocalSession session,
|
||||||
@ -683,6 +696,7 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.regen")
|
@CommandPermissions("worldedit.regen")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
void regenerate(
|
void regenerate(
|
||||||
Actor actor, World world, LocalSession session, EditSession editSession,
|
Actor actor, World world, LocalSession session, EditSession editSession,
|
||||||
@ -737,6 +751,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.deform")
|
@CommandPermissions("worldedit.region.deform")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int deform(
|
public int deform(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@ -814,6 +829,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.hollow")
|
@CommandPermissions("worldedit.region.hollow")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int hollow(
|
public int hollow(
|
||||||
Actor actor, EditSession editSession,
|
Actor actor, EditSession editSession,
|
||||||
@ -848,6 +864,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.forest")
|
@CommandPermissions("worldedit.region.forest")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int forest(
|
public int forest(
|
||||||
Actor actor, EditSession editSession, @Selection Region region,
|
Actor actor, EditSession editSession, @Selection Region region,
|
||||||
@ -869,6 +886,7 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.flora")
|
@CommandPermissions("worldedit.region.flora")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
|
@SynchronousSettingExpected
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int flora(
|
public int flora(
|
||||||
Actor actor, EditSession editSession, @Selection Region region,
|
Actor actor, EditSession editSession, @Selection Region region,
|
||||||
|
@ -28,6 +28,7 @@ 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.annotation.SynchronousSettingExpected;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
@ -66,6 +67,7 @@ public class SnapshotUtilCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@CommandPermissions("worldedit.snapshots.restore")
|
||||||
|
@SynchronousSettingExpected
|
||||||
public void restore(
|
public void restore(
|
||||||
Actor actor, World world, LocalSession session, EditSession editSession,
|
Actor actor, World world, LocalSession session, EditSession editSession,
|
||||||
@Arg(name = "snapshot", desc = "The snapshot to restore", def = "")
|
@Arg(name = "snapshot", desc = "The snapshot to restore", def = "")
|
||||||
|
@ -44,6 +44,7 @@ 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.WorldEditAsyncCommandBuilder;
|
||||||
|
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
|
||||||
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;
|
||||||
@ -220,6 +221,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fill")
|
@CommandPermissions("worldedit.fill")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int fill(
|
public int fill(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The blocks to fill with")
|
@Arg(desc = "The blocks to fill with")
|
||||||
@ -310,6 +312,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fill.recursive")
|
@CommandPermissions("worldedit.fill.recursive")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int fillr(
|
public int fillr(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The blocks to fill with")
|
@Arg(desc = "The blocks to fill with")
|
||||||
@ -341,6 +344,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.drain")
|
@CommandPermissions("worldedit.drain")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int drain(
|
public int drain(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
//FAWE start - we take an expression over a double
|
//FAWE start - we take an expression over a double
|
||||||
@ -369,6 +373,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fixlava")
|
@CommandPermissions("worldedit.fixlava")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int fixLava(
|
public int fixLava(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius to fix in")
|
@Arg(desc = "The radius to fix in")
|
||||||
@ -388,6 +393,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fixwater")
|
@CommandPermissions("worldedit.fixwater")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int fixWater(
|
public int fixWater(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius to fix in")
|
@Arg(desc = "The radius to fix in")
|
||||||
@ -407,6 +413,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.removeabove")
|
@CommandPermissions("worldedit.removeabove")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int removeAbove(
|
public int removeAbove(
|
||||||
Actor actor, World world, LocalSession session, EditSession editSession,
|
Actor actor, World world, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The apothem of the square to remove from", def = "1")
|
@Arg(desc = "The apothem of the square to remove from", def = "1")
|
||||||
@ -432,6 +439,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.removebelow")
|
@CommandPermissions("worldedit.removebelow")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int removeBelow(
|
public int removeBelow(
|
||||||
Actor actor, World world, LocalSession session, EditSession editSession,
|
Actor actor, World world, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The apothem of the square to remove from", def = "1")
|
@Arg(desc = "The apothem of the square to remove from", def = "1")
|
||||||
@ -457,6 +465,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.removenear")
|
@CommandPermissions("worldedit.removenear")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int removeNear(
|
public int removeNear(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The mask of blocks to remove")
|
@Arg(desc = "The mask of blocks to remove")
|
||||||
@ -519,6 +528,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snow")
|
@CommandPermissions("worldedit.snow")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int snow(
|
public int snow(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius of the cylinder to snow in", def = "10")
|
@Arg(desc = "The radius of the cylinder to snow in", def = "10")
|
||||||
@ -558,6 +568,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.thaw")
|
@CommandPermissions("worldedit.thaw")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int thaw(
|
public int thaw(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius of the cylinder to thaw in", def = "10")
|
@Arg(desc = "The radius of the cylinder to thaw in", def = "10")
|
||||||
@ -587,6 +598,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.green")
|
@CommandPermissions("worldedit.green")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int green(
|
public int green(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius of the cylinder to convert in", def = "10")
|
@Arg(desc = "The radius of the cylinder to convert in", def = "10")
|
||||||
@ -621,6 +633,7 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.extinguish")
|
@CommandPermissions("worldedit.extinguish")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
|
@SynchronousSettingExpected
|
||||||
public int extinguish(
|
public int extinguish(
|
||||||
Actor actor, LocalSession session, EditSession editSession,
|
Actor actor, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius of the square to remove in", def = "")
|
@Arg(desc = "The radius of the square to remove in", def = "")
|
||||||
@ -835,55 +848,6 @@ public class UtilityCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Command(
|
|
||||||
// name = "/hollowr",
|
|
||||||
// desc = "Hollow out a space recursively with a pattern"
|
|
||||||
// )
|
|
||||||
// @CommandPermissions("worldedit.hollowr")
|
|
||||||
// @Logging(PLACEMENT)
|
|
||||||
// public int hollowr(
|
|
||||||
// Actor actor,
|
|
||||||
// LocalSession session,
|
|
||||||
// EditSession editSession,
|
|
||||||
// @Arg(desc = "The radius to hollow out") Expression radiusExp,
|
|
||||||
// @ArgFlag(name = 'p', desc = "The blocks to fill with") Pattern pattern,
|
|
||||||
// @ArgFlag(name = 'm', desc = "The blocks remove", def = "") Mask mask
|
|
||||||
// ) throws WorldEditException {
|
|
||||||
// //FAWE start
|
|
||||||
// double radius = radiusExp.evaluate();
|
|
||||||
// //FAWE end
|
|
||||||
// radius = Math.max(1, radius);
|
|
||||||
// we.checkMaxRadius(radius);
|
|
||||||
// if (mask == null) {
|
|
||||||
// Mask mask = new MaskIntersection(
|
|
||||||
// new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
|
||||||
// new BoundedHeightMask(
|
|
||||||
// Math.max(lowerBound, minY),
|
|
||||||
// Math.min(maxY, origin.getBlockY())
|
|
||||||
// ),
|
|
||||||
// Masks.negate(new ExistingBlockMask(this))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Want to replace blocks
|
|
||||||
// BlockReplace replace = new BlockReplace(this, pattern);
|
|
||||||
//
|
|
||||||
// // Pick how we're going to visit blocks
|
|
||||||
// RecursiveVisitor visitor;
|
|
||||||
// //FAWE start - provide extent for preloading, min/max y
|
|
||||||
// if (recursive) {
|
|
||||||
// visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), minY, maxY, this);
|
|
||||||
// } else {
|
|
||||||
// visitor = new DownwardVisitor(mask, replace, origin.getBlockY(), (int) (radius * 2 + 1), minY, maxY, this);
|
|
||||||
// }
|
|
||||||
// //FAWE end
|
|
||||||
//
|
|
||||||
// BlockVector3 pos = session.getPlacementPosition(actor);
|
|
||||||
// int affected = editSession.res(pos, pattern, radius, depth, true);
|
|
||||||
// actor.print(Caption.of("worldedit.fillr.created", TextComponent.of(affected)));
|
|
||||||
// return affected;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static List<Map.Entry<URI, String>> filesToEntry(final File root, final List<File> files, final UUID uuid) {
|
public static List<Map.Entry<URI, String>> filesToEntry(final File root, final List<File> files, final UUID uuid) {
|
||||||
return files.stream()
|
return files.stream()
|
||||||
.map(input -> { // Keep this functional, as transform is evaluated lazily
|
.map(input -> { // Keep this functional, as transform is evaluated lazily
|
||||||
|
@ -64,7 +64,7 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player, "AreaPickaxe")) {
|
try (EditSession editSession = session.createEditSession(player, "AreaPickaxe", true)) {
|
||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||||
int maxY = editSession.getMaxY();
|
int maxY = editSession.getMaxY();
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
Property<Object> objProp = (Property<Object>) currentProperty;
|
Property<Object> objProp = (Property<Object>) currentProperty;
|
||||||
BaseBlock newBlock = block.with(objProp, currentProperty.getValues().get(index));
|
BaseBlock newBlock = block.with(objProp, currentProperty.getValues().get(index));
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player, null, true)) {
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(blockPoint, newBlock);
|
editSession.setBlock(blockPoint, newBlock);
|
||||||
player.print(Caption.of(
|
player.print(Caption.of(
|
||||||
|
@ -63,7 +63,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
) {
|
) {
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player, null, true)) {
|
||||||
try {
|
try {
|
||||||
BlockVector3 position = clicked.toVector().toBlockPoint();
|
BlockVector3 position = clicked.toVector().toBlockPoint();
|
||||||
editSession.setBlock(position, pattern);
|
editSession.setBlock(position, pattern);
|
||||||
|
@ -440,7 +440,7 @@ public class BrushTool
|
|||||||
Caption.of("fawe.error.no-perm", StringMan.join(current.getPermissions(), ",")));
|
Caption.of("fawe.error.no-perm", StringMan.join(current.getPermissions(), ",")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try (EditSession editSession = session.createEditSession(player, current.toString())) {
|
try (EditSession editSession = session.createEditSession(player, current.toString(), brush.setsSynchronously())) {
|
||||||
Location target = player.getBlockTrace(getRange(), true, traceMask);
|
Location target = player.getBlockTrace(getRange(), true, traceMask);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
|
@ -86,7 +86,7 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player, "FloatingTreeRemover")) {
|
try (EditSession editSession = session.createEditSession(player, "FloatingTreeRemover", true)) {
|
||||||
try {
|
try {
|
||||||
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
|
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
|
||||||
if (blockSet == null) {
|
if (blockSet == null) {
|
||||||
|
@ -82,7 +82,7 @@ public class FloodFillTool implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player, "FloodFillTool")) {
|
try (EditSession editSession = session.createEditSession(player, "FloodFillTool", true)) {
|
||||||
try {
|
try {
|
||||||
//FAWE start - Respect masks
|
//FAWE start - Respect masks
|
||||||
Mask mask = initialType.toMask(editSession);
|
Mask mask = initialType.toMask(editSession);
|
||||||
|
@ -61,7 +61,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
}
|
}
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) {
|
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool", true)) {
|
||||||
try {
|
try {
|
||||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
BaseBlock applied = secondary.applyBlock(blockPoint);
|
BaseBlock applied = secondary.applyBlock(blockPoint);
|
||||||
@ -90,7 +90,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
}
|
}
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) {
|
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool", true)) {
|
||||||
try {
|
try {
|
||||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
BaseBlock applied = primary.applyBlock(blockPoint);
|
BaseBlock applied = primary.applyBlock(blockPoint);
|
||||||
|
@ -79,7 +79,7 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player, "RecursivePickaxe")) {
|
try (EditSession editSession = session.createEditSession(player, "RecursivePickaxe", true)) {
|
||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
|
@ -62,7 +62,7 @@ public class SinglePickaxe implements BlockTool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player, null, true)) {
|
||||||
try {
|
try {
|
||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
||||||
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
|
||||||
|
@ -59,7 +59,7 @@ public class StackTool implements BlockTool {
|
|||||||
}
|
}
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player, null, true)) {
|
||||||
BlockStateHolder<?> block = editSession.getFullBlock(clicked.toVector().toBlockPoint());
|
BlockStateHolder<?> block = editSession.getFullBlock(clicked.toVector().toBlockPoint());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -60,7 +60,7 @@ public class TreePlanter implements BlockTool {
|
|||||||
@Nullable Direction face
|
@Nullable Direction face
|
||||||
) {
|
) {
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player, null, true)) {
|
||||||
try {
|
try {
|
||||||
boolean successful = false;
|
boolean successful = false;
|
||||||
|
|
||||||
|
@ -40,4 +40,13 @@ public interface Brush {
|
|||||||
*/
|
*/
|
||||||
void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException;
|
void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this brush is expected to set blocks synchronously, i.e. from one thread (at a time)
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
default boolean setsSynchronously() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs called commands to a logger.
|
* Handles commands indicated as requiring confirmation.
|
||||||
*/
|
*/
|
||||||
public class ConfirmHandler implements CommandCallListener {
|
public class ConfirmHandler implements CommandCallListener {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs called commands to a logger.
|
* Initialises preloading of chunks.
|
||||||
*/
|
*/
|
||||||
public class PreloadHandler implements CommandCallListener {
|
public class PreloadHandler implements CommandCallListener {
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.sk89q.worldedit.command.util.annotation;
|
||||||
|
|
||||||
|
import org.enginehub.piston.inject.InjectAnnotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates it is expected that blocks will only be set synchronously, i.e. from one thread (at a time)
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({
|
||||||
|
ElementType.METHOD
|
||||||
|
})
|
||||||
|
@InjectAnnotation
|
||||||
|
public @interface SynchronousSettingExpected {
|
||||||
|
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
* {@link com.sk89q.worldedit.command.util.annotation.PatternList},
|
* {@link com.sk89q.worldedit.command.util.annotation.PatternList},
|
||||||
* {@link com.sk89q.worldedit.command.util.annotation.Preload},
|
* {@link com.sk89q.worldedit.command.util.annotation.Preload},
|
||||||
* {@link com.sk89q.worldedit.command.util.annotation.PreloadHandler},
|
* {@link com.sk89q.worldedit.command.util.annotation.PreloadHandler},
|
||||||
|
* {@link com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected},
|
||||||
* {@link com.sk89q.worldedit.command.util.annotation.Step},
|
* {@link com.sk89q.worldedit.command.util.annotation.Step},
|
||||||
* {@link com.sk89q.worldedit.command.util.annotation.Time}
|
* {@link com.sk89q.worldedit.command.util.annotation.Time}
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +24,7 @@ import com.fastasyncworldedit.core.configuration.Caption;
|
|||||||
import com.fastasyncworldedit.core.configuration.Settings;
|
import com.fastasyncworldedit.core.configuration.Settings;
|
||||||
import com.fastasyncworldedit.core.extension.platform.binding.Bindings;
|
import com.fastasyncworldedit.core.extension.platform.binding.Bindings;
|
||||||
import com.fastasyncworldedit.core.extension.platform.binding.ConsumeBindings;
|
import com.fastasyncworldedit.core.extension.platform.binding.ConsumeBindings;
|
||||||
|
import com.fastasyncworldedit.core.extension.platform.binding.EditSessionHolder;
|
||||||
import com.fastasyncworldedit.core.extension.platform.binding.PrimitiveBindings;
|
import com.fastasyncworldedit.core.extension.platform.binding.PrimitiveBindings;
|
||||||
import com.fastasyncworldedit.core.extension.platform.binding.ProvideBindings;
|
import com.fastasyncworldedit.core.extension.platform.binding.ProvideBindings;
|
||||||
import com.fastasyncworldedit.core.internal.command.MethodInjector;
|
import com.fastasyncworldedit.core.internal.command.MethodInjector;
|
||||||
@ -154,7 +155,6 @@ import org.enginehub.piston.inject.MemoizingValueAccess;
|
|||||||
import org.enginehub.piston.inject.MergedValueAccess;
|
import org.enginehub.piston.inject.MergedValueAccess;
|
||||||
import org.enginehub.piston.part.SubCommandPart;
|
import org.enginehub.piston.part.SubCommandPart;
|
||||||
import org.enginehub.piston.suggestion.Suggestion;
|
import org.enginehub.piston.suggestion.Suggestion;
|
||||||
import org.enginehub.piston.util.HelpGenerator;
|
|
||||||
import org.enginehub.piston.util.ValueProvider;
|
import org.enginehub.piston.util.ValueProvider;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -227,7 +227,6 @@ public final class PlatformCommandManager {
|
|||||||
new ConfirmHandler(),
|
new ConfirmHandler(),
|
||||||
new PreloadHandler()
|
new PreloadHandler()
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
));
|
));
|
||||||
// setup separate from main constructor
|
// setup separate from main constructor
|
||||||
// ensures that everything is definitely assigned
|
// ensures that everything is definitely assigned
|
||||||
@ -312,20 +311,6 @@ public final class PlatformCommandManager {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
//FAWE start
|
//FAWE start
|
||||||
/*
|
|
||||||
globalInjectedValues.injectValue(Key.of(EditSession.class),
|
|
||||||
context -> {
|
|
||||||
LocalSession localSession = context.injectedValue(Key.of(LocalSession.class))
|
|
||||||
.orElseThrow(() -> new IllegalStateException("No LocalSession"));
|
|
||||||
return context.injectedValue(Key.of(Actor.class))
|
|
||||||
.map(actor -> {
|
|
||||||
EditSession editSession = localSession.createEditSession(actor);
|
|
||||||
editSession.enableStandardMode();
|
|
||||||
Request.request().setEditSession(editSession);
|
|
||||||
return editSession;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
// globalInjectedValues.injectValue(Key.of(CFICommands.CFISettings.class),
|
// globalInjectedValues.injectValue(Key.of(CFICommands.CFISettings.class),
|
||||||
// context -> context.injectedValue(Key.of(Actor.class))
|
// context -> context.injectedValue(Key.of(Actor.class))
|
||||||
@ -866,10 +851,10 @@ public final class PlatformCommandManager {
|
|||||||
store.injectValue(Key.of(InjectedValueStore.class), ValueProvider.constant(store));
|
store.injectValue(Key.of(InjectedValueStore.class), ValueProvider.constant(store));
|
||||||
store.injectValue(Key.of(Event.class), ValueProvider.constant(event));
|
store.injectValue(Key.of(Event.class), ValueProvider.constant(event));
|
||||||
//FAWE start - allow giving editsessions
|
//FAWE start - allow giving editsessions
|
||||||
if (event instanceof CommandEvent) {
|
if (event instanceof CommandEvent commandEvent) {
|
||||||
EditSession session = ((CommandEvent) event).getSession();
|
EditSession session = commandEvent.getSession();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
store.injectValue(Key.of(EditSession.class), context -> Optional.of(session));
|
store.injectValue(Key.of(EditSessionHolder.class), context -> Optional.of(new EditSessionHolder(session)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
@ -361,6 +361,11 @@ public class AbstractDelegateExtent implements Extent {
|
|||||||
public <T extends Filter> T apply(final Region region, final T filter, final boolean full) {
|
public <T extends Filter> T apply(final Region region, final T filter, final boolean full) {
|
||||||
return extent.apply(region, filter, full);
|
return extent.apply(region, filter, full);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Filter> T apply(final Iterable<BlockVector3> positions, final T filter) {
|
||||||
|
return extent.apply(positions, filter);
|
||||||
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
protected Operation commitBefore() {
|
protected Operation commitBefore() {
|
||||||
|
@ -30,6 +30,7 @@ import com.fastasyncworldedit.core.queue.IChunk;
|
|||||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||||
import com.fastasyncworldedit.core.queue.IChunkSet;
|
import com.fastasyncworldedit.core.queue.IChunkSet;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
@ -46,6 +47,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
|||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
private final LongFunction<ChunkFilterBlock> getOrCreateFilterBlock;
|
private final LongFunction<ChunkFilterBlock> getOrCreateFilterBlock;
|
||||||
|
private AbstractExtentMask extentMask;
|
||||||
private Mask mask;
|
private Mask mask;
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class BiomeMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
BiomeType biome = getExtent().getBiome(vector);
|
BiomeType biome = vector.getBiome(getExtent());
|
||||||
return biomes.contains(biome);
|
return biomes.contains(biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return category.contains(getExtent().getBlock(vector));
|
return category.contains(vector.getBlock(getExtent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
|
@ -204,7 +204,7 @@ public class BlockMask extends ABlockMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
int test = getExtent().getBlock(vector).getOrdinal();
|
int test = vector.getBlock(getExtent()).getOrdinal();
|
||||||
return ordinals[test] || replacesAir() && test == 0;
|
return ordinals[test] || replacesAir() && test == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class BlockStateMask extends AbstractExtentMask {
|
|||||||
//FAWE start
|
//FAWE start
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return test(getExtent().getBlock(vector));
|
return test(vector.getBlock(getExtent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,7 +124,7 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
//FAWE start
|
//FAWE start
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return test(getExtent().getBlock(vector).getBlockType());
|
return test(vector.getBlock(getExtent()).getBlockType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
return !vector.getBlock(getExtent()).getBlockType().getMaterial().isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public class InverseSingleBlockStateMask extends ABlockMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
int test = getExtent().getBlock(vector).getOrdinal();
|
int test = vector.getBlock(getExtent()).getOrdinal();
|
||||||
if (isAir && test == 0) {
|
if (isAir && test == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,7 @@
|
|||||||
"fawe.error.occurred-continuing": "Ignorable error occurred during edit: {0}",
|
"fawe.error.occurred-continuing": "Ignorable error occurred during edit: {0}",
|
||||||
"fawe.error.limit.max-brush-radius": "Maximum brush radius in limit: {0}",
|
"fawe.error.limit.max-brush-radius": "Maximum brush radius in limit: {0}",
|
||||||
"fawe.error.limit.max-radius": "Maximum radius in limit: {0}",
|
"fawe.error.limit.max-radius": "Maximum radius in limit: {0}",
|
||||||
|
"fawe.error.no-process-non-synchronous-edit": "No processor holder was found but edit is non-synchronous",
|
||||||
"fawe.cancel.count": "Cancelled {0} edits.",
|
"fawe.cancel.count": "Cancelled {0} edits.",
|
||||||
"fawe.cancel.reason.confirm": "Use //confirm to execute {0}",
|
"fawe.cancel.reason.confirm": "Use //confirm to execute {0}",
|
||||||
"fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}",
|
"fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}",
|
||||||
@ -149,6 +150,7 @@
|
|||||||
"fawe.cancel.reason.low.memory": "Low memory",
|
"fawe.cancel.reason.low.memory": "Low memory",
|
||||||
"fawe.cancel.reason.max.changes": "Too many blocks changed",
|
"fawe.cancel.reason.max.changes": "Too many blocks changed",
|
||||||
"fawe.cancel.reason.max.checks": "Too many block checks",
|
"fawe.cancel.reason.max.checks": "Too many block checks",
|
||||||
|
"fawe.cancel.reason.max.fails": "Too many fails",
|
||||||
"fawe.cancel.reason.max.tiles": "Too many block entities",
|
"fawe.cancel.reason.max.tiles": "Too many block entities",
|
||||||
"fawe.cancel.reason.max.entities": "Too many entities",
|
"fawe.cancel.reason.max.entities": "Too many entities",
|
||||||
"fawe.cancel.reason.max.iterations": "Max iterations",
|
"fawe.cancel.reason.max.iterations": "Max iterations",
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren