SteamWar/SpigotCore
Archiviert
13
0

Fix CCE in SubCommand.invoke #100

Manuell gemergt
YoyoNow hat 1 Commits von CommandFix nach master 2021-04-16 17:19:42 +02:00 zusammengeführt
Nur Änderungen aus Commit a7e5f50262 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -26,6 +26,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
class SubCommand {
@ -33,6 +34,7 @@ class SubCommand {
private Method method;
String[] subCommand;
TypeMapper<?>[] arguments;
private Predicate<CommandSender> commandSenderPredicate;
private Function<CommandSender, ?> commandSenderFunction;
Class<?> varArgType = null;
@ -45,6 +47,7 @@ class SubCommand {
this.method = method;
Parameter[] parameters = method.getParameters();
commandSenderPredicate = sender -> parameters[0].getType().isAssignableFrom(sender.getClass());
commandSenderFunction = sender -> parameters[0].getType().cast(sender);
this.subCommand = subCommand;
@ -88,6 +91,9 @@ class SubCommand {
return false;
}
try {
if (!commandSenderPredicate.test(commandSender)) {
return false;
}
Object[] objects = SWCommandUtils.generateArgumentArray(commandSender, arguments, args, varArgType, subCommand);
objects[0] = commandSenderFunction.apply(commandSender);
method.setAccessible(true);