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,10 +111,16 @@ 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);
if (index > args.length - 1) {
return arguments;
}
}
for (int i = 0; i < parameters.length - (varArgType != null ? 1 : 0); i++) { 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]); arguments[i + 1] = parameters[i].map(commandSender, Arrays.copyOf(args, index), args[index]);
index++; index++;
@ -124,9 +130,7 @@ public class SWCommandUtils {
} }
if (varArgType != null) { if (varArgType != null) {
int length = args.length - parameters.length - subCommand.length + 1; Object varArgument = arguments[args.length - 1];
Object varArgument = Array.newInstance(varArgType, length);
arguments[arguments.length - 1] = varArgument;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Object value = parameters[parameters.length - 1].map(commandSender, Arrays.copyOf(args, index), args[index]); Object value = parameters[parameters.length - 1].map(commandSender, Arrays.copyOf(args, index), args[index]);
@ -137,7 +141,6 @@ public class SWCommandUtils {
index++; index++;
} }
} }
}
return arguments; return arguments;
} }