SteamWar/SpigotCore
Archiviert
13
0

Fix SubCommand behaviour
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2021-11-16 22:28:08 +01:00
Ursprung 9c588b74bf
Commit 8124189214

Datei anzeigen

@ -92,7 +92,11 @@ class SubCommand {
SWCommand.Guard guard = parameter.getAnnotation(SWCommand.Guard.class);
if (guard != null) {
if (guard.value() == null || guard.value().isEmpty()) {
return GUARD_FUNCTIONS.getOrDefault(parameter.getType().getTypeName(), null);
String s = parameter.getType().getTypeName();
if (parameter.isVarArgs()) {
s = parameter.getType().getComponentType().getTypeName();
}
return localGuardChecker.getOrDefault(s, GUARD_FUNCTIONS.getOrDefault(s, null));
}
GuardChecker current = localGuardChecker.getOrDefault(guard.value(), GUARD_FUNCTIONS.getOrDefault(guard.value(), null));
if (guardChecker == null) {
@ -116,15 +120,24 @@ class SubCommand {
}
Object[] objects = SWCommandUtils.generateArgumentArray(commandSender, arguments, guards, args, varArgType, subCommand);
objects[0] = commandSenderFunction.apply(commandSender);
for (int i = 0; i < objects.length; i++) {
for (int i = subCommand.length; i < args.length; i++) {
GuardChecker current;
if (i == 0) {
if (i == subCommand.length) {
current = guardChecker;
} else {
current = guards[i - 1];
if (i >= objects.length + subCommand.length) {
current = guards[guards.length - 1];
} else {
current = guards[i - 1 - subCommand.length];
}
}
if (current != null) {
GuardResult guardResult = current.guard(commandSender, help ? GuardCheckType.HELP_COMMAND : GuardCheckType.COMMAND, new String[0], null);
GuardResult guardResult;
if (i == 0) {
guardResult = current.guard(commandSender, help ? GuardCheckType.HELP_COMMAND : GuardCheckType.COMMAND, new String[0], null);
} else {
guardResult = current.guard(commandSender, help ? GuardCheckType.HELP_COMMAND : GuardCheckType.COMMAND, Arrays.copyOf(args, i - 1), args[i - 1]);
}
if (guardResult != GuardResult.ALLOWED) {
if (guardResult == GuardResult.DENIED) {
throw new CommandNoHelpException();