mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 15:08:35 +00:00
Feature/propagate diff and object cleanup (#1190)
* Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit275ba9bd84
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit9fd8984804
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit861fb45e5c
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit420c45a29a
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit4d4db7dcd0
Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commitc98f6e4f37
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit2485f5eccc
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commitd9418ec8ae
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of41073bb1a0
Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
This commit is contained in:
@ -20,25 +20,25 @@
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.beta.implementation.lighting.NullRelighter;
|
||||
import com.fastasyncworldedit.core.beta.implementation.lighting.Relighter;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.NullRelighter;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.Relighter;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.object.FaweLimit;
|
||||
import com.fastasyncworldedit.core.object.RegionWrapper;
|
||||
import com.fastasyncworldedit.core.object.RunnableVal;
|
||||
import com.fastasyncworldedit.core.object.changeset.AbstractChangeSet;
|
||||
import com.fastasyncworldedit.core.object.changeset.BlockBagChangeSet;
|
||||
import com.fastasyncworldedit.core.object.clipboard.WorldCopyClipboard;
|
||||
import com.fastasyncworldedit.core.object.collection.LocalBlockVectorSet;
|
||||
import com.fastasyncworldedit.core.object.extent.FaweRegionExtent;
|
||||
import com.fastasyncworldedit.core.object.extent.ProcessedWEExtent;
|
||||
import com.fastasyncworldedit.core.object.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.object.extent.SingleRegionExtent;
|
||||
import com.fastasyncworldedit.core.object.extent.SourceMaskExtent;
|
||||
import com.fastasyncworldedit.core.object.function.SurfaceRegionFunction;
|
||||
import com.fastasyncworldedit.core.object.mask.ResettableMask;
|
||||
import com.fastasyncworldedit.core.object.pattern.ExistingPattern;
|
||||
import com.fastasyncworldedit.core.regions.RegionWrapper;
|
||||
import com.fastasyncworldedit.core.util.task.RunnableVal;
|
||||
import com.fastasyncworldedit.core.history.changeset.AbstractChangeSet;
|
||||
import com.fastasyncworldedit.core.history.changeset.BlockBagChangeSet;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.WorldCopyClipboard;
|
||||
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
|
||||
import com.fastasyncworldedit.core.extent.FaweRegionExtent;
|
||||
import com.fastasyncworldedit.core.extent.ProcessedWEExtent;
|
||||
import com.fastasyncworldedit.core.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.extent.SingleRegionExtent;
|
||||
import com.fastasyncworldedit.core.extent.SourceMaskExtent;
|
||||
import com.fastasyncworldedit.core.function.SurfaceRegionFunction;
|
||||
import com.fastasyncworldedit.core.function.mask.ResettableMask;
|
||||
import com.fastasyncworldedit.core.function.pattern.ExistingPattern;
|
||||
import com.fastasyncworldedit.core.util.EditSessionBuilder;
|
||||
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||
import com.fastasyncworldedit.core.util.MaskTraverser;
|
||||
@ -52,42 +52,41 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.MaskingExtent;
|
||||
import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||
import com.fastasyncworldedit.core.extent.PassthroughExtent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
|
||||
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
||||
import com.sk89q.worldedit.extent.world.WatchdogTickingExtent;
|
||||
import com.sk89q.worldedit.function.GroundFunction;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||
import com.sk89q.worldedit.function.block.SnowSimulator;
|
||||
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
||||
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||
import com.sk89q.worldedit.function.generator.GenBase;
|
||||
import com.sk89q.worldedit.function.generator.OreGen;
|
||||
import com.sk89q.worldedit.function.generator.SchemGen;
|
||||
import com.fastasyncworldedit.core.function.mask.BlockMaskBuilder;
|
||||
import com.fastasyncworldedit.core.function.generator.GenBase;
|
||||
import com.fastasyncworldedit.core.function.generator.OreGen;
|
||||
import com.fastasyncworldedit.core.function.generator.SchemGen;
|
||||
import com.sk89q.worldedit.function.mask.BlockStateMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
import com.fastasyncworldedit.core.function.mask.MaskUnion;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.WallMakeMask;
|
||||
import com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask;
|
||||
import com.fastasyncworldedit.core.function.mask.WallMakeMask;
|
||||
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
|
||||
import com.sk89q.worldedit.function.util.RegionOffset;
|
||||
import com.sk89q.worldedit.function.visitor.DirectionalVisitor;
|
||||
import com.fastasyncworldedit.core.function.visitor.DirectionalVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.DownwardVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
@ -105,8 +104,8 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector2;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
||||
@ -174,7 +173,12 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
* using the {@link ChangeSetExtent}.</p>
|
||||
*/
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
/* FAWE start - extends PassthroughExtent > implements Extent
|
||||
Make sure, that all edits go thru it, else history etc. can have issues.
|
||||
PassthroughExtent has some for loops that then delegate to methods editsession overrides.
|
||||
*/
|
||||
public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
//FAWE end
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
@ -215,24 +219,27 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
@SuppressWarnings("ProtectedField")
|
||||
protected final World world;
|
||||
//FAWE start
|
||||
private final FaweLimit originalLimit;
|
||||
private final FaweLimit limit;
|
||||
private final Player player;
|
||||
private AbstractChangeSet changeSet;
|
||||
private boolean history;
|
||||
|
||||
private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
|
||||
private final MutableBlockVector3 mutableBlockVector3 = new MutableBlockVector3();
|
||||
|
||||
private int changes = 0;
|
||||
private final BlockBag blockBag;
|
||||
|
||||
private final Extent bypassHistory;
|
||||
private Extent bypassAll;
|
||||
private final Extent bypassAll;
|
||||
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
//FAWE end
|
||||
private final List<WatchdogTickingExtent> watchdogExtents = new ArrayList<>(2);
|
||||
|
||||
//FAWE start
|
||||
private final Relighter relighter;
|
||||
private final boolean wnaMode;
|
||||
|
||||
@ -247,6 +254,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
@Nullable BlockBag blockBag, @Nullable EditSessionEvent event) {
|
||||
this(new EditSessionBuilder(world).player(player).limit(limit).changeSet(changeSet).allowedRegions(allowedRegions).autoQueue(autoQueue).fastmode(fastmode).checkMemory(checkMemory).combineStages(combineStages).blockBag(blockBag).eventBus(bus).event(event));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Construct the object with a maximum number of blocks and a block bag.
|
||||
@ -257,6 +265,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param blockBag an optional {@link BlockBag} to use, otherwise null
|
||||
* @param event the event to call with the extent
|
||||
*/
|
||||
//FAWE start - EditSessionEvent
|
||||
public EditSession(@NotNull EventBus eventBus, World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) {
|
||||
this(eventBus, world, null, null, null, null, true, null, null, null, blockBag, event);
|
||||
}
|
||||
@ -359,6 +368,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
boolean commitRequired() {
|
||||
return false;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Turns on specific features for a normal WorldEdit session, such as
|
||||
@ -375,6 +385,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param reorderMode The reorder mode
|
||||
*/
|
||||
public void setReorderMode(ReorderMode reorderMode) {
|
||||
//FAWE start - we don't do physics so we don't need this
|
||||
switch (reorderMode) {
|
||||
case MULTI_STAGE:
|
||||
enableQueue();
|
||||
@ -386,6 +397,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
default:
|
||||
throw new UnsupportedOperationException("Not implemented: " + reorderMode);
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -457,7 +469,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isQueueEnabled() {
|
||||
//FAWE start - see reorder comment, we don't need this
|
||||
return true;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -468,7 +482,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
@Deprecated
|
||||
public void enableQueue() {
|
||||
//FAWE start - see reorder comment, we don't need this
|
||||
super.enableQueue();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -476,7 +492,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
@Deprecated
|
||||
public void disableQueue() {
|
||||
//FAWE start - see reorder comment, we don't need this
|
||||
super.disableQueue();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -485,14 +503,17 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return mask, may be null
|
||||
*/
|
||||
public Mask getMask() {
|
||||
//FAWE start - ExtendTraverser & MaskingExtents
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser<>(getExtent()).find(MaskingExtent.class);
|
||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Get the mask.
|
||||
* Get the source mask.
|
||||
*
|
||||
* @return mask, may be null
|
||||
* @return source mask, may be null
|
||||
*/
|
||||
public Mask getSourceMask() {
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
|
||||
@ -518,7 +539,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - use source mast > mask
|
||||
/**
|
||||
* Set a mask.
|
||||
*
|
||||
@ -558,7 +581,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
setSourceMask(mask);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - use MaskingExtent & ExtentTraverser
|
||||
/**
|
||||
* Set a mask.
|
||||
*
|
||||
@ -581,7 +606,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
addProcessor(new MaskingExtent(getExtent(), mask));
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - ExtentTraverser
|
||||
/**
|
||||
* Get the {@link SurvivalModeExtent}.
|
||||
*
|
||||
@ -597,7 +624,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return survival;
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - our fastmode works different to upstream
|
||||
/**
|
||||
* Set whether fast mode is enabled.
|
||||
*
|
||||
@ -610,7 +639,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
public void setFastMode(boolean enabled) {
|
||||
disableHistory(enabled);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - we don't use this (yet)
|
||||
/**
|
||||
* Set which block updates should occur.
|
||||
*
|
||||
@ -624,7 +655,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
//Do nothing; TODO: SideEffects currently not fully implemented in FAWE.
|
||||
return SideEffectSet.defaults();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Disable history (or re-enable)
|
||||
*
|
||||
@ -646,7 +679,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - See comment on setFastMode
|
||||
/**
|
||||
* Return fast mode status.
|
||||
*
|
||||
@ -659,7 +694,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
public boolean hasFastMode() {
|
||||
return getChangeSet() == null;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - Don't use blockBagExtent
|
||||
/**
|
||||
* Get the {@link BlockBag} is used.
|
||||
*
|
||||
@ -668,7 +705,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
public BlockBag getBlockBag() {
|
||||
return this.blockBag;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Set a {@link BlockBag} to use.
|
||||
*
|
||||
@ -678,7 +717,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
//Not Supported in FAWE
|
||||
throw new UnsupportedOperationException("TODO - this is never called anyway");
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + ":" + getExtent();
|
||||
@ -730,7 +771,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - We don't use this method
|
||||
/**
|
||||
* Returns chunk batching status.
|
||||
*
|
||||
@ -739,6 +782,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
public boolean isBatchingChunks() {
|
||||
return false;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Enable or disable chunk batching. Disabling will flush the session.
|
||||
@ -746,11 +790,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param batchingChunks {@code true} to enable, {@code false} to disable
|
||||
*/
|
||||
public void setBatchingChunks(boolean batchingChunks) {
|
||||
//FAWE start - altered by our lifecycle
|
||||
if (batchingChunks) {
|
||||
enableQueue();
|
||||
} else {
|
||||
disableQueue();
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -760,7 +806,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @see #setBatchingChunks(boolean)
|
||||
*/
|
||||
public void disableBuffering() {
|
||||
//FAWE start - see comment on reorder mode
|
||||
disableQueue();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -804,20 +852,24 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
//FAWE start - use extent
|
||||
if (position.getY() < this.minY || position.getY() > this.maxY) {
|
||||
return false;
|
||||
}
|
||||
this.changes++;
|
||||
return this.getExtent().setBiome(position, biome);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
//FAWE start - use extent
|
||||
if (y < this.minY || y > this.maxY) {
|
||||
return false;
|
||||
}
|
||||
this.changes++;
|
||||
return this.getExtent().setBiome(x, y, z, biome);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -830,10 +882,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return height of highest block found or 'minY'
|
||||
*/
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
//FAWE start - check movement blocker
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (getBlock(x, y, z).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
return y;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
return minY;
|
||||
}
|
||||
@ -850,7 +904,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (filter.test(mutablebv.setComponents(x, y, z))) {
|
||||
//FAWE start - get position from mutable vector
|
||||
if (filter.test(mutableBlockVector3.setComponents(x, y, z))) {
|
||||
//FAWE end
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@ -858,9 +914,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return minY;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public BlockType getBlockType(int x, int y, int z) {
|
||||
return getBlock(x, y, z).getBlockType();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Set a block, bypassing both history and block re-ordering.
|
||||
@ -873,6 +931,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
@Deprecated
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, Stage stage) throws WorldEditException {
|
||||
//FAWE start - accumulate changes
|
||||
if (position.getBlockY() < this.minY || position.getBlockY() > this.maxY) {
|
||||
return false;
|
||||
}
|
||||
@ -886,10 +945,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
case BEFORE_REORDER:
|
||||
return bypassAll.setBlock(position, block);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
throw new RuntimeException("New enum entry added that is unhandled here");
|
||||
}
|
||||
|
||||
//FAWE start - see former comment
|
||||
/**
|
||||
* Set a block, bypassing both history and block re-ordering.
|
||||
*
|
||||
@ -910,7 +971,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
throw new RuntimeException("Unexpected exception", e);
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - we use this
|
||||
/**
|
||||
* Set a block, bypassing history but still utilizing block re-ordering.
|
||||
*
|
||||
@ -980,7 +1043,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
this.changes++;
|
||||
try {
|
||||
BlockVector3 bv = mutablebv.setComponents(x, y, z);
|
||||
BlockVector3 bv = mutableBlockVector3.setComponents(x, y, z);
|
||||
return pattern.apply(getExtent(), bv, bv);
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException("Unexpected exception", e);
|
||||
@ -1017,7 +1080,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return this.changes = super.setBlocks(region, pattern);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Restores all blocks to their initial state.
|
||||
*
|
||||
@ -1025,6 +1090,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
public void undo(EditSession editSession) {
|
||||
UndoContext context = new UndoContext();
|
||||
//FAWE start - listen for inventory, flush & prepare changeset
|
||||
context.setExtent(editSession.bypassAll);
|
||||
ChangeSet changeSet = getChangeSet();
|
||||
setChangeSet(null);
|
||||
@ -1033,6 +1099,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
editSession.changes = 1;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public void setBlocks(ChangeSet changeSet, ChangeSetExecutor.Type type) {
|
||||
final UndoContext context = new UndoContext();
|
||||
context.setExtent(bypassAll);
|
||||
@ -1040,6 +1107,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
flushQueue();
|
||||
changes = 1;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Sets to new state.
|
||||
@ -1048,6 +1116,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
public void redo(EditSession editSession) {
|
||||
UndoContext context = new UndoContext();
|
||||
//FAWE start - listen for inventory, flush & prepare changeset
|
||||
context.setExtent(editSession.bypassAll);
|
||||
ChangeSet changeSet = getChangeSet();
|
||||
setChangeSet(null);
|
||||
@ -1055,6 +1124,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
flushQueue();
|
||||
editSession.changes = 1;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the number of changed blocks.
|
||||
@ -1065,9 +1135,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return getBlockChangeCount();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public void setSize(int size) {
|
||||
this.changes = size;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Closing an EditSession flushes its buffers to the world, and performs other
|
||||
@ -1089,6 +1161,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
flushQueue();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Finish off the queue.
|
||||
*/
|
||||
@ -1222,6 +1295,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
Operations.completeBlindly(visitor);
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Fills an area recursively in the X/Z directions.
|
||||
@ -1279,7 +1353,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
// Execute
|
||||
Operations.completeLegacy(visitor);
|
||||
|
||||
//FAWE start
|
||||
return this.changes = visitor.getAffected();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1449,13 +1525,16 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
//FAWE start
|
||||
int blocksChanged = 0;
|
||||
for (Region wall : CuboidRegion.makeCuboid(region).getWalls().getRegions()) {
|
||||
blocksChanged += setBlocks(wall, pattern);
|
||||
}
|
||||
return blocksChanged;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Make the walls of the given region. The method by which the walls are found
|
||||
* may be inefficient, because there may not be an efficient implementation supported
|
||||
@ -1477,6 +1556,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Places a layer of blocks on top of ground blocks in the given region
|
||||
@ -1510,10 +1590,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace);
|
||||
//FAWE start
|
||||
int minY = region.getMinimumPoint().getBlockY();
|
||||
int maxY = Math.min(getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockY() + 1);
|
||||
SurfaceRegionFunction surface = new SurfaceRegionFunction(this, offset, minY, maxY);
|
||||
FlatRegionVisitor visitor = new FlatRegionVisitor(asFlatRegion(region), surface);
|
||||
//FAWE end
|
||||
Operations.completeBlindly(visitor);
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
@ -1551,6 +1633,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return stackCuboidRegion(region, dir, count, true, false, copyAir ? null : new ExistingBlockMask(this));
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Stack a cuboid region.
|
||||
*
|
||||
@ -1590,6 +1673,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
Operations.completeLegacy(copy);
|
||||
return this.changes = copy.getAffected();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Move the blocks in a region a certain direction.
|
||||
@ -1605,11 +1689,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, boolean moveEntities, boolean copyBiomes, Pattern replacement) throws MaxChangedBlocksException {
|
||||
//FAWE start
|
||||
Mask mask = null;
|
||||
if (!copyAir) {
|
||||
mask = new ExistingBlockMask(this);
|
||||
}
|
||||
return moveRegion(region, dir, distance, moveEntities, copyBiomes, mask, replacement);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1633,6 +1719,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
checkArgument(distance >= 1, "distance >= 1 required");
|
||||
checkArgument(!copyBiomes || region instanceof FlatRegion, "can't copy biomes from non-flat region");
|
||||
|
||||
//FAWE start - add up distance
|
||||
BlockVector3 to = region.getMinimumPoint().add(dir.multiply(distance));
|
||||
|
||||
final BlockVector3 displace = dir.multiply(distance);
|
||||
@ -1673,6 +1760,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
Operations.completeBlindly(copy);
|
||||
return this.changes = copy.getAffected();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1729,22 +1817,30 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
checkNotNull(origin);
|
||||
checkArgument(radius >= 0, "radius >= 0 required");
|
||||
|
||||
//FAWE start - liquidmask
|
||||
Mask liquidMask;
|
||||
if (plants) {
|
||||
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER,
|
||||
BlockTypes.KELP_PLANT, BlockTypes.KELP, BlockTypes.SEAGRASS, BlockTypes.TALL_SEAGRASS);
|
||||
BlockTypes.KELP_PLANT, BlockTypes.KELP, BlockTypes.SEAGRASS, BlockTypes.TALL_SEAGRASS);
|
||||
} else {
|
||||
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
|
||||
liquidMask = new BlockMaskBuilder()
|
||||
.addTypes(BlockTypes.WATER, BlockTypes.LAVA)
|
||||
.build(this);
|
||||
}
|
||||
//FAWE end
|
||||
if (waterlogged) {
|
||||
Map<String, String> stateMap = new HashMap<>();
|
||||
stateMap.put("waterlogged", "true");
|
||||
//FAWE start
|
||||
liquidMask = new MaskUnion(liquidMask, new BlockStateMask(this, stateMap, true));
|
||||
//FAWE end
|
||||
}
|
||||
Mask mask = new MaskIntersection(
|
||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||
new BoundedHeightMask(getWorld().getMinY(), getWorld().getMaxY()),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
//FAWE start
|
||||
liquidMask);
|
||||
//FAWE end
|
||||
BlockReplace replace;
|
||||
if (waterlogged) {
|
||||
replace = new BlockReplace(this, new WaterloggedRemover(this));
|
||||
@ -1762,7 +1858,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
Operations.completeLegacy(visitor);
|
||||
|
||||
//FAWE start
|
||||
return this.changes = visitor.getAffected();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1786,7 +1884,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
// There are boundaries that the routine needs to stay in
|
||||
Mask mask = new MaskIntersection(
|
||||
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||
new BoundedHeightMask(getWorld().getMinY(), Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
blockMask
|
||||
);
|
||||
@ -1837,34 +1935,43 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return makeCylinder(pos, block, radiusX, radiusZ, height, 0, filled);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public int makeHollowCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness) throws MaxChangedBlocksException {
|
||||
return makeCylinder(pos, block, radiusX, radiusZ, height, thickness, false);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
private int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, double thickness, boolean filled) throws MaxChangedBlocksException {
|
||||
public int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, double thickness, boolean filled) throws MaxChangedBlocksException {
|
||||
radiusX += 0.5;
|
||||
radiusZ += 0.5;
|
||||
|
||||
MutableBlockVector3 posv = new MutableBlockVector3(pos);
|
||||
//FAWE start
|
||||
MutableBlockVector3 mutableBlockVector3 = new MutableBlockVector3(pos);
|
||||
//FAWE end
|
||||
if (height == 0) {
|
||||
return 0;
|
||||
} else if (height < 0) {
|
||||
height = -height;
|
||||
posv.mutY(posv.getY() - height);
|
||||
//FAWE start
|
||||
mutableBlockVector3.mutY(mutableBlockVector3.getY() - height);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
if (posv.getBlockY() < 0) {
|
||||
posv.mutY(0);
|
||||
} else if (posv.getBlockY() + height - 1 > maxY) {
|
||||
height = maxY - posv.getBlockY() + 1;
|
||||
//FAWE start
|
||||
if (mutableBlockVector3.getBlockY() < getWorld().getMinY()) {
|
||||
mutableBlockVector3.mutY(world.getMinY());
|
||||
} else if (mutableBlockVector3.getBlockY() + height - 1 > maxY) {
|
||||
height = maxY - mutableBlockVector3.getBlockY() + 1;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
final double invRadiusX = 1 / radiusX;
|
||||
final double invRadiusZ = 1 / radiusZ;
|
||||
|
||||
int px = posv.getBlockX();
|
||||
int py = posv.getBlockY();
|
||||
int pz = posv.getBlockZ();
|
||||
//FAWE start
|
||||
int px = mutableBlockVector3.getBlockX();
|
||||
int py = mutableBlockVector3.getBlockY();
|
||||
int pz = mutableBlockVector3.getBlockZ();
|
||||
MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
final int ceilRadiusX = (int) Math.ceil(radiusX);
|
||||
@ -1914,6 +2021,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//FAWE end
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
@ -1938,16 +2046,20 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
//FAWE start - mutable
|
||||
this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block);
|
||||
this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block);
|
||||
this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block);
|
||||
this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block);
|
||||
//FAWE end
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
return this.changes;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1965,6 +2077,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return moveRegion(region, dir, distance, true, false, copyAir ? new ExistingBlockMask(this) : null, replacement);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public int makeCircle(BlockVector3 pos, final Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled, Vector3 normal) throws MaxChangedBlocksException {
|
||||
radiusX += 0.5;
|
||||
radiusY += 0.5;
|
||||
@ -2061,6 +2174,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
return changes;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Makes a sphere.
|
||||
@ -2105,7 +2219,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
final int ceilRadiusY = (int) Math.ceil(radiusY);
|
||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||
|
||||
//FAWE start
|
||||
int yy;
|
||||
//FAWE end
|
||||
|
||||
double nextXn = 0;
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
@ -2141,6 +2257,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//FAWE start
|
||||
yy = py + y;
|
||||
if (yy <= maxY) {
|
||||
this.setBlock(px + x, py + y, pz + z, block);
|
||||
@ -2171,6 +2288,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
return changes;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2184,6 +2302,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makePyramid(BlockVector3 position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
|
||||
//FAWE start - abbreviated logic
|
||||
int bx = position.getX();
|
||||
int by = position.getY();
|
||||
int bz = position.getZ();
|
||||
@ -2206,6 +2325,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
return changes;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2266,6 +2386,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
++affected;
|
||||
}
|
||||
} else if (id == BlockTypes.SNOW) {
|
||||
//FAWE start
|
||||
if (setBlock(pt, air)) {
|
||||
if (y > 0 ) {
|
||||
BlockState block = getBlock(below);
|
||||
@ -2275,6 +2396,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
++affected;
|
||||
}
|
||||
} else if (id.getMaterial().isAir()) {
|
||||
@ -2419,6 +2541,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return makePumpkinPatches(position, apothem, 0.02);
|
||||
}
|
||||
|
||||
//FAWE start - support density
|
||||
public int makePumpkinPatches(BlockVector3 position, int apothem, double density) throws MaxChangedBlocksException {
|
||||
// We want to generate pumpkins
|
||||
GardenPatchGenerator generator = new GardenPatchGenerator(this);
|
||||
@ -2436,6 +2559,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
Operations.completeLegacy(visitor);
|
||||
return this.changes = ground.getAffected();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Makes a forest.
|
||||
@ -2476,6 +2600,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return the results
|
||||
*/
|
||||
public List<Countable<BlockState>> getBlockDistribution(Region region, boolean separateStates) {
|
||||
//FAWE start - get distr
|
||||
if (separateStates) {
|
||||
return getBlockDistributionWithData(region);
|
||||
}
|
||||
@ -2484,6 +2609,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
for (Countable<BlockType> count : normalDistr) {
|
||||
distribution.add(new Countable<>(count.getID().getDefaultState(), count.getAmount()));
|
||||
}
|
||||
//FAWE end
|
||||
return distribution;
|
||||
}
|
||||
|
||||
@ -2631,41 +2757,40 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||
expression.setEnvironment(environment);
|
||||
//FAWE start
|
||||
final Vector3 zero2 = zero.add(0.5, 0.5, 0.5);
|
||||
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> {
|
||||
try {
|
||||
// offset, scale
|
||||
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
try {
|
||||
// offset, scale
|
||||
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
|
||||
// transform
|
||||
expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout);
|
||||
int xv = (int) (x.getValue() * unit.getX() + zero2.getX());
|
||||
int yv = (int) (y.getValue() * unit.getY() + zero2.getY());
|
||||
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ());
|
||||
|
||||
// transform
|
||||
expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout);
|
||||
int xv = (int) (x.getValue() * unit.getX() + zero2.getX());
|
||||
int yv = (int) (y.getValue() * unit.getY() + zero2.getY());
|
||||
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ());
|
||||
|
||||
BlockState get;
|
||||
if (yv >= 0 && yv < 256) {
|
||||
get = getBlock(xv, yv, zv);
|
||||
} else {
|
||||
get = BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
// read block from world
|
||||
return setBlock(position, get);
|
||||
} catch (EvaluationException e) {
|
||||
throw new RuntimeException(e);
|
||||
BlockState get;
|
||||
if (yv >= 0 && yv < 256) {
|
||||
get = getBlock(xv, yv, zv);
|
||||
} else {
|
||||
get = BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
// read block from world
|
||||
return setBlock(position, get);
|
||||
} catch (EvaluationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
Operations.completeBlindly(visitor);
|
||||
changes += visitor.getAffected();
|
||||
return changes;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start - respect Mask
|
||||
/**
|
||||
* Hollows out the region (Semi-well-defined for non-cuboid selections).
|
||||
*
|
||||
@ -2676,10 +2801,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return hollowOutRegion(region, thickness, pattern, new SolidBlockMask(this));
|
||||
}
|
||||
|
||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern, Mask mask) {
|
||||
try {
|
||||
final Set<BlockVector3> outside = new LocalBlockVectorSet();
|
||||
@ -2747,6 +2868,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled) throws MaxChangedBlocksException {
|
||||
return drawLine(pattern, pos1, pos2, radius, filled, false);
|
||||
@ -2770,7 +2892,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
LocalBlockVectorSet vset = new LocalBlockVectorSet();
|
||||
//FAWE start
|
||||
boolean notdrawn = true;
|
||||
//FAWE end
|
||||
|
||||
int x1 = pos1.getBlockX();
|
||||
int y1 = pos1.getBlockY();
|
||||
@ -2787,11 +2911,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
if (dx + dy + dz == 0) {
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
//FAWE start
|
||||
notdrawn = false;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
int dMax = Math.max(Math.max(dx, dy), dz);
|
||||
//FAWE start - notdrawn
|
||||
if (dMax == dx && notdrawn) {
|
||||
//FAWE end
|
||||
for (int domstep = 0; domstep <= dx; domstep++) {
|
||||
tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
|
||||
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dx * (y2 - y1 > 0 ? 1 : -1));
|
||||
@ -2799,7 +2927,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
}
|
||||
//FAWE start - notdrawn
|
||||
} else if (dMax == dy && notdrawn) {
|
||||
//FAWE end
|
||||
for (int domstep = 0; domstep <= dy; domstep++) {
|
||||
tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1);
|
||||
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dy * (x2 - x1 > 0 ? 1 : -1));
|
||||
@ -2807,7 +2937,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
}
|
||||
//FAWE start - notdrawn
|
||||
} else if (dMax == dz && notdrawn) {
|
||||
//FAWE end
|
||||
for (int domstep = 0; domstep <= dz; domstep++) {
|
||||
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
|
||||
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2 - y1 > 0 ? 1 : -1));
|
||||
@ -2816,6 +2948,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
}
|
||||
}
|
||||
//FAWE start - set BV3
|
||||
Set<BlockVector3> newVset;
|
||||
if (flat) {
|
||||
newVset = getStretched(vset, radius);
|
||||
@ -2829,6 +2962,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
return this.changes += setBlocks(newVset, pattern);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2983,6 +3117,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return returnset;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public static Set<BlockVector3> getStretched(Set<BlockVector3> vset, double radius) {
|
||||
if (radius < 1) {
|
||||
return vset;
|
||||
@ -3021,6 +3156,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
return returnset;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
public Set<BlockVector3> getHollowed(Set<BlockVector3> vset) {
|
||||
final Set<BlockVector3> returnset = new LocalBlockVectorSet();
|
||||
@ -3126,6 +3262,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
Direction.DOWN.toBlockVector(),
|
||||
};
|
||||
|
||||
//FAWE start
|
||||
public boolean regenerate(Region region) {
|
||||
return regenerate(region, this);
|
||||
}
|
||||
@ -3298,4 +3435,5 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
faweClipboard.setOrigin(region.getMinimumPoint());
|
||||
return faweClipboard;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.fastasyncworldedit.core.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.io.file.ArchiveNioSupports;
|
||||
@ -101,7 +101,7 @@ public abstract class LocalConfiguration {
|
||||
|
||||
protected String[] getDefaultDisallowedBlocks() {
|
||||
List<BlockType> blockTypes = Lists.newArrayList(
|
||||
/*
|
||||
/* FAWE start
|
||||
BlockTypes.OAK_SAPLING,
|
||||
BlockTypes.JUNGLE_SAPLING,
|
||||
BlockTypes.DARK_OAK_SAPLING,
|
||||
@ -163,7 +163,7 @@ public abstract class LocalConfiguration {
|
||||
BlockTypes.SUGAR_CANE,
|
||||
// ores and stuff
|
||||
BlockTypes.BEDROCK
|
||||
*/
|
||||
FAWE end*/
|
||||
);
|
||||
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
|
||||
}
|
||||
|
@ -20,14 +20,14 @@
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.object.FaweInputStream;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweInputStream;
|
||||
import com.fastasyncworldedit.core.object.FaweLimit;
|
||||
import com.fastasyncworldedit.core.object.FaweOutputStream;
|
||||
import com.fastasyncworldedit.core.object.changeset.DiskStorageHistory;
|
||||
import com.fastasyncworldedit.core.object.clipboard.MultiClipboardHolder;
|
||||
import com.fastasyncworldedit.core.object.collection.SparseBitSet;
|
||||
import com.fastasyncworldedit.core.object.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
|
||||
import com.fastasyncworldedit.core.history.DiskStorageHistory;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
|
||||
import com.fastasyncworldedit.core.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.util.BrushCache;
|
||||
import com.fastasyncworldedit.core.util.EditSessionBuilder;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
@ -76,6 +76,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.snapshot.experimental.Snapshot;
|
||||
import com.zaxxer.sparsebits.SparseBitSet;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.io.File;
|
||||
@ -85,11 +86,9 @@ import java.io.IOException;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
@ -122,6 +121,7 @@ public class LocalSession implements TextureHolder {
|
||||
// Session related
|
||||
private transient RegionSelector selector = new CuboidRegionSelector();
|
||||
private transient boolean placeAtPos1 = false;
|
||||
//FAWE start
|
||||
private final transient List<Object> history = Collections.synchronizedList(new LinkedList<>() {
|
||||
@Override
|
||||
public Object get(int index) {
|
||||
@ -139,12 +139,17 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
});
|
||||
private transient volatile Integer historyNegativeIndex;
|
||||
private transient final Lock historyWriteLock = new ReentrantLock(true);
|
||||
private final transient Int2ObjectOpenHashMap<Tool> tools = new Int2ObjectOpenHashMap<>(0);
|
||||
private transient Mask sourceMask;
|
||||
private transient TextureUtil texture;
|
||||
private transient ResettableExtent transform = null;
|
||||
private transient World currentWorld;
|
||||
//FAWE end
|
||||
private transient ClipboardHolder clipboard;
|
||||
private transient final Object clipboardLock = new Object();
|
||||
private transient final Lock historyWriteLock = new ReentrantLock(true);
|
||||
private transient boolean superPickaxe = false;
|
||||
private transient BlockTool pickaxeMode = new SinglePickaxe();
|
||||
private final transient Int2ObjectOpenHashMap<Tool> tools = new Int2ObjectOpenHashMap<>(0);
|
||||
private transient int maxBlocksChanged = -1;
|
||||
private transient int maxTimeoutTime;
|
||||
private transient boolean useInventory;
|
||||
@ -152,11 +157,7 @@ public class LocalSession implements TextureHolder {
|
||||
private transient Snapshot snapshotExperimental;
|
||||
private transient SideEffectSet sideEffectSet = SideEffectSet.defaults();
|
||||
private transient Mask mask;
|
||||
private transient Mask sourceMask;
|
||||
private transient TextureUtil texture;
|
||||
private transient ResettableExtent transform = null;
|
||||
private transient ZoneId timezone = ZoneId.systemDefault();
|
||||
private transient World currentWorld;
|
||||
private transient UUID uuid;
|
||||
private transient volatile long historySize = 0;
|
||||
|
||||
@ -174,7 +175,6 @@ public class LocalSession implements TextureHolder {
|
||||
private boolean useServerCUI = false; // Save this to not annoy players.
|
||||
private ItemType wandItem;
|
||||
private ItemType navWandItem;
|
||||
private Map<String, String> macros = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
@ -213,6 +213,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public boolean loadSessionHistoryFromDisk(UUID uuid, World world) {
|
||||
if (world == null || uuid == null) {
|
||||
return false;
|
||||
@ -307,19 +308,7 @@ public class LocalSession implements TextureHolder {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getMacros() {
|
||||
return Collections.unmodifiableMap(this.macros);
|
||||
}
|
||||
|
||||
public void setMacro(String key, String value) {
|
||||
this.macros.put(key, value);
|
||||
setDirty();
|
||||
}
|
||||
|
||||
public String getMacro(String key) {
|
||||
return this.macros.get(key);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get whether this session is "dirty" and has changes that needs to
|
||||
@ -338,6 +327,7 @@ public class LocalSession implements TextureHolder {
|
||||
dirty.set(true);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public int getHistoryIndex() {
|
||||
return history.size() - 1 - (historyNegativeIndex == null ? 0 : historyNegativeIndex);
|
||||
}
|
||||
@ -360,6 +350,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get whether this session is "dirty" and has changes that needs to
|
||||
@ -395,9 +386,11 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
public void clearHistory() {
|
||||
history.clear();
|
||||
//FAWE start
|
||||
historyNegativeIndex = 0;
|
||||
historySize = 0;
|
||||
currentWorld = null;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,6 +407,7 @@ public class LocalSession implements TextureHolder {
|
||||
return;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
Player player = editSession.getPlayer();
|
||||
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
|
||||
remember(editSession, true, limit);
|
||||
@ -552,6 +546,7 @@ public class LocalSession implements TextureHolder {
|
||||
historyWriteLock.unlock();
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Performs an undo.
|
||||
@ -562,6 +557,7 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
|
||||
checkNotNull(actor);
|
||||
//FAWE start - use our logic
|
||||
World world = ((Player) actor).getWorldForEditing();
|
||||
loadSessionHistoryFromDisk(actor.getUniqueId(), world);
|
||||
if (getHistoryNegativeIndex() < history.size()) {
|
||||
@ -590,6 +586,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -599,6 +596,7 @@ public class LocalSession implements TextureHolder {
|
||||
* @param actor the actor
|
||||
* @return whether anything was redone
|
||||
*/
|
||||
//FAWE start - use our logic
|
||||
public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
|
||||
checkNotNull(actor);
|
||||
World world = ((Player) actor).getWorldForEditing();
|
||||
@ -620,6 +618,7 @@ public class LocalSession implements TextureHolder {
|
||||
return newEditSession;
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -775,14 +774,17 @@ public class LocalSession implements TextureHolder {
|
||||
* @throws EmptyClipboardException thrown if no clipboard is set
|
||||
*/
|
||||
public ClipboardHolder getClipboard() throws EmptyClipboardException {
|
||||
//FAWE start
|
||||
synchronized (clipboardLock) {
|
||||
if (clipboard == null) {
|
||||
throw new EmptyClipboardException();
|
||||
}
|
||||
//FAWE end
|
||||
return clipboard;
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Nullable
|
||||
public ClipboardHolder getExistingClipboard() {
|
||||
synchronized (clipboardLock) {
|
||||
@ -810,6 +812,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
setClipboard(multi);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Sets the clipboard.
|
||||
@ -819,6 +822,7 @@ public class LocalSession implements TextureHolder {
|
||||
* @param clipboard the clipboard, or null if the clipboard is to be cleared
|
||||
*/
|
||||
public void setClipboard(@Nullable ClipboardHolder clipboard) {
|
||||
//FAWE start
|
||||
synchronized (clipboardLock) {
|
||||
if (this.clipboard == clipboard) {
|
||||
return;
|
||||
@ -829,6 +833,7 @@ public class LocalSession implements TextureHolder {
|
||||
this.clipboard.close();
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
this.clipboard = clipboard;
|
||||
}
|
||||
}
|
||||
@ -967,7 +972,9 @@ public class LocalSession implements TextureHolder {
|
||||
@Nullable
|
||||
public BlockBag getBlockBag(Player player) {
|
||||
checkNotNull(player);
|
||||
//FAWE start - inventory mode
|
||||
if (!useInventory && player.getLimit().INVENTORY_MODE == 0) {
|
||||
//FAWE end
|
||||
return null;
|
||||
}
|
||||
return player.getInventoryBlockBag();
|
||||
@ -1044,6 +1051,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Nullable
|
||||
public Tool getTool(Player player) {
|
||||
loadDefaults(player, false);
|
||||
@ -1087,7 +1095,9 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - see deprecation note
|
||||
/**
|
||||
* Get the brush tool assigned to the item. If there is no tool assigned
|
||||
* or the tool is not assigned, the slot will be replaced with the
|
||||
@ -1114,7 +1124,7 @@ public class LocalSession implements TextureHolder {
|
||||
|
||||
public BrushTool getBrushTool(BaseItem item, Player player, boolean create) throws InvalidToolBindException {
|
||||
if (item.getType().hasBlockType()) {
|
||||
throw new InvalidToolBindException(item.getType(), "Blocks can't be used");
|
||||
throw new InvalidToolBindException(item.getType(), Caption.of("worldedit.error.blocks-cant-be-used"));
|
||||
}
|
||||
Tool tool = getTool(item, player);
|
||||
if (!(tool instanceof BrushTool)) {
|
||||
@ -1128,7 +1138,9 @@ public class LocalSession implements TextureHolder {
|
||||
|
||||
return (BrushTool) tool;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - see note of getBrushTool
|
||||
/**
|
||||
* Set the tool.
|
||||
*
|
||||
@ -1138,7 +1150,7 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException {
|
||||
if (item.hasBlockType()) {
|
||||
throw new InvalidToolBindException(item, "Blocks can't be used");
|
||||
throw new InvalidToolBindException(item, Caption.of("worldedit.error.blocks-cant-be-used"));
|
||||
}
|
||||
if (tool instanceof SelectionWand) {
|
||||
changeTool(this.wandItem, this.wandItem = item, tool);
|
||||
@ -1175,7 +1187,7 @@ public class LocalSession implements TextureHolder {
|
||||
public void setTool(BaseItem item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
|
||||
ItemType type = item.getType();
|
||||
if (type.hasBlockType() && type.getBlockType().getMaterial().isAir()) {
|
||||
throw new InvalidToolBindException(type, "Blocks can't be used");
|
||||
throw new InvalidToolBindException(type, Caption.of("worldedit.error.blocks-cant-be-used"));
|
||||
} else if (tool instanceof SelectionWand) {
|
||||
changeTool(this.wandItem, this.wandItem = item.getType(), tool);
|
||||
setDirty();
|
||||
@ -1208,6 +1220,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Returns whether inventory usage is enabled for this session.
|
||||
@ -1380,7 +1393,9 @@ public class LocalSession implements TextureHolder {
|
||||
public void describeCUI(Actor actor) {
|
||||
checkNotNull(actor);
|
||||
|
||||
//FAWE start
|
||||
// TODO preload
|
||||
//FAWE end
|
||||
|
||||
if (!hasCUISupport) {
|
||||
return;
|
||||
@ -1518,6 +1533,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
|
||||
// Create an edit session
|
||||
//FAWE start - we don't use the edit session builder yet
|
||||
EditSession editSession;
|
||||
EditSessionBuilder builder = new EditSessionBuilder(world);
|
||||
if (actor.isPlayer() && actor instanceof Player) {
|
||||
@ -1543,6 +1559,7 @@ public class LocalSession implements TextureHolder {
|
||||
|
||||
return editSession;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
private void prepareEditingExtents(EditSession editSession, Actor actor) {
|
||||
editSession.setSideEffectApplier(sideEffectSet);
|
||||
@ -1617,6 +1634,7 @@ public class LocalSession implements TextureHolder {
|
||||
return mask;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Get the mask.
|
||||
*
|
||||
@ -1625,6 +1643,7 @@ public class LocalSession implements TextureHolder {
|
||||
public Mask getSourceMask() {
|
||||
return sourceMask;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Set a mask.
|
||||
@ -1635,6 +1654,7 @@ public class LocalSession implements TextureHolder {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Set a mask.
|
||||
*
|
||||
@ -1662,6 +1682,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the preferred wand item for this user, or {@code null} to use the default
|
||||
|
@ -24,7 +24,10 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
public class TracedEditSession extends EditSession {
|
||||
/**
|
||||
* Internal use only.
|
||||
*/
|
||||
class TracedEditSession extends EditSession {
|
||||
|
||||
TracedEditSession(EventBus eventBus, World world, int maxBlocks, BlockBag blockBag, EditSessionEvent event) {
|
||||
super(eventBus, world, maxBlocks, blockBag, event);
|
||||
|
@ -59,7 +59,6 @@ import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
|
||||
import com.sk89q.worldedit.util.concurrency.LazyReference;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
||||
@ -123,10 +122,12 @@ public final class WorldEdit {
|
||||
private final SessionManager sessions = new SessionManager(this);
|
||||
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s"));
|
||||
private final Supervisor supervisor = new SimpleSupervisor();
|
||||
//FAWE start
|
||||
private final LazyReference<TranslationManager> translationManager =
|
||||
LazyReference.from(() -> new TranslationManager(
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.CONFIGURATION).getResourceLoader()
|
||||
));
|
||||
//FAWE end
|
||||
|
||||
private final BlockFactory blockFactory = new BlockFactory(this);
|
||||
private final ItemFactory itemFactory = new ItemFactory(this);
|
||||
@ -423,6 +424,7 @@ public final class WorldEdit {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public void checkMaxBrushRadius(Expression radius) throws MaxBrushRadiusException {
|
||||
double val = radius.evaluate();
|
||||
checkArgument(val >= 0, "Radius must be a positive number.");
|
||||
@ -432,6 +434,7 @@ public final class WorldEdit {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get a file relative to the defined working directory. If the specified
|
||||
@ -462,7 +465,7 @@ public final class WorldEdit {
|
||||
return getConfiguration().getWorkingDirectoryPath().resolve(path);
|
||||
}
|
||||
|
||||
//FAWE
|
||||
//FAWE start
|
||||
/**
|
||||
* Gets the path to the folder in which schematics are saved by default
|
||||
*
|
||||
@ -471,6 +474,7 @@ public final class WorldEdit {
|
||||
public Path getSchematicsFolderPath() {
|
||||
return getWorkingDirectoryPath(getConfiguration().saveDir);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the direction vector for a player's direction.
|
||||
@ -782,7 +786,7 @@ public final class WorldEdit {
|
||||
logger.warn("Failed to execute script", e);
|
||||
} finally {
|
||||
for (EditSession editSession : scriptContext.getEditSessions()) {
|
||||
editSession.flushSession();
|
||||
editSession.close();
|
||||
session.remember(editSession);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ import java.util.Locale;
|
||||
/**
|
||||
* Parent for all WorldEdit exceptions.
|
||||
*/
|
||||
//FAWE start - RuntimeException > Exception
|
||||
public abstract class WorldEditException extends RuntimeException {
|
||||
//FAWE end
|
||||
|
||||
private final Component message;
|
||||
|
||||
|
@ -42,7 +42,9 @@ public class BaseItem implements NbtValued {
|
||||
|
||||
private ItemType itemType;
|
||||
@Nullable
|
||||
//FAWE start - Use LR & CBT over CompoundTag
|
||||
private LazyReference<CompoundBinaryTag> nbtData;
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
@ -54,6 +56,25 @@ public class BaseItem implements NbtValued {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of item.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public ItemType getType() {
|
||||
return this.itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of the item.
|
||||
*
|
||||
* @param itemType The type to set
|
||||
*/
|
||||
public void setType(ItemType itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
@ -83,24 +104,6 @@ public class BaseItem implements NbtValued {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of item.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public ItemType getType() {
|
||||
return this.itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of the item.
|
||||
*
|
||||
* @param itemType The type to set
|
||||
*/
|
||||
public void setType(ItemType itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LazyReference<CompoundBinaryTag> getNbtReference() {
|
||||
@ -126,4 +129,5 @@ public class BaseItem implements NbtValued {
|
||||
|
||||
return getType().getId() + nbtString;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -70,18 +70,6 @@ public class BaseItemStack extends BaseItem {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id The item type
|
||||
* @param tag Tag value
|
||||
* @param amount amount in the stack
|
||||
*/
|
||||
public BaseItemStack(ItemType id, LazyReference<CompoundBinaryTag> tag, int amount) {
|
||||
super(id, tag);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of items in the stack.
|
||||
*
|
||||
@ -104,4 +92,18 @@ public class BaseItemStack extends BaseItem {
|
||||
return WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
|
||||
.getRegistries().getItemRegistry().getRichName(this);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id The item type
|
||||
* @param tag Tag value
|
||||
* @param amount amount in the stack
|
||||
*/
|
||||
public BaseItemStack(ItemType id, LazyReference<CompoundBinaryTag> tag, int amount) {
|
||||
super(id, tag);
|
||||
this.amount = amount;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public interface TileEntityBlock extends NbtValued {
|
||||
*
|
||||
* @return tile entity ID, non-null string
|
||||
*/
|
||||
//FAWE start - Handle method here
|
||||
default String getNbtId() {
|
||||
CompoundTag nbtData = getNbtData();
|
||||
if (nbtData == null) {
|
||||
@ -48,6 +49,7 @@ public interface TileEntityBlock extends NbtValued {
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.factory.Apply;
|
||||
import com.sk89q.worldedit.function.factory.ApplyRegion;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
@ -97,7 +97,7 @@ public class ApplyBrushCommands {
|
||||
double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class));
|
||||
RegionFactory regionFactory = REGION_FACTORY.value(parameters).asSingle(RegionFactory.class);
|
||||
BrushCommands.setOperationBasedBrush(player, localSession, Expression.compile(Double.toString(radius)),
|
||||
new Apply(generatorFactory), regionFactory, "worldedit.brush.apply");
|
||||
new ApplyRegion(generatorFactory), regionFactory, "worldedit.brush.apply");
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
|
||||
@ -38,6 +39,7 @@ import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -100,6 +102,12 @@ public class ChunkCommands {
|
||||
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
|
||||
final Region region = session.getSelection(world);
|
||||
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor,
|
||||
() -> new ChunkListPaginationBox(region).create(page),
|
||||
TranslatableComponent.of(
|
||||
"worldedit.listchunks.listfor",
|
||||
TextComponent.of(actor.getName())
|
||||
));
|
||||
actor.print(new ChunkListPaginationBox(region).create(page));
|
||||
actor.print(Caption.of("worldedit.listchunks.listfor", TextComponent.of(actor.getName())));
|
||||
}
|
||||
@ -178,6 +186,10 @@ public class ChunkCommands {
|
||||
|
||||
ChunkListPaginationBox(Region region) {
|
||||
super("Selected Chunks", "/listchunks -p %page%");
|
||||
// TODO make efficient/streamable/calculable implementations of this
|
||||
// for most region types, so we can just store the region and random-access get one page of chunks
|
||||
// (this is non-trivial for some types of selections...)
|
||||
//this.region = region.clone();
|
||||
this.chunks = new ArrayList<>(region.getChunks());
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,13 @@ import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.object.FaweLimit;
|
||||
import com.fastasyncworldedit.core.object.RunnableVal;
|
||||
import com.fastasyncworldedit.core.object.clipboard.DiskOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.object.clipboard.MultiClipboardHolder;
|
||||
import com.fastasyncworldedit.core.object.clipboard.ReadOnlyClipboard;
|
||||
import com.fastasyncworldedit.core.object.clipboard.URIClipboardHolder;
|
||||
import com.fastasyncworldedit.core.object.exception.FaweException;
|
||||
import com.fastasyncworldedit.core.object.io.FastByteArrayOutputStream;
|
||||
import com.fastasyncworldedit.core.util.task.RunnableVal;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.DiskOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
|
||||
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||
import com.fastasyncworldedit.core.internal.io.FastByteArrayOutputStream;
|
||||
import com.fastasyncworldedit.core.util.ImgurUtility;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.fastasyncworldedit.core.util.MaskTraverser;
|
||||
@ -45,7 +45,7 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.PasteEvent;
|
||||
import com.fastasyncworldedit.core.event.extent.PasteEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -119,6 +119,7 @@ public class ClipboardCommands {
|
||||
boolean copyEntities,
|
||||
@Switch(name = 'b', desc = "Also copy biomes")
|
||||
boolean copyBiomes,
|
||||
//FAWE start
|
||||
@Switch(name = 'c', desc = "Set the origin of the clipboard to the center of the copied region")
|
||||
boolean centerClipboard,
|
||||
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
|
||||
@ -165,8 +166,10 @@ public class ClipboardCommands {
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
|
||||
copy.getStatusMessages().forEach(actor::print);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "/lazycopy",
|
||||
desc = "Lazily copy the selection to the clipboard"
|
||||
@ -223,6 +226,7 @@ public class ClipboardCommands {
|
||||
session.setClipboard(new ClipboardHolder(lazyClipboard));
|
||||
actor.print(Caption.of("fawe.worldedit.cut.command.cut.lazy", region.getArea()));
|
||||
}*/
|
||||
//FAWE end
|
||||
|
||||
@Command(
|
||||
name = "/cut",
|
||||
@ -243,6 +247,7 @@ public class ClipboardCommands {
|
||||
boolean copyBiomes,
|
||||
@ArgFlag(name = 'm', desc = "Set the exclude mask, non-matching blocks become air")
|
||||
Mask mask) throws WorldEditException {
|
||||
//FAWE start - Inject limits & respect source mask
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
@ -289,8 +294,10 @@ public class ClipboardCommands {
|
||||
actor.print(Caption.of("fawe.tips.tip.lazycut"));
|
||||
}
|
||||
copy.getStatusMessages().forEach(actor::print);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "download",
|
||||
aliases = { "/download" },
|
||||
@ -329,7 +336,7 @@ public class ClipboardCommands {
|
||||
final LocalConfiguration config = WorldEdit.getInstance().getConfiguration();
|
||||
final File working = WorldEdit.getInstance().getWorkingDirectoryFile(config.saveDir).getAbsoluteFile();
|
||||
|
||||
url = MainUtil.upload(null, null, "zip", new RunnableVal<OutputStream>() {
|
||||
url = MainUtil.upload(null, null, "zip", new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(OutputStream out) {
|
||||
try (ZipOutputStream zos = new ZipOutputStream(out)) {
|
||||
@ -388,6 +395,61 @@ public class ClipboardCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/place",
|
||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.place")
|
||||
@Logging(PLACEMENT)
|
||||
public void place(Actor actor, World world, LocalSession session, final EditSession editSession,
|
||||
@Switch(name = 'a', desc = "Skip air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'o', desc = "Paste at the original position")
|
||||
boolean atOrigin,
|
||||
@Switch(name = 's', desc = "Select the region after pasting")
|
||||
boolean selectPasted,
|
||||
@Switch(name = 'e', desc = "Paste entities if available")
|
||||
boolean pasteEntities,
|
||||
@Switch(name = 'b', desc = "Paste biomes if available")
|
||||
boolean pasteBiomes) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
final Clipboard clipboard = holder.getClipboard();
|
||||
final BlockVector3 origin = clipboard.getOrigin();
|
||||
final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(actor);
|
||||
checkPaste(actor, editSession, to, holder, clipboard);
|
||||
|
||||
clipboard.paste(editSession, to, !ignoreAirBlocks, pasteEntities, pasteBiomes);
|
||||
|
||||
Region region = clipboard.getRegion().clone();
|
||||
if (selectPasted) {
|
||||
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 realTo = to.add(holder.getTransform().apply(clipboardOffset.toVector3()).toBlockPoint());
|
||||
BlockVector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()).toBlockPoint());
|
||||
RegionSelector selector = new CuboidRegionSelector(world, realTo, max);
|
||||
session.setRegionSelector(world, selector);
|
||||
selector.learnChanges();
|
||||
selector.explainRegionAdjust(actor, session);
|
||||
}
|
||||
actor.print(Caption.of("fawe.worldedit.paste.command.paste", to));
|
||||
|
||||
if (!actor.hasPermission("fawe.tips")) {
|
||||
actor.print(Caption.of("fawe.tips.tip.copypaste"));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveDiskClipboard(Clipboard clipboard) {
|
||||
DiskOptimizedClipboard c;
|
||||
if (clipboard instanceof DiskOptimizedClipboard)
|
||||
c = (DiskOptimizedClipboard) clipboard;
|
||||
else if (clipboard instanceof BlockArrayClipboard
|
||||
&& ((BlockArrayClipboard) clipboard).getParent() instanceof DiskOptimizedClipboard)
|
||||
c = (DiskOptimizedClipboard) ((BlockArrayClipboard) clipboard).getParent();
|
||||
else
|
||||
return;
|
||||
c.flush();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Command(
|
||||
name = "/paste",
|
||||
aliases = {"/p", "/pa"},
|
||||
@ -414,8 +476,10 @@ public class ClipboardCommands {
|
||||
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) {
|
||||
//FAWE start - use place
|
||||
place(actor, world, session, editSession, ignoreAirBlocks, atOrigin, selectPasted,
|
||||
pasteEntities, pasteBiomes);
|
||||
//FAWE end
|
||||
return;
|
||||
}
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
@ -423,7 +487,9 @@ public class ClipboardCommands {
|
||||
List<Component> messages = Lists.newArrayList();
|
||||
|
||||
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor);
|
||||
//FAWE start
|
||||
checkPaste(actor, editSession, to, holder, clipboard);
|
||||
//FAWE end
|
||||
|
||||
if (!onlySelect) {
|
||||
Operation operation = holder
|
||||
@ -456,6 +522,7 @@ public class ClipboardCommands {
|
||||
messages.forEach(actor::print);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
private void checkPaste(Actor player, EditSession editSession, BlockVector3 to, ClipboardHolder holder, Clipboard clipboard) {
|
||||
URI uri = null;
|
||||
if (holder instanceof URIClipboardHolder) {
|
||||
@ -467,48 +534,7 @@ public class ClipboardCommands {
|
||||
throw new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.manual"));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/place",
|
||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.place")
|
||||
@Logging(PLACEMENT)
|
||||
public void place(Actor actor, World world, LocalSession session, final EditSession editSession,
|
||||
@Switch(name = 'a', desc = "Skip air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'o', desc = "Paste at the original position")
|
||||
boolean atOrigin,
|
||||
@Switch(name = 's', desc = "Select the region after pasting")
|
||||
boolean selectPasted,
|
||||
@Switch(name = 'e', desc = "Paste entities if available")
|
||||
boolean pasteEntities,
|
||||
@Switch(name = 'b', desc = "Paste biomes if available")
|
||||
boolean pasteBiomes) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
final Clipboard clipboard = holder.getClipboard();
|
||||
final BlockVector3 origin = clipboard.getOrigin();
|
||||
final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(actor);
|
||||
checkPaste(actor, editSession, to, holder, clipboard);
|
||||
|
||||
clipboard.paste(editSession, to, !ignoreAirBlocks, pasteEntities, pasteBiomes);
|
||||
|
||||
Region region = clipboard.getRegion().clone();
|
||||
if (selectPasted) {
|
||||
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 realTo = to.add(holder.getTransform().apply(clipboardOffset.toVector3()).toBlockPoint());
|
||||
BlockVector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()).toBlockPoint());
|
||||
RegionSelector selector = new CuboidRegionSelector(world, realTo, max);
|
||||
session.setRegionSelector(world, selector);
|
||||
selector.learnChanges();
|
||||
selector.explainRegionAdjust(actor, session);
|
||||
}
|
||||
actor.print(Caption.of("fawe.worldedit.paste.command.paste", to));
|
||||
|
||||
if (!actor.hasPermission("fawe.tips")) {
|
||||
actor.print(Caption.of("fawe.tips.tip.copypaste"));
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Command(
|
||||
name = "/rotate",
|
||||
@ -559,16 +585,4 @@ public class ClipboardCommands {
|
||||
session.setClipboard(null);
|
||||
actor.print(Caption.of("worldedit.clearclipboard.cleared"));
|
||||
}
|
||||
|
||||
private void saveDiskClipboard(Clipboard clipboard) {
|
||||
DiskOptimizedClipboard c;
|
||||
if (clipboard instanceof DiskOptimizedClipboard)
|
||||
c = (DiskOptimizedClipboard) clipboard;
|
||||
else if (clipboard instanceof BlockArrayClipboard
|
||||
&& ((BlockArrayClipboard) clipboard).getParent() instanceof DiskOptimizedClipboard)
|
||||
c = (DiskOptimizedClipboard) ((BlockArrayClipboard) clipboard).getParent();
|
||||
else
|
||||
return;
|
||||
c.flush();
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ public class FlattenedClipboardTransform {
|
||||
minimum.withZ(maximum.getZ()),
|
||||
maximum.withX(minimum.getX()),
|
||||
maximum.withY(minimum.getY()),
|
||||
maximum.withZ(minimum.getZ()) };
|
||||
maximum.withZ(minimum.getZ())
|
||||
};
|
||||
|
||||
for (int i = 0; i < corners.length; i++) {
|
||||
corners[i] = transformAround.apply(corners[i]);
|
||||
@ -112,10 +113,12 @@ public class FlattenedClipboardTransform {
|
||||
* @return the operation
|
||||
*/
|
||||
public Operation copyTo(Extent target) {
|
||||
//FAWE start
|
||||
Extent extent = original;
|
||||
if (transform != null && !transform.isIdentity()) {
|
||||
extent = new BlockTransformExtent(original, transform);
|
||||
}
|
||||
//FAWE end
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(extent, original.getRegion(), original.getOrigin(), target, original.getOrigin());
|
||||
copy.setTransform(transform);
|
||||
if (original.hasBiomes()) {
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.command;
|
||||
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.util.CachedTextureUtil;
|
||||
import com.fastasyncworldedit.core.util.CleanTextureUtil;
|
||||
import com.fastasyncworldedit.core.util.MathMan;
|
||||
@ -48,6 +48,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.internal.command.CommandUtil;
|
||||
import com.sk89q.worldedit.internal.cui.ServerCUIHandler;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
@ -102,7 +103,7 @@ public class GeneralCommands {
|
||||
Set<org.enginehub.piston.Command> commands = collect.getAllCommands()
|
||||
.collect(Collectors.toSet());
|
||||
for (org.enginehub.piston.Command command : commands) {
|
||||
/*if in FAWE, //fast will remain for now
|
||||
/*FAWE start - if in FAWE, //fast will remain for now
|
||||
(command.getName().equals("/fast")) {
|
||||
|
||||
// deprecate to `//perf`
|
||||
@ -211,30 +212,6 @@ public class GeneralCommands {
|
||||
actor.print(component);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/fast",
|
||||
desc = "Toggle fast mode"
|
||||
)
|
||||
@CommandPermissions("worldedit.fast")
|
||||
@Deprecated
|
||||
void fast(Actor actor, LocalSession session,
|
||||
@Arg(desc = "The new fast mode state", def = "")
|
||||
Boolean fastMode) {
|
||||
boolean hasFastMode = session.hasFastMode();
|
||||
if (fastMode != null && fastMode == hasFastMode) {
|
||||
actor.print(Caption.of(fastMode ? "worldedit.fast.enabled.already" : "worldedit.fast.disabled.already"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasFastMode) {
|
||||
session.setFastMode(false);
|
||||
actor.print(Caption.of("worldedit.fast.disabled"));
|
||||
} else {
|
||||
session.setFastMode(true);
|
||||
actor.print(Caption.of("worldedit.fast.enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/perf",
|
||||
desc = "Toggle side effects for performance",
|
||||
@ -338,7 +315,8 @@ public class GeneralCommands {
|
||||
} else {
|
||||
session.setUseServerCUI(true);
|
||||
session.updateServerCUI(player);
|
||||
player.print(Caption.of("worldedit.drawsel.enabled"));
|
||||
int maxSize = ServerCUIHandler.getMaxServerCuiSize();
|
||||
player.print(Caption.of("worldedit.drawsel.enabled", TextComponent.of(maxSize), TextComponent.of(maxSize), TextComponent.of(maxSize)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,6 +465,7 @@ public class GeneralCommands {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "/gtexture",
|
||||
aliases = {"gtexture"},
|
||||
@ -601,4 +580,29 @@ public class GeneralCommands {
|
||||
player.print(Caption.of("fawe.info.worldedit.toggle.tips.off"));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/fast",
|
||||
desc = "Toggle fast mode"
|
||||
)
|
||||
@CommandPermissions("worldedit.fast")
|
||||
@Deprecated
|
||||
void fast(Actor actor, LocalSession session,
|
||||
@Arg(desc = "The new fast mode state", def = "")
|
||||
Boolean fastMode) {
|
||||
boolean hasFastMode = session.hasFastMode();
|
||||
if (fastMode != null && fastMode == hasFastMode) {
|
||||
actor.print(Caption.of(fastMode ? "worldedit.fast.enabled.already" : "worldedit.fast.disabled.already"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasFastMode) {
|
||||
session.setFastMode(false);
|
||||
actor.print(Caption.of("worldedit.fast.disabled"));
|
||||
} else {
|
||||
session.setFastMode(true);
|
||||
actor.print(Caption.of("worldedit.fast.enabled"));
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.function.generator.CavesGen;
|
||||
import com.fastasyncworldedit.core.function.generator.CavesGen;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
@ -87,111 +87,6 @@ public class GenerationCommands {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/caves",
|
||||
desc = "Generates a cave network"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.caves")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void caves(Actor actor, LocalSession session, EditSession editSession, @Selection Region region,
|
||||
@Arg(name = "size", desc = "TODO", def = "8") int sizeOpt,
|
||||
@Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt,
|
||||
@Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt,
|
||||
@Arg(name = "minY", desc = "TODO", def = "8") int minYOpt,
|
||||
@Arg(name = "maxY", desc = "TODO", def = "127") int maxYOpt,
|
||||
@Arg(name = "systemFrequency", desc = "TODO", def = "1") int systemFrequencyOpt,
|
||||
@Arg(name = "individualRarity", desc = "TODO", def = "25") int individualRarityOpt,
|
||||
@Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChanceOpt,
|
||||
@Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMinOpt,
|
||||
@Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException {
|
||||
CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt);
|
||||
editSession.generate(region, gen);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/ores",
|
||||
desc = "Generates ores"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
|
||||
editSession.addOres(region, mask);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/img",
|
||||
aliases = { "/image", "image" },
|
||||
desc = "Generate an image"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.image")
|
||||
@Logging(PLACEMENT)
|
||||
public void image(Actor actor,
|
||||
LocalSession session,
|
||||
EditSession editSession,
|
||||
@Arg(desc = "Image URL (imgur only)") String imageURL,
|
||||
@Arg(desc = "boolean", def = "true") boolean randomize,
|
||||
@Arg(desc = "TODO", def = "100") int threshold,
|
||||
@Arg(desc = "BlockVector2", def = "") BlockVector2 dimensions) throws WorldEditException, IOException {
|
||||
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
||||
URL url = new URL(imageURL);
|
||||
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
|
||||
throw new IOException("Only i.imgur.com links are allowed!");
|
||||
}
|
||||
BufferedImage image = MainUtil.readImage(url);
|
||||
if (dimensions != null) {
|
||||
image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(),
|
||||
RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||
}
|
||||
|
||||
BlockVector3 pos1 = session.getPlacementPosition(actor);
|
||||
BlockVector3 pos2 = pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1);
|
||||
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
||||
int[] count = new int[1];
|
||||
final BufferedImage finalImage = image;
|
||||
RegionVisitor visitor = new RegionVisitor(region, pos -> {
|
||||
try {
|
||||
int x = pos.getBlockX() - pos1.getBlockX();
|
||||
int z = pos.getBlockZ() - pos1.getBlockZ();
|
||||
int color = finalImage.getRGB(x, z);
|
||||
BlockType block = tu.getNearestBlock(color);
|
||||
count[0]++;
|
||||
if (block != null) {
|
||||
return editSession.setBlock(pos, block.getDefaultState());
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
Operations.completeBlindly(visitor);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(name = "/ore", desc = "Generates ores")
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void ore(Actor actor,
|
||||
LocalSession session,
|
||||
EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "Mask") Mask mask,
|
||||
@Arg(desc = "Pattern") Pattern material,
|
||||
@Arg(desc = "Ore vein size") @Range(from = 0, to = Integer.MAX_VALUE) int size,
|
||||
@Arg(desc = "Ore vein frequency (number of times to attempt to place ore)", def = "10") @Range(from = 0, to = Integer.MAX_VALUE) int freq,
|
||||
@Arg(desc = "Ore vein rarity (% chance each attempt is placed)", def = "100") @Range(from = 0, to = 100) int rarity,
|
||||
@Arg(desc = "Ore vein min y", def = "0") @Range(from = 0, to = 255) int minY,
|
||||
@Arg(desc = "Ore vein max y", def = "63") @Range(from = 0, to = 255) int maxY) throws WorldEditException {
|
||||
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/hcyl",
|
||||
desc = "Generates a hollow cylinder."
|
||||
@ -539,4 +434,111 @@ public class GenerationCommands {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "/caves",
|
||||
desc = "Generates a cave network"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.caves")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void caves(Actor actor, LocalSession session, EditSession editSession, @Selection Region region,
|
||||
@Arg(name = "size", desc = "TODO", def = "8") int sizeOpt,
|
||||
@Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt,
|
||||
@Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt,
|
||||
@Arg(name = "minY", desc = "TODO", def = "8") int minYOpt,
|
||||
@Arg(name = "maxY", desc = "TODO", def = "127") int maxYOpt,
|
||||
@Arg(name = "systemFrequency", desc = "TODO", def = "1") int systemFrequencyOpt,
|
||||
@Arg(name = "individualRarity", desc = "TODO", def = "25") int individualRarityOpt,
|
||||
@Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChanceOpt,
|
||||
@Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMinOpt,
|
||||
@Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException {
|
||||
CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt);
|
||||
editSession.generate(region, gen);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/ores",
|
||||
desc = "Generates ores"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
|
||||
editSession.addOres(region, mask);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/img",
|
||||
aliases = { "/image", "image" },
|
||||
desc = "Generate an image"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.image")
|
||||
@Logging(PLACEMENT)
|
||||
public void image(Actor actor,
|
||||
LocalSession session,
|
||||
EditSession editSession,
|
||||
@Arg(desc = "Image URL (imgur only)") String imageURL,
|
||||
@Arg(desc = "boolean", def = "true") boolean randomize,
|
||||
@Arg(desc = "TODO", def = "100") int threshold,
|
||||
@Arg(desc = "BlockVector2", def = "") BlockVector2 dimensions) throws WorldEditException, IOException {
|
||||
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
||||
URL url = new URL(imageURL);
|
||||
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
|
||||
throw new IOException("Only i.imgur.com links are allowed!");
|
||||
}
|
||||
BufferedImage image = MainUtil.readImage(url);
|
||||
if (dimensions != null) {
|
||||
image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(),
|
||||
RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||
}
|
||||
|
||||
BlockVector3 pos1 = session.getPlacementPosition(actor);
|
||||
BlockVector3 pos2 = pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1);
|
||||
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
||||
int[] count = new int[1];
|
||||
final BufferedImage finalImage = image;
|
||||
RegionVisitor visitor = new RegionVisitor(region, pos -> {
|
||||
try {
|
||||
int x = pos.getBlockX() - pos1.getBlockX();
|
||||
int z = pos.getBlockZ() - pos1.getBlockZ();
|
||||
int color = finalImage.getRGB(x, z);
|
||||
BlockType block = tu.getNearestBlock(color);
|
||||
count[0]++;
|
||||
if (block != null) {
|
||||
return editSession.setBlock(pos, block.getDefaultState());
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
Operations.completeBlindly(visitor);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
||||
@Command(name = "/ore", desc = "Generates ores")
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void ore(Actor actor,
|
||||
LocalSession session,
|
||||
EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "Mask") Mask mask,
|
||||
@Arg(desc = "Pattern") Pattern material,
|
||||
@Arg(desc = "Ore vein size") @Range(from = 0, to = Integer.MAX_VALUE) int size,
|
||||
@Arg(desc = "Ore vein frequency (number of times to attempt to place ore)", def = "10") @Range(from = 0, to = Integer.MAX_VALUE) int freq,
|
||||
@Arg(desc = "Ore vein rarity (% chance each attempt is placed)", def = "100") @Range(from = 0, to = 100) int rarity,
|
||||
@Arg(desc = "Ore vein min y", def = "0") @Range(from = 0, to = 255) int minY,
|
||||
@Arg(desc = "Ore vein max y", def = "63") @Range(from = 0, to = 255) int maxY) throws WorldEditException {
|
||||
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
@ -68,10 +68,12 @@ public class HistoryCommands {
|
||||
String playerName) throws WorldEditException {
|
||||
times = Math.max(1, times);
|
||||
LocalSession undoSession = session;
|
||||
//FAWE start - Add fastmode check
|
||||
if (session.hasFastMode()) {
|
||||
actor.print(Caption.of("fawe.worldedit.history.command.undo.disabled"));
|
||||
return;
|
||||
}
|
||||
//FAWE end
|
||||
if (playerName != null) {
|
||||
actor.checkPermission("worldedit.history.undo.other");
|
||||
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||
|
@ -6,9 +6,9 @@ import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.database.DBHandler;
|
||||
import com.fastasyncworldedit.core.database.RollbackDatabase;
|
||||
import com.fastasyncworldedit.core.logging.RollbackOptimizedHistory;
|
||||
import com.fastasyncworldedit.core.object.RegionWrapper;
|
||||
import com.fastasyncworldedit.core.object.changeset.SimpleChangeSetSummary;
|
||||
import com.fastasyncworldedit.core.history.RollbackOptimizedHistory;
|
||||
import com.fastasyncworldedit.core.regions.RegionWrapper;
|
||||
import com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.fastasyncworldedit.core.util.StringMan;
|
||||
import com.google.common.base.Function;
|
||||
@ -22,8 +22,8 @@ import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.internal.annotation.AllowedRegion;
|
||||
import com.sk89q.worldedit.internal.annotation.Time;
|
||||
import com.sk89q.worldedit.command.util.annotation.AllowedRegion;
|
||||
import com.sk89q.worldedit.command.util.annotation.Time;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -76,7 +76,7 @@ public class HistorySubCommands {
|
||||
+ " - The time uses s, m, h, d, y.\n"
|
||||
+ " - Import from disk: /history import"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.redo")
|
||||
@CommandPermissions("worldedit.history.restore")
|
||||
@Confirm
|
||||
public synchronized void rerun(Player player, World world, RollbackDatabase database,
|
||||
@AllowedRegion Region[] allowedRegions,
|
||||
@ -96,7 +96,7 @@ public class HistorySubCommands {
|
||||
desc = "Undo a specific edit. "
|
||||
+ " - The time uses s, m, h, d, y."
|
||||
)
|
||||
@CommandPermissions("worldedit.history.undo")
|
||||
@CommandPermissions("worldedit.history.rollback")
|
||||
@Confirm
|
||||
public synchronized void rollback(Player player, World world, RollbackDatabase database,
|
||||
@AllowedRegion Region[] allowedRegions,
|
||||
|
@ -1,132 +0,0 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.util.StringMan;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
//TODO This class breaks compilation
|
||||
//@CommandContainer
|
||||
public class ListFilters {
|
||||
public class Filter {
|
||||
public boolean listPrivate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean listPublic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public File getPath(File root) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean applies(File file) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "all",
|
||||
desc = "List both public and private schematics"
|
||||
)
|
||||
public Filter all() {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean listPublic() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "local",
|
||||
aliases = {"me", "mine", "private"},
|
||||
desc = "List your personal schematics"
|
||||
)
|
||||
public Filter local() {
|
||||
return new Filter();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "global",
|
||||
aliases = {"public"},
|
||||
desc = "List public schematics"
|
||||
)
|
||||
public Filter global() {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean listPrivate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean listPublic() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "*", //TODO NOT IMPLEMENTED originally this was left blank but doing so causes a major compilation error
|
||||
desc = "wildcard"
|
||||
)
|
||||
public Filter wildcard(Actor actor, File root, String arg) {
|
||||
arg = arg.replace("/", File.separator);
|
||||
String argLower = arg.toLowerCase(Locale.ROOT);
|
||||
if (arg.endsWith(File.separator)) {
|
||||
String finalArg = arg;
|
||||
return new Filter() {
|
||||
@Override
|
||||
public File getPath(File root) {
|
||||
File newRoot = new File(root, finalArg);
|
||||
if (newRoot.exists()) {
|
||||
return newRoot;
|
||||
}
|
||||
String firstArg = finalArg.substring(0, finalArg.length() - File.separator.length());
|
||||
if (firstArg.length() > 3 && firstArg.length() <= 16) {
|
||||
UUID fromName = Fawe.imp().getUUID(finalArg);
|
||||
if (fromName != null) {
|
||||
newRoot = new File(root, finalArg);
|
||||
if (newRoot.exists()) {
|
||||
return newRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new StopExecutionException(TextComponent.of("Cannot find path: " + finalArg));
|
||||
}
|
||||
};
|
||||
} else {
|
||||
if (StringMan.containsAny(arg, "\\^$.|?+(){}<>~$!%^&*+-/")) {
|
||||
Pattern pattern;
|
||||
try {
|
||||
pattern = Pattern.compile(argLower);
|
||||
} catch (PatternSyntaxException ignored) {
|
||||
pattern = Pattern.compile(Pattern.quote(argLower));
|
||||
}
|
||||
Pattern finalPattern = pattern;
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean applies(File file) {
|
||||
String path = file.getPath().toLowerCase(Locale.ROOT);
|
||||
return finalPattern.matcher(path).find();
|
||||
}
|
||||
};
|
||||
}
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean applies(File file) {
|
||||
return StringMan.containsIgnoreCase(file.getPath(), argLower);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
// TODO: Ping @MattBDev to reimplement (or remove because this class is stupid) 2020-02-04
|
||||
//package com.sk89q.worldedit.command;
|
||||
//
|
||||
//import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||
//import com.boydti.fawe.object.mask.AdjacentMask;
|
||||
//import com.boydti.fawe.object.mask.AngleMask;
|
||||
//import com.boydti.fawe.object.mask.BiomeMask;
|
||||
//import com.boydti.fawe.object.mask.BlockLightMask;
|
||||
//import com.boydti.fawe.object.mask.BrightnessMask;
|
||||
//import com.boydti.fawe.object.mask.ExtremaMask;
|
||||
//import com.boydti.fawe.object.mask.LightMask;
|
||||
//import com.boydti.fawe.object.mask.OpacityMask;
|
||||
//import com.boydti.fawe.object.mask.ROCAngleMask;
|
||||
//import com.boydti.fawe.object.mask.RadiusMask;
|
||||
//import com.boydti.fawe.object.mask.RandomMask;
|
||||
//import com.boydti.fawe.object.mask.SimplexMask;
|
||||
//import com.boydti.fawe.object.mask.SkyLightMask;
|
||||
//import com.boydti.fawe.object.mask.SurfaceMask;
|
||||
//import com.boydti.fawe.object.mask.WallMask;
|
||||
//import com.boydti.fawe.function.mask.XAxisMask;
|
||||
//import com.boydti.fawe.function.mask.YAxisMask;
|
||||
//import com.boydti.fawe.function.mask.ZAxisMask;
|
||||
//import com.sk89q.worldedit.IncompleteRegionException;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.WorldEdit;
|
||||
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.extent.Extent;
|
||||
//import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
//import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
//import com.sk89q.worldedit.function.mask.ExpressionMask;
|
||||
//import com.sk89q.worldedit.function.mask.Mask;
|
||||
//import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
//import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
//import com.sk89q.worldedit.function.mask.Masks;
|
||||
//import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
//import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
//import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||
//import com.sk89q.worldedit.internal.expression.ExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
//import com.sk89q.worldedit.math.BlockVector3;
|
||||
//import com.sk89q.worldedit.math.Vector3;
|
||||
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.session.request.RequestSelection;
|
||||
//import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
//import org.enginehub.piston.annotation.Command;
|
||||
//import org.enginehub.piston.annotation.CommandContainer;
|
||||
//import org.enginehub.piston.annotation.param.Arg;
|
||||
//import org.enginehub.piston.annotation.param.Switch;
|
||||
//
|
||||
////@Command(aliases = {"masks"},
|
||||
//// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
|
||||
//// descFooter = "Masks determine if a block can be placed\n" +
|
||||
//// " - Use [brackets] for arguments\n" +
|
||||
//// " - Use , to OR multiple\n" +
|
||||
//// " - Use & to AND multiple\n" +
|
||||
//// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
|
||||
//// "More Info: https://git.io/v9r4K"
|
||||
////)
|
||||
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//public class MaskCommands {
|
||||
// private final WorldEdit worldEdit;
|
||||
//
|
||||
// public MaskCommands(WorldEdit worldEdit) {
|
||||
// this.worldEdit = worldEdit;
|
||||
// }
|
||||
// @Command(
|
||||
// name = "#light",
|
||||
// desc = "Restrict to specific light levels"
|
||||
// )
|
||||
// public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new LightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#skylight",
|
||||
// desc = "Restrict to specific sky light levels"
|
||||
// )
|
||||
// public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#blocklight",
|
||||
// aliases = {"#emittedlight"},
|
||||
// desc = "Restrict to specific block light levels"
|
||||
// )
|
||||
// public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#opacity",
|
||||
// desc = "Restrict to specific opacity levels"
|
||||
// )
|
||||
// public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#brightness",
|
||||
// desc = "Restrict to specific block brightness"
|
||||
// )
|
||||
// public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#haslight",
|
||||
// desc = "Restricts to blocks with light (sky or emitted)"
|
||||
// )
|
||||
// public Mask haslight(Extent extent) {
|
||||
// return new LightMask(extent, 1, Integer.MAX_VALUE);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#nolight",
|
||||
// desc = "Restrict to blocks without light (sky or emitted)"
|
||||
// )
|
||||
// public Mask nolight(Extent extent) {
|
||||
// return new LightMask(extent, 0, 0);
|
||||
// }
|
||||
|
||||
// @Command(
|
||||
// name = "#iddata",
|
||||
// desc = "Restrict to initial block id and data"
|
||||
// )
|
||||
// public Mask iddata(Extent extent) {
|
||||
// return new IdDataMask(extent);
|
||||
// }
|
||||
//}
|
@ -1,19 +0,0 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MethodCommands {
|
||||
|
||||
public static String getArguments(InjectedValueAccess context) {
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
Optional<Arguments> arguments = context.injectedValue(Key.of(Arguments.class));
|
||||
return arguments.map(Arguments::get).orElse(null);
|
||||
}
|
||||
|
||||
}
|
@ -151,20 +151,22 @@ public class NavigationCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "jumpto",
|
||||
aliases = { "j", "/jumpto", "/j" },
|
||||
desc = "Teleport to a location"
|
||||
name = "jumpto",
|
||||
aliases = { "j", "/jumpto", "/j" },
|
||||
desc = "Teleport to a location"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.jumpto.command")
|
||||
public void jumpTo(Player player,
|
||||
@Arg(desc = "Location to jump to", def = "")
|
||||
Location pos,
|
||||
@Switch(name = 'f', desc = "force teleport")
|
||||
boolean force) throws WorldEditException {
|
||||
@Arg(desc = "Location to jump to", def = "")
|
||||
Location pos,
|
||||
//FAWE start
|
||||
@Switch(name = 'f', desc = "force teleport")
|
||||
boolean force) throws WorldEditException {
|
||||
|
||||
if (pos == null) {
|
||||
pos = player.getSolidBlockTrace(300);
|
||||
}
|
||||
//FAWE end
|
||||
if (pos != null) {
|
||||
player.findFreePosition(pos);
|
||||
player.print(Caption.of("worldedit.jumpto.moved"));
|
||||
|
@ -1,356 +0,0 @@
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
//package com.sk89q.worldedit.command;
|
||||
//
|
||||
//import com.boydti.fawe.object.DataAnglePattern;
|
||||
//import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
//import com.boydti.fawe.object.collection.RandomCollection;
|
||||
//import com.boydti.fawe.object.pattern.AngleColorPattern;
|
||||
//import com.boydti.fawe.object.pattern.AverageColorPattern;
|
||||
//import com.boydti.fawe.object.pattern.BiomePattern;
|
||||
//import com.boydti.fawe.object.pattern.BufferedPattern;
|
||||
//import com.boydti.fawe.object.pattern.BufferedPattern2D;
|
||||
//import com.boydti.fawe.object.pattern.DataPattern;
|
||||
//import com.boydti.fawe.object.pattern.DesaturatePattern;
|
||||
//import com.boydti.fawe.object.pattern.ExistingPattern;
|
||||
//import com.boydti.fawe.object.pattern.ExpressionPattern;
|
||||
//import com.boydti.fawe.object.pattern.FullClipboardPattern;
|
||||
//import com.boydti.fawe.object.pattern.IdDataMaskPattern;
|
||||
//import com.boydti.fawe.object.pattern.IdPattern;
|
||||
//import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
|
||||
//import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
|
||||
//import com.boydti.fawe.object.pattern.LinearBlockPattern;
|
||||
//import com.boydti.fawe.object.pattern.MaskedPattern;
|
||||
//import com.boydti.fawe.object.pattern.NoXPattern;
|
||||
//import com.boydti.fawe.object.pattern.NoYPattern;
|
||||
//import com.boydti.fawe.object.pattern.NoZPattern;
|
||||
//import com.boydti.fawe.object.pattern.OffsetPattern;
|
||||
//import com.boydti.fawe.object.pattern.PropertyPattern;
|
||||
//import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
|
||||
//import com.boydti.fawe.object.pattern.RandomOffsetPattern;
|
||||
//import com.boydti.fawe.object.pattern.RelativePattern;
|
||||
//import com.boydti.fawe.object.pattern.SaturatePattern;
|
||||
//import com.boydti.fawe.object.pattern.ShadePattern;
|
||||
//import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
|
||||
//import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
|
||||
//import com.boydti.fawe.object.random.SimplexRandom;
|
||||
//import com.boydti.fawe.util.ColorUtil;
|
||||
//import com.boydti.fawe.util.TextureUtil;
|
||||
//import com.sk89q.worldedit.EmptyClipboardException;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||
//import com.sk89q.worldedit.extent.Extent;
|
||||
//import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
//import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
//import com.sk89q.worldedit.function.mask.Mask;
|
||||
//import com.sk89q.worldedit.function.pattern.ClipboardPattern;
|
||||
//import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
//import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||
//import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
//import com.sk89q.worldedit.math.Vector3;
|
||||
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
//import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
//import java.awt.Color;
|
||||
//import java.io.IOException;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//import org.enginehub.piston.annotation.Command;
|
||||
//import org.enginehub.piston.annotation.CommandContainer;
|
||||
//import org.enginehub.piston.annotation.param.Arg;
|
||||
//import org.jetbrains.annotations.Range;
|
||||
//
|
||||
////@Command(aliases = {"patterns"},
|
||||
//// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
|
||||
//// descFooter = "Patterns determine what blocks are placed\n" +
|
||||
//// " - Use [brackets] for arguments\n" +
|
||||
//// " - Use , to OR multiple\n" +
|
||||
//// "e.g., #surfacespread[10][#existing],andesite\n" +
|
||||
//// "More Info: https://git.io/vSPmA"
|
||||
////)
|
||||
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//public class PatternCommands {
|
||||
//
|
||||
//
|
||||
// @Command(
|
||||
// name = "#simplex",
|
||||
// desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
|
||||
//)
|
||||
// public Pattern simplex(@Arg(desc = "scale factor") double scale, @Arg(desc = "Pattern") Pattern other) {
|
||||
// if (other instanceof RandomPattern) {
|
||||
// scale = (1d / Math.max(1, scale));
|
||||
// RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
|
||||
// collection.setRandom(new SimplexRandom(scale));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#color",
|
||||
// desc = "Use the block closest to a specific color"
|
||||
//)
|
||||
// public Pattern color(TextureUtil textureUtil, @Arg(desc = "String color") String color) {
|
||||
// Color colorObj = ColorUtil.parseColor(color);
|
||||
// return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#anglecolor",
|
||||
// desc = "A darker block based on the existing terrain angle"
|
||||
//)
|
||||
// public Pattern anglecolor(Extent extent, LocalSession session, @Arg(desc = "int", def = "1") int distance) {
|
||||
// return new AngleColorPattern(extent, session, distance);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#angledata",
|
||||
// desc = "Block data based on the existing terrain angle"
|
||||
// )
|
||||
// public Pattern angledata(Extent extent, @Arg(desc = "int", def = "1") int distance) {
|
||||
// return new DataAnglePattern(extent, distance);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#saturate",
|
||||
// desc = "Saturate the existing block with a color"
|
||||
//)
|
||||
// public Pattern saturate(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
||||
// Color color = ColorUtil.parseColor(colorStr);
|
||||
// return new SaturatePattern(extent, color.getRGB(), session);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#averagecolor",
|
||||
// desc = "Average between the existing block and a color"
|
||||
//)
|
||||
// public Pattern averagecolor(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
||||
// Color color = ColorUtil.parseColor(colorStr);
|
||||
// return new AverageColorPattern(extent, color.getRGB(), session);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#desaturate",
|
||||
// desc = "Desaturated color of the existing block"
|
||||
//)
|
||||
// public Pattern desaturate(Extent extent, LocalSession session, @Arg(desc = "double", def = "100") double percent) {
|
||||
// return new DesaturatePattern(extent, percent / 100d, session);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#lighten",
|
||||
// desc = "Lighten the existing block"
|
||||
//)
|
||||
// public Pattern lighten(Extent extent, TextureUtil util) {
|
||||
// return new ShadePattern(extent, false, util);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#darken",
|
||||
// desc = "Darken the existing block"
|
||||
//)
|
||||
// public Pattern darken(Extent extent, TextureUtil util) {
|
||||
// return new ShadePattern(extent, true, util);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#buffer",
|
||||
// desc = "Only place a block once while a pattern is in use",
|
||||
// descFooter = "Only place a block once while a pattern is in use\n" +
|
||||
// "Use with a brush when you don't want to apply to the same spot twice"
|
||||
//)
|
||||
// public Pattern buffer(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
// return new BufferedPattern(actor, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#buffer2d",
|
||||
// desc = "Only place a block once in a column while a pattern is in use"
|
||||
//)
|
||||
// public Pattern buffer2d(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
// return new BufferedPattern2D(actor, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#iddatamask",
|
||||
// desc = "Use the pattern's id and the existing blocks data with the provided mask",
|
||||
// descFooter = "Use the pattern's id and the existing blocks data with the provided mask\n" +
|
||||
// " - Use to replace slabs or where the data values needs to be shifted instead of set"
|
||||
//)
|
||||
// public Pattern iddatamask(Extent extent, @Range(from = 0, to = 15) @Arg(desc = "bit mask") int bitmask, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new IdDataMaskPattern(extent, pattern, bitmask);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#id",
|
||||
// desc = "Only change the block id"
|
||||
//)
|
||||
// public Pattern id(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new IdPattern(extent, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#data",
|
||||
// desc = "Only change the block data"
|
||||
//)
|
||||
// public Pattern data(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new DataPattern(extent, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#biome",
|
||||
// aliases = {"$"},
|
||||
// desc = "Set the biome"
|
||||
//)
|
||||
// public Pattern biome(Extent extent, @Arg(desc = "Biome type") BiomeType biome) {
|
||||
//
|
||||
// return new BiomePattern(extent, biome);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#relative",
|
||||
// aliases = {"#~", "#r", "#rel"},
|
||||
// desc = "Offset the pattern to where you click"
|
||||
//)
|
||||
// public Pattern relative(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new RelativePattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#!x",
|
||||
// aliases = {"#nx", "#nox"},
|
||||
// desc = "The pattern will not be provided the x axis info",
|
||||
// descFooter = "The pattern will not be provided the z axis info.\n" +
|
||||
// "Example: #!x[#!z[#~[#l3d[pattern]]]]"
|
||||
//)
|
||||
// public Pattern nox(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new NoXPattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#!y",
|
||||
// aliases = {"#ny", "#noy"},
|
||||
// desc = "The pattern will not be provided the y axis info"
|
||||
//)
|
||||
// public Pattern noy(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new NoYPattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#!z",
|
||||
// aliases = {"#nz", "#noz"},
|
||||
// desc = "The pattern will not be provided the z axis info"
|
||||
//)
|
||||
// public Pattern noz(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new NoZPattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#mask",
|
||||
// desc = "Apply a pattern depending on a mask"
|
||||
//)
|
||||
// public Pattern mask(@Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern")Pattern pass, @Arg(desc = "Pattern")Pattern fail) {
|
||||
// return new MaskedPattern(mask, pass, fail);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#offset",
|
||||
// desc = "Offset a pattern"
|
||||
//)
|
||||
// public Pattern offset(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#surfacespread",
|
||||
// desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given randomized offset `[0, <distance>)`. e.g., Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
|
||||
//)
|
||||
// public Pattern surfacespread(@Arg(desc = "spread distance (blocks)") double distance, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#solidspread",
|
||||
// desc = "Randomly spread solid blocks"
|
||||
//)
|
||||
// public Pattern solidspread(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#spread",
|
||||
// aliases = {"#randomoffset"},
|
||||
// desc = "Randomly spread blocks"
|
||||
//)
|
||||
// public Pattern spread(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
//
|
||||
// return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear",
|
||||
// aliases = {"#l"},
|
||||
// desc = "Sequentially set blocks from a list of patterns"
|
||||
//)
|
||||
// public Pattern linear(@Arg(desc = "Pattern") Pattern other) {
|
||||
//
|
||||
// if (other instanceof RandomPattern) {
|
||||
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
// return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear3d",
|
||||
// aliases = {"#l3d"},
|
||||
// desc = "Use the x,y,z coordinate to pick a block from the list"
|
||||
//)
|
||||
// public Pattern linear3d(@Arg(desc = "Pattern") Pattern other) {
|
||||
//
|
||||
// if (other instanceof RandomPattern) {
|
||||
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
// return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear2d",
|
||||
// aliases = {"#l2d"},
|
||||
// desc = "Use the x,z coordinate to pick a block from the list"
|
||||
//)
|
||||
// public Pattern linear2d(@Arg(desc = "Pattern") Pattern other) {
|
||||
//
|
||||
// if (other instanceof RandomPattern) {
|
||||
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
// return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "=",
|
||||
// aliases = {"#=", "#expression"},
|
||||
// desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
|
||||
//)
|
||||
// public Pattern expression(Extent extent, @Arg(desc = "Expression") String input) throws ExpressionException {
|
||||
//
|
||||
// Expression exp = Expression.compile(input, "x", "y", "z");
|
||||
// WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||
// exp.setEnvironment(env);
|
||||
// return new ExpressionPattern(exp);
|
||||
// }
|
||||
//}
|
@ -23,7 +23,7 @@ import com.fastasyncworldedit.core.FaweAPI;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.FaweLimit;
|
||||
import com.fastasyncworldedit.core.object.RelightMode;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.command;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.object.clipboard.MultiClipboardHolder;
|
||||
import com.fastasyncworldedit.core.object.clipboard.URIClipboardHolder;
|
||||
import com.fastasyncworldedit.core.object.schematic.MinecraftStructure;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Multimap;
|
||||
@ -36,7 +36,7 @@ import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.ActorSaveClipboardEvent;
|
||||
import com.fastasyncworldedit.core.event.extent.ActorSaveClipboardEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
@ -115,6 +115,7 @@ public class SchematicCommands {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
//TODO filtering for directories, global, and private scheamtics needs to be reimplemented here
|
||||
private static List<File> getFiles(File root, String filter, ClipboardFormat format) {
|
||||
File[] files = root.listFiles();
|
||||
@ -215,6 +216,76 @@ public class SchematicCommands {
|
||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.uri.not.found", fileName));
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "move",
|
||||
aliases = {"m"},
|
||||
desc = "Move your loaded schematic"
|
||||
)
|
||||
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
||||
public void move(Player player, LocalSession session, String directory) throws WorldEditException, IOException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||
File destDir = new File(dir, directory);
|
||||
if (!MainUtil.isInSubDirectory(working, destDir)) {
|
||||
player.print(Caption.of("worldedit.schematic.directory-does-not-exist", TextComponent.of(String.valueOf(destDir))));
|
||||
return;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) {
|
||||
player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.move.other"));
|
||||
return;
|
||||
}
|
||||
ClipboardHolder clipboard = session.getClipboard();
|
||||
List<File> sources = getFiles(clipboard);
|
||||
if (sources.isEmpty()) {
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.none"));
|
||||
return;
|
||||
}
|
||||
if (!destDir.exists() && !destDir.mkdirs()) {
|
||||
player.print(Caption.of("worldedit.schematic.file-perm-fail", TextComponent.of(String.valueOf(destDir))));
|
||||
return;
|
||||
}
|
||||
for (File source : sources) {
|
||||
File destFile = new File(destDir, source.getName());
|
||||
if (destFile.exists()) {
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists", destFile));
|
||||
continue;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.failed", destFile,
|
||||
Caption.of("fawe.error.no-perm", ("worldedit.schematic.move.other"))));
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
File cached = new File(source.getParentFile(), "." + source.getName() + ".cached");
|
||||
Files.move(source.toPath(), destFile.toPath());
|
||||
if (cached.exists()) {
|
||||
Files.move(cached.toPath(), destFile.toPath());
|
||||
}
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.success", source, destFile));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<File> getFiles(ClipboardHolder clipboard) {
|
||||
Collection<URI> uris = Collections.emptyList();
|
||||
if (clipboard instanceof URIClipboardHolder) {
|
||||
uris = ((URIClipboardHolder) clipboard).getURIs();
|
||||
}
|
||||
List<File> files = new ArrayList<>();
|
||||
for (URI uri : uris) {
|
||||
File file = new File(uri);
|
||||
if (file.exists()) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Command(
|
||||
name = "load",
|
||||
desc = "Load a schematic into your clipboard"
|
||||
@ -227,6 +298,7 @@ public class SchematicCommands {
|
||||
String formatName) throws FilenameException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
//FAWE start
|
||||
ClipboardFormat format = null;
|
||||
InputStream in = null;
|
||||
try {
|
||||
@ -313,6 +385,7 @@ public class SchematicCommands {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -327,8 +400,10 @@ public class SchematicCommands {
|
||||
String formatName,
|
||||
@Switch(name = 'f', desc = "Overwrite an existing file.")
|
||||
boolean allowOverwrite,
|
||||
//FAWE start
|
||||
@Switch(name = 'g', desc = "Bypasses per-player-schematic folders")
|
||||
boolean global) throws WorldEditException {
|
||||
//FAWE end
|
||||
if (worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion() == -1) {
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.unsupported-minecraft-version"));
|
||||
return;
|
||||
@ -338,6 +413,7 @@ public class SchematicCommands {
|
||||
|
||||
File dir = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||
|
||||
//FAWE start
|
||||
if (!global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) {
|
||||
dir = new File(dir, actor.getUniqueId().toString());
|
||||
}
|
||||
@ -361,6 +437,7 @@ public class SchematicCommands {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE end
|
||||
File f = worldEdit.getSafeSaveFile(actor, dir, filename, format.getPrimaryFileExtension());
|
||||
|
||||
boolean overwrite = f.exists();
|
||||
@ -394,80 +471,12 @@ public class SchematicCommands {
|
||||
SchematicSaveTask task = new SchematicSaveTask(actor, f, dir, format, holder, overwrite);
|
||||
AsyncCommandBuilder.wrap(task, actor)
|
||||
.registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename)
|
||||
.sendMessageAfterDelay(Caption.of("worldedit.schematic.save.saving"))
|
||||
.setDelayMessage(Caption.of("worldedit.schematic.save.saving"))
|
||||
.onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null)
|
||||
.onFailure(Caption.of("worldedit.schematic.failed-to-save"), worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter())
|
||||
.buildAndExec(worldEdit.getExecutorService());
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "move",
|
||||
aliases = {"m"},
|
||||
desc = "Move your loaded schematic"
|
||||
)
|
||||
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
||||
public void move(Player player, LocalSession session, String directory) throws WorldEditException, IOException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||
File destDir = new File(dir, directory);
|
||||
if (!MainUtil.isInSubDirectory(working, destDir)) {
|
||||
player.print(Caption.of("worldedit.schematic.directory-does-not-exist", TextComponent.of(String.valueOf(destDir))));
|
||||
return;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) {
|
||||
player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.move.other"));
|
||||
return;
|
||||
}
|
||||
ClipboardHolder clipboard = session.getClipboard();
|
||||
List<File> sources = getFiles(clipboard);
|
||||
if (sources.isEmpty()) {
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.none"));
|
||||
return;
|
||||
}
|
||||
if (!destDir.exists() && !destDir.mkdirs()) {
|
||||
player.print(Caption.of("worldedit.schematic.file-perm-fail", TextComponent.of(String.valueOf(destDir))));
|
||||
return;
|
||||
}
|
||||
for (File source : sources) {
|
||||
File destFile = new File(destDir, source.getName());
|
||||
if (destFile.exists()) {
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists", destFile));
|
||||
continue;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.failed", destFile,
|
||||
Caption.of("fawe.error.no-perm", ("worldedit.schematic.move.other"))));
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
File cached = new File(source.getParentFile(), "." + source.getName() + ".cached");
|
||||
Files.move(source.toPath(), destFile.toPath());
|
||||
if (cached.exists()) {
|
||||
Files.move(cached.toPath(), destFile.toPath());
|
||||
}
|
||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.success", source, destFile));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<File> getFiles(ClipboardHolder clipboard) {
|
||||
Collection<URI> uris = Collections.emptyList();
|
||||
if (clipboard instanceof URIClipboardHolder) {
|
||||
uris = ((URIClipboardHolder) clipboard).getURIs();
|
||||
}
|
||||
List<File> files = new ArrayList<>();
|
||||
for (URI uri : uris) {
|
||||
File file = new File(uri);
|
||||
if (file.exists()) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "formats",
|
||||
aliases = {"listformats", "f"},
|
||||
@ -514,6 +523,7 @@ public class SchematicCommands {
|
||||
if (oldFirst && newFirst) {
|
||||
throw new StopExecutionException(Caption.of("worldedit.schematic.sorting-old-new"));
|
||||
}
|
||||
//FAWE start
|
||||
String pageCommand = "/" + arguments.get();
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File dir = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||
@ -621,6 +631,7 @@ public class SchematicCommands {
|
||||
PaginationBox paginationBox = PaginationBox.fromComponents(fullHeader, pageCommand, components);
|
||||
actor.print(paginationBox.create(page));
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
||||
@ -635,6 +646,7 @@ public class SchematicCommands {
|
||||
String filename) throws WorldEditException, IOException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||
//FAWE start
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working;
|
||||
List<File> files = new ArrayList<>();
|
||||
|
||||
@ -664,8 +676,10 @@ public class SchematicCommands {
|
||||
}
|
||||
actor.print(Caption.of("worldedit.schematic.delete.deleted", filename));
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
private boolean deleteFile(File file) {
|
||||
if (file.delete()) {
|
||||
new File(file.getParentFile(), "." + file.getName() + ".cached").delete();
|
||||
@ -673,6 +687,7 @@ public class SchematicCommands {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
private static class SchematicLoadTask implements Callable<ClipboardHolder> {
|
||||
private final Actor actor;
|
||||
@ -722,6 +737,7 @@ public class SchematicCommands {
|
||||
Transform transform = holder.getTransform();
|
||||
Clipboard target;
|
||||
|
||||
//FAWE start
|
||||
boolean checkFilesize = false;
|
||||
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS
|
||||
@ -782,6 +798,7 @@ public class SchematicCommands {
|
||||
};
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
// If we have a transform, bake it into the copy
|
||||
if (transform.isIdentity()) {
|
||||
@ -797,6 +814,7 @@ public class SchematicCommands {
|
||||
FileOutputStream fos = closer.register(new FileOutputStream(file));
|
||||
BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
|
||||
ClipboardWriter writer = closer.register(format.getWriter(bos));
|
||||
//FAWE start
|
||||
URI uri = null;
|
||||
if (holder instanceof URIClipboardHolder) {
|
||||
uri = ((URIClipboardHolder) holder).getURI(clipboard);
|
||||
@ -857,6 +875,7 @@ public class SchematicCommands {
|
||||
actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.manual"));
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -890,6 +909,7 @@ public class SchematicCommands {
|
||||
return ErrorFormat.wrap("No schematics found.");
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
File[] files = new File[fileList.size()];
|
||||
fileList.toArray(files);
|
||||
// cleanup file list
|
||||
@ -912,12 +932,14 @@ public class SchematicCommands {
|
||||
return res;
|
||||
});
|
||||
|
||||
//FAWE end
|
||||
PaginationBox paginationBox = new SchematicPaginationBox(prefix, files, pageCommand);
|
||||
return paginationBox.create(page);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SchematicPaginationBox extends PaginationBox {
|
||||
//FAWE start - Expand to per player schematics
|
||||
private final String prefix;
|
||||
private final File[] files;
|
||||
|
||||
@ -925,11 +947,13 @@ public class SchematicCommands {
|
||||
super("worldedit.schematic.available", pageCommand);
|
||||
this.prefix = rootDir == null ? "" : rootDir;
|
||||
this.files = files;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent(int number) {
|
||||
checkArgument(number < files.length && number >= 0);
|
||||
//FAWE start - Per player schematic support & translatable things
|
||||
File file = files[number];
|
||||
Multimap<String, ClipboardFormat> exts = ClipboardFormats.getFileExtensionMap();
|
||||
String format = exts.get(com.google.common.io.Files.getFileExtension(file.getName()))
|
||||
@ -948,6 +972,7 @@ public class SchematicCommands {
|
||||
.append(TextComponent.of(path)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of(format))))
|
||||
.build();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,10 +20,10 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.clipboard.URIClipboardHolder;
|
||||
import com.fastasyncworldedit.core.object.mask.IdMask;
|
||||
import com.fastasyncworldedit.core.object.regions.selector.FuzzyRegionSelector;
|
||||
import com.fastasyncworldedit.core.object.regions.selector.PolyhedralRegionSelector;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
|
||||
import com.fastasyncworldedit.core.function.mask.IdMask;
|
||||
import com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector;
|
||||
import com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector;
|
||||
import com.google.common.base.Strings;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -47,7 +47,6 @@ import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.MultiDirection;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
@ -94,6 +93,8 @@ import java.util.stream.Stream;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.world.storage.ChunkStore.CHUNK_SHIFTS;
|
||||
import static com.sk89q.worldedit.world.storage.ChunkStore.CHUNK_SHIFTS_Y;
|
||||
|
||||
/**
|
||||
* Selection commands.
|
||||
@ -118,10 +119,12 @@ public class SelectionCommands {
|
||||
@Arg(desc = "Coordinates to set position 1 to", def = "")
|
||||
BlockVector3 coordinates) throws WorldEditException {
|
||||
Location pos;
|
||||
//FAWE start - clamp
|
||||
if (coordinates != null) {
|
||||
pos = new Location(world, coordinates.toVector3().clampY(0, world.getMaxY()));
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation().clampY(0, world.getMaxY());
|
||||
//FAWE end
|
||||
} else {
|
||||
actor.print(Caption.of("worldedit.pos.console-require-coords"));
|
||||
return;
|
||||
@ -148,9 +151,11 @@ public class SelectionCommands {
|
||||
BlockVector3 coordinates) throws WorldEditException {
|
||||
Location pos;
|
||||
if (coordinates != null) {
|
||||
//FAWE start - clamp
|
||||
pos = new Location(world, coordinates.toVector3().clampY(0, world.getMaxY()));
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation().clampY(0, world.getMaxY());
|
||||
//Fawe end
|
||||
} else {
|
||||
actor.print(Caption.of("worldedit.pos.console-require-coords"));
|
||||
return;
|
||||
@ -218,7 +223,7 @@ public class SelectionCommands {
|
||||
@CommandPermissions("worldedit.selection.chunk")
|
||||
public void chunk(Actor actor, World world, LocalSession session,
|
||||
@Arg(desc = "The chunk to select", def = "")
|
||||
BlockVector2 coordinates,
|
||||
BlockVector3 coordinates,
|
||||
@Switch(name = 's', desc = "Expand your selection to encompass all chunks that are part of it")
|
||||
boolean expandSelection,
|
||||
@Switch(name = 'c', desc = "Use chunk coordinates instead of block coordinates")
|
||||
@ -228,40 +233,49 @@ public class SelectionCommands {
|
||||
if (expandSelection) {
|
||||
Region region = session.getSelection(world);
|
||||
|
||||
final BlockVector2 min2D = ChunkStore.toChunk(region.getMinimumPoint());
|
||||
final BlockVector2 max2D = ChunkStore.toChunk(region.getMaximumPoint());
|
||||
int minChunkY = world.getMinY() >> CHUNK_SHIFTS_Y;
|
||||
int maxChunkY = world.getMaxY() >> CHUNK_SHIFTS_Y;
|
||||
|
||||
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
max = BlockVector3.at(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
|
||||
BlockVector3 minChunk = ChunkStore.toChunk3d(region.getMinimumPoint())
|
||||
.clampY(minChunkY, maxChunkY);
|
||||
BlockVector3 maxChunk = ChunkStore.toChunk3d(region.getMaximumPoint())
|
||||
.clampY(minChunkY, maxChunkY);
|
||||
|
||||
min = minChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS);
|
||||
max = maxChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS).add(15, world.getMaxY(), 15);
|
||||
|
||||
actor.print(Caption.of(
|
||||
"worldedit.chunk.selected-multiple",
|
||||
TextComponent.of(min2D.getBlockX()),
|
||||
TextComponent.of(min2D.getBlockZ()),
|
||||
TextComponent.of(max2D.getBlockX()),
|
||||
TextComponent.of(max2D.getBlockZ())
|
||||
TextComponent.of(minChunk.getBlockX()),
|
||||
TextComponent.of(minChunk.getBlockY()),
|
||||
TextComponent.of(minChunk.getBlockZ()),
|
||||
TextComponent.of(maxChunk.getBlockX()),
|
||||
TextComponent.of(maxChunk.getBlockY()),
|
||||
TextComponent.of(maxChunk.getBlockZ())
|
||||
));
|
||||
} else {
|
||||
final BlockVector2 min2D;
|
||||
BlockVector3 minChunk;
|
||||
if (coordinates != null) {
|
||||
// coords specified
|
||||
min2D = useChunkCoordinates
|
||||
minChunk = useChunkCoordinates
|
||||
? coordinates
|
||||
: ChunkStore.toChunk(coordinates.toBlockVector3());
|
||||
: ChunkStore.toChunk3d(coordinates);
|
||||
} else {
|
||||
// use player loc
|
||||
if (actor instanceof Locatable) {
|
||||
min2D = ChunkStore.toChunk(((Locatable) actor).getBlockLocation().toVector().toBlockPoint());
|
||||
minChunk = ChunkStore.toChunk3d(((Locatable) actor).getBlockLocation().toVector().toBlockPoint());
|
||||
} else {
|
||||
throw new StopExecutionException(TextComponent.of("A player or coordinates are required."));
|
||||
}
|
||||
}
|
||||
|
||||
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
min = minChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS);
|
||||
max = min.add(15, world.getMaxY(), 15);
|
||||
|
||||
actor.print(Caption.of("worldedit.chunk.selected", TextComponent.of(min2D.getBlockX()),
|
||||
TextComponent.of(min2D.getBlockZ())));
|
||||
actor.print(Caption.of("worldedit.chunk.selected",
|
||||
TextComponent.of(minChunk.getBlockX()),
|
||||
TextComponent.of(minChunk.getBlockY()),
|
||||
TextComponent.of(minChunk.getBlockZ())));
|
||||
}
|
||||
|
||||
final CuboidRegionSelector selector;
|
||||
@ -285,7 +299,9 @@ public class SelectionCommands {
|
||||
@CommandPermissions("worldedit.wand")
|
||||
public void wand(Player player, LocalSession session,
|
||||
@Switch(name = 'n', desc = "Get a navigation wand") boolean navWand) throws WorldEditException {
|
||||
//FAWE start
|
||||
session.loadDefaults(player, true);
|
||||
//FAWE end
|
||||
String wandId = navWand ? session.getNavWandItem() : session.getWandItem();
|
||||
if (wandId == null) {
|
||||
wandId = navWand ? we.getConfiguration().navigationWand : we.getConfiguration().wandItem;
|
||||
@ -296,12 +312,14 @@ public class SelectionCommands {
|
||||
return;
|
||||
}
|
||||
player.giveItem(new BaseItemStack(itemType, 1));
|
||||
//FAWE start - instance-iate session
|
||||
if (navWand) {
|
||||
session.setTool(itemType, NavigationWand.INSTANCE);
|
||||
player.print(Caption.of("worldedit.wand.navwand.info"));
|
||||
} else {
|
||||
session.setTool(itemType, SelectionWand.INSTANCE);
|
||||
player.print(Caption.of("worldedit.wand.selwand.info"));
|
||||
//FAWE end
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,6 +477,7 @@ public class SelectionCommands {
|
||||
boolean clipboardInfo) throws WorldEditException {
|
||||
Region region;
|
||||
if (clipboardInfo) {
|
||||
//FAWE start - Modify for cross server clipboards
|
||||
ClipboardHolder root = session.getClipboard();
|
||||
int index = 0;
|
||||
for (ClipboardHolder holder : root.getHolders()) {
|
||||
@ -488,6 +507,7 @@ public class SelectionCommands {
|
||||
index++;
|
||||
}
|
||||
return;
|
||||
//FAWE end
|
||||
} else {
|
||||
region = session.getSelection(world);
|
||||
|
||||
@ -572,7 +592,9 @@ public class SelectionCommands {
|
||||
aliases = { ";", "/desel", "/deselect" },
|
||||
desc = "Choose a region selector"
|
||||
)
|
||||
//FAWE start
|
||||
@CommandPermissions("worldedit.analysis.sel")
|
||||
//FAWE end
|
||||
public void select(Actor actor, World world, LocalSession session,
|
||||
@Arg(desc = "Selector to switch to", def = "")
|
||||
SelectorChoice selector,
|
||||
@ -625,6 +647,7 @@ public class SelectionCommands {
|
||||
limit.ifPresent(integer -> actor.print(Caption.of("worldedit.select.convex.limit-message", TextComponent.of(integer))));
|
||||
break;
|
||||
}
|
||||
//FAWE start
|
||||
case POLYHEDRAL:
|
||||
newSelector = new PolyhedralRegionSelector(world);
|
||||
actor.print(Caption.of("fawe.selection.sel.convex.polyhedral"));
|
||||
@ -640,6 +663,7 @@ public class SelectionCommands {
|
||||
actor.print(Caption.of("fawe.selection.sel.fuzzy"));
|
||||
actor.print(Caption.of("fawe.selection.sel.list"));
|
||||
break;
|
||||
//FAWE end
|
||||
case LIST:
|
||||
default:
|
||||
CommandListBox box = new CommandListBox("Selection modes", null, null);
|
||||
|
@ -20,7 +20,7 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.brush.InspectBrush;
|
||||
import com.fastasyncworldedit.core.command.tool.brush.InspectBrush;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -143,8 +143,10 @@ public class ToolCommands {
|
||||
|
||||
static void setToolNone(Player player, LocalSession session, boolean isBrush)
|
||||
throws InvalidToolBindException {
|
||||
//FAWE start
|
||||
isBrush = session.getTool(player) instanceof BrushTool;
|
||||
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
||||
//FAWE end
|
||||
player.print(Caption.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip"));
|
||||
}
|
||||
|
||||
@ -183,7 +185,9 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.setwand")
|
||||
public void selwand(Player player, LocalSession session) throws WorldEditException {
|
||||
//FAWE start - instance-inized
|
||||
setTool(player, session, SelectionWand.INSTANCE, "worldedit.tool.selwand.equip");
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -193,7 +197,9 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.setwand")
|
||||
public void navwand(Player player, LocalSession session) throws WorldEditException {
|
||||
//FAWE start - instance-inized
|
||||
setTool(player, session, NavigationWand.INSTANCE, "worldedit.tool.navwand.equip");
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -206,6 +212,7 @@ public class ToolCommands {
|
||||
setTool(player, session, new QueryTool(), "worldedit.tool.info.equip");
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "inspect",
|
||||
aliases = { "/inspect" },
|
||||
@ -215,6 +222,7 @@ public class ToolCommands {
|
||||
public void inspectBrush(Player player, LocalSession session) throws WorldEditException {
|
||||
setTool(player, session, new InspectBrush(), "worldedit.tool.info.equip");
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Command(
|
||||
name = "tree",
|
||||
|
@ -20,9 +20,9 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.brush.BrushSettings;
|
||||
import com.fastasyncworldedit.core.object.brush.TargetMode;
|
||||
import com.fastasyncworldedit.core.object.brush.scroll.Scroll;
|
||||
import com.fastasyncworldedit.core.command.tool.brush.BrushSettings;
|
||||
import com.fastasyncworldedit.core.command.tool.TargetMode;
|
||||
import com.fastasyncworldedit.core.command.tool.scroll.Scroll;
|
||||
import com.fastasyncworldedit.core.util.MathMan;
|
||||
import com.fastasyncworldedit.core.util.StringMan;
|
||||
import com.google.common.collect.Iterables;
|
||||
@ -61,6 +61,7 @@ public class ToolUtilCommands {
|
||||
this.we = we;
|
||||
}
|
||||
|
||||
//FAWE start - destination mask > mask
|
||||
@Command(
|
||||
name = "mask",
|
||||
aliases = "/mask",
|
||||
@ -90,6 +91,7 @@ public class ToolUtilCommands {
|
||||
player.print(Caption.of("worldedit.tool.mask.set"));
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Command(
|
||||
name = "material",
|
||||
@ -100,6 +102,7 @@ public class ToolUtilCommands {
|
||||
public void material(Player player, LocalSession session,
|
||||
@Arg(desc = "The pattern of blocks to use")
|
||||
Pattern pattern,
|
||||
//FAWE start - add offhand
|
||||
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
||||
boolean offHand, Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
@ -116,6 +119,7 @@ public class ToolUtilCommands {
|
||||
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
|
||||
tool.update();
|
||||
}
|
||||
//FAWE end
|
||||
player.print(Caption.of("worldedit.tool.material.set"));
|
||||
}
|
||||
|
||||
@ -128,7 +132,7 @@ public class ToolUtilCommands {
|
||||
public void range(Player player, LocalSession session,
|
||||
@Arg(desc = "The range of the brush")
|
||||
int range) throws WorldEditException {
|
||||
session.getBrushTool(player, false).setRange(range);
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
||||
player.print(Caption.of("worldedit.tool.range.set"));
|
||||
}
|
||||
|
||||
@ -186,6 +190,7 @@ public class ToolUtilCommands {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "primary",
|
||||
aliases = { "/primary" },
|
||||
@ -358,4 +363,5 @@ public class ToolUtilCommands {
|
||||
// tool.update();
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.transform"));
|
||||
// }
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -1,105 +0,0 @@
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
//package com.sk89q.worldedit.command;
|
||||
//
|
||||
//import com.boydti.fawe.object.extent.Linear3DTransform;
|
||||
//import com.boydti.fawe.object.extent.LinearTransform;
|
||||
//import com.boydti.fawe.object.extent.OffsetExtent;
|
||||
//import com.boydti.fawe.object.extent.PatternTransform;
|
||||
//import com.boydti.fawe.object.extent.RandomOffsetTransform;
|
||||
//import com.boydti.fawe.object.extent.RandomTransform;
|
||||
//import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
//import com.boydti.fawe.object.extent.ScaleTransform;
|
||||
//import com.boydti.fawe.object.extent.TransformExtent;
|
||||
//import com.boydti.fawe.util.ExtentTraverser;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||
//import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
//import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
//import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
//import java.util.Set;
|
||||
//import org.enginehub.piston.annotation.Command;
|
||||
//import org.enginehub.piston.annotation.CommandContainer;
|
||||
//import org.enginehub.piston.annotation.param.Arg;
|
||||
//
|
||||
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//public class TransformCommands {
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear",
|
||||
// aliases = {"#l"},
|
||||
// desc = "Sequentially pick from a list of transform"
|
||||
// )
|
||||
// public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// if (other instanceof RandomTransform) {
|
||||
// Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
// return new LinearTransform(extents.toArray(new ResettableExtent[0]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear3d",
|
||||
// aliases = {"#l3d"},
|
||||
// desc = "Use the x,y,z coordinate to pick a transform from the list"
|
||||
// )
|
||||
// public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// if (other instanceof RandomTransform) {
|
||||
// Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
// return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#pattern",
|
||||
// desc = "Always use a specific pattern"
|
||||
// )
|
||||
// public ResettableExtent pattern(Actor actor, LocalSession session, @Arg(desc = "Pattern") Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new PatternTransform(other, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#offset",
|
||||
// desc = "Offset transform"
|
||||
// )
|
||||
// public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new OffsetExtent(other, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#spread",
|
||||
// aliases = {"#randomoffset"},
|
||||
// desc = "Random offset transform"
|
||||
//)
|
||||
// public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new RandomOffsetTransform(other, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#scale",
|
||||
// desc = "All changes will be scaled"
|
||||
// )
|
||||
// public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new ScaleTransform(other, x, y, z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#rotate",
|
||||
// desc = "All changes will be rotate around the initial position"
|
||||
// )
|
||||
// public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// ExtentTraverser<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class);
|
||||
// BlockTransformExtent affine = traverser != null ? traverser.get() : null;
|
||||
// if (affine == null) {
|
||||
// other = affine = new TransformExtent(other);
|
||||
// }
|
||||
// AffineTransform transform = (AffineTransform) affine.getTransform();
|
||||
// transform = transform.rotateX(x);
|
||||
// transform = transform.rotateY(y);
|
||||
// transform = transform.rotateZ(z);
|
||||
// affine.setTransform(transform);
|
||||
// return other;
|
||||
// }
|
||||
//}
|
@ -22,8 +22,8 @@ package com.sk89q.worldedit.command;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.object.DelegateConsumer;
|
||||
import com.fastasyncworldedit.core.object.function.QuadFunction;
|
||||
import com.fastasyncworldedit.core.util.task.DelegateConsumer;
|
||||
import com.fastasyncworldedit.core.function.QuadFunction;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.fastasyncworldedit.core.util.TaskManager;
|
||||
import com.fastasyncworldedit.core.util.image.ImageUtil;
|
||||
@ -204,13 +204,17 @@ public class UtilityCommands {
|
||||
public int fill(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The blocks to fill with")
|
||||
Pattern pattern,
|
||||
//FAWE start - we take an expression over a double
|
||||
@Arg(desc = "The radius to fill in")
|
||||
Expression radiusExp,
|
||||
//FAWE end
|
||||
@Arg(desc = "The depth to fill", def = "1")
|
||||
int depth,
|
||||
@Arg(desc = "The direction to move", def = "down")
|
||||
@Direction BlockVector3 direction) throws WorldEditException, EvaluationException {
|
||||
//FAWE start
|
||||
double radius = radiusExp.evaluate();
|
||||
//FAWE end
|
||||
radius = Math.max(1, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
depth = Math.max(1, depth);
|
||||
@ -222,22 +226,6 @@ public class UtilityCommands {
|
||||
}
|
||||
|
||||
/*
|
||||
@Command(
|
||||
name = "/fillr",
|
||||
desc = "Fill a hole recursively"
|
||||
name = "patterns",
|
||||
desc = "View help about patterns",
|
||||
descFooter = "Patterns determine what blocks are placed\n" +
|
||||
" - Use [brackets] for arguments\n" +
|
||||
" - Use , to OR multiple\n" +
|
||||
"e.g., #surfacespread[10][#existing],andesite\n" +
|
||||
"More Info: https://git.io/vSPmA"
|
||||
)
|
||||
@CommandQueued(false)
|
||||
@CommandPermissions("worldedit.patterns")
|
||||
public void patterns(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
|
||||
displayModifierHelp(player, DefaultPatternParser.class, args);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "masks",
|
||||
@ -303,11 +291,15 @@ public class UtilityCommands {
|
||||
public int fillr(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The blocks to fill with")
|
||||
Pattern pattern,
|
||||
//FAWE start - we take an expression over a double
|
||||
@Arg(desc = "The radius to fill in")
|
||||
Expression radiusExp,
|
||||
//FAWE end
|
||||
@Arg(desc = "The depth to fill", def = "")
|
||||
Integer depth) throws WorldEditException {
|
||||
//FAWE start
|
||||
double radius = radiusExp.evaluate();
|
||||
//FAWE end
|
||||
radius = Math.max(1, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth);
|
||||
@ -326,12 +318,16 @@ public class UtilityCommands {
|
||||
@CommandPermissions("worldedit.drain")
|
||||
@Logging(PLACEMENT)
|
||||
public int drain(Actor actor, LocalSession session, EditSession editSession,
|
||||
//FAWE start - we take an expression over a double
|
||||
@Arg(desc = "The radius to drain")
|
||||
Expression radiusExp,
|
||||
//FAWE end
|
||||
@Switch(name = 'w', desc = "Also un-waterlog blocks")
|
||||
boolean waterlogged,
|
||||
//FAWE start
|
||||
@Switch(name = 'p', desc = "Also remove water plants")
|
||||
boolean plants) throws WorldEditException {
|
||||
//FAWE end
|
||||
double radius = radiusExp.evaluate();
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
@ -637,8 +633,10 @@ public class UtilityCommands {
|
||||
flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, "worldedit.butcher.armorstands");
|
||||
flags.or(CreatureButcher.Flags.WATER, killWater, "worldedit.butcher.water");
|
||||
|
||||
//FAWE start - run this sync
|
||||
int finalRadius = radius;
|
||||
int killed = TaskManager.IMP.sync(() -> killMatchingEntities(finalRadius, actor, flags::createFunction));
|
||||
//FAWE end
|
||||
|
||||
actor.print(Caption.of(
|
||||
"worldedit.butcher.killed",
|
||||
@ -666,7 +664,9 @@ public class UtilityCommands {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//FAWE start - run this sync
|
||||
int removed = TaskManager.IMP.sync(() -> killMatchingEntities(radius, actor, remover::createFunction));
|
||||
//FAWE end
|
||||
actor.print(Caption.of("worldedit.remove.removed", TextComponent.of(removed)));
|
||||
return removed;
|
||||
}
|
||||
@ -694,7 +694,7 @@ public class UtilityCommands {
|
||||
}
|
||||
|
||||
session.remember(editSession);
|
||||
editSession.flushSession();
|
||||
editSession.close();
|
||||
return killed;
|
||||
}
|
||||
|
||||
@ -749,6 +749,7 @@ public class UtilityCommands {
|
||||
}
|
||||
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "/confirm",
|
||||
desc = "Confirm a command"
|
||||
@ -1064,5 +1065,6 @@ public class UtilityCommands {
|
||||
name.append(relative.getPath());
|
||||
return name.toString();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public class WorldEditCommands {
|
||||
)
|
||||
@CommandPermissions(queued = false)
|
||||
public void version(Actor actor) {
|
||||
//FAWE start - get own version format
|
||||
FaweVersion fVer = Fawe.get().getVersion();
|
||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||
actor.print(TextComponent.of("FastAsyncWorldEdit" + fVerStr + " created by Empire92, MattBDev, IronApollo, dordsor21 and NotMyFault"));
|
||||
@ -95,6 +96,7 @@ public class WorldEditCommands {
|
||||
}
|
||||
|
||||
actor.printInfo(TextComponent.of("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/wiki"));
|
||||
//FAWE end
|
||||
|
||||
PlatformManager pm = we.getPlatformManager();
|
||||
|
||||
@ -130,10 +132,13 @@ public class WorldEditCommands {
|
||||
public void reload(Actor actor) {
|
||||
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
|
||||
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
|
||||
//FAWE start
|
||||
Fawe.get().setupConfigs();
|
||||
//FAWE end
|
||||
actor.print(Caption.of("worldedit.reload.config"));
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Command(
|
||||
name = "debugpaste",
|
||||
desc = "Writes a report of latest.log, config.yml, config-legacy.yml, strings.json to https://athion.net/ISPaster/paste"
|
||||
@ -171,6 +176,7 @@ public class WorldEditCommands {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Command(
|
||||
name = "cui",
|
||||
|
@ -28,7 +28,6 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.MultiDirection;
|
||||
import com.sk89q.worldedit.internal.annotation.OptionalArg;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
|
@ -19,10 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.command.argument;
|
||||
|
||||
import com.fastasyncworldedit.core.object.brush.scroll.Scroll;
|
||||
import com.fastasyncworldedit.core.command.tool.scroll.Scroll;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.command.util.HookMode;
|
||||
import com.sk89q.worldedit.extent.TracingExtent;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
@ -58,6 +59,8 @@ public final class EnumConverter {
|
||||
basic(HookMode.class));
|
||||
commandManager.registerConverter(Key.of(Scroll.Action.class),
|
||||
basic(Scroll.Action.class));
|
||||
commandManager.registerConverter(Key.of(TracingExtent.Action.class),
|
||||
basic(TracingExtent.Action.class));
|
||||
}
|
||||
|
||||
private static <E extends Enum<E>> ArgumentConverter<E> basic(Class<E> enumClass) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.command.argument;
|
||||
|
||||
import com.fastasyncworldedit.core.object.extent.SupplyingExtent;
|
||||
import com.fastasyncworldedit.core.extent.SupplyingExtent;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
@ -1,22 +1,3 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.argument;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
@ -30,7 +30,9 @@ public enum SelectorChoice {
|
||||
HULL,
|
||||
POLYHEDRON,
|
||||
LIST,
|
||||
//FAWE start
|
||||
FUZZY,
|
||||
MAGIC,
|
||||
POLYHEDRAL
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -42,7 +42,9 @@ public class WorldConverter implements ArgumentConverter<World> {
|
||||
commandManager.registerConverter(Key.of(World.class), WORLD_CONVERTER);
|
||||
}
|
||||
|
||||
//FAWE start - Accessed by LocationConverter
|
||||
public static final WorldConverter WORLD_CONVERTER = new WorldConverter();
|
||||
//FAWE end
|
||||
|
||||
private final TextComponent choices;
|
||||
|
||||
|
@ -17,5 +17,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The following classes are FAWE additions:
|
||||
*
|
||||
* @see com.sk89q.worldedit.command.argument.ExpressionConverter
|
||||
* @see com.sk89q.worldedit.command.argument.LocationConverter
|
||||
*/
|
||||
@org.enginehub.piston.util.NonnullByDefault
|
||||
package com.sk89q.worldedit.command.argument;
|
||||
|
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* The following classes are FAWE additions:
|
||||
*
|
||||
* @see com.sk89q.worldedit.command.HistorySubCommands
|
||||
*/
|
||||
package com.sk89q.worldedit.command;
|
@ -36,7 +36,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
*/
|
||||
public class AreaPickaxe implements BlockTool {
|
||||
|
||||
private int range;
|
||||
private final int range;
|
||||
|
||||
public AreaPickaxe(int range) {
|
||||
this.range = range;
|
||||
|
@ -30,9 +30,12 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mode that replaces one block.
|
||||
*/
|
||||
@ -50,11 +53,12 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
|
||||
BlockBag bag = session.getBlockBag(player);
|
||||
|
||||
try (EditSession editSession = session.createEditSession(player, "BlockReplacer")) {
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
try {
|
||||
editSession.disableBuffering();
|
||||
BlockVector3 position = clicked.toVector().toBlockPoint();
|
||||
editSession.setBlock(position, pattern);
|
||||
} catch (MaxChangedBlocksException ignored) {
|
||||
@ -72,7 +76,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
|
||||
BaseBlock targetBlock = player.getWorld().getFullBlock(clicked.toVector().toBlockPoint());
|
||||
|
||||
if (targetBlock != null) {
|
||||
|
@ -20,15 +20,15 @@
|
||||
package com.sk89q.worldedit.command.tool;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.brush.BrushSettings;
|
||||
import com.fastasyncworldedit.core.object.brush.MovableTool;
|
||||
import com.fastasyncworldedit.core.object.brush.ResettableTool;
|
||||
import com.fastasyncworldedit.core.object.brush.TargetMode;
|
||||
import com.fastasyncworldedit.core.object.brush.scroll.Scroll;
|
||||
import com.fastasyncworldedit.core.object.brush.scroll.ScrollTool;
|
||||
import com.fastasyncworldedit.core.object.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.object.mask.MaskedTargetBlock;
|
||||
import com.fastasyncworldedit.core.object.pattern.PatternTraverser;
|
||||
import com.fastasyncworldedit.core.command.tool.brush.BrushSettings;
|
||||
import com.fastasyncworldedit.core.command.tool.MovableTool;
|
||||
import com.fastasyncworldedit.core.command.tool.ResettableTool;
|
||||
import com.fastasyncworldedit.core.command.tool.TargetMode;
|
||||
import com.fastasyncworldedit.core.command.tool.scroll.Scroll;
|
||||
import com.fastasyncworldedit.core.command.tool.scroll.ScrollTool;
|
||||
import com.fastasyncworldedit.core.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.function.mask.MaskedTargetBlock;
|
||||
import com.fastasyncworldedit.core.function.pattern.PatternTraverser;
|
||||
import com.fastasyncworldedit.core.util.BrushCache;
|
||||
import com.fastasyncworldedit.core.util.MaskTraverser;
|
||||
import com.fastasyncworldedit.core.util.StringMan;
|
||||
@ -65,23 +65,25 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* Builds a shape at the place being looked at.
|
||||
*/
|
||||
public class BrushTool
|
||||
implements DoubleActionTraceTool, ScrollTool, MovableTool, ResettableTool, Serializable {
|
||||
//FAWE start - All implements but TraceTool
|
||||
implements DoubleActionTraceTool, ScrollTool, MovableTool, ResettableTool, Serializable, TraceTool {
|
||||
// TODO:
|
||||
// Serialize methods
|
||||
// serialize BrushSettings (primary and secondary only if different)
|
||||
// set transient values e.g., context
|
||||
|
||||
|
||||
public enum BrushAction {
|
||||
enum BrushAction {
|
||||
PRIMARY, SECONDARY
|
||||
}
|
||||
|
||||
//FAWE end
|
||||
|
||||
protected static int MAX_RANGE = 500;
|
||||
protected static int DEFAULT_RANGE = 240; // 500 is laggy as the default
|
||||
protected int range = -1;
|
||||
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
|
||||
private Mask traceMask = null;
|
||||
//FAWE start
|
||||
protected static int DEFAULT_RANGE = 240; // 500 is laggy as the default
|
||||
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
|
||||
private int targetOffset;
|
||||
|
||||
private transient BrushSettings primary = new BrushSettings();
|
||||
@ -89,6 +91,7 @@ public class BrushTool
|
||||
private transient BrushSettings context = primary;
|
||||
|
||||
private transient BaseItem holder;
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Construct the tool.
|
||||
@ -100,6 +103,7 @@ public class BrushTool
|
||||
getContext().addPermission(permission);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public BrushTool() {
|
||||
}
|
||||
|
||||
@ -192,15 +196,6 @@ public class BrushTool
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filter.
|
||||
*
|
||||
* @return the filter
|
||||
*/
|
||||
public Mask getMask() {
|
||||
return getContext().getMask();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filter.
|
||||
*
|
||||
@ -229,6 +224,16 @@ public class BrushTool
|
||||
this.getContext().setMask(filter);
|
||||
update();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the filter.
|
||||
*
|
||||
* @return the filter
|
||||
*/
|
||||
public Mask getMask() {
|
||||
return getContext().getMask();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mask used for identifying where to stop traces.
|
||||
@ -250,6 +255,7 @@ public class BrushTool
|
||||
update();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Set the block filter used for identifying blocks to replace.
|
||||
*
|
||||
@ -259,6 +265,7 @@ public class BrushTool
|
||||
this.getContext().setSourceMask(filter);
|
||||
update();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Set the brush.
|
||||
@ -267,11 +274,13 @@ public class BrushTool
|
||||
* @param permission the permission
|
||||
*/
|
||||
public void setBrush(Brush brush, String permission) {
|
||||
//FAWE start - We use our own logic
|
||||
BrushSettings current = getContext();
|
||||
current.clearPerms();
|
||||
current.setBrush(brush);
|
||||
current.addPermission(permission);
|
||||
update();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,9 +359,12 @@ public class BrushTool
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player,
|
||||
LocalSession session) {
|
||||
//FAWE start - Use logic previously declared as FAWE-like
|
||||
return act(BrushAction.PRIMARY, player, session);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public BlockVector3 getPosition(EditSession editSession, Player player) {
|
||||
Location loc = player.getLocation();
|
||||
switch (targetMode) {
|
||||
@ -524,4 +536,5 @@ public class BrushTool
|
||||
public boolean move(Player player) {
|
||||
return false;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
package com.sk89q.worldedit.command.tool;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.collection.LocalBlockVectorSet;
|
||||
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -120,8 +120,10 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
||||
*/
|
||||
private Set<BlockVector3> bfs(World world, BlockVector3 origin) {
|
||||
//FAWE start - Use a LBVS over a HashMap & LinkedList
|
||||
final LocalBlockVectorSet visited = new LocalBlockVectorSet();
|
||||
final LocalBlockVectorSet queue = new LocalBlockVectorSet();
|
||||
//FAWE end
|
||||
|
||||
queue.add(origin);
|
||||
visited.add(origin);
|
||||
|
@ -77,11 +77,13 @@ public class FloodFillTool implements BlockTool {
|
||||
|
||||
try (EditSession editSession = session.createEditSession(player, "FloodFillTool")) {
|
||||
try {
|
||||
//FAWE start - Respect masks
|
||||
Mask mask = initialType.toMask(editSession);
|
||||
BlockReplace function = new BlockReplace(editSession, pattern);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range);
|
||||
visitor.visit(origin);
|
||||
Operations.completeLegacy(visitor);
|
||||
//FAWE end
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.print(Caption.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
|
@ -21,11 +21,18 @@ package com.sk89q.worldedit.command.tool;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
|
||||
public class InvalidToolBindException extends WorldEditException {
|
||||
|
||||
private ItemType item;
|
||||
private final ItemType item;
|
||||
|
||||
public InvalidToolBindException(ItemType item, Component msg) {
|
||||
super(msg);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public InvalidToolBindException(ItemType item, String msg) {
|
||||
super(msg);
|
||||
this.item = item;
|
||||
|
@ -27,12 +27,17 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
//FAWE start - enum-ized
|
||||
public enum NavigationWand implements DoubleActionTraceTool {
|
||||
INSTANCE;
|
||||
//FAWE end
|
||||
|
||||
private static final String PRIMARY_PERMISSION = "worldedit.navigation.thru.tool";
|
||||
private static final String SECONDARY_PERMISSION = "worldedit.navigation.jumpto.tool";
|
||||
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
|
||||
if (!player.hasPermission(SECONDARY_PERMISSION)) {
|
||||
return false;
|
||||
}
|
||||
final int maxDist = config.navigationWandMaxDistance;
|
||||
@ -50,7 +55,7 @@ public enum NavigationWand implements DoubleActionTraceTool {
|
||||
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
|
||||
if (!player.hasPermission(PRIMARY_PERMISSION)) {
|
||||
return false;
|
||||
}
|
||||
final int maxDist = config.navigationWandMaxDistance;
|
||||
@ -66,6 +71,6 @@ public enum NavigationWand implements DoubleActionTraceTool {
|
||||
|
||||
@Override
|
||||
public boolean canUse(Actor actor) {
|
||||
return actor.hasPermission("worldedit.navigation.jumpto.tool"); // check should be here
|
||||
return actor.hasPermission(PRIMARY_PERMISSION) || actor.hasPermission(SECONDARY_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.command.tool;
|
||||
|
||||
import com.fastasyncworldedit.core.object.mask.IdMask;
|
||||
import com.fastasyncworldedit.core.function.mask.IdMask;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -75,6 +75,7 @@ public class RecursivePickaxe implements BlockTool {
|
||||
try (EditSession editSession = session.createEditSession(player, "RecursivePickaxe")) {
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
|
||||
//FAWE start
|
||||
final int radius = (int) range;
|
||||
final BlockReplace replace = new BlockReplace(editSession, (BlockTypes.AIR.getDefaultState()));
|
||||
editSession.setMask(null);
|
||||
@ -83,6 +84,7 @@ public class RecursivePickaxe implements BlockTool {
|
||||
//visitor.visit(pos);
|
||||
//Operations.completeBlindly(visitor);
|
||||
recurse(server, editSession, world, pos, origin, radius, initialType, visitor.getVisited());
|
||||
//FAWE end
|
||||
editSession.flushQueue();
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
@ -29,36 +29,46 @@ import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
//FAWE start - enum-ized
|
||||
public enum SelectionWand implements DoubleActionBlockTool {
|
||||
INSTANCE;
|
||||
//FAWE end
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||
|
||||
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
//FAWE start
|
||||
if (Settings.IMP.EXPERIMENTAL.OTHER) {
|
||||
LOGGER.info("actSecondary Hit and about to explain with explainPrimarySelection");
|
||||
}
|
||||
//FAWE end
|
||||
selector.explainPrimarySelection(player, session, blockPoint);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||
|
||||
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
//FAWE start
|
||||
if (Settings.IMP.EXPERIMENTAL.OTHER) {
|
||||
LOGGER.info("actPrimary Hit and about to explain with explainSecondarySelection");
|
||||
}
|
||||
//FAWE end
|
||||
selector.explainSecondarySelection(player, session, blockPoint);
|
||||
}
|
||||
return true;
|
||||
|
@ -28,11 +28,14 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A super pickaxe mode that removes one block.
|
||||
*/
|
||||
@ -44,7 +47,7 @@ public class SinglePickaxe implements BlockTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
|
||||
World world = (World) clicked.getExtent();
|
||||
BlockVector3 blockPoint = clicked.toBlockPoint();
|
||||
final BlockType blockType = world.getBlock(blockPoint).getBlockType();
|
||||
|
@ -28,15 +28,18 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Plants a tree.
|
||||
*/
|
||||
public class TreePlanter implements BlockTool {
|
||||
|
||||
private TreeGenerator.TreeType treeType;
|
||||
private final TreeGenerator.TreeType treeType;
|
||||
|
||||
public TreePlanter(TreeGenerator.TreeType treeType) {
|
||||
this.treeType = treeType;
|
||||
@ -48,7 +51,7 @@ public class TreePlanter implements BlockTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
|
||||
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
try {
|
||||
|
@ -33,7 +33,7 @@ import java.util.List;
|
||||
|
||||
public class ButcherBrush implements Brush {
|
||||
|
||||
private CreatureButcher flags;
|
||||
private final CreatureButcher flags;
|
||||
|
||||
public ButcherBrush(CreatureButcher flags) {
|
||||
this.flags = flags;
|
||||
|
@ -27,7 +27,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class CylinderBrush implements Brush {
|
||||
|
||||
private int height;
|
||||
private final int height;
|
||||
|
||||
public CylinderBrush(int height) {
|
||||
this.height = height;
|
||||
|
@ -36,6 +36,7 @@ public class GravityBrush implements Brush {
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
//FAWE start - Ours operates differently to upstream, but does the same
|
||||
double endY = position.getY() + size;
|
||||
double startPerformY = Math.max(0, position.getY() - size);
|
||||
double startCheckY = fullHeight ? 0 : startPerformY;
|
||||
@ -54,5 +55,6 @@ public class GravityBrush implements Brush {
|
||||
}
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class HollowCylinderBrush implements Brush {
|
||||
|
||||
private int height;
|
||||
private final int height;
|
||||
|
||||
public HollowCylinderBrush(int height) {
|
||||
this.height = height;
|
||||
|
@ -37,7 +37,7 @@ import javax.annotation.Nullable;
|
||||
public class SmoothBrush implements Brush {
|
||||
|
||||
private final Mask mask;
|
||||
private int iterations;
|
||||
private final int iterations;
|
||||
|
||||
public SmoothBrush(int iterations) {
|
||||
this(iterations, null);
|
||||
|
@ -36,10 +36,10 @@ import com.sk89q.worldedit.util.task.Supervisor;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.enginehub.piston.exception.CommandException;
|
||||
import org.enginehub.piston.exception.CommandExecutionException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Consumer;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -57,6 +57,8 @@ public final class AsyncCommandBuilder<T> {
|
||||
private String description;
|
||||
@Nullable
|
||||
private Component delayMessage;
|
||||
@Nullable
|
||||
private Component workingMessage;
|
||||
|
||||
@Nullable
|
||||
private Component successMessage;
|
||||
@ -90,11 +92,22 @@ public final class AsyncCommandBuilder<T> {
|
||||
return sendMessageAfterDelay(TextComponent.of(checkNotNull(message)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AsyncCommandBuilder<T> sendMessageAfterDelay(Component message) {
|
||||
return setDelayMessage(message);
|
||||
}
|
||||
|
||||
public AsyncCommandBuilder<T> setDelayMessage(Component message) {
|
||||
this.delayMessage = checkNotNull(message);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AsyncCommandBuilder<T> setWorkingMessage(Component message) {
|
||||
checkNotNull(this.delayMessage, "Must have a delay message if using a working message");
|
||||
this.workingMessage = checkNotNull(message);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AsyncCommandBuilder<T> onSuccess(@Nullable Component message, @Nullable Consumer<T> consumer) {
|
||||
checkArgument(message != null || consumer != null, "Can't have null message AND consumer");
|
||||
this.successMessage = message;
|
||||
@ -145,7 +158,7 @@ public final class AsyncCommandBuilder<T> {
|
||||
if (successMessage != null) {
|
||||
sender.print(successMessage);
|
||||
}
|
||||
} catch (Exception orig) {
|
||||
} catch (Throwable orig) {
|
||||
Component failure = failureMessage != null ? failureMessage : TextComponent.of("An error occurred");
|
||||
try {
|
||||
if (exceptionConverter != null) {
|
||||
|
@ -146,7 +146,9 @@ public class EntityRemover {
|
||||
EntityProperties registryType = entity.getFacet(EntityProperties.class);
|
||||
if (registryType != null) {
|
||||
if (type.matches(registryType)) {
|
||||
//FAWE start - Calling this async violates thread safety
|
||||
TaskManager.IMP.sync(entity::remove);
|
||||
//FAWE end
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Timer;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -32,7 +33,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class FutureProgressListener implements Runnable {
|
||||
|
||||
private static final Timer timer = new Timer();
|
||||
private static final int MESSAGE_DELAY = 1000;
|
||||
private static final int MESSAGE_DELAY = 1000; // 1 second
|
||||
private static final int MESSAGE_PERIOD = 10000; // 10 seconds
|
||||
|
||||
private final MessageTimerTask task;
|
||||
|
||||
@ -42,11 +44,15 @@ public class FutureProgressListener implements Runnable {
|
||||
}
|
||||
|
||||
public FutureProgressListener(Actor sender, Component message) {
|
||||
this(sender, message, null);
|
||||
}
|
||||
|
||||
public FutureProgressListener(Actor sender, Component message, @Nullable Component workingMessage) {
|
||||
checkNotNull(sender);
|
||||
checkNotNull(message);
|
||||
|
||||
task = new MessageTimerTask(sender, message);
|
||||
timer.schedule(task, MESSAGE_DELAY);
|
||||
task = new MessageTimerTask(sender, message, workingMessage);
|
||||
timer.scheduleAtFixedRate(task, MESSAGE_DELAY, MESSAGE_PERIOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,11 +62,15 @@ public class FutureProgressListener implements Runnable {
|
||||
|
||||
@Deprecated
|
||||
public static void addProgressListener(ListenableFuture<?> future, Actor sender, String message) {
|
||||
future.addListener(new FutureProgressListener(sender, message), MoreExecutors.directExecutor());
|
||||
addProgressListener(future, sender, TextComponent.of(message));
|
||||
}
|
||||
|
||||
public static void addProgressListener(ListenableFuture<?> future, Actor sender, Component message) {
|
||||
future.addListener(new FutureProgressListener(sender, message), MoreExecutors.directExecutor());
|
||||
}
|
||||
|
||||
public static void addProgressListener(ListenableFuture<?> future, Actor sender, Component message, Component workingMessage) {
|
||||
future.addListener(new FutureProgressListener(sender, message, workingMessage), MoreExecutors.directExecutor());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -31,23 +32,35 @@ public class MessageTimerTask extends TimerTask {
|
||||
|
||||
private final Actor sender;
|
||||
private final Component message;
|
||||
@Nullable
|
||||
private final Component workingMessage;
|
||||
|
||||
private boolean hasRunBefore = false;
|
||||
|
||||
@Deprecated
|
||||
MessageTimerTask(Actor sender, String message) {
|
||||
this(sender, TextComponent.of(message));
|
||||
this(sender, TextComponent.of(message), null);
|
||||
}
|
||||
|
||||
MessageTimerTask(Actor sender, Component message) {
|
||||
MessageTimerTask(Actor sender, Component message, @Nullable Component workingMessage) {
|
||||
checkNotNull(sender);
|
||||
checkNotNull(message);
|
||||
|
||||
this.sender = sender;
|
||||
this.message = message;
|
||||
this.workingMessage = workingMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sender.printDebug(message);
|
||||
if (!hasRunBefore) {
|
||||
sender.printDebug(message);
|
||||
hasRunBefore = true;
|
||||
} else if (workingMessage != null) {
|
||||
sender.printDebug(workingMessage);
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,9 @@ public class PermissionCondition implements Command.Condition {
|
||||
private static final Key<Actor> ACTOR_KEY = Key.of(Actor.class);
|
||||
|
||||
private final Set<String> permissions;
|
||||
//FAWE start
|
||||
private final boolean queued;
|
||||
//FAWE end
|
||||
|
||||
public PermissionCondition(Set<String> permissions) {
|
||||
this(permissions, true);
|
||||
@ -54,7 +56,9 @@ public class PermissionCondition implements Command.Condition {
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
public boolean isQueued() {
|
||||
return queued;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -179,6 +179,7 @@ public final class SuggestionHelper {
|
||||
return registry.keySet().stream().filter(search);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Returns a stream of suggestions for positive doubles.
|
||||
*
|
||||
@ -231,4 +232,5 @@ public final class SuggestionHelper {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public final class WorldEditAsyncCommandBuilder {
|
||||
public static void createAndSendMessage(Actor actor, Callable<Component> task, @Nullable Component desc) {
|
||||
final AsyncCommandBuilder<Component> builder = AsyncCommandBuilder.wrap(task, actor);
|
||||
if (desc != null) {
|
||||
builder.sendMessageAfterDelay(desc);
|
||||
builder.setDelayMessage(desc);
|
||||
}
|
||||
builder
|
||||
.onSuccess((String) null, actor::printInfo)
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.sk89q.worldedit.internal.annotation;
|
||||
package com.sk89q.worldedit.command.util.annotation;
|
||||
|
||||
import com.fastasyncworldedit.core.regions.FaweMaskManager;
|
||||
import org.enginehub.piston.inject.InjectAnnotation;
|
@ -1,23 +1,4 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.internal.command;
|
||||
package com.sk89q.worldedit.command.util.annotation;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
@ -0,0 +1,11 @@
|
||||
package com.sk89q.worldedit.command.util.annotation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Link {
|
||||
|
||||
Class clazz() default Link.class;
|
||||
String value();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Annotates a {@code List<BlockState>} parameter to inject a list of BlockStates.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@InjectAnnotation
|
||||
public @interface PatternList {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.sk89q.worldedit.command.util.annotation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Step {
|
||||
Class clazz() default Link.class;
|
||||
|
||||
double value() default 1;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.sk89q.worldedit.internal.annotation;
|
||||
package com.sk89q.worldedit.command.util.annotation;
|
||||
|
||||
import org.enginehub.piston.inject.InjectAnnotation;
|
||||
|
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* The following classes are FAWE additions:
|
||||
*
|
||||
* @see com.sk89q.worldedit.command.util.annotation.AllowedRegion
|
||||
* @see com.sk89q.worldedit.command.util.annotation.Confirm
|
||||
* @see com.sk89q.worldedit.command.util.annotation.ConfirmHandler
|
||||
* @see com.sk89q.worldedit.command.util.annotation.Link
|
||||
* @see com.sk89q.worldedit.command.util.annotation.PatternList
|
||||
* @see com.sk89q.worldedit.command.util.annotation.Step
|
||||
* @see com.sk89q.worldedit.command.util.annotation.Time
|
||||
*/
|
||||
package com.sk89q.worldedit.command.util.annotation;
|
@ -47,7 +47,9 @@ public class BaseEntity implements NbtValued {
|
||||
|
||||
private final EntityType type;
|
||||
@Nullable
|
||||
//FAWE start - use LZ<CBT> over CompoundTag
|
||||
private LazyReference<CompoundBinaryTag> nbtData;
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Create a new base entity.
|
||||
@ -93,12 +95,6 @@ public class BaseEntity implements NbtValued {
|
||||
setNbtReference(other.getNbtReference());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LazyReference<CompoundBinaryTag> getNbtReference() {
|
||||
return nbtData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtReference(@Nullable LazyReference<CompoundBinaryTag> nbtData) {
|
||||
this.nbtData = nbtData;
|
||||
@ -113,11 +109,16 @@ public class BaseEntity implements NbtValued {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
// FAWE start
|
||||
//FAWE start
|
||||
public BaseEntity(CompoundTag tag) {
|
||||
this(EntityTypes.parse(tag.getString("Id")), tag);
|
||||
}
|
||||
|
||||
// FAWE end
|
||||
@Nullable
|
||||
@Override
|
||||
public LazyReference<CompoundBinaryTag> getNbtReference() {
|
||||
return nbtData;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
@ -48,10 +48,12 @@ public interface Entity extends Faceted, Locatable {
|
||||
@Nullable
|
||||
BaseEntity getState();
|
||||
|
||||
//FAWE start
|
||||
default EntityType getType() {
|
||||
BaseEntity state = getState();
|
||||
return state != null ? state.getType() : null;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Remove this entity from it container.
|
||||
|
@ -1,32 +0,0 @@
|
||||
package com.sk89q.worldedit.entity;
|
||||
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class LazyBaseEntity extends BaseEntity {
|
||||
private Supplier<CompoundTag> saveTag;
|
||||
public LazyBaseEntity(EntityType type, Supplier<CompoundTag> saveTag) {
|
||||
super(type);
|
||||
this.saveTag = saveTag;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Supplier<CompoundTag> tmp = saveTag;
|
||||
if (tmp != null) {
|
||||
saveTag = null;
|
||||
if (Fawe.isMainThread()) {
|
||||
setNbtData(tmp.get());
|
||||
} else {
|
||||
setNbtData(TaskManager.IMP.sync(tmp));
|
||||
}
|
||||
}
|
||||
return super.getNbtData();
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.sk89q.worldedit.entity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface MapMetadatable extends Metadatable {
|
||||
|
||||
Map<String, Object> getRawMeta();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
default void setMeta(String key, Object value) {
|
||||
getRawMeta().put(key, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
default <T> T getAndSetMeta(String key, T value) {
|
||||
return (T) getRawMeta().put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
default boolean hasMeta() {
|
||||
return !getRawMeta().isEmpty();
|
||||
}
|
||||
|
||||
default Object putIfAbsent(String key, Object value) {
|
||||
return getRawMeta().putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
default <V> V getMeta(String key) {
|
||||
return (V) getRawMeta().get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
default <V> V getMeta(String key, @NotNull V def) {
|
||||
V value = (V) getRawMeta().get(key);
|
||||
return value == null ? def : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
default <V> V deleteMeta(String key) {
|
||||
return (V) getRawMeta().remove(key);
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package com.sk89q.worldedit.entity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface Metadatable {
|
||||
|
||||
/**
|
||||
* Set some session only metadata for the player
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
void setMeta(String key, Object value);
|
||||
|
||||
<T> T getAndSetMeta(String key, T value);
|
||||
|
||||
/**
|
||||
* Checks if the object contains any metadata.
|
||||
*
|
||||
* @return {@code true} if there is metadata set for the object
|
||||
*/
|
||||
boolean hasMeta();
|
||||
|
||||
/**
|
||||
* Gets the metadata value to which the specified key is mapped,
|
||||
* or {@code null} if the key is not set.
|
||||
*
|
||||
* @param key the key of the metadata value to retrieve
|
||||
* @return the value of the metadata or {@code null} if none exists
|
||||
*/
|
||||
<V> V getMeta(String key);
|
||||
|
||||
/**
|
||||
* Gets the metadata value to which the specified key is mapped,
|
||||
* or the default value if no metadata exists for the key.
|
||||
*
|
||||
* @param key the key of the metadata value to retrieve
|
||||
* @param defaultValue the value to return if there is no metadata for the given key
|
||||
* @return the metadata value for the key, if present; else the default value
|
||||
*/
|
||||
@NotNull
|
||||
default <V> V getMeta(String key, @NotNull V defaultValue) {
|
||||
V value = getMeta(key);
|
||||
return value == null ? defaultValue : value; }
|
||||
|
||||
/**
|
||||
* Deletes the given metadata key from object. Do not delete metadata set by another plugin
|
||||
* unless you know what you are doing.
|
||||
*
|
||||
* @param key the key identifying the metadata to remove.
|
||||
* @return the previous value associated with they given key
|
||||
*/
|
||||
@Nullable
|
||||
<V> V deleteMeta(String key);
|
||||
|
||||
final class METADATA_KEYS {
|
||||
|
||||
public static final String ANVIL_CLIPBOARD = "anvil-clipboard";
|
||||
public static final String ROLLBACK = "rollback";
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ package com.sk89q.worldedit.entity;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.object.clipboard.DiskOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.DiskOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.regions.FaweMaskManager;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
@ -348,6 +348,7 @@ public interface Player extends Entity, Actor {
|
||||
*/
|
||||
<B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, @Nullable B block);
|
||||
|
||||
//FAWE start
|
||||
public Region[] getCurrentRegions();
|
||||
|
||||
Region[] getCurrentRegions(FaweMaskManager.MaskType type);
|
||||
@ -429,4 +430,5 @@ public interface Player extends Entity, Actor {
|
||||
print(Caption.of("fawe.error.stacktrace"));
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
* An abstract base class for all WorldEdit events.
|
||||
*/
|
||||
public abstract class Event {
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Returns true if this event was called and not cancelled.
|
||||
@ -37,4 +38,5 @@ public abstract class Event {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
package com.sk89q.worldedit.event.extent;
|
||||
|
||||
import com.sk89q.worldedit.event.Cancellable;
|
||||
import com.sk89q.worldedit.event.Event;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class ActorSaveClipboardEvent extends Event implements Cancellable {
|
||||
private final Actor actor;
|
||||
private final Clipboard clipboard;
|
||||
private final URI source;
|
||||
private final URI destination;
|
||||
private boolean cancelled;
|
||||
|
||||
public ActorSaveClipboardEvent(Actor actor, Clipboard clipboard, URI source, URI destination) {
|
||||
this.actor = actor;
|
||||
this.clipboard = clipboard;
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public URI getSourceURI() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public URI getDestinationURI() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public Clipboard getClipboard() {
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
public Actor getActor() {
|
||||
return actor;
|
||||
}
|
||||
}
|
@ -24,12 +24,16 @@ import com.sk89q.worldedit.event.Cancellable;
|
||||
import com.sk89q.worldedit.event.Event;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.TracingExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.EditSession.Stage;
|
||||
|
||||
@ -67,7 +71,11 @@ public class EditSessionEvent extends Event implements Cancellable {
|
||||
private final int maxBlocks;
|
||||
private final Stage stage;
|
||||
private Extent extent;
|
||||
private final List<TracingExtent> tracingExtents = new ArrayList<>();
|
||||
private boolean tracing;
|
||||
//FAWE start
|
||||
private boolean cancelled;
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Create a new event.
|
||||
@ -139,17 +147,31 @@ public class EditSessionEvent extends Event implements Cancellable {
|
||||
*/
|
||||
public void setExtent(Extent extent) {
|
||||
checkNotNull(extent);
|
||||
if (tracing && extent != this.extent) {
|
||||
TracingExtent tracingExtent = new TracingExtent(extent);
|
||||
extent = tracingExtent;
|
||||
tracingExtents.add(tracingExtent);
|
||||
}
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
/**
|
||||
* Set tracing enabled, with the current extent as the "base".
|
||||
*
|
||||
* <em>Internal use only.</em>
|
||||
* @param tracing if tracing is enabled
|
||||
*/
|
||||
public void setTracing(boolean tracing) {
|
||||
this.tracing = tracing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
/**
|
||||
* Get the current list of tracing extents.
|
||||
*
|
||||
* <em>Internal use only.</em>
|
||||
*/
|
||||
public List<TracingExtent> getTracingExtents() {
|
||||
return tracingExtents;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,4 +184,16 @@ public class EditSessionEvent extends Event implements Cancellable {
|
||||
return new EditSessionEvent(world, actor, maxBlocks, stage);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.event.extent;
|
||||
|
||||
import com.sk89q.worldedit.event.Cancellable;
|
||||
import com.sk89q.worldedit.event.Event;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static com.sk89q.worldedit.EditSession.Stage;
|
||||
|
||||
public class PasteEvent extends Event implements Cancellable {
|
||||
|
||||
private final Actor actor;
|
||||
private final Clipboard clipboard;
|
||||
private final URI uri;
|
||||
private final BlockVector3 to;
|
||||
private final Extent extent;
|
||||
private boolean cancelled;
|
||||
|
||||
public PasteEvent(Actor actor, Clipboard clipboard, URI uri, Extent extent, BlockVector3 to) {
|
||||
this.actor = actor;
|
||||
this.clipboard = clipboard;
|
||||
this.uri = uri;
|
||||
this.extent = extent;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public Actor getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
public Clipboard getClipboard() {
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public BlockVector3 getPosition() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a clone of this event with the given stage.
|
||||
*
|
||||
* @param stage the stage
|
||||
* @return a new event
|
||||
*/
|
||||
public PasteEvent clone(Stage stage) {
|
||||
PasteEvent clone = new PasteEvent(actor, clipboard, uri, extent, to);
|
||||
return clone;
|
||||
}
|
||||
}
|
@ -65,9 +65,11 @@ public class CommandEvent extends AbstractCancellable {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public boolean call() {
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(this);
|
||||
return true;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -58,8 +58,10 @@ public class BlockFactory extends AbstractFactory<BaseBlock> {
|
||||
*/
|
||||
public Set<BaseBlock> parseFromListInput(String input, ParserContext context) throws InputParseException {
|
||||
Set<BaseBlock> blocks = new HashSet<>();
|
||||
//FAWE start
|
||||
// String[] splits = input.split(",");
|
||||
for (String token : StringUtil.split(input, ',', '[', ']')) {
|
||||
//FAWE end
|
||||
blocks.add(parseFromInput(token, context));
|
||||
}
|
||||
return blocks;
|
||||
|
@ -1,136 +0,0 @@
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
//package com.sk89q.worldedit.extension.factory;
|
||||
//
|
||||
//import com.boydti.fawe.command.FaweParser;
|
||||
//import com.boydti.fawe.command.SuggestInputParseException;
|
||||
//import com.boydti.fawe.object.extent.MultiTransform;
|
||||
//import com.boydti.fawe.object.extent.RandomTransform;
|
||||
//import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
//import com.boydti.fawe.object.random.TrueRandom;
|
||||
//import com.boydti.fawe.util.StringMan;
|
||||
//import com.google.common.collect.Iterables;
|
||||
//import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
//import com.sk89q.worldedit.WorldEdit;
|
||||
////import com.sk89q.worldedit.command.TransformCommands;
|
||||
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
//import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
//import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//public class DefaultTransformParser extends FaweParser<ResettableExtent> {
|
||||
//
|
||||
// public DefaultTransformParser(WorldEdit worldEdit) {
|
||||
// super(worldEdit, "transforms");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ResettableExtent parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
// if (input.isEmpty()) return null;
|
||||
//
|
||||
// List<Double> unionChances = new ArrayList<>();
|
||||
// List<Double> intersectionChances = new ArrayList<>();
|
||||
//
|
||||
// List<ResettableExtent> intersection = new ArrayList<>();
|
||||
// List<ResettableExtent> union = new ArrayList<>();
|
||||
// final CommandLocals locals = new CommandLocals();
|
||||
// Actor actor = context != null ? context.getActor() : null;
|
||||
// if (actor != null) {
|
||||
// locals.put(Actor.class, actor);
|
||||
// }
|
||||
// try {
|
||||
// List<Map.Entry<ParseEntry, List<String>>> parsed = parse(input);
|
||||
// for (Map.Entry<ParseEntry, List<String>> entry : parsed) {
|
||||
// ParseEntry pe = entry.getKey();
|
||||
// String command = pe.input;
|
||||
// ResettableExtent transform;
|
||||
// double chance = 1;
|
||||
// if (command.isEmpty()) {
|
||||
// transform = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
||||
// } else {
|
||||
// List<String> args = entry.getValue();
|
||||
// String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
||||
// try {
|
||||
// transform = parse(command + cmdArgs, context);
|
||||
// } catch (SuggestInputParseException rethrow) {
|
||||
// throw rethrow;
|
||||
// } catch (Throwable e) {
|
||||
// throw new NoMatchException("See: //transforms");
|
||||
// }
|
||||
// if (transform == null) {
|
||||
// // Legacy syntax
|
||||
// int percentIndex = command.indexOf('%');
|
||||
// if (percentIndex != -1) { // Legacy percent pattern
|
||||
// chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
|
||||
// command = command.substring(percentIndex + 1);
|
||||
// if (!entry.getValue().isEmpty()) {
|
||||
// if (!command.isEmpty()) command += " ";
|
||||
// command += StringMan.join(entry.getValue(), " ");
|
||||
// }
|
||||
// transform = parseFromInput(command, context);
|
||||
// } else {
|
||||
// throw new NoMatchException("See: //transforms");
|
||||
// }
|
||||
// }
|
||||
// if (pe.and) { // &
|
||||
// intersectionChances.add(chance);
|
||||
// intersection.add(transform);
|
||||
// } else {
|
||||
// if (!intersection.isEmpty()) {
|
||||
// if (intersection.size() == 1) {
|
||||
// throw new InputParseException("Error, floating &");
|
||||
// }
|
||||
// MultiTransform multi = new MultiTransform();
|
||||
// double total = 0;
|
||||
// for (int i = 0; i < intersection.size(); i++) {
|
||||
// Double value = intersectionChances.get(i);
|
||||
// total += value;
|
||||
// multi.add(intersection.get(i), value);
|
||||
// }
|
||||
// union.add(multi);
|
||||
// unionChances.add(total);
|
||||
// intersection.clear();
|
||||
// intersectionChances.clear();
|
||||
// }
|
||||
// unionChances.add(chance);
|
||||
// union.add(transform);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (Throwable e) {
|
||||
// throw new InputParseException(e.getMessage(), e);
|
||||
// }
|
||||
// if (!intersection.isEmpty()) {
|
||||
// if (intersection.size() == 1) {
|
||||
// throw new InputParseException("Error, floating &");
|
||||
// }
|
||||
// MultiTransform multi = new MultiTransform();
|
||||
// double total = 0;
|
||||
// for (int i = 0; i < intersection.size(); i++) {
|
||||
// Double value = intersectionChances.get(i);
|
||||
// total += value;
|
||||
// multi.add(intersection.get(i), value);
|
||||
// }
|
||||
// union.add(multi);
|
||||
// unionChances.add(total);
|
||||
// intersection.clear();
|
||||
// intersectionChances.clear();
|
||||
// }
|
||||
// if (union.isEmpty()) {
|
||||
// throw new NoMatchException("See: //transforms");
|
||||
// } else if (union.size() == 1) {
|
||||
// return union.get(0);
|
||||
// } else {
|
||||
// RandomTransform random = new RandomTransform(new TrueRandom());
|
||||
// for (int i = 0; i < union.size(); i++) {
|
||||
// random.add(union.get(i), unionChances.get(i));
|
||||
// }
|
||||
// return random;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
@ -21,33 +21,33 @@ package com.sk89q.worldedit.extension.factory;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.AdjacentMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.AdjacentMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.AirMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.AngleMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.AngleMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.ExtremaMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.FalseMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.ExtremaMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.FalseMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.LiquidMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.LiquidMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.ROCAngleMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.ROCAngleMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.RichOffsetMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.SimplexMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.RichOffsetMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.SimplexMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.SurfaceMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.TrueMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.WallMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.XAxisMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.YAxisMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.ZAxisMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.SurfaceMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.TrueMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.WallMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.XAxisMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.YAxisMaskParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.mask.ZAxisMaskParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
@ -91,6 +91,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
|
||||
register(new BlockCategoryMaskParser(worldEdit));
|
||||
register(new BiomeMaskParser(worldEdit));
|
||||
//FAWE start
|
||||
// Mask Parsers from FAWE
|
||||
register(new AdjacentMaskParser(worldEdit));
|
||||
register(new AngleMaskParser(worldEdit));
|
||||
@ -107,6 +108,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
register(new XAxisMaskParser(worldEdit));
|
||||
register(new YAxisMaskParser(worldEdit));
|
||||
register(new ZAxisMaskParser(worldEdit));
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
||||
|
@ -20,21 +20,21 @@
|
||||
package com.sk89q.worldedit.extension.factory;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.BiomePatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.BiomePatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.BufferedPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.BufferedPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.ExistingPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.Linear2DPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.Linear3DPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.PerlinPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExistingPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear2DPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear3DPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.PerlinPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RandomPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.RidgedMultiFractalPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.SimplexPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RidgedMultiFractalPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.SimplexPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.SingleBlockPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.TypeOrStateApplyingPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.VoronoiPatternParser;
|
||||
import com.fastasyncworldedit.core.extension.factory.parser.pattern.VoronoiPatternParser;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
|
||||
@ -64,7 +64,7 @@ public final class PatternFactory extends AbstractFactory<Pattern> {
|
||||
register(new RandomStatePatternParser(worldEdit));
|
||||
register(new BlockCategoryPatternParser(worldEdit));
|
||||
|
||||
// FAWE
|
||||
//FAWE start
|
||||
register(new SimplexPatternParser(worldEdit));
|
||||
register(new VoronoiPatternParser(worldEdit));
|
||||
register(new PerlinPatternParser(worldEdit));
|
||||
@ -74,6 +74,7 @@ public final class PatternFactory extends AbstractFactory<Pattern> {
|
||||
register(new Linear3DPatternParser(worldEdit));
|
||||
register(new BufferedPatternParser(worldEdit));
|
||||
register(new ExistingPatternParser(worldEdit));
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
||||
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
@ -57,7 +57,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
import com.sk89q.worldedit.world.block.BlanketBaseBlock;
|
||||
import com.fastasyncworldedit.core.world.block.BlanketBaseBlock;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
@ -118,7 +118,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] EMPTY_STRING_ARRAY = {};
|
||||
private static final String[] EMPTY_STRING_ARRAY = {};
|
||||
|
||||
/**
|
||||
* Backwards compatibility for wool colours in block syntax.
|
||||
@ -253,9 +253,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
|
||||
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
|
||||
//FAWE start
|
||||
String[] blockAndExtraData = input.trim().split("\\|", 2);
|
||||
blockAndExtraData[0] = woolMapper(blockAndExtraData[0]);
|
||||
Map<Property<?>, Object> blockStates = new HashMap<>();
|
||||
//FAWE end
|
||||
|
||||
BlockState state = null;
|
||||
|
||||
@ -270,6 +272,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
} else if (MathMan.isInteger(split[0])) {
|
||||
int id = Integer.parseInt(split[0]);
|
||||
int data = Integer.parseInt(split[1]);
|
||||
//FAWE start
|
||||
if (data < 0 || data >= 16) {
|
||||
throw new InputParseException(Caption.of("fawe.error.parser.invalid-data", TextComponent.of(data)));
|
||||
}
|
||||
@ -289,6 +292,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
|
||||
CompoundTag nbt = null;
|
||||
//FAWE end
|
||||
if (state == null) {
|
||||
String typeString;
|
||||
String stateString = null;
|
||||
@ -319,13 +323,17 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
if ("hand".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the item in the user's hand.
|
||||
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
|
||||
//FAWE start
|
||||
state = blockInHand.toBlockState();
|
||||
nbt = blockInHand.getNbtData();
|
||||
//FAWE end
|
||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the item in the user's off hand.
|
||||
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||
//FAWE start
|
||||
state = blockInHand.toBlockState();
|
||||
nbt = blockInHand.getNbtData();
|
||||
//FAWE end
|
||||
} else if (typeString.matches("pos[0-9]+")) {
|
||||
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
||||
// Get the block type from the "primary position"
|
||||
@ -337,6 +345,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
throw new InputParseException(Caption.of("worldedit.error.incomplete-region"));
|
||||
}
|
||||
state = world.getBlock(primaryPosition);
|
||||
//FAWE start
|
||||
} else if (typeString.matches("slot[0-9]+")) {
|
||||
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
||||
Actor actor = context.requireActor();
|
||||
@ -369,6 +378,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
if (nbt == null) {
|
||||
nbt = state.getNbtData();
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
blockStates.putAll(parseProperties(state.getBlockType(), stateProperties, context));
|
||||
if (context.isPreferringWildcard()) {
|
||||
@ -394,7 +404,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
// this should be impossible but IntelliJ isn't that smart
|
||||
if (state == null) {
|
||||
throw new NoMatchException(Caption.of("fawe.error.invalid-block-type", TextComponent.of(input)));
|
||||
throw new NoMatchException(Caption.of("worldedit.error.unknown-block", TextComponent.of(input)));
|
||||
}
|
||||
|
||||
if (blockAndExtraData.length > 1 && blockAndExtraData[1].startsWith("{")) {
|
||||
@ -413,7 +423,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
Actor actor = context.requireActor();
|
||||
if (actor != null && !actor.hasPermission("worldedit.anyblock")
|
||||
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId())) {
|
||||
throw new DisallowedUsageException(Caption.of("fawe.error.block.not.allowed", TextComponent.of(input)));
|
||||
throw new DisallowedUsageException(Caption.of("worldedit.error.disallowed-block", TextComponent.of(input)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -462,11 +472,12 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE Start
|
||||
private <T extends BlockStateHolder> T validate(ParserContext context, T holder) {
|
||||
if (context.isRestricted()) {
|
||||
Actor actor = context.requireActor();
|
||||
if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) {
|
||||
throw new DisallowedUsageException(Caption.of("fawe.error.block.not.allowed", TextComponent.of(String.valueOf(holder))));
|
||||
throw new DisallowedUsageException(Caption.of("worldedit.error.disallowed-block", TextComponent.of(String.valueOf(holder))));
|
||||
}
|
||||
CompoundTag nbt = holder.getNbtData();
|
||||
if (nbt != null) {
|
||||
@ -477,4 +488,5 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -101,16 +101,21 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
|
||||
if ("hand".equalsIgnoreCase(typeString)) {
|
||||
BaseItemStack heldItem = getItemInHand(context.requireActor(), HandSide.MAIN_HAND);
|
||||
//FAWE start
|
||||
itemType = heldItem.getType();
|
||||
itemNbtData = heldItem.getNbt();
|
||||
//FAWE end
|
||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||
BaseItemStack heldItem = getItemInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||
//FAWE start
|
||||
itemType = heldItem.getType();
|
||||
itemNbtData = heldItem.getNbt();
|
||||
//FAWE end
|
||||
} else {
|
||||
itemType = ItemTypes.get(typeString.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
if (itemType == null) {
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.unknown-item", TextComponent.of(input)));
|
||||
}
|
||||
@ -139,6 +144,7 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
|
||||
return item;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
private BaseItemStack getItemInHand(Actor actor, HandSide handSide) throws InputParseException {
|
||||
if (actor instanceof Player) {
|
||||
|
@ -1,150 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A rich parser allows parsing of patterns and masks with extra arguments,
|
||||
* e.g. #simplex[scale][pattern].
|
||||
*
|
||||
* @param <E> the parse result.
|
||||
*/
|
||||
public abstract class RichParser<E> extends InputParser<E> {
|
||||
private final String[] prefixes;
|
||||
|
||||
/**
|
||||
* Create a new rich parser with a defined prefix for the result, e.g. {@code #simplex}.
|
||||
*
|
||||
* @param worldEdit the worldedit instance.
|
||||
* @param aliases the prefix of this parser result.
|
||||
*/
|
||||
protected RichParser(WorldEdit worldEdit, String... aliases) {
|
||||
super(worldEdit);
|
||||
Preconditions.checkArgument(aliases.length >= 1, "Aliases may not be empty");
|
||||
this.prefixes = aliases;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Predicate<String> validPrefix(String other) {
|
||||
return prefix -> {
|
||||
if (prefix.length() > other.length()) {
|
||||
return prefix.startsWith(other);
|
||||
}
|
||||
return other.startsWith(prefix);
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Function<String, Stream<? extends String>> extractArguments(String input) {
|
||||
return prefix -> {
|
||||
if (input.length() > prefix.length()) {
|
||||
// input already contains argument(s) -> extract them
|
||||
String[] strings = extractArguments(input.substring(prefix.length()), false);
|
||||
// rebuild the argument string without the last argument
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < strings.length - 1; i++) {
|
||||
builder.append('[').append(strings[i]).append(']');
|
||||
}
|
||||
String previous = prefix + builder;
|
||||
// read the suggestions for the last argument
|
||||
return getSuggestions(strings[strings.length - 1], strings.length - 1)
|
||||
.map(suggestion -> previous + "[" + suggestion);
|
||||
} else {
|
||||
return Stream.of(prefix);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefixes[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> getSuggestions(String input) {
|
||||
return Arrays.stream(this.prefixes)
|
||||
.filter(validPrefix(input))
|
||||
.flatMap(extractArguments(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public E parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
for (String prefix : this.prefixes) {
|
||||
if (!input.startsWith(prefix)) {
|
||||
continue;
|
||||
}
|
||||
if (input.length() < prefix.length()) {
|
||||
continue;
|
||||
}
|
||||
String[] arguments = extractArguments(input.substring(prefix.length()), true);
|
||||
return parseFromInput(arguments, context);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream of suggestions for the argument at the given index.
|
||||
*
|
||||
* @param argumentInput the already provided input for the argument at the given index.
|
||||
* @param index the index of the argument to get suggestions for.
|
||||
* @return a stream of suggestions matching the given input for the argument at the given index.
|
||||
*/
|
||||
protected abstract Stream<String> getSuggestions(String argumentInput, int index);
|
||||
|
||||
/**
|
||||
* Parses the already split arguments.
|
||||
*
|
||||
* @param arguments the array of arguments that were split (can be empty).
|
||||
* @param context the context of this parsing process.
|
||||
* @return the resulting parsed type.
|
||||
* @throws InputParseException if the input couldn't be parsed correctly.
|
||||
*/
|
||||
protected abstract E parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException;
|
||||
|
||||
/**
|
||||
* Extracts arguments enclosed by {@code []} into an array.
|
||||
* Example: {@code [Hello][World]} results in a list containing {@code Hello} and {@code World}.
|
||||
*
|
||||
* @param input the input to extract arguments from.
|
||||
* @param requireClosing whether or not the extraction requires valid bracketing.
|
||||
* @return an array of extracted arguments.
|
||||
* @throws InputParseException if {@code requireClosing == true} and the count of [ != the count of ]
|
||||
*/
|
||||
protected String[] extractArguments(String input, boolean requireClosing) throws InputParseException {
|
||||
int open = 0; // the "level"
|
||||
int openIndex = 0;
|
||||
int i = 0;
|
||||
List<String> arguments = new ArrayList<>();
|
||||
for (; i < input.length(); i++) {
|
||||
if (input.charAt(i) == '[') {
|
||||
if (open++ == 0) {
|
||||
openIndex = i;
|
||||
}
|
||||
}
|
||||
if (input.charAt(i) == ']') {
|
||||
if (--open == 0) {
|
||||
arguments.add(input.substring(openIndex + 1, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!requireClosing && open > 0) {
|
||||
arguments.add(input.substring(openIndex + 1));
|
||||
}
|
||||
if (requireClosing && open != 0) {
|
||||
throw new InputParseException(Caption.of("fawe.error.invalid-bracketing", TextComponent.of("'[' or ']'?")));
|
||||
}
|
||||
return arguments.toArray(new String[0]);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.object.mask.AdjacentAnyMask;
|
||||
import com.fastasyncworldedit.core.object.mask.AdjacentMask;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||
import com.sk89q.worldedit.extension.factory.parser.RichParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class AdjacentMaskParser extends RichParser<Mask> {
|
||||
|
||||
public AdjacentMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit, "~");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> getSuggestions(String argumentInput, int index) {
|
||||
if (index == 0) {
|
||||
return worldEdit.getMaskFactory().getSuggestions(argumentInput).stream();
|
||||
} else if (index == 1 || index == 2) {
|
||||
return SuggestionHelper.suggestPositiveDoubles(argumentInput);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length == 0) {
|
||||
return null;
|
||||
}
|
||||
Mask subMask = worldEdit.getMaskFactory().parseFromInput(arguments[0], context);
|
||||
int min = arguments.length > 1 ? Integer.parseInt(arguments[1]) : -1;
|
||||
int max = arguments.length > 2 ? Integer.parseInt(arguments[2]) : -1;
|
||||
if (min == -1 && max == -1) {
|
||||
min = 1;
|
||||
max = 8;
|
||||
} else if (max == -1) {
|
||||
max = min;
|
||||
}
|
||||
if (max >= 8 && min == 1) {
|
||||
return new AdjacentAnyMask(subMask);
|
||||
}
|
||||
return new AdjacentMask(subMask, min, max);
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.mask.AngleMask;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||
import com.sk89q.worldedit.extension.factory.parser.RichParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class AngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
private final String[] flags = new String[]{"-o"};
|
||||
|
||||
public AngleMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit, "/");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> getSuggestions(String argumentInput, int index) {
|
||||
if (index == 0 || index == 1) {
|
||||
return SuggestionHelper.suggestPositiveDoubles(argumentInput).flatMap(s -> Stream.of(s, s + "d"));
|
||||
} else if (index > 1 && index <= 1 + flags.length) {
|
||||
return Stream.of(flags);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException(Caption.of("fawe.error.mask.angle"));
|
||||
}
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
String flag = arguments[index];
|
||||
if (flag.equals("-o")) {
|
||||
overlay = true;
|
||||
} else {
|
||||
throw new InputParseException(Caption.of("fawe.error.invalid-flag",
|
||||
TextComponent.of(flag)));
|
||||
}
|
||||
}
|
||||
}
|
||||
double min;
|
||||
double max;
|
||||
if (degree) {
|
||||
double minDeg = Double.parseDouble(minArg.substring(0, minArg.length() - 1));
|
||||
double maxDeg = Double.parseDouble(maxArg.substring(0, maxArg.length() - 1));
|
||||
min = (Math.tan(minDeg * (Math.PI / 180)));
|
||||
max = (Math.tan(maxDeg * (Math.PI / 180)));
|
||||
} else {
|
||||
min = Double.parseDouble(minArg);
|
||||
max = Double.parseDouble(maxArg);
|
||||
}
|
||||
|
||||
return new AngleMask(context.getExtent(), min, max, overlay, 1);
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ public class BlockStateMaskParser extends InputParser<Mask> {
|
||||
Splitter.on(',').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(states),
|
||||
strict);
|
||||
} catch (Exception e) {
|
||||
throw new InputParseException(Caption.of("fawe.error.invalid-states", TextComponent.of(String.valueOf(e))));
|
||||
throw new InputParseException(Caption.of("worldedit.error.parser.bad-state-format", TextComponent.of(String.valueOf(e))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,207 +0,0 @@
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
///*
|
||||
// * WorldEdit, a Minecraft world manipulation toolkit
|
||||
// * Copyright (C) sk89q <http://www.sk89q.com>
|
||||
// * Copyright (C) WorldEdit team and contributors
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify it
|
||||
// * under the terms of the GNU Lesser General Public License as published by the
|
||||
// * Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
// * for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU Lesser General Public License
|
||||
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
//
|
||||
//import com.boydti.fawe.command.FaweParser;
|
||||
//import com.boydti.fawe.command.SuggestInputParseException;
|
||||
//import com.boydti.fawe.config.Caption;
|
||||
//import com.boydti.fawe.util.StringMan;
|
||||
//import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
//import com.sk89q.worldedit.WorldEdit;
|
||||
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
//import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||
//import com.sk89q.worldedit.extent.Extent;
|
||||
//import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
//import com.sk89q.worldedit.function.mask.Mask;
|
||||
//import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
//import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
//import com.sk89q.worldedit.session.request.Request;
|
||||
//import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
//import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
//import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//import java.util.stream.Collectors;
|
||||
//import java.util.stream.Stream;
|
||||
//
|
||||
//public class DefaultMaskParser extends FaweParser<Mask> {
|
||||
// public DefaultMaskParser(WorldEdit worldEdit) {
|
||||
// super(worldEdit, "masks");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
// if (input.isEmpty()) {
|
||||
// throw new SuggestInputParseException("No input provided", "", () -> Stream.concat(Stream.of("#", ",", "&"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList()));
|
||||
// }
|
||||
// Extent extent = Request.request().getExtent();
|
||||
// if (extent == null) extent = context.getExtent();
|
||||
// List<List<Mask>> masks = new ArrayList<>();
|
||||
// masks.add(new ArrayList<>());
|
||||
//
|
||||
// final CommandLocals locals = new CommandLocals();
|
||||
// Actor actor = context != null ? context.getActor() : null;
|
||||
// if (actor != null) {
|
||||
// locals.put(Actor.class, actor);
|
||||
// }
|
||||
// try {
|
||||
// List<Map.Entry<ParseEntry, List<String>>> parsed = parse(input);
|
||||
// for (Map.Entry<ParseEntry, List<String>> entry : parsed) {
|
||||
// ParseEntry pe = entry.getKey();
|
||||
// final String command = pe.input;
|
||||
// String full = pe.full;
|
||||
// Mask mask = null;
|
||||
// if (command.isEmpty()) {
|
||||
// mask = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
||||
// } else {
|
||||
// List<String> args = entry.getValue();
|
||||
// String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
||||
// try {
|
||||
// mask = parse(command + cmdArgs, context);
|
||||
// } catch (SuggestInputParseException rethrow) {
|
||||
// throw rethrow;
|
||||
// } catch (Throwable e) {
|
||||
// // TODO NOT IMPLEMENTED
|
||||
//// throw SuggestInputParseException.of(e, full, () -> {
|
||||
//// try {
|
||||
//// List<String> suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals);
|
||||
//// if (suggestions.size() <= 2) {
|
||||
//// for (int i = 0; i < suggestions.size(); i++) {
|
||||
//// String suggestion = suggestions.get(i);
|
||||
//// if (suggestion.indexOf(' ') != 0) {
|
||||
//// String[] split = suggestion.split(" ");
|
||||
//// suggestion = "[" + StringMan.join(split, "][") + "]";
|
||||
//// suggestions.set(i, suggestion);
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
//// return suggestions;
|
||||
//// } catch (CommandException e1) {
|
||||
//// throw new InputParseException(e1.getMessage());
|
||||
//// } catch (Throwable e2) {
|
||||
//// e2.printStackTrace();
|
||||
//// throw new InputParseException(e2.getMessage());
|
||||
//// }
|
||||
//// });
|
||||
// }
|
||||
// if (mask == null) {
|
||||
// // Legacy patterns
|
||||
// char char0 = command.charAt(0);
|
||||
// boolean charMask = input.length() > 1 && input.charAt(1) != '[';
|
||||
// if (charMask && input.charAt(0) == '=') {
|
||||
// return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
|
||||
// }
|
||||
// if (char0 == '#' || char0 == '?') {
|
||||
// // TODO NOT IMPLEMENTED
|
||||
//// throw new SuggestInputParseException(new NoMatchException("Unknown mask: " + full + ", See: //masks"), full,
|
||||
//// () -> {
|
||||
//// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
||||
//// return dispatcher.getAliases().stream().filter(
|
||||
//// s -> s.startsWith(command.toLowerCase(Locale.ROOT))
|
||||
//// ).collect(Collectors.toList());
|
||||
//// }
|
||||
//// );
|
||||
// }
|
||||
// // Legacy syntax
|
||||
// if (charMask) {
|
||||
// switch (char0) {
|
||||
// case '\\': //
|
||||
// case '/': //
|
||||
// case '{': //
|
||||
// case '$': //
|
||||
// case '%': {
|
||||
// String value = command.substring(1) + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]");
|
||||
// if (value.contains(":")) {
|
||||
// if (value.charAt(0) == ':') value.replaceFirst(":", "");
|
||||
// value = value.replaceAll(":", "][");
|
||||
// }
|
||||
// mask = parseFromInput("#" + char0 + "[" + value + "]", context);
|
||||
// break;
|
||||
// }
|
||||
// case '|':
|
||||
// case '~':
|
||||
// case '<':
|
||||
// case '>':
|
||||
// case '!':
|
||||
// input = input.substring(input.indexOf(char0) + 1);
|
||||
// mask = parseFromInput(char0 + "[" + input + "]", context);
|
||||
// if (actor != null) {
|
||||
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket", char0 + "[" + input + "]"));
|
||||
// }
|
||||
// return mask;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (mask == null) {
|
||||
// if (command.startsWith("[")) {
|
||||
// int end = command.lastIndexOf(']');
|
||||
// mask = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
|
||||
// } else {
|
||||
// List<String> entries = entry.getValue();
|
||||
// BlockMaskBuilder builder = new BlockMaskBuilder();
|
||||
//// if (StringMan.containsAny(full, "\\^$.|?+(){}<>~$!%^&*+-/"))
|
||||
// {
|
||||
// try {
|
||||
// builder.addRegex(full);
|
||||
// } catch (InputParseException ignored) {}
|
||||
// }
|
||||
// if (mask == null) {
|
||||
// context.setPreferringWildcard(false);
|
||||
// context.setRestricted(false);
|
||||
// BaseBlock block = worldEdit.getBlockFactory().parseFromInput(full, context);
|
||||
// builder.add(block);
|
||||
// mask = builder.build(extent);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (pe.and) {
|
||||
// masks.add(new ArrayList<>());
|
||||
// }
|
||||
// masks.get(masks.size() - 1).add(mask);
|
||||
// }
|
||||
// } catch (InputParseException rethrow) {
|
||||
// throw rethrow;
|
||||
// } catch (Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// throw new InputParseException(e.getMessage(), e);
|
||||
// }
|
||||
// List<Mask> maskUnions = new ArrayList<>();
|
||||
// for (List<Mask> maskList : masks) {
|
||||
// if (maskList.size() == 1) {
|
||||
// maskUnions.add(maskList.get(0));
|
||||
// } else if (maskList.size() != 0) {
|
||||
// maskUnions.add(new MaskUnion(maskList));
|
||||
// }
|
||||
// }
|
||||
// if (maskUnions.size() == 1) {
|
||||
// return maskUnions.get(0);
|
||||
// } else if (maskUnions.size() != 0) {
|
||||
// return new MaskIntersection(maskUnions);
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
@ -1,71 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.mask.ExtremaMask;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||
import com.sk89q.worldedit.extension.factory.parser.RichParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ExtremaMaskParser extends RichParser<Mask> {
|
||||
|
||||
private final String[] flags = new String[]{"-o"};
|
||||
|
||||
public ExtremaMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit, "#extrema");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> getSuggestions(String argumentInput, int index) {
|
||||
if (index == 0 || index == 1) {
|
||||
return SuggestionHelper.suggestPositiveDoubles(argumentInput).flatMap(s -> Stream.of(s, s + "d"));
|
||||
} else if (index > 1 && index <= 1 + flags.length) {
|
||||
return Stream.of(flags);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException(Caption.of("fawe.error.mask.angle"));
|
||||
}
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
String flag = arguments[index];
|
||||
if (flag.equals("-o")) {
|
||||
overlay = true;
|
||||
} else {
|
||||
throw new InputParseException(Caption.of("fawe.error.invalid-flag",
|
||||
TextComponent.of(flag)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (degree) {
|
||||
double minDeg = Double.parseDouble(minArg.substring(0, minArg.length() - 1));
|
||||
double maxDeg = Double.parseDouble(maxArg.substring(0, maxArg.length() - 1));
|
||||
min = (Math.tan(minDeg * (Math.PI / 180)));
|
||||
max = (Math.tan(maxDeg * (Math.PI / 180)));
|
||||
} else {
|
||||
min = Double.parseDouble(minArg);
|
||||
max = Double.parseDouble(maxArg);
|
||||
}
|
||||
|
||||
return new ExtremaMask(context.getExtent(), min, max, overlay, 4);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FalseMaskParser extends SimpleInputParser<Mask> {
|
||||
|
||||
private final List<String> aliases = ImmutableList.of("#false");
|
||||
|
||||
public FalseMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMatchedAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return Masks.alwaysFalse();
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.object.mask.LiquidMask;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LiquidMaskParser extends SimpleInputParser<Mask> {
|
||||
|
||||
private final List<String> aliases = ImmutableList.of("#liquid");
|
||||
|
||||
public LiquidMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMatchedAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return new LiquidMask(context.getExtent());
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.object.mask.ROCAngleMask;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||
import com.sk89q.worldedit.extension.factory.parser.RichParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ROCAngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
private final String[] flags = new String[]{"-o"};
|
||||
|
||||
public ROCAngleMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit, "#roc");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> getSuggestions(String argumentInput, int index) {
|
||||
if (index == 0 || index == 1) {
|
||||
return SuggestionHelper.suggestPositiveDoubles(argumentInput).flatMap(s -> Stream.of(s, s + "d"));
|
||||
} else if (index > 1 && index <= 1 + flags.length) {
|
||||
return Stream.of(flags);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException(Caption.of("fawe.error.mask.angle"));
|
||||
}
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
String flag = arguments[index];
|
||||
if (flag.equals("-o")) {
|
||||
overlay = true;
|
||||
} else {
|
||||
throw new InputParseException(Caption.of("fawe.error.invalid-flag",
|
||||
TextComponent.of(flag)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (degree) {
|
||||
double minDeg = Double.parseDouble(minArg.substring(0, minArg.length() - 1));
|
||||
double maxDeg = Double.parseDouble(maxArg.substring(0, maxArg.length() - 1));
|
||||
min = (Math.tan(minDeg * (Math.PI / 180)));
|
||||
max = (Math.tan(maxDeg * (Math.PI / 180)));
|
||||
} else {
|
||||
min = Double.parseDouble(minArg);
|
||||
max = Double.parseDouble(maxArg);
|
||||
}
|
||||
|
||||
return new ROCAngleMask(context.getExtent(), min, max, overlay, 4);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.object.mask.RadiusMask;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||
import com.sk89q.worldedit.extension.factory.parser.RichParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class RadiusMaskParser extends RichParser<Mask> {
|
||||
|
||||
public RadiusMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit, "{");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> getSuggestions(String argumentInput, int index) {
|
||||
if (index == 0 || index == 1) {
|
||||
return SuggestionHelper.suggestPositiveDoubles(argumentInput);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2) {
|
||||
return null;
|
||||
}
|
||||
int min = Integer.parseInt(arguments[0]);
|
||||
int max = Integer.parseInt(arguments[1]);
|
||||
return new RadiusMask(min, max);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||
import com.sk89q.worldedit.extension.factory.parser.RichParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class RichOffsetMaskParser extends RichParser<Mask> {
|
||||
|
||||
/**
|
||||
* Create a new rich parser with a defined prefix for the result, e.g. {@code #simplex}.
|
||||
*
|
||||
* @param worldEdit the worldedit instance.
|
||||
*/
|
||||
public RichOffsetMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit, "#offset");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> getSuggestions(String argumentInput, int index) {
|
||||
if (index < 3) {
|
||||
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
|
||||
}
|
||||
if (index == 3) {
|
||||
return worldEdit.getMaskFactory().getSuggestions(argumentInput).stream();
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length != 4) {
|
||||
return null;
|
||||
}
|
||||
int x = Integer.parseInt(arguments[0]);
|
||||
int y = Integer.parseInt(arguments[1]);
|
||||
int z = Integer.parseInt(arguments[2]);
|
||||
Mask submask = worldEdit.getMaskFactory().parseFromInput(arguments[3], context);
|
||||
OffsetMask offsetMask = new OffsetMask(submask, BlockVector3.at(x, y, z));
|
||||
return new MaskIntersection(offsetMask, Masks.negate(submask));
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.object.mask.SimplexMask;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||
import com.sk89q.worldedit.extension.factory.parser.RichParser;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SimplexMaskParser extends RichParser<Mask> {
|
||||
private static final String SIMPLEX_PREFIX = "#simplex";
|
||||
|
||||
public SimplexMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit, SIMPLEX_PREFIX);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> getSuggestions(String argumentInput, int index) {
|
||||
if (index < 3) {
|
||||
return SuggestionHelper.suggestPositiveDoubles(argumentInput);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length != 3) {
|
||||
return null;
|
||||
}
|
||||
double scale = Double.parseDouble(arguments[0]);
|
||||
double min = Double.parseDouble(arguments[1]);
|
||||
double max = Double.parseDouble(arguments[2]);
|
||||
scale = 1d / Math.max(1d, scale);
|
||||
min = (min - 50d) / 50d;
|
||||
max = (max - 50d) / 50d;
|
||||
return new SimplexMask(scale, min, max);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.fastasyncworldedit.core.object.mask.SurfaceMask;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SurfaceMaskParser extends SimpleInputParser<Mask> {
|
||||
|
||||
private final List<String> aliases = ImmutableList.of("#surface");
|
||||
|
||||
public SurfaceMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMatchedAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
|
||||
return new SurfaceMask(context.getExtent());
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TrueMaskParser extends SimpleInputParser<Mask> {
|
||||
|
||||
private final List<String> aliases = ImmutableList.of("#true");
|
||||
|
||||
public TrueMaskParser(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMatchedAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return Masks.alwaysTrue();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user