Compare commits

...
34 Commits
Author SHA1 Message Date
Andre601 0908ddad5e Remove unused imports and bump version 2024-10-10 17:01:10 +02:00
Andre601 d1549b1441 delete release-config.ts 2024-10-10 14:58:51 +00:00
Andre601 57f618e7e2 Remove the action (Pointless and confusing to use) 2024-10-10 14:58:29 +00:00
Andre601 911c64f7ad Merge pull request '🎉 Release 5.0.5' (#352) from next-release/master into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/352
2024-10-10 14:50:32 +00:00
oauth fdeeb35fa9 🎉 Release 5.0.5 2024-10-10 12:30:10 +00:00
oauth c2c653e613 Merge branch 'origin/master' into 'next-release/master' 2024-10-10 12:30:10 +00:00
Andre601 8fa7c1593d Merge pull request 'Update dependency mkdocs-material to v9.5.40' (#355) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/355
2024-10-10 12:29:26 +00:00
Andre601's Bot b2dc74951f Update dependency mkdocs-material to v9.5.40 2024-10-10 12:01:17 +00:00
oauth 099c45e4c4 🎉 Release 5.0.5 2024-10-09 12:29:42 +00:00
oauth e38f6648ee Merge branch 'origin/master' into 'next-release/master' 2024-10-09 12:29:42 +00:00
Andre601 2d701aa8a8 Merge pull request 'Update dependency ch.qos.logback:logback-classic to v1.5.9' (#354) from renovate/ch.qos.logback-logback-classic-1.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/354
2024-10-09 12:29:05 +00:00
Andre601's Bot 1f32c22ebf Update dependency ch.qos.logback:logback-classic to v1.5.9 2024-10-09 12:01:45 +00:00
oauth 610d86ad1b 🎉 Release 5.0.5 2024-10-09 11:55:51 +00:00
oauth 658ec8dd74 Merge branch 'origin/master' into 'next-release/master' 2024-10-09 11:55:51 +00:00
Andre601 85b7210e7c Push empty commit to trigger release 2024-10-09 13:55:23 +02:00
Andre601 98b99b37de Merge pull request 'Improve PAPIProxyBridge support' (#353) from feature/improve-papi-support into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/353
2024-10-09 11:49:41 +00:00
Andre601 bc3aaa4d28 Improve PAPIProxyBridge support 2024-10-09 13:31:34 +02:00
oauth a3d0342f28 🎉 Release 5.0.5 2024-10-09 11:20:46 +00:00
Andre601 6e057422b6 Merge pull request 'Add automatic release action' (#351) from feature/automatic-release-creation into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/351
2024-10-09 11:20:26 +00:00
Andre601 7ee65c6c21 Add useVersionPrefixV to release-config.ts 2024-10-09 13:18:42 +02:00
Andre601 b4b754e483 Update MODRINTH.md 2024-10-08 23:53:00 +00:00
Andre601 b7c0c8a312 Update Mastodon Link 2024-10-08 23:51:52 +00:00
Andre601 cf6006f9d6 Merge branch 'master' into feature/automatic-release-creation 2024-10-06 00:07:49 +02:00
Andre601 6bf44f6208 Fix hover not supporting PlaceholderAPI Placeholders 2024-10-06 00:01:06 +02:00
Andre601 428dd3cd06 Merge pull request 'Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.2' (#350) from renovate/org.junit.jupiter-junit-jupiter-engine-5.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/350
2024-10-05 12:12:34 +00:00
Andre601's Bot 871e2efbe2 Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.2 2024-10-05 12:01:14 +00:00
Andre601 a5b45e2c82 Add SECURITY.md 2024-10-04 22:54:25 +00:00
Andre601 9feb3dfac6 Bump version 2024-10-02 13:43:45 +02:00
Andre601 5961d0dca0 Don't log errors when fetching servers (+ misc changes) 2024-10-02 13:43:05 +02:00
Andre601 ea0f0f09f4 Add automatic release action 2024-10-02 13:27:46 +02:00
Andre601 3d5d4fcab2 Fix wrong name for AdvancedBan in BanPlugins Addon 2024-10-01 19:58:11 +02:00
Andre601 0763a9b3b4 Fix wrong main class for Paper BanPluginsAddon 2024-10-01 02:26:14 +02:00
Andre601 2d67a89fc2 Merge pull request 'Update dependency mkdocs-material to v9.5.39' (#349) from renovate/mkdocs-material-9.x into master
Reviewed-on: https://codeberg.org/Andre601/AdvancedServerList/pulls/349
2024-09-29 12:07:56 +00:00
Andre601's Bot 4207d875f9 Update dependency mkdocs-material to v9.5.39 2024-09-29 12:03:17 +00:00
29 changed files with 197 additions and 103 deletions

No files matched your search

+1 -1
View File
@@ -98,6 +98,6 @@ Spanish Video by Ajneb97
<img src="https://wsrv.nl/?url=https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/social/revolt-singular_vector.svg&h=48" alt="revolt" title="Join my Revolt Server">
</a>
<br>
<a href="https://blobfox.coffee/@andre_601" target="_blank">
<a href="https://swiss.social/@andre_601" target="_blank">
<img src="https://wsrv.nl/?url=https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/social/mastodon-singular_vector.svg&h=48" alt="revolt" title="Chat with me on Mastodon">
</a>
+13
View File
@@ -0,0 +1,13 @@
# Changelog
## [5.0.5](https://codeberg.org/Andre601/AdvancedServerList/releases/tag/v5.0.5) - 2024-10-10
### ❤️ Thanks to all contributors! ❤️
@Andre601, @Andre_601-Bot
### Misc
- Update dependency ch.qos.logback:logback-classic to v1.5.9 [[#354](https://codeberg.org/Andre601/AdvancedServerList/pulls/354)]
- Improve PAPIProxyBridge support [[#353](https://codeberg.org/Andre601/AdvancedServerList/pulls/353)]
- Add automatic release action [[#351](https://codeberg.org/Andre601/AdvancedServerList/pulls/351)]
+1 -1
View File
@@ -108,6 +108,6 @@ Spanish Video by Ajneb97
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/social/revolt-singular_vector.svg" height="48" alt="revolt" title="Join my Revolt Server">
</a>
<br>
<a href="https://blobfox.coffee/@andre_601" target="_blank">
<a href="https://swiss.social/@andre_601" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/social/mastodon-singular_vector.svg" height="48" alt="revolt" title="Chat with me on Mastodon">
</a>
+58
View File
@@ -0,0 +1,58 @@
# Supported Versions
To ensure proper safety and support are only certain versions and Platforms of AdvancedServerList maintained and supported.
## Supported Plugin Versions
| Major Version | Supported |
|---------------|-----------|
| v4 | Yes |
| v3 | Yes* |
| v2 | No |
| v1 | No |
\*Only receives support but no updates or bug fixes.
## Supported Server/Proxy Versions
| Server/Proxy Version* | Supported |
|-----------------------|-----------|
| 1.21.x | Yes |
| 1.20.x | Yes |
| 1.19.x | No |
| 1.18.x | No |
| 1.17.x | No |
| 1.16.x | No |
| 1.15.x | No |
| 1.14.x | No |
| 1.13.x | No |
| 1.12.x | No |
| 1.11.x | No |
| 1.10.x | No |
| 1.19.x | No |
| 1.8.x | No |
\*Only the latest patch version is actively supported should "Supported" have "Yes".
## Supported Platforms
### Servers
| Server | Supported |
|--------|-----------|
| Spigot | No |
| Paper | Yes |
| Purpur | Yes* |
| Mohist | No |
\*Support hasn't actively been tested, but should work without issues.
### Proxies
| Proxy | Supported |
|------------|-----------|
| BungeeCord | Yes** |
| Waterfall | Yes** |
| Velocity | Yes |
\*\*Platform version of this plugin is maintenance only, not receiving any bug fixes for major breaking changes anymore.
@@ -31,8 +31,6 @@ import com.google.common.primitives.UnsignedLongs;
import me.leoko.advancedban.manager.PunishmentManager;
import me.leoko.advancedban.utils.Punishment;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
public class AdvancedBanProvider implements PunishmentProvider{
@@ -2,7 +2,7 @@ name: 'ASLBanPluginsAddon'
author: 'Andre_601'
version: '${plugin.version}'
main: 'ch.andre601.advancedserverlist.banplugins.paper.AdvancedBanPlaceholders'
main: 'ch.andre601.advancedserverlist.banplugins.paper.PaperBanPluginsAddon'
api-version: '1.19'
@@ -11,7 +11,7 @@ dependencies:
AdvancedServerList:
required: false
load: BEFORE
AdvancedBans:
AdvancedBan:
required: false
load: BEFORE
LibertyBans:
@@ -41,6 +41,7 @@ import com.alessiodp.libby.Library;
import de.myzelyam.api.vanish.BungeeVanishAPI;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.md_5.bungee.api.Favicon;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
@@ -51,10 +52,14 @@ import java.awt.image.BufferedImage;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
private final PluginLogger logger = new BungeeLogger(this);
private final Map<String, ServerPing> fetchedServers = new ConcurrentHashMap<>();
private boolean successfulLoad = false;
@@ -91,6 +96,7 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
@Override
public void onDisable(){
core.disable();
getProxy().getScheduler().cancel(this);
}
@Override
@@ -142,6 +148,11 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
libraryManager.loadLibrary(lib);
}
@Override
public void startScheduler(){
getProxy().getScheduler().schedule(this, this::fetchServers, 0, 10, TimeUnit.SECONDS);
}
@Override
public AdvancedServerList<Favicon> getCore(){
return core;
@@ -200,6 +211,10 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
return players.size();
}
public Map<String, ServerPing> getFetchedServers(){
return fetchedServers;
}
private boolean loadLibs(){
try{
if(libraryManager == null){
@@ -215,4 +230,14 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
return false;
}
}
private void fetchServers(){
fetchedServers.clear();
getProxy().getServers().forEach((name, server) -> server.ping((ping, throwable) -> {
if(throwable != null)
return;
fetchedServers.put(name, ping);
}));
}
}
@@ -107,6 +107,7 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
for(int i = 0; i < players.length; i++){
String parsed = ComponentParser.text(lines.get(i))
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> parsePAPIPlaceholders(text, player))
.toString();
ServerPing.PlayerInfo pi = new ServerPing.PlayerInfo(parsed, UUID.randomUUID());
@@ -10,20 +10,14 @@ import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.chat.BaseComponent;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class BungeeProxyPlaceholders extends PlaceholderProvider{
private final Map<String, ServerPing> serverStates = new ConcurrentHashMap<>();
private final BungeeCordCore plugin;
private BungeeProxyPlaceholders(BungeeCordCore plugin){
super("proxy");
this.plugin = plugin;
plugin.getProxy().getScheduler().schedule(plugin, this::fetchServerStates, 0, 10, TimeUnit.SECONDS);
}
public static BungeeProxyPlaceholders init(BungeeCordCore plugin){
@@ -36,7 +30,7 @@ public class BungeeProxyPlaceholders extends PlaceholderProvider{
if(args.length < 2)
return null;
ServerPing ping = serverStates.get(args[1]);
ServerPing ping = plugin.getFetchedServers().get(args[1]);
return switch(args[0]){
case "status" -> ping == null ? "offline" : "online";
@@ -64,16 +58,4 @@ public class BungeeProxyPlaceholders extends PlaceholderProvider{
default -> null;
};
}
private void fetchServerStates(){
serverStates.clear();
plugin.getProxy().getServers().forEach((name, server) -> server.ping((ping, throwable) -> {
if(throwable != null){
plugin.getPluginLogger().warn("Encountered an exception while fetching status of Server %s", throwable, name);
return;
}
serverStates.put(name, ping);
}));
}
}
+1 -1
View File
@@ -157,7 +157,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.1</version>
<version>5.11.2</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -177,6 +177,10 @@ public class AdvancedServerList<F>{
getPlugin().getPluginLogger().info("Loading bStats metrics. Disable it in the global config under /plugins/bstats/");
plugin.loadMetrics();
getPlugin().getPluginLogger().info("Metrics loaded!");
getPlugin().getPluginLogger().info("Enabling Schedulers...");
plugin.startScheduler();
getPlugin().getPluginLogger().info("Schedulers enabled.");
getPlugin().getPluginLogger().info("AdvancedServerList is ready!");
@@ -28,7 +28,7 @@ package ch.andre601.advancedserverlist.core.check;
import ch.andre601.advancedserverlist.core.AdvancedServerList;
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
import ch.andre601.advancedserverlist.core.objects.CacheUtil;
import ch.andre601.advancedserverlist.core.objects.ValueCache;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -59,7 +59,7 @@ public class UpdateChecker{
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(new UpdateCheckThread());
private final CacheUtil<CompletableFuture<ModrinthVersion>> cache = new CacheUtil<>(Duration.ofMinutes(5));
private final ValueCache<CompletableFuture<ModrinthVersion>> cache = new ValueCache<>(Duration.ofMinutes(5));
private final AdvancedServerList<?> core;
private final PluginLogger logger;
@@ -25,22 +25,24 @@
package ch.andre601.advancedserverlist.core.compat.papi;
import ch.andre601.advancedserverlist.core.objects.CacheUtil;
import ch.andre601.advancedserverlist.core.objects.ValueCache;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import net.william278.papiproxybridge.api.PlaceholderAPI;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletionException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class PAPIUtil{
private static PAPIUtil instance;
private final CacheUtil<String> cache = new CacheUtil<>(Duration.ofSeconds(5));
private final ValueCache<CompletableFuture<Set<String>>> serversCache = new ValueCache<>(Duration.ofSeconds(10));
private final Cache<UUID, CompletableFuture<String>> textCache = CacheBuilder.newBuilder()
.expireAfterWrite(Duration.ofSeconds(10))
.build();
private final PlaceholderAPI papi;
private PAPIUtil(){
@@ -66,24 +68,11 @@ public class PAPIUtil{
}
public String getServer(){
return cache.get(() -> {
List<String> servers;
try{
Set<String> value = papi.getServers().getNow(null);
if(value == null)
return null;
servers = List.copyOf(value);
}catch(CancellationException | CompletionException ex){
return null;
}
if(servers == null || servers.isEmpty())
return null;
return servers.get(0);
});
Set<String> values = serversCache.get(papi::getServers).getNow(Collections.emptySet());
if(values.isEmpty())
return null;
return List.copyOf(values).get(0);
}
public <P> P getPlayer(Collection<P> players){
@@ -95,8 +84,8 @@ public class PAPIUtil{
public String parse(String text, UUID carrier, UUID player){
try{
return papi.formatPlaceholders(text, carrier, player).getNow(text);
}catch(IllegalArgumentException | CancellationException | CompletionException ex){
return textCache.get(player, () -> papi.formatPlaceholders(text, carrier, player)).getNow(text);
}catch(ExecutionException ex){
return text;
}
}
@@ -29,14 +29,14 @@ import java.util.Locale;
public abstract class PluginCommand{
private final String argument;
private final String name;
public PluginCommand(String argument){
this.argument = argument;
public PluginCommand(String name){
this.name = name;
}
public String name(){
return argument;
return name;
}
public String permission(){
@@ -46,6 +46,8 @@ public interface PluginCore<F>{
void downloadLibrary(String groupId, String artifactId, String version);
void startScheduler();
AdvancedServerList<F> getCore();
Path getFolderPath();
@@ -28,12 +28,12 @@ package ch.andre601.advancedserverlist.core.objects;
import java.time.Duration;
import java.util.function.Supplier;
public class CacheUtil<T>{
public class ValueCache<T>{
private final Duration duration;
private CacheValue<T> cache = null;
public CacheUtil(Duration duration){
public ValueCache(Duration duration){
this.duration = duration;
}
@@ -114,8 +114,6 @@ public class PlayerHandler{
}catch(IOException ex){
logger.warn("Encountered IOException while saving cached players to playercache.json!", ex);
}
}
public void addPlayer(String ip, String name, UUID uuid){
@@ -60,8 +60,19 @@ public class ProfileManager{
String maxPlayersCount = resolve(defEntry, entry, ProfileEntry::maxPlayersCount);
String onlinePlayersCount = resolve(defEntry, entry, ProfileEntry::onlinePlayersCount);
return new ProfileEntry(motd, players, playerCountText, favicon, hidePlayersEnabled, extraPlayersEnabled,
maxPlayersEnabled, onlinePlayersEnabled, extraPlayersCount, maxPlayersCount, onlinePlayersCount);
return new ProfileEntry.Builder()
.motd(motd)
.players(players)
.playerCountText(playerCountText)
.favicon(favicon)
.hidePlayersEnabled(hidePlayersEnabled)
.extraPlayersEnabled(extraPlayersEnabled)
.maxPlayersEnabled(maxPlayersEnabled)
.onlinePlayersEnabled(onlinePlayersEnabled)
.extraPlayersCount(extraPlayersCount)
.maxPlayersCount(maxPlayersCount)
.onlinePlayersCount(onlinePlayersCount)
.build();
}
public static ServerListProfile resolveProfile(AdvancedServerList<?> core, GenericPlayer player, GenericServer server){
@@ -149,6 +149,11 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
libraryManager.loadLibrary(lib);
}
@Override
public void startScheduler(){
// Unused
}
@Override
public AdvancedServerList<CachedServerIcon> getCore(){
return core;
@@ -205,12 +205,7 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
for(String line : lines){
String parsed = ComponentParser.text(line)
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> {
if(plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
return PlaceholderAPI.setPlaceholders(player.getPlayer(), text);
return text;
})
.modifyText(text -> parsePAPIPlaceholders(text, player))
.toString();
playerList.add(function.apply(parsed));
+1 -1
View File
@@ -37,7 +37,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.version>5.0.0</plugin.version>
<plugin.version>5.0.5</plugin.version>
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
<api.version>4.0.0</api.version>
+1 -1
View File
@@ -1,3 +1,3 @@
mkdocs-material==9.5.38
mkdocs-material==9.5.40
mkdocs-glightbox==0.4.0
git+https://github.com/Andre601/mkdocs-pagenav-generator
@@ -47,6 +47,8 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerPing;
import com.velocitypowered.api.scheduler.ScheduledTask;
import com.velocitypowered.api.util.Favicon;
import de.myzelyam.api.vanish.VelocityVanishAPI;
import org.bstats.charts.SimplePie;
@@ -59,10 +61,14 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class VelocityCore implements PluginCore<Favicon>{
private final Logger logger = LoggerFactory.getLogger("AdvancedServerList");
private final Map<String, ServerPing> fetchedServers = new ConcurrentHashMap<>();
private final PluginLogger pluginLogger;
private final ProxyServer proxy;
@@ -74,6 +80,8 @@ public class VelocityCore implements PluginCore<Favicon>{
private VelocityLibraryManager<VelocityCore> libraryManager = null;
private ScheduledTask scheduledTask = null;
@Inject
public VelocityCore(ProxyServer proxy, @DataDirectory Path path, Metrics.Factory metrics){
this.pluginLogger = new VelocityLogger(this, this.logger);
@@ -92,6 +100,8 @@ public class VelocityCore implements PluginCore<Favicon>{
@Subscribe
public void pluginDisable(ProxyShutdownEvent event){
core.disable();
if(scheduledTask != null)
scheduledTask.cancel();
}
@Override
@@ -147,6 +157,13 @@ public class VelocityCore implements PluginCore<Favicon>{
libraryManager.loadLibrary(lib);
}
@Override
public void startScheduler(){
scheduledTask = getProxy().getScheduler().buildTask(this, this::fetchServers)
.repeat(10, TimeUnit.SECONDS)
.schedule();
}
@Override
public AdvancedServerList<Favicon> getCore(){
return core;
@@ -210,4 +227,18 @@ public class VelocityCore implements PluginCore<Favicon>{
return players.size();
}
public Map<String, ServerPing> getFetchedServers(){
return fetchedServers;
}
private void fetchServers(){
fetchedServers.clear();
getProxy().getAllServers().forEach(server -> server.ping().whenComplete((ping, throwable) -> {
if(throwable != null)
return;
fetchedServers.put(server.getServerInfo().getName(), ping);
}));
}
}
@@ -109,6 +109,7 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
for(int i = 0; i < players.length; i++){
String parsed = ComponentParser.text(lines.get(i))
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> parsePAPIPlaceholders(text, player))
.toString();
players[i] = new ServerPing.SamplePlayer(parsed, UUID.randomUUID());
@@ -7,22 +7,14 @@ import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
import ch.andre601.advancedserverlist.velocity.VelocityCore;
import com.velocitypowered.api.proxy.server.ServerPing;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class VelocityProxyPlaceholders extends PlaceholderProvider{
private final Map<String, ServerPing> serverStates = new ConcurrentHashMap<>();
private final VelocityCore plugin;
private VelocityProxyPlaceholders(VelocityCore plugin){
super("proxy");
this.plugin = plugin;
plugin.getProxy().getScheduler().buildTask(plugin, this::fetchServerStates)
.repeat(Duration.ofSeconds(10))
.schedule();
}
public static VelocityProxyPlaceholders init(VelocityCore plugin){
@@ -35,7 +27,7 @@ public class VelocityProxyPlaceholders extends PlaceholderProvider{
if(args.length < 2)
return null;
ServerPing ping = serverStates.get(args[1]);
ServerPing ping = plugin.getFetchedServers().get(args[1]);
return switch(args[0]){
case "status" -> ping == null ? "offline" : "online";
case "motd" -> {
@@ -67,16 +59,4 @@ public class VelocityProxyPlaceholders extends PlaceholderProvider{
default -> null;
};
}
private void fetchServerStates(){
serverStates.clear();
plugin.getProxy().getAllServers().forEach(server -> server.ping().whenComplete((ping, throwable) -> {
if(throwable != null){
plugin.getPluginLogger().warn("Encountered an exception while fetching status of Server %s", throwable, server.getServerInfo().getName());
return;
}
serverStates.put(server.getServerInfo().getName(), ping);
}));
}
}
+1 -1
View File
@@ -52,7 +52,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.8</version>
<version>1.5.9</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -53,7 +53,7 @@ public class VersionUploader{
if(args.length == 0){
LOGGER.warn("MISSING ARGUMENT!");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar [--dryrun] --all | --modrinth | --hangar");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar --all | --modrinth | --hangar [--dryrun]");
System.exit(1);
return;
}
@@ -84,7 +84,7 @@ public class VersionUploader{
}
default -> {
LOGGER.warn("Unknown argument '{}' provided.", args[0]);
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar [--dryrun] --all | --modrinth | --hangar");
LOGGER.warn("COMMAND USAGE: java -jar VersionUploader.jar --all | --modrinth | --hangar [--dryrun]");
System.exit(1);
return;
}
@@ -50,9 +50,9 @@ public class CodebergReleaseFetcher{
public static CodebergRelease fetch(){
String tag = System.getenv("CI_COMMIT_TAG");
String codbergToken = System.getenv("CODEBERG_API_TOKEN");
String codebergToken = System.getenv("CODEBERG_API_TOKEN");
if(tag == null || codbergToken == null || tag.isEmpty() || codbergToken.isEmpty()){
if(tag == null || codebergToken == null || tag.isEmpty() || codebergToken.isEmpty()){
LOGGER.warn("Cannot fetch release data. Either Tag or Codeberg token was null/empty.");
return null;
}
@@ -64,7 +64,7 @@ public class CodebergReleaseFetcher{
.url(url)
.header("User-Agent", "VersionUploader-CodebergReleaseFetcher/v1.0.0")
.header("Accept", "application/json")
.header("Authorization", "token " + codbergToken)
.header("Authorization", "token " + codebergToken)
.build();
try(Response response = CLIENT.newCall(request).execute()){
@@ -25,8 +25,8 @@
package ch.andre601.advancedserverlist.versionuploader.modrinth;
import ch.andre601.advancedserverlist.versionuploader.ReleaseHolder;
import ch.andre601.advancedserverlist.versionuploader.PlatformInfo;
import ch.andre601.advancedserverlist.versionuploader.ReleaseHolder;
import ch.andre601.advancedserverlist.versionuploader.VersionUploader;
import ch.andre601.advancedserverlist.versionuploader.data.CodebergRelease;
import com.google.gson.Gson;
@@ -143,7 +143,8 @@ public class ModrinthVersionUploader{
String url = versionUrl + projectVersion.getId();
logger.info("Created new release!");
logger.info("Link: {}", url);
logger.info("Link: {}", url);
logger.info("Platform: {}", platforms.get(index).getPlatform());
releaseHolder.addRelease(
"modrinth",