Compare commits

..
82 Commits
Author SHA1 Message Date
Andre601 dcb119df96 Fix ${player protocol} using the protocol of the proxy. 2024-04-10 14:31:43 +02:00
Andre601 78ae7fbcb2 Merge pull request 'Update dependency ch.qos.logback:logback-classic to v1.5.4' (#257) from renovate/ch.qos.logback-logback-classic-1.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/257
2024-04-09 23:57:48 +00:00
Andre601's Bot 1545aad32d Update dependency ch.qos.logback:logback-classic to v1.5.4 2024-04-09 12:10:52 +00:00
Andre601 035d485561 Forgot a closing double quote... 2024-04-08 00:48:00 +00:00
Andre601 f34a1ad2e4 Add gap 2024-04-08 00:44:56 +00:00
Andre601 5ceef81927 Add basic condition example 2024-04-08 00:41:24 +00:00
Andre601 6315f74312 Fix wrong link 2024-04-06 23:43:56 +00:00
Andre601 086a45593b Put negate example into admonition box 2024-04-05 22:37:44 +00:00
Andre601 1095166155 Remove unused placeholder 2024-04-04 01:03:52 +00:00
Andre601 bf89a7cb12 Add comment on failure action 2024-04-02 22:56:40 +00:00
Andre601 729b671c5a Add <filename> 2024-04-02 15:50:13 +00:00
Andre601 380791cd45 Merge pull request 'Update dependency mkdocs-material to v9.5.17' (#256) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/256
2024-04-02 12:09:37 +00:00
Andre601's Bot ca80083414 Update dependency mkdocs-material to v9.5.17 2024-04-02 12:01:00 +00:00
Andre601 ee7fa16514 Merge pull request 'Update dependency mkdocs-material to v9.5.16' (#255) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/255
2024-03-31 12:03:36 +00:00
Andre601's Bot c86a3d4101 Update dependency mkdocs-material to v9.5.16 2024-03-31 12:00:58 +00:00
Andre601 6fd6a8fe38 Re-add Hangar badge 2024-03-30 12:14:57 +00:00
Andre601 b05b38e0e8 Merge pull request 'Update actions/configure-pages action to v5' (#254) from renovate/actions-configure-pages-5.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/254
2024-03-30 12:02:18 +00:00
Andre601's Bot d55298d61b Update actions/configure-pages action to v5 2024-03-30 12:01:09 +00:00
Andre601 37ccf7176c Fix wrong relative link 2024-03-29 00:44:59 +00:00
Andre601 868c93ac09 Update api index about events 2024-03-29 00:42:45 +00:00
Andre601 f927e836f5 Merge pull request 'Update dependency mkdocs-material to v9.5.15' (#253) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/253
2024-03-27 22:49:40 +00:00
Andre601's Bot 2172628985 Update dependency mkdocs-material to v9.5.15 2024-03-27 22:46:32 +00:00
Andre601 628b1763da Merge pull request 'Update docs' (#252) from docs/update-docs into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/252
2024-03-27 15:58:39 +00:00
Andre601 bbe5fea132 Update docs 2024-03-27 16:51:01 +01:00
Andre601 8b555a8f53 .woodpecker/publish_assets.yml aktualisiert 2024-03-27 15:30:53 +00:00
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
63 changed files with 882 additions and 423 deletions

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
name: Pull Request
description: Create a new Pull request
body:
- type: markdown
attributes:
value: |-
Thank you for creating a Pull request!
Please be sure to fill out this template with all requested information to ensure it being valid and not being closed unmerged.
- type: dropdown
attributes:
label: Type
description: What kind of Pull request is this?
options:
- Enhancement
- Bugfix
- Documentation
validations:
required: true
- type: dropdown
attributes:
label: Breaking Change?
description: |-
Is this a breaking change?
A breaking change means that it becomes incompatible with previous server/proxy versions or plugin versions.
options:
- Yes
- No
validations:
required: true
- type: textarea
attributes:
label: Description
description: Provide a detailed description of what this Pull request is doing. Link any issues this Pull request may fix/close.
validations:
required: true
+1 -1
View File
@@ -39,7 +39,7 @@ jobs:
- name: Build docs
run: mkdocs build
- name: Configure GitHub Pages
uses: actions/configure-pages@v4
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
+67
View File
@@ -0,0 +1,67 @@
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
commentOnSuccess:
image: mcs94/gitea-comment
when:
- status: ['success']
secrets:
- bot_token
settings:
gitea_address: https://codeberg.org
gitea_token:
from_secret: BOT_TOKEN
comment: |-
Pull request Preview ready!
| Name | Value |
|--------|-------------------------------------------------------|
| Commit | ${CI_COMMIT_SHA} |
| Link | https://asl.andre601.ch/@pr-${CI_COMMIT_PULL_REQUEST} |
commentOnFailure:
image: mcs94/gitea-comment
when:
- status: ['failure']
secrets:
- bot_token
settings:
gitea_address: https://codeberg.org
gitea_token:
from_secret: BOT_TOKEN
comment: |-
Issue while creating Pull request preview.
Please check the CI logs for any reasons: ${CI_PIPELINE_URL}
+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_url: 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
-2
View File
@@ -8,11 +8,9 @@ AdvancedServerList is a plugin that allows you to customize your server's MOTD,
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact/available/modrinth_vector.svg" height="46" alt="modrinth" title="Available on Modrinth">
</a>
<br>
<!--
<a href="https://hangar.papermc.io/Andre_601/AdvancedServerList" target="_blank">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact/available/hangar_vector.svg" height="46" alt="hangar" title="Available on Hangar">
</a>
-->
## Supported Platforms
+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
+1 -1
View File
@@ -138,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>
@@ -142,7 +142,7 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
@Override
public int getProtocolVersion(){
return this.protocol.getProtocol();
return event.getConnection().getVersion();
}
@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));
}
}
+3 -3
View File
@@ -41,7 +41,7 @@
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<plugin.config.version>4</plugin.config.version>
<plugin.config.version>5</plugin.config.version>
</properties>
<repositories>
@@ -119,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>
@@ -158,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>
@@ -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());
}
}
+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 }
+19 -7
View File
@@ -361,18 +361,22 @@ Your plugin should now hook into AdvancedServerList and register its own custom
## Listening for events
<!-- admo:info This requires the platform specific dependencies -->
<!-- admo:info These events require the platform-specific APIs -->
AdvancedServerList provides an Event that your plugin can listen for.
The event is called `PreServerListSetEvent` and provides the following methods to use:
AdvancedServerList provides Events that your plugin can listen for specific situations.
### PreServerListSetEvent
This event is called **before** AdvancedServerList starts handling the PingEvent of the Server/Proxy.
It allows you to get and alter the [ProfileEntry][profileentry] used in the PingEvent, or even outright cancel the event itself.
The event offers the following methods:
- [`getEntry()`][getentry] - Gets the currently set [`ProfileEntry`][profileentry].
- [`setEntry(ProfileEntry)`][setentry] - Sets a new [`ProfileEntry`][profileentry] to use.
- [`isCancelled()`][iscancelled] - Gets the current cancelled state of the event.
- [`setCancelled(boolean)`][setcancelled] - Sets the current cancelled state.
Setting the event's cancelled state to true will result in AdvancedServerList not altering the Server list.
Please check the server/proxy's documentation on how to listen for events with your plugin.
[getentry]: reference/api/ch.andre601.advancedserverlist.api/events/genericserverlistevent.md#getentry()
@@ -380,6 +384,13 @@ Please check the server/proxy's documentation on how to listen for events with y
[iscancelled]: reference/api/ch.andre601.advancedserverlist.api/events/genericserverlistevent.md#iscancelled()
[setcancelled]: reference/api/ch.andre601.advancedserverlist.api/events/genericserverlistevent.md#setcancelled(boolean)
### PostServerListSetEvent
This event is called **after** AdvancedServerList has completed its handling of the Server's/Proxy's PingEvent.
It provides a method to retrieve the [ProfileEntry][profileentry] used during the PingEvent.
Do note that this ProfileEntry is **not** a representation of what is actually displayed in the server list, but rather what has been used by AdvancedServerList. It may also be `null` should the event handling get cancelled for any reason.
[profileentry]: reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/index.md
### ProfileEntry
@@ -387,8 +398,9 @@ Please check the server/proxy's documentation on how to listen for events with y
The ProfileEntry record is the core class used within the `PreServerListSetEvent`. It sets what values (MOTD, Favicon, Players, etc.) should be displayed.
Note that the record is - by nature - immutable and that the [`Builder`][builder] class should be used to create a new ProfileEntry instance to use.
A convenience method exists to create a `Builder` instance from an existing `ProfileEntry` in case you only want to alter certain options while everything else unchanged.
A convenience method ([`builder()`][builder()]) exists to create a `Builder` instance from an existing `ProfileEntry` in case you only want to alter certain options while everything else should remain unchanged.
This allows you to customize the Server list using your plugin. Just keep in mind that other plugins may also do the same, overriding your changes.
[builder]: reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/builder.md
[builder]: reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/builder.md
[builder()]: reference/api/ch.andre601.advancedserverlist.api/profiles/profileentry/index.md#builder()
+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
+7 -1
View File
@@ -21,18 +21,24 @@ The following subcommands are available (Subcommands are case-insensitive):
### help
/// info |
**Permission:** `advancedserverlist.command.help`
Shows a list of all available [subcommands](#subcommands) for AdvancedServerList.
///
### reload
/// info |
**Permission:** `advancedserverlist.command.reload`
Reloads the plugin's `config.yml` and all available YAML files in the `profiles` folder.
///
### clearCache
/// info |
**Permission:** `advancedserverlist.command.clearcache`
Clears the currently cached favicons and players.
Clears the currently cached favicons and players.
///
+139 -99
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,18 +52,18 @@ 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:**
:fontawesome-solid-paper-plane: Paper
- [**ViaVersion**][viaversion]
- [**ViaVersion**][viaversion]{ target="_blank" rel="nofollow" }
----
@@ -74,7 +74,7 @@ The plugin also supports these additional plugins. They are all optional.
**Supported on:**
:fontawesome-solid-paper-plane: Paper
- [**PAPIProxyBridge**][papiproxybridge]
- [**PAPIProxyBridge**][papiproxybridge]{ target="_blank" rel="nofollow" }
----
@@ -85,11 +85,11 @@ The plugin also supports these additional plugins. They are all optional.
**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.
AdvancedServerList will disable any modification of the server list entry should Maintenance mode be enabled, unless you change this in the config.yml file.
----
@@ -117,7 +117,7 @@ The plugin also supports these additional plugins. They are all optional.
## 2. Installation { #installation }
Installing the plugin is as simple as moving the jar file into the plugins folder. Just make sure to download the right version of AdvancedServerList for the right platform.
Installing the plugin is as simple as moving the jar file into the `plugins` folder. Just make sure to download the right version of AdvancedServerList for the right platform.
Here is a quick table showing the jar file name with the platforms it is made for:
| Jar file name | Platforms |
@@ -133,7 +133,7 @@ If everything goes well should AdvancedServerList create a folder named `Advance
When you install AdvancedServerList for the first time should it have created the following file structure inside the plugins folder of your Server or Proxy:
```
AdvancedServerList/
AdvancedServerList/ # advancedserverlist/ on Velocity
├── favicons/
├── profiles/
│ └── default.yml
@@ -156,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
#
@@ -334,10 +337,11 @@ These functions include, but aren't limited to:
- Disabling/Enabling checking for updates.
- Disabling/Enabling debug mode.
- Setting how long favicons should be cached for.
- Disabling/Enabling features of the plugin while the plugin Maintenance is active.
- The config version used for migration. Don't touch this, or it may reset your config.
Similar to the default.yml is this file containing comments to try and explain the settings in questions.
Do note that if the config gets migrated from an older version, that the comments will be discarded in the process, unfortunately.
Note that the config can get migrated to newer versions, adding missing options in the process. However, comments will get lost during that process.
/// details | default config.yml content
type: file
@@ -395,23 +399,59 @@ 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
```
///
#### Additionally created files and folders
#### Additional created files and folders
There are certain files and folders that get created when certain events happen:
- A `playercache.json` file will be created on plugin shutdown containing a collection of IPs, UUIDs and Player names for every player that joined the server while AdvancedServerList was running.
This file is used to identify a player through their last used IP, to replace placeholders such as `${player name}` or `${player uuid}` with their respective values using the cached data.
This file is not created, used nor updated when `disableCache` is set to `true` in the config.yml
This file is not created, used, nor updated when `disableCache` is set to `true` in the config.yml
- A `backups` folder containing old config.yml files.
This folder is created when AdvancedServerList migrates your old config to a new version. This allows you to transfer settings over in case the migration didn't work properly.
Each backup will have the name pattern `config-<date>.yml` with `<date>` being the date and time of when this file has been created.
@@ -424,7 +464,7 @@ It's best to open the `default.yml` file located inside `profiles` with the file
This file should contain all available options that you can set and alter.
Edit the options to whatever you like. All text-based options, except [`condition`](../profiles/index.md#condition), support [MiniMessage formatting](../profiles/formatting.md).
The [`motd`](../profiles/index.md#motd) option also supports Hexadecimal colors, assuming the server/proxy runs at least MC 1.16.
Hexadecimal (RGB) colors are supported, however, only the [`motd` option](../profiles/index.md#motd) may display them and only for MC 1.16+ clients. Any other option will have the color down-sampled to the nearest supported color code.
If you're unsure how a specific option should look like, head over to the [Profiles page](../profiles/index.md) for more information about the general structure.
All you need to know is, that a bare-bones server list profile requires a valid [priority](../profiles/index.md#priority) and at least one of the settings to be present.
@@ -440,16 +480,16 @@ motd:
### Additional profiles
To add additional profiles, create a new YAML file inside the `profiles` folder. The name doesn't matter, but it is recommended to keep it lowercase, use alphanumeric characters (`a-z, 0-9`), hyphens (`-`), underscores (`_`) and avoid spaces. You should also name it after what it is for, to have it more easily organized.
To add additional profiles, create a new YAML file inside the `profiles` folder. The name can be whatever you like, but it is recommended to keep it simple and only use alphanumeric characters (`a-z` and `0-9`), underlines and hyphens.
Inside the file, add a priority and at least one setting, similar to the above shown example.
This would already be enough to have a valid profile, but depending on the priority and file name may the file not be used, or used over other profiles.
If you want to only show this file under specific situations can you use the [`condition`](../profiles/index.md#condition) option to apply conditions that need to be met to show the profile.
The condition option would have a single String containing one or muliple [Expressions](../profiles/expressions.md). Only if the condition would return true, would the profile be displayed, granted that it has a higher priority than any other valid file with a true condition output.
The condition option would have a single String containing one or multiple [Expressions](../profiles/expressions.md). Only if the condition would return true, would the profile be displayed, granted that it has a higher priority than any other valid file with a true condition output.
/// info | Note
Profiles which do not have any conditions, or have an empty condition, will always be considered to have a true condition, meaning that a profile with higher priority and no condition will be selected over a profile with lower priority and a condition, even if said condition returns true.
Files without a condition or an empty condition will be treated as always having a true condition.
///
Here is another example profile using conditions to show it when the player was banned on the server:
+56 -35
View File
@@ -7,18 +7,21 @@ icon: octicons/home-24
Welcome to the Wiki of AdvancedServerList!
On this site can you find the latest documentation for the plugin, including some useful examples.
If you're new to the plugin is it recommended to check out the [Profiles page](profiles/index.md) for a quick start on how to use this plugin.
If you're new to the plugin, check out [:octicons-milestone-24: **Getting Started**](getting-started/index.md) for a quick Start Guide.
## 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}!'
-1
View File
@@ -16,7 +16,6 @@ Note that the values depend on the player it is used for, as AdvancedServerList
| Placeholder | Description |
|----------------------------------|--------------------------------------------------------------------------------------------------------|
| `%asl_favicon%` | Gives the value of `favicon` from a matching Profile. |
| `%asl_extra_players_max%` | Gives the value of `playerCount -> extraPlayers -> amount` from a matching Profile. Can return `null`. |
| `%asl_motd%` | Gives the value of `motd` in the matching Profile as a single String. |
| `%asl_playercount_extraplayers%` | Gives the value of `playerCount -> extraPlayers -> amount` from a matching Profile. Can return `null`. |
| `%asl_playercount_hover%` | Gives the value of `playerCount -> hover` from a matching Profile as a single String. |
+2
View File
@@ -126,9 +126,11 @@ Parenthesis can be used to prevent ambiguities.
`!` can be used to negate boolean expressions.
/// example | Examples
```shell
!${player isWhitelisted}
```
///
## Credits
+1 -1
View File
@@ -4,7 +4,7 @@ icon: octicons/pencil-24
# Formatting
All text options, with exception of [`Conditions`](../index.md#conditions), allow the usage of formatting options using [MiniMessage].
All text options, with exception of [`Conditions`](index.md#condition), allow the usage of formatting options using [MiniMessage].
/// info | Online Tool
The devs of the Adventure library provide a handy online tool to create the right formatting codes to display the text properly.
+14
View File
@@ -40,6 +40,20 @@ Not setting this option, or setting it to an empty String (`condition: ''`), wil
The condition option can hold one or multiple expressions. The Expression system is explained on the [Expressions page](expressions.md).
/// details | Example
type: example
```yaml title="YAML file"
priority: 0
condition: '${player isWhitelisted}'
motd:
- '<grey>Hello ${player name}!'
- '<grey>Nice to see you.'
```
///
## Profiles
The `profile` option allows you to define a list of all other options, with the exception of [`priority`](#priority), [`condition`](#condition) or itself.
+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
+1 -1
View File
@@ -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>
@@ -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));
}
}
+2 -2
View File
@@ -37,10 +37,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.version>4.4.0</plugin.version>
<plugin.version>4.6.2</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.13
mkdocs-material==9.5.17
mkdocs-glightbox==0.3.7
mkdocs-awesome-pages-plugin==2.9.2
git+https://github.com/Andre601/mkdocs-pagenav-generator
+1 -1
View File
@@ -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>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -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));
}
}
@@ -138,7 +138,7 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
@Override
public int getProtocolVersion(){
return protocol.getProtocol();
return event.getConnection().getProtocolVersion().getProtocol();
}
@Override
+2 -2
View File
@@ -52,7 +52,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.3</version>
<version>1.5.4</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
);
}));
}