Skip to content

Commit f2e9a41

Browse files
authored
🛠 [2.7] Fix Duplicated Spaces in StructCommand (#5416) (#5929)
1 parent f4b7b06 commit f2e9a41

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/ch/njol/skript/structures/StructCommand.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ public class StructCommand extends Structure {
8282

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

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

9089
private static final AtomicBoolean SYNC_COMMANDS = new AtomicBoolean();
9190

@@ -184,7 +183,10 @@ public boolean load() {
184183

185184
Matcher matcher = COMMAND_PATTERN.matcher(fullCommand);
186185
boolean matches = matcher.matches();
187-
assert matches;
186+
if (!matches) {
187+
Skript.error("Invalid command structure pattern");
188+
return false;
189+
}
188190

189191
String command = matcher.group(1).toLowerCase();
190192
ScriptCommand existingCommand = Commands.getScriptCommand(command);

0 commit comments

Comments
 (0)