SteamWar/SpigotCore
Archiviert
13
0

Add SWCommand.Register.Registeres #104

Manuell gemergt
Lixfel hat 19 Commits von Registeres nach master 2021-05-12 20:35:45 +02:00 zusammengeführt
Nur Änderungen aus Commit 2adab560c2 werden angezeigt - Alle Commits anzeigen

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;