Compare commits

...
68 Commits
Author SHA1 Message Date
Andre601 a5ca6fb53e Bump version 2024-03-27 16:19:09 +01:00
Andre601 164a4823e8 Fix wrong regex for LibertyBansPlaceholders and limit to 2 results 2024-03-27 16:18:27 +01:00
Andre601 352191695a Merge pull request 'Remove dependencies section' (#251) from docs/remove-dependencies-section into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/251
2024-03-19 20:49:51 +00:00
Andre601 b2235e1d8b Fix formatting 2024-03-19 20:45:47 +00:00
Andre601 324b6d6f82 Try without remote branches 2024-03-19 20:39:29 +00:00
Andre601 fd6e2e736f Merge branch 'master' into docs/remove-dependencies-section 2024-03-19 20:34:26 +00:00
Andre601 efd5164b8e Add attr_list 2024-03-19 20:32:10 +00:00
Andre601 cdb86ae83f Use branch option for git clone 2024-03-19 20:30:11 +00:00
Andre601 90c02da02e Update default.yml and config.yml examples 2024-03-19 20:19:28 +00:00
Andre601 53d56c5891 Different wording 2024-03-19 20:16:07 +00:00
Andre601 7dd02fa0e5 Try without branch option 2024-03-19 20:15:06 +00:00
Andre601 e02b944181 revert 299eff1b0d
revert Try without branch
2024-03-19 20:14:42 +00:00
Andre601 299eff1b0d Try without branch 2024-03-19 20:14:10 +00:00
Andre601 aa24ab336b Remove .pages.yml file 2024-03-19 20:13:39 +00:00
Andre601 a8b9e69e30 Remove dependencies section 2024-03-19 20:11:42 +00:00
Andre601 065c9abf9c Try with just the branch option. 2024-03-19 20:09:49 +00:00
Andre601 bdc9668b29 Merge pull request 'Fix link' (#250) from docs/fix-link into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/250
2024-03-19 20:03:49 +00:00
Andre601 7d1abdd2b2 Fix link 2024-03-19 20:03:28 +00:00
Andre601 667c642708 Merge pull request 'Add "Available on Codeberg" badge' (#248) from docs/available-on-codeberg-badge into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/248
2024-03-19 19:56:12 +00:00
Andre601 79b13ceab6 Merge branch 'master' into docs/available-on-codeberg-badge 2024-03-19 19:55:45 +00:00
Andre601 169f560b2c Add mastodon posting 2024-03-19 15:26:56 +00:00
Andre601 7e8c41c27a Merge pull request 'Update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.13.0' (#249) from renovate/org.apache.maven.plugins-maven-compiler-plugin-3.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/249
2024-03-19 12:03:54 +00:00
Andre601's Bot 973966c844 Update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.13.0 2024-03-19 12:01:18 +00:00
Andre601 eee90cc02f Remove not needed content 2024-03-18 22:10:33 +00:00
Andre601 ecf052b955 Remove unused setting 2024-03-18 22:09:43 +00:00
Andre601 a791c86df0 Merge branch 'master' into docs/available-on-codeberg-badge 2024-03-18 22:06:38 +00:00
Andre601 63d0b0ac62 Fix wrong workflow file target 2024-03-18 22:06:26 +00:00
Andre601 c46bc37818 Merge branch 'master' into docs/available-on-codeberg-badge 2024-03-18 22:05:13 +00:00
Andre601 268d5b84c9 Add quotes 2024-03-18 22:05:05 +00:00
Andre601 0c63abfac8 Merge branch 'master' into docs/available-on-codeberg-badge 2024-03-18 22:02:59 +00:00
Andre601 35ca151424 Set default branch directly 2024-03-18 22:02:45 +00:00
Andre601 e28800f72f Add evaluate when check 2024-03-18 21:43:51 +00:00
Andre601 8232357aba Add "Available on Codeberg" badge 2024-03-18 21:35:28 +00:00
Andre601 eae7f1117c Merge pull request 'Create PR-preview' (#247) from feature/pr-preview into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/247
2024-03-18 21:26:11 +00:00
Andre601 d25053b285 Add switch and set-branches git commands 2024-03-18 21:25:54 +00:00
Andre601 57273bd265 Use bot token for docs publish 2024-03-18 20:44:11 +00:00
Andre601 9cf694a7d6 Use bot token 2024-03-18 20:43:38 +00:00
Andre601 5bc0c7b843 Create PR-preview 2024-03-18 20:35:45 +00:00
Andre601 1c48fd61bc Fix wrong target URL 2024-03-18 19:54:15 +00:00
Andre601 8e622b4038 Add woodpecker file to CI run 2024-03-18 19:51:37 +00:00
Andre601 35e37bca2e Move site to dedicated repository 2024-03-18 19:50:47 +00:00
Andre601 cdb508994f Improve default.yml file 2024-03-18 15:53:20 +01:00
Andre601 1113c41379 Merge pull request 'Update dependency mkdocs-material to v9.5.14' (#246) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/246
2024-03-18 12:05:24 +00:00
Andre601's Renovate Bot d186ca82a2 Update dependency mkdocs-material to v9.5.14 2024-03-18 12:01:09 +00:00
Andre601 5cda9e819b Add missing changelog entry 2024-03-17 01:30:19 +00:00
Andre601 fe5a73440b Update API Javadocs URL 2024-03-16 21:39:01 +00:00
Andre601 a91e839f8c Update API reference 2024-03-14 14:53:36 +01:00
Andre601 d4668e0e76 Add PostServerListSetEvent 2024-03-14 14:08:17 +01:00
Andre601 305f3452c4 Merge pull request 'Update dependency com.google.guava:guava to v33.1.0-jre' (#245) from renovate/com.google.guava-guava-33.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/245
2024-03-14 12:02:24 +00:00
Andre601's Renovate Bot fec3361fd7 Update dependency com.google.guava:guava to v33.1.0-jre 2024-03-14 12:01:22 +00:00
Andre601 f0861ffa6a Merge pull request 'Allow handling of options while Maintenance is active' (#244) from feature/configure-maintenance-support into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/244
2024-03-13 23:15:49 +00:00
Andre601 cfca3f72dc Fix ambigous method call getBoolean 2024-03-13 22:04:17 +01:00
Andre601 aca83e8350 Update priorities and bump version 2024-03-13 20:44:08 +01:00
Andre601 8383c8b97f Allow handling of options while Maintenance is active 2024-03-13 20:33:41 +01:00
Andre601 3d1ddaa782 Update Nav 2024-03-13 16:06:07 +01:00
Andre601 1d615e252f Update requirements.txt 2024-03-13 02:51:02 +01:00
Andre601 310e72d048 Don't use awesome-pages 2024-03-13 02:50:31 +01:00
Andre601 2754bf13aa Allow support for vanished players 2024-03-10 14:01:10 +01:00
Andre601 9ff5fcdaa7 Unify Placeholder parsing system. 2024-03-07 22:01:18 +01:00
Andre601 0ba7ed6ece Merge pull request 'Update dependency com.viaversion:viaversion-api to v4.9.3' (#241) from renovate/com.viaversion-viaversion-api-4.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/241
2024-03-06 12:46:39 +00:00
Andre601 2d8c774401 Merge pull request 'Update dependency mkdocs-material to v9.5.13' (#242) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/242
2024-03-06 12:46:23 +00:00
Andre601's Renovate Bot f68be63f64 Update dependency mkdocs-material to v9.5.13 2024-03-06 12:14:43 +00:00
Andre601's Renovate Bot 2695b393d8 Update dependency com.viaversion:viaversion-api to v4.9.3 2024-03-06 12:14:35 +00:00
Andre601 55821d2edf Merge pull request 'Update dependency ch.qos.logback:logback-classic to v1.5.3' (#240) from renovate/ch.qos.logback-logback-classic-1.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/240
2024-03-05 12:02:36 +00:00
Andre601's Renovate Bot b64e32503e Update dependency ch.qos.logback:logback-classic to v1.5.3 2024-03-05 12:01:13 +00:00
Andre601 c5ab9b118f Use code highlighting for expression examples 2024-03-05 02:11:01 +01:00
Andre601 6cc54349b5 Fix typo with fontawesome 2024-03-05 01:02:47 +00:00
Andre601 98d2de975e Add divider lines to optional dependencies 2024-03-05 00:59:59 +00:00
67 changed files with 1031 additions and 642 deletions

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
when:
- event: pull_request
path:
include: ['.woodpecker/pr_preview.yml', 'requirements.txt', 'mkdocs.yml', 'docs/**']
variables:
setup_git: &setup_git
- apk add git
- git config --global user.email "andre@andre601.ch"
- git config --global user.name "ASL Docs Builder"
steps:
cloneTargetRepo:
image: alpine:3.18.4
commands:
- chmod -R a+w .
- <<: *setup_git
- git clone https://codeberg.org/Andre601/asl-docs.git site
- chmod -R a+w site
- cd site
- git switch pr-${CI_COMMIT_PULL_REQUEST} 2>/dev/null || git switch -c pr-${CI_COMMIT_PULL_REQUEST}
buildDocs:
image: woodpeckerci/plugin-mkdocs:latest
settings:
pip_install_file: requirements.txt
commitAndPush:
image: alpine:3.18.4
secrets:
- bot_token
commands:
- <<: *setup_git
- mv domains site/.domains
- cd site
- git remote add upstream https://$BOT_TOKEN@codeberg.org/Andre601/asl-docs.git
- git add --all
- git commit -m "Update Preview for PR ${CI_COMMIT_PULL_REQUEST} ($( env TZ=Europe/Zurich date +"%d.%m.%Y %Z" )) [SKIP CI]"
- git push --set-upstream upstream pr-${CI_COMMIT_PULL_REQUEST} -f
writeComment:
image: mcs94/gitea-comment
secrets:
- bot_token
settings:
gitea_address: https://codeberg.org
gitea_token:
from_secret: BOT_TOKEN
comment: |-
Build-preview created!
| Name | Value |
|--------|-------------------------------------------------------|
| Commit | ${CI_COMMIT_SHA} |
| Link | https://asl.andre601.ch/@pr-${CI_COMMIT_PULL_REQUEST} |
+11 -1
View File
@@ -33,4 +33,14 @@ steps:
- "velocity/target/AdvancedServerList-*.jar"
- "addons/banplugins/target/AdvancedServerList-*.jar"
api_key:
from_secret: CB_TOKEN
from_secret: CB_TOKEN
postOnMastodon:
image: woodpeckerci/plugin-mastodon-post
when:
- status: ['success']
settings:
server: https://blobfox.coffee
access_token:
from_secret: MASTODON_TOKEN
status: '${CI_COMMIT_TAG} of #AdvancedServerList has been released and can be found on Modrinth (https://modrinth.com/plugin/AdvancedServerList), Hangar (https://hangar.papermc.io/Andre_601/AdvancedServerList) and Codeberg (https://codeberg.org/Andre601/AdvancedServerList).'
visibility: public
+5 -5
View File
@@ -1,8 +1,8 @@
when:
- branch: master
- branch: '${CI_REPO_DEFAULT_BRANCH}'
event: push
path:
include: ['requirements.txt', 'mkdocs.yml', 'docs/**']
include: ['.woodpecker/publish_docs.yml', 'requirements.txt', 'mkdocs.yml', 'docs/**']
variables:
setup_git: &setup_git
@@ -16,7 +16,7 @@ steps:
commands:
- chmod -R a+w .
- <<: *setup_git
- git clone -b pages https://codeberg.org/Andre601/AdvancedServerList.git site
- git clone -b pages https://codeberg.org/Andre601/asl-docs site
- chmod -R a+w site
buildDocs:
image: woodpeckerci/plugin-mkdocs:latest
@@ -25,12 +25,12 @@ steps:
commitAndPush:
image: alpine:3.18.4
secrets:
- cb_token
- bot_token
commands:
- <<: *setup_git
- mv domains site/.domains
- cd site
- git remote set-url origin https://$CB_TOKEN@codeberg.org/Andre601/AdvancedServerList.git
- git remote set-url origin https://$BOT_TOKEN@codeberg.org/Andre601/asl-docs.git
- git add --all
- git commit -m "Update AdvancedServerList Docs ($( env TZ=Europe/Zurich date +"%d.%m.%Y %Z" )) [SKIP CI]"
- git push
+1 -1
View File
@@ -122,7 +122,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
</plugin>
</plugins>
</build>
@@ -30,8 +30,6 @@ import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.banplugins.providers.AdvancedBanProvider;
import java.util.Arrays;
public class AdvancedBanPlaceholders extends PlaceholderProvider{
private final AdvancedBanProvider provider = new AdvancedBanProvider();
@@ -42,7 +40,7 @@ public class AdvancedBanPlaceholders extends PlaceholderProvider{
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
String[] args = placeholder.split("\\s");
String[] args = placeholder.split("\\s", 2);
return switch(args[0]) {
// Mute-related placeholders
@@ -52,9 +50,6 @@ public class AdvancedBanPlaceholders extends PlaceholderProvider{
if(args.length == 1)
yield provider.muteDuration(player);
if(args.length > 2)
yield null;
boolean fromStart = Boolean.getBoolean(args[1]);
yield provider.muteDuration(player, fromStart);
}
@@ -62,9 +57,7 @@ public class AdvancedBanPlaceholders extends PlaceholderProvider{
if(args.length == 1)
yield provider.muteExpirationDate(player);
String pattern = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
yield provider.banExpirationDate(player, pattern);
yield provider.banExpirationDate(player, args[1]);
}
// Ban-related placeholders
@@ -74,9 +67,6 @@ public class AdvancedBanPlaceholders extends PlaceholderProvider{
if(args.length == 1)
yield provider.banDuration(player);
if(args.length > 2)
yield null;
boolean fromStart = Boolean.getBoolean(args[1]);
yield provider.banDuration(player, fromStart);
}
@@ -84,9 +74,7 @@ public class AdvancedBanPlaceholders extends PlaceholderProvider{
if(args.length == 1)
yield provider.banExpirationDate(player);
String pattern = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
yield provider.banExpirationDate(player, pattern);
yield provider.banExpirationDate(player, args[1]);
}
// Unknown/Invalid placeholder.
@@ -30,8 +30,6 @@ import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.banplugins.providers.LibertyBansProvider;
import java.util.Arrays;
public class LibertyBansPlaceholders extends PlaceholderProvider{
private final LibertyBansProvider provider = LibertyBansProvider.create();
@@ -42,7 +40,7 @@ public class LibertyBansPlaceholders extends PlaceholderProvider{
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
String[] args = placeholder.split("\\.");
String[] args = placeholder.split("\\s", 2);
return switch(args[0]){
// Mute-related placeholders
@@ -52,9 +50,7 @@ public class LibertyBansPlaceholders extends PlaceholderProvider{
if(args.length == 1)
yield provider.muteExpirationDate(player);
String pattern = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
yield provider.muteExpirationDate(player, pattern);
yield provider.muteExpirationDate(player, args[1]);
}
// Ban-related placeholders
@@ -64,9 +60,7 @@ public class LibertyBansPlaceholders extends PlaceholderProvider{
if(args.length == 1)
yield provider.banExpirationDate(player);
String pattern = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
yield provider.banExpirationDate(player, pattern);
yield provider.banExpirationDate(player, args[1]);
}
// Unknown/Invalid placeholder
+17 -1
View File
@@ -64,6 +64,8 @@
<version>${api.version}</version>
<scope>compile</scope>
</dependency>
<!-- BungeeCord API -->
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
@@ -78,6 +80,8 @@
<type>javadoc</type>
<scope>provided</scope>
</dependency>
<!-- Adventure Library. Needs to be shaded in -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
@@ -96,18 +100,30 @@
<version>4.3.2</version>
<scope>compile</scope>
</dependency>
<!-- Metrics -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<!-- Configurate -->
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<!-- Plugins -->
<dependency>
<groupId>com.github.LeonMangler</groupId>
<artifactId>PremiumVanishAPI</artifactId>
<version>2.9.0-4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@@ -122,7 +138,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -35,13 +35,18 @@ import ch.andre601.advancedserverlist.core.AdvancedServerList;
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
import de.myzelyam.api.vanish.BungeeVanishAPI;
import net.md_5.bungee.api.Favicon;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
import org.bstats.bungeecord.Metrics;
import org.bstats.charts.SimplePie;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
@@ -51,7 +56,7 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
@Override
public void onEnable(){
this.core = AdvancedServerList.init(this, BungeePlayerPlaceholders.init(), BungeeServerPlaceholders.init());
this.core = AdvancedServerList.init(this, BungeePlayerPlaceholders.init(), BungeeServerPlaceholders.init(this));
}
@Override
@@ -133,4 +138,15 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
public Favicon createFavicon(BufferedImage image) throws IllegalArgumentException{
return Favicon.create(image);
}
public int getOnlinePlayers(ServerInfo server){
List<ProxiedPlayer> players = new ArrayList<>(server == null ? getProxy().getPlayers() : server.getPlayers());
// Exclude players when PremiumVanish is enabled and player is hidden.
if(getProxy().getPluginManager().getPlugin("PremiumVanish") != null){
players.removeIf(BungeeVanishAPI::isInvisible);
}
return players.size();
}
}
@@ -147,7 +147,7 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
@Override
public int getOnlinePlayers(){
return ping.getPlayers().getOnline();
return plugin.getOnlinePlayers(null);
}
@Override
@@ -25,12 +25,13 @@
package ch.andre601.advancedserverlist.bungeecord.listeners;
import ch.andre601.advancedserverlist.api.bungeecord.events.PostServerListSetEvent;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.bungeecord.BungeeCordCore;
import ch.andre601.advancedserverlist.core.events.PingEventHandler;
import net.md_5.bungee.api.event.ProxyPingEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.event.EventPriority;
public class PingEvent implements Listener{
@@ -41,8 +42,10 @@ public class PingEvent implements Listener{
plugin.getProxy().getPluginManager().registerListener(plugin, this);
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = 90) // Maintenance has Event Priority 80, so we need to be AFTER it.
public void onProxyPing(ProxyPingEvent event){
PingEventHandler.handleEvent(new BungeeEventWrapper(plugin, event));
ProfileEntry entry = PingEventHandler.handleEvent(new BungeeEventWrapper(plugin, event));
plugin.getProxy().getPluginManager().callEvent(new PostServerListSetEvent(entry));
}
}
@@ -29,18 +29,22 @@ import ch.andre601.advancedserverlist.api.PlaceholderProvider;
import ch.andre601.advancedserverlist.api.bungeecord.objects.BungeeProxy;
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.bungeecord.BungeeCordCore;
import net.md_5.bungee.api.config.ServerInfo;
import java.net.InetSocketAddress;
public class BungeeServerPlaceholders extends PlaceholderProvider{
private BungeeServerPlaceholders(){
private final BungeeCordCore plugin;
private BungeeServerPlaceholders(BungeeCordCore plugin){
super("server");
this.plugin = plugin;
}
public static BungeeServerPlaceholders init(){
return new BungeeServerPlaceholders();
public static BungeeServerPlaceholders init(BungeeCordCore plugin){
return new BungeeServerPlaceholders(plugin);
}
@Override
@@ -64,7 +68,7 @@ public class BungeeServerPlaceholders extends PlaceholderProvider{
if(info == null)
continue;
players += info.getPlayers().size();
players += plugin.getOnlinePlayers(info);
}
yield String.valueOf(players);
+6 -4
View File
@@ -41,7 +41,7 @@
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<plugin.config.version>4</plugin.config.version>
<plugin.config.version>5</plugin.config.version>
</properties>
<repositories>
@@ -73,7 +73,7 @@
<dependency>
<groupId>ch.andre601</groupId>
<artifactId>expressionparser</artifactId>
<version>v1.2.0</version>
<version>1.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -102,6 +102,8 @@
<version>4.16.0</version>
<scope>provided</scope>
</dependency>
<!-- Misc -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
@@ -117,7 +119,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.0.0-jre</version>
<version>33.1.0-jre</version>
<scope>provided</scope>
</dependency>
@@ -156,7 +158,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -46,7 +46,7 @@ public class AdvancedServerList<F>{
private final FileHandler fileHandler;
private final CommandHandler commandHandler;
private final PlayerHandler playerHandler;
private final AdvancedServerListAPI api = AdvancedServerListAPI.get();
private static final AdvancedServerListAPI api = AdvancedServerListAPI.get();
private final ProfileConditionParser parser = ProfileConditionParser.create();
private UpdateChecker updateChecker;
@@ -59,7 +59,7 @@ public class AdvancedServerList<F>{
this.commandHandler = new CommandHandler(this);
this.playerHandler = new PlayerHandler(this);
placeholders.forEach(this.api::addPlaceholderProvider);
placeholders.forEach(AdvancedServerList.getApi()::addPlaceholderProvider);
load();
}
@@ -88,7 +88,7 @@ public class AdvancedServerList<F>{
return version;
}
public AdvancedServerListAPI getApi(){
public static AdvancedServerListAPI getApi(){
return api;
}
@@ -44,11 +44,11 @@ public class PingEventHandler{
private static PAPIUtil papiUtil = null;
private static MaintenanceUtil maintenanceUtil = null;
public static <F, P extends GenericPlayer> void handleEvent(GenericEventWrapper<F, P> event){
public static <F, P extends GenericPlayer> ProfileEntry handleEvent(GenericEventWrapper<F, P> event){
event.getPlugin().getPluginLogger().debug(PingEventHandler.class, "Received ping event. Handling it...");
if(event.isInvalidProtocol() || event.isMaintenanceModeActive()){
event.getPlugin().getPluginLogger().debug(PingEventHandler.class, "Not handling event. Either protocol was invalid of Maintenance is enabled.");
return;
if(event.isInvalidProtocol()){
event.getPlugin().getPluginLogger().debug(PingEventHandler.class, "Not handling event. Protocol was invalid.");
return null;
}
PluginCore<F> plugin = event.getPlugin();
@@ -70,7 +70,7 @@ public class PingEventHandler{
if(profile == null){
logger.debugWarn(PingEventHandler.class, "Server List Profile couldn't be resolved properly. Cancelling event handling...");
return;
return null;
}
logger.debug(PingEventHandler.class, "Received valid Server List Profile. Calling PreServerListSetEvent...");
@@ -78,7 +78,7 @@ public class PingEventHandler{
GenericServerListEvent e = event.callEvent(ProfileManager.merge(profile));
if(e == null || e.isCancelled()){
logger.debug(PingEventHandler.class, "PreServerListSetEvent was cancelled. Stopping ping handling...");
return;
return null;
}
logger.debug(PingEventHandler.class, "PreServerListSetEvent completed. Proceeding with ping handling...");
@@ -86,12 +86,12 @@ public class PingEventHandler{
ProfileEntry entry = e.getEntry();
if(entry.isInvalid()){
logger.debugWarn(PingEventHandler.class, "No valid ProfileEntry retrieved. Cancelling ping handling...");
return;
return null;
}
boolean extraPlayers = ProfileManager.checkOption(entry.extraPlayersEnabled());
if(extraPlayers){
if(extraPlayers && ignoreMaintenance(event, "extraPlayers")){
max = online + (entry.extraPlayersCount() == null ? 0 : entry.extraPlayersCount());
logger.debug(PingEventHandler.class, "Extra Players enabled. Applying '%d' as max player count...", max);
@@ -99,7 +99,7 @@ public class PingEventHandler{
event.setMaxPlayers(max);
}
if(ProfileManager.checkOption(entry.maxPlayersEnabled()) && !extraPlayers){
if(ProfileManager.checkOption(entry.maxPlayersEnabled()) && !extraPlayers && ignoreMaintenance(event, "maxPlayers")){
max = (entry.maxPlayersCount() == null) ? 0 : entry.maxPlayersCount();
logger.debug(PingEventHandler.class, "Max Players enabled. Applying '%d' as max player count...", max);
@@ -109,7 +109,7 @@ public class PingEventHandler{
GenericServer finalServer = event.createGenericServer(online, max, host);
if(ProfileManager.checkOption(entry.motd())){
if(ProfileManager.checkOption(entry.motd()) && ignoreMaintenance(event, "motd")){
logger.debug(PingEventHandler.class, "MOTD set. Applying '%s'...", String.join("\\n", entry.motd()));
event.setMotd(
@@ -122,13 +122,13 @@ public class PingEventHandler{
boolean hidePlayers = ProfileManager.checkOption(entry.hidePlayersEnabled());
if(hidePlayers){
if(hidePlayers && ignoreMaintenance(event, "hidePlayers")){
logger.debug(PingEventHandler.class, "Hide Players enabled. Hiding player count...");
event.hidePlayers();
}
if(ProfileManager.checkOption(entry.playerCountText()) && !hidePlayers){
if(ProfileManager.checkOption(entry.playerCountText()) && !hidePlayers && ignoreMaintenance(event, "playerCountText")){
logger.debug(PingEventHandler.class, "Player Count Text set. Applying '%s'...", entry.playerCountText());
event.setPlayerCount(
@@ -139,13 +139,13 @@ public class PingEventHandler{
);
}
if(ProfileManager.checkOption(entry.players()) && !hidePlayers){
if(ProfileManager.checkOption(entry.players()) && !hidePlayers && ignoreMaintenance(event, "playerCountHover")){
logger.debug(PingEventHandler.class, "Player Count Hover set. Applying '%s'...", String.join("\\n", entry.players()));
event.setPlayers(entry.players(), player, server);
}
if(ProfileManager.checkOption(entry.favicon())){
if(ProfileManager.checkOption(entry.favicon()) && ignoreMaintenance(event, "favicon")){
logger.debug(PingEventHandler.class, "Favicon set. Resolving '%s'...", entry.favicon());
String faviconString = StringReplacer.replace(entry.favicon(), player, server);
@@ -165,6 +165,8 @@ public class PingEventHandler{
logger.debug(PingEventHandler.class, "Event handling completed. Updating Ping data...");
event.updateEvent();
return entry;
}
public static PAPIUtil getPAPIUtil(){
@@ -180,4 +182,11 @@ public class PingEventHandler{
return (maintenanceUtil = new MaintenanceUtil());
}
private static <F, P extends GenericPlayer> boolean ignoreMaintenance(GenericEventWrapper<F, P> event, String option){
if(!event.isMaintenanceModeActive())
return true;
return !event.getPlugin().getCore().getFileHandler().getBool(true, "disableDuringMaintenance", option);
}
}
@@ -46,12 +46,29 @@ public class ConfigMigrator{
public static ConfigurationTransformation.Versioned create(){
return ConfigurationTransformation.versionedBuilder()
.versionKey("configVersion")
.addVersion(LATEST, threeToFour())
.addVersion(LATEST, fourToFive())
.addVersion(4, threeToFour())
.addVersion(3, twoToThree())
.addVersion(2, oneToTwo())
.build();
}
public static ConfigurationTransformation fourToFive(){
return ConfigurationTransformation.builder()
.addAction(NodePath.path(), (path, value) -> {
value.node("disableDuringMaintenance", "motd").set(true);
value.node("disableDuringMaintenance", "favicon").set(true);
value.node("disableDuringMaintenance", "hidePlayers").set(true);
value.node("disableDuringMaintenance", "playerCountText").set(true);
value.node("disableDuringMaintenance", "playerCountHover").set(true);
value.node("disableDuringMaintenance", "extraPlayers").set(true);
value.node("disableDuringMaintenance", "maxPlayers").set(true);
return null;
})
.build();
}
public static ConfigurationTransformation threeToFour(){
return ConfigurationTransformation.builder()
.addAction(NodePath.path(), (path, value) -> {
@@ -187,8 +187,12 @@ public class FileHandler{
return node.node(path).getString(def);
}
public boolean getBool(boolean def, Object... path){
return node.node(path).getBoolean(def);
}
public boolean getBoolean(Object... path){
return node.node(path).getBoolean();
return getBool(false, path);
}
public long getLong(long def, long limit, Object... path){
@@ -53,15 +53,11 @@ public record ServerListProfile(int priority, String condition, ProfileEntry def
logger.warn("Encountered %d Error(s) while parsing condition for file '%s':", collector.getWarnings().size(), file);
for(ParseWarnCollector.Context context : collector.getWarnings()){
if(context.position() <= -1){
logger.warn(" - %s", condition);
logger.warn(" -> %s", context.message());
}else{
logger.warn(" - At position %d:", context.position());
logger.warn(" %s", condition);
logger.warn(" ".repeat(context.position() + 5) + "^");
logger.warn(" -> %s", context.message());
}
logger.warn(" - At position %s:", context.position() == -1 ? "Unknown" : context.position());
logger.warn(" %s", condition);
logger.warn(" ".repeat(context.position() + 5) + "^");
logger.warn(" -> %s", context.message());
}
}
@@ -54,7 +54,7 @@ public class ProfileConditionParser implements ExpressionParserEngine{
}
public static ProfileConditionParser create(){
return new ProfileConditionParserBuilder().createDefault()
return new ProfileConditionParserBuilder().addDefaults()
.addTokenReader(new PlaceholderTokenReader(-20))
.addValueReader(new PlaceholderValueReader())
.build();
@@ -1,120 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2024 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.core.profiles.conditions.placeholders;
import ch.andre601.advancedserverlist.api.AdvancedServerListAPI;
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.profiles.conditions.placeholders.tokens.PlaceholderToken;
import ch.andre601.expressionparser.ParseWarnCollector;
import java.text.ParsePosition;
public class PlaceholderParser{
public static PlaceholderToken.Placeholder parse(String text, ParsePosition position, GenericPlayer player, GenericServer server, ParseWarnCollector collector){
AdvancedServerListAPI api = AdvancedServerListAPI.get();
// We want to point to the start of a placeholder in the ParseWarnCollector.
// Since the PlaceholderTokenReader updates the index by 2 are we reverting this here.
int placeholderStart = position.getIndex() - 2;
int index = position.getIndex();
StringBuilder identifier = new StringBuilder();
StringBuilder values = new StringBuilder();
boolean identified = false;
boolean invalid = true;
char[] chars = text.substring(index).toCharArray();
for(final char c : chars){
index++;
if(c == '}'){
invalid = false;
break;
}
if(c == ' ' && !identified){
identified = true;
continue;
}
if(identified){
values.append(c);
}else{
identifier.append(c);
}
}
String identifierStr = identifier.toString();
String valuesStr = values.toString();
StringBuilder raw = new StringBuilder();
// Skipping whatever character we currently were on (i.e. })
position.setIndex(index + 1);
if(invalid){
raw.append("${").append(identifierStr);
if(identified)
raw.append(' ').append(valuesStr);
collector.appendWarningFormatted(placeholderStart, "Placeholder '%s' does not have a closing bracket (}).", raw.toString());
return new PlaceholderToken.Placeholder(raw.toString());
}
PlaceholderProvider provider = api.retrievePlaceholderProvider(identifierStr);
if(provider == null){
raw.append("${").append(identifierStr);
if(identified)
raw.append(' ').append(valuesStr);
raw.append('}');
collector.appendWarningFormatted(placeholderStart, "Placeholder '%s' does not have any available PlaceholderProvider", raw.toString());
return new PlaceholderToken.Placeholder(raw.toString());
}
String replacement = provider.parsePlaceholder(valuesStr, player, server);
if(replacement == null){
raw.append("${").append(identifierStr);
if(identified)
raw.append(' ').append(valuesStr);
raw.append('}');
collector.appendWarningFormatted(placeholderStart, "Placeholder '%s' has an invalid value String '%s'.", raw.toString(), valuesStr);
return new PlaceholderToken.Placeholder(raw.toString());
}
return new PlaceholderToken.Placeholder(replacement);
}
}
@@ -27,8 +27,8 @@ package ch.andre601.advancedserverlist.core.profiles.conditions.placeholders.rea
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.core.profiles.conditions.placeholders.PlaceholderParser;
import ch.andre601.advancedserverlist.core.profiles.conditions.placeholders.tokens.PlaceholderToken;
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
import ch.andre601.expressionparser.ParseWarnCollector;
import ch.andre601.expressionparser.tokens.Token;
@@ -44,7 +44,7 @@ public class PlaceholderTokenReader extends CustomTokenReader{
public Token read(String text, ParsePosition position, GenericPlayer player, GenericServer server, ParseWarnCollector collector){
if(position.getIndex() + 1 < text.length() && text.charAt(position.getIndex()) == '$' && text.charAt(position.getIndex() + 1) == '{'){
position.setIndex(position.getIndex() + 2);
return new PlaceholderToken(PlaceholderParser.parse(text, position, player, server, collector));
return new PlaceholderToken(StringReplacer.parsePlaceholder(text, position, player, server, collector));
}
return null;
}
@@ -29,6 +29,11 @@ import ch.andre601.advancedserverlist.api.AdvancedServerListAPI;
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.AdvancedServerList;
import ch.andre601.advancedserverlist.core.profiles.conditions.placeholders.tokens.PlaceholderToken;
import ch.andre601.expressionparser.ParseWarnCollector;
import java.text.ParsePosition;
public class StringReplacer{
@@ -36,99 +41,113 @@ public class StringReplacer{
if(input == null)
return null;
char[] chars = input.toCharArray();
ParsePosition position = new ParsePosition(0);
StringBuilder builder = new StringBuilder(input.length());
StringBuilder identifier = new StringBuilder();
StringBuilder placeholder = new StringBuilder();
AdvancedServerListAPI api = AdvancedServerListAPI.get();
for(int i = 0; i < chars.length; i++){
char c = chars[i];
char next = (i == (chars.length - 1)) ? '\0' : chars[i + 1];
if(c != '$' || i + 2 >= chars.length){
builder.append(c);
while(position.getIndex() < input.length()){
if(position.getIndex() + 1 < input.length() && input.charAt(position.getIndex()) == '$' && input.charAt(position.getIndex() + 1) == '{'){
position.setIndex(position.getIndex() + 2);
builder.append(parsePlaceholder0(input, position, player, server, null));
continue;
}
if(next != '{'){
if(next == '\0')
continue;
builder.append(next);
i++;
continue;
}
i++;
boolean identified = false;
boolean invalid = true;
while(++i < chars.length){
final char id = chars[i];
if(id == '}'){
invalid = false;
break;
}
if(id == ' ' && !identified){
identified = true;
continue;
}
if(identified){
placeholder.append(id);
}else{
identifier.append(id);
}
}
String identifierString = identifier.toString();
String placeholderString = placeholder.toString();
identifier.setLength(0);
placeholder.setLength(0);
if(invalid){
builder.append("${").append(identifierString);
if(identified){
builder.append(' ').append(placeholderString);
}
continue;
}
PlaceholderProvider provider = api.retrievePlaceholderProvider(identifierString);
if(provider == null){
builder.append("${").append(identifierString);
if(identified){
builder.append(' ').append(placeholderString);
}
builder.append('}');
continue;
}
String replacement = provider.parsePlaceholder(placeholderString, player, server);
if(replacement == null){
builder.append("${").append(identifierString);
if(identified){
builder.append(' ').append(placeholderString);
}
builder.append('}');
continue;
}
builder.append(replacement);
builder.append(input.charAt(position.getIndex()));
position.setIndex(position.getIndex() + 1);
}
return builder.toString();
}
public static PlaceholderToken.Placeholder parsePlaceholder(String input, ParsePosition position, GenericPlayer player, GenericServer server, ParseWarnCollector collector){
return new PlaceholderToken.Placeholder(parsePlaceholder0(input, position, player, server, collector));
}
private static String parsePlaceholder0(String input, ParsePosition position, GenericPlayer player, GenericServer server, ParseWarnCollector collector){
AdvancedServerListAPI api = AdvancedServerList.getApi();
int placeholderStart = position.getIndex() - 2;
int index = position.getIndex();
StringBuilder identifier = new StringBuilder();
StringBuilder values = new StringBuilder();
boolean identified = false;
boolean invalid = true;
char[] chars = input.substring(index).toCharArray();
for(final char c : chars){
index++;
if(c == '}'){
invalid = false;
break;
}
if(c == ' ' && !identified){
identified = true;
continue;
}
if(identified){
values.append(c);
}else{
identifier.append(c);
}
}
String identifierStr = identifier.toString();
String valuesStr = values.toString();
StringBuilder raw = new StringBuilder();
// Condition parsing needs one extra increase of index... for some reason
if(collector != null)
index++;
position.setIndex(index);
if(invalid){
raw.append("${").append(identifierStr);
if(identified)
raw.append(' ').append(valuesStr);
if(collector != null)
collector.appendWarningFormatted(placeholderStart, "Placeholder '%s' does not have a closing bracket (})", raw.toString());
return raw.toString();
}
PlaceholderProvider provider = api.retrievePlaceholderProvider(identifierStr);
if(provider == null){
raw.append("${").append(identifierStr);
if(identified)
raw.append(' ').append(valuesStr);
raw.append('}');
if(collector != null)
collector.appendWarningFormatted(placeholderStart, "Placeholder '%s' does not have any available PlaceholderProvider", raw.toString());
return raw.toString();
}
String replacement = provider.parsePlaceholder(valuesStr, player, server);
if(replacement == null){
raw.append("${").append(identifierStr);
if(identified)
raw.append(' ').append(valuesStr);
raw.append('}');
if(collector != null)
collector.appendWarningFormatted(placeholderStart, "Placeholder '%s' has an invalid value String '%s'", raw.toString(), valuesStr);
return raw.toString();
}
return replacement;
}
}
+36
View File
@@ -50,6 +50,42 @@ debug: false
#
faviconCacheTime: 1
#
# List of options that should be disabled while the Maintenance Mode of the plugin Maintenance is active.
# Any option not listed here will NOT be disabled, meaning AdvancedServerList will continue to handle it.
#
# Each option defaults to true when not present, disabling said option while Maintenance is active.
#
disableDuringMaintenance:
#
# When true (Default), disables handling of MOTD while Maintenance is enabled.
#
motd: true
#
# When true (Default), disables handling of Favicon while Maintenance is enabled.
#
favicon: true
#
# When true (Default), disables hiding of player count while Maintenance is enabled.
#
hidePlayers: true
#
# When true (Default), disables handling of player count text while Maintenance is enabled.
#
playerCountText: true
#
# When true (Default), disables handling of player count hover while Maintenance is enabled.
#
playerCountHover: true
#
# When true (Default), disables use of extra players feature while Maintenance is enabled.
#
extraPlayers: true
#
# When true (Default), disables use of max players feature while Maintenance is enabled.
#
maxPlayers: true
#
# DO NOT EDIT!
#
+79 -86
View File
@@ -1,176 +1,169 @@
#
# Set the priority of this profile.
# Higher number = Higher priority.
# If there are multiple profiles (files) will they be sorted by priority, starting with highest.
#
# Read more: https://asl.andre601.ch/profiles/#priority
#
priority: 0
#
# Set conditions that need to me met to show this profile.
# You can use keywords 'and' or 'or' (Or alternatively '&&' or `||`) to make more complex condition sets.
# Set condition(s) that should return true to display this profile.
# This allows you to create profiles to only show for specific scenarios (i.e. player is banned).
#
# Multiple conditions can be chaing with the keywords 'and', 'or', or their counterparts '&&' and '||'.
#
# No condition or an empty condition will be treated as true by default.
#
# Read more: https://asl.andre601.ch/profiles/#condition
#
# condition: '${player protocol} < 759'
#
condition: ''
#
# Set conditions that needs to be met.
# Only when all conditions return true will the profile be shown (Given no profile with higher priority is used).
# Set one or multiple profiles.
#
# Read more: https://asl.andre601.ch/profiles/#conditions
# A profile can contain the same options as used in the file itself, except for priority and condition.
# If multiple entries are present, a random one will be selected. Any options set in the selected profile will override
# any existing option in the file.
#
#conditions:
# - '{playerVersion} < 759'
# Example: The below profile configuration will randomly change the MOTD between two types, but keep the Hover text
# the same.
#
# Option that allows you to define multiple profiles to use.
# Each entry supports the same options as the server list profile does. Whenever an option is not present, or set to
# an empty value (If supported) would the option in the file be used (if present).
# This allows you to f.e. randomize the MOTD while keeping other options the same, without copy-pasting the same options.
#
# A profile will be selected randomly.
#
# Remove this option or set it to profiles: [] to use the global options of this file.
# When not present or empty (profiles: []), no profiles will be used and global options from the file will be used instead.
#
# Read more: https://asl.andre601.ch/profiles/#profiles
#
#profiles:
# - motd:
# - '<aqua>Line 1'
# - '<aqua>Line 2'
# favicon: ''
# playerCount:
# hidePlayers: false
# hover:
# - '<green>Line 1'
# - '<green>Line 2'
# - '<green>Line 3'
# text: ''
# extraPlayers:
# enabled: false
# amount: 0
profiles:
- motd: ['<aqua>Line A', '<gold>Line B']
- motd:
- '<aqua>Line 1'
- '<gold>Line 2'
#
# Set the default (Global) MOTD used by this server list profile.
# Supports HEX colors for 1.16+ servers including gradients using MiniMessage's <gradient:color:color> format.
#
# Remove this option or set it to motd: [] to not alter the MOTD.
# Set the "Message of the day" to display.
# This option supports RGB colors for 1.16+ Servers and clients, including gradients using MiniMessage's <gradient>
# option.
#
# Only the first two lines will be considered and any additional one is ignored.
#
# When not present or empty (motd: []), no MOTD will be set.
#
# Read more: https://asl.andre601.ch/profiles/#motd
#
motd:
- '<grey>Line 1'
- '<grey>Line 2'
- '<grey>First Line'
- '<grey>Second Line'
#
# Allows you to set a global (Default) favicon for this server list profile.
# You can use one of three possible options:
# 1. A file name matching a PNG file located in the 'favicons' folder (Needs to end with .png)
# 2. A URL pointing to a valid Image
# 3. ${player name} to display the player's head as favicon. Uses https://mc-heads.net for this
# Set the Favicon (image on the left of a server entry) to display.
# This option supports three types of inputs:
#
# Remove this option or set to favicon: '' to not replace the Favicon.
# 1. Name, including .png extension, pointing to an image located in the plugin's favicons folder.
# 2. URL pointing to an image.*
# 3. Player name, UUID or placeholders returning one of these.*
# https://mc-heads.net will be used to retrieve an image of the provided name/UUID.
#
# * These images are loaded asynchronously, meaning they may not yet be "ready" when AdvancedServerList is done with
# the event, requiring a refresh of the server list by the player to have it shown.
#
# Any images above or below 64x64 pixels will be automatically resized to these dimensions.
#
# If not present or empty (favicon: ''), defaults to not modifying the favicon.
#
# Read more: https://asl.andre601.ch/profiles/#favicon
#
favicon: ''
#
# Contains various options to manipulate the player count (Text displaying online and max players allowed).
# Contains options for modifying the player count (Text displaying <online>/<max>).
#
# Read more: https://asl.andre601.ch/profiles/#playercount
#
playerCount:
#
# Whether AdvancedServerList should hide the player count or not.
# When set to true will the player count display '???' instead of <online>/<max>
# Set whether the Player count should be hidden.
# When set to true, the player count will be displayed as '???' instead of the usual '<online>/<max>' and all other
# playerCount options, except for extraPlayers and maxPlayers, will be ignored.
#
# Note that when this is enabled will all other options, except for 'extraPlayers', be ignored.
#
# Defaults to false when not present.
# If not present, defaults to false.
#
# Read more: https://asl.andre601.ch/profiles/#hideplayers
#
hidePlayers: false
#
# Sets the text displayed when hovering over the player count.
# Set the lines shown when the player hovers over the player count.
# Unlike the MOTD option does this one only support basic color and formatting codes. Any RGB colors will be
# downsampled to the nearest matching color.
#
# Remove this option or set it to hover: [] to not modify the player samples on the player count.
# If not present or empty (hover: []), defaults to not modifying the hover.
#
# Read more: https://asl.andre601.ch/profiles/#hover
#
hover:
- '<grey>Line 1'
- '<grey>Line 2'
- '<grey>Line 3'
- '<aqua>Line 1'
- '<yellow>Line 2'
- '<green>Line 3'
#
# Modifies the text that usually displays '<online>/<max>'
#
# Note that when used, the Ping icon will display as 'outdated server'/'outdated client'.
# This is nothing that can be fixed or avoided and would require changes from Mojang.
# Set the text that should be displayed instead of the default '<online>/<max>' text.
#
# Remove this option or set it to text: '' to not modify the player count text.
# Using this option will show the server as "outdated" to the client (Have the ping icon crossed out).
# This cannot be fixed and would require Mojang to change stuff.
#
# If not present or empty (text: ''), defaults to not modifying the text.
#
# Read more: https://asl.andre601.ch/profiles/#text
#
text: ''
#
# Allows you to modify the max player count displayed.
# Note that this will affect ${server playersMax} (Except for when used in conditions).
# The extraPlayers feature allows to set a number that should be added to the current online players and then be
# used as the "max" player count.
#
# Using this feature will modify the ${server playersMax} placeholder, except for usage in the condition option.
#
# Read more: https://asl.andre601.ch/profiles/#extraplayers
#
extraPlayers:
#
# Enables/Disables the extraPlayers option.
# When enabled will the total amount of players allowed to join be modified to the current
# number of online players + 'amount'
# Set whether the extraPlayers feature should be enabled or not.
# When set to true, the max players count will be modified to be the number of online players with the 'amount'
# value added to it.
#
# Defaults to false when not present.
# If not present, defaults to false.
#
# Read more: https://asl.andre601.ch/profiles/#extraplayers-enabled
#
enabled: false
#
# Sets how much should be added/subtracted from the current number of online players
# to then use for the max player count.
# Set the number that should be added to the online player count to then use as the new max player count.
#
# Example:
# When set to 1 while 10 players are online would the player count - if unmodified -
# display '10/11'. When -1 is used will it display '10/9'
# 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.
#
# Defaults to 0 when not present.
# If not present, defaults to 0.
#
# Read more: https://asl.andre601.ch/profiles/#extraplayers-amount
#
amount: 0
#
# Allows you to set the max players that could join your server.
# Note that this option influences the '${server playersMax}' placeholder.
# The maxPlayers feature allows to set a number to use as the max player count to display.
#
# The settings of this option have no effect should 'extraPlayers' be enabled
# Using this feature will modify the ${server playersMax} placeholder, except for usage in the condition option.
#
# Read more: https://asl.andre601.ch/profiles/#maxplayers
#
maxPlayers:
#
# Enables/Disables the maxPlayers option.
# When enabled will the total amount of players allowed to join be changed to what 'amount' is set to.
# Set whether the maxPlayers 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.
#
# Defaults to false when not present.
#
# Read more: https://asl.andre601.ch/profiles/#maxplayers-enabled
#
enabled: false
#
# Sets the number to display for the max number of players allowed to join your server.
# Set the number that should be used as the new max players count.
#
# Example:
# Setting this option to 0 (Default) while 1 player is online would display '1/0'
#
# Defaults to 0 if not set.
# If not present, defaults to 0.
#
# Read more: https://asl.andre601.ch/profiles/#maxplayers-amount
#
+3 -3
View File
@@ -23,13 +23,13 @@
Detailed object info
-->
{% if page.meta.constructors %}
{{ info.info('Constructor Detail', page.meta.constructors, defaults=page.meta.defaults) }}
{{ info.info('Constructor Detail', page.meta.constructors, 'constructor', defaults=page.meta.defaults) }}
{% endif %}
{% if page.meta.enums %}
{{ info.info('Enum Constant Detail', page.meta.enums, true, defaults=page.meta.defaults) }}
{{ info.info('Enum Constant Detail', page.meta.enums, 'enum', defaults=page.meta.defaults) }}
{% endif %}
{% if page.meta.methods %}
{{ info.info('Method Detail', page.meta.methods, defaults=page.meta.defaults)}}
{{ info.info('Method Detail', page.meta.methods, 'method', defaults=page.meta.defaults)}}
{% endif %}
{% endif %}
{% endblock %}
@@ -105,14 +105,14 @@
</div>
{%- endmacro %}
{% macro info(title, details, enum = false, defaults = []) -%}
{% macro info(title, details, details_type = 'unknown', defaults = []) -%}
<h2 id="{{ title | lower() | replace(' ', '-') | e}}">
{{ title }}
</h2>
{% for detail in details %}
<div class="api-detail">
{% set final_name = namespace(name = "") %}
{% if enum %}
{% if details_type == "enum" %}
{% set final_name.name = detail.name | upper() %}
{% else %}
{% set final_name.name = detail.name ~ "(" %}
@@ -123,7 +123,7 @@
{% if loop.revindex > 1 %}{% set final_name.name = final_name.name ~ ", " %}{% endif %}
{% endfor %}
{% if not enum %}
{% if details_type != "enum" %}
{% set final_name.name = final_name.name ~ ")" %}
{% endif %}
@@ -140,19 +140,19 @@
<api__static></api__static> <api__final></api__final>
{% endif %}
{% if detail.type %}
{% if detail.type and details_type == "method" %}
{% if detail.type.link %}
<a href="{{ detail.type.link }}" class="api-type__{{- detail.type.type | default('primitive') -}}">{{ detail.type.name | default('void') | e }}</a>
{% else %}
<span class="api-type__{{- detail.type.type | default('primitive') -}}">{{ detail.type.name | default('void') | e }}</span>
{% endif %}
{% elif defaults and defaults.type %}
{% elif defaults and defaults.type and details_type == "method" %}
{% if defaults.type.link %}
<a href="{{ defaults.type.link }}" class="api-type__{{- defaults.type.type | default('primitive') -}}">{{ defaults.type.name | default('void') | e }}</a>
{% else %}
<span class="api-type__{{- defaults.type.type | default('primitive') -}}">{{ defaults.type.name | default('void') }}</span>
{% endif %}
{% else %}
{% elif details_type == "method" %}
<span class="api-type__primitive">void</span>
{% endif %}
<code>{{ final_name.name | e }}</code><a href="#{{ final_name.name | lower() | replace(' ', '-') | e }}" class="headerlink" title="Permanent link"></a>
-10
View File
@@ -6,16 +6,6 @@
<!-- Actions -->
{% include "partials/actions.html" %}
{% if config.extra.github_repository %}
<div class="admonition info">
<p class="admonition-title">Moved</p>
<p>
The documenation has been moved and can now be found at <a href="https://asl.andre601.ch" target="_blank" rel="noreferral nofollow noopener"><strong>asl.andre601.ch</strong></a>.<br>
This page in particular can be found at <a href="https://asl.andre601.ch/{{ page.url }}" target="_blank" rel="noreferral nofollow noopener"><strong>asl.andre601.ch/{{ page.url }}</strong></a>.
</p>
</div>
{% endif %}
<!--
Hack: check whether the content contains a h1 headline. If it doesn't, the
page title (or respectively site name) is used as the main headline.
-10
View File
@@ -1,10 +0,0 @@
nav:
- Home: index.md
- getting-started
- commands
- profiles
- examples
- migration
- api
- addons
- PlaceholderAPI: placeholderapi
-2
View File
@@ -1,2 +0,0 @@
nav:
- ...
+8
View File
@@ -7,6 +7,14 @@ icon: octicons/log-24
This page lists the recent changes made towards the AdvancedServerListAPI.
They are ordered newest to oldest.
## v3.3.0 { #v3.3.0 }
### :octicons-plus-circle-24:{ .changelog-added title="Added" } Added { #v3.3.0-added }
- Added `PostServerListSetEvent` to the different platform APIs.
- Fired **after** AdvancedServerList is done with handling the PingEvent.
- Allows to retrieve the [`ProfileEntry`][profileentry] used for the PingEvent.
## v3.2.1 { #v3.2.1 }
### :octicons-pencil-24:{ .changelog-changed title="Changed" } Changed { #v3.2.1-changed }
+1 -1
View File
@@ -1,7 +1,7 @@
---
template: redirect.html
location: https://jd.andre601.ch
location: https://jd.andre601.ch/asl-api
title: Javadocs
icon: octicons/link-external-24
-6
View File
@@ -1,6 +0,0 @@
nav:
- index.md
- api: api
- platform-bukkit: platform-bukkit
- platform-bungeecord: platform-bungeecord
- platform-velocity: platform-velocity
-3
View File
@@ -1,3 +0,0 @@
nav:
- index.md
- ch.andre601.advancedserverlist.api: ch.andre601.advancedserverlist.api
@@ -8,7 +8,7 @@ constructors:
- name: 'identifier'
description: 'The identifier to use for the placeholder. Cannot be empty.'
type: String
attributes:
attribute:
- notnull
methods:
@@ -28,7 +28,7 @@ methods:
type: GenericServer
description: 'The <a href="./../objects/genericserver/"><code>GenericServer</code> instance</a> used.'
returns: 'Possibly-parsed or possibly-null String to replace the placeholder with.'
attributes:
attribute:
- nullable
- abstract
type:
@@ -1,3 +0,0 @@
nav:
- index.md
- ch.andre601.advancedserverlist.api.bukkit: ch.andre601.advancedserverlist.api.bukkit
@@ -0,0 +1,49 @@
---
template: api-doc.html
constructors:
- name: 'PostServerListSetEvent'
description: 'Constructor for creating a new PostServerListSetEvent instance.'
parameters:
- name: 'entry'
description: 'The <a href="../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/"><code>ProfileEntry</code></a> used during the PingEvent.'
type: ProfileEntry
attribute:
- nullable
methods:
- name: 'getHandlerList'
description: 'Static <a href="https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/HandlerList.html" target="_blank" rel="nofollow"><code>HandlerList</code></a> getter. Required by Paper.'
returns: 'The static <a href="https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/HandlerList.html" target="_blank" rel="nofollow"><code>HandlerList instance</code></a> of this event.'
attributes:
- static
type:
name: 'HandlerList'
type: 'object'
- name: 'getEntry'
description: |
The <a href="../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/"><code>ProfileEntry</code></a> that was used during the PingEvent handling.<br>
<br>
The returned value may be <code>null</code> should the PingEvent handling be cancelled at any point (i.e. due to an invalid protocol or because the <a href="../preserverlistsetevent/"><code>PreServerListSetEvent</code></a> has been cancelled).<br>
The values within the ProfileEntry also do not represent what is actually used within the Server list itself, but only the values provided for the PingEvent handling.
returns: 'Possibly-null ProfileEntry used for the PingEvent.'
attributes:
- nullable
type:
name: 'ProfileEntry'
type: 'object'
link: '../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/'
inherits:
'org.bukkit.event.Event':
link: 'https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/Event.html'
list:
- 'getHandlers()'
---
# <api__class></api__class> PostServerListSetEvent
Called **after** the plugin has updated the Server List.
The provided [`ProfileEntry`](#getentry()) may be null due to the PingEvent handling being cancelled (i.e. due to a invalid protocol or due to the [`PreServerListSetEvent`](preserverlistsetevent.md) being cancelled).
The entry also only represents the values used during the PingEvent, not the actual content that is being displayed.
@@ -1,3 +0,0 @@
nav:
- index.md
- ch.andre601.advancedserverlist.api.bungeecord: ch.andre601.advancedserverlist.api.bungeecord
@@ -0,0 +1,35 @@
---
template: api-doc.html
constructors:
- name: 'PostServerListSetEvent'
description: 'Constructor for creating a new PostServerListSetEvent instance.'
parameters:
- name: 'entry'
description: 'The <a href="../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/"><code>ProfileEntry</code></a> used during the PingEvent.'
type: ProfileEntry
attribute:
- nullable
methods:
- name: 'getEntry'
description: |
The <a href="../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/"><code>ProfileEntry</code></a> that was used during the PingEvent handling.<br>
<br>
The returned value may be <code>null</code> should the PingEvent handling be cancelled at any point (i.e. due to an invalid protocol or because the <a href="../preserverlistsetevent/"><code>PreServerListSetEvent</code></a> has been cancelled).<br>
The values within the ProfileEntry also do not represent what is actually used within the Server list itself, but only the values provided for the PingEvent handling.
returns: 'Possibly-null ProfileEntry used for the PingEvent.'
attributes:
- nullable
type:
name: 'ProfileEntry'
type: 'object'
link: '../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/'
---
# <api__class></api__class> PostServerListSetEvent
Called **after** the plugin has updated the Server List.
The provided [`ProfileEntry`](#getentry()) may be null due to the PingEvent handling being cancelled (i.e. due to a invalid protocol or due to the [`PreServerListSetEvent`](preserverlistsetevent.md) being cancelled).
The entry also only represents the values used during the PingEvent, not the actual content that is being displayed.
@@ -1,3 +0,0 @@
nav:
- index.md
- ch.andre601.advancedserverlist.api.velocity: ch.andre601.advancedserverlist.api.velocity
@@ -0,0 +1,35 @@
---
template: api-doc.html
constructors:
- name: 'PostServerListSetEvent'
description: 'Constructor for creating a new PostServerListSetEvent instance.'
parameters:
- name: 'entry'
description: 'The <a href="../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/"><code>ProfileEntry</code></a> used during the PingEvent.'
type: ProfileEntry
attribute:
- nullable
methods:
- name: 'getEntry'
description: |
The <a href="../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/"><code>ProfileEntry</code></a> that was used during the PingEvent handling.<br>
<br>
The returned value may be <code>null</code> should the PingEvent handling be cancelled at any point (i.e. due to an invalid protocol or because the <a href="../preserverlistsetevent/"><code>PreServerListSetEvent</code></a> has been cancelled).<br>
The values within the ProfileEntry also do not represent what is actually used within the Server list itself, but only the values provided for the PingEvent handling.
returns: 'Possibly-null ProfileEntry used for the PingEvent.'
attributes:
- nullable
type:
name: 'ProfileEntry'
type: 'object'
link: '../../../../api/ch.andre601.advancedserverlist.api/profiles/profileentry/'
---
# <api__class></api__class> PostServerListSetEvent
Called **after** the plugin has updated the Server List.
The provided [`ProfileEntry`](#getentry()) may be null due to the PingEvent handling being cancelled (i.e. due to a invalid protocol or due to the [`PreServerListSetEvent`](preserverlistsetevent.md) being cancelled).
The entry also only represents the values used during the PingEvent, not the actual content that is being displayed.
-1
View File
@@ -1 +0,0 @@
hide: true
+143 -94
View File
@@ -5,7 +5,7 @@ icon: octicons/milestone-24
# Getting Started
This page will explain how to set up AdvancedServerList and make it work for your server.
It tries to be as easy to understand as possible. But if you still have problems, consider joining the [Discord Server](https://discord.gg/6dazXp6) for help.
It tries to be as easy to understand as possible. But if you still have problems, consider joining the [Discord Server](https://discord.gg/6dazXp6){ target="_blank" rel="nofollow" } for help.
## 1. Download the plugin { #download-the-plugin }
@@ -14,26 +14,26 @@ AdvancedServerList is available on the following places (Please note the current
<div class="grid cards" markdown>
- [:simple-modrinth: **Modrinth**][modrinth]
- [:simple-modrinth: **Modrinth**][modrinth]{ target="_blank" rel="nofollow" }
----
:octicons-check-24:{ style="color: var(--md-badge-fg--success);" } **Actively updated!**
- [:simple-codeberg: **Codeberg**][codeberg]
- [:simple-codeberg: **Codeberg**][codeberg]{ target="_blank" rel="nofollow" }
----
:octicons-check-24:{ style="color: var(--md-badge-fg--success);" } **Actively updated!**
- [:fontawesome-solid-paper-plane: **HangarMC**][hangar]
- [:fontawesome-solid-paper-plane: **HangarMC**][hangar]{ target="_blank" rel="nofollow" }
----
:octicons-check-24:{ style="color: var(--md-badge-fg--success);" } **Actively updated!**
- [:simple-spigotmc: **SpigotMC**][spigot]
- [:simple-spigotmc: **SpigotMC**][spigot]{ target="_blank" rel="nofollow" }
----
@@ -52,40 +52,48 @@ The plugin also supports these additional plugins. They are all optional.
<div class="grid cards" markdown>
- [**PlaceholderAPI**][placeholderapi]
- [**PlaceholderAPI**][placeholderapi]{ target="_blank" rel="nofollow" }
----
AdvancedServerList supports the use of placeholder from PlaceholderAPI in all its text options, excluding the `condition` option.
AdvancedServerList supports the use of placeholder from PlaceholderAPI in all its text options, except for the `condition` option.
Supported on:
----
**Supported on:**
:fontawesome-solid-paper-plane: Paper
- [**ViaVersion**][viaversion]
- [**ViaVersion**][viaversion]{ target="_blank" rel="nofollow" }
----
When installed will AdvancedServerList use ViaVersion to resolve the protocol version of a player for its PlaceholderAPI placeholders.
Supported on:
----
**Supported on:**
:fontawesome-solid-paper-plane: Paper
- [**PAPIProxyBridge**][papiproxybridge]
- [**PAPIProxyBridge**][papiproxybridge]{ target="_blank" rel="nofollow" }
----
Allows AdvancedServerList to parse placeholders from PlaceholderAPI while being used on a proxy.
Supported on:
----
**Supported on:**
:simple-spigotmc: BungeeCord, :fontawesome-solid-paper-plane: Velocity
- [**Maintenance**][maintenance]
- [**Maintenance**][maintenance]{ target="_blank" rel="nofollow" }
----
AdvancedServerList will disable any modification of the server list entry should Maintenance mode be enabled.
Supported on:
----
**Supported on:**
:fontawesome-solid-paper-plane: Paper, :simple-spigotmc: BungeeCord, :fontawesome-solid-paper-plane: Velocity
- [**BanPlugins Addon**][addon]
@@ -94,8 +102,10 @@ The plugin also supports these additional plugins. They are all optional.
Official Add-on for AdvancedServerList that adds placeholders for different Ban/Punishment plugins such as AdvancedBan and LibertyBans.
Supported on:
:fontawesome-solid-paper-plane: Paper, :simple-spigotmc: BungeeCord, :fontawesone-solid-paper-plane: Velocity
----
**Supported on:**
:fontawesome-solid-paper-plane: Paper, :simple-spigotmc: BungeeCord, :fontawesome-solid-paper-plane: Velocity
</div>
@@ -146,167 +156,170 @@ On first creation will the folder have a `default.yml` file. This file contains
```yaml
#
# Set the priority of this profile.
# Higher number = Higher priority.
# If there are multiple profiles (files) will they be sorted by priority, starting with highest.
#
# Read more: https://asl.andre601.ch/profiles/#priority
#
priority: 0
#
# Set conditions that need to me met to show this profile.
# You can use keywords 'and' or 'or' (Or alternatively '&&' or `||`) to make more complex condition sets.
# Set condition(s) that should return true to display this profile.
# This allows you to create profiles to only show for specific scenarios (i.e. player is banned).
#
# Multiple conditions can be chaing with the keywords 'and', 'or', or their counterparts '&&' and '||'.
#
# No condition or an empty condition will be treated as true by default.
#
# Read more: https://asl.andre601.ch/profiles/#condition
#
# condition: '${player protocol} < 759'
condition: ''
#
# Option that allows you to define multiple profiles to use.
# Each entry supports the same options as the server list profile does. Whenever an option is not present, or set to
# an empty value (If supported) would the option in the file be used (if present).
# This allows you to f.e. randomize the MOTD while keeping other options the same, without copy-pasting the same options.
# Set one or multiple profiles.
#
# A profile will be selected randomly.
# A profile can contain the same options as used in the file itself, except for priority and condition.
# If multiple entries are present, a random one will be selected. Any options set in the selected profile will override
# any existing option in the file.
#
# Remove this option or set it to profiles: [] to use the global options of this file.
# Example: The below profile configuration will randomly change the MOTD between two types, but keep the Hover text
# the same.
#
# When not present or empty (profiles: []), no profiles will be used and global options from the file will be used instead.
#
# Read more: https://asl.andre601.ch/profiles/#profiles
#
#profiles:
# - motd:
# - '<aqua>Line 1'
# - '<aqua>Line 2'
# favicon: ''
# playerCount:
# hidePlayers: false
# hover:
# - '<green>Line 1'
# - '<green>Line 2'
# - '<green>Line 3'
# text: ''
# extraPlayers:
# enabled: false
# amount: 0
profiles:
- motd: ['<aqua>Line A', '<gold>Line B']
- motd:
- '<aqua>Line 1'
- '<gold>Line 2'
#
# Set the default (Global) MOTD used by this server list profile.
# Supports HEX colors for 1.16+ servers including gradients using MiniMessage's <gradient:color:color> format.
#
# Remove this option or set it to motd: [] to not alter the MOTD.
# Set the "Message of the day" to display.
# This option supports RGB colors for 1.16+ Servers and clients, including gradients using MiniMessage's <gradient>
# option.
#
# Only the first two lines will be considered and any additional one is ignored.
#
# When not present or empty (motd: []), no MOTD will be set.
#
# Read more: https://asl.andre601.ch/profiles/#motd
#
motd:
- '<grey>Line 1'
- '<grey>Line 2'
- '<grey>First Line'
- '<grey>Second Line'
#
# Allows you to set a global (Default) favicon for this server list profile.
# You can use one of three possible options:
# 1. A file name matching a PNG file located in the 'favicons' folder (Needs to end with .png)
# 2. A URL pointing to a valid Image
# 3. ${player name} to display the player's head as favicon. Uses https://mc-heads.net for this
# Set the Favicon (image on the left of a server entry) to display.
# This option supports three types of inputs:
#
# Remove this option or set to favicon: '' to not replace the Favicon.
# 1. Name, including .png extension, pointing to an image located in the plugin's favicons folder.
# 2. URL pointing to an image.*
# 3. Player name, UUID or placeholders returning one of these.*
# https://mc-heads.net will be used to retrieve an image of the provided name/UUID.
#
# * These images are loaded asynchronously, meaning they may not yet be "ready" when AdvancedServerList is done with
# the event, requiring a refresh of the server list by the player to have it shown.
#
# Any images above or below 64x64 pixels will be automatically resized to these dimensions.
#
# If not present or empty (favicon: ''), defaults to not modifying the favicon.
#
# Read more: https://asl.andre601.ch/profiles/#favicon
#
favicon: ''
#
# Contains various options to manipulate the player count (Text displaying online and max players allowed).
# Contains options for modifying the player count (Text displaying <online>/<max>).
#
# Read more: https://asl.andre601.ch/profiles/#playercount
#
playerCount:
#
# Whether AdvancedServerList should hide the player count or not.
# When set to true will the player count display '???' instead of <online>/<max>
# Set whether the Player count should be hidden.
# When set to true, the player count will be displayed as '???' instead of the usual '<online>/<max>' and all other
# playerCount options, except for extraPlayers and maxPlayers, will be ignored.
#
# Note that when this is enabled will all other options, except for 'extraPlayers', be ignored.
#
# Defaults to false when not present.
# If not present, defaults to false.
#
# Read more: https://asl.andre601.ch/profiles/#hideplayers
#
hidePlayers: false
#
# Sets the text displayed when hovering over the player count.
# Set the lines shown when the player hovers over the player count.
# Unlike the MOTD option does this one only support basic color and formatting codes. Any RGB colors will be
# downsampled to the nearest matching color.
#
# Remove this option or set it to hover: [] to not modify the player samples on the player count.
# If not present or empty (hover: []), defaults to not modifying the hover.
#
# Read more: https://asl.andre601.ch/profiles/#hover
#
hover:
- '<grey>Line 1'
- '<grey>Line 2'
- '<grey>Line 3'
- '<aqua>Line 1'
- '<yellow>Line 2'
- '<green>Line 3'
#
# Modifies the text that usually displays '<online>/<max>'
#
# Note that when used, the Ping icon will display as 'outdated server'/'outdated client'.
# This is nothing that can be fixed or avoided and would require changes from Mojang.
# Set the text that should be displayed instead of the default '<online>/<max>' text.
#
# Remove this option or set it to text: '' to not modify the player count text.
# Using this option will show the server as "outdated" to the client (Have the ping icon crossed out).
# This cannot be fixed and would require Mojang to change stuff.
#
# If not present or empty (text: ''), defaults to not modifying the text.
#
# Read more: https://asl.andre601.ch/profiles/#text
#
text: ''
#
# Allows you to modify the max player count displayed.
# Note that this will affect ${server playersMax} (Except for when used in conditions).
# The extraPlayers feature allows to set a number that should be added to the current online players and then be
# used as the "max" player count.
#
# Using this feature will modify the ${server playersMax} placeholder, except for usage in the condition option.
#
# Read more: https://asl.andre601.ch/profiles/#extraplayers
#
extraPlayers:
#
# Enables/Disables the extraPlayers option.
# When enabled will the total amount of players allowed to join be modified to the current
# number of online players + 'amount'
# Set whether the extraPlayers feature should be enabled or not.
# When set to true, the max players count will be modified to be the number of online players with the 'amount'
# value added to it.
#
# Defaults to false when not present.
# If not present, defaults to false.
#
# Read more: https://asl.andre601.ch/profiles/#extraplayers-enabled
#
enabled: false
#
# Sets how much should be added/subtracted from the current number of online players
# to then use for the max player count.
# Set the number that should be added to the online player count to then use as the new max player count.
#
# Example:
# When set to 1 while 10 players are online would the player count - if unmodified -
# display '10/11'. When -1 is used will it display '10/9'
# 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.
#
# Defaults to 0 when not present.
# If not present, defaults to 0.
#
# Read more: https://asl.andre601.ch/profiles/#extraplayers-amount
#
amount: 0
#
# Allows you to set the max players that could join your server.
# Note that this option influences the '${server playersMax}' placeholder.
# The maxPlayers feature allows to set a number to use as the max player count to display.
#
# The settings of this option have no effect should 'extraPlayers' be enabled
# Using this feature will modify the ${server playersMax} placeholder, except for usage in the condition option.
#
# Read more: https://asl.andre601.ch/profiles/#maxplayers
#
maxPlayers:
#
# Enables/Disables the maxPlayers option.
# When enabled will the total amount of players allowed to join be changed to what 'amount' is set to.
# Set whether the maxPlayers 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.
#
# Defaults to false when not present.
#
# Read more: https://asl.andre601.ch/profiles/#maxplayers-enabled
#
enabled: false
#
# Sets the number to display for the max number of players allowed to join your server.
# Set the number that should be used as the new max players count.
#
# Example:
# Setting this option to 0 (Default) while 1 player is online would display '1/0'
#
# Defaults to 0 if not set.
# If not present, defaults to 0.
#
# Read more: https://asl.andre601.ch/profiles/#maxplayers-amount
#
@@ -385,13 +398,49 @@ debug: false
#
faviconCacheTime: 1
#
# List of options that should be disabled while the Maintenance Mode of the plugin Maintenance is active.
# Any option not listed here will NOT be disabled, meaning AdvancedServerList will continue to handle it.
#
# Each option defaults to true when not present, disabling said option while Maintenance is active.
#
disableDuringMaintenance:
#
# When true (Default), disables handling of MOTD while Maintenance is enabled.
#
motd: true
#
# When true (Default), disables handling of Favicon while Maintenance is enabled.
#
favicon: true
#
# When true (Default), disables hiding of player count while Maintenance is enabled.
#
hidePlayers: true
#
# When true (Default), disables handling of player count text while Maintenance is enabled.
#
playerCountText: true
#
# When true (Default), disables handling of player count hover while Maintenance is enabled.
#
playerCountHover: true
#
# When true (Default), disables use of extra players feature while Maintenance is enabled.
#
extraPlayers: true
#
# When true (Default), disables use of max players feature while Maintenance is enabled.
#
maxPlayers: true
#
# DO NOT EDIT!
#
# This is used internally to determine if the config needs to be migrated.
# Changing or even removing this option could result in your config being broken.
#
config-version: 4
config-version: 5
```
///
+55 -34
View File
@@ -12,13 +12,16 @@ If you're new to the plugin is it recommended to check out the [Profiles page](p
## Downloads
[![modrinth-img]{ width="260" loading="lazy" }][modrinth-download]{ target="_blank" rel="noreferrer nofollow noopener" }
[![hangar-img]{ width="260" loading="lazy" }][hangar-download]{ target="_blank" rel="noreferrer nofollow noopener" }
[![hangar-img]{ width="260" loading="lazy" }][hangar-download]{ target="_blank" rel="noreferrer nofollow noopener" }
[![codeberg-img]{ width="260" loading="lazy" }][codeberg-download]{ target="_blank" rel="noreferrer nofollow noopener" }
[modrinth-img]: https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact/available/modrinth_vector.svg "Available on Modrinth"
[hangar-img]: https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact/available/hangar_vector.svg "Available on Hangar"
[codeberg-img]: https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact/available/codeberg_vector.svg "Available on Codeberg"
[modrinth-download]: https://modrinth.com/plugin/advancedserverlist
[hangar-download]: https://hangar.papermc.io/Andre_601/AdvancedServerList
[codeberg-download]: https://codeberg.org/Andre601/AdvancedServerList
## Platforms
@@ -38,38 +41,56 @@ AdvancedServerList supports the following platforms:
[paper]: https://papermc.io
[velocity]: https://velocitypowered.com
## Dependencies
/// info
All listed dependencies are optional.
///
| Dependency | Platforms |
|-------------------------------------------------------------------------|----------------------|
| [PlaceholderAPI]{ target="_blank" rel="noreferrer nofollow noopener" } | Paper |
| [ViaVersion]{ target="_blank" rel="noreferrer nofollow noopener" } | Paper |
| [PAPIProxyBridge]{ target="_blank" rel="noreferrer nofollow noopener" } | BungeeCord, Velocity |
| [Maintenance]{ target="_blank" rel="noreferrer nofollow noopener" } | All |
[placeholderapi]: https://hangar.papermc.io/HelpChat/PlaceholderAPI
[viaversion]: https://hangar.papermc.io/ViaVersion/ViaVersion
[papiproxybridge]: https://hangar.papermc.io/William278/PAPIProxyBridge
[maintenance]: https://hangar.papermc.io/kennytv/Maintenance
## Pages
- [Getting started](getting-started/index.md)
- [Commands](commands/index.md)
- [Profiles](profiles/index.md)
- [Formatting](profiles/formatting.md)
- [Placeholders](profiles/placeholders.md)
- [Examples](examples/index.md)
- [Migration](migration/index.md)
- [v1.5.3 to v1.6.0](migration/v1_5_3-to-v1_6_0.md)
- [v1.9.0 to v1.10.0](migration/v1_9_0-to-v1_10_0.md)
- [API](api/index.md)
- [Changelog](api/changelog.md)
- [Javadocs](api/javadocs.md) (External site)
- [Source Code](api/source.md) (External site)
- [Reference](api/reference/index.md)
- [PlaceholderAPI](placeholderapi/index.md)
<div class="grid cards" markdown>
- [:octicons-milestone-24: **Getting Started**](getting-started/index.md)
----
A simple guide on how to get started with AdvancedServerList.
- [:octicons-rel-file-path-24: **Commands**](commands/index.md)
----
A list of all available commands in AdvancedServerList.
- [:octicons-note-24: **Profiles**](profiles/index.md)
----
Pages containing information about the Server List Profile System and all its available options.
- [:octicons-list-unordered-24: **Examples**](examples/index.md)
----
Collection of various profile examples to use for different situations.
- [:octicons-file-directory-symlink-24: **Migration**](migration/index.md)
----
Pages explaining how to migrate from one version of the plugin to another.
- [:octicons-command-palette-24: **API**](api/index.md)
----
Pages all about the API of AdvancedServerList.
- [:octicons-plus-circle-24: **Addons**](addons/index.md)
----
Pages listing 1st-party and 3rd-party add-ons for AdvancedServerList.
- [:material-percent: **PlaceholderAPI**](placeholderapi/index.md)
----
Information about available placeholders to use in PlaceholderAPI and how to use placeholders from other plugins in AdvancedServerList using PlaceholderAPI.
</div>
-7
View File
@@ -1,7 +0,0 @@
nav:
- index.md
- v3_8_0-to-v3_9_0.md
- v3_7_0-to-v3_8_0.md
- pre-v3_7_0-to-v3_7_0.md
- v1_9_0-to-v1_10_0.md
- v1_5_3-to-v1_6_0.md
+6
View File
@@ -12,6 +12,12 @@ Note that these pages only cover server list profile files. The config.yml is au
<div class="grid cards" markdown>
- [**v3.8.0 to v3.9.0**](v3_8_0-to-v3_9_0.md)
----
Migrate from version 3.8.0 to 3.9.0.
- [**v3.7.0 to v3.8.0**](v3_7_0-to-v3_8_0.md)
----
+4
View File
@@ -49,8 +49,12 @@ priority: 0
-conditions:
- - '${player protocol} >= 763'
- - '${player isWhitelisted} == true'
+# The text can all be in one line. This is only for better readability.
+condition: |
+ ${player protocol} >= 763 and
+ ${player isWhitelisted}
motd:
- 'Welcome ${player name}!'
```
///
+1 -1
View File
@@ -18,7 +18,7 @@ Here is a before and after example to help visualize the change:
```yaml
priority: 0
conditions: '${server host} <- "survival"'
condition: '${server host} <- "survival"'
motd:
- 'Welcome ${player name}!'
+1 -1
View File
@@ -18,7 +18,7 @@ Here is a before and after example to help visualize the change:
```yaml
priority: 0
conditions: '${player name} ~= "Someone"'
condition: '${player name} ~= "Someone"'
motd:
- 'Welcome ${player name}!'
+5 -5
View File
@@ -33,7 +33,7 @@ The following cases are considered literal values:
Any number is considered an expression, meaning the below examples are considered valid:
/// example | Examples
```
```shell
0
1000
-7
@@ -53,7 +53,7 @@ To avoid this is it very important to always surround Strings with single or dou
///
/// example | Examples
```
```shell
"Hello World!"
""
```
@@ -68,7 +68,7 @@ Strings `true` and `false` are treated as boolean literals.
Any [placeholder](placeholders.md) is a valid expression.
/// example | Examples
```
```shell
${player protocol}
${player name}
@@ -110,7 +110,7 @@ These additional binary operators can also be used to perform certain actions:
| `/` | Divides one number by another. Strings use their text length as number. |
/// example | Examples
```
```shell
${player name} != "Anonymous"
763 > ${player protocol} > 758
${player hasPlayedBefore} and ${player isBanned} == "false"
@@ -126,7 +126,7 @@ Parenthesis can be used to prevent ambiguities.
`!` can be used to negate boolean expressions.
```
```shell
!${player isWhitelisted}
```
+74 -4
View File
@@ -57,7 +57,6 @@ extra_javascript:
- assets/js/repo-stats.js
extra:
github_repository: !ENV [GITHUB_REPO_INSTANCE, False]
social:
- icon: 'simple/codeberg'
link: 'https://codeberg.org/Andre601/AdvancedServerList'
@@ -69,8 +68,6 @@ extra:
plugins:
- search
- glightbox
- awesome-pages:
filename: .pages.yml
- pagenav-generator
markdown_extensions:
@@ -107,4 +104,77 @@ markdown_extensions:
hooks:
- docs/.hooks/badges.py
- docs/.hooks/replacer.py
- docs/.hooks/replacer.py
nav:
- Home: index.md
- Getting Started: getting-started/index.md
- Commands: commands/index.md
- Profiles:
- profiles/index.md
- Expressions: profiles/expressions.md
- Formatting: profiles/formatting.md
- Placeholders: profiles/placeholders.md
- Examples: examples/index.md
- Migration:
- migration/index.md
- v3.8.0 to v3.9.0: migration/v3_8_0-to-v3_9_0.md
- v3.7.0 to v3.8.0: migration/v3_7_0-to-v3_8_0.md
- '< v3.7.0 to v3.7.0': migration/pre-v3_7_0-to-v3_7_0.md
- v1.9.0 to v1.10.0: migration/v1_9_0-to-v1_10_0.md
- v1.5.3 to v1.6.0: migration/v1_5_3-to-v1_6_0.md
- API:
- api/index.md
- Changelog: api/changelog.md
- Javadocs: api/javadocs.md
- Source Code: api/source.md
- Reference:
- api/reference/index.md
- api:
- api/reference/api/index.md
- ch.andre601.advancedserverlist.api:
- api/reference/api/ch.andre601.advancedserverlist.api/advancedserverlistapi.md
- api/reference/api/ch.andre601.advancedserverlist.api/placeholderprovider.md
- events:
- api/reference/api/ch.andre601.advancedserverlist.api/events/genericserverlistevent.md
- exceptions:
- api/reference/api/ch.andre601.advancedserverlist.api/exceptions/invalidplaceholderproviderexception.md
- objects:
- api/reference/api/ch.andre601.advancedserverlist.api/objects/genericplayer.md
- api/reference/api/ch.andre601.advancedserverlist.api/objects/genericserver.md
- api/reference/api/ch.andre601.advancedserverlist.api/objects/nullbool.md
- profiles:
- '<api__record></api__record> ProfileEntry':
- api/reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/index.md
- api/reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/builder.md
- platform-bukkit:
- api/reference/platform-bukkit/index.md
- ch.andre601.advancedserverlist.api.bukkit:
- events:
- api/reference/platform-bukkit/ch.andre601.advancedserverlist.api.bukkit/events/postserverlistsetevent.md
- api/reference/platform-bukkit/ch.andre601.advancedserverlist.api.bukkit/events/preserverlistsetevent.md
- objects:
- api/reference/platform-bukkit/ch.andre601.advancedserverlist.api.bukkit/objects/bukkitplayer.md
- api/reference/platform-bukkit/ch.andre601.advancedserverlist.api.bukkit/objects/bukkitserver.md
- platform-bungeecord:
- api/reference/platform-bungeecord/index.md
- ch.andre601.advancedserverlist.api.bungeecord:
- events:
- api/reference/platform-bungeecord/ch.andre601.advancedserverlist.api.bungeecord/events/postserverlistsetevent.md
- api/reference/platform-bungeecord/ch.andre601.advancedserverlist.api.bungeecord/events/preserverlistsetevent.md
- objects:
- api/reference/platform-bungeecord/ch.andre601.advancedserverlist.api.bungeecord/objects/bungeeplayer.md
- api/reference/platform-bungeecord/ch.andre601.advancedserverlist.api.bungeecord/objects/bungeeproxy.md
- platform-velocity:
- api/reference/platform-velocity/index.md
- ch.andre601.advancedserverlist.api.velocity:
- events:
- api/reference/platform-velocity/ch.andre601.advancedserverlist.api.velocity/events/postserverlistsetevent.md
- api/reference/platform-velocity/ch.andre601.advancedserverlist.api.velocity/events/preserverlistsetevent.md
- objects:
- api/reference/platform-velocity/ch.andre601.advancedserverlist.api.velocity/objects/velocityplayer.md
- api/reference/platform-velocity/ch.andre601.advancedserverlist.api.velocity/objects/velocityproxy.md
- Addons:
- addons/index.md
- BanPlugins: addons/banplugins.md
- PlaceholderAPI: placeholderapi/index.md
+2 -2
View File
@@ -92,7 +92,7 @@
<dependency>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>4.9.2</version>
<version>4.9.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -109,7 +109,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<release>16</release>
</configuration>
@@ -39,11 +39,16 @@ import ch.andre601.advancedserverlist.paper.objects.placeholders.PaperServerPlac
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.CachedServerIcon;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon>{
@@ -68,7 +73,7 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
}
}
this.core = AdvancedServerList.init(this, new PaperPlayerPlaceholders(), new PaperServerPlaceholders());
this.core = AdvancedServerList.init(this, new PaperPlayerPlaceholders(), new PaperServerPlaceholders(this));
if(getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
papiPlaceholders = new PAPIPlaceholders(this);
@@ -171,6 +176,21 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
return (worldCache = new WorldCache());
}
public int getPlayersOnline(World world){
List<? extends Player> players = new ArrayList<>(world == null ? getServer().getOnlinePlayers() : world.getPlayers());
players.removeIf(player -> {
for(MetadataValue metadata : player.getMetadata("vanished")){
if(metadata.asBoolean())
return true;
}
return false;
});
return players.size();
}
private void printNoPaperWarning(){
getPluginLogger().warn("======================================================================================");
getPluginLogger().warn("THIS SERVER DOES NOT USE PAPER OR A COMPATIBLE FORK!");
@@ -145,7 +145,7 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
@Override
public int getOnlinePlayers(){
return event.getNumPlayers();
return plugin.getPlayersOnline(null);
}
@Override
@@ -25,10 +25,13 @@
package ch.andre601.advancedserverlist.paper.listeners;
import ch.andre601.advancedserverlist.api.bukkit.events.PostServerListSetEvent;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.core.events.PingEventHandler;
import ch.andre601.advancedserverlist.paper.PaperCore;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class PingEvent implements Listener{
@@ -40,8 +43,10 @@ public class PingEvent implements Listener{
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST) // Maintenance plugin has HIGHEST priority, so ASL needs too.
public void onPaperServerListPing(PaperServerListPingEvent event){
PingEventHandler.handleEvent(new PaperEventWrapper(plugin, event));
ProfileEntry entry = PingEventHandler.handleEvent(new PaperEventWrapper(plugin, event));
plugin.getServer().getPluginManager().callEvent(new PostServerListSetEvent(entry));
}
}
@@ -28,15 +28,20 @@ package ch.andre601.advancedserverlist.paper.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.paper.PaperCore;
import ch.andre601.advancedserverlist.paper.objects.impl.PaperServerImpl;
import org.bukkit.Bukkit;
import org.bukkit.World;
public class PaperServerPlaceholders extends PlaceholderProvider{
public PaperServerPlaceholders(){
private final PaperCore plugin;
public PaperServerPlaceholders(PaperCore plugin){
super("server");
this.plugin = plugin;
}
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
if(!(server instanceof PaperServerImpl paperServer))
@@ -58,7 +63,7 @@ public class PaperServerPlaceholders extends PlaceholderProvider{
if(world == null)
continue;
players += world.getPlayers().size();
players += plugin.getPlayersOnline(world);
}
yield String.valueOf(players);
+2 -2
View File
@@ -37,10 +37,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.version>4.3.1</plugin.version>
<plugin.version>4.6.1</plugin.version>
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
<api.version>3.2.1</api.version>
<api.version>3.3.0</api.version>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
+1 -2
View File
@@ -1,4 +1,3 @@
mkdocs-material==9.5.12
mkdocs-material==9.5.14
mkdocs-glightbox==0.3.7
mkdocs-awesome-pages-plugin==2.9.2
git+https://github.com/Andre601/mkdocs-pagenav-generator
+15 -1
View File
@@ -63,24 +63,38 @@
<version>${api.version}</version>
<scope>compile</scope>
</dependency>
<!-- Velocity API -->
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Metrics -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<!-- Configurate -->
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
<!-- Plugins -->
<dependency>
<groupId>com.github.LeonMangler</groupId>
<artifactId>PremiumVanishAPI</artifactId>
<version>2.9.0-4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@@ -95,7 +109,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -41,14 +41,19 @@ import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
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.util.Favicon;
import de.myzelyam.api.vanish.VelocityVanishAPI;
import org.bstats.charts.SimplePie;
import org.bstats.velocity.Metrics;
import org.slf4j.LoggerFactory;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class VelocityCore implements PluginCore<Favicon>{
@@ -71,7 +76,7 @@ public class VelocityCore implements PluginCore<Favicon>{
@Subscribe
public void init(ProxyInitializeEvent event){
this.core = AdvancedServerList.init(this, VelocityPlayerPlaceholders.init(), VelocityServerPlaceholders.init());
this.core = AdvancedServerList.init(this, VelocityPlayerPlaceholders.init(), VelocityServerPlaceholders.init(this));
}
@Subscribe
@@ -154,11 +159,25 @@ public class VelocityCore implements PluginCore<Favicon>{
}
@Override
public Favicon createFavicon(BufferedImage image) throws Exception{
public Favicon createFavicon(BufferedImage image){
return Favicon.create(image);
}
public ProxyServer getProxy(){
return proxy;
}
public int getOnlinePlayers(RegisteredServer server){
if(getProxy() == null)
return -1;
List<Player> players = new ArrayList<>(server == null ? getProxy().getAllPlayers() : server.getPlayersConnected());
// Exclude players when PremiumVanish is enabled and player is hidden.
if(getProxy().getPluginManager().isLoaded("premiumvanish")){
players.removeIf(VelocityVanishAPI::isInvisible);
}
return players.size();
}
}
@@ -25,6 +25,8 @@
package ch.andre601.advancedserverlist.velocity.listeners;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.api.velocity.events.PostServerListSetEvent;
import ch.andre601.advancedserverlist.core.events.PingEventHandler;
import ch.andre601.advancedserverlist.velocity.VelocityCore;
import com.velocitypowered.api.event.PostOrder;
@@ -40,8 +42,10 @@ public class PingEvent{
plugin.getProxy().getEventManager().register(plugin, this);
}
@Subscribe(order = PostOrder.EARLY)
@Subscribe(order = PostOrder.LAST) // Maintenance has LAST priority, so ASL needs it too.
public void onProxyPing(ProxyPingEvent event){
PingEventHandler.handleEvent(new VelocityEventWrapper(plugin, event));
ProfileEntry entry = PingEventHandler.handleEvent(new VelocityEventWrapper(plugin, event));
plugin.getProxy().getEventManager().fire(new PostServerListSetEvent(entry));
}
}
@@ -44,10 +44,7 @@ import com.velocitypowered.api.proxy.server.ServerPing;
import com.velocitypowered.api.util.Favicon;
import net.kyori.adventure.text.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.ExecutionException;
public class VelocityEventWrapper implements GenericEventWrapper<Favicon, VelocityPlayerImpl>{
@@ -146,7 +143,11 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
@Override
public int getOnlinePlayers(){
return builder.getOnlinePlayers();
int players = plugin.getOnlinePlayers(null);
if(players == -1)
return builder.getOnlinePlayers();
return players;
}
@Override
@@ -29,16 +29,20 @@ import ch.andre601.advancedserverlist.api.PlaceholderProvider;
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.api.velocity.objects.VelocityProxy;
import ch.andre601.advancedserverlist.velocity.VelocityCore;
import com.velocitypowered.api.proxy.server.RegisteredServer;
public class VelocityServerPlaceholders extends PlaceholderProvider{
private VelocityServerPlaceholders(){
private final VelocityCore plugin;
private VelocityServerPlaceholders(VelocityCore plugin){
super("server");
this.plugin = plugin;
}
public static VelocityServerPlaceholders init(){
return new VelocityServerPlaceholders();
public static VelocityServerPlaceholders init(VelocityCore core){
return new VelocityServerPlaceholders(core);
}
@Override
@@ -62,7 +66,11 @@ public class VelocityServerPlaceholders extends PlaceholderProvider{
if(registeredServer == null)
continue;
players += registeredServer.getPlayersConnected().size();
int connected = plugin.getOnlinePlayers(registeredServer);
if(connected == -1)
continue;
players += connected;
}
yield String.valueOf(players);
+2 -2
View File
@@ -52,7 +52,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.2</version>
<version>1.5.3</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -93,7 +93,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<release>16</release>
</configuration>
@@ -35,7 +35,7 @@ public enum PlatformInfo{
"paper/target/AdvancedServerList-Paper-{{version}}.jar",
"addons/banplugins/target/AdvancedServerList-BanPlugins-Addon-{{version}}.jar"
),
"paper", "folia"
List.of("Paper", "Folia")
),
BUNGEECORD(
"bungeecord",
@@ -43,7 +43,7 @@ public enum PlatformInfo{
"bungeecord/target/AdvancedServerList-BungeeCord-{{version}}.jar",
"addons/banplugins/target/AdvancedServerList-BanPlugins-Addon-{{version}}.jar"
),
"bungeecord", "waterfall"
List.of("BungeeCord", "Waterfall")
),
VELOCITY(
"velocity",
@@ -51,17 +51,19 @@ public enum PlatformInfo{
"velocity/target/AdvancedServerList-Velocity-{{version}}.jar",
"addons/banplugins/target/AdvancedServerList-BanPlugins-Addon-{{version}}.jar"
),
"velocity"
List.of("Velocity")
);
private final String platform;
private final List<String> filePaths;
private final List<String> loaders;
private final List<String> platformNames;
PlatformInfo(String platform, List<String> filePaths, String... loaders){
PlatformInfo(String platform, List<String> filePaths, List<String> loaders){
this.platform = platform;
this.filePaths = filePaths;
this.loaders = List.of(loaders);
this.loaders = loaders.stream().map(String::toLowerCase).toList();
this.platformNames = loaders;
}
public String getPlatform(){
@@ -75,4 +77,8 @@ public enum PlatformInfo{
public List<String> getLoaders(){
return loaders;
}
public List<String> getPlatformNames(){
return platformNames;
}
}
@@ -25,18 +25,22 @@
package ch.andre601.advancedserverlist.versionuploader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ModrinthRelease{
public class ReleaseHolder{
Map<String, String> releases = new HashMap<>();
private final List<ReleaseInfo> releases = new ArrayList<>();
public void addRelease(String platform, String id){
releases.put(platform, id);
public void addRelease(String type, String platform, String url){
releases.add(new ReleaseInfo(type, platform, url));
}
public Map<String, String> getReleases(){
public List<ReleaseInfo> getReleases(){
return releases;
}
record ReleaseInfo(String type, String platform, String url){}
}
@@ -40,8 +40,8 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.StringJoiner;
import java.util.concurrent.CompletableFuture;
public class VersionUploader{
@@ -53,7 +53,7 @@ public class VersionUploader{
if(args.length == 0){
LOGGER.warn("MISSING ARGUMENT!");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar <--all|--modrinth|--hangar> [--dryrun]");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar [--dryrun] --all | --modrinth | --hangar");
System.exit(1);
return;
}
@@ -72,22 +72,19 @@ public class VersionUploader{
}
CompletableFuture<?> future;
ModrinthRelease modrinthRelease = null;
ReleaseHolder releaseHolder = new ReleaseHolder();
switch(args[0].toLowerCase(Locale.ROOT)){
case "--modrinth" -> {
modrinthRelease = new ModrinthRelease();
future = new ModrinthVersionUploader().performUpload(release, modrinthRelease, dryrun);
}
case "--hangar" -> future = new HangarVersionUploader().performUpload(release, dryrun);
case "--modrinth" -> future = new ModrinthVersionUploader().performUpload(release, releaseHolder, dryrun);
case "--hangar" -> future = new HangarVersionUploader().performUpload(release, releaseHolder, dryrun);
case "--all" -> {
modrinthRelease = new ModrinthRelease();
future = CompletableFuture.allOf(
new ModrinthVersionUploader().performUpload(release, modrinthRelease, dryrun),
new HangarVersionUploader().performUpload(release, dryrun)
new ModrinthVersionUploader().performUpload(release, releaseHolder, dryrun),
new HangarVersionUploader().performUpload(release, releaseHolder, dryrun)
);
}
default -> {
LOGGER.warn("Unknown argument '{}' provided. Supported are '--all', '--modrinth' or '--hangar'", args[0]);
LOGGER.warn("Unknown argument '{}' provided.", args[0]);
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar [--dryrun] --all | --modrinth | --hangar");
System.exit(1);
return;
}
@@ -111,8 +108,8 @@ public class VersionUploader{
System.exit(1);
}
if(modrinthRelease == null || modrinthRelease.getReleases().isEmpty()){
LOGGER.warn("No Modrinth release info on Discord to share... Skipping.");
if(releaseHolder.getReleases().isEmpty()){
LOGGER.warn("No releases to share on Discord... Skipping.");
return;
}
@@ -124,17 +121,31 @@ public class VersionUploader{
WebhookEmbedBuilder builder = new WebhookEmbedBuilder()
.setTitle(new WebhookEmbed.EmbedTitle("New Release", null))
.setDescription("A new release of AdvancedServerList is available on Modrinth for you to download!")
.setDescription("A new release of AdvancedServerList is available on Modrinth and Hangar for you to download!")
.setColor(0x1BD96A);
for(Map.Entry<String, String> entry : modrinthRelease.getReleases().entrySet()){
builder.addField(new WebhookEmbed.EmbedField(
false,
entry.getKey(),
"https://modrinth.com/plugin/advancedserverlist/version/" + entry.getValue()
));
StringJoiner modrinthText = new StringJoiner("\n");
String hangarText = null;
for(ReleaseHolder.ReleaseInfo info : releaseHolder.getReleases()){
String text = String.format("[%s](%s)", info.platform(), info.url());
if(info.type().equalsIgnoreCase("modrinth")){
modrinthText.add(text);
}else{
hangarText = text;
}
}
builder.addField(new WebhookEmbed.EmbedField(
true,
"Modrinth:",
modrinthText.toString()
)).addField(new WebhookEmbed.EmbedField(
true,
"Hangar:",
hangarText == null ? "No download available" : hangarText
));
try(WebhookClient client = new WebhookClientBuilder(webhookUrl).build()){
CompletableFuture<ReadonlyMessage> webhookFuture = client.send(builder.build()).whenComplete((readonlyMessage, throwable) -> {
if(throwable != null){
@@ -26,6 +26,7 @@
package ch.andre601.advancedserverlist.versionuploader.hangar;
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 ch.andre601.advancedserverlist.versionuploader.hangar.version.Dependency;
@@ -35,6 +36,7 @@ import ch.andre601.advancedserverlist.versionuploader.hangar.version.Version;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.entity.mime.FileBody;
@@ -72,7 +74,7 @@ public class HangarVersionUploader{
this.apiKey = System.getenv("HANGAR_API_TOKEN");
}
public CompletableFuture<?> performUpload(CodebergRelease release, boolean dryrun){
public CompletableFuture<?> performUpload(CodebergRelease release, ReleaseHolder releaseInfo, boolean dryrun){
LOGGER.info("Starting HangarVersionUploader...");
if((apiKey == null || apiKey.isEmpty()) && !dryrun){
@@ -145,14 +147,14 @@ public class HangarVersionUploader{
try{
HttpClient client = HttpClients.createDefault();
return uploadVersion(client, versionUpload, filePaths);
return uploadVersion(client, versionUpload, filePaths, releaseInfo);
}catch(ParseException | IOException ex){
LOGGER.warn("Encountered an exception while uploading to Hangar!", ex);
return CompletableFuture.completedFuture(ex);
}
}
private CompletableFuture<?> uploadVersion(HttpClient client, Version versionUpload, List<Path> filePaths) throws IOException, ParseException{
private CompletableFuture<?> uploadVersion(HttpClient client, Version versionUpload, List<Path> filePaths, ReleaseHolder releaseInfo) throws IOException, ParseException{
return CompletableFuture.supplyAsync(() -> {
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addPart("versionUpload", new StringBody(GSON.toJson(versionUpload), ContentType.APPLICATION_JSON));
@@ -174,7 +176,22 @@ public class HangarVersionUploader{
));
}
LOGGER.info("Successfully uploaded new release on Hangar!");
return true;
String body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
try{
JsonObject json = GSON.fromJson(body, JsonObject.class);
if(json == null)
return true;
releaseInfo.addRelease(
"hangar",
"Paper, Waterfall, Velocity",
json.getAsJsonPrimitive("url").getAsString()
);
return true;
}catch(JsonSyntaxException ex){
return true;
}
});
}catch(IOException ex){
LOGGER.warn("Encountered IOException while perfoming upload.", ex);
@@ -25,7 +25,7 @@
package ch.andre601.advancedserverlist.versionuploader.modrinth;
import ch.andre601.advancedserverlist.versionuploader.ModrinthRelease;
import ch.andre601.advancedserverlist.versionuploader.ReleaseHolder;
import ch.andre601.advancedserverlist.versionuploader.PlatformInfo;
import ch.andre601.advancedserverlist.versionuploader.VersionUploader;
import ch.andre601.advancedserverlist.versionuploader.data.CodebergRelease;
@@ -45,7 +45,9 @@ import java.util.concurrent.CompletableFuture;
public class ModrinthVersionUploader{
private static final Logger LOGGER = LoggerFactory.getLogger(ModrinthVersionUploader.class);
private final Logger logger = LoggerFactory.getLogger(ModrinthVersionUploader.class);
private final String versionUrl = "https://modrinth.com/plugin/advancedserverlist/version/";
private final List<PlatformInfo> platforms = List.of(
PlatformInfo.PAPER,
@@ -62,11 +64,11 @@ public class ModrinthVersionUploader{
this.api = createClient();
}
public CompletableFuture<?> performUpload(CodebergRelease release, ModrinthRelease modrinthRelease, boolean dryrun){
LOGGER.info("Starting ModrinthVersionUploader...");
public CompletableFuture<?> performUpload(CodebergRelease release, ReleaseHolder releaseHolder, boolean dryrun){
logger.info("Starting ModrinthVersionUploader...");
if(api == null){
LOGGER.warn("Cannot create updates on Modrinth. API instance is null.");
logger.warn("Cannot create updates on Modrinth. API instance is null.");
return CompletableFuture.completedFuture(false);
}
@@ -74,7 +76,7 @@ public class ModrinthVersionUploader{
final String pluginVersion = VersionUploader.retrieveVersion();
if(pluginVersion == null || pluginVersion.isEmpty()){
LOGGER.warn("Retrieved null/empty plugin version.");
logger.warn("Retrieved null/empty plugin version.");
return CompletableFuture.completedFuture(false);
}
@@ -97,7 +99,7 @@ public class ModrinthVersionUploader{
);
for(int i = 0; i < platforms.size(); i++){
LOGGER.info("Creating release for platform {}...", platforms.get(i).getPlatform());
logger.info("Creating release for platform {}...", platforms.get(i).getPlatform());
List<File> files = platforms.get(i).getFilePaths().stream()
.map(path -> new File(path.replace("{{version}}", pluginVersion)))
@@ -125,7 +127,7 @@ public class ModrinthVersionUploader{
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(builder.build());
LOGGER.info("JSON Data to send: {}", json);
logger.info("JSON Data to send: {}", json);
futures[i] = CompletableFuture.completedFuture(json);
continue;
@@ -134,14 +136,20 @@ public class ModrinthVersionUploader{
final int index = i;
futures[i] = api.versions().createProjectVersion(builder.build()).whenComplete(((projectVersion, throwable) -> {
if(throwable != null){
LOGGER.warn("Encountered an exception while uploading a new release to Modrinth!", throwable);
logger.warn("Encountered an exception while uploading a new release to Modrinth!", throwable);
return;
}
LOGGER.info("Created new release!");
LOGGER.info("Link: https://modrinth.com/plugin/advancedserverlist/version/{}", projectVersion.getId());
String url = versionUrl + projectVersion.getId();
modrinthRelease.addRelease(String.join(", ", platforms.get(index).getLoaders()), projectVersion.getId());
logger.info("Created new release!");
logger.info("Link: {}", url);
releaseHolder.addRelease(
"modrinth",
String.join(", ", platforms.get(index).getPlatformNames()),
url
);
}));
}