ServerListPlus
ServerListPlus copied to clipboard
Placeholder Problem
Hey, I register a couple of placeholders on my Velocity (b393) and latest development build of ServerListPlus with this code:
(Config.serverList returns the list of server names like survival, kitpvp, skyblock and ...)
@Plugin(
id = "slputils",
name = "SLPUtils",
version = "1.0.0",
authors = {"xii69"},
dependencies = {
@Dependency(id = "serverlistplus")
}
)
@Getter
public class SLPUtils {
private final Logger logger;
private final ProxyServer server;
private final Path dataDirectory;
@Inject
public SLPUtils(Logger logger, ProxyServer server, @DataDirectory Path dataDirectory) {
this.logger = logger;
this.server = server;
this.dataDirectory = dataDirectory;
}
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
new Config(getDataDirectory(), getClass()).load();
Config.serverList.forEach(this::regTest);
}
private void regTest(String serverName) {
ReplacementManager.getDynamic().add(new LiteralPlaceholder("%sum_" + serverName + "%") {
@Override
public String replace(StatusResponse response, String s) {
int count = 0;
int vanishedCount = 0;
List<UUID> vanishedPlayers = VelocityVanishAPI.getInvisiblePlayers();
for (RegisteredServer server : server.getAllServers()) {
vanishedCount = 0;
if (server.getServerInfo().getName().toLowerCase().contains(serverName)) {
count += server.getPlayersConnected().size();
List<UUID> uuids = new ArrayList<>();
for (Player player : server.getPlayersConnected()) uuids.add(player.getUniqueId());
for (UUID uuid : vanishedPlayers) if (uuids.contains(uuid)) vanishedCount++;
}
}
return replace(s, count - vanishedCount);
}
@Override
public String replace(ServerListPlusCore serverListPlusCore, String s) {
return replace(s, 0);
}
});
}
}
Basically I'm using PremiumVanish API to remove the vanished player count from the server MOTD, but the placeholder doesn't work and when you hover over on the MOTD you see this:
After a /slp reload
placeholders get registered, I've tried registering the placeholders with a 5 and 10 seconds delay but nothing changed, what should I do?