SteamWar/SpigotCore
Archiviert
13
0

Add ignoreCase subCommands

Add ignoreCase tabComplete filter
Dieser Commit ist enthalten in:
yoyosource 2021-03-30 16:14:28 +02:00
Ursprung ce2cd3d1bf
Commit 314120a01f
3 geänderte Dateien mit 3 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -70,7 +70,7 @@ public abstract class SWCommand {
} }
strings = new ArrayList<>(strings); strings = new ArrayList<>(strings);
for (int i = strings.size() - 1; i >= 0; i--) { for (int i = strings.size() - 1; i >= 0; i--) {
if (!strings.get(i).startsWith(args[args.length - 1])) { if (!strings.get(i).toLowerCase().startsWith(args[args.length - 1].toLowerCase())) {
strings.remove(i); strings.remove(i);
} }
} }

Datei anzeigen

@ -104,7 +104,7 @@ public class SWCommandUtils {
Object[] arguments = new Object[parameters.length + 1]; Object[] arguments = new Object[parameters.length + 1];
int index = 0; int index = 0;
while (index < subCommand.length) { while (index < subCommand.length) {
if (!args[index].equals(subCommand[index])) { if (!args[index].equalsIgnoreCase(subCommand[index])) {
throw new CommandParseException(); throw new CommandParseException();
} }
index++; index++;
@ -115,9 +115,7 @@ public class SWCommandUtils {
arguments[arguments.length - 1] = varArgument; arguments[arguments.length - 1] = varArgument;
} else { } else {
for (int i = 0; i < parameters.length - (varArgType != null ? 1 : 0); i++) { for (int i = 0; i < parameters.length - (varArgType != null ? 1 : 0); i++) {
System.out.println(index);
arguments[i + 1] = parameters[i].map(args[index]); arguments[i + 1] = parameters[i].map(args[index]);
System.out.println(arguments[i + 1]);
index++; index++;
if (arguments[i + 1] == null) { if (arguments[i + 1] == null) {
throw new CommandParseException(); throw new CommandParseException();

Datei anzeigen

@ -108,7 +108,7 @@ class SubCommand {
for (String value : subCommand) { for (String value : subCommand) {
String s = argsList.remove(0); String s = argsList.remove(0);
if (argsList.isEmpty()) return Collections.singletonList(value); if (argsList.isEmpty()) return Collections.singletonList(value);
if (!value.equals(s)) return null; if (!value.equalsIgnoreCase(s)) return null;
} }
for (TypeMapper<?> argument : arguments) { for (TypeMapper<?> argument : arguments) {
String s = argsList.remove(0); String s = argsList.remove(0);