mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-21 06:11:32 +01:00
Finalization for #305 - command refactor
This commit is contained in:
parent
3cc35baa5e
commit
efa458cae1
@ -146,16 +146,15 @@ public class CommandDescription {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of parents that precede the command description.
|
||||
* Return the number of labels necessary to get to this command. This corresponds to the number of parents + 1.
|
||||
*
|
||||
* @return The number of parents, e.g. for "/authme abc def" the parent count is 2 ("/authme abc", "/authme")
|
||||
* @return The number of labels, e.g. for "/authme abc def" the label count is 3
|
||||
*/
|
||||
// TODO ljacqu 20151217: If we always use `getParentCount() + 1` rewrite this method to a `getLabelCount()`
|
||||
public int getParentCount() {
|
||||
public int getLabelCount() {
|
||||
if (parent == null) {
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
return parent.getParentCount() + 1;
|
||||
return parent.getLabelCount() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,7 +125,7 @@ public class CommandHandler {
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Unknown command!");
|
||||
|
||||
// Show a command suggestion if available and the difference isn't too big
|
||||
if (result.getDifference() < SUGGEST_COMMAND_THRESHOLD && result.getCommandDescription() != null) {
|
||||
if (result.getDifference() <= SUGGEST_COMMAND_THRESHOLD && result.getCommandDescription() != null) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Did you mean " + ChatColor.GOLD
|
||||
+ CommandUtils.constructCommandPath(result.getCommandDescription()) + ChatColor.YELLOW + "?");
|
||||
}
|
||||
@ -215,7 +215,7 @@ public class CommandHandler {
|
||||
|
||||
FoundResultStatus status = (minDifference == 0.0) ? INCORRECT_ARGUMENTS : UNKNOWN_LABEL;
|
||||
final int partsSize = parts.size();
|
||||
List<String> labels = parts.subList(0, Math.min(closestCommand.getParentCount() + 1, partsSize));
|
||||
List<String> labels = parts.subList(0, Math.min(closestCommand.getLabelCount(), partsSize));
|
||||
List<String> arguments = (labels.size() == partsSize)
|
||||
? new ArrayList<String>()
|
||||
: parts.subList(labels.size(), partsSize);
|
||||
|
@ -34,7 +34,6 @@ import fr.xephi.authme.command.executable.register.RegisterCommand;
|
||||
import fr.xephi.authme.command.executable.unregister.UnregisterCommand;
|
||||
import fr.xephi.authme.permission.AdminPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -56,7 +55,6 @@ public final class CommandInitializer {
|
||||
|
||||
public static Set<CommandDescription> getBaseCommands() {
|
||||
if (baseCommands == null) {
|
||||
Wrapper.getInstance().getLogger().info("Initializing AuthMe commands");
|
||||
initializeCommands();
|
||||
}
|
||||
return baseCommands;
|
||||
@ -287,8 +285,8 @@ public final class CommandInitializer {
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("version", "ver", "v", "about", "info")
|
||||
.description("Version info")
|
||||
.detailedDescription("Show detailed information about the installed AuthMeReloaded version, and shows the "
|
||||
+ "developers, contributors, license and other information.")
|
||||
.detailedDescription("Show detailed information about the installed AuthMeReloaded version, the "
|
||||
+ "developers, contributors, and license.")
|
||||
.executableCommand(new VersionCommand())
|
||||
.build();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user