SteamWar/SpigotCore
Archiviert
13
0

Add SWCommand.Register.description to simplify help commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2021-11-20 19:10:22 +01:00
Ursprung f1e5e39156
Commit 745ac401bb

Datei anzeigen

@ -47,6 +47,7 @@ public abstract class SWCommand {
@Setter @Setter
private Message message = null; private Message message = null;
private List<String> defaultHelpMessages = new ArrayList<>();
protected SWCommand(String command) { protected SWCommand(String command) {
this(command, new String[0]); this(command, new String[0]);
@ -205,6 +206,10 @@ public abstract class SWCommand {
}); });
} }
public void addDefaultHelpMessage(String message) {
defaultHelpMessages.add(message);
}
private List<Method> methods() { private List<Method> methods() {
List<Method> methods = new ArrayList<>(Arrays.asList(getClass().getDeclaredMethods())); List<Method> methods = new ArrayList<>(Arrays.asList(getClass().getDeclaredMethods()));
methods.addAll(Arrays.asList(SWCommand.class.getDeclaredMethods())); methods.addAll(Arrays.asList(SWCommand.class.getDeclaredMethods()));
@ -228,6 +233,7 @@ public abstract class SWCommand {
} }
try { try {
message.sendPrefixless("COMMAND_HELP_HEAD", p, command.getName()); message.sendPrefixless("COMMAND_HELP_HEAD", p, command.getName());
defaultHelpMessages.forEach(s -> message.sendPrefixless(s, p));
} catch (Exception e) { } catch (Exception e) {
Bukkit.getLogger().log(Level.WARNING, "Failed to send help message", e); Bukkit.getLogger().log(Level.WARNING, "Failed to send help message", e);
return; return;