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++;
}
if (varArgType != null && index > args.length - 1) {
Object varArgument = Array.newInstance(varArgType, 0);
arguments[arguments.length - 1] = varArgument;
} else {
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) {
int length = 0;
if (varArgType != null) {
length = args.length - parameters.length - subCommand.length + 1;
arguments[arguments.length - 1] = Array.newInstance(varArgType, length);
if (index > args.length - 1) {
return arguments;
}
}
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();
}
}
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++;
}
Array.set(varArgument, i, value);
index++;
}
}
return arguments;