feat: 增强部分API
This commit is contained in:
@@ -94,7 +94,7 @@ public abstract class ParentCommand extends ChildCommand {
|
||||
|
||||
@NotNull
|
||||
public Map<String, String> getCommandHelp(CommandSender sender) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
for (ChildCommand child : childCommands) {
|
||||
if (!child.hasPermission(sender)) {
|
||||
continue;
|
||||
@@ -111,14 +111,12 @@ public abstract class ParentCommand extends ChildCommand {
|
||||
|
||||
public void sendHelp(@NotNull CommandSender sender) {
|
||||
sender.sendMessage("§e==================== [ " + getName() + " 使用帮助] ====================");
|
||||
Map<String, String> helpMap = getCommandHelp(sender);
|
||||
int maxLength = helpMap.keySet().stream()
|
||||
Map<String, String> map = getCommandHelp(sender);
|
||||
int maxLength = map.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) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
sender.sendMessage(String.format("§a%-" + maxLength + "s - %s", entry.getKey(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user