mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 07:14:58 +01:00
Add a simple /help command
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user