diff --git a/src/main/java/fr/xephi/authme/command/CommandDescription.java b/src/main/java/fr/xephi/authme/command/CommandDescription.java index 01034a2d..018ac79b 100644 --- a/src/main/java/fr/xephi/authme/command/CommandDescription.java +++ b/src/main/java/fr/xephi/authme/command/CommandDescription.java @@ -1,10 +1,11 @@ package fr.xephi.authme.command; -import com.timvisee.dungeonmaze.util.StringUtils; +import fr.xephi.authme.util.StringUtils; import org.bukkit.command.CommandSender; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; @SuppressWarnings("UnusedDeclaration") @@ -21,7 +22,7 @@ public class CommandDescription { /** The parent command. */ private CommandDescription parent = null; /** The child labels. */ - private List childs = new ArrayList<>(); + private List children = new ArrayList<>(); /** The command arguments. */ private List arguments = new ArrayList<>(); /** Defines whether there is an argument maximum or not. */ @@ -487,12 +488,12 @@ public class CommandDescription { } /** - * Get all command childs. + * Get all command children. * - * @return Command childs. + * @return Command children. */ - public List getChilds() { - return this.childs; + public List getChildren() { + return this.children; } /** @@ -514,7 +515,7 @@ public class CommandDescription { return true; // The command description to add as a child - if(!this.childs.add(commandDescription)) + if(!this.children.add(commandDescription)) return false; // Set this description as parent on the child @@ -522,17 +523,17 @@ public class CommandDescription { } /** - * Set the childs of this command. + * Set the children of this command. * - * @param childs New command childs. Null to remove all childs. + * @param children New command children. Null to remove all children. */ - public void setChilds(List childs) { - // Check whether the childs list should be cleared - if(childs == null) - this.childs.clear(); + public void setChildren(List children) { + // Check whether the children list should be cleared + if(children == null) + this.children.clear(); else - this.childs = childs; + this.children = children; } /** @@ -541,7 +542,7 @@ public class CommandDescription { * @return True if this command has any child labels. */ public boolean hasChilds() { - return (this.childs.size() != 0); + return (this.children.size() != 0); } /** @@ -559,7 +560,7 @@ public class CommandDescription { return false; // Check whether this child exists, return the result - return this.childs.contains(commandDescription); + return this.children.contains(commandDescription); } /** @@ -765,15 +766,20 @@ public class CommandDescription { CommandParts newArguments = new CommandParts(queryReference.getRange(getParentCount() + 1)); // Handle the child's, if this command has any - if(getChilds().size() > 0) { + if(getChildren().size() > 0) { // Get a new instance of the child's list, and sort them by their difference in comparison to the query reference - List commandChilds = new ArrayList<>(getChilds()); - Collections.sort(commandChilds, (o1, o2) -> Double.compare( - o1.getCommandDifference(queryReference), - o2.getCommandDifference(queryReference))); + List commandChildren = new ArrayList<>(getChildren()); + Collections.sort(commandChildren, new Comparator() { + @Override + public int compare(CommandDescription o1, CommandDescription o2) { + return Double.compare( + o1.getCommandDifference(queryReference), + o2.getCommandDifference(queryReference)); + } + }); // Get the difference of the first child in the list - double firstChildDifference = commandChilds.get(0).getCommandDifference(queryReference, true); + double firstChildDifference = commandChildren.get(0).getCommandDifference(queryReference, true); // Check if the reference perfectly suits the arguments of the current command if it doesn't perfectly suits a child command if(firstChildDifference > 0.0) @@ -781,7 +787,7 @@ public class CommandDescription { return new FoundCommandResult(this, newReference, newArguments, queryReference); // Loop through each child - for(CommandDescription child : commandChilds) { + for(CommandDescription child : commandChildren) { // Get the best suitable command FoundCommandResult result = child.findCommand(queryReference); if(result != null) diff --git a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java index 18ec476e..17aeb163 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java @@ -182,14 +182,14 @@ public class HelpPrinter { */ public static void printChildren(CommandSender sender, CommandDescription command, CommandParts commandReference) { // Make sure there are child's - if(command.getChilds().size() <= 0) + if(command.getChildren().size() <= 0) return; // Print the header sender.sendMessage(ChatColor.GOLD + "Commands:"); // Loop through each child - for(CommandDescription child : command.getChilds()) + for(CommandDescription child : command.getChildren()) sender.sendMessage(" " + HelpSyntaxHelper.getCommandSyntax(child, commandReference, null, false) + ChatColor.GRAY + ChatColor.ITALIC + " : " + child.getDescription()); } }