From 745ac401bb5eaf298ff19eaf5aefb36f436e05e0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 20 Nov 2021 19:10:22 +0100 Subject: [PATCH] Add SWCommand.Register.description to simplify help commands --- SpigotCore_Main/src/de/steamwar/command/SWCommand.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index f04cf62..4125bb7 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -47,6 +47,7 @@ public abstract class SWCommand { @Setter private Message message = null; + private List defaultHelpMessages = new ArrayList<>(); protected SWCommand(String command) { this(command, new String[0]); @@ -205,6 +206,10 @@ public abstract class SWCommand { }); } + public void addDefaultHelpMessage(String message) { + defaultHelpMessages.add(message); + } + private List methods() { List methods = new ArrayList<>(Arrays.asList(getClass().getDeclaredMethods())); methods.addAll(Arrays.asList(SWCommand.class.getDeclaredMethods())); @@ -228,6 +233,7 @@ public abstract class SWCommand { } try { message.sendPrefixless("COMMAND_HELP_HEAD", p, command.getName()); + defaultHelpMessages.forEach(s -> message.sendPrefixless(s, p)); } catch (Exception e) { Bukkit.getLogger().log(Level.WARNING, "Failed to send help message", e); return;