use of io.github.nucleuspowered.nucleus.internal.docgen.PermissionDoc in project Nucleus by NucleusPowered.
the class DocGenCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.nucleus.docgen.start"));
DocGenCache genCache = plugin.getDocGenCache().get();
// Generate command file.
YAMLConfigurationLoader configurationLoader = YAMLConfigurationLoader.builder().setPath(plugin.getDataPath().resolve("commands.yml")).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
List<CommandDoc> lcd = getAndSort(genCache.getCommandDocs(), (first, second) -> {
int m = first.getModule().compareToIgnoreCase(second.getModule());
if (m == 0) {
return first.getCommandName().compareToIgnoreCase(second.getCommandName());
}
return m;
});
ConfigurationNode commandConfigurationNode = SimpleConfigurationNode.root().setValue(ttlcd, lcd);
configurationLoader.save(commandConfigurationNode);
// Markdown
new MarkdownGenerator.CommandMarkdownGenerator().create(plugin.getDataPath().resolve("commands.md"), lcd);
// Generate permission file.
YAMLConfigurationLoader permissionsConfigurationLoader = YAMLConfigurationLoader.builder().setPath(plugin.getDataPath().resolve("permissions.yml")).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
List<PermissionDoc> lpd = getAndSort(Lists.newArrayList(genCache.getPermissionDocs()), (first, second) -> {
int m = first.getModule().compareToIgnoreCase(second.getModule());
if (m == 0) {
return first.getPermission().compareToIgnoreCase(second.getPermission());
}
return m;
});
ConfigurationNode permissionConfigurationNode = SimpleConfigurationNode.root().setValue(ttlpd, lpd.stream().filter(PermissionDoc::isNormal).collect(Collectors.toList()));
permissionsConfigurationLoader.save(permissionConfigurationNode);
// Markdown
new MarkdownGenerator.PermissionMarkdownGenerator().create(plugin.getDataPath().resolve("permissions.md"), lpd.stream().filter(PermissionDoc::isOre).collect(Collectors.toList()));
YAMLConfigurationLoader tokenConfigurationLoader = YAMLConfigurationLoader.builder().setPath(plugin.getDataPath().resolve("tokens.yml")).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
ConfigurationNode tokenConfigurationNode = SimpleConfigurationNode.root().setValue(ttltd, getAndSort(genCache.getTokenDocs(), Comparator.comparing(TokenDoc::getName)));
tokenConfigurationLoader.save(tokenConfigurationNode);
YAMLConfigurationLoader essentialsConfigurationLoader = YAMLConfigurationLoader.builder().setPath(plugin.getDataPath().resolve("ess.yml")).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
ConfigurationNode essentialsConfigurationNode = SimpleConfigurationNode.root().setValue(tted, getAndSort(genCache.getEssentialsDocs(), Comparator.comparing(x -> x.getEssentialsCommands().get(0))));
essentialsConfigurationLoader.save(essentialsConfigurationNode);
YAMLConfigurationLoader configurationConfigurationLoader = YAMLConfigurationLoader.builder().setPath(plugin.getDataPath().resolve("conf.yml")).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
ConfigurationNode configurationConfigurationNode = SimpleConfigurationNode.root().setValue(genCache.getConfigDocs());
configurationConfigurationLoader.save(configurationConfigurationNode);
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.nucleus.docgen.complete"));
return CommandResult.success();
}
Aggregations