diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/ProxyDataManager.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/ProxyDataManager.java index 5e9c269..707b6fd 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/ProxyDataManager.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/ProxyDataManager.java @@ -10,6 +10,7 @@ package com.imaginarycode.minecraft.redisbungee.api; +import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.imaginarycode.minecraft.redisbungee.api.payloads.AbstractPayload; @@ -147,6 +148,12 @@ public abstract class ProxyDataManager implements Runnable { return players; } + public Map eachProxyCount() { + ImmutableMap.Builder builder = ImmutableMap.builder(); + heartbeats.forEach((proxy, data) -> builder.put(proxy, data.players())); + return builder.build(); + } + // Call on close private synchronized void publishDeath() { publishPayload(new DeathPayload(this.proxyId)); diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java index 8025030..65aabe9 100644 --- a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java @@ -17,6 +17,7 @@ import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; import com.imaginarycode.minecraft.redisbungee.commands.utils.StopperUUIDCleanupTask; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; @@ -69,6 +70,7 @@ public class CommandRedisBungee extends AdventureBaseCommand { /rb help: shows this page. /rb clean: cleans up the uuid cache WARNING... command above could cause performance issues + /rb show: shows list of proxies with player count ======================================== run /rb help for more commands"""; sendMessage(issuer, MiniMessage.miniMessage().deserialize(message)); @@ -86,4 +88,19 @@ public class CommandRedisBungee extends AdventureBaseCommand { plugin.executeAsync(new StopperUUIDCleanupTask(plugin)); } + + @Subcommand("show") + public void showProxies(CommandIssuer issuer) { + final String message = """ + ======================================== + ========================================"""; + TextComponent.Builder builder = Component.text(); + + plugin.proxyDataManager().eachProxyCount().forEach((proxy, players) + -> builder.append(Component.text(proxy + ": " + players)).appendNewline()); + + sendMessage(issuer, MiniMessage.miniMessage().deserialize(message, Placeholder.component("data", builder))); + + + } }