RandomPatternParser is an upstream class

This commit is contained in:
dordsor21 2021-11-15 18:02:43 +00:00
parent 7f61483609
commit 527b7141a3
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 8 additions and 7 deletions

View File

@ -42,7 +42,7 @@ import com.fastasyncworldedit.core.extension.factory.parser.pattern.OffsetPatter
import com.fastasyncworldedit.core.extension.factory.parser.pattern.PerlinPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RandomFullClipboardPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RandomOffsetPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RandomPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RelativePatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RichPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RidgedMultiFractalPatternParser;

View File

@ -1,4 +1,4 @@
package com.fastasyncworldedit.core.extension.factory.parser.pattern;
package com.sk89q.worldedit.extension.factory.parser.pattern;
import com.fastasyncworldedit.core.configuration.Caption;
import com.sk89q.util.StringUtil;
@ -26,9 +26,8 @@ public class RandomPatternParser extends InputParser<Pattern> {
@Override
public Stream<String> getSuggestions(String input) {
//FAWE start
List<String> patterns = StringUtil.split(input, ',', '[', ']');
/*String[] splits = input.split(",", -1);
List<String> patterns = StringUtil.parseListInQuotes(splits, ',', '[', ']', true);*/
if (patterns.size() == 1) {
return Stream.empty();
}
@ -37,7 +36,6 @@ public class RandomPatternParser extends InputParser<Pattern> {
String previous = String.join(",", patterns.subList(0, patterns.size() - 1));
if (token.matches("[0-9]+(\\.[0-9]*)?%.*")) {
String[] p = token.split("%");
if (p.length < 2) {
return Stream.empty();
} else {
@ -46,15 +44,16 @@ public class RandomPatternParser extends InputParser<Pattern> {
}
final List<String> innerSuggestions = worldEdit.getPatternFactory().getSuggestions(token);
return innerSuggestions.stream().map(s -> previous + "," + s);
//FAWE end
}
@Override
public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
RandomPattern randomPattern = new RandomPattern();
//FAWE start
List<String> patterns = StringUtil.split(input, ',', '[', ']');
/*String[] splits = input.split(",", -1);
List<String> patterns = StringUtil.parseListInQuotes(splits, ',', '[', ']', true);*/
//FAWE end
if (patterns.size() == 1) {
return null; // let a 'single'-pattern parser handle it
}
@ -64,7 +63,9 @@ public class RandomPatternParser extends InputParser<Pattern> {
// Parse special percentage syntax
if (token.matches("[0-9]+(\\.[0-9]*)?%.*")) {
//FAWE start
String[] p = token.split("%", 2);
//FAWE end
if (p.length < 2) {
throw new InputParseException(Caption.of(