Reformat, fix RichParser suggestions

Dieser Commit ist enthalten in:
IronApollo 2020-09-07 21:46:54 -04:00
Ursprung 7929320611
Commit dc465f7d3c
7 geänderte Dateien mit 58 neuen und 34 gelöschten Zeilen

Datei anzeigen

@ -94,32 +94,32 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
boolean aboveMin;
lastY = y;
slope =
Math.abs(getHeight(extent, x + distance, y, z) - getHeight(extent, x - distance, y, z))
* ADJACENT_MOD;
Math.abs(getHeight(extent, x + distance, y, z) - getHeight(extent, x - distance, y, z))
* ADJACENT_MOD;
if (checkFirst) {
if (slope >= min) {
return lastValue = true;
}
slope = Math.max(slope, Math.abs(
getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance))
* ADJACENT_MOD);
getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance))
* ADJACENT_MOD);
slope = Math.max(slope, Math.abs(
getHeight(extent, x + distance, y, z + distance) - getHeight(extent,
x - distance, y, z - distance)) * DIAGONAL_MOD);
getHeight(extent, x + distance, y, z + distance) - getHeight(extent,
x - distance, y, z - distance)) * DIAGONAL_MOD);
slope = Math.max(slope, Math.abs(
getHeight(extent, x - distance, y, z + distance) - getHeight(extent,
x + distance, y, z - distance)) * DIAGONAL_MOD);
getHeight(extent, x - distance, y, z + distance) - getHeight(extent,
x + distance, y, z - distance)) * DIAGONAL_MOD);
return lastValue = (slope >= min);
} else {
slope = Math.max(slope, Math.abs(
getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance))
* ADJACENT_MOD);
getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance))
* ADJACENT_MOD);
slope = Math.max(slope, Math.abs(
getHeight(extent, x + distance, y, z + distance) - getHeight(extent,
x - distance, y, z - distance)) * DIAGONAL_MOD);
getHeight(extent, x + distance, y, z + distance) - getHeight(extent,
x - distance, y, z - distance)) * DIAGONAL_MOD);
slope = Math.max(slope, Math.abs(
getHeight(extent, x - distance, y, z + distance) - getHeight(extent,
x + distance, y, z - distance)) * DIAGONAL_MOD);
getHeight(extent, x - distance, y, z + distance) - getHeight(extent,
x + distance, y, z - distance)) * DIAGONAL_MOD);
return lastValue = (slope >= min && slope <= max);
}
}

Datei anzeigen

@ -14,19 +14,19 @@ public class ROCAngleMask extends AngleMask {
int base = getHeight(extent, x, y, z);
double slope =
(getHeight(extent, x + distance, y, z) - base - (base - getHeight(extent, x - distance, y, z)))
* ADJACENT_MOD;
(getHeight(extent, x + distance, y, z) - base - (base - getHeight(extent, x - distance, y, z)))
* ADJACENT_MOD;
double tmp = (getHeight(extent, x, y, z + distance) - base - (base - getHeight(extent, x, y,
z - distance))) * ADJACENT_MOD;
z - distance))) * ADJACENT_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = (getHeight(extent, x + distance, y, z + distance) - base - (base - getHeight(extent, x - distance, y,
z - distance))) * DIAGONAL_MOD;
z - distance))) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = (getHeight(extent, x - distance, y, z + distance) - base - (base - getHeight(extent, x + distance, y,
z - distance))) * DIAGONAL_MOD;
z - distance))) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
return lastValue = slope >= min && slope <= max;

Datei anzeigen

@ -13,9 +13,9 @@ public class SurfaceMask extends AdjacentAnyMask {
public static AbstractExtentMask getMask(Extent extent) {
return new BlockMaskBuilder()
.addTypes(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR)
.addAll(b -> !b.getMaterial().isMovementBlocker())
.build(extent);
.addTypes(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR)
.addAll(b -> !b.getMaterial().isMovementBlocker())
.build(extent);
}
@Override

Datei anzeigen

@ -20,7 +20,32 @@
package com.sk89q.worldedit.extension.factory;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.factory.parser.mask.*;
import com.sk89q.worldedit.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.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.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser;
import com.sk89q.worldedit.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.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
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.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.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;

Datei anzeigen

@ -36,7 +36,7 @@ public abstract class RichParser<E> extends InputParser<E> {
@Override
public Stream<String> getSuggestions(String input) {
// we don't even want to start suggesting if it's not meant to be this parser result
if (input.length() > this.required.length() && !input.startsWith(this.required)) {
if (input.length() >= this.required.length() && !input.startsWith(this.required)) {
return Stream.empty();
}
// suggest until the first [ as long as it isn't fully typed
@ -45,11 +45,11 @@ public abstract class RichParser<E> extends InputParser<E> {
}
// we know that it is at least "<required>"
String[] strings = extractArguments(input.substring(this.prefix.length()), false);
StringJoiner joiner = new StringJoiner(",");
StringBuilder builder = new StringBuilder();
for (int i = 0; i < strings.length - 1; i++) {
joiner.add("[" + strings[i] + "]");
builder.append('[').append(strings[i]).append(']');
}
String previous = this.prefix + joiner;
String previous = this.prefix + builder;
return getSuggestions(strings[strings.length - 1], strings.length - 1).map(s -> previous + "[" + s + "]");
}

Datei anzeigen

@ -14,12 +14,12 @@ import java.util.stream.Stream;
public class AdjacentMaskParser extends RichParser<Mask> {
public AdjacentMaskParser(WorldEdit worldEdit) {
super(worldEdit,"~");
super(worldEdit, "~");
}
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
if(index == 0){
if (index == 0) {
return worldEdit.getMaskFactory().getSuggestions(argumentInput).stream();
} else if (index == 1 || index == 2) {
return this.suggestPositiveDoubles(argumentInput);
@ -29,7 +29,7 @@ public class AdjacentMaskParser extends RichParser<Mask> {
@Override
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
if(arguments.length == 0) return null;
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;
@ -40,6 +40,6 @@ public class AdjacentMaskParser extends RichParser<Mask> {
if (max >= 8 && min == 1) {
return new AdjacentAnyMask(subMask);
}
return new AdjacentMask(subMask, (int) min, (int) max);
return new AdjacentMask(subMask, min, max);
}
}

Datei anzeigen

@ -18,7 +18,7 @@ public class RadiusMaskParser extends RichParser<Mask> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
if(index == 0 || index == 1){
if (index == 0 || index == 1) {
return suggestPositiveDoubles(argumentInput);
}
return Stream.empty();
@ -26,10 +26,9 @@ public class RadiusMaskParser extends RichParser<Mask> {
@Override
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
if(arguments.length < 2) return null;
if (arguments.length < 2) return null;
int min = Integer.parseInt(arguments[0]);
int max = Integer.parseInt(arguments[1]);
System.out.println("radius: " + min + " | " + max);
return new RadiusMask(min, max);
}
}