mirror of
https://github.com/kaboomserver/extras.git
synced 2024-10-31 16:59:24 +00:00
Improve distance selector detection
This commit is contained in:
parent
a91c25f8c2
commit
634661e1fa
|
@ -19,6 +19,8 @@ import java.util.regex.Pattern;
|
||||||
public final class ServerCommand implements Listener {
|
public final class ServerCommand implements Listener {
|
||||||
private static final Pattern AS_AT_PATTERN = Pattern.compile(
|
private static final Pattern AS_AT_PATTERN = Pattern.compile(
|
||||||
"\\b(as|at|facing entity) @[ae]\\b");
|
"\\b(as|at|facing entity) @[ae]\\b");
|
||||||
|
private static final Pattern DISTANCE_SELECTOR_PATTERN = Pattern.compile(
|
||||||
|
"[\"']?distance[\"']?\\s*=\\s*");
|
||||||
private static final Logger LOGGER = JavaPlugin.getPlugin(Main.class).getLogger();
|
private static final Logger LOGGER = JavaPlugin.getPlugin(Main.class).getLogger();
|
||||||
|
|
||||||
public static boolean checkExecuteCommand(final String cmd) {
|
public static boolean checkExecuteCommand(final String cmd) {
|
||||||
|
@ -208,8 +210,8 @@ public final class ServerCommand implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.contains("distance")) {
|
if (command.contains("distance")) {
|
||||||
return command.replace("distance=", "]").replace("\"distance\"=", "]")
|
final Matcher distanceMatcher = DISTANCE_SELECTOR_PATTERN.matcher(command);
|
||||||
.replace("'distance'=", "]");
|
return distanceMatcher.replaceAll("]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue