Compare commits

...
63 Commits
Author SHA1 Message Date
Andre601 9feb3dfac6 Bump version 2024-10-02 13:43:45 +02:00
Andre601 5961d0dca0 Don't log errors when fetching servers (+ misc changes) 2024-10-02 13:43:05 +02:00
Andre601 3d5d4fcab2 Fix wrong name for AdvancedBan in BanPlugins Addon 2024-10-01 19:58:11 +02:00
Andre601 0763a9b3b4 Fix wrong main class for Paper BanPluginsAddon 2024-10-01 02:26:14 +02:00
Andre601 2d67a89fc2 Merge pull request 'Update dependency mkdocs-material to v9.5.39' (#349) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/349
2024-09-29 12:07:56 +00:00
Andre601's Bot 4207d875f9 Update dependency mkdocs-material to v9.5.39 2024-09-29 12:03:17 +00:00
Andre601 5da420c6c6 Merge pull request 'feature/online-players-setting' (#348) from feature/online-players-setting into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/348
2024-09-27 14:27:47 +00:00
Andre601 1ffa4842c3 Update API docs and bump version to major v5 2024-09-26 16:47:28 +02:00
Andre601 819e194f27 Make Server placeholders return empty String instead of null. 2024-09-26 16:11:38 +02:00
Andre601 269e55b93f Merge branch 'master' into feature/online-players-setting 2024-09-26 15:54:50 +02:00
Andre601 04412f7138 Implement feature to set online player count 2024-09-26 15:54:28 +02:00
Andre601 0fce9d01e1 Merge pull request 'Update dependency mkdocs-material to v9.5.38' (#346) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/346
2024-09-26 13:50:41 +00:00
Andre601's Bot 1c29301635 Update dependency mkdocs-material to v9.5.38 2024-09-26 12:02:06 +00:00
Andre601 8bd7bbb5d7 Merge pull request 'Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.1' (#345) from renovate/org.junit.jupiter-junit-jupiter-engine-5.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/345
2024-09-25 12:04:33 +00:00
Andre601 1a99663b59 Merge pull request 'Update dependency mkdocs-material to v9.5.37' (#344) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/344
2024-09-25 12:04:14 +00:00
Andre601's Bot 36e31279b2 Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.1 2024-09-25 12:01:31 +00:00
Andre601's Bot 4aa7eba675 Update dependency mkdocs-material to v9.5.37 2024-09-25 12:01:21 +00:00
Andre601 3bbe2d26b8 Merge pull request 'Update dependency com.google.guava:guava to v33.3.1-jre' (#342) from renovate/com.google.guava-guava-33.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/342
2024-09-24 13:11:35 +00:00
Andre601 782ad838be Merge pull request 'Update dependency org.bstats:bstats-velocity to v3.1.0' (#343) from renovate/org.bstats-bstats-velocity-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/343
2024-09-24 13:11:22 +00:00
Andre601's Bot ceddb26137 Update dependency org.bstats:bstats-velocity to v3.1.0 2024-09-24 12:01:32 +00:00
Andre601's Bot ff044d75c7 Update dependency com.google.guava:guava to v33.3.1-jre 2024-09-24 12:01:25 +00:00
Andre601 8955df695d Merge pull request 'Update dependency org.bstats:bstats-bungeecord to v3.1.0' (#341) from renovate/org.bstats-bstats-bungeecord-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/341
2024-09-23 12:57:03 +00:00
Andre601 8ddcb208f5 Merge pull request 'Update dependency org.bstats:bstats-bukkit to v3.1.0' (#340) from renovate/org.bstats-bstats-bukkit-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/340
2024-09-23 12:56:27 +00:00
Andre601's Bot 95834df89f Update dependency org.bstats:bstats-bungeecord to v3.1.0 2024-09-23 12:01:58 +00:00
Andre601's Bot 2f67f26cbe Update dependency org.bstats:bstats-bukkit to v3.1.0 2024-09-23 12:01:52 +00:00
Andre601 00957f9458 Merge pull request 'Create ${proxy status ...} placeholder.' (#334) from feature/proxy-status-placeholder into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/334
2024-09-22 13:12:42 +00:00
Andre601 2e9e886c48 Merge pull request 'Update dependency mkdocs-material to v9.5.36' (#338) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/338
2024-09-21 12:24:01 +00:00
Andre601's Bot d2d4e48b73 Update dependency mkdocs-material to v9.5.36 2024-09-21 12:01:47 +00:00
Andre601 fe16df27f2 Merge pull request 'Update dependency org.apache.httpcomponents.client5:httpclient5 to v5.4' (#337) from renovate/org.apache.httpcomponents.client5-httpclient5-5.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/337
2024-09-20 15:51:44 +00:00
Andre601's Bot cc29f70dff Update dependency org.apache.httpcomponents.client5:httpclient5 to v5.4 2024-09-20 12:02:38 +00:00
Andre601 e136f7cfaf Merge pull request 'Update dependency mkdocs-material to v9.5.35' (#336) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/336
2024-09-18 12:05:57 +00:00
Andre601's Bot fd52f124fb Update dependency mkdocs-material to v9.5.35 2024-09-18 12:01:38 +00:00
Andre601 5a656cee39 Merge pull request 'Update alpine Docker tag to v3.20.3' (#335) from renovate/alpine-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/335
2024-09-17 14:39:09 +00:00
Andre601's Bot 21a89f9b14 Update alpine Docker tag to v3.20.3 2024-09-17 12:01:40 +00:00
Andre601 9ded4d2d57 Add more placeholders 2024-09-09 14:49:07 +02:00
Andre601 fb64d92879 Create Proxy Placeholder 2024-09-09 02:05:50 +02:00
Andre601 1a4bcae4d1 Merge pull request 'Update dependency ch.qos.logback:logback-classic to v1.5.8' (#331) from renovate/ch.qos.logback-logback-classic-1.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/331
2024-09-07 12:07:57 +00:00
Andre601's Bot 25ee4da4f4 Update dependency ch.qos.logback:logback-classic to v1.5.8 2024-09-07 12:01:12 +00:00
Andre601 35cb39c35e Merge pull request 'Update dependency mkdocs-material to v9.5.34' (#330) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/330
2024-09-01 14:09:33 +00:00
Andre601's Bot 3a5f232f92 Update dependency mkdocs-material to v9.5.34 2024-09-01 12:03:23 +00:00
Andre601 4ed201fba9 Bump version 2024-08-29 20:31:14 +02:00
Andre601 03835f71d9 Fix local favicon saving using non-lowercased names. 2024-08-29 20:30:44 +02:00
Andre601 480e50e71e .woodpecker/publish_assets.yml aktualisiert 2024-08-29 11:51:38 +00:00
Andre601 39110b2898 Merge pull request 'Update dependency mkdocs-material to v9.5.33' (#329) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/329
2024-08-23 13:08:17 +00:00
Andre601's Bot e8db70e319 Update dependency mkdocs-material to v9.5.33 2024-08-23 12:02:52 +00:00
Andre601 eb907988fb Merge pull request 'Update maven Docker tag to v3.9.9' (#328) from renovate/maven-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/328
2024-08-21 12:39:31 +00:00
Andre601's Bot 95935022b8 Update maven Docker tag to v3.9.9 2024-08-21 12:10:41 +00:00
Andre601 1e70cb0651 Merge pull request 'Update dependency org.bstats:bstats-velocity to v3.0.3' (#327) from renovate/org.bstats-bstats-velocity-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/327
2024-08-20 13:55:27 +00:00
Andre601 1594d062e5 Merge pull request 'Update dependency org.bstats:bstats-bungeecord to v3.0.3' (#326) from renovate/org.bstats-bstats-bungeecord-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/326
2024-08-20 13:55:11 +00:00
Andre601's Bot 04b266f558 Update dependency org.bstats:bstats-velocity to v3.0.3 2024-08-20 12:03:13 +00:00
Andre601's Bot 9989fec809 Update dependency org.bstats:bstats-bungeecord to v3.0.3 2024-08-20 12:03:06 +00:00
Andre601 ab8eabc348 Merge pull request 'Update dependency org.bstats:bstats-bukkit to v3.0.3' (#325) from renovate/org.bstats-bstats-bukkit-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/325
2024-08-19 13:54:53 +00:00
Andre601 931b8b5c36 Merge pull request 'Update dependency mkdocs-material to v9.5.32' (#324) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/324
2024-08-19 13:53:45 +00:00
Andre601's Bot 64957ba13c Update dependency org.bstats:bstats-bukkit to v3.0.3 2024-08-19 12:04:55 +00:00
Andre601's Bot a03be990ab Update dependency mkdocs-material to v9.5.32 2024-08-19 12:04:46 +00:00
Andre601 44729495f5 Merge pull request 'Update dependency ch.qos.logback:logback-classic to v1.5.7' (#322) from renovate/ch.qos.logback-logback-classic-1.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/322
2024-08-19 00:59:33 +00:00
Andre601 9e7500f0cd Merge pull request 'Update dependency com.google.guava:guava to v33.3.0-jre' (#323) from renovate/com.google.guava-guava-33.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/323
2024-08-17 12:06:21 +00:00
Andre601's Bot d10ff8bdbc Update dependency com.google.guava:guava to v33.3.0-jre 2024-08-17 12:04:11 +00:00
Andre601's Bot f91fc36365 Update dependency ch.qos.logback:logback-classic to v1.5.7 2024-08-16 12:02:51 +00:00
Andre601 84ddff07a2 Merge pull request 'Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.0' (#321) from renovate/org.junit.jupiter-junit-jupiter-engine-5.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/321
2024-08-14 12:46:12 +00:00
Andre601's Bot 4a89658cf4 Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.0 2024-08-14 12:31:56 +00:00
Andre601 5daef41031 Fix renovate.json 2024-08-14 12:22:44 +00:00
Andre601 07cc1e8160 Update registry URL for Libby 2024-08-13 12:45:02 +00:00
48 changed files with 549 additions and 280 deletions

No files matched your search

+2 -2
View File
@@ -11,7 +11,7 @@ variables:
steps:
- name: "Clone Preview Repository"
image: alpine:3.18.4
image: alpine:3.20.3
commands:
- chmod -R a+w .
- <<: *setup_git
@@ -24,7 +24,7 @@ steps:
settings:
pip_install_file: requirements.txt
- name: "Commit and Push"
image: alpine:3.18.4
image: alpine:3.20.3
secrets:
- bot_token
commands:
+2 -2
View File
@@ -4,7 +4,7 @@ when:
steps:
- name: "Build Jar and Upload"
image: maven:3.9.8-eclipse-temurin-21
image: maven:3.9.9-eclipse-temurin-21
secrets:
- modrinth_api_token
- hangar_api_token
@@ -34,7 +34,7 @@ steps:
when:
- status: ["success"]
settings:
server_url: https://blobfox.coffee
server_url: https://swiss.social
access_token:
from_secret: mastodon_token
status: |-
+2 -2
View File
@@ -12,7 +12,7 @@ variables:
steps:
- name: "Clone target Repository"
image: alpine:3.18.4
image: alpine:3.20.3
commands:
- chmod -R a+w .
- <<: *setup_git
@@ -23,7 +23,7 @@ steps:
settings:
pip_install_file: requirements.txt
- name: "Commit and Push"
image: alpine:3.18.4
image: alpine:3.20.3
secrets:
- bot_token
commands:
@@ -2,7 +2,7 @@ name: 'ASLBanPluginsAddon'
author: 'Andre_601'
version: '${plugin.version}'
main: 'ch.andre601.advancedserverlist.banplugins.paper.AdvancedBanPlaceholders'
main: 'ch.andre601.advancedserverlist.banplugins.paper.PaperBanPluginsAddon'
api-version: '1.19'
@@ -11,7 +11,7 @@ dependencies:
AdvancedServerList:
required: false
load: BEFORE
AdvancedBans:
AdvancedBan:
required: false
load: BEFORE
LibertyBans:
+1 -1
View File
@@ -105,7 +105,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
@@ -30,6 +30,7 @@ import ch.andre601.advancedserverlist.bungeecord.listeners.JoinEvent;
import ch.andre601.advancedserverlist.bungeecord.listeners.PingEvent;
import ch.andre601.advancedserverlist.bungeecord.logging.BungeeLogger;
import ch.andre601.advancedserverlist.bungeecord.objects.placeholders.BungeePlayerPlaceholders;
import ch.andre601.advancedserverlist.bungeecord.objects.placeholders.BungeeProxyPlaceholders;
import ch.andre601.advancedserverlist.bungeecord.objects.placeholders.BungeeServerPlaceholders;
import ch.andre601.advancedserverlist.core.AdvancedServerList;
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
@@ -40,6 +41,7 @@ import com.alessiodp.libby.Library;
import de.myzelyam.api.vanish.BungeeVanishAPI;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.md_5.bungee.api.Favicon;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
@@ -50,10 +52,14 @@ import java.awt.image.BufferedImage;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
private final PluginLogger logger = new BungeeLogger(this);
private final Map<String, ServerPing> fetchedServers = new ConcurrentHashMap<>();
private boolean successfulLoad = false;
@@ -83,12 +89,14 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
}
this.audiences = BungeeAudiences.create(this);
this.core = AdvancedServerList.init(this, BungeePlayerPlaceholders.init(), BungeeServerPlaceholders.init(this));
this.core = AdvancedServerList.init(this,
BungeePlayerPlaceholders.init(), BungeeServerPlaceholders.init(this), BungeeProxyPlaceholders.init(this));
}
@Override
public void onDisable(){
core.disable();
getProxy().getScheduler().cancel(this);
}
@Override
@@ -140,6 +148,11 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
libraryManager.loadLibrary(lib);
}
@Override
public void startScheduler(){
getProxy().getScheduler().schedule(this, this::fetchServers, 0, 10, TimeUnit.SECONDS);
}
@Override
public AdvancedServerList<Favicon> getCore(){
return core;
@@ -198,6 +211,10 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
return players.size();
}
public Map<String, ServerPing> getFetchedServers(){
return fetchedServers;
}
private boolean loadLibs(){
try{
if(libraryManager == null){
@@ -213,4 +230,14 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
return false;
}
}
private void fetchServers(){
fetchedServers.clear();
getProxy().getServers().forEach((name, server) -> server.ping((ping, throwable) -> {
if(throwable != null)
return;
fetchedServers.put(name, ping);
}));
}
}
@@ -79,6 +79,11 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
ping.getPlayers().setMax(maxPlayers);
}
@Override
public void setOnlinePlayers(int onlinePlayers){
ping.getPlayers().setOnline(onlinePlayers);
}
@Override
public void setMotd(Component component){
ping.setDescriptionComponent(new TextComponent(BungeeComponentSerializer.get().serialize(component)));
@@ -0,0 +1,61 @@
package ch.andre601.advancedserverlist.bungeecord.objects.placeholders;
import ch.andre601.advancedserverlist.api.PlaceholderProvider;
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.bungeecord.BungeeCordCore;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.chat.BaseComponent;
public class BungeeProxyPlaceholders extends PlaceholderProvider{
private final BungeeCordCore plugin;
private BungeeProxyPlaceholders(BungeeCordCore plugin){
super("proxy");
this.plugin = plugin;
}
public static BungeeProxyPlaceholders init(BungeeCordCore plugin){
return new BungeeProxyPlaceholders(plugin);
}
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
String[] args = placeholder.split("\\s", 2);
if(args.length < 2)
return null;
ServerPing ping = plugin.getFetchedServers().get(args[1]);
return switch(args[0]){
case "status" -> ping == null ? "offline" : "online";
case "motd" -> {
if(ping == null)
yield "none";
BaseComponent[] components = new BaseComponent[]{ping.getDescriptionComponent()};
Component component = BungeeComponentSerializer.get().deserialize(components);
yield ComponentParser.toMMString(component);
}
case "players" -> {
if(ping == null)
yield "0";
yield String.valueOf(ping.getPlayers().getOnline());
}
case "maxPlayers" -> {
if(ping == null)
yield "0";
yield String.valueOf(ping.getPlayers().getMax());
}
default -> null;
};
}
}
@@ -79,18 +79,18 @@ public class BungeeServerPlaceholders extends PlaceholderProvider{
case "playersMax" -> {
// ServerInfo doesn't provide the max players that could join, so we won't allow an extra argument
if(args.length >= 2)
yield null;
yield "";
yield String.valueOf(proxy.getPlayersMax());
}
case "host" -> {
if(args.length > 2)
yield null;
yield "";
if(args.length == 2 && args[1] != null && !args[1].isEmpty()){
ServerInfo info = proxy.getServers().get(args[1]);
if(info == null)
yield null;
yield "";
yield String.valueOf(((InetSocketAddress)info.getSocketAddress()).getHostString());
}
+3 -3
View File
@@ -41,7 +41,7 @@
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<plugin.config.version>5</plugin.config.version>
<plugin.config.version>6</plugin.config.version>
</properties>
<repositories>
@@ -129,7 +129,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
<version>33.3.1-jre</version>
<scope>provided</scope>
</dependency>
@@ -157,7 +157,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.3</version>
<version>5.11.1</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -177,6 +177,10 @@ public class AdvancedServerList<F>{
getPlugin().getPluginLogger().info("Loading bStats metrics. Disable it in the global config under /plugins/bstats/");
plugin.loadMetrics();
getPlugin().getPluginLogger().info("Metrics loaded!");
getPlugin().getPluginLogger().info("Enabling Schedulers...");
plugin.startScheduler();
getPlugin().getPluginLogger().info("Schedulers enabled.");
getPlugin().getPluginLogger().info("AdvancedServerList is ready!");
@@ -70,42 +70,75 @@ public class PingEventHandler{
logger.debug(PingEventHandler.class, "Received valid Server List Profile. Calling PreServerListSetEvent...");
GenericServerListEvent e = event.callEvent(ProfileManager.merge(profile));
if(e == null || e.isCancelled()){
GenericServerListEvent slEvent = event.callEvent(ProfileManager.merge(profile));
if(slEvent == null || slEvent.isCancelled()){
logger.debug(PingEventHandler.class, "PreServerListSetEvent was cancelled. Stopping ping handling...");
return null;
}
logger.debug(PingEventHandler.class, "PreServerListSetEvent completed. Proceeding with ping handling...");
ProfileEntry entry = e.getEntry();
ProfileEntry entry = slEvent.getEntry();
if(entry.isInvalid()){
logger.debugWarn(PingEventHandler.class, "No valid ProfileEntry retrieved. Cancelling ping handling...");
return null;
}
boolean extraPlayers = ProfileManager.checkOption(entry.extraPlayersEnabled());
if(extraPlayers && ignoreMaintenance(event, "extraPlayers")){
max = online + (entry.extraPlayersCount() == null ? 0 : entry.extraPlayersCount());
if(ProfileManager.checkOption(entry.onlinePlayersEnabled()) && ignoreMaintenance(event, "onlinePlayers")){
logger.debug(PingEventHandler.class, "'playerCount -> onlinePlayers -> enabled' option is true. Trying to apply '%s'...", entry.onlinePlayersCount());
String onlinePlayers = ComponentParser.text(entry.onlinePlayersCount())
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
.toString();
logger.debug(PingEventHandler.class, "Extra Players enabled. Applying '%d' as max player count...", max);
event.setMaxPlayers(max);
try{
online = onlinePlayers == null ? online : Integer.parseInt(onlinePlayers);
event.setOnlinePlayers(online);
}catch(NumberFormatException ex){
logger.warn("Option 'playerCount -> onlinePlayers -> amount' is not a valid Number!");
}
}
if(ProfileManager.checkOption(entry.maxPlayersEnabled()) && !extraPlayers && ignoreMaintenance(event, "maxPlayers")){
max = (entry.maxPlayersCount() == null) ? 0 : entry.maxPlayersCount();
boolean extraPlayersEnabled = ProfileManager.checkOption(entry.extraPlayersEnabled());
if(extraPlayersEnabled && ignoreMaintenance(event, "extraPlayers")){
logger.debug(PingEventHandler.class, "'playerCount -> extraPlayers -> enabled' option is true. Trying to apply '%s'...", entry.extraPlayersCount());
String extraPlayers = ComponentParser.text(entry.extraPlayersCount())
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
.toString();
logger.debug(PingEventHandler.class, "Max Players enabled. Applying '%d' as max player count...", max);
try{
max = online + (extraPlayers == null ? 0 : Integer.parseInt(extraPlayers));
logger.debug(PingEventHandler.class, "'playerCount -> extraPlayers -> amount' is a valid number. Applying it...");
event.setMaxPlayers(max);
}catch(NumberFormatException ex){
logger.warn("Option 'playerCount -> extraPlayers -> amount' is not a valid Number!");
}
}
if(ProfileManager.checkOption(entry.maxPlayersEnabled()) && !extraPlayersEnabled && ignoreMaintenance(event, "maxPlayers")){
logger.debug(PingEventHandler.class, "'playerCount -> maxPlayers -> enabled' option is true. Trying to apply '%s'...", entry.maxPlayersCount());
String maxPlayers = ComponentParser.text(entry.maxPlayersCount())
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
.toString();
event.setMaxPlayers(max);
try{
max = maxPlayers == null ? 0 : Integer.parseInt(maxPlayers);
logger.debug(PingEventHandler.class, "'playerCount -> maxPlayers -> amount' is a valid number. Applying it...");
event.setMaxPlayers(max);
}catch(NumberFormatException ex){
logger.warn("Option 'playerCount -> maxPlayers -> amount' is not a valid Number!");
}
}
GenericServer finalServer = event.createGenericServer(online, max, host);
if(ProfileManager.checkOption(entry.motd()) && ignoreMaintenance(event, "motd")){
logger.debug(PingEventHandler.class, "MOTD set. Applying '%s'...", String.join("\\n", entry.motd()));
logger.debug(PingEventHandler.class, "'motd' option present. Applying '%s'...", String.join("\\n", entry.motd()));
event.setMotd(
ComponentParser.list(entry.motd())
@@ -118,13 +151,13 @@ public class PingEventHandler{
boolean hidePlayers = ProfileManager.checkOption(entry.hidePlayersEnabled());
if(hidePlayers && ignoreMaintenance(event, "hidePlayers")){
logger.debug(PingEventHandler.class, "Hide Players enabled. Hiding player count...");
logger.debug(PingEventHandler.class, "'playerCount -> hidePlayers' enabled. Hiding player count...");
event.hidePlayers();
}
if(ProfileManager.checkOption(entry.playerCountText()) && !hidePlayers && ignoreMaintenance(event, "playerCountText")){
logger.debug(PingEventHandler.class, "Player Count Text set. Applying '%s'...", entry.playerCountText());
logger.debug(PingEventHandler.class, "'playerCount -> text' option set. Applying '%s'...", entry.playerCountText());
event.setPlayerCount(
ComponentParser.text(entry.playerCountText())
@@ -135,13 +168,13 @@ public class PingEventHandler{
}
if(ProfileManager.checkOption(entry.players()) && !hidePlayers && ignoreMaintenance(event, "playerCountHover")){
logger.debug(PingEventHandler.class, "Player Count Hover set. Applying '%s'...", String.join("\\n", entry.players()));
logger.debug(PingEventHandler.class, "'playerCount -> hover' option set. Applying '%s'...", String.join("\\n", entry.players()));
event.setPlayers(entry.players(), player, server);
}
if(ProfileManager.checkOption(entry.favicon()) && ignoreMaintenance(event, "favicon")){
logger.debug(PingEventHandler.class, "Favicon set. Resolving '%s'...", entry.favicon());
logger.debug(PingEventHandler.class, "'favicon' option set. Resolving '%s'...", entry.favicon());
String faviconString = StringReplacer.replace(entry.favicon(), player, server);
@@ -46,13 +46,24 @@ public class ConfigMigrator{
public static ConfigurationTransformation.Versioned create(){
return ConfigurationTransformation.versionedBuilder()
.versionKey("configVersion")
.addVersion(LATEST, fourToFive())
.addVersion(LATEST, fiveToSix())
.addVersion(5, fourToFive())
.addVersion(4, threeToFour())
.addVersion(3, twoToThree())
.addVersion(2, oneToTwo())
.build();
}
public static ConfigurationTransformation fiveToSix(){
return ConfigurationTransformation.builder()
.addAction(NodePath.path("disableDuringMaintenance"), (path, value) -> {
value.node("onlinePlayers").set(true);
return null;
})
.build();
}
public static ConfigurationTransformation fourToFive(){
return ConfigurationTransformation.builder()
.addAction(NodePath.path(), (path, value) -> {
@@ -29,14 +29,14 @@ import java.util.Locale;
public abstract class PluginCommand{
private final String argument;
private final String name;
public PluginCommand(String argument){
this.argument = argument;
public PluginCommand(String name){
this.name = name;
}
public String name(){
return argument;
return name;
}
public String permission(){
@@ -46,6 +46,8 @@ public interface PluginCore<F>{
void downloadLibrary(String groupId, String artifactId, String version);
void startScheduler();
AdvancedServerList<F> getCore();
Path getFolderPath();
@@ -42,6 +42,8 @@ public interface GenericEventWrapper<F, P extends GenericPlayer>{
void setMaxPlayers(int maxPlayers);
void setOnlinePlayers(int onlinePlayers);
void setMotd(Component component);
void hidePlayers();
@@ -135,9 +135,9 @@ public class MiniMOTDConfigMigrator{
profileBuilder.hidePlayersEnabled(hidePlayers)
.extraPlayersEnabled(xMoreEnabled)
.extraPlayersCount(xMore)
.extraPlayersCount(String.valueOf(xMore))
.maxPlayersEnabled(maxPlayersEnabled)
.maxPlayersCount(maxPlayers);
.maxPlayersCount(String.valueOf(maxPlayers));
}
ProfileEntry entry = profileBuilder.build();
@@ -129,7 +129,7 @@ public class SLPConfigMigrator{
apply(motds, builder, profiles, ProfileEntry.Builder::motd);
apply(favicons, builder, profiles, ProfileEntry.Builder::favicon);
apply(hovers, builder, profiles, ProfileEntry.Builder::players);
apply(maxPlayers, builder, profiles, (build, count) -> build.maxPlayersEnabled(NullBool.TRUE).maxPlayersCount(count));
apply(maxPlayers, builder, profiles, (build, count) -> build.maxPlayersEnabled(NullBool.TRUE).maxPlayersCount(String.valueOf(count)));
apply(playerCount, builder, profiles, ProfileEntry.Builder::playerCountText);
builder.hidePlayersEnabled(hidePlayers);
@@ -65,6 +65,10 @@ public class ComponentParser{
return mm.deserialize(text);
}
public static String toMMString(Component component){
return mm.serialize(component);
}
@Override
public String toString(){
return legacy.serialize(toComponent());
@@ -70,11 +70,20 @@ public class FaviconHandler<F>{
}
public F getFavicon(String input){
if(localFavicons.containsKey(input.toLowerCase(Locale.ROOT).split("\\.")[0])){
return localFavicons.get(input.toLowerCase(Locale.ROOT).split("\\.")[0]);
if(localFavicons.size() > 0){
logger.debug(FaviconHandler.class, "Current Local Favicons:");
for(String key : localFavicons.keySet()){
logger.debug(FaviconHandler.class, " - %s", key);
}
}
if(localFavicons.containsKey(input.toLowerCase(Locale.ROOT))){
logger.debug(FaviconHandler.class, "Input matches local favicon Image. Returning it...");
return localFavicons.get(input.toLowerCase(Locale.ROOT));
}
try{
logger.debug(FaviconHandler.class, "Getting Favicon image from cache...");
return faviconCache.get(input, () -> getFuture(input)).getNow(null);
}catch(ExecutionException ex){
logger.warn("Received ExecutionException while retrieving Favicon for '%s'.", ex, input);
@@ -94,7 +103,7 @@ public class FaviconHandler<F>{
}else
if(input.toLowerCase(Locale.ROOT).endsWith(".png")){
logger.debug(FaviconHandler.class, "Resolving image file '%s'...", input);
return CompletableFuture.completedFuture(localFavicons.get(input.toLowerCase(Locale.ROOT).split("\\.")[0]));
return CompletableFuture.completedFuture(localFavicons.get(input.toLowerCase(Locale.ROOT)));
}else{
logger.debug(FaviconHandler.class, "Resolving Name/UUID as https://mc-heads.net/avatar/%s/64...", input);
return CompletableFuture.supplyAsync(() -> fromURL(core, "https://mc-heads.net/avatar/" + input + "/64"), this.faviconThreadPool);
@@ -134,7 +143,7 @@ public class FaviconHandler<F>{
return;
}
localFavicons.put(path.getFileName().toString().split("\\.")[0], favicon);
localFavicons.put(path.getFileName().toString().toLowerCase(Locale.ROOT), favicon);
logger.info("Loaded file '%s' as Favicon.", path.getFileName().toString());
}catch(IOException ex){
logger.warn("Cannot create Favicon from file '%s'. Encountered IOException.", ex);
@@ -114,8 +114,6 @@ public class PlayerHandler{
}catch(IOException ex){
logger.warn("Encountered IOException while saving cached players to playercache.json!", ex);
}
}
public void addPlayer(String ip, String name, UUID uuid){
@@ -55,11 +55,24 @@ public class ProfileManager{
NullBool hidePlayersEnabled = resolve(defEntry, entry, ProfileEntry::hidePlayersEnabled);
NullBool extraPlayersEnabled = resolve(defEntry, entry, ProfileEntry::extraPlayersEnabled);
NullBool maxPlayersEnabled = resolve(defEntry, entry, ProfileEntry::maxPlayersEnabled);
Integer extraPlayersCount = resolve(defEntry, entry, ProfileEntry::extraPlayersCount);
Integer maxPlayersCount = resolve(defEntry, entry, ProfileEntry::maxPlayersCount);
NullBool onlinePlayersEnabled = resolve(defEntry, entry, ProfileEntry::onlinePlayersEnabled);
String extraPlayersCount = resolve(defEntry, entry, ProfileEntry::extraPlayersCount);
String maxPlayersCount = resolve(defEntry, entry, ProfileEntry::maxPlayersCount);
String onlinePlayersCount = resolve(defEntry, entry, ProfileEntry::onlinePlayersCount);
return new ProfileEntry(motd, players, playerCountText, favicon, hidePlayersEnabled, extraPlayersEnabled,
maxPlayersEnabled, extraPlayersCount, maxPlayersCount);
return new ProfileEntry.Builder()
.motd(motd)
.players(players)
.playerCountText(playerCountText)
.favicon(favicon)
.hidePlayersEnabled(hidePlayersEnabled)
.extraPlayersEnabled(extraPlayersEnabled)
.maxPlayersEnabled(maxPlayersEnabled)
.onlinePlayersEnabled(onlinePlayersEnabled)
.extraPlayersCount(extraPlayersCount)
.maxPlayersCount(maxPlayersCount)
.onlinePlayersCount(onlinePlayersCount)
.build();
}
public static ServerListProfile resolveProfile(AdvancedServerList<?> core, GenericPlayer player, GenericServer server){
@@ -82,8 +95,10 @@ public class ProfileManager{
NullBool hidePlayers = resolveNullBool(node, "playerCount", "hidePlayers");
NullBool extraPlayersEnabled = resolveNullBool(node, "playerCount", "extraPlayers", "enabled");
NullBool maxPlayersEnabled = resolveNullBool(node, "playerCount", "maxPlayers", "enabled");
Integer extraPlayers = resolveNullableInt(node, "playerCount", "extraPlayers", "amount");
Integer maxPlayers = resolveNullableInt(node, "playerCount", "maxPlayers", "amount");
NullBool onlinePlayersEnabled = resolveNullBool(node, "playerCount", "onlinePlayers", "enabled");
String extraPlayers = resolveNullableString(node, "playerCount", "extraPlayers", "amount");
String maxPlayers = resolveNullableString(node, "playerCount", "maxPlayers", "amount");
String onlinePlayers = resolveNullableString(node, "playerCount", "onlinePlayers", "amount");
return new ProfileEntry.Builder()
.motd(motd)
@@ -93,8 +108,10 @@ public class ProfileManager{
.hidePlayersEnabled(hidePlayers)
.extraPlayersEnabled(extraPlayersEnabled)
.maxPlayersEnabled(maxPlayersEnabled)
.onlinePlayersEnabled(onlinePlayersEnabled)
.extraPlayersCount(extraPlayers)
.maxPlayersCount(maxPlayers)
.onlinePlayersCount(onlinePlayers)
.build();
}
@@ -137,10 +154,10 @@ public class ProfileManager{
return NullBool.resolve(node.node(path).getBoolean());
}
private static Integer resolveNullableInt(ConfigurationNode node, Object... path){
private static String resolveNullableString(ConfigurationNode node, Object... path){
if(node.node(path).virtual())
return null;
return node.node(path).getInt();
return node.node(path).getString();
}
}
@@ -54,8 +54,10 @@ public class ProfileSerializer implements TypeSerializer<ProfileEntry>{
node.node("favicon").set(profile.favicon());
node.node("playerCount", "hidePlayers").set(profile.hidePlayersEnabled().getOrDefault(false));
node.node("playerCount", "extraPlayers", "enabled").set(profile.extraPlayersEnabled().getOrDefault(false));
node.node("playerCount", "extraPlayers", "amount").set((profile.extraPlayersCount() == null) ? 0 : profile.extraPlayersCount());
node.node("playerCount", "extraPlayers", "amount").set((profile.extraPlayersCount() == null) ? "0" : profile.extraPlayersCount());
node.node("playerCount", "maxPlayers", "enabled").set(profile.maxPlayersEnabled().getOrDefault(false));
node.node("playerCount", "maxPlayers", "amount").set((profile.maxPlayersCount() == null) ? 0 : profile.maxPlayersCount());
node.node("playerCount", "maxPlayers", "amount").set((profile.maxPlayersCount() == null) ? "0" : profile.maxPlayersCount());
node.node("playerCount", "onlinePlayers", "enabled").set(profile.onlinePlayersEnabled().getOrDefault(false));
node.node("playerCount", "onlinePlayers", "amount").set(profile.onlinePlayersCount() == null ? "0" : profile.onlinePlayersCount());
}
}
+6
View File
@@ -107,6 +107,12 @@ disableDuringMaintenance:
# Default: true
#
maxPlayers: true
#
# Whether the online players feature should be disabled while Maintenance mode is active.
#
# Default: true
#
onlinePlayers: true
#
# DO NOT EDIT!
@@ -134,6 +134,7 @@ playerCount:
enabled: false
#
# Set the number that should be added to the online player count to then use as the new max player count.
# Placeholders resolving to numbers can be used here.
#
# Example: Setting this to 1 will result in ${server playersMax} displaying 11 while 10 players are online,
# 9 when 8 are online and so on.
@@ -162,9 +163,34 @@ playerCount:
enabled: false
#
# Set the number that should be used as the new max players count.
# Placeholders resolving to numbers can be used here.
#
# If not present, defaults to 0.
#
# Read more: https://asl.andre601.ch/profiles/#maxplayers-amount
#
amount: 0
#
# The onlinePlayers feature allows to set a number to use as the online player count to display.
#
# Read more: https://asl.andre601.ch/profiles/#onlineplayers
#
onlinePlayers:
#
# Set whether the onlinePlayers feature should be enabled or not.
# When set to true, the max player count will be set to the 'amount' value.
#
# If not present, defaults to false.
#
# Read more: https://asl.andre601.ch/profiles/#onlineplayers-enabled
#
enabled: false
#
# Set the number that should be used as the new online players count.
# Placeholders resolving to numbers can be used here.
#
# If not present, defaults to current online player count.
#
# Read more: https://asl.andre601.ch/profiles/#onlineplayers-amount
#
amount: 0
+17
View File
@@ -7,6 +7,23 @@ icon: octicons/log-24
This page lists the recent changes made towards the AdvancedServerListAPI.
They are ordered newest to oldest.
## v4.0.0 { #v4.0.0 }
### :octicons-alert-24:{ .changelog-breaking title="Breaking Changes" } Breaking Changes { #v4.0.0-breaking }
- Changed `extraPlayersCount()` and `maxPlayersCount()` from using an Integer to using a String instead.
- This also affects their corresponding `ProfileEntry.Builder` methods.
- Removed all previously deprecated methods.
### :octicons-plus-circle-24:{ .changelog-added title="Added" } Added { #v4.0.0-added }
- New setter methods added to [`ProfileEntry.Builder`][profilentry.builder] class:
- [`onlinePlayersCount(String)`][onlinePlayersCount]
- [`onlinePlayersEnabled(NullBool)`][onlinePlayersEnabled]
[onlinePlayersCount]: reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/builder.md#onlineplayerscount(integer)
[onlinePlayersEnabled]: reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/builder.md#onlineplayersenabled(nullbool)
## v3.3.0 { #v3.3.0 }
### :octicons-plus-circle-24:{ .changelog-added title="Added" } Added { #v3.3.0-added }
@@ -119,6 +119,34 @@ methods:
throws:
- name: 'IllegalArgumentException'
description: 'Thrown by the <code>CheckUtil</code> in case <code>null</code> has been provided as parameter.'
- name: 'onlinePlayersCount'
description: |
Sets the value to resolve into a number by AdvancedServerList.<br>
Strings not resolving into valid numbers will be treated as this option not being set.
parameters:
- name: 'onlinePlayersCount'
description: 'The number of online players to set.'
type: 'String'
attribute:
- 'nullable'
returns: 'This Builder after the max player count has been set. Useful for chaining.'
- name: 'onlinePlayersEnabled'
description: |
Sets whether the online players feature should be enabled.<br>
<br>
Set to <a href="../../../objects/nullbool/#not_set"><code>NullBool.NOT_SET</code></a> to not set this.<br>
<br>
An <code>IllegalArgumentException</code> may be thrown by the <code>CheckUtil</code> should onlinePlayersEnabled be null.
parameters:
- name: 'onlinePlayersEnabled'
description: 'Whether the extra players feature should be enabled or not.'
type: 'NullBool'
attribute:
- 'notnull'
returns: 'This Builder after the NullBool has been set. Useful for chaining.'
throws:
- name: 'IllegalArgumentException'
description: 'Thrown by the <code>CheckUtil</code> in case <code>null</code> has been provided as parameter.'
- name: 'playerCountText'
description: |
Sets the text to override the player count with.<br>
@@ -155,192 +183,6 @@ methods:
name: 'ProfileEntry'
type: 'object'
link: './..'
#
# Deprecated stuff
#
- name: 'setExtraPlayerCount'
description: |
Sets the number of players to add to the online players to use as the new max players value.<br>
This option has no effect when <a href="../#extraplayersenabled()"><code>extraPlayersEnabled</code></a> is set to <a href="../../objects/nullbool/#false"><code>NullBool.FALSE</code></a> or <a href="../../objects/nullbool/#not_set"><code>NullBool.NOT_SET</code></a>.<br>
<br>
Set this to <code>null</code> to not alter the max player count. Alternatively, set <a href="#setextraplayersenabled(nullbool)"><code>setExtraPlayersEnabled(NullBool)</code></a> to <a href="../../objects/nullbool/#false"><code>NullBool.FALSE</code></a>.
returns: 'This Builder after the extra player count has been set. Useful for chaining.'
parameters:
- name: 'extraPlayersCount'
description: 'The number of extra players to add.'
type: Integer
attribute:
- nullable
deprecated: 'Typo in the name. Use <a href="#setextraplayerscount(integer)">setExtraPlayersCount(Integer)</a> instead.'
type:
name: 'Builder'
type: 'object'
- name: 'setExtraPlayersCount'
description: |
Sets the number of players to add to the online players to use as the new max players value.<br>
This option has no effect when <a href="../#extraplayersenabled()"><code>extraPlayersEnabled</code></a> is set to <a href="../../objects/nullbool/#false"><code>NullBool.FALSE</code></a> or <a href="../../objects/nullbool/#not_set"><code>NullBool.NOT_SET</code></a>.<br>
<br>
Set this to <code>null</code> to not alter the max player count. Alternatively, set <a href="#setextraplayersenabled(nullbool)"><code>setExtraPlayersEnabled(NullBool)</code></a> to <a href="../../objects/nullbool/#false"><code>NullBool.FALSE</code></a>.
returns: 'This Builder after the extra player count has been set. Useful for chaining.'
parameters:
- name: 'extraPlayersCount'
description: 'The number of extra players to add.'
type: Integer
attribute:
- nullable
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#extraplayerscount(integer)">extraPlayersCount(Integer)</a> instead.'
type:
name: 'Builder'
type: 'object'
- name: 'setExtraPlayersEnabled'
description: |
Sets whether the extra players feature should be enabled or not.<br>
<br>
Set to <a href="../../objects/nullbool/#not_set"><code>NullBool.NOT_SET</code></a> to not set this.
returns: 'This Builder after the NullBool has been set. Useful for chaining.'
parameters:
- name: 'extraPlayersEnabled'
description: 'Whether the extra players feature should be enabled or not.'
type: NullBool
attribute:
- notnull
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#extraplayersenabled(nullbool)">extraPlayersEnabled(NullBool)</a> instead.'
throws:
- name: 'IllegalArgumentException'
description: 'Thrown by the <code>CheckUtil</code> in case <code>null</code> has been provided as parameter.'
type:
name: 'Builder'
type: 'object'
- name: 'setFavicon'
description: |
Sets the value to use for the favicon.<br>
The following values are supported:
<ul>
<li>URL to a valid PNG file.</li>
<li>File name (with <code>.png</code> extension) matching a file saved in the favicons folder of AdvancedServerList.</li>
<li><code>${player uuid}</code> to display the avatar of the player.</li>
</ul>
returns: 'This Builder after the favicon has been set. Useful for chaining.'
parameters:
- name: 'favicon'
description: 'The favicon to set'
type: String
attribute:
- nullable
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#favicon(string)">favicon(String)</a> instead.'
type:
name: 'Builder'
type: 'object'
- name: 'setHidePlayersEnabled'
description: |
Sets whether the player count should be hidden or not.<br>
<br>
Set to <a href="../../objects/nullbool/#not_set"><code>NullBool.NOT_SET</code></a> to not set this.
returns: 'This Builder after the NullBool has been set. Useful for chaining.'
parameters:
- name: 'hidePlayersEnabled'
description: 'Whether the player count should be hidden or not.'
type: NullBool
attribute:
- notnull
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#hideplayersenabled(nullbool)">hidePlayersEnabled(NullBool)</a> instead.'
throws:
- name: 'IllegalArgumentException'
description: 'Thrown by the <code>CheckUtil</code> in case <code>null</code> has been provided as parameter.'
type:
name: 'Builder'
type: 'object'
- name: 'setMaxPlayersCount'
description: |
Sets the number of max players allowed to join this server.<br>
This option has no effect when <a href="../#maxplayersenabled()"><code>maxPlayersEnabled</code></a> is set to <a href="../../objects/nullbool/#false"><code>NullBool.FALSE</code></a> or <a href="../../objects/nullbool/#not_set"><code>NullBool.NOT_SET</code></a>.<br>
<br>
Set this to <code>null</code> to not alter the max player count. Alternatively, set <a href="#setmaxplayersenabled(nullbool)"><code>setMaxPlayersEnabled(NullBool)</code></a> to <a href="../../objects/nullbool/#false"><code>NullBool.FALSE</code></a>.
returns: 'This Builder after the extra player count has been set. Useful for chaining.'
parameters:
- name: 'maxPlayersCount'
description: 'The number of max players to set.'
type: Integer
attribute:
- nullable
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#maxplayerscount(integer)">maxPlayersCount(Integer)</a> instead.'
type:
name: 'Builder'
type: 'object'
- name: 'setMaxPlayersEnabled'
description: |
Sets whether the max players feature should be enabled.<br>
<br>
Set to <a href="../../objects/nullbool/#not_set"><code>NullBool.NOT_SET</code></a> to not set this.
returns: 'This Builder after the NullBool has been set. Useful for chaining.'
parameters:
- name: 'maxPlayersEnabled'
description: 'Whether the extra players feature should be enabled or not.'
type: NullBool
attribute:
- notnull
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#maxplayersenabled(nullbool)">maxPlayersEnabled(NullBool)</a> instead.'
throws:
- name: 'IllegalArgumentException'
description: 'Thrown by the <code>CheckUtil</code> in case <code>null</code> has been provided as parameter.'
type:
name: 'Builder'
type: 'object'
- name: 'setMotd'
description: |
Sets a new MOTD to use.<br>
<br>
Set to an empty list to not change the MOTD.<br>
Only the first two entries of the list will be considered and any additional ones discarded.
returns: 'This Builder after the motd has been set. Useful for chaining.'
parameters:
- name: 'motd'
description: 'The MOTD to use.'
type: 'List<String>'
attribute:
- notnull
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#motd(string)">motd(String)</a> instead.'
throws:
- name: 'IllegalArgumentException'
description: 'Thrown by the <code>CheckUtil</code> in case <code>null</code> has been provided as parameter.'
type:
name: 'Builder'
type: 'object'
- name: 'setPlayerCountText'
description: |
Sets the text to override the player count with.<br>
<br>
Set to an empty String or <code>null</code> to not alter the player count text.
returns: 'This Builder after the player count text has been set. Useful for chaining.'
parameters:
- name: 'playerCountText'
description: 'The text to show in the player count.'
type: String
attribute:
- nullable
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#playercounttext(string)">playerCountText(String)</a> instead.'
type:
name: 'Builder'
type: 'object'
- name: 'setPlayers'
description: |
Sets the players (lines) to use for the hover.<br>
<br>
Set to an empty list to not change the hover text.
returns: 'This Builder after the players have been set. Useful for chaining.'
parameters:
- name: 'players'
description: 'The lines to set for the hover.'
type: 'List<String>'
attribute:
- notnull
deprecated: 'Method renamed to fit <a href="..">ProfileEntry</a> record more closely. Use <a href="#players(list<string>)">players(List&lt;String&gt;)</a> instead.'
throws:
- name: 'IllegalArgumentException'
description: 'Thrown by the <code>CheckUtil</code> in case <code>null</code> has been provided as parameter.'
type:
name: 'Builder'
type: 'object'
---
# <api__class></api__class> Builder
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+48 -5
View File
@@ -127,7 +127,7 @@ The Value can be one of three possible options, each being checked for in order:
Note that for the name/UUID, the site https://mc-heads.net is being used.
Use the URL option with the `${player uuid}` placeholder if you want to use another service.
/// details | Example
type: example
@@ -161,7 +161,7 @@ When set to true will the player count be replaced with `???`.
In addition are the [`playerCount -> text`](#text) and [`playerCount -> hover`](#hover) options ignored.
If you want to not show any text at all, set this option to `false` (or remove it) and instead use the [`playerCount -> text`](#text) option.
/// details | Example
type: example
@@ -227,7 +227,7 @@ Please take note of the following caveats:
If you want to not show any text, just use a single color (i.e. `text: '<grey>'`) to do so.
This option only supports basic colors and no HEX colors.
/// details | Example
type: example
@@ -267,7 +267,9 @@ Use the [`playerCount -> extraPlayers -> amount`](#extraplayers-amount) option t
The `playerCount -> extraPlayers -> amount` option defines how much should be added to the current online player count to then use as max player count.
Example: Setting this option to `1` while currently 10 players are online will result in `10/11` being displayed on the player count (Assuming it is not being overriden by the [`playerCount -> text`](#text) option).
You can use placeholders that resolve into numbers for this option.
/// details | Example
type: example
@@ -309,7 +311,9 @@ Use the [`playerCount -> maxPlayers -> amount`](#maxplayers-amount) option to se
The `playerCount -> maxPlayers -> amount` option defines the number to use as the server's max players count.
Unlike the [`playerCount -> extraPlayers -> amount`](#extraplayers-amount) option does this one not first add the current online player count to the number to then set.
You can use placeholders that resolve into numbers for this option.
/// details | Example
type: example
@@ -330,5 +334,44 @@ playerCount:
![maxplayers-example](../assets/images/examples/maxplayers-example.jpg){ loading="lazy" }
</div>
///
### OnlinePlayers
<!-- admo:warning Using this option alters the output of <code>playerCount -> extraPlayers</code> -->
The `playerCount -> onlinePlayers` option contains settings to enable and set the number of players online on the server.
#### Enabled { #onlineplayers-enabled }
Enables the online players feature.
Use the [`playerCount -> onlinePlayers -> amount`](#onlineplayers-amount) option to set the online players value itself.
#### Amount { #onlineplayers-amount }
Sets the number to display as the server's only player count.
You can use placeholders that resolve into numbers for this option.
/// details | Example
type: example
```yaml title="YAML file
priority: 0
# Hides the MOTD for demonstration purposes
motd:
- '<grey>'
- '<grey>'
playerCount:
onlinePlayers:
enabled: true
amount: 10
```
<div class="result" markdown>
![onlineplayers-example](../assets/images/examples/onlineplayers-example.png)
</div>
///
+19 -1
View File
@@ -44,7 +44,8 @@ These placeholders use values given by the server/proxy AdvancedServerList runs
[^4]:
A comma-separated list of world (On Paper) or Server (On BungeeCord/Velocity) names can be provided to display the added numbers of players in these worlds/servers.
**Example:** `${server playersOnline lobby1,lobby2}` will display the collective numbers of players in the servers `lobby1` and `lobby2`.
**Example:** `${server playersOnline lobby1,lobby2}` will display the collective numbers of players in the servers `lobby1` and `lobby2`.
Using the [onlinePlayers' `amount`](index.md#onlineplayers-amount) option will modify the output of this placeholder, except when used in [`condition`](index.md#condition).
[^5]:
Using either the [extraPlayers' `amount`](index.md#extraplayers-amount) or [maxPlayers' `amount`](index.md#maxplayers-amount) option will make this placeholder return the modified max players count.
Only exception to this rule is when the placeholder is used in the [`condition`](index.md#condition) option in which case it returns the actual max player count of the proxy/server.
@@ -52,6 +53,23 @@ These placeholders use values given by the server/proxy AdvancedServerList runs
An optional server name can be provided to display the IP/Domain associated with that server. This only works on BungeeCord or Velocity.
**Example:** `${server host survival}` would display the IP/Domain associated with the `survival` server.
### Proxy
These placeholders are only available on the BungeeCord and Velocity versions of AdvancedServerList.
/// note
Servers are pinged every 10 seconds by the plugin and cached for that time period.
///
| Placeholders | Description | Default[^7] |
|------------------------------|-------------------------------------------------------------------|-------------|
| `${proxy status <name>}` | Returns `online` or `offline` based on the Server's availability. | `offline` |
| `${proxy motd <name>}` | Returns the Server's MOTD as MiniMessage String. | `none` |
| `${proxy players <name>}` | Returns the number of online Players on the Server. | `0` |
| `${proxy maxPlayers <name>}` | Returns the max number of Players allowed to join the Server. | `0` |
[^7]: The default value returned, should the Server or parts of it not be available.
### Maintenance
These placeholders require the [Maintenance](https://hangar.papermc.io/kennytv/Maintenance) plugin to work.
+1 -1
View File
@@ -85,7 +85,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
@@ -149,6 +149,11 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
libraryManager.loadLibrary(lib);
}
@Override
public void startScheduler(){
// Unused
}
@Override
public AdvancedServerList<CachedServerIcon> getCore(){
return core;
@@ -74,6 +74,11 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
event.setMaxPlayers(maxPlayers);
}
@Override
public void setOnlinePlayers(int onlinePlayers){
event.setNumPlayers(onlinePlayers);
}
@Override
public void setMotd(Component component){
event.motd(component);
@@ -70,7 +70,7 @@ public record FakePlayerProfile(String name, UUID uuid) implements PlayerProfile
@Override
public @NotNull PlayerTextures getTextures(){
return new FakePlayeerTextures();
return new FakePlayerTextures();
}
@Override
@@ -153,7 +153,7 @@ public record FakePlayerProfile(String name, UUID uuid) implements PlayerProfile
return Collections.emptyMap();
}
private static record FakePlayeerTextures() implements PlayerTextures{
private record FakePlayerTextures() implements PlayerTextures{
@Override
public boolean isEmpty(){
@@ -94,16 +94,22 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
ProfileEntry entry = ProfileManager.merge(profile);
Integer onlinePlayers = null;
if(ProfileManager.checkOption(entry.onlinePlayersEnabled())){
onlinePlayers = parseNumberOption(entry.onlinePlayersCount(), pl, player, server);
online = onlinePlayers == null ? online : onlinePlayers;
}
Integer maxPlayers = null;
if(ProfileManager.checkOption(entry.maxPlayersEnabled())){
max = entry.maxPlayersCount() == null ? 0 : entry.maxPlayersCount();
maxPlayers = entry.maxPlayersCount();
maxPlayers = parseNumberOption(entry.maxPlayersCount(), pl, player, server);
max = maxPlayers == null ? 0 : maxPlayers;
}
Integer extraPlayers = null;
if(ProfileManager.checkOption(entry.extraPlayersEnabled())){
max = online + (entry.extraPlayersCount() == null ? 0 : entry.extraPlayersCount());
extraPlayers = entry.extraPlayersCount();
extraPlayers = parseNumberOption(entry.extraPlayersCount(), pl, player, server);
max = online + (extraPlayers == null ? 0 : extraPlayers);
}
BukkitServer finalServer = new PaperServerImpl(plugin.getWorldCache().worlds(), online, max, host);
@@ -114,6 +120,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
case "playercount_text" -> getOption(entry.playerCountText(), pl, player, finalServer);
case "playercount_extraplayers" -> extraPlayers == null ? "null" : String.valueOf(extraPlayers);
case "playercount_maxplayers" -> maxPlayers == null ? "null" : String.valueOf(maxPlayers);
case "playercount_onlineplayers" -> onlinePlayers == null ? "null" : String.valueOf(onlinePlayers);
case "server_playersmax" -> String.valueOf(max);
default -> null;
};
@@ -134,8 +141,21 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
private String getOption(List<String> list, Player pl, BukkitPlayer player, BukkitServer server){
return ComponentParser.list(list)
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.toString();
}
private Integer parseNumberOption(String option, Player pl, BukkitPlayer player, BukkitServer server){
String parsed = ComponentParser.text(option)
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.toString();
try{
return Integer.parseInt(parsed);
}catch(NumberFormatException ex){
return null;
}
}
}
@@ -73,19 +73,19 @@ public class PaperServerPlaceholders extends PlaceholderProvider{
}
case "playersMax" -> {
if(args.length >= 2)
yield null;
yield "";
yield String.valueOf(paperServer.getPlayersMax());
}
case "host" -> {
if(args.length >= 2)
yield null;
yield "";
yield paperServer.getHost();
}
case "whitelistEnabled" -> {
if(args.length >= 2)
yield null;
yield "";
yield String.valueOf(Bukkit.hasWhitelist());
}
+2 -2
View File
@@ -37,10 +37,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.version>4.13.0</plugin.version>
<plugin.version>5.0.3</plugin.version>
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
<api.version>3.3.0</api.version>
<api.version>4.0.0</api.version>
<dependency.adventure-api>4.17.0</dependency.adventure-api>
<dependency.adventure-text-minimessage>4.17.0</dependency.adventure-text-minimessage>
+12 -1
View File
@@ -18,7 +18,7 @@
]
},
{
"description": "Use Codeberg packages for asl-api",
"description": "Use Codeberg packages for Own API stuff",
"matchPackageNames": [
"ch.andre601.asl-api:api",
"ch.andre601.asl-api:parent",
@@ -58,6 +58,17 @@
"https://repo.viaversion.com"
]
},
{
"description": "Use Sonatype for Libby",
"matchPackageNames": [
"com.alessiodp.libby:libby-bungee",
"com.alessiodp.libby:libby-paper",
"com.alessiodp.libby:libby-velocity"
],
"registryUrls": [
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
]
},
{
"description": "Apply label for Bukkit platform",
"matchFileNames": ["bukkit/pom.xml"],
+1 -1
View File
@@ -1,3 +1,3 @@
mkdocs-material==9.5.31
mkdocs-material==9.5.39
mkdocs-glightbox==0.4.0
git+https://github.com/Andre601/mkdocs-pagenav-generator
+1 -1
View File
@@ -76,7 +76,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
@@ -34,6 +34,7 @@ import ch.andre601.advancedserverlist.velocity.listeners.JoinEvent;
import ch.andre601.advancedserverlist.velocity.listeners.PingEvent;
import ch.andre601.advancedserverlist.velocity.logging.VelocityLogger;
import ch.andre601.advancedserverlist.velocity.objects.placeholders.VelocityPlayerPlaceholders;
import ch.andre601.advancedserverlist.velocity.objects.placeholders.VelocityProxyPlaceholders;
import ch.andre601.advancedserverlist.velocity.objects.placeholders.VelocityServerPlaceholders;
import com.alessiodp.libby.Library;
import com.alessiodp.libby.VelocityLibraryManager;
@@ -46,6 +47,8 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerPing;
import com.velocitypowered.api.scheduler.ScheduledTask;
import com.velocitypowered.api.util.Favicon;
import de.myzelyam.api.vanish.VelocityVanishAPI;
import org.bstats.charts.SimplePie;
@@ -58,10 +61,14 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class VelocityCore implements PluginCore<Favicon>{
private final Logger logger = LoggerFactory.getLogger("AdvancedServerList");
private final Map<String, ServerPing> fetchedServers = new ConcurrentHashMap<>();
private final PluginLogger pluginLogger;
private final ProxyServer proxy;
@@ -73,6 +80,8 @@ public class VelocityCore implements PluginCore<Favicon>{
private VelocityLibraryManager<VelocityCore> libraryManager = null;
private ScheduledTask scheduledTask = null;
@Inject
public VelocityCore(ProxyServer proxy, @DataDirectory Path path, Metrics.Factory metrics){
this.pluginLogger = new VelocityLogger(this, this.logger);
@@ -84,12 +93,15 @@ public class VelocityCore implements PluginCore<Favicon>{
@Subscribe
public void init(ProxyInitializeEvent event){
this.core = AdvancedServerList.init(this, VelocityPlayerPlaceholders.init(), VelocityServerPlaceholders.init(this));
this.core = AdvancedServerList.init(this,
VelocityPlayerPlaceholders.init(), VelocityServerPlaceholders.init(this), VelocityProxyPlaceholders.init(this));
}
@Subscribe
public void pluginDisable(ProxyShutdownEvent event){
core.disable();
if(scheduledTask != null)
scheduledTask.cancel();
}
@Override
@@ -145,6 +157,13 @@ public class VelocityCore implements PluginCore<Favicon>{
libraryManager.loadLibrary(lib);
}
@Override
public void startScheduler(){
scheduledTask = getProxy().getScheduler().buildTask(this, this::fetchServers)
.repeat(10, TimeUnit.SECONDS)
.schedule();
}
@Override
public AdvancedServerList<Favicon> getCore(){
return core;
@@ -208,4 +227,18 @@ public class VelocityCore implements PluginCore<Favicon>{
return players.size();
}
public Map<String, ServerPing> getFetchedServers(){
return fetchedServers;
}
private void fetchServers(){
fetchedServers.clear();
getProxy().getAllServers().forEach(server -> server.ping().whenComplete((ping, throwable) -> {
if(throwable != null)
return;
fetchedServers.put(server.getServerInfo().getName(), ping);
}));
}
}
@@ -82,6 +82,11 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
builder.maximumPlayers(maxPlayers);
}
@Override
public void setOnlinePlayers(int onlinePlayers){
builder.onlinePlayers(onlinePlayers);
}
@Override
public void setMotd(Component component){
builder.description(component);
@@ -0,0 +1,62 @@
package ch.andre601.advancedserverlist.velocity.objects.placeholders;
import ch.andre601.advancedserverlist.api.PlaceholderProvider;
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
import ch.andre601.advancedserverlist.velocity.VelocityCore;
import com.velocitypowered.api.proxy.server.ServerPing;
public class VelocityProxyPlaceholders extends PlaceholderProvider{
private final VelocityCore plugin;
private VelocityProxyPlaceholders(VelocityCore plugin){
super("proxy");
this.plugin = plugin;
}
public static VelocityProxyPlaceholders init(VelocityCore plugin){
return new VelocityProxyPlaceholders(plugin);
}
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
String[] args = placeholder.split("\\s", 2);
if(args.length < 2)
return null;
ServerPing ping = plugin.getFetchedServers().get(args[1]);
return switch(args[0]){
case "status" -> ping == null ? "offline" : "online";
case "motd" -> {
if(ping == null)
yield "none";
yield ComponentParser.toMMString(ping.getDescriptionComponent());
}
case "players" -> {
if(ping == null)
yield "0";
ServerPing.Players players = ping.getPlayers().orElse(null);
if(players == null)
yield "0";
yield String.valueOf(players.getOnline());
}
case "maxPlayers" -> {
if(ping == null)
yield "0";
ServerPing.Players players = ping.getPlayers().orElse(null);
if(players == null)
yield "0";
yield String.valueOf(players.getMax());
}
default -> null;
};
}
}
@@ -80,18 +80,18 @@ public class VelocityServerPlaceholders extends PlaceholderProvider{
}
case "playersMax" -> {
if(args.length >= 2)
yield null;
yield "";
yield String.valueOf(proxy.getPlayersMax());
}
case "host" -> {
if(args.length > 2)
yield null;
yield "";
if(args.length == 2 && args[1] != null && !args[1].isEmpty()){
RegisteredServer info = proxy.getServers().get(args[1]);
if(info == null)
yield null;
yield "";
yield info.getServerInfo().getAddress().getHostString();
}
+2 -2
View File
@@ -52,13 +52,13 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.6</version>
<version>1.5.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3.1</version>
<version>5.4</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -53,7 +53,7 @@ public class VersionUploader{
if(args.length == 0){
LOGGER.warn("MISSING ARGUMENT!");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar [--dryrun] --all | --modrinth | --hangar");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar --all | --modrinth | --hangar [--dryrun]");
System.exit(1);
return;
}
@@ -84,7 +84,7 @@ public class VersionUploader{
}
default -> {
LOGGER.warn("Unknown argument '{}' provided.", args[0]);
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar [--dryrun] --all | --modrinth | --hangar");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar --all | --modrinth | --hangar [--dryrun]");
System.exit(1);
return;
}
@@ -50,9 +50,9 @@ public class CodebergReleaseFetcher{
public static CodebergRelease fetch(){
String tag = System.getenv("CI_COMMIT_TAG");
String codbergToken = System.getenv("CODEBERG_API_TOKEN");
String codebergToken = System.getenv("CODEBERG_API_TOKEN");
if(tag == null || codbergToken == null || tag.isEmpty() || codbergToken.isEmpty()){
if(tag == null || codebergToken == null || tag.isEmpty() || codebergToken.isEmpty()){
LOGGER.warn("Cannot fetch release data. Either Tag or Codeberg token was null/empty.");
return null;
}
@@ -64,7 +64,7 @@ public class CodebergReleaseFetcher{
.url(url)
.header("User-Agent", "VersionUploader-CodebergReleaseFetcher/v1.0.0")
.header("Accept", "application/json")
.header("Authorization", "token " + codbergToken)
.header("Authorization", "token " + codebergToken)
.build();
try(Response response = CLIENT.newCall(request).execute()){
@@ -25,8 +25,8 @@
package ch.andre601.advancedserverlist.versionuploader.modrinth;
import ch.andre601.advancedserverlist.versionuploader.ReleaseHolder;
import ch.andre601.advancedserverlist.versionuploader.PlatformInfo;
import ch.andre601.advancedserverlist.versionuploader.ReleaseHolder;
import ch.andre601.advancedserverlist.versionuploader.VersionUploader;
import ch.andre601.advancedserverlist.versionuploader.data.CodebergRelease;
import com.google.gson.Gson;
@@ -143,7 +143,8 @@ public class ModrinthVersionUploader{
String url = versionUrl + projectVersion.getId();
logger.info("Created new release!");
logger.info("Link: {}", url);
logger.info("Link: {}", url);
logger.info("Platform: {}", platforms.get(index).getPlatform());
releaseHolder.addRelease(
"modrinth",