mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Reimplement #offset mask (#712)
This commit is contained in:
parent
d3600e4225
commit
097f3ec473
@ -38,6 +38,7 @@ 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.OffsetMaskParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.ROCAngleMaskParser;
|
import com.sk89q.worldedit.extension.factory.parser.mask.ROCAngleMaskParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
|
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.sk89q.worldedit.extension.factory.parser.mask.SimplexMaskParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser;
|
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.SurfaceMaskParser;
|
||||||
@ -97,6 +98,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
|||||||
register(new FalseMaskParser(worldEdit));
|
register(new FalseMaskParser(worldEdit));
|
||||||
register(new LiquidMaskParser(worldEdit));
|
register(new LiquidMaskParser(worldEdit));
|
||||||
//register(new RadiusMaskParser(worldEdit)); TODO: Adapt to work with FAWE's Chunk I/O
|
//register(new RadiusMaskParser(worldEdit)); TODO: Adapt to work with FAWE's Chunk I/O
|
||||||
|
register(new RichOffsetMaskParser(worldEdit));
|
||||||
register(new ROCAngleMaskParser(worldEdit));
|
register(new ROCAngleMaskParser(worldEdit));
|
||||||
register(new SimplexMaskParser(worldEdit));
|
register(new SimplexMaskParser(worldEdit));
|
||||||
register(new SurfaceMaskParser(worldEdit));
|
register(new SurfaceMaskParser(worldEdit));
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user