summaryrefslogtreecommitdiff
path: root/src/main/java/lh/lockhead/skynet/chat/commandhandling/ListHeuristics.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/lh/lockhead/skynet/chat/commandhandling/ListHeuristics.java')
-rwxr-xr-xsrc/main/java/lh/lockhead/skynet/chat/commandhandling/ListHeuristics.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/lh/lockhead/skynet/chat/commandhandling/ListHeuristics.java b/src/main/java/lh/lockhead/skynet/chat/commandhandling/ListHeuristics.java
new file mode 100755
index 0000000..d4969ed
--- /dev/null
+++ b/src/main/java/lh/lockhead/skynet/chat/commandhandling/ListHeuristics.java
@@ -0,0 +1,56 @@
+package lh.lockhead.skynet.chat.commandhandling;
+
+import lh.lockhead.skynet.Skynet;
+import lh.lockhead.skynet.chat.Message;
+import lh.lockhead.skynet.chat.chatformat.HoverText;
+import lh.lockhead.skynet.configuration.Settings;
+import nl.lockhead.lpf.plugins.plugin.PluginConfig;
+import nl.lockhead.lpf.plugins.plugin.PluginContainer;
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+
+public class ListHeuristics extends Command {
+
+ public ListHeuristics() {
+ labels = new String[] {"list", "listheurs", "listheuristics"};
+ description = "Display the list of currently loaded heuristics, with additional information.";
+ adminOnly = false;
+ allowConsole = true;
+ }
+
+ @Override
+ public void dispatch(CommandSender sender, List<String> args) {
+ CommandHandler c = CommandHandler.get();
+ if (sender instanceof ConsoleCommandSender) {
+ c.sendConsoleMessage("List", "Currently loaded heuristics (" +
+ Skynet.getPluginManager().getPlugins().size() + "):");
+ for (PluginContainer heuristic : Skynet.getPluginManager().getPlugins()) {
+ PluginConfig pc = heuristic.getPlugin().getConfig();
+ c.sendConsoleMessage("List", " " + (heuristic.getPlugin().isEnabled() ? "(enabled) " : "(disabled) ") + pc.getName() + " v" + pc.getVersion().toString() + ": " + pc.getMetadataMap().get("description"));
+ }
+ }
+ else {
+ Player player = (Player) sender;
+ Message m = new Message("List");
+ m.add("Currently loaded heuristics (" +
+ Settings.COLOR_SECONDARY + Skynet.getPluginManager().getPlugins().size() + Settings.COLOR_DEFAULT + "):");
+ for (PluginContainer heuristic : Skynet.getPluginManager().getPlugins()) {
+ PluginConfig pc = heuristic.getPlugin().getConfig();
+ boolean p = (boolean) heuristic.getPlugin().getConfig().getMetadataMap().getOrDefault("premium", false);
+ String h = (p ? Skynet.p.toString() : "") +
+ (heuristic.getPlugin().isEnabled() ?
+ Settings.COLOR_SECONDARY : ChatColor.DARK_GRAY) +
+ pc.getName() + Settings.COLOR_DEFAULT + " v" + pc.getVersion().toString() +
+ " by " + pc.getAuthor() + "\n" + pc.getMetadataMap().get("description");
+ m.add(new HoverText((heuristic.getPlugin().isEnabled() ? Settings.COLOR_SECONDARY : ChatColor.DARK_GRAY) + " " + pc.getName(), h));
+ }
+ m.add("Hover over the heuristics for more information.");
+ c.sendMessage(player, m);
+ }
+ }
+
+}