Consistently set the correct command prefix

This commit is contained in:
Aikar
2018-03-21 22:16:24 -04:00
parent 8cf361aeaf
commit 08b8ab6355
3 changed files with 11 additions and 10 deletions
@@ -81,7 +81,6 @@ public abstract class BaseCommand {
Map<String, RootCommand> registeredCommands = new HashMap<>();
String description;
String commandName;
String usageMessage;
String permission;
String conditions;
@@ -140,7 +139,6 @@ public abstract class BaseCommand {
this.commandName = cmd != null ? cmd : self.getSimpleName().toLowerCase();
this.permission = annotations.getAnnotationValue(self, CommandPermission.class, Annotations.REPLACEMENTS);
this.description = this.commandName + " commands";
this.usageMessage = "/" + this.commandName;
this.parentSubcommand = getParentSubcommand(self);
this.conditions = annotations.getAnnotationValue(self, Conditions.class, Annotations.REPLACEMENTS | Annotations.NO_EMPTY);
@@ -620,7 +618,7 @@ public abstract class BaseCommand {
public void showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd) {
issuer.sendMessage(MessageType.SYNTAX, MessageKeys.INVALID_SYNTAX,
"{command}", "/" + cmd.command,
"{command}", manager.getCommandPrefix(issuer) + cmd.command,
"{syntax}", cmd.syntaxText
);
}
@@ -23,9 +23,7 @@
package co.aikar.commands;
import co.aikar.locales.MessageKeyProvider;
import com.google.common.collect.SetMultimap;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Comparator;
@@ -41,6 +39,7 @@ public class CommandHelp {
private final CommandIssuer issuer;
private final List<HelpEntry> helpEntries = new ArrayList<>();
private final String commandName;
final String commandPrefix;
private int page;
private int perPage;
private List<String> search;
@@ -50,7 +49,9 @@ public class CommandHelp {
this.manager = manager;
this.issuer = issuer;
this.perPage = manager.defaultHelpPerPage;
this.commandName = manager.getCommandPrefix(issuer) + rootCommand.getCommandName();
this.commandPrefix = manager.getCommandPrefix(issuer);
this.commandName = this.commandPrefix + rootCommand.getCommandName();
SetMultimap<String, RegisteredCommand> subCommands = rootCommand.getSubCommands();
Set<RegisteredCommand> seen = new HashSet<>();
@@ -62,7 +63,7 @@ public class CommandHelp {
RegisteredCommand regCommand = e.getValue();
if (regCommand.hasPermission(issuer) && !seen.contains(regCommand)) {
this.helpEntries.add(new HelpEntry(regCommand));
this.helpEntries.add(new HelpEntry(this, regCommand));
seen.add(regCommand);
}
});
@@ -25,10 +25,12 @@ package co.aikar.commands;
public class HelpEntry {
private final CommandHelp commandHelp;
private final RegisteredCommand command;
private int searchScore = 1;
HelpEntry(RegisteredCommand command) {
HelpEntry(CommandHelp commandHelp, RegisteredCommand command) {
this.commandHelp = commandHelp;
this.command = command;
}
@@ -36,8 +38,8 @@ public class HelpEntry {
return this.command;
}
public String getCommand(){
return "/" + this.command.command;
public String getCommand() {
return this.commandHelp.commandPrefix + this.command.command;
}
public String getParameterSyntax(){