Slim down CommandParts API
- Remove all methods that aren't constructors / fancy get() on list; almost possible to remove class entirely
This commit is contained in:
@@ -3,9 +3,11 @@ package fr.xephi.authme.command.help;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.CommandUtils;
|
||||
import fr.xephi.authme.command.FoundCommandResult;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import fr.xephi.authme.util.CollectionUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -86,13 +88,14 @@ public class HelpProvider {
|
||||
// Show the unknown command warning
|
||||
sender.sendMessage(ChatColor.DARK_RED + "No help found for '" + helpQuery + "'!");
|
||||
|
||||
// Get the suggested command
|
||||
CommandParts suggestedCommandParts = new CommandParts(result.getCommandDescription().getCommandReference(commandReference).getRange(1));
|
||||
|
||||
// Show a command suggestion if available and the difference isn't too big
|
||||
if (commandDifference < 0.75)
|
||||
if (result.getCommandDescription() != null)
|
||||
sender.sendMessage(ChatColor.YELLOW + "Did you mean " + ChatColor.GOLD + "/" + baseCommand + " help " + suggestedCommandParts + ChatColor.YELLOW + "?");
|
||||
if (commandDifference < 0.75 && result.getCommandDescription() != null) {
|
||||
// Get the suggested command
|
||||
List<String> suggestedCommandParts = CollectionUtils.getRange(
|
||||
result.getCommandDescription().getCommandReference(commandReference).getList(), 1);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Did you mean " + ChatColor.GOLD + "/" + baseCommand
|
||||
+ " help " + CommandUtils.labelsToString(suggestedCommandParts) + ChatColor.YELLOW + "?");
|
||||
}
|
||||
|
||||
// Show the help command
|
||||
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + baseCommand + " help" + ChatColor.YELLOW + " to view help.");
|
||||
@@ -102,10 +105,12 @@ public class HelpProvider {
|
||||
// Show a message when the command handler is assuming a command
|
||||
if (commandDifference > 0) {
|
||||
// Get the suggested command
|
||||
CommandParts suggestedCommandParts = new CommandParts(result.getCommandDescription().getCommandReference(commandReference).getRange(1));
|
||||
List<String> suggestedCommandParts = CollectionUtils.getRange(
|
||||
result.getCommandDescription().getCommandReference(commandReference).getList(), 1);
|
||||
|
||||
// Show the suggested command
|
||||
sender.sendMessage(ChatColor.DARK_RED + "No help found, assuming '" + ChatColor.GOLD + suggestedCommandParts + ChatColor.DARK_RED + "'!");
|
||||
sender.sendMessage(ChatColor.DARK_RED + "No help found, assuming '" + ChatColor.GOLD
|
||||
+ CommandUtils.labelsToString(suggestedCommandParts) + ChatColor.DARK_RED + "'!");
|
||||
}
|
||||
|
||||
// Print the help header
|
||||
|
||||
@@ -3,6 +3,8 @@ package fr.xephi.authme.command.help;
|
||||
import fr.xephi.authme.command.CommandArgumentDescription;
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.CommandUtils;
|
||||
import fr.xephi.authme.util.CollectionUtils;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -35,8 +37,8 @@ public final class HelpSyntaxHelper {
|
||||
|
||||
// Get the help command reference, and the command label
|
||||
CommandParts helpCommandReference = commandDescription.getCommandReference(commandReference);
|
||||
final String parentCommand = new CommandParts(
|
||||
helpCommandReference.getRange(0, helpCommandReference.getCount() - 1)).toString();
|
||||
final String parentCommand = CommandUtils.labelsToString(
|
||||
CollectionUtils.getRange(helpCommandReference.getList(), 0, helpCommandReference.getCount() - 1));
|
||||
|
||||
// Check whether the alternative label should be used
|
||||
String commandLabel;
|
||||
|
||||
Reference in New Issue
Block a user