mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-01-09 09:17:39 +00:00
First attempt at fixing quoted string oddities.
This commit is contained in:
parent
508ece9e0f
commit
96e2b6c5af
@ -42,6 +42,7 @@ import com.sk89q.worldedit.internal.registry.InputParser;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry of known {@link Mask}s. Provides methods to instantiate
|
* A registry of known {@link Mask}s. Provides methods to instantiate
|
||||||
@ -74,6 +75,16 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
|||||||
register(new BiomeMaskParser(worldEdit));
|
register(new BiomeMaskParser(worldEdit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSuggestions(String input) {
|
||||||
|
final String[] split = input.split(" ");
|
||||||
|
if (split.length > 1) {
|
||||||
|
String prev = input.substring(0, input.lastIndexOf(" ")) + " ";
|
||||||
|
return super.getSuggestions(split[split.length -1]).stream().map(s -> prev + s).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return super.getSuggestions(input);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
|
public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||||
List<Mask> masks = new ArrayList<>();
|
List<Mask> masks = new ArrayList<>();
|
||||||
|
@ -67,16 +67,28 @@ public class CommandArgParser {
|
|||||||
handleQuote(nextPart);
|
handleQuote(nextPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (currentArg.size() > 0) {
|
||||||
|
finishArg(); // force finish "hanging" args
|
||||||
|
}
|
||||||
return args.build();
|
return args.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNormal(Substring part) {
|
private void handleNormal(Substring part) {
|
||||||
if (part.getSubstring().startsWith("\"")) {
|
final String strPart = part.getSubstring();
|
||||||
state = State.QUOTE;
|
if (strPart.startsWith("\"")) {
|
||||||
currentArg.add(Substring.wrap(
|
if (strPart.endsWith("\"") && strPart.length() > 1) {
|
||||||
part.getSubstring().substring(1),
|
currentArg.add(Substring.wrap(
|
||||||
part.getStart(), part.getEnd()
|
strPart.substring(1, strPart.length() - 1),
|
||||||
));
|
part.getStart(), part.getEnd()
|
||||||
|
));
|
||||||
|
finishArg();
|
||||||
|
} else {
|
||||||
|
state = State.QUOTE;
|
||||||
|
currentArg.add(Substring.wrap(
|
||||||
|
strPart.substring(1),
|
||||||
|
part.getStart(), part.getEnd()
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
currentArg.add(part);
|
currentArg.add(part);
|
||||||
finishArg();
|
finishArg();
|
||||||
|
Loading…
Reference in New Issue
Block a user