From e40db3d711553765ff81bd31173fb891c9536b3c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 14 May 2021 15:36:04 +0200 Subject: [PATCH] Add SWCommand.methods --- .../src/de/steamwar/command/SWCommand.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index c44c0bb..0e502b3 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -70,7 +70,7 @@ public abstract class SWCommand { unregister(); register(); - Method[] methods = getClass().getDeclaredMethods(); + List 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 methods() { + List 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 -> {