SteamWar/SpigotCore
Archiviert
13
0

Add SWCommand.methods

Dieser Commit ist enthalten in:
yoyosource 2021-05-14 15:36:04 +02:00
Ursprung 2a9636b995
Commit e40db3d711

Datei anzeigen

@ -70,7 +70,7 @@ public abstract class SWCommand {
unregister();
register();
Method[] methods = getClass().getDeclaredMethods();
List<Method> methods = methods();
for (Method method : methods) {
addMapper(Mapper.class, method, i -> i == 0, false, TypeMapper.class, (anno, typeMapper) -> {
(anno.local() ? localTypeMapper : SWCommandUtils.MAPPER_FUNCTIONS).putIfAbsent(anno.value(), typeMapper);
@ -90,7 +90,8 @@ public abstract class SWCommand {
Bukkit.getLogger().log(Level.WARNING, "The method '" + method.toString() + "' is lacking the varArgs parameters of type '" + String.class.getTypeName() + "' as last Argument");
return;
}
if (method.getName().equals("internalHelp") && method.getDeclaringClass() == SWCommand.class) {
if (method.getName().equals("internalHelp")) {
System.out.println(method + " " + hasHelp);
if (hasHelp) {
return;
}
@ -167,6 +168,12 @@ public abstract class SWCommand {
});
}
private List<Method> methods() {
List<Method> methods = Arrays.asList(getClass().getDeclaredMethods());
methods.addAll(Arrays.asList(SWCommand.class.getDeclaredMethods()));
return methods;
}
public void unregister() {
SWCommandUtils.knownCommandMap.remove(command.getName());
command.getAliases().forEach(SWCommandUtils.knownCommandMap::remove);
@ -177,7 +184,7 @@ public abstract class SWCommand {
SWCommandUtils.commandMap.register("steamwar", this.command);
}
@Register
@Register(help = true)
private void internalHelp(CommandSender sender, String... args) {
if (help.isEmpty()) {
commandList.forEach(subCommand -> {