Skip to content

Commit 014cb21

Browse files
Improve prefix validation
1 parent f889689 commit 014cb21

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/main/java/org/skriptlang/skript/bukkit/command/brigadier/RuntimeCommandRegistrar.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.lang.reflect.Method;
1818
import java.lang.reflect.Proxy;
1919
import java.util.Collection;
20-
import java.util.Locale;
2120
import java.util.Map;
2221
import java.util.Set;
2322
import java.util.concurrent.ConcurrentHashMap;
@@ -154,10 +153,8 @@ public TemporaryNamePluginMeta(PluginMeta source, String name) {
154153
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
155154
if (useAlternativeName) {
156155
String methodName = method.getName();
157-
if (methodName.equals("getName")) {
156+
if (methodName.equals("getName") || methodName.equals("namespace")) {
158157
return name;
159-
} else if (methodName.equals("namespace")) {
160-
return name.toLowerCase(Locale.ROOT);
161158
}
162159
}
163160
return method.invoke(source, args);

src/main/java/org/skriptlang/skript/bukkit/command/elements/structures/util/SubCommandEntryData.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,20 @@ public SubCommandEntryData(String key, boolean optional, boolean multiple) {
190190
}
191191

192192
String prefix = entryContainer.getOptional("prefix", String.class, false);
193-
if (!isRoot && prefix != null) {
194-
Skript.error("Only the root of a command may have a prefix.");
195-
return null;
193+
if (prefix != null) {
194+
if (!isRoot) {
195+
Skript.error("Only the root of a command may have a prefix.");
196+
return null;
197+
}
198+
for (char c : prefix.toCharArray()) {
199+
if (Character.isWhitespace(c)) {
200+
Skript.error("Command prefixes must not have any whitespace.");
201+
return null;
202+
} else if (c == 167) { // char 167 is §
203+
Skript.error("Command prefixes must not have any section symbols.");
204+
return null;
205+
}
206+
}
196207
}
197208

198209
// command requirements

0 commit comments

Comments
 (0)