Commit 05b2dbd9 authored by Adam Gausmann's avatar Adam Gausmann

Add >plugins utility command

parent a37d81c6
Pipeline #7639359 passed with stages
in 14 seconds
package ninja.nonemu.samurai.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import ninja.nonemu.samurai.BotImpl;
import ninja.nonemu.samurai.connection.Connection;
import ninja.nonemu.samurai.connection.User;
import ninja.nonemu.samurai.connection.UserMask;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class CommandExecutorImpl {
private final BotImpl bot;
......@@ -75,6 +77,12 @@ public class CommandExecutorImpl {
"msg <target> <message>",
true
), this::handleMsg);
commandSystem.registerCommand(new CommandInfo(
"plugins",
"Returns a list of all registered plugins.",
"plugins",
false
), this::handlePlugins);
}
private boolean handleVersion(CommandSender sender, CommandInfo info, String label, String[] args) {
......@@ -263,6 +271,15 @@ public class CommandExecutorImpl {
return false;
}
private boolean handlePlugins(CommandSender sender, CommandInfo info, String label, String[] args) {
Set<String> pluginSet = bot.getPluginManager().getPlugins().keySet();
String[] pluginNames = new String[pluginSet.size()];
pluginSet.toArray(pluginNames);
sender.sendChat(String.format("Plugins (%d): %s", pluginNames.length, String.join(",", pluginNames)));
return true;
}
private Connection getConnection(String name) {
return bot.getConnectionManager().getConnection(name);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment