mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-09 05:43:01 +08:00
Fix HelpCommand missing aliases
This commit is contained in:
parent
466488ca7a
commit
dd10dcc09b
@ -83,7 +83,7 @@ public final class CommandMap {
|
|||||||
return new LinkedList<>(this.annotations.values());
|
return new LinkedList<>(this.annotations.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Command> getAnnotations() {
|
public Map<String, Command> getAnnotations() {
|
||||||
return new LinkedHashMap<>(this.annotations);
|
return new LinkedHashMap<>(this.annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +96,8 @@ public final class CommandMap {
|
|||||||
return new LinkedList<>(this.commands.values());
|
return new LinkedList<>(this.commands.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, CommandHandler> getHandlers() {
|
public Map<String, CommandHandler> getHandlers() {
|
||||||
return new LinkedHashMap<>(this.commands);
|
return this.commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,25 +46,25 @@ public final class HelpCommand implements CommandHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(Player player, Player targetPlayer, List<String> args) {
|
public void execute(Player player, Player targetPlayer, List<String> args) {
|
||||||
Account account = (player == null) ? null : player.getAccount();
|
Account account = (player == null) ? null : player.getAccount();
|
||||||
Map<String, CommandHandler> handlers = CommandMap.getInstance().getHandlers();
|
var commandMap = CommandMap.getInstance();
|
||||||
List<String> commands = new ArrayList<>();
|
List<String> commands = new ArrayList<>();
|
||||||
List<String> commands_no_permission = new ArrayList<>();
|
List<String> commands_no_permission = new ArrayList<>();
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
for (String key : handlers.keySet()) {
|
commandMap.getHandlers().forEach((key, command) -> {
|
||||||
CommandHandler command = handlers.get(key);
|
|
||||||
Command annotation = command.getClass().getAnnotation(Command.class);
|
Command annotation = command.getClass().getAnnotation(Command.class);
|
||||||
if (player == null || account.hasPermission(annotation.permission())) {
|
if (player == null || account.hasPermission(annotation.permission())) {
|
||||||
commands.add(createCommand(player, command, args));
|
commands.add(createCommand(player, command, args));
|
||||||
} else if (SHOW_COMMANDS_WITHOUT_PERMISSIONS) {
|
} else if (SHOW_COMMANDS_WITHOUT_PERMISSIONS) {
|
||||||
commands_no_permission.add(createCommand(player, command, args));
|
commands_no_permission.add(createCommand(player, command, args));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
CommandHandler.sendTranslatedMessage(player, "commands.help.available_commands");
|
CommandHandler.sendTranslatedMessage(player, "commands.help.available_commands");
|
||||||
} else {
|
} else {
|
||||||
String command_str = args.remove(0).toLowerCase();
|
String command_str = args.remove(0).toLowerCase();
|
||||||
CommandHandler command = handlers.get(command_str);
|
CommandHandler command = commandMap.getHandler(command_str);
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
CommandHandler.sendTranslatedMessage(player, "commands.generic.command_exist_error");
|
CommandHandler.sendTranslatedMessage(player, "commands.generic.command_exist_error");
|
||||||
|
CommandHandler.sendMessage(player, "Command: " + command_str);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Command annotation = command.getClass().getAnnotation(Command.class);
|
Command annotation = command.getClass().getAnnotation(Command.class);
|
||||||
@ -75,9 +75,8 @@ public final class HelpCommand implements CommandHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String s : commands)
|
final String suf = "\n\t" + translate(player, "commands.help.warn_player_has_no_permission");
|
||||||
CommandHandler.sendMessage(player, s);
|
commands.forEach(s -> CommandHandler.sendMessage(player, s));
|
||||||
for (String s : commands_no_permission)
|
commands_no_permission.forEach(s -> CommandHandler.sendMessage(player, s + suf));
|
||||||
CommandHandler.sendMessage(player, s + "\n\t" + translate(player, "commands.help.warn_player_has_no_permission"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user