#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:
@@ -13,7 +13,6 @@ import tools.utils.ToolsConstants;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommandPageCreater implements AutoToolTask {
|
||||
|
||||
@@ -32,7 +31,7 @@ public class CommandPageCreater implements AutoToolTask {
|
||||
@Override
|
||||
public void executeDefault() {
|
||||
CommandInitializer commandInitializer = new CommandInitializer();
|
||||
final Set<CommandDescription> baseCommands = commandInitializer.getCommands();
|
||||
final Collection<CommandDescription> baseCommands = commandInitializer.getCommands();
|
||||
NestedTagValue commandTags = new NestedTagValue();
|
||||
addCommandsInfo(commandTags, baseCommands);
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@ import tools.utils.ToolsConstants;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Gatherer to generate up-to-date lists of the AuthMe permission nodes.
|
||||
@@ -27,6 +29,11 @@ public class PermissionNodesGatherer {
|
||||
+ "(.*?)\\s+\\*/" // Capture everything until we encounter '*/'
|
||||
+ "\\s+([A-Z_]+)\\("); // Match the enum name (e.g. 'LOGIN'), until before the first '('
|
||||
|
||||
/**
|
||||
* List of all enum classes that implement the {@link PermissionNode} interface.
|
||||
*/
|
||||
private List<Class<? extends PermissionNode>> permissionClasses;
|
||||
|
||||
/**
|
||||
* Return a sorted collection of all permission nodes, including its JavaDoc description.
|
||||
*
|
||||
@@ -39,14 +46,27 @@ public class PermissionNodesGatherer {
|
||||
result.put("authme.player.*", "Permission to use all player (non-admin) commands.");
|
||||
result.put("authme.player.email", "Grants all email permissions.");
|
||||
|
||||
new ClassCollector(ToolsConstants.MAIN_SOURCE_ROOT, "")
|
||||
.collectClasses(PermissionNode.class)
|
||||
.stream()
|
||||
.filter(Class::isEnum)
|
||||
.forEach(clz -> addDescriptionsForClass((Class<T>) clz, result));
|
||||
getPermissionClasses().forEach(clz -> addDescriptionsForClass((Class<T>) clz, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all enum classes implementing the PermissionNode interface.
|
||||
*
|
||||
* @return all permission node enums
|
||||
*/
|
||||
public List<Class<? extends PermissionNode>> getPermissionClasses() {
|
||||
if (permissionClasses == null) {
|
||||
ClassCollector classCollector = new ClassCollector(ToolsConstants.MAIN_SOURCE_ROOT, "");
|
||||
permissionClasses = classCollector
|
||||
.collectClasses(PermissionNode.class)
|
||||
.stream()
|
||||
.filter(Class::isEnum)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return permissionClasses;
|
||||
}
|
||||
|
||||
private <T extends Enum<T> & PermissionNode> void addDescriptionsForClass(Class<T> clazz,
|
||||
Map<String, String> descriptions) {
|
||||
String classSource = getSourceForClass(clazz);
|
||||
|
||||
Reference in New Issue
Block a user