Skip to content

Commit

Permalink
🛠 Fix Duplicated Spaces in StructCommand (SkriptLang#5416)
Browse files Browse the repository at this point in the history
  • Loading branch information
AyhamAl-Ali committed Aug 21, 2023
1 parent d6cabe1 commit 3fa5cef
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/ch/njol/skript/structures/StructCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ public class StructCommand extends Structure {

public static final Priority PRIORITY = new Priority(500);

private static final Pattern
COMMAND_PATTERN = Pattern.compile("(?i)^command /?(\\S+)\\s*(\\s+(.+))?$"),
ARGUMENT_PATTERN = Pattern.compile("<\\s*(?:([^>]+?)\\s*:\\s*)?(.+?)\\s*(?:=\\s*(" + SkriptParser.wildcard + "))?\\s*>"),
DESCRIPTION_PATTERN = Pattern.compile("(?<!\\\\)%-?(.+?)%");
private static final Pattern COMMAND_PATTERN = Pattern.compile("(?i)^command\\s+/?(\\S+)\\s*(\\s+(.+))?$");
private static final Pattern ARGUMENT_PATTERN = Pattern.compile("<\\s*(?:([^>]+?)\\s*:\\s*)?(.+?)\\s*(?:=\\s*(" + SkriptParser.wildcard + "))?\\s*>");
private static final Pattern DESCRIPTION_PATTERN = Pattern.compile("(?<!\\\\)%-?(.+?)%");

private static final AtomicBoolean SYNC_COMMANDS = new AtomicBoolean();

Expand Down Expand Up @@ -184,7 +183,10 @@ public boolean load() {

Matcher matcher = COMMAND_PATTERN.matcher(fullCommand);
boolean matches = matcher.matches();
assert matches;
if (!matches) {
Skript.error("Invalid command structure pattern");
return false;
}

String command = matcher.group(1).toLowerCase();
ScriptCommand existingCommand = Commands.getScriptCommand(command);
Expand Down

0 comments on commit 3fa5cef

Please sign in to comment.