mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-18 23:07:34 +01:00
Allow to count multiple servers.
This commit is contained in:
parent
52d9940926
commit
0704693810
@ -55,15 +55,15 @@ public class BungeeServerTracker {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPlayersOnline(String server) {
|
public static int getPlayersOnline(String server) {
|
||||||
BungeeServerInfo info = trackedServers.get(server);
|
BungeeServerInfo info = trackedServers.get(server);
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
info.updateLastRequest();
|
info.updateLastRequest();
|
||||||
return String.valueOf(info.getOnlinePlayers());
|
return info.getOnlinePlayers();
|
||||||
} else {
|
} else {
|
||||||
// It was not tracked, add it.
|
// It was not tracked, add it.
|
||||||
track(server);
|
track(server);
|
||||||
return "0";
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,14 +165,37 @@ public class PlaceholdersManager {
|
|||||||
final String serverName = extractArgumentFromPlaceholder(matcher);
|
final String serverName = extractArgumentFromPlaceholder(matcher);
|
||||||
BungeeServerTracker.track(serverName); // Track this server.
|
BungeeServerTracker.track(serverName); // Track this server.
|
||||||
|
|
||||||
// Add it to tracked servers.
|
if (serverName.contains(",")) {
|
||||||
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
|
||||||
|
|
||||||
@Override
|
String[] split = serverName.split(",");
|
||||||
public String update() {
|
for (int i = 0; i < split.length; i++) {
|
||||||
return BungeeServerTracker.getPlayersOnline(serverName);
|
split[i] = split[i].trim();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
final String[] serversToTrack = split;
|
||||||
|
|
||||||
|
// Add it to tracked servers.
|
||||||
|
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String update() {
|
||||||
|
int count = 0;
|
||||||
|
for (String serverToTrack : serversToTrack) {
|
||||||
|
count += BungeeServerTracker.getPlayersOnline(serverToTrack);
|
||||||
|
}
|
||||||
|
return String.valueOf(count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Normal, single tracked server.
|
||||||
|
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String update() {
|
||||||
|
return String.valueOf(BungeeServerTracker.getPlayersOnline(serverName));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BungeeCord max players pattern.
|
// BungeeCord max players pattern.
|
||||||
|
Loading…
Reference in New Issue
Block a user