diff --git a/README.md b/README.md index 387338e..ffe88e1 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Server commands can be run in the server console or in-game. There is a dummy us /gender {male | female}. Sets the player gender. /give [item id] x[amount]. Gives the targetted player an item. /giveall {materials | avatars}. Gives the targeted player items. +/help. Displays a list of available commands. /mail [content]. Sends the targeted player a system mail. /permission {add | remove | clear} [permission]. Gives/removes a permission from the targeted player. /reload. Reloads the server config. diff --git a/src/main/java/emu/lunarcore/command/commands/HelpCommand.java b/src/main/java/emu/lunarcore/command/commands/HelpCommand.java new file mode 100644 index 0000000..9442add --- /dev/null +++ b/src/main/java/emu/lunarcore/command/commands/HelpCommand.java @@ -0,0 +1,26 @@ +package emu.lunarcore.command.commands; + +import emu.lunarcore.LunarCore; +import emu.lunarcore.command.Command; +import emu.lunarcore.command.CommandArgs; +import emu.lunarcore.command.CommandHandler; +import emu.lunarcore.game.player.Player; + +@Command(label = "help", permission = "player.help", desc = "/help. Displays a list of available commands.") +public class HelpCommand implements CommandHandler { + + @Override + public void execute(Player sender, CommandArgs args) { + StringBuilder help = new StringBuilder(); + this.sendMessage(sender, "Displaying list of commands:"); + + var labels = LunarCore.getCommandManager().getLabels().keySet().stream().sorted().toList(); + for (var label : labels) { + Command command = LunarCore.getCommandManager().getLabels().get(label).getClass().getAnnotation(Command.class); + if (command == null) continue; + + this.sendMessage(sender, command.desc()); + } + } + +}