Add SWCommand.methods
Dieser Commit ist enthalten in:
Ursprung
2a9636b995
Commit
e40db3d711
@ -70,7 +70,7 @@ public abstract class SWCommand {
|
|||||||
unregister();
|
unregister();
|
||||||
register();
|
register();
|
||||||
|
|
||||||
Method[] methods = getClass().getDeclaredMethods();
|
List<Method> methods = methods();
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
addMapper(Mapper.class, method, i -> i == 0, false, TypeMapper.class, (anno, typeMapper) -> {
|
addMapper(Mapper.class, method, i -> i == 0, false, TypeMapper.class, (anno, typeMapper) -> {
|
||||||
(anno.local() ? localTypeMapper : SWCommandUtils.MAPPER_FUNCTIONS).putIfAbsent(anno.value(), 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");
|
Bukkit.getLogger().log(Level.WARNING, "The method '" + method.toString() + "' is lacking the varArgs parameters of type '" + String.class.getTypeName() + "' as last Argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (method.getName().equals("internalHelp") && method.getDeclaringClass() == SWCommand.class) {
|
if (method.getName().equals("internalHelp")) {
|
||||||
|
System.out.println(method + " " + hasHelp);
|
||||||
if (hasHelp) {
|
if (hasHelp) {
|
||||||
return;
|
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() {
|
public void unregister() {
|
||||||
SWCommandUtils.knownCommandMap.remove(command.getName());
|
SWCommandUtils.knownCommandMap.remove(command.getName());
|
||||||
command.getAliases().forEach(SWCommandUtils.knownCommandMap::remove);
|
command.getAliases().forEach(SWCommandUtils.knownCommandMap::remove);
|
||||||
@ -177,7 +184,7 @@ public abstract class SWCommand {
|
|||||||
SWCommandUtils.commandMap.register("steamwar", this.command);
|
SWCommandUtils.commandMap.register("steamwar", this.command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register(help = true)
|
||||||
private void internalHelp(CommandSender sender, String... args) {
|
private void internalHelp(CommandSender sender, String... args) {
|
||||||
if (help.isEmpty()) {
|
if (help.isEmpty()) {
|
||||||
commandList.forEach(subCommand -> {
|
commandList.forEach(subCommand -> {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren