3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 10:30:04 +01:00

Reimplement radius mask, fix wall mask

Dieser Commit ist enthalten in:
dordsor21 2021-08-17 17:03:25 +01:00
Ursprung 46f6395279
Commit 569fdc3861
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
4 geänderte Dateien mit 37 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -20,14 +20,14 @@ public class RadiusMaskParser extends RichParser<Mask> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
if (index == 0 || index == 1) {
return SuggestionHelper.suggestPositiveDoubles(argumentInput);
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
}
return Stream.empty();
}
@Override
protected Mask parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
if (arguments.length < 2) {
if (arguments.length != 2) {
return null;
}
int min = Integer.parseInt(arguments[0]);

Datei anzeigen

@ -1,22 +1,21 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.mask.WallMask;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.BlockMask;
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.internal.registry.SimpleInputParser;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.stream.Stream;
public class WallMaskParser extends SimpleInputParser<Mask> {
public class WallMaskParser extends RichParser<Mask> {
private final List<String> aliases = ImmutableList.of("#wall");
private final List<String> aliases = ImmutableList.of("#wall", "|");
public WallMaskParser(WorldEdit worldEdit) {
super(worldEdit);
@ -28,11 +27,30 @@ public class WallMaskParser extends SimpleInputParser<Mask> {
}
@Override
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new MaskIntersection(
new ExistingBlockMask(context.getExtent()),
new WallMask(new BlockMask(context.getExtent(), BlockTypes.AIR.getDefaultState().toBaseBlock()), 1, 8)
);
protected Stream<String> getSuggestions(final String argumentInput, final 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(@Nonnull final String[] arguments, final ParserContext context) throws InputParseException {
if (arguments.length > 3 || 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;
}
return new WallMask(subMask, min, max);
}
}

Datei anzeigen

@ -6,9 +6,9 @@ import com.sk89q.worldedit.math.BlockVector3;
public class RadiusMask extends AbstractMask implements ResettableMask {
private transient BlockVector3 pos;
private final int minSqr;
private final int maxSqr;
private transient BlockVector3 pos;
public RadiusMask(int min, int max) {
this.minSqr = min * min;
@ -47,7 +47,7 @@ public class RadiusMask extends AbstractMask implements ResettableMask {
@Override
public Mask copy() {
return new RadiusMask(minSqr, maxSqr);
return new RadiusMask((Integer) minSqr, (Integer) maxSqr);
}
}

Datei anzeigen

@ -22,11 +22,12 @@ package com.sk89q.worldedit.extension.factory;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.mask.AdjacentMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.AngleMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.RichMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.ExtremaMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.FalseMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.LiquidMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.ROCAngleMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.RadiusMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.RichMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.RichOffsetMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.SimplexMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.SurfaceAngleMaskParser;
@ -108,7 +109,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
register(new ExtremaMaskParser(worldEdit));
register(new FalseMaskParser(worldEdit));
register(new LiquidMaskParser(worldEdit));
//register(new RadiusMaskParser(worldEdit)); TODO: Adapt to work with FAWE's Chunk I/O
register(new RadiusMaskParser(worldEdit));
register(new RichOffsetMaskParser(worldEdit));
register(new ROCAngleMaskParser(worldEdit));
register(new SimplexMaskParser(worldEdit));