SteamWar/SpigotCore
Archiviert
13
0

Simplify SWCommandUtils

Dieser Commit ist enthalten in:
yoyosource 2021-05-05 08:54:24 +02:00
Ursprung 95fb899d14
Commit 2adab560c2

Datei anzeigen

@ -111,31 +111,34 @@ public class SWCommandUtils {
index++; index++;
} }
if (varArgType != null && index > args.length - 1) { int length = 0;
Object varArgument = Array.newInstance(varArgType, 0); if (varArgType != null) {
arguments[arguments.length - 1] = varArgument; length = args.length - parameters.length - subCommand.length + 1;
} else { arguments[arguments.length - 1] = Array.newInstance(varArgType, length);
for (int i = 0; i < parameters.length - (varArgType != null ? 1 : 0); i++) {
arguments[i + 1] = parameters[i].map(commandSender, Arrays.copyOf(args, index), args[index]); if (index > args.length - 1) {
index++; return arguments;
if (arguments[i + 1] == null) { }
}
for (int i = 0; i < parameters.length - (varArgType != null ? 1 : 0); i++) {
arguments[i + 1] = parameters[i].map(commandSender, Arrays.copyOf(args, index), args[index]);
index++;
if (arguments[i + 1] == null) {
throw new CommandParseException();
}
}
if (varArgType != null) {
Object varArgument = arguments[args.length - 1];
for (int i = 0; i < length; i++) {
Object value = parameters[parameters.length - 1].map(commandSender, Arrays.copyOf(args, index), args[index]);
if (value == null) {
throw new CommandParseException(); throw new CommandParseException();
} }
} Array.set(varArgument, i, value);
index++;
if (varArgType != null) {
int length = args.length - parameters.length - subCommand.length + 1;
Object varArgument = Array.newInstance(varArgType, length);
arguments[arguments.length - 1] = varArgument;
for (int i = 0; i < length; i++) {
Object value = parameters[parameters.length - 1].map(commandSender, Arrays.copyOf(args, index), args[index]);
if (value == null) {
throw new CommandParseException();
}
Array.set(varArgument, i, value);
index++;
}
} }
} }
return arguments; return arguments;