diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index 0e502b3..06757f5 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -22,6 +22,8 @@ package de.steamwar.command; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitRunnable; import java.lang.annotation.*; import java.lang.reflect.Method; @@ -169,8 +171,15 @@ public abstract class SWCommand { } private List methods() { - List methods = Arrays.asList(getClass().getDeclaredMethods()); - methods.addAll(Arrays.asList(SWCommand.class.getDeclaredMethods())); + Class current = getClass(); + List methods = new ArrayList<>(); + int count = 0; + while (current != null && count < 4) { + methods.addAll(Arrays.asList(current.getDeclaredMethods())); + current = current.getSuperclass(); + count++; + } + System.out.println(methods); return methods; } @@ -184,6 +193,16 @@ public abstract class SWCommand { SWCommandUtils.commandMap.register("steamwar", this.command); } + public void inject(Plugin plugin) { + new BukkitRunnable() { + @Override + public void run() { + SWCommand.this.unregister(); + SWCommand.this.register(); + } + }.runTask(plugin); + } + @Register(help = true) private void internalHelp(CommandSender sender, String... args) { if (help.isEmpty()) {