From 207738c1d82828e59145bd65ca0894e44967a996 Mon Sep 17 00:00:00 2001 From: Bella Date: Tue, 17 Mar 2020 11:32:33 -0400 Subject: [PATCH] added genwebsite command --- .../commands/GenerateWebsiteCommand.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java diff --git a/src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java b/src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java new file mode 100644 index 00000000..0558d656 --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/command/commands/GenerateWebsiteCommand.java @@ -0,0 +1,74 @@ +package me.zeroeightsix.kami.command.commands; + +import me.zeroeightsix.kami.KamiMod; +import me.zeroeightsix.kami.command.Command; +import me.zeroeightsix.kami.module.Module; +import me.zeroeightsix.kami.module.ModuleManager; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author S-B99 + * Updated by S-B99 on 18/03/20 + */ +public class GenerateWebsiteCommand extends Command { + public GenerateWebsiteCommand() { + super("genwebsite", null); + setDescription("Generates the module page for the website"); + } + + private static String nameAndDescription(Module module) { + return "
  • " + module.getName() + "

    " + module.getDescription() + "

  • "; + } + + @Override + public void call(String[] args) { + List mods = new ArrayList<>(ModuleManager.getModules()); + String[] modCategories = new String[]{"Chat", "Combat", "Gui", "Misc", "Movement", "Player", "Render"}; + List modCategoriesList = new ArrayList<>(java.util.Arrays.asList(modCategories)); + + List modsChat = new ArrayList<>(); + List modsCombat = new ArrayList<>(); + List modsGui = new ArrayList<>(); + List modsMisc = new ArrayList<>(); + List modsMovement = new ArrayList<>(); + List modsPlayer = new ArrayList<>(); + List modsRender = new ArrayList<>(); + + mods.forEach(module -> { + switch (module.getCategory()) { + case CHAT: + modsChat.add(nameAndDescription(module)); + case COMBAT: + modsCombat.add(nameAndDescription(module)); + case GUI: + modsGui.add(nameAndDescription(module)); + case MISC: + modsMisc.add(nameAndDescription(module)); + case MOVEMENT: + modsMovement.add(nameAndDescription(module)); + case PLAYER: + modsPlayer.add(nameAndDescription(module)); + case RENDER: + modsRender.add(nameAndDescription(module)); + } + }); + + modCategoriesList.forEach(modCategory -> { + KamiMod.log.info("
    "); + KamiMod.log.info(" " + modCategory + ""); + KamiMod.log.info("

      "); + mods.forEach(module -> { + if (module.getCategory().toString().equalsIgnoreCase(modCategory)) { + KamiMod.log.info("
    • " + module.getName() + "

      " + module.getDescription() + "

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

    "); // cat#$*UWUnuzzl3s70U + KamiMod.log.info("
    "); + + }); + + Command.sendChatMessage(getLabel().substring(0, 1).toUpperCase() + getLabel().substring(1) + ": Generated website to log file!"); + } +}