Add a simple /help command

This commit is contained in:
Melledy 2023-11-24 20:15:46 -08:00
parent e1c203a165
commit 1e8c811895
2 changed files with 27 additions and 0 deletions

View File

@ -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.

View File

@ -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());
}
}
}