Compare commits
5 Commits
72025bc22c
...
78561fa467
Author | SHA1 | Date |
---|---|---|
mohammed jasem alaajel | 78561fa467 | |
mohammed jasem alaajel | ab441503c7 | |
mohammed jasem alaajel | 51719f13e2 | |
mohammed jasem alaajel | 2015d1d0fd | |
mohammed jasem alaajel | 70aacc99c0 |
|
@ -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));
|
||||
|
@ -273,6 +280,7 @@ public abstract class ProxyDataManager implements Runnable {
|
|||
return;
|
||||
}
|
||||
for (UUID uuid : getProxyMembers(id)) plugin.fireEvent(plugin.createPlayerLeftNetworkEvent(uuid));
|
||||
this.heartbeats.remove(id);
|
||||
plugin.logInfo("Proxy {} has disconnected", id);
|
||||
}
|
||||
|
||||
|
@ -335,7 +343,7 @@ public abstract class ProxyDataManager implements Runnable {
|
|||
if (!payloadDataManagerUUID.equals(this.dataManagerUUID)) {
|
||||
plugin.logWarn("detected other proxy is using same ID! {} this can cause issues, please shutdown this proxy and change the id!", this.proxyId);
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (unknownPayload instanceof HeartbeatPayload payload) {
|
||||
handleHeartBeat(payload);
|
||||
|
|
|
@ -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;
|
||||
|
@ -40,12 +41,12 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||
public void info(CommandIssuer issuer) {
|
||||
final String message = """
|
||||
<color:aqua>This proxy is running RedisBungee Limework's fork
|
||||
<color:yellow>========================================
|
||||
<color:gold>========================================
|
||||
<color:aqua>RedisBungee version: <color:green><version>
|
||||
<color:aqua>Build date: <color:green><build-date>
|
||||
<color:aqua>Commit: <color:green><commit>
|
||||
<color:yellow>========================================
|
||||
<color:yellow>run /rb help for more commands""";
|
||||
<color:gold>========================================
|
||||
<color:gold>run /rb help for more commands""";
|
||||
sendMessage(
|
||||
issuer,
|
||||
MiniMessage.miniMessage()
|
||||
|
@ -64,13 +65,14 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||
@HelpCommand
|
||||
public void help(CommandIssuer issuer) {
|
||||
final String message = """
|
||||
<color:yellow>========================================
|
||||
<color:gold>========================================
|
||||
<color:aqua>/rb info: <color:green>shows info of this version.
|
||||
<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:yellow>========================================
|
||||
<color:yellow>run /rb help for more commands""";
|
||||
<color:aqua>/rb show: <color:green>shows list of proxies with player count
|
||||
<color:gold>========================================
|
||||
<color:gold>run /rb help for more commands""";
|
||||
sendMessage(issuer, MiniMessage.miniMessage().deserialize(message));
|
||||
}
|
||||
@Subcommand("clean")
|
||||
|
@ -86,4 +88,30 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||
plugin.executeAsync(new StopperUUIDCleanupTask(plugin));
|
||||
}
|
||||
|
||||
|
||||
@Subcommand("show")
|
||||
public void showProxies(CommandIssuer issuer) {
|
||||
final String message = """
|
||||
<color:gold>========================================
|
||||
<data><color:gold>========================================""";
|
||||
|
||||
final String proxyPlayersMessage = "<color:yellow><proxy><here> : <color:green><players> online";
|
||||
|
||||
|
||||
TextComponent.Builder builder = Component.text();
|
||||
|
||||
plugin.proxyDataManager().eachProxyCount().forEach((proxy, players)
|
||||
-> builder.append(
|
||||
MiniMessage.miniMessage()
|
||||
.deserialize(proxyPlayersMessage,
|
||||
Placeholder.component("here", Component.text(plugin.proxyDataManager().proxyId().equals(proxy) ? " (#) " : "")),
|
||||
Placeholder.component("proxy", Component.text(proxy)),
|
||||
Placeholder.component("players", Component.text(players))
|
||||
)
|
||||
.appendNewline()));
|
||||
|
||||
sendMessage(issuer, MiniMessage.miniMessage().deserialize(message, Placeholder.component("data", builder)));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue