From c7bcad87f87d8fb726c87a9b402931a97b7e72ad Mon Sep 17 00:00:00 2001 From: Bella Date: Fri, 3 Apr 2020 10:40:03 -0400 Subject: [PATCH] improved genwebsite --- .../commands/GenerateWebsiteCommand.java | 29 +++++++++++++++++-- .../me/zeroeightsix/kami/module/Module.java | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java b/src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java index 63faac353..45c0197ad 100644 --- a/src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java +++ b/src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java @@ -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 mods = new ArrayList<>(MODULE_MANAGER.getModules()); + List mods = MODULE_MANAGER.getModules().stream().filter(Module::isProduction).collect(Collectors.toList()); String[] modCategories = new String[]{"Chat", "Combat", "Client", "Misc", "Movement", "Player", "Render", "Utils"}; List 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("
"); - KamiMod.log.info(" " + modCategory + ""); + KamiMod.log.info(" " + modCategory + " (" + totalMods + ")"); KamiMod.log.info("

    "); 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("
    "); + KamiMod.log.info(" " + command.getLabel() + ""); + KamiMod.log.info("

      "); + KamiMod.log.info("
    • " + command.getDescription() + "

      Aliases: " + command.getAliases() + "

    • "); + KamiMod.log.info("

    "); + KamiMod.log.info("
    "); + }); + Command.sendChatMessage(getLabel().substring(0, 1).toUpperCase() + getLabel().substring(1) + ": Generated website to log file!"); } } diff --git a/src/main/java/me/zeroeightsix/kami/module/Module.java b/src/main/java/me/zeroeightsix/kami/module/Module.java index 59aeafbc0..f153d1b22 100644 --- a/src/main/java/me/zeroeightsix/kami/module/Module.java +++ b/src/main/java/me/zeroeightsix/kami/module/Module.java @@ -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() {}