Add SWCommand.Register.description to simplify help commands
Dieser Commit ist enthalten in:
Ursprung
745ac401bb
Commit
9fe1361030
@ -250,7 +250,9 @@ public abstract class SWCommand {
|
|||||||
.anyMatch(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()));
|
.anyMatch(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()));
|
||||||
if (hasTabCompletes) {
|
if (hasTabCompletes) {
|
||||||
try {
|
try {
|
||||||
message.sendPrefixless(subCommand.description, p);
|
for (String s : subCommand.description) {
|
||||||
|
message.sendPrefixless(s, p);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
Bukkit.getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
||||||
}
|
}
|
||||||
@ -263,7 +265,9 @@ public abstract class SWCommand {
|
|||||||
commandList.forEach(subCommand -> {
|
commandList.forEach(subCommand -> {
|
||||||
if (subCommand.guardChecker == null || subCommand.guardChecker.guard(p, GuardCheckType.TAB_COMPLETE, new String[0], null) == GuardResult.ALLOWED) {
|
if (subCommand.guardChecker == null || subCommand.guardChecker.guard(p, GuardCheckType.TAB_COMPLETE, new String[0], null) == GuardResult.ALLOWED) {
|
||||||
try {
|
try {
|
||||||
message.sendPrefixless(subCommand.description, p);
|
for (String s : subCommand.description) {
|
||||||
|
message.sendPrefixless(s, p);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
Bukkit.getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
||||||
}
|
}
|
||||||
@ -280,7 +284,7 @@ public abstract class SWCommand {
|
|||||||
|
|
||||||
boolean help() default false;
|
boolean help() default false;
|
||||||
|
|
||||||
String description() default "";
|
String[] description() default {};
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.METHOD})
|
@Target({ElementType.METHOD})
|
||||||
|
@ -36,7 +36,7 @@ class SubCommand {
|
|||||||
|
|
||||||
private SWCommand swCommand;
|
private SWCommand swCommand;
|
||||||
Method method;
|
Method method;
|
||||||
String description;
|
String[] description;
|
||||||
String[] subCommand;
|
String[] subCommand;
|
||||||
TypeMapper<?>[] arguments;
|
TypeMapper<?>[] arguments;
|
||||||
GuardChecker[] guards;
|
GuardChecker[] guards;
|
||||||
@ -46,7 +46,7 @@ class SubCommand {
|
|||||||
Class<?> varArgType = null;
|
Class<?> varArgType = null;
|
||||||
private boolean help;
|
private boolean help;
|
||||||
|
|
||||||
SubCommand(SWCommand swCommand, Method method, String[] subCommand, Map<String, TypeMapper<?>> localTypeMapper, Map<String, GuardChecker> localGuardChecker, boolean help, String description) {
|
SubCommand(SWCommand swCommand, Method method, String[] subCommand, Map<String, TypeMapper<?>> localTypeMapper, Map<String, GuardChecker> localGuardChecker, boolean help, String[] description) {
|
||||||
this.swCommand = swCommand;
|
this.swCommand = swCommand;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren