#963 Create tool task to generate plugin.yml
- Create task that generates commands/permissions section of plugin.yml - Change CommandInitializer to return a List instead of Set (preserve insertion order) - Merge CommandSyntaxHelper into CommandUtils
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
package fr.xephi.authme.command.help;
|
||||
|
||||
import fr.xephi.authme.command.CommandArgumentDescription;
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper class for displaying the syntax of a command properly to a user.
|
||||
*/
|
||||
final class CommandSyntaxHelper {
|
||||
|
||||
private CommandSyntaxHelper() {
|
||||
}
|
||||
|
||||
public static String getSyntax(CommandDescription command, List<String> correctLabels) {
|
||||
String commandSyntax = ChatColor.WHITE + "/" + correctLabels.get(0) + ChatColor.YELLOW;
|
||||
for (int i = 1; i < correctLabels.size(); ++i) {
|
||||
commandSyntax += " " + correctLabels.get(i);
|
||||
}
|
||||
for (CommandArgumentDescription argument : command.getArguments()) {
|
||||
commandSyntax += " " + formatArgument(argument);
|
||||
}
|
||||
return commandSyntax;
|
||||
}
|
||||
|
||||
/** Format a command argument with the proper type of brackets. */
|
||||
private static String formatArgument(CommandArgumentDescription argument) {
|
||||
if (argument.isOptional()) {
|
||||
return "[" + argument.getName() + "]";
|
||||
}
|
||||
return "<" + argument.getName() + ">";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class HelpProvider implements Reloadable {
|
||||
|
||||
if (hasFlag(SHOW_COMMAND, options)) {
|
||||
lines.add(ChatColor.GOLD + helpMessagesService.getMessage(HelpSection.COMMAND) + ": "
|
||||
+ CommandSyntaxHelper.getSyntax(command, correctLabels));
|
||||
+ CommandUtils.buildSyntax(command, correctLabels));
|
||||
}
|
||||
if (hasFlag(SHOW_DESCRIPTION, options)) {
|
||||
lines.add(ChatColor.GOLD + helpMessagesService.getMessage(SHORT_DESCRIPTION) + ": "
|
||||
@@ -194,7 +194,7 @@ public class HelpProvider implements Reloadable {
|
||||
// Create a list of alternatives
|
||||
for (String label : command.getLabels()) {
|
||||
if (!label.equalsIgnoreCase(usedLabel)) {
|
||||
lines.add(" " + CommandSyntaxHelper.getSyntax(command, commandLabelsFn.apply(label)));
|
||||
lines.add(" " + CommandUtils.buildSyntax(command, commandLabelsFn.apply(label)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user