improved genwebsite

This commit is contained in:
Bella 2020-04-03 10:40:03 -04:00
parent a9410d2b17
commit c7bcad87f8
No known key found for this signature in database
GPG Key ID: 815562EA23BFE344
2 changed files with 29 additions and 2 deletions

View File

@ -5,13 +5,17 @@ import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.module.Module;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import static me.zeroeightsix.kami.KamiMod.MODULE_MANAGER;
/**
* @author S-B99
* Updated by S-B99 on 18/03/20
*
* Horribly designed command for uh, generating the modules page on the website. This was the easiest way I could do it, but maybe not the most efficient.
*/
public class GenerateWebsiteCommand extends Command {
public GenerateWebsiteCommand() {
@ -25,7 +29,7 @@ public class GenerateWebsiteCommand extends Command {
@Override
public void call(String[] args) {
List<Module> mods = new ArrayList<>(MODULE_MANAGER.getModules());
List<Module> mods = MODULE_MANAGER.getModules().stream().filter(Module::isProduction).collect(Collectors.toList());
String[] modCategories = new String[]{"Chat", "Combat", "Client", "Misc", "Movement", "Player", "Render", "Utils"};
List<String> modCategoriesList = new ArrayList<>(java.util.Arrays.asList(modCategories));
@ -59,9 +63,19 @@ public class GenerateWebsiteCommand extends Command {
}
});
KamiMod.log.info("\n"
+ "---\n"
+ "layout: default\n"
+ "title: Modules\n"
+ "description: A list of modules and commands this mod has\n"
+ "---"
+ "\n## Modules (" + mods.size() + ")\n");
modCategoriesList.forEach(modCategory -> {
int totalMods;
totalMods = (int) mods.stream().filter(module -> module.getCategory().toString().equalsIgnoreCase(modCategory)).count();
KamiMod.log.info("<details>");
KamiMod.log.info(" <summary>" + modCategory + "</summary>");
KamiMod.log.info(" <summary>" + modCategory + " (" + totalMods + ")</summary>");
KamiMod.log.info(" <p><ul>");
mods.forEach(module -> {
if (module.getCategory().toString().equalsIgnoreCase(modCategory)) {
@ -73,6 +87,17 @@ public class GenerateWebsiteCommand extends Command {
});
KamiMod.log.info("\n## Commands (" + KamiMod.getInstance().getCommandManager().getCommands().size() + ")\n");
KamiMod.getInstance().getCommandManager().getCommands().stream().sorted(Comparator.comparing(Command::getLabel)).forEach(command -> {
KamiMod.log.info("<details>");
KamiMod.log.info(" <summary>" + command.getLabel() + "</summary>");
KamiMod.log.info(" <p><ul>");
KamiMod.log.info(" <li>" + command.getDescription() + "<p><i>Aliases: " + command.getAliases() + "</i></p></li>");
KamiMod.log.info(" </ul></p>");
KamiMod.log.info("</details>");
});
Command.sendChatMessage(getLabel().substring(0, 1).toUpperCase() + getLabel().substring(1) + ": Generated website to log file!");
}
}

View File

@ -139,6 +139,8 @@ public class Module {
public boolean isOnArray() { return showOnArray.getValue().equals(ShowOnArray.ON); }
public boolean isProduction() { return !category.equals(Category.EXPERIMENTAL) && !category.equals(Category.HIDDEN); }
protected void onEnable() {}
protected void onDisable() {}