Add SWCommand.inject
Dieser Commit ist enthalten in:
Ursprung
e40db3d711
Commit
8985393fe1
@ -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<Method> methods() {
|
||||
List<Method> methods = Arrays.asList(getClass().getDeclaredMethods());
|
||||
methods.addAll(Arrays.asList(SWCommand.class.getDeclaredMethods()));
|
||||
Class<?> current = getClass();
|
||||
List<Method> 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()) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren