Skip to content

Commit

Permalink
Add database and redis info to /pyspigot info command
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmq committed May 24, 2024
1 parent b9578e5 commit cd80dfb
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Database> scriptDatabases = DatabaseManager.get().getDatabases(script);
List<String> databasesInfo = new ArrayList<>();
if (scriptDatabases != null)
scriptDatabases.forEach(database -> databasesInfo.add(database.toString()));
builder.append(ChatColor.GOLD + "Database connections: " + ChatColor.RESET + databasesInfo + "\n");

List<ScriptRedisClient> scriptRedisClients = RedisManager.get().getRedisClients(script);
List<String> 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());
Expand Down

0 comments on commit cd80dfb

Please sign in to comment.