mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-05 04:48:02 +00:00
show command
This commit is contained in:
parent
2015d1d0fd
commit
51719f13e2
@ -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<String, Integer> eachProxyCount() {
|
||||
ImmutableMap.Builder<String, Integer> 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));
|
||||
|
@ -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 {
|
||||
<color:aqua>/rb help: <color:green>shows this page.
|
||||
<color:aqua>/rb clean: <color:green>cleans up the uuid cache
|
||||
<color:red><bold>WARNING...</bold> <color:white>command above could cause performance issues
|
||||
<color:aqua>/rb show: <color:green>shows list of proxies with player count
|
||||
<color:yellow>========================================
|
||||
<color:yellow>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 = """
|
||||
<color:yellow>========================================
|
||||
<data><color:yellow>========================================""";
|
||||
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)));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user