Initialize Server Variable

This commit is contained in:
RayzsYT committed 2024-05-17 12:16:15 +02:00
1 parent 7abb7fdd3e
commit ee7aafe3d3
1 file changed
+7 -2
@@ -9,12 +9,17 @@ import de.rayzs.pat.utils.Storage;
public class VelocityPingListener {
private static ProxyServer server;
public VelocityPingListener(ProxyServer server) {
VelocityPingListener.server = server;
}
@Subscribe
public void onProxyPing(ProxyPingEvent event) {
if(!Storage.USE_CUSTOM_PROTOCOL_PING) return;
ProxyServer proxyServer = VelocityLoader.getServer();
int online = proxyServer.getPlayerCount(), max = proxyServer.getConfiguration().getShowMaxPlayers();
int online = server.getPlayerCount(), max = server.getConfiguration().getShowMaxPlayers();
ServerPing oldServerPing = event.getPing(), newServerPing;
ServerPing.Version newVersion = new ServerPing.Version(!Storage.USE_ALWAYS_SHOW_CUSTOM_PROTOCOL_PING ? oldServerPing.getVersion().getProtocol() : -1, Storage.CUSTOM_PROTOCOL_PING.replace("%online%", String.valueOf(online)).replace("%max%", String.valueOf(max)));
newServerPing = oldServerPing.asBuilder().version(newVersion).build();