From cd80dfbde37fdb4671734f3357fb4b6f73faca2c Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 24 May 2024 02:01:20 -0500 Subject: [PATCH] Add database and redis info to /pyspigot info command --- .../command/subcommands/InfoCommand.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/dev/magicmq/pyspigot/command/subcommands/InfoCommand.java b/src/main/java/dev/magicmq/pyspigot/command/subcommands/InfoCommand.java index 7cdefa1..aedc7c2 100644 --- a/src/main/java/dev/magicmq/pyspigot/command/subcommands/InfoCommand.java +++ b/src/main/java/dev/magicmq/pyspigot/command/subcommands/InfoCommand.java @@ -20,12 +20,16 @@ import dev.magicmq.pyspigot.command.SubCommandMeta; import dev.magicmq.pyspigot.manager.command.CommandManager; import dev.magicmq.pyspigot.manager.command.ScriptCommand; +import dev.magicmq.pyspigot.manager.database.Database; +import dev.magicmq.pyspigot.manager.database.DatabaseManager; import dev.magicmq.pyspigot.manager.listener.ListenerManager; import dev.magicmq.pyspigot.manager.listener.ScriptEventListener; import dev.magicmq.pyspigot.manager.placeholder.PlaceholderManager; import dev.magicmq.pyspigot.manager.placeholder.ScriptPlaceholder; import dev.magicmq.pyspigot.manager.protocol.ProtocolManager; import dev.magicmq.pyspigot.manager.protocol.ScriptPacketListener; +import dev.magicmq.pyspigot.manager.redis.RedisManager; +import dev.magicmq.pyspigot.manager.redis.ScriptRedisClient; import dev.magicmq.pyspigot.manager.script.Script; import dev.magicmq.pyspigot.manager.script.ScriptManager; import dev.magicmq.pyspigot.manager.task.Task; @@ -96,6 +100,18 @@ public boolean onCommand(CommandSender sender, String[] args) { scriptTasks.forEach(task -> tasksInfo.add(task.toString())); builder.append(ChatColor.GOLD + "Running tasks: " + ChatColor.RESET + tasksInfo + "\n"); + List scriptDatabases = DatabaseManager.get().getDatabases(script); + List databasesInfo = new ArrayList<>(); + if (scriptDatabases != null) + scriptDatabases.forEach(database -> databasesInfo.add(database.toString())); + builder.append(ChatColor.GOLD + "Database connections: " + ChatColor.RESET + databasesInfo + "\n"); + + List scriptRedisClients = RedisManager.get().getRedisClients(script); + List redisInfo = new ArrayList<>(); + if (scriptRedisClients != null) + scriptRedisClients.forEach(redisClient -> redisInfo.add(redisClient.toString())); + builder.append(ChatColor.GOLD + "Redis clients: " + ChatColor.RESET + redisInfo + "\n"); + builder.append(ChatColor.GOLD + "Script options: " + ChatColor.RESET + script.getOptions().toString()); sender.sendMessage(builder.toString());