feat: 为指令工具添加 sendHelp 方法
This commit is contained in:
@@ -57,8 +57,7 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
logger.info("已注册 CallbackListener.");
|
||||
Bukkit.getPluginManager().registerEvents(DebugListener.INSTANCE, this);
|
||||
logger.info("已注册 DebugListener.");
|
||||
//noinspection SpellCheckingInspection
|
||||
ParentCoreCommand.INSTANCE.hook(getCommand("hamstercore"));
|
||||
ParentCoreCommand.INSTANCE.hook(getCommand("HamsterCore"));
|
||||
ParentLoreCommand.INSTANCE.hook(getCommand("lore"));
|
||||
long time = System.currentTimeMillis() - start;
|
||||
logger.info("仓鼠核心启动完成,总计耗时 " + time + " ms.");
|
||||
|
@@ -99,6 +99,20 @@ public class ParentCommand extends ChildCommand {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void sendHelp(@NotNull CommandSender sender) {
|
||||
sender.sendMessage("§e==================== [" + name + "使用帮助] ====================");
|
||||
Map<String, String> helpMap = getCommandHelp(sender);
|
||||
int maxLength = helpMap.keySet().stream()
|
||||
.map(String::length)
|
||||
.max(Integer::compareTo)
|
||||
.orElse(-1);
|
||||
ArrayList<Map.Entry<String, String>> list = new ArrayList<>(helpMap.entrySet());
|
||||
list.sort(Map.Entry.comparingByKey());
|
||||
for (Map.Entry<String, String> entry : list) {
|
||||
sender.sendMessage(String.format("§a%-" + maxLength + "s - %s", entry.getKey(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public void hook(PluginCommand command) {
|
||||
if (command == null) {
|
||||
return;
|
||||
@@ -115,17 +129,7 @@ public class ParentCommand extends ChildCommand {
|
||||
return true;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("§e==================== [" + name + "使用帮助] ====================");
|
||||
Map<String, String> helpMap = getCommandHelp(sender);
|
||||
int maxLength = helpMap.keySet().stream()
|
||||
.map(String::length)
|
||||
.max(Integer::compareTo)
|
||||
.orElse(-1);
|
||||
ArrayList<Map.Entry<String, String>> list = new ArrayList<>(helpMap.entrySet());
|
||||
list.sort(Map.Entry.comparingByKey());
|
||||
for (Map.Entry<String, String> entry : list) {
|
||||
sender.sendMessage(String.format("§a%-" + maxLength + "s - %s", entry.getKey(), entry.getValue()));
|
||||
}
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
}
|
||||
for (ChildCommand childCommand : childCommands) {
|
||||
|
@@ -11,7 +11,7 @@ softdepend:
|
||||
- PlayerPoints
|
||||
|
||||
commands:
|
||||
hamstercore:
|
||||
HamsterCore:
|
||||
aliases: [ hcore, core ]
|
||||
description: 仓鼠核心调试指令
|
||||
permission: hamster.core.admin
|
||||
|
Reference in New Issue
Block a user