mirror of
https://codeberg.org/Andre601/AdvancedServerList.git
synced 2026-11-05 09:00:15 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dedd9368f | ||
|
|
f2df3727a7 | ||
|
|
2b7c24daa4 | ||
|
|
1e042461ac | ||
|
|
599c2db2bc | ||
|
|
87505f820c | ||
|
|
28109c8b5b | ||
|
|
243854592d | ||
|
|
4648bc30e9 | ||
|
|
f9a96e5525 | ||
|
|
d158fb852f | ||
|
|
77f95900e2 | ||
|
|
912fec1875 | ||
|
|
dba9ca20a4 | ||
|
|
7b94ae52db | ||
|
|
6d3bf50278 | ||
|
|
8039088fb9 | ||
|
|
ecaaf7bbf3 | ||
|
|
dd970cfabf | ||
|
|
a888481674 | ||
|
|
ee68eafc63 | ||
|
|
f22313a5c8 | ||
|
|
9603155722 | ||
|
|
df938485b2 | ||
|
|
0ddda8bd78 | ||
|
|
56a83e88fb | ||
|
|
1947f627ef | ||
|
|
3c344f9a5d | ||
|
|
8e2004cb81 | ||
|
|
004d723c81 | ||
|
|
90fb6a2654 | ||
|
|
0eb5daac81 | ||
|
|
f23f282ba9 | ||
|
|
df705c0c14 | ||
|
|
f27202f2df | ||
|
|
0d84335db9 | ||
|
|
50f878e39c | ||
|
|
b88ee87c96 | ||
|
|
a5f6e689f0 | ||
|
|
dd0bc8a43a | ||
|
|
563362504f | ||
|
|
bd95be080e | ||
|
|
2d02d48d3c | ||
|
|
15f7b5def3 | ||
|
|
f37813d5b7 | ||
|
|
93c2dda56b |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
patreon: andre_601
|
||||
ko_fi: andre_601
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
@@ -1,23 +1,95 @@
|
||||
name: Build Jars
|
||||
#
|
||||
# Big thank you to @Kir-Antipov for providing this workflow file.
|
||||
# Check out his mc-publish action here: https://github.com/Kir-Antipov/mc-publish
|
||||
#
|
||||
|
||||
name: Publish Assets
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
buildJars:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 1.11
|
||||
- name: Set up JDK 1.16
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '16'
|
||||
- name: Build jar
|
||||
cache: 'maven'
|
||||
- name: Build Jar files
|
||||
run: mvn clean install
|
||||
- name: Upload jar
|
||||
uses: AButler/upload-release-assets@v2.0
|
||||
- name: Save BungeeCord Jar file
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
files: 'bungeecord/target/AdvancedServerList-*.jar;paper/target/AdvancedServerList-*.jar;spigot/target/AdvancedServerList-*.jar;velocity/target/AdvancedServerList-*.jar'
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: asl-bungeecord
|
||||
path: bungeecord/target/AdvancedServerList-*.jar
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
- name: Save Paper Jar file
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: asl-paper
|
||||
path: paper/target/AdvancedServerList-*.jar
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
- name: Save Spigot Jar file
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: asl-spigot
|
||||
path: spigot/target/AdvancedServerList-*.jar
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
- name: Save Velocity Jar file
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: asl-velocity
|
||||
path: velocity/target/AdvancedServerList-*.jar
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
publish:
|
||||
needs: [buildJars]
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- directory: bungeecord
|
||||
loaders: |
|
||||
bungeecord
|
||||
waterfall
|
||||
- directory: paper
|
||||
loaders: paper
|
||||
- directory: spigot
|
||||
loaders: spigot
|
||||
- directory: velocity
|
||||
loaders: velocity
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Get Jar files
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: asl-${{ matrix.directory }}
|
||||
path: ${{ matrix.directory }}/target
|
||||
- name: Get Version
|
||||
id: github-release
|
||||
run: |
|
||||
version=$(echo ${{ github.event.release.tag_name }} | cut -d'v' -f2)
|
||||
echo "::set-output name=version::$version"
|
||||
- name: Upload AdvancedServerList (${{ matrix.loaders }}) to GitHub and Modrinth
|
||||
uses: Kir-Antipov/mc-publish@v3.2
|
||||
with:
|
||||
name: ${{ github.event.release.name }}
|
||||
version: ${{ steps.github-release.outputs.version }}
|
||||
version-type: release
|
||||
files: ${{ matrix.directory}}/target/AdvancedServerList-*.jar
|
||||
files-secondary: ""
|
||||
loaders: ${{ matrix.loaders }}
|
||||
version-resolver: releases
|
||||
game-versions: '1.19'
|
||||
java: 16
|
||||
modrinth-id: xss83sOY
|
||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -4,42 +4,57 @@
|
||||
AdvancedServerList is a plugin made for SpigotMC, PaperMC, BungeeCord/Waterfall and Velocity. It allows you to create server list profiles to display based on priority and conditions.
|
||||
|
||||
## What is a Server List Profile?
|
||||
A Server List Profile is a YAML file located in the plugin’s profiles folder having a priority, conditions (Optional), MOTD, Player count text, hover for player count and hiding the player count completely (Changing it to ???)
|
||||
A Server List Profile refers to a YAML file located in the plugin's `profiles` directory.
|
||||
It allows you to configure specific aspects of the server display in the MC-Client's multiplayer server list, such as the MOTD, player count text, player count hover or Favicon.
|
||||
|
||||
> [*Read More*][profiles]
|
||||
|
||||
### Conditions
|
||||
Thanks to conditions can you determine when a profile should be displayed in the player’s server list, to allow displaying specific text (i.e. a warning when they are using an outdated version).
|
||||
|
||||
When multiple profiles exist that have valid conditions will the one with highest priority (Higher number = higher priority) be selected. Having no conditions makes the profile automatically return true.
|
||||
When multiple profiles exist that have valid conditions will the one with the highest priority (Higher number = higher priority) be selected. Having no conditions makes the profile automatically return true.
|
||||
|
||||
> [Read More][conditions]
|
||||
> [*Read More*][conditions]
|
||||
|
||||
### Placeholders
|
||||
Placeholders can be used within conditions to further customize them. They can also be used in any other text option (motd, playerCount and players) to display their respective value.
|
||||
The format is ${<target> <identifier>} which was adopted from BungeeTabListPlus. Depending on what platform you use the plugin on are only specific placeholders available.
|
||||
Placeholders can be used within conditions to further customize them. They can also be used in any other text option (motd, playerCount and players) to display their respective values.
|
||||
The format is `${<target> <identifier>}` which was adopted from BungeeTabListPlus. Depending on what platform you use the plugin on are only specific placeholders available.
|
||||
|
||||
When using the SpigotMC/PaperMC version can you also use placeholders from PlaceholderAPI using its %<identifier>_<values>% format. PlaceholderAPI needs to be installed for that.
|
||||
When using the SpigotMC/PaperMC version can you also use placeholders from [PlaceholderAPI][placeholderapi] using its `%<identifier>_<values>%` placeholder format. PlaceholderAPI needs to be installed for that.
|
||||
|
||||
> [Read More][placeholders]
|
||||
> [*Read More*][placeholders]
|
||||
|
||||
### Formatting
|
||||
The plugin uses the MiniMessage format for a consistent, easy way of formatting your text.
|
||||
Depending on the option you use can you use more advanced formatting options such as HEX colours and gradients (Only available for the motd option).
|
||||
Only certain options are usable for each option. As an example does motd support HEX colours and gradients, while the other options only support default colour codes.
|
||||
|
||||
> [Read More][minimessage]
|
||||
> [*Read More*][minimessage]
|
||||
|
||||
## Downloads
|
||||
AdvancedServerList can be downloaded from the following places:
|
||||
|
||||
[![dl-modrinth]][modrinth] [![dl-spigot]][spigot] [![dl-hangar]][hangar]
|
||||
|
||||
## Dependencies
|
||||
|
||||
| Dependency | Platforms | Required? |
|
||||
| ---------------- | ------------- | --------- |
|
||||
| [ProtocolLib] | Spigot | Yes |
|
||||
| [PlaceholderAPI] | Spigot, Paper | No |
|
||||
|
||||
## Statistics
|
||||
|
||||
This plugin sends statistics to [bStats] to display.
|
||||
You can disable this in the `config.yml` by setting `send_statistics` to `false`.
|
||||
|
||||
- [BungeeCord][bstats-bungee]
|
||||
- [Paper/Spigot][bstats-spigot]
|
||||
- [Velocity][bstats-velocity]
|
||||
|
||||
## Screenshots
|
||||
Here are screenshots showing the plugin in action. Do you have your own screenshots that you would like to share? Let me know and I may add them here with proper credit.
|
||||
|
||||
![showcase]
|
||||
|
||||
![features]
|
||||
Please see the [Gallery Tab][gallery] for some previews.
|
||||
If you have any own screenshots, feel free to share them with me. I may add them to the Gallery if they are good.
|
||||
|
||||
<!-- Links -->
|
||||
[profiles]: https://github.com/Andre601/AdvancedServerList/wiki/Profiles
|
||||
@@ -47,16 +62,24 @@ Here are screenshots showing the plugin in action. Do you have your own screensh
|
||||
[placeholders]: https://github.com/Andre601/AdvancedServerList/wiki/Profiles#placeholders
|
||||
[minimessage]: https://github.com/Andre601/AdvancedServerList/wiki/Profiles#minimessage
|
||||
|
||||
[modrinth]: https://modrinth.com/mod/advancedserverlist
|
||||
[placeholderapi]: https://www.spigotmc.org/resources/6245/
|
||||
|
||||
[modrinth]: https://modrinth.com/plugin/advancedserverlist
|
||||
[spigot]: https://www.spigotmc.org/resources/102910/
|
||||
[hangar]: https://hangar.benndorf.dev/Andre_601/AdvancedServerList
|
||||
|
||||
<!-- images -->
|
||||
[showcase]: https://cdn.discordapp.com/attachments/417019799365746690/990379003250626580/unknown.png
|
||||
[features]: https://cdn.discordapp.com/attachments/990389158944055366/1004042735973568522/2022-08-02_17.03.40.jpg
|
||||
[protocollib]: https://www.spigotmc.org/resources/1997/
|
||||
[placeholderapi]: https://www.spigotmc.org/resources/6245/
|
||||
|
||||
[bstats]: https://bstats.org
|
||||
[bstats-bungee]: https://bstats.org/plugin/bungeecord/AdvancedServerList/15585
|
||||
[bstats-spigot]: https://bstats.org/plugin/bukkit/AdvancedServerList/15584
|
||||
[bstats-velocity]: https://bstats.org/plugin/velocity/AdvancedServerList/15587
|
||||
|
||||
[gallery]: https://modrinth.com/mod/advancedserverlist/gallery
|
||||
|
||||
<!-- Badges -->
|
||||
[platform]: https://img.shields.io/badge/Platforms-Spigot%20%7C%20PaperMC%20%7C%20BungeeCord%20%7C%20Velocity-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSJ3aGl0ZSI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTEuMDYzIDEuNDU2YTEuNzUgMS43NSAwIDAxMS44NzQgMGw4LjM4MyA1LjMxNmExLjc1IDEuNzUgMCAwMTAgMi45NTZsLTguMzgzIDUuMzE2YTEuNzUgMS43NSAwIDAxLTEuODc0IDBMMi42OCA5LjcyOGExLjc1IDEuNzUgMCAwMTAtMi45NTZsOC4zODMtNS4zMTZ6bTEuMDcxIDEuMjY3YS4yNS4yNSAwIDAwLS4yNjggMEwzLjQ4MyA4LjAzOWEuMjUuMjUgMCAwMDAgLjQyMmw4LjM4MyA1LjMxNmEuMjUuMjUgMCAwMC4yNjggMGw4LjM4My01LjMxNmEuMjUuMjUgMCAwMDAtLjQyMmwtOC4zODMtNS4zMTZ6Ij48L3BhdGg+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS44NjcgMTIuMzI0YS43NS43NSAwIDAxMS4wMzUtLjIzMmw4Ljk2NCA1LjY4NWEuMjUuMjUgMCAwMC4yNjggMGw4Ljk2NC01LjY4NWEuNzUuNzUgMCAwMS44MDQgMS4yNjdsLTguOTY1IDUuNjg1YTEuNzUgMS43NSAwIDAxLTEuODc0IDBsLTguOTY1LTUuNjg1YS43NS43NSAwIDAxLS4yMzEtMS4wMzV6Ij48L3BhdGg+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS44NjcgMTYuMzI0YS43NS43NSAwIDAxMS4wMzUtLjIzMmw4Ljk2NCA1LjY4NWEuMjUuMjUgMCAwMC4yNjggMGw4Ljk2NC01LjY4NWEuNzUuNzUgMCAwMS44MDQgMS4yNjdsLTguOTY1IDUuNjg1YTEuNzUgMS43NSAwIDAxLTEuODc0IDBsLTguOTY1LTUuNjg1YS43NS43NSAwIDAxLS4yMzEtMS4wMzV6Ij48L3BhdGg+PC9zdmc+
|
||||
[platform]: https://img.shields.io/badge/Platforms-Spigot%20%7C%20Paper%20%7C%20BungeeCord%20%7C%20Velocity-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSJ3aGl0ZSI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTEuMDYzIDEuNDU2YTEuNzUgMS43NSAwIDAxMS44NzQgMGw4LjM4MyA1LjMxNmExLjc1IDEuNzUgMCAwMTAgMi45NTZsLTguMzgzIDUuMzE2YTEuNzUgMS43NSAwIDAxLTEuODc0IDBMMi42OCA5LjcyOGExLjc1IDEuNzUgMCAwMTAtMi45NTZsOC4zODMtNS4zMTZ6bTEuMDcxIDEuMjY3YS4yNS4yNSAwIDAwLS4yNjggMEwzLjQ4MyA4LjAzOWEuMjUuMjUgMCAwMDAgLjQyMmw4LjM4MyA1LjMxNmEuMjUuMjUgMCAwMC4yNjggMGw4LjM4My01LjMxNmEuMjUuMjUgMCAwMDAtLjQyMmwtOC4zODMtNS4zMTZ6Ij48L3BhdGg+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS44NjcgMTIuMzI0YS43NS43NSAwIDAxMS4wMzUtLjIzMmw4Ljk2NCA1LjY4NWEuMjUuMjUgMCAwMC4yNjggMGw4Ljk2NC01LjY4NWEuNzUuNzUgMCAwMS44MDQgMS4yNjdsLTguOTY1IDUuNjg1YTEuNzUgMS43NSAwIDAxLTEuODc0IDBsLTguOTY1LTUuNjg1YS43NS43NSAwIDAxLS4yMzEtMS4wMzV6Ij48L3BhdGg+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS44NjcgMTYuMzI0YS43NS43NSAwIDAxMS4wMzUtLjIzMmw4Ljk2NCA1LjY4NWEuMjUuMjUgMCAwMC4yNjggMGw4Ljk2NC01LjY4NWEuNzUuNzUgMCAwMS44MDQgMS4yNjdsLTguOTY1IDUuNjg1YTEuNzUgMS43NSAwIDAxLTEuODc0IDBsLTguOTY1LTUuNjg1YS43NS43NSAwIDAxLS4yMzEtMS4wMzV6Ij48L3BhdGg+PC9zdmc+
|
||||
|
||||
[tested]: https://img.shields.io/badge/Tested%20Versions-1.19%20%7C%201.19.1%20%7C%201.19.2-blue?style=for-the-badge&logo=image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSJ3aGl0ZSI+PHBhdGggZD0iTTE3LjI4IDkuMjhhLjc1Ljc1IDAgMDAtMS4wNi0xLjA2bC01Ljk3IDUuOTctMi40Ny0yLjQ3YS43NS43NSAwIDAwLTEuMDYgMS4wNmwzIDNhLjc1Ljc1IDAgMDAxLjA2IDBsNi41LTYuNXoiPjwvcGF0aD48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0zLjc1IDJBMS43NSAxLjc1IDAgMDAyIDMuNzV2MTYuNWMwIC45NjYuNzg0IDEuNzUgMS43NSAxLjc1aDE2LjVBMS43NSAxLjc1IDAgMDAyMiAyMC4yNVYzLjc1QTEuNzUgMS43NSAwIDAwMjAuMjUgMkgzLjc1ek0zLjUgMy43NWEuMjUuMjUgMCAwMS4yNS0uMjVoMTYuNWEuMjUuMjUgMCAwMS4yNS4yNXYxNi41YS4yNS4yNSAwIDAxLS4yNS4yNUgzLjc1YS4yNS4yNSAwIDAxLS4yNS0uMjVWMy43NXoiPjwvcGF0aD48L3N2Zz4=
|
||||
|
||||
|
||||
+7
-3
@@ -105,20 +105,24 @@
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.spongepowered.configurate</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.configurate</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.adventure</shadedPattern>
|
||||
<pattern>net.kyori</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.kyori</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.caffeine</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
<filter>
|
||||
|
||||
+17
-1
@@ -32,15 +32,18 @@ import ch.andre601.advancedserverlist.bungeecord.logging.BungeeLogger;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class BungeeCordCore extends Plugin implements PluginCore{
|
||||
public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
|
||||
|
||||
private AdvancedServerList core;
|
||||
private FaviconHandler<Favicon> faviconHandler = null;
|
||||
private final PluginLogger logger = new BungeeLogger(getLogger());
|
||||
|
||||
@Override
|
||||
@@ -72,6 +75,11 @@ public class BungeeCordCore extends Plugin implements PluginCore{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFaviconCache(){
|
||||
faviconHandler.clearCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedServerList getCore(){
|
||||
return core;
|
||||
@@ -87,6 +95,14 @@ public class BungeeCordCore extends Plugin implements PluginCore{
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaviconHandler<Favicon> getFaviconHandler(){
|
||||
if(faviconHandler == null)
|
||||
faviconHandler = new FaviconHandler<>(core);
|
||||
|
||||
return faviconHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName(){
|
||||
return getProxy().getName();
|
||||
|
||||
+27
-8
@@ -31,9 +31,11 @@ import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ProfileManager;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.PlayerPlaceholders;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.ServerPlaceholders;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
@@ -59,15 +61,15 @@ public class PingEvent implements Listener{
|
||||
if(protocol == null)
|
||||
return;
|
||||
|
||||
InetSocketAddress address = (InetSocketAddress)event.getConnection().getSocketAddress();
|
||||
String playerName = plugin.getCore().getPlayerHandler().getPlayerByIp(
|
||||
((InetSocketAddress)event.getConnection().getSocketAddress()).getHostString()
|
||||
);
|
||||
InetSocketAddress host = event.getConnection().getVirtualHost();
|
||||
|
||||
int online = ping.getPlayers().getOnline();
|
||||
int max = ping.getPlayers().getMax();
|
||||
|
||||
PlayerPlaceholders playerPlaceholders = new PlayerPlaceholders(
|
||||
new BungeePlayer(plugin.getCore().getPlayerHandler().getPlayerByIp(address.getHostString()), protocol.getProtocol())
|
||||
);
|
||||
PlayerPlaceholders playerPlaceholders = new PlayerPlaceholders(new BungeePlayer(playerName, protocol.getProtocol()));
|
||||
ServerPlaceholders serverPlaceholders = new ServerPlaceholders(online, max, host == null ? null : host.getHostString());
|
||||
|
||||
ServerListProfile profile = ProfileManager.get(plugin.getCore())
|
||||
@@ -78,8 +80,8 @@ public class PingEvent implements Listener{
|
||||
if(profile == null)
|
||||
return;
|
||||
|
||||
if(profile.isOneMore()){
|
||||
max = online + 1;
|
||||
if(profile.getXMore() >= 0){
|
||||
max = online + profile.getXMore();
|
||||
ping.getPlayers().setMax(max);
|
||||
}
|
||||
|
||||
@@ -126,10 +128,27 @@ public class PingEvent implements Listener{
|
||||
|
||||
if(playerInfos.length > 0)
|
||||
ping.getPlayers().setSample(playerInfos);
|
||||
|
||||
}
|
||||
|
||||
ping.setFavicon(ping.getFaviconObject());
|
||||
if(!profile.getFavicon().isEmpty()){
|
||||
String favName = StringReplacer.replace(profile.getFavicon(), playerPlaceholders.getReplacements());
|
||||
|
||||
Favicon favicon = plugin.getFaviconHandler().getFavicon(favName, image -> {
|
||||
try{
|
||||
return Favicon.create(image);
|
||||
}catch(Exception ex){
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if(favicon == null){
|
||||
plugin.getPluginLogger().warn("Could not obtain valid Favicon to use.");
|
||||
ping.setFavicon(ping.getFaviconObject());
|
||||
}else{
|
||||
ping.setFavicon(favicon);
|
||||
}
|
||||
}
|
||||
|
||||
ping.setVersion(protocol);
|
||||
|
||||
event.setResponse(ping);
|
||||
|
||||
+7
-1
@@ -64,6 +64,12 @@
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<version>4.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -85,7 +91,7 @@
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
|
||||
@@ -29,9 +29,7 @@ import ch.andre601.advancedserverlist.core.commands.CommandHandler;
|
||||
import ch.andre601.advancedserverlist.core.file.FileHandler;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.profiles.players.GenericPlayer;
|
||||
import ch.andre601.advancedserverlist.core.profiles.players.PlayerHandler;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.PlayerPlaceholders;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -83,6 +81,10 @@ public class AdvancedServerList{
|
||||
getPluginLogger().info("AdvancedServerList disabled!");
|
||||
}
|
||||
|
||||
public void clearFaviconCache(){
|
||||
plugin.clearFaviconCache();
|
||||
}
|
||||
|
||||
public PluginLogger getPluginLogger(){
|
||||
return plugin.getPluginLogger();
|
||||
}
|
||||
@@ -113,7 +115,7 @@ public class AdvancedServerList{
|
||||
|
||||
getPluginLogger().info("Starting AdvancedServerList v%s...", version);
|
||||
|
||||
getPluginLogger().info("Proxy: " + plugin.getPlatformName() + " " + plugin.getPlatformVersion());
|
||||
getPluginLogger().info("Platform: " + plugin.getPlatformName() + " " + plugin.getPlatformVersion());
|
||||
|
||||
if(getFileHandler().loadConfig()){
|
||||
getPluginLogger().info("Successfully loaded config.yml!");
|
||||
@@ -129,6 +131,9 @@ public class AdvancedServerList{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!getPath().resolve("favicons").toFile().exists() && getPath().resolve("favicons").toFile().mkdirs())
|
||||
getPluginLogger().info("Successfully created favicons folder.");
|
||||
|
||||
getPluginLogger().info("Loading Commands...");
|
||||
plugin.loadCommands();
|
||||
getPluginLogger().info("Commands loaded!");
|
||||
@@ -140,13 +145,9 @@ public class AdvancedServerList{
|
||||
getPluginLogger().info("Loading cache.data...");
|
||||
getPlayerHandler().load();
|
||||
|
||||
getPluginLogger().info("Loading Metrics for bStats...");
|
||||
if(getFileHandler().getBoolean("send_statistics")){
|
||||
plugin.loadMetrics();
|
||||
getPluginLogger().info("Metrics loaded!");
|
||||
}else{
|
||||
getPluginLogger().info("'send_statistics' disabled in config.yml. Not loading Metrics for bStats...");
|
||||
}
|
||||
getPluginLogger().info("Loading bStats metrics. Disable it in the global config under /plugins/bstats/");
|
||||
plugin.loadMetrics();
|
||||
getPluginLogger().info("Metrics loaded!");
|
||||
|
||||
getPluginLogger().info("AdvancedServerList is ready!");
|
||||
}
|
||||
|
||||
+20
-12
@@ -37,37 +37,45 @@ public class CommandHandler{
|
||||
}
|
||||
|
||||
public void handle(CmdSender sender, String[] args){
|
||||
String errorPrefix = "<grey>[<gradient:dark_red:red>AdvancedServerList</gradient>]";
|
||||
String prefix = "<grey>[<gradient:aqua:white>AdvancedServerList</gradient>]";
|
||||
|
||||
if(args.length == 0 || args[0].equalsIgnoreCase("help")){
|
||||
if(sender.hasPermission("advancedserverlist.command.help")){
|
||||
sender.sendMsg("AdvancedServerList Commands");
|
||||
sender.sendMsg("%s - Commands", prefix);
|
||||
sender.sendMsg();
|
||||
sender.sendMsg("<aqua>/asl help <grey>- Shows this help.");
|
||||
sender.sendMsg("<gradient:aqua:white>/asl help</gradient> <grey>- Shows this Help");
|
||||
sender.sendMsg();
|
||||
sender.sendMsg("<aqua>/asl reload <grey>- Reloads the config and profiles.");
|
||||
sender.sendMsg("<gradient:aqua:white>/asl reload</gradient> <grey>- Reloads the plugin");
|
||||
}else{
|
||||
sender.sendMsg("<red>You do not have the permissions to execute this command!");
|
||||
sender.sendMsg("%s <red>You do not have permissions to execute this command!", errorPrefix);
|
||||
}
|
||||
}else
|
||||
if(args[0].equalsIgnoreCase("reload")){
|
||||
if(sender.hasPermission("advancedserverlist.command.reload")){
|
||||
sender.sendMsg("<grey>Reloading config.yml...");
|
||||
sender.sendMsg("%s Reloading plugin...", prefix);
|
||||
|
||||
if(core.getFileHandler().reloadConfig()){
|
||||
sender.sendMsg("<green>Successfully reloaded <grey>config.yml</grey>!");
|
||||
sender.sendMsg("%s <green>Reloaded <grey>config.yml</grey>!", prefix);
|
||||
}else{
|
||||
sender.sendMsg("<red>Error while reloading the config.yml.");
|
||||
sender.sendMsg("%s <red>Error while reloading the <grey>config.yml</grey>!", errorPrefix);
|
||||
}
|
||||
|
||||
sender.sendMsg("<grey>Reloading Profiles...");
|
||||
if(core.getFileHandler().reloadProfiles()){
|
||||
sender.sendMsg("<green>Successfully loaded <grey>%d</grey> Profiles!", core.getFileHandler().getProfiles().size());
|
||||
sender.sendMsg("%s <green>Loaded <grey>%s Profile(s)</grey>!", prefix, core.getFileHandler().getProfiles());
|
||||
}else{
|
||||
sender.sendMsg("<red>Error while reloading Profiles. No profiles have been loaded.");
|
||||
sender.sendMsg("%s <red>Cannot load Profiles!", errorPrefix);
|
||||
}
|
||||
|
||||
sender.sendMsg("<green>Reload complete!");
|
||||
core.clearFaviconCache();
|
||||
sender.sendMsg("%s <green>Successfully cleared Favicon cache!", prefix);
|
||||
|
||||
sender.sendMsg("%s <green>Reload complete!", prefix);
|
||||
}else{
|
||||
sender.sendMsg("%s <red>You do not have permissions to execute this command!", errorPrefix);
|
||||
}
|
||||
}else{
|
||||
sender.sendMsg("<red>Unknown subcommand <grey>%s</grey>. Use <grey>/asl help</grey> for a list of commands.", args[0]);
|
||||
sender.sendMsg("%s <red>Unknown subcommand <grey>%s</grey>. Use <grey>/asl help</grey> for a list of commands.", prefix, args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
@@ -43,8 +42,6 @@ import java.util.List;
|
||||
|
||||
public class FileHandler{
|
||||
|
||||
private final FilenameFilter profileFilter = (dir, name) -> name.endsWith(".yml");
|
||||
|
||||
private final AdvancedServerList plugin;
|
||||
private final PluginLogger logger;
|
||||
|
||||
@@ -119,7 +116,7 @@ public class FileHandler{
|
||||
public boolean reloadProfiles(){
|
||||
profiles.clear();
|
||||
|
||||
File[] files = profilesFolder.toFile().listFiles(profileFilter);
|
||||
File[] files = profilesFolder.toFile().listFiles(((dir, name) -> name.endsWith(".yml")));
|
||||
if(files == null || files.length == 0){
|
||||
logger.warn("Cannot load files from profiles folder! No valid YAML files present.");
|
||||
return false;
|
||||
@@ -159,8 +156,4 @@ public class FileHandler{
|
||||
public String getString(String def, Object... path){
|
||||
return node.node(path).getString(def);
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object... path){
|
||||
return node.node(path).getBoolean(true);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,6 @@
|
||||
|
||||
package ch.andre601.advancedserverlist.core.interfaces;
|
||||
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public interface CmdSender{
|
||||
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
package ch.andre601.advancedserverlist.core.interfaces;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface PluginCore{
|
||||
public interface PluginCore<T>{
|
||||
|
||||
void loadCommands();
|
||||
|
||||
@@ -37,12 +38,16 @@ public interface PluginCore{
|
||||
|
||||
void loadMetrics();
|
||||
|
||||
void clearFaviconCache();
|
||||
|
||||
AdvancedServerList getCore();
|
||||
|
||||
Path getPath();
|
||||
|
||||
PluginLogger getPluginLogger();
|
||||
|
||||
FaviconHandler<T> getFaviconHandler();
|
||||
|
||||
String getPlatformName();
|
||||
|
||||
String getPlatformVersion();
|
||||
|
||||
@@ -32,7 +32,6 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ComponentParser{
|
||||
|
||||
+10
-4
@@ -43,8 +43,9 @@ public class ServerListProfile{
|
||||
private final List<String> motd;
|
||||
private final List<String> players;
|
||||
private final String playerCount;
|
||||
private final String favicon;
|
||||
private final boolean hidePlayers;
|
||||
private final boolean oneMore;
|
||||
private final int xMore;
|
||||
|
||||
public ServerListProfile(ConfigurationNode node, PluginLogger logger){
|
||||
this.priority = node.node("priority").getInt();
|
||||
@@ -53,8 +54,9 @@ public class ServerListProfile{
|
||||
this.motd = getList(node, "motd", true);
|
||||
this.players = getList(node, "players", false);
|
||||
this.playerCount = node.node("playerCount").getString("");
|
||||
this.favicon = node.node("favicon").getString("");
|
||||
this.hidePlayers = node.node("hidePlayers").getBoolean();
|
||||
this.oneMore = node.node("oneMore").getBoolean();
|
||||
this.xMore = node.node("xMore").getInt(-1);
|
||||
}
|
||||
|
||||
public int getPriority(){
|
||||
@@ -73,12 +75,16 @@ public class ServerListProfile{
|
||||
return playerCount;
|
||||
}
|
||||
|
||||
public String getFavicon(){
|
||||
return favicon;
|
||||
}
|
||||
|
||||
public boolean shouldHidePlayers(){
|
||||
return hidePlayers;
|
||||
}
|
||||
|
||||
public boolean isOneMore(){
|
||||
return oneMore;
|
||||
public int getXMore(){
|
||||
return xMore;
|
||||
}
|
||||
|
||||
public boolean evalConditions(Map<String, Object> replacements){
|
||||
|
||||
+15
-28
@@ -28,7 +28,6 @@ package ch.andre601.advancedserverlist.core.profiles.conditions;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Expression{
|
||||
|
||||
@@ -99,7 +98,7 @@ public class Expression{
|
||||
}
|
||||
|
||||
public enum Operator{
|
||||
LESS_THAN('<', '\0'){
|
||||
LESS('<', '\0'){
|
||||
@Override
|
||||
public boolean evaluate(String left, String right){
|
||||
int leftInt = Operator.getInt(left);
|
||||
@@ -129,7 +128,7 @@ public class Expression{
|
||||
return !left.equals(right);
|
||||
}
|
||||
},
|
||||
GREATER_THAN('>', '\0'){
|
||||
GREATER('>', '\0'){
|
||||
@Override
|
||||
public boolean evaluate(String left, String right){
|
||||
int leftInt = Operator.getInt(left);
|
||||
@@ -192,32 +191,20 @@ public class Expression{
|
||||
}
|
||||
|
||||
public enum ExpressionResult{
|
||||
VALID{
|
||||
@Override
|
||||
public String getMessage(){
|
||||
return null;
|
||||
}
|
||||
},
|
||||
VALID(null),
|
||||
|
||||
INVALID_NO_EXPRESSION{
|
||||
@Override
|
||||
public String getMessage(){
|
||||
return "Received empty condition which isn't allowed!";
|
||||
}
|
||||
},
|
||||
INVALID_DOUBLE_OPERATOR{
|
||||
@Override
|
||||
public String getMessage(){
|
||||
return "Condition contained two operands.";
|
||||
}
|
||||
},
|
||||
INVALID_EMPTY_PARTS{
|
||||
@Override
|
||||
public String getMessage(){
|
||||
return "Received condition with either left or right part being empty.";
|
||||
}
|
||||
};
|
||||
INVALID_NO_EXPRESSION ("Received empty condition which isn't allowed!"),
|
||||
INVALID_DOUBLE_OPERATOR("Condition contained two operands."),
|
||||
INVALID_EMPTY_PARTS ("Received condition with either left or right part being empty.");
|
||||
|
||||
public abstract String getMessage();
|
||||
private final String message;
|
||||
|
||||
ExpressionResult(String message){
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage(){
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022 Andre_601
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.andre601.advancedserverlist.core.profiles.favicon;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FaviconHandler<T>{
|
||||
|
||||
private final Cache<String, T> favicons = Caffeine.newBuilder()
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
private final AdvancedServerList core;
|
||||
|
||||
public FaviconHandler(AdvancedServerList core){
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
public T getFavicon(String input, Function<BufferedImage, T> function){
|
||||
return favicons.get(input, k -> {
|
||||
BufferedImage image = resolveImage(core, input);
|
||||
if(image == null)
|
||||
return null;
|
||||
|
||||
return function.apply(image);
|
||||
});
|
||||
}
|
||||
|
||||
public void clearCache(){
|
||||
favicons.invalidateAll();
|
||||
}
|
||||
|
||||
private BufferedImage resolveImage(AdvancedServerList core, String input){
|
||||
InputStream stream;
|
||||
|
||||
if(input.toLowerCase(Locale.ROOT).startsWith("https://")){
|
||||
stream = getFromUrl(core, input);
|
||||
}else
|
||||
if(input.toLowerCase(Locale.ROOT).endsWith(".png")){
|
||||
File folder = core.getPath().resolve("favicons").toFile();
|
||||
if(!folder.exists()){
|
||||
core.getPluginLogger().warn("Cannot get Favicon %s from favicons folder. Folder doesn't exist!", input);
|
||||
return null;
|
||||
}
|
||||
|
||||
File file = new File(folder, input);
|
||||
|
||||
try{
|
||||
stream = new FileInputStream(file);
|
||||
}catch(IOException ex){
|
||||
core.getPluginLogger().warn("Cannot create Favicon from File %s.", input);
|
||||
core.getPluginLogger().warn("Cause: %s", ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}else{
|
||||
stream = getFromUrl(core, "https://mc-heads.net/avatar/" + input + "/64");
|
||||
}
|
||||
|
||||
if(stream == null){
|
||||
core.getPluginLogger().warn("Cannot create Favicon. InputStream was null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
try{
|
||||
BufferedImage original = ImageIO.read(stream);
|
||||
if(original == null){
|
||||
core.getPluginLogger().warn("Cannot create Favicon. Unable to create BufferedImage.");
|
||||
return null;
|
||||
}
|
||||
|
||||
BufferedImage favicon = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D img = favicon.createGraphics();
|
||||
|
||||
// Resize original image to 64x64 and apply to favicon.
|
||||
img.drawImage(original, 0, 0, 64, 64, null);
|
||||
img.dispose();
|
||||
|
||||
return favicon;
|
||||
}catch(IOException ex){
|
||||
core.getPluginLogger().warn("Unable to create Favicon. Encountered IOException during creation.");
|
||||
core.getPluginLogger().warn("Cause: %s", ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream getFromUrl(AdvancedServerList core, String url){
|
||||
try{
|
||||
URL faviconUrl = new URL(url);
|
||||
URLConnection connection = faviconUrl.openConnection();
|
||||
connection.setRequestProperty("User-Agent", "AdvancedServerList/" + core.getVersion());
|
||||
connection.connect();
|
||||
|
||||
return connection.getInputStream();
|
||||
}catch(IOException ex){
|
||||
core.getPluginLogger().warn("Error while connecting to %s for Favicon creation.", url);
|
||||
core.getPluginLogger().warn("Cause: %s", ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
#
|
||||
# Used for when AdvancedServerList doesn't have a cached player to use for ${player name}
|
||||
#
|
||||
unknown_player: "Anonymous"
|
||||
#
|
||||
# Whether statistics should be sent to bStats or not.
|
||||
#
|
||||
send_statistics: true
|
||||
unknown_player: "Anonymous"
|
||||
@@ -60,11 +60,30 @@ players:
|
||||
playerCount: '<grey>Text'
|
||||
|
||||
#
|
||||
# When set to true, will the ${server maxPlayers} placeholder display the online players + 1
|
||||
# This means that if 20 players are online, 21 would be displayed by the placeholder with this option enabled.
|
||||
# Allows you to override the default Favicon used by the Server/Proxy.
|
||||
# You can provide three specific inputs:
|
||||
# - A valid URL pointing to a PNG file.
|
||||
# - ${player name} for a per-player avatar being displayed (Uses mc-heads.net)
|
||||
# - Image file name (i.e. example.png) for a file in the "favicons" folder.
|
||||
#
|
||||
# Note that the placeholder will not be affected in the conditions.
|
||||
# NOTE:
|
||||
# - The favicon will be cached for 5 minutes to avoid spam and rate limits.
|
||||
# - BungeeCord/Waterfall may report issues that the plugin takes a long time to process.
|
||||
# This is something I cannot really get improved without help.
|
||||
#
|
||||
# Read more: https://github.com/Andre601/AdvancedServerList/wiki/Profile#onemore
|
||||
# Read more: https://github.com/Andre601/AdvancedServerList/wiki/Profiles#favicon
|
||||
#
|
||||
oneMore: false
|
||||
favicon: ''
|
||||
|
||||
#
|
||||
# When set to 0 or higher will alter the max player count to the online count + xMore.
|
||||
# Example: With 20 online players would 'xMore: 1' show 20/21 and 'xMore: 0' show 20/20
|
||||
#
|
||||
# Note that this will also manipulate the ${server playersMax} placeholder when used
|
||||
# in motd, players or playerCount.
|
||||
#
|
||||
# Remove this option or set it to -1 to not alter the max player count.
|
||||
#
|
||||
# Read more: https://github.com/Andre601/AdvancedServerList/wiki/Profiles#xmore
|
||||
#
|
||||
xMore: -1
|
||||
+7
-3
@@ -82,7 +82,7 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>AdvancedServerList-PaperMC-${plugin.version}</finalName>
|
||||
<finalName>AdvancedServerList-Paper-${plugin.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
@@ -103,7 +103,7 @@
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.spongepowered.configurate</pattern>
|
||||
@@ -111,7 +111,11 @@
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.spigot.depends.bstats</shadedPattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.paper.depends.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.paper.depends.caffeine</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
|
||||
@@ -28,6 +28,7 @@ package ch.andre601.advancedserverlist.paper;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
|
||||
import ch.andre601.advancedserverlist.paper.commands.CmdAdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.paper.events.JoinEvent;
|
||||
import ch.andre601.advancedserverlist.paper.events.PingEvent;
|
||||
@@ -36,23 +37,26 @@ import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class PaperCore extends JavaPlugin implements PluginCore{
|
||||
public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon>{
|
||||
|
||||
private final PluginLogger logger = new PaperLogger(getLogger());
|
||||
|
||||
private AdvancedServerList core;
|
||||
private FaviconHandler<CachedServerIcon> faviconHandler;
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
try{
|
||||
Class.forName("io.papermc.paper.configuration.ConfigurationLoaders");
|
||||
this.core = new AdvancedServerList(this);
|
||||
enable();
|
||||
}catch(ClassNotFoundException ex){
|
||||
try{
|
||||
Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||
this.core = new AdvancedServerList(this);
|
||||
enable();
|
||||
}catch(ClassNotFoundException ex1){
|
||||
getPluginLogger().warn("======================================== WARNING ========================================");
|
||||
getPluginLogger().warn("");
|
||||
@@ -102,6 +106,11 @@ public class PaperCore extends JavaPlugin implements PluginCore{
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFaviconCache(){
|
||||
faviconHandler.clearCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedServerList getCore(){
|
||||
return core;
|
||||
@@ -117,6 +126,14 @@ public class PaperCore extends JavaPlugin implements PluginCore{
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaviconHandler<CachedServerIcon> getFaviconHandler(){
|
||||
if(faviconHandler == null)
|
||||
faviconHandler = new FaviconHandler<>(core);
|
||||
|
||||
return faviconHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName(){
|
||||
return getServer().getName();
|
||||
@@ -126,4 +143,8 @@ public class PaperCore extends JavaPlugin implements PluginCore{
|
||||
public String getPlatformVersion(){
|
||||
return getServer().getVersion();
|
||||
}
|
||||
|
||||
private void enable(){
|
||||
this.core = new AdvancedServerList(this);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ package ch.andre601.advancedserverlist.paper.events;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ProfileManager;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.Placeholders;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.PlayerPlaceholders;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.ServerPlaceholders;
|
||||
@@ -40,9 +41,12 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PingEvent implements Listener{
|
||||
|
||||
@@ -74,8 +78,8 @@ public class PingEvent implements Listener{
|
||||
if(profile == null)
|
||||
return;
|
||||
|
||||
if(profile.isOneMore()){
|
||||
max = online + 1;
|
||||
if(profile.getXMore() >= 0){
|
||||
max = online + profile.getXMore();
|
||||
event.setMaxPlayers(max);
|
||||
}
|
||||
|
||||
@@ -119,7 +123,24 @@ public class PingEvent implements Listener{
|
||||
event.getPlayerSample().addAll(getPlayers(profile.getPlayers(), playerPlaceholders, serverPlaceholders, player.getPlayer()));
|
||||
}
|
||||
|
||||
event.setServerIcon(event.getServerIcon());
|
||||
if(!profile.getFavicon().isEmpty()){
|
||||
String favName = StringReplacer.replace(profile.getFavicon(), playerPlaceholders.getReplacements());
|
||||
|
||||
CachedServerIcon favicon = plugin.getFaviconHandler().getFavicon(favName, image -> {
|
||||
try{
|
||||
return Bukkit.loadServerIcon(image);
|
||||
}catch(Exception ex){
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if(favicon == null){
|
||||
plugin.getPluginLogger().warn("Could not obtain valid Favicon to use.");
|
||||
event.setServerIcon(event.getServerIcon());
|
||||
}else{
|
||||
event.setServerIcon(favicon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<PlayerProfile> getPlayers(List<String> lines, Placeholders playerPlaceholders, Placeholders serverPlaceholders, OfflinePlayer player){
|
||||
|
||||
@@ -13,7 +13,7 @@ softdepend:
|
||||
commands:
|
||||
advancedserverlist:
|
||||
description: 'Main command of AdvancedServerList'
|
||||
usage: '/<command> [reload]'
|
||||
usage: '/<command> [help|reload]'
|
||||
aliases:
|
||||
- 'asl'
|
||||
permission: 'advancedserverlist.admin'
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<plugin.version>1.3.0</plugin.version>
|
||||
<plugin.version>1.5.3</plugin.version>
|
||||
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
|
||||
|
||||
<maven.compiler.source>16</maven.compiler.source>
|
||||
|
||||
+6
-2
@@ -118,11 +118,15 @@
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.paper.depends.bstats</shadedPattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.spigot.depends.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.spigot.depends.caffeine</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
|
||||
@@ -28,9 +28,11 @@ package ch.andre601.advancedserverlist.spigot;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
|
||||
import ch.andre601.advancedserverlist.spigot.commands.CmdAdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.spigot.events.LoadEvent;
|
||||
import ch.andre601.advancedserverlist.spigot.logging.SpigotLogger;
|
||||
import com.comphenix.protocol.wrappers.WrappedServerPing;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -38,10 +40,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class SpigotCore extends JavaPlugin implements PluginCore{
|
||||
public class SpigotCore extends JavaPlugin implements PluginCore<WrappedServerPing.CompressedImage>{
|
||||
|
||||
private final PluginLogger logger = new SpigotLogger(getLogger());
|
||||
|
||||
private AdvancedServerList core;
|
||||
private final PluginLogger logger = new SpigotLogger(getLogger());
|
||||
FaviconHandler<WrappedServerPing.CompressedImage> faviconHandler = null;
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
@@ -88,6 +92,11 @@ public class SpigotCore extends JavaPlugin implements PluginCore{
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFaviconCache(){
|
||||
faviconHandler.clearCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedServerList getCore(){
|
||||
return core;
|
||||
@@ -103,6 +112,14 @@ public class SpigotCore extends JavaPlugin implements PluginCore{
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaviconHandler<WrappedServerPing.CompressedImage> getFaviconHandler(){
|
||||
if(faviconHandler == null)
|
||||
faviconHandler = new FaviconHandler<>(core);
|
||||
|
||||
return faviconHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName(){
|
||||
return getServer().getName();
|
||||
|
||||
@@ -28,6 +28,7 @@ package ch.andre601.advancedserverlist.spigot.events;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ProfileManager;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.PlayerPlaceholders;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.ServerPlaceholders;
|
||||
import ch.andre601.advancedserverlist.spigot.SpigotCore;
|
||||
@@ -101,8 +102,8 @@ public class PingEvent implements Listener{
|
||||
if(profile == null)
|
||||
return;
|
||||
|
||||
if(profile.isOneMore()){
|
||||
max = online + 1;
|
||||
if(profile.getXMore() >= 0){
|
||||
max = online + profile.getXMore();
|
||||
ping.setPlayersMaximum(max);
|
||||
}
|
||||
|
||||
@@ -156,6 +157,25 @@ public class PingEvent implements Listener{
|
||||
.toString()
|
||||
));
|
||||
}
|
||||
|
||||
if(!profile.getFavicon().isEmpty()){
|
||||
String favName = StringReplacer.replace(profile.getFavicon(), playerPlaceholders.getReplacements());
|
||||
|
||||
WrappedServerPing.CompressedImage favicon = spigotPlugin.getFaviconHandler().getFavicon(favName, image -> {
|
||||
try{
|
||||
return WrappedServerPing.CompressedImage.fromPng(image);
|
||||
}catch(Exception ex){
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if(favicon == null){
|
||||
spigotPlugin.getPluginLogger().warn("Could not obtain valid Favicon to use.");
|
||||
ping.setFavicon(ping.getFavicon());
|
||||
}else{
|
||||
ping.setFavicon(favicon);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ main: 'ch.andre601.advancedserverlist.spigot.SpigotCore'
|
||||
api-version: 1.19
|
||||
|
||||
libraries:
|
||||
- 'org.spongepowered:configurate-yaml:${plugin.depend.configurate}'
|
||||
- 'net.kyori:adventure-api:${plugin.depend.kyori-adventure}'
|
||||
- 'net.kyori:adventure-text-minimessage:${plugin.depend.kyori-minimessage}'
|
||||
- 'net.kyori:adventure-text-serializer-legacy:${plugin.depend.kyori-legacy}'
|
||||
- 'net.kyori:adventure-platform-bukkit:${plugin.depend.kyori-platform-bukkit}'
|
||||
- 'org.spongepowered:configurate-yaml:4.1.2'
|
||||
- 'net.kyori:adventure-api:4.11.0'
|
||||
- 'net.kyori:adventure-text-minimessage:4.11.0'
|
||||
- 'net.kyori:adventure-text-serializer-legacy:4.11.0'
|
||||
- 'net.kyori:adventure-platform-bukkit:4.1.2'
|
||||
|
||||
softdepend:
|
||||
- 'ProtocolLib'
|
||||
@@ -21,7 +21,7 @@ softdepend:
|
||||
commands:
|
||||
advancedserverlist:
|
||||
description: 'Main command of AdvancedServerList'
|
||||
usage: '/<command> [reload]'
|
||||
usage: '/<command> [help|reload]'
|
||||
aliases:
|
||||
- 'asl'
|
||||
permission: 'advancedserverlist.admin'
|
||||
|
||||
+5
-1
@@ -90,7 +90,7 @@
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.spongepowered.configurate</pattern>
|
||||
@@ -100,6 +100,10 @@
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.velocity.depends.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>ch.andre601.advancedserverlist.velocity.depends.caffeine</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
<filter>
|
||||
|
||||
@@ -28,6 +28,7 @@ package ch.andre601.advancedserverlist.velocity;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
|
||||
import ch.andre601.advancedserverlist.velocity.commands.CmdAdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.velocity.events.JoinEvent;
|
||||
import ch.andre601.advancedserverlist.velocity.events.PingEvent;
|
||||
@@ -39,13 +40,14 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class VelocityCore implements PluginCore{
|
||||
public class VelocityCore implements PluginCore<Favicon>{
|
||||
|
||||
private final PluginLogger logger;
|
||||
private final ProxyServer proxy;
|
||||
@@ -53,6 +55,7 @@ public class VelocityCore implements PluginCore{
|
||||
private final Metrics.Factory metrics;
|
||||
|
||||
private AdvancedServerList core;
|
||||
private FaviconHandler<Favicon> faviconHandler = null;
|
||||
|
||||
@Inject
|
||||
public VelocityCore(ProxyServer proxy, @DataDirectory Path path, Metrics.Factory metrics){
|
||||
@@ -96,6 +99,11 @@ public class VelocityCore implements PluginCore{
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFaviconCache(){
|
||||
faviconHandler.clearCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedServerList getCore(){
|
||||
return core;
|
||||
@@ -111,6 +119,14 @@ public class VelocityCore implements PluginCore{
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaviconHandler<Favicon> getFaviconHandler(){
|
||||
if(faviconHandler == null)
|
||||
faviconHandler = new FaviconHandler<>(core);
|
||||
|
||||
return faviconHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName(){
|
||||
return getProxy().getVersion().getName();
|
||||
|
||||
+24
-6
@@ -29,6 +29,7 @@ import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ProfileManager;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.PlayerPlaceholders;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.ServerPlaceholders;
|
||||
import ch.andre601.advancedserverlist.velocity.VelocityCore;
|
||||
@@ -37,6 +38,7 @@ import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
@@ -58,15 +60,13 @@ public class PingEvent{
|
||||
return;
|
||||
|
||||
ServerPing.Builder builder = ping.asBuilder();
|
||||
InetSocketAddress address = event.getConnection().getRemoteAddress();
|
||||
String playerName = plugin.getCore().getPlayerHandler().getPlayerByIp(event.getConnection().getRemoteAddress().getHostString());
|
||||
InetSocketAddress host = event.getConnection().getVirtualHost().orElse(null);
|
||||
|
||||
int online = builder.getOnlinePlayers();
|
||||
int max = builder.getMaximumPlayers();
|
||||
|
||||
PlayerPlaceholders playerPlaceholders = new PlayerPlaceholders(
|
||||
new VelocityPlayer(plugin.getCore().getPlayerHandler().getPlayerByIp(address.getHostString()), protocol.getProtocol())
|
||||
);
|
||||
PlayerPlaceholders playerPlaceholders = new PlayerPlaceholders(new VelocityPlayer(playerName, protocol.getProtocol()));
|
||||
ServerPlaceholders serverPlaceholders = new ServerPlaceholders(online, max, host == null ? null : host.getHostString());
|
||||
|
||||
ServerListProfile profile = ProfileManager.get(plugin.getCore())
|
||||
@@ -77,8 +77,8 @@ public class PingEvent{
|
||||
if(profile == null)
|
||||
return;
|
||||
|
||||
if(profile.isOneMore()){
|
||||
max = online + 1;
|
||||
if(profile.getXMore() >= 0){
|
||||
max = online + profile.getXMore();
|
||||
builder.maximumPlayers(max);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,24 @@ public class PingEvent{
|
||||
builder.clearSamplePlayers().samplePlayers(playerSamples);
|
||||
}
|
||||
|
||||
if(!profile.getFavicon().isEmpty()){
|
||||
String favName = StringReplacer.replace(profile.getFavicon(), playerPlaceholders.getReplacements());
|
||||
|
||||
Favicon favicon = plugin.getFaviconHandler().getFavicon(favName, image -> {
|
||||
try{
|
||||
return Favicon.create(image);
|
||||
}catch(Exception ex){
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if(favicon == null){
|
||||
plugin.getPluginLogger().warn("Could not obtain valid Favicon to use.");
|
||||
}else{
|
||||
builder.favicon(favicon);
|
||||
}
|
||||
}
|
||||
|
||||
event.setPing(builder.build());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user