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.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -169,8 +171,15 @@ public abstract class SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Method> methods() {
|
private List<Method> methods() {
|
||||||
List<Method> methods = Arrays.asList(getClass().getDeclaredMethods());
|
Class<?> current = getClass();
|
||||||
methods.addAll(Arrays.asList(SWCommand.class.getDeclaredMethods()));
|
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;
|
return methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +193,16 @@ public abstract class SWCommand {
|
|||||||
SWCommandUtils.commandMap.register("steamwar", this.command);
|
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)
|
@Register(help = true)
|
||||||
private void internalHelp(CommandSender sender, String... args) {
|
private void internalHelp(CommandSender sender, String... args) {
|
||||||
if (help.isEmpty()) {
|
if (help.isEmpty()) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren