From 527b7141a318c78962be1cf7b1ea0228c81e8abe Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Mon, 15 Nov 2021 18:02:43 +0000 Subject: [PATCH] RandomPatternParser is an upstream class --- .../worldedit/extension/factory/PatternFactory.java | 2 +- .../factory/parser/pattern/RandomPatternParser.java | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) rename worldedit-core/src/main/java/com/{fastasyncworldedit/core => sk89q/worldedit}/extension/factory/parser/pattern/RandomPatternParser.java (89%) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java index 99d781ab6..420e58d2a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java @@ -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; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java similarity index 89% rename from worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomPatternParser.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java index f617d0e63..66b410817 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java @@ -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 { @Override public Stream getSuggestions(String input) { + //FAWE start List patterns = StringUtil.split(input, ',', '[', ']'); - /*String[] splits = input.split(",", -1); - List patterns = StringUtil.parseListInQuotes(splits, ',', '[', ']', true);*/ if (patterns.size() == 1) { return Stream.empty(); } @@ -37,7 +36,6 @@ public class RandomPatternParser extends InputParser { 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 { } final List 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 patterns = StringUtil.split(input, ',', '[', ']'); - /*String[] splits = input.split(",", -1); - List 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 { // 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(