From b34598bd80a775efecd1c4c5245711d8efa4eff8 Mon Sep 17 00:00:00 2001 From: Bella Date: Fri, 7 Feb 2020 15:30:06 -0500 Subject: [PATCH] add enabled command --- .../kami/command/commands/EnabledCommand.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/me/zeroeightsix/kami/command/commands/EnabledCommand.java diff --git a/src/main/java/me/zeroeightsix/kami/command/commands/EnabledCommand.java b/src/main/java/me/zeroeightsix/kami/command/commands/EnabledCommand.java new file mode 100644 index 00000000..f140de58 --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/command/commands/EnabledCommand.java @@ -0,0 +1,36 @@ +package me.zeroeightsix.kami.command.commands; + +import me.zeroeightsix.kami.command.Command; +import me.zeroeightsix.kami.module.Module; +import me.zeroeightsix.kami.module.ModuleManager; + +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +/** + * @author S-B99 + * Updated by S-B99 on 07/02/20 + */ +public class EnabledCommand extends Command { + public EnabledCommand() { + super("enabledlist", null, "enabled"); + setDescription("Prints Enabled Modules"); + } + + @Override + public void call(String[] args) { + AtomicReference enabled = new AtomicReference<>(""); + List mods = ModuleManager.getModules().stream() + .filter(Module::isEnabled) + .collect(Collectors.toList()); + + mods.forEach(module -> { + if (module.isEnabled()) { + enabled.set(String.join(", ", module.getName())); + } + }); + Command.sendChatMessage("Enabled modules: \n" + enabled); + } + +}