mirror of
https://codeberg.org/Andre601/AdvancedServerList.git
synced 2026-11-07 01:42:41 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
151f5494fc | ||
|
|
f997fa0a89 | ||
|
|
2f1549eb8a | ||
|
|
77dba75c17 | ||
|
|
dfa72cb852 | ||
|
|
dc0cf6ebfc | ||
|
|
2c520e53c0 | ||
|
|
356cca9ba0 | ||
|
|
4e7b17a601 | ||
|
|
033f4bd6ab | ||
|
|
13edca3c4c | ||
|
|
a626dc5b28 | ||
|
|
7a60024bd0 | ||
|
|
cedb1e5748 | ||
|
|
8b0fb99bc5 | ||
|
|
31202a930a | ||
|
|
a105e3186b | ||
|
|
e2df79c428 | ||
|
|
01ecce170c | ||
|
|
3bb171cecf | ||
|
|
f54bbe26e1 | ||
|
|
ddede7abef | ||
|
|
2c6467f176 | ||
|
|
8b92f8fc4d | ||
|
|
7bf6d8de0f | ||
|
|
844a88d381 | ||
|
|
fcea4e90e3 | ||
|
|
6a97debdf7 | ||
|
|
07fa6cf0ec | ||
|
|
367f0f3501 | ||
|
|
16dcaef825 | ||
|
|
f780372fda | ||
|
|
a8f8c0d770 | ||
|
|
70e06afaf0 | ||
|
|
13e087eddd | ||
|
|
31af916f04 |
No files matched your search
@@ -4,7 +4,7 @@ when:
|
||||
|
||||
steps:
|
||||
- name: "Build Jar and Upload"
|
||||
image: maven:3.9.10-eclipse-temurin-21
|
||||
image: maven:3.9.11-eclipse-temurin-21
|
||||
environment:
|
||||
CODEBERG_API_TOKEN:
|
||||
from_secret: cb_token
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<dependency>
|
||||
<groupId>space.arim.libertybans</groupId>
|
||||
<artifactId>bans-api</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
+29
-11
@@ -36,6 +36,9 @@ 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.interfaces.core.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialog;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialogList;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.handlers.FaviconHandler;
|
||||
import com.alessiodp.libby.BungeeLibraryManager;
|
||||
import com.alessiodp.libby.Library;
|
||||
@@ -116,7 +119,7 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
|
||||
@Override
|
||||
public void loadMetrics(){
|
||||
new Metrics(this, 15585).addCustomChart(new SimplePie("profiles",
|
||||
() -> String.valueOf(core.getFileHandler().getProfiles().size())
|
||||
() -> String.valueOf(core.fileHandler().profiles().size())
|
||||
));
|
||||
|
||||
}
|
||||
@@ -157,22 +160,22 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedServerList<Favicon> getCore(){
|
||||
public AdvancedServerList<Favicon> core(){
|
||||
return core;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFolderPath(){
|
||||
public Path folderPath(){
|
||||
return getDataFolder().toPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginLogger getPluginLogger(){
|
||||
public PluginLogger pluginLogger(){
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaviconHandler<Favicon> getFaviconHandler(){
|
||||
public FaviconHandler<Favicon> faviconHandler(){
|
||||
if(faviconHandler == null)
|
||||
faviconHandler = new FaviconHandler<>(core);
|
||||
|
||||
@@ -180,17 +183,17 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager<CmdSender> getCommandManager(){
|
||||
public CommandManager<CmdSender> commandManager(){
|
||||
return handler.commandHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformInfo(){
|
||||
public String platformInfo(){
|
||||
return getProxy().getName() + " " + getProxy().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLoader(){
|
||||
public String loader(){
|
||||
return "bungeecord";
|
||||
}
|
||||
|
||||
@@ -199,16 +202,31 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
|
||||
return getProxy().getPluginManager().getPlugin(plugin) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDialogsSupported(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Favicon createFavicon(BufferedImage image) throws IllegalArgumentException{
|
||||
return Favicon.create(image);
|
||||
}
|
||||
|
||||
public BungeeAudiences getAudiences(){
|
||||
@Override
|
||||
public IDialogList.IDialogListBuilder createDialogListBuilder(String title){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDialog.IDialogBuilder createDialogBuilder(String title, ServerListProfile profile, int profilesPosition){
|
||||
return null;
|
||||
}
|
||||
|
||||
public BungeeAudiences audiences(){
|
||||
return audiences;
|
||||
}
|
||||
|
||||
public int getOnlinePlayers(ServerInfo server){
|
||||
public int onlinePlayers(ServerInfo server){
|
||||
List<ProxiedPlayer> players = new ArrayList<>(server == null ? getProxy().getPlayers() : server.getPlayers());
|
||||
|
||||
// Exclude players when PremiumVanish is enabled and player is hidden.
|
||||
@@ -222,7 +240,7 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
|
||||
return players.size();
|
||||
}
|
||||
|
||||
public Map<String, ServerPing> getFetchedServers(){
|
||||
public Map<String, ServerPing> fetchedServers(){
|
||||
return fetchedServers;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class BungeeCommandManagerInterface implements CommandManagerInterface<Co
|
||||
@Override
|
||||
public SenderMapper<CommandSender, CmdSender> senderMapper(){
|
||||
return SenderMapper.create(
|
||||
cmdSender -> new BungeeCmdSender(cmdSender, plugin.getAudiences()),
|
||||
cmdSender -> new BungeeCmdSender(cmdSender, plugin.audiences()),
|
||||
sender -> ((BungeeCmdSender)sender).sender()
|
||||
);
|
||||
}
|
||||
|
||||
+16
-16
@@ -75,17 +75,17 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxPlayers(int maxPlayers){
|
||||
public void maxPlayers(int maxPlayers){
|
||||
ping.getPlayers().setMax(maxPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnlinePlayers(int onlinePlayers){
|
||||
public void onlinePlayers(int onlinePlayers){
|
||||
ping.getPlayers().setOnline(onlinePlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMotd(Component component){
|
||||
public void motd(Component component){
|
||||
ping.setDescriptionComponent(new TextComponent(BungeeComponentSerializer.get().serialize(component)));
|
||||
}
|
||||
|
||||
@@ -95,13 +95,13 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerCount(String name){
|
||||
public void playerCount(String name){
|
||||
protocol.setName(name);
|
||||
protocol.setProtocol(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayers(List<String> lines, BungeePlayerImpl player, GenericServer server){
|
||||
public void players(List<String> lines, BungeePlayerImpl player, GenericServer server){
|
||||
ServerPing.PlayerInfo[] players = new ServerPing.PlayerInfo[lines.size()];
|
||||
|
||||
for(int i = 0; i < players.length; i++){
|
||||
@@ -119,17 +119,17 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayersHidden(){
|
||||
public void playersHidden(){
|
||||
ping.getPlayers().setSample(new ServerPing.PlayerInfo[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFavicon(Favicon favicon){
|
||||
public void favicon(Favicon favicon){
|
||||
ping.setFavicon(favicon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultFavicon(){
|
||||
public void defaultFavicon(){
|
||||
ping.setFavicon(ping.getFaviconObject());
|
||||
}
|
||||
|
||||
@@ -153,22 +153,22 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion(){
|
||||
public int protocolVersion(){
|
||||
return event.getConnection().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOnlinePlayers(){
|
||||
return plugin.getOnlinePlayers(null);
|
||||
public int onlinePlayers(){
|
||||
return plugin.onlinePlayers(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers(){
|
||||
public int maxPlayers(){
|
||||
return ping.getPlayers().getMax();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerIP(){
|
||||
public String playerIP(){
|
||||
return ((InetSocketAddress)event.getConnection().getSocketAddress()).getHostString();
|
||||
}
|
||||
|
||||
@@ -196,12 +196,12 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVirtualHost(){
|
||||
public String virtualHost(){
|
||||
return this.resolveHost(event.getConnection().getVirtualHost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginCore<Favicon> getPlugin(){
|
||||
public PluginCore<Favicon> plugin(){
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericServer createGenericServer(int playersOnline, int playersMax, String host){
|
||||
public GenericServer createServer(int playersOnline, int playersMax, String host){
|
||||
Map<String, ServerInfo> servers = plugin.getProxy().getServers();
|
||||
|
||||
return new BungeeProxyImpl(servers, playersOnline, playersMax, host);
|
||||
|
||||
+4
-4
@@ -47,15 +47,15 @@ public class PlayerJoinEventListener implements Listener{
|
||||
InetSocketAddress address = (InetSocketAddress)event.getPlayer().getPendingConnection().getSocketAddress();
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
|
||||
plugin.getCore().getPlayerHandler().addPlayer(address.getHostString(), player.getName(), player.getUniqueId());
|
||||
plugin.core().playerHandler().addPlayer(address.getHostString(), player.getName(), player.getUniqueId());
|
||||
|
||||
if(player.hasPermission("advancedserverlist.admin") || player.hasPermission("advancedserverlist.updatecheck")){
|
||||
if(plugin.getAudiences() == null || plugin.getCore().getUpdateChecker() == null)
|
||||
if(plugin.audiences() == null || plugin.core().updateChecker() == null)
|
||||
return;
|
||||
|
||||
BungeeCmdSender sender = new BungeeCmdSender(player, plugin.getAudiences());
|
||||
BungeeCmdSender sender = new BungeeCmdSender(player, plugin.audiences());
|
||||
|
||||
plugin.getCore().getUpdateChecker().performCachedUpdateCheck(sender);
|
||||
plugin.core().updateChecker().performCachedUpdateCheck(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -27,9 +27,11 @@ package ch.andre601.advancedserverlist.bungeecord.objects.impl;
|
||||
|
||||
import ch.andre601.advancedserverlist.api.bungeecord.objects.BungeePlayer;
|
||||
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@NullMarked
|
||||
public record BungeePlayerImpl(CachedPlayer player, int protocol) implements BungeePlayer{
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -27,12 +27,13 @@ package ch.andre601.advancedserverlist.bungeecord.objects.impl;
|
||||
|
||||
import ch.andre601.advancedserverlist.api.bungeecord.objects.BungeeProxy;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record BungeeProxyImpl(Map<String, ServerInfo> servers, int playersOnline, int playersMax, String host) implements BungeeProxy{
|
||||
@Override
|
||||
public Map<String, ServerInfo> getServers(){
|
||||
public @NonNull Map<String, ServerInfo> getServers(){
|
||||
return servers;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -28,9 +28,12 @@ package ch.andre601.advancedserverlist.bungeecord.objects.placeholders;
|
||||
import ch.andre601.advancedserverlist.api.PlaceholderProvider;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericServer;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@NullMarked
|
||||
public class BungeePlayerPlaceholders extends PlaceholderProvider{
|
||||
|
||||
private BungeePlayerPlaceholders(){
|
||||
@@ -42,7 +45,7 @@ public class BungeePlayerPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
return switch(placeholder.toLowerCase(Locale.ROOT)){
|
||||
case "name" -> player.getName();
|
||||
case "protocol" -> String.valueOf(player.getProtocol());
|
||||
|
||||
+5
-2
@@ -9,7 +9,10 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class BungeeProxyPlaceholders extends PlaceholderProvider{
|
||||
|
||||
private final BungeeCordCore plugin;
|
||||
@@ -25,12 +28,12 @@ public class BungeeProxyPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
String[] args = placeholder.split("\\s", 2);
|
||||
if(args.length < 2)
|
||||
return null;
|
||||
|
||||
ServerPing ping = plugin.getFetchedServers().get(args[1]);
|
||||
ServerPing ping = plugin.fetchedServers().get(args[1]);
|
||||
|
||||
return switch(args[0]){
|
||||
case "status" -> ping == null ? "offline" : "online";
|
||||
|
||||
+6
-3
@@ -31,9 +31,12 @@ import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericServer;
|
||||
import ch.andre601.advancedserverlist.bungeecord.BungeeCordCore;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@NullMarked
|
||||
public class BungeeServerPlaceholders extends PlaceholderProvider{
|
||||
|
||||
private final BungeeCordCore plugin;
|
||||
@@ -48,7 +51,7 @@ public class BungeeServerPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
if(!(server instanceof BungeeProxy proxy))
|
||||
return null;
|
||||
|
||||
@@ -68,7 +71,7 @@ public class BungeeServerPlaceholders extends PlaceholderProvider{
|
||||
if(info == null)
|
||||
continue;
|
||||
|
||||
players += plugin.getOnlinePlayers(info);
|
||||
players += plugin.onlinePlayers(info);
|
||||
}
|
||||
|
||||
yield String.valueOf(players);
|
||||
@@ -87,7 +90,7 @@ public class BungeeServerPlaceholders extends PlaceholderProvider{
|
||||
if(args.length > 2)
|
||||
yield "";
|
||||
|
||||
if(args.length == 2 && args[1] != null && !args[1].isEmpty()){
|
||||
if(args.length == 2 && !args[1].isEmpty()){
|
||||
ServerInfo info = proxy.getServers().get(args[1]);
|
||||
if(info == null)
|
||||
yield "";
|
||||
|
||||
+3
-3
@@ -79,7 +79,7 @@
|
||||
<dependency>
|
||||
<groupId>ch.andre601</groupId>
|
||||
<artifactId>expressionparser</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<version>1.6.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
<dependency>
|
||||
<groupId>net.william278</groupId>
|
||||
<artifactId>papiproxybridge</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.8.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -188,7 +188,7 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.13.2</version>
|
||||
<version>5.13.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -29,6 +29,7 @@ import ch.andre601.advancedserverlist.api.AdvancedServerListAPI;
|
||||
import ch.andre601.advancedserverlist.api.PlaceholderProvider;
|
||||
import ch.andre601.advancedserverlist.core.check.UpdateChecker;
|
||||
import ch.andre601.advancedserverlist.core.commands.CommandHandler;
|
||||
import ch.andre601.advancedserverlist.core.commands.CommandTypePostprocessor;
|
||||
import ch.andre601.advancedserverlist.core.compat.maintenance.MaintenancePlaceholder;
|
||||
import ch.andre601.advancedserverlist.core.file.FileHandler;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
@@ -81,7 +82,7 @@ public class AdvancedServerList<F>{
|
||||
this.playerHandler = new PlayerHandler(this);
|
||||
this.textCenterUtil = new TextCenterUtil(this);
|
||||
|
||||
plugin.getPluginLogger().info("Registering internal Placeholders...");
|
||||
plugin.pluginLogger().info("Registering internal Placeholders...");
|
||||
|
||||
placeholders.forEach(this::addPlaceholder);
|
||||
|
||||
@@ -90,52 +91,52 @@ public class AdvancedServerList<F>{
|
||||
}
|
||||
|
||||
resolveVersion();
|
||||
getPlugin().getPluginLogger().info("Starting <white>AdvancedServerList v%s</white>...", version);
|
||||
plugin().pluginLogger().info("Starting <white>AdvancedServerList v%s</white>...", version);
|
||||
load();
|
||||
}
|
||||
|
||||
public static AdvancedServerListAPI getApi(){
|
||||
public static AdvancedServerListAPI api(){
|
||||
return api;
|
||||
}
|
||||
|
||||
public PluginCore<F> getPlugin(){
|
||||
public PluginCore<F> plugin(){
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public FileHandler getFileHandler(){
|
||||
public FileHandler fileHandler(){
|
||||
return fileHandler;
|
||||
}
|
||||
|
||||
public PlayerHandler getPlayerHandler(){
|
||||
public PlayerHandler playerHandler(){
|
||||
return playerHandler;
|
||||
}
|
||||
|
||||
public String getVersion(){
|
||||
public String version(){
|
||||
return version;
|
||||
}
|
||||
|
||||
public ProfileConditionParser getParser(){
|
||||
public ProfileConditionParser parser(){
|
||||
return parser;
|
||||
}
|
||||
|
||||
public UpdateChecker getUpdateChecker(){
|
||||
public UpdateChecker updateChecker(){
|
||||
return updateChecker;
|
||||
}
|
||||
|
||||
public TextCenterUtil getTextCenterUtil(){
|
||||
public TextCenterUtil textCenterUtil(){
|
||||
return textCenterUtil;
|
||||
}
|
||||
|
||||
public void disable(){
|
||||
getPlugin().getPluginLogger().info("[-] Saving <white>playercache.json</white> file...");
|
||||
getPlayerHandler().save();
|
||||
plugin().pluginLogger().info("[-] Saving <white>playercache.json</white> file...");
|
||||
playerHandler().save();
|
||||
|
||||
if(updateChecker != null){
|
||||
getPlugin().getPluginLogger().info("[-] Disabling Update Checker...");
|
||||
plugin().pluginLogger().info("[-] Disabling Update Checker...");
|
||||
updateChecker.disable();
|
||||
}
|
||||
|
||||
getPlugin().getPluginLogger().success("AdvancedServerList disabled!");
|
||||
plugin().pluginLogger().success("AdvancedServerList disabled!");
|
||||
}
|
||||
|
||||
public void clearFaviconCache(){
|
||||
@@ -143,69 +144,69 @@ public class AdvancedServerList<F>{
|
||||
}
|
||||
|
||||
public void clearPlayerCache(){
|
||||
getPlayerHandler().clearCache();
|
||||
playerHandler().clearCache();
|
||||
}
|
||||
|
||||
private void load(){
|
||||
if(!getFileHandler().loadConfig()){
|
||||
getPlugin().getPluginLogger().failure("Unable to load <white>config.yml</white>! Check previous lines for errors.");
|
||||
if(!fileHandler().loadConfig()){
|
||||
plugin().pluginLogger().failure("Unable to load <white>config.yml</white>! Check previous lines for errors.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(getFileHandler().isOldConfig()){
|
||||
getPlugin().getPluginLogger().info("[-] Detected old <white>config.yml</white>. Attempting to migrate...");
|
||||
if(getFileHandler().migrateConfig()){
|
||||
getPlugin().getPluginLogger().success("Migration completed successfully!");
|
||||
if(fileHandler().isOldConfig()){
|
||||
plugin().pluginLogger().info("[-] Detected old <white>config.yml</white>. Attempting to migrate...");
|
||||
if(fileHandler().migrateConfig()){
|
||||
plugin().pluginLogger().success("Migration completed successfully!");
|
||||
}else{
|
||||
getPlugin().getPluginLogger().failure("Couldn't migrate <white>config.yml</white>! Check previous lines for errors.");
|
||||
plugin().pluginLogger().failure("Couldn't migrate <white>config.yml</white>! Check previous lines for errors.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(getFileHandler().getBool(true, "printBanner")){
|
||||
if(fileHandler().getBool(true, "printBanner")){
|
||||
printBanner();
|
||||
}
|
||||
|
||||
getPlugin().getPluginLogger().info("Platform: <white>%s</white>", plugin.getPlatformInfo());
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("Platform: <white>%s</white>", plugin.platformInfo());
|
||||
plugin().pluginLogger().info("");
|
||||
|
||||
if(getFileHandler().loadProfiles()){
|
||||
getPlugin().getPluginLogger().success("Successfully loaded <white>%d</white> profile(s)!", getFileHandler().getProfiles().size());
|
||||
if(fileHandler().loadProfiles()){
|
||||
plugin().pluginLogger().success("Successfully loaded <white>%d</white> profile(s)!", fileHandler().profiles().size());
|
||||
}else{
|
||||
getPlugin().getPluginLogger().failure("Unable to load profiles! Check previous lines for errors.");
|
||||
plugin().pluginLogger().failure("Unable to load profiles! Check previous lines for errors.");
|
||||
return;
|
||||
}
|
||||
|
||||
loadCommands();
|
||||
|
||||
plugin.loadEvents();
|
||||
getPlayerHandler().load();
|
||||
playerHandler().load();
|
||||
plugin.loadMetrics();
|
||||
plugin.startScheduler();
|
||||
|
||||
getPlugin().getPluginLogger().success("<green>AdvancedServerList is ready!");
|
||||
plugin().pluginLogger().success("<green>AdvancedServerList is ready!");
|
||||
|
||||
if(getFileHandler().getBoolean("checkUpdates"))
|
||||
if(fileHandler().getBoolean("checkUpdates"))
|
||||
this.updateChecker = new UpdateChecker(this);
|
||||
}
|
||||
|
||||
private void printBanner(){
|
||||
getPlugin().getPluginLogger().info("<#3b90ff> __ _______ ___");
|
||||
getPlugin().getPluginLogger().info("<#3b90ff> /\\ \\ / ____|_| | |");
|
||||
getPlugin().getPluginLogger().info("<#3b90ff> / \\ \\ | (_(___ | | |");
|
||||
getPlugin().getPluginLogger().info("<#3b90ff> / /\\ \\ \\ \\___ \\ \\| | |");
|
||||
getPlugin().getPluginLogger().info("<#3b90ff> / ____ \\ \\ ____) | | |_|____");
|
||||
getPlugin().getPluginLogger().info("<#3b90ff>/_/_/ \\_\\_\\_____/_/|______|_|");
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("<#3b90ff> __ _______ ___");
|
||||
plugin().pluginLogger().info("<#3b90ff> /\\ \\ / ____|_| | |");
|
||||
plugin().pluginLogger().info("<#3b90ff> / \\ \\ | (_(___ | | |");
|
||||
plugin().pluginLogger().info("<#3b90ff> / /\\ \\ \\ \\___ \\ \\| | |");
|
||||
plugin().pluginLogger().info("<#3b90ff> / ____ \\ \\ ____) | | |_|____");
|
||||
plugin().pluginLogger().info("<#3b90ff>/_/_/ \\_\\_\\_____/_/|______|_|");
|
||||
plugin().pluginLogger().info("");
|
||||
|
||||
seasonalText();
|
||||
}
|
||||
|
||||
private void resolveVersion(){
|
||||
try(InputStream is = getClass().getResourceAsStream("/version.properties")){
|
||||
try(InputStream stream = getClass().getResourceAsStream("/version.properties")){
|
||||
Properties properties = new Properties();
|
||||
|
||||
properties.load(is);
|
||||
properties.load(stream);
|
||||
|
||||
version = properties.getProperty("version");
|
||||
}catch(IOException ex){
|
||||
@@ -214,15 +215,16 @@ public class AdvancedServerList<F>{
|
||||
}
|
||||
|
||||
private void addPlaceholder(PlaceholderProvider placeholderProvider){
|
||||
AdvancedServerList.getApi().addPlaceholderProvider(placeholderProvider);
|
||||
AdvancedServerList.api().addPlaceholderProvider(placeholderProvider);
|
||||
}
|
||||
|
||||
private void loadCommands(){
|
||||
getPlugin().loadFaviconHandler(this);
|
||||
plugin().loadFaviconHandler(this);
|
||||
|
||||
CommandManager<CmdSender> commandManager = plugin.getCommandManager();
|
||||
CommandManager<CmdSender> commandManager = plugin().commandManager();
|
||||
|
||||
commandManager.parameterInjectorRegistry().registerInjector(AdvancedServerList.class, ParameterInjector.constantInjector(this));
|
||||
commandManager.registerCommandPostProcessor(new CommandTypePostprocessor());
|
||||
|
||||
AnnotationParser<CmdSender> annotationParser = new AnnotationParser<>(commandManager, CmdSender.class);
|
||||
annotationParser.registerBuilderModifier(
|
||||
@@ -241,7 +243,7 @@ public class AdvancedServerList<F>{
|
||||
StringParser.stringParser(),
|
||||
Description.of("The profile to edit."),
|
||||
SuggestionProvider.suggesting(
|
||||
getFileHandler().getProfiles().stream()
|
||||
fileHandler().profiles().stream()
|
||||
.map(ServerListProfile::file)
|
||||
.map(Suggestion::suggestion)
|
||||
.toList()
|
||||
@@ -262,7 +264,7 @@ public class AdvancedServerList<F>{
|
||||
);
|
||||
}
|
||||
|
||||
getPlugin().getPluginLogger().success("Loaded Command <white>/advancedserverlist</white>!");
|
||||
plugin().pluginLogger().success("Loaded Command <white>/advancedserverlist</white>!");
|
||||
}
|
||||
|
||||
private ParserDescriptor<CmdSender, ?> descriptor(String option){
|
||||
@@ -295,34 +297,34 @@ public class AdvancedServerList<F>{
|
||||
switch(date.getMonth()){
|
||||
case JANUARY -> {
|
||||
if(date.getDayOfMonth() == 1){
|
||||
getPlugin().getPluginLogger().info("Happy new Year!");
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("Happy new Year!");
|
||||
plugin().pluginLogger().info("");
|
||||
}
|
||||
}
|
||||
case JUNE -> {
|
||||
getPlugin().getPluginLogger().info("Happy Pride Month!");
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("Happy Pride Month!");
|
||||
plugin().pluginLogger().info("");
|
||||
}
|
||||
case AUGUST -> {
|
||||
if(date.getDayOfMonth() == 1){
|
||||
getPlugin().getPluginLogger().info("Happy Birthday Switzerland!");
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("Happy Birthday Switzerland!");
|
||||
plugin().pluginLogger().info("");
|
||||
}
|
||||
}
|
||||
case OCTOBER -> {
|
||||
if(date.getDayOfMonth() == 31){
|
||||
getPlugin().getPluginLogger().info("Happy Halloween!");
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("Happy Halloween!");
|
||||
plugin().pluginLogger().info("");
|
||||
}
|
||||
}
|
||||
case DECEMBER -> {
|
||||
if(date.getDayOfMonth() == 13){
|
||||
getPlugin().getPluginLogger().info("Happy Birthday Andre_601!");
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("Happy Birthday Andre_601!");
|
||||
plugin().pluginLogger().info("");
|
||||
}else
|
||||
if(date.getDayOfMonth() > 23 && date.getDayOfMonth() < 27){
|
||||
getPlugin().getPluginLogger().info("Merry Christmas!");
|
||||
getPlugin().getPluginLogger().info("");
|
||||
plugin().pluginLogger().info("Merry Christmas!");
|
||||
plugin().pluginLogger().info("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public class UpdateChecker{
|
||||
|
||||
public UpdateChecker(AdvancedServerList<?> core){
|
||||
this.core = core;
|
||||
this.logger = core.getPlugin().getPluginLogger();
|
||||
this.loader = core.getPlugin().getLoader();
|
||||
this.logger = core.plugin().pluginLogger();
|
||||
this.loader = core.plugin().loader();
|
||||
this.client = HttpClient.newBuilder().executor(Executors.newSingleThreadExecutor(new UpdateCheckThread())).build();
|
||||
|
||||
startUpdateChecker();
|
||||
@@ -88,10 +88,10 @@ public class UpdateChecker{
|
||||
if(version == null)
|
||||
return;
|
||||
|
||||
int result = version.compare(core.getVersion());
|
||||
int result = version.compare(core.version());
|
||||
if(result == -1){
|
||||
sender.sendPrefixedMsg("<green>A new Version of AdvancedServerList is available!");
|
||||
sender.sendPrefixedMsg("<green>Your version: <white>%s", core.getVersion());
|
||||
sender.sendPrefixedMsg("<green>Your version: <white>%s", core.version());
|
||||
sender.sendPrefixedMsg("<green>Version on Modrinth: <white>%s", version.versionNumber());
|
||||
sender.sendPrefixedMsg(
|
||||
"<click:open_url:'https://modrinth.com/plugin/advancedserverlist/version/%s'>" +
|
||||
@@ -103,7 +103,7 @@ public class UpdateChecker{
|
||||
if(result == 1){
|
||||
sender.sendPrefixedMsg(
|
||||
"Your version (<white>%</white>) is newer than what is available on Modrinth (<white>%s</white>).",
|
||||
core.getVersion(),
|
||||
core.version(),
|
||||
version.versionNumber()
|
||||
);
|
||||
sender.sendPrefixedMsg("Are you using a Development Version?");
|
||||
@@ -137,14 +137,14 @@ public class UpdateChecker{
|
||||
|
||||
logger.debug(UpdateChecker.class, "Comparing versions...");
|
||||
|
||||
int result = version.compare(core.getVersion());
|
||||
int result = version.compare(core.version());
|
||||
switch(result){
|
||||
case -1 -> printUpdateBanner(version);
|
||||
case 0 -> logger.success("You are running the latest version!");
|
||||
case 1 -> {
|
||||
logger.info(
|
||||
"[?] Your version (<white>%s</white>) is newer than what is available on Modrint (<white>%s</white>).",
|
||||
core.getVersion(),
|
||||
core.version(),
|
||||
version.versionNumber()
|
||||
);
|
||||
logger.info(" Are you using a Development Version?");
|
||||
@@ -163,7 +163,7 @@ public class UpdateChecker{
|
||||
|
||||
logger.debug(UpdateChecker.class, "Checking '%s' for updates...", finalUrl);
|
||||
|
||||
if(core.getVersion().equals("UNKNOWN")){
|
||||
if(core.version().equals("UNKNOWN")){
|
||||
logger.warn("Cannot perform update check. Plugin version is 'UNKNOWN'!");
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class UpdateChecker{
|
||||
request = HttpRequest.newBuilder()
|
||||
.uri(new URI(finalUrl))
|
||||
.timeout(Duration.ofSeconds(5))
|
||||
.header("User-Agent", "AdvancedServerList-" + loader + "/" + core.getVersion())
|
||||
.header("User-Agent", "AdvancedServerList-" + loader + "/" + core.version())
|
||||
.build();
|
||||
}catch(URISyntaxException ex){
|
||||
logger.warn("Cannot perform update check. URL '%s' is not a valid URI.", ex, finalUrl);
|
||||
@@ -193,7 +193,7 @@ public class UpdateChecker{
|
||||
logger.warn("=======================================================================");
|
||||
logger.warn("You are running an outdated version of AdvancedServerList!");
|
||||
logger.warn("");
|
||||
logger.warn("Your version: <white>%s</white>", core.getVersion());
|
||||
logger.warn("Your version: <white>%s</white>", core.version());
|
||||
logger.warn("Modrinth: <white>%s</white>", version.versionNumber());
|
||||
logger.warn("");
|
||||
|
||||
|
||||
+101
-84
@@ -29,6 +29,8 @@ import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CommandType;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialog;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialogList;
|
||||
import ch.andre601.advancedserverlist.core.migration.minimotd.MiniMOTDConfigMigrator;
|
||||
import ch.andre601.advancedserverlist.core.migration.serverlistplus.SLPConfigMigrator;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
@@ -315,51 +317,7 @@ public class CommandHandler{
|
||||
}
|
||||
}
|
||||
|
||||
Path path = core.getPlugin().getFolderPath().resolve("profiles").resolve(profileName(profile));
|
||||
if(!Files.exists(path)){
|
||||
sender.sendErrorMsg("<red>No file with name</red> %s <red>found!", profile);
|
||||
return;
|
||||
}
|
||||
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder()
|
||||
.path(path)
|
||||
.indent(2)
|
||||
.nodeStyle(NodeStyle.BLOCK)
|
||||
.defaultOptions(opt -> opt.serializers(optBuilder -> optBuilder.register(ProfileEntry.class, ProfileSerializer.INSTANCE)))
|
||||
.build();
|
||||
|
||||
ConfigurationNode node;
|
||||
try{
|
||||
node = loader.load();
|
||||
}catch(IOException ex){
|
||||
sender.sendErrorMsg("<red>Encountered an IOException while trying to load file</red> %s<red>.", profile);
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
|
||||
core.getPlugin().getPluginLogger().warn("Encountered IOException while loading file <white>%s.yml</white>", profile);
|
||||
return;
|
||||
}
|
||||
|
||||
if(node == null){
|
||||
sender.sendErrorMsg("<red>Unable to load file</red> %s<red>.", profile);
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
node.node("priority").set(priority);
|
||||
node.node("condition").set(condition);
|
||||
node.node("profiles").setList(ProfileEntry.class, slp.profiles());
|
||||
node.set(ProfileEntry.class, builder.build());
|
||||
}catch(SerializationException ex){
|
||||
sender.sendErrorMsg("<red>Encountered a SerializationException while updating</red> %s<red>!", profile);
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
|
||||
core.getPlugin().getPluginLogger().warn("Encountered SerializationException while updating <white>%s</white>", profile);
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
loader.save(node);
|
||||
|
||||
if(core.fileHandler().saveProfile(profileName(profile), priority, condition, slp.profiles(), builder.build())){
|
||||
if(sender.isPlayer()){
|
||||
sender.sendPrefixedMsg(
|
||||
"<green>Successfully updated <white>[<grey><hover:show_text:\"%s\">%s</hover></grey>]</white>!",
|
||||
@@ -389,16 +347,16 @@ public class CommandHandler{
|
||||
sender.sendPrefixedMsg(
|
||||
"<green>Use <white><click:suggest_command:/asl reload>/asl reload</click></white> to apply changes."
|
||||
);
|
||||
}catch(IOException ex){
|
||||
}else{
|
||||
sender.sendErrorMsg("<red>Encountered an IOException while trying to save file</red> %s<red>.", profile);
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
|
||||
core.getPlugin().getPluginLogger().warn("Encountered IOException while saving file <white>%s.yml</white>", profile);
|
||||
core.plugin().pluginLogger().warn("Encountered IOException while saving file <white>%s.yml</white>", profile);
|
||||
}
|
||||
}
|
||||
|
||||
private static ServerListProfile profile(AdvancedServerList<?> core, String name){
|
||||
return core.getFileHandler().getProfiles().stream()
|
||||
return core.fileHandler().profiles().stream()
|
||||
.filter(p -> p.file().equalsIgnoreCase(profileName(name)))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
@@ -424,20 +382,13 @@ public class CommandHandler{
|
||||
}
|
||||
|
||||
private static String getOptionValue(Object obj){
|
||||
if(obj == null){
|
||||
return "";
|
||||
}else
|
||||
if(obj instanceof Boolean bool){
|
||||
return Boolean.toString(bool);
|
||||
}else
|
||||
if(obj instanceof Integer integer){
|
||||
return Integer.toString(integer);
|
||||
}else
|
||||
if(obj instanceof String str){
|
||||
return str;
|
||||
}else{
|
||||
return obj.toString();
|
||||
}
|
||||
return switch(obj){
|
||||
case null -> "";
|
||||
case Boolean bool -> Boolean.toString(bool);
|
||||
case Integer integer -> Integer.toString(integer);
|
||||
case String str -> str;
|
||||
default -> obj.toString();
|
||||
};
|
||||
}
|
||||
|
||||
private final CommandManager<CmdSender> commandManager;
|
||||
@@ -473,15 +424,15 @@ public class CommandHandler{
|
||||
public void reload(CmdSender sender, AdvancedServerList<?> core){
|
||||
sender.sendPrefixedMsg("Reloading plugin...");
|
||||
|
||||
if(core.getFileHandler().reloadConfig()){
|
||||
if(core.fileHandler().reloadConfig()){
|
||||
sender.sendPrefixedMsg("<green>Reloaded </green>config.yml<green>!");
|
||||
}else{
|
||||
sender.sendErrorMsg("<red>Error while reloading </red>config.yml<red>.");
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
}
|
||||
|
||||
if(core.getFileHandler().reloadProfiles()){
|
||||
sender.sendPrefixedMsg("<green>(Re)loaded </green>%d<green> Profile(s)!", core.getFileHandler().getProfiles().size());
|
||||
if(core.fileHandler().reloadProfiles()){
|
||||
sender.sendPrefixedMsg("<green>(Re)loaded </green>%d<green> Profile(s)!", core.fileHandler().profiles().size());
|
||||
}else{
|
||||
sender.sendErrorMsg("<red>Error while (re)loading profiles.");
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
@@ -516,7 +467,7 @@ public class CommandHandler{
|
||||
@NonNull @Argument(description = "The plugin to migrate from.") Plugin plugin
|
||||
){
|
||||
if(plugin == Plugin.SERVERLISTPLUS){
|
||||
if(!core.getPlugin().isPluginEnabled("ServerListPlus")){
|
||||
if(!core.plugin().isPluginEnabled("ServerListPlus")){
|
||||
sender.sendErrorMsg("<red>ServerListPlus is not enabled.");
|
||||
sender.sendErrorMsg("<red>The plugin is required for the migration to work.");
|
||||
return;
|
||||
@@ -559,7 +510,7 @@ public class CommandHandler{
|
||||
sender.sendPrefixedMsg("Available Profiles");
|
||||
sender.sendMsg("<dark_grey>│");
|
||||
|
||||
List<ServerListProfile> profiles = core.getFileHandler().getProfiles().stream()
|
||||
List<ServerListProfile> profiles = core.fileHandler().profiles().stream()
|
||||
.sorted(Comparator.comparingInt(ServerListProfile::priority).reversed())
|
||||
.toList();
|
||||
|
||||
@@ -598,11 +549,6 @@ public class CommandHandler{
|
||||
AdvancedServerList<?> core,
|
||||
@NonNull @Argument(description = "Name of the profile to view.", suggestions = "profiles") String profile
|
||||
){
|
||||
if(!sender.isPlayer()){
|
||||
sender.sendErrorMsg("<red>This command can only be executed by Players!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(profile.isEmpty()){
|
||||
sender.sendErrorMsg("<red>Insufficient arguments.");
|
||||
sender.sendErrorMsg("<red>Please provide a proper profile name.");
|
||||
@@ -749,7 +695,7 @@ public class CommandHandler{
|
||||
|
||||
String fileName = profileName(name);
|
||||
|
||||
if(core.getFileHandler().createFile(fileName)){
|
||||
if(core.fileHandler().createFile(fileName)){
|
||||
sender.sendPrefixedMsg("<green>Successfully created </green>%s<green>!", fileName);
|
||||
sender.sendPrefixedMsg("<green>Use <white><click:suggest_command:/asl reload>/asl reload</click></white> to load the file.");
|
||||
}else{
|
||||
@@ -790,7 +736,7 @@ public class CommandHandler{
|
||||
return;
|
||||
}
|
||||
|
||||
Path profilePath = core.getPlugin().getFolderPath().resolve("profiles").resolve(copyName);
|
||||
Path profilePath = core.plugin().folderPath().resolve("profiles").resolve(copyName);
|
||||
if(!Files.exists(profilePath)){
|
||||
try{
|
||||
Files.createFile(profilePath);
|
||||
@@ -798,7 +744,7 @@ public class CommandHandler{
|
||||
sender.sendErrorMsg("<red>Encountered IOException while creating file </red>%s<red>.", copyName);
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
|
||||
core.getPlugin().getPluginLogger().warn("Encountered IOException while creating file <white>%s</white>", ex, copyName);
|
||||
core.plugin().pluginLogger().warn("Encountered IOException while creating file <white>%s</white>", ex, copyName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -817,12 +763,7 @@ public class CommandHandler{
|
||||
sender.sendErrorMsg("<red>There was an IOException while loading file </red>%s<red>!", copyName);
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
|
||||
core.getPlugin().getPluginLogger().warn("Encountered IOException while loading file <white>%s</white>", ex, copyName);
|
||||
return;
|
||||
}
|
||||
|
||||
if(node == null){
|
||||
sender.sendErrorMsg("<red>Cannot create ConfigurationNode for file </red>%s<red>", copyName);
|
||||
core.plugin().pluginLogger().warn("Encountered IOException while loading file <white>%s</white>", ex, copyName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -837,7 +778,7 @@ public class CommandHandler{
|
||||
sender.sendErrorMsg("<red>There was a SerializationException while copying values from </red>%s<red>.", profile);
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
|
||||
core.getPlugin().getPluginLogger().warn("Encountered IOException while copying data from <white>%s</white> to <white>%s</white>.", ex, profileName, copyName);
|
||||
core.plugin().pluginLogger().warn("Encountered IOException while copying data from <white>%s</white> to <white>%s</white>.", ex, profileName, copyName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -849,10 +790,52 @@ public class CommandHandler{
|
||||
sender.sendErrorMsg("<red>There was an IOException while loading file </red>%s<red>!", copyName);
|
||||
sender.sendErrorMsg("<red>Check console for details.");
|
||||
|
||||
core.getPlugin().getPluginLogger().warn("Encountered IOException while loading file <white>%s</white>", ex, copyName);
|
||||
core.plugin().pluginLogger().warn("Encountered IOException while loading file <white>%s</white>", ex, copyName);
|
||||
}
|
||||
}
|
||||
|
||||
@Command("profiles edit <profile>")
|
||||
@CommandDescription("Opens a Dialog to edit a profile.")
|
||||
@Permission({"advancedserverlist.admin", "advancedserverlist.command.profiles", "advancedserverlist.command.profiles.edit"})
|
||||
@CommandType(CommandType.Type.PLAYER_ONLY)
|
||||
public void edit(
|
||||
CmdSender sender,
|
||||
AdvancedServerList<?> core,
|
||||
@NonNull @Argument(description = "Name of the profile to edit.", suggestions = "profiles") String profile
|
||||
){
|
||||
if(!core.plugin().isDialogsSupported()){
|
||||
sender.sendErrorMsg("This command requires the new Dialog feature to be available!");
|
||||
return;
|
||||
}
|
||||
|
||||
ServerListProfile slp = profile(core, profile);
|
||||
if(slp == null){
|
||||
sender.sendErrorMsg("No profile with name <white>%s</white> found.", profile);
|
||||
return;
|
||||
}
|
||||
|
||||
IDialogList.IDialogListBuilder listBuilder = core.plugin().createDialogListBuilder(slp.file());
|
||||
String warning = """
|
||||
<gold><b>WARNING!</b></gold>
|
||||
|
||||
Dialog-based profile editing is currently an <i>experimental feature</i>!
|
||||
Please create backups first before using it and report any bugs and/or glitches you may find.""";
|
||||
|
||||
listBuilder.appendBody(warning);
|
||||
|
||||
listBuilder.appendDialog(
|
||||
createDialog(core, "Main Settings", warning, slp, slp.defaultProfile(), slp.priority(), slp.condition(), -1)
|
||||
);
|
||||
|
||||
for(int i = 0; i < slp.profiles().size(); i++){
|
||||
listBuilder.appendDialog(
|
||||
createDialog(core, "Profiles <aqua>#" + (i + 1), warning, slp, slp.profiles().get(i), -1, null, i)
|
||||
);
|
||||
}
|
||||
|
||||
listBuilder.build().show(sender);
|
||||
}
|
||||
|
||||
@Suggestions("help")
|
||||
public List<String> helpQueries(CommandContext<CmdSender> context){
|
||||
return this.commandManager.createHelpHandler()
|
||||
@@ -872,7 +855,7 @@ public class CommandHandler{
|
||||
@Suggestions("profiles")
|
||||
public List<String> profilesSuggestions(CommandInput input, AdvancedServerList<?> core){
|
||||
String name = input.readString();
|
||||
List<String> profiles = core.getFileHandler().getProfiles().stream()
|
||||
List<String> profiles = core.fileHandler().profiles().stream()
|
||||
.map(profile -> profile.file().substring(0, profile.file().lastIndexOf('.')))
|
||||
.toList();
|
||||
if(name.isEmpty())
|
||||
@@ -932,6 +915,40 @@ public class CommandHandler{
|
||||
);
|
||||
}
|
||||
|
||||
private IDialog<?> createDialog(
|
||||
AdvancedServerList<?> core,
|
||||
String title,
|
||||
String warning,
|
||||
ServerListProfile slp,
|
||||
ProfileEntry entry,
|
||||
int priority,
|
||||
String condition,
|
||||
int index
|
||||
){
|
||||
IDialog.IDialogBuilder builder = core.plugin().createDialogBuilder(title, slp, index);
|
||||
builder.appendBody(warning);
|
||||
|
||||
if(index < 0){
|
||||
builder.appendNumberRange("priority", "Priority", priority)
|
||||
.appendTextInput("condition", "Condition", condition, 100);
|
||||
}
|
||||
|
||||
builder.appendTextbox("motd", "MOTD", entry.motd(), 100, 2)
|
||||
.appendTextInput("favicon", "Favicon", entry.favicon(), 100)
|
||||
.appendBoolean("hidePlayers", "Hide Player Count", entry.hidePlayersEnabled())
|
||||
.appendBoolean("hidePlayersHover", "Hide Player Count Hover", entry.hidePlayersHoverEnabled())
|
||||
.appendTextbox("hover", "Player Count Hover", entry.players(), 200, 10)
|
||||
.appendTextInput("text", "Player Count Text", entry.playerCountText(), 100)
|
||||
.appendBoolean("extraPlayersEnabled", "Enable Extra Players", entry.extraPlayersEnabled())
|
||||
.appendTextInput("extraPlayersCount", "Extra Players Count", entry.extraPlayersCount(), 100)
|
||||
.appendBoolean("maxPlayersEnabled", "Enable Max Players", entry.maxPlayersEnabled())
|
||||
.appendTextInput("maxPlayersCount", "Max Players Count", entry.maxPlayersCount(), 100)
|
||||
.appendBoolean("onlinePlayersEnabled", "Enable Online Players", entry.onlinePlayersEnabled())
|
||||
.appendTextInput("onlinePlayersCount", "Online Players Count", entry.onlinePlayersCount(), 100);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public enum Plugin {
|
||||
SERVERLISTPLUS,
|
||||
MINIMOTD
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package ch.andre601.advancedserverlist.core.commands;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CommandType;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.execution.postprocessor.CommandPostprocessingContext;
|
||||
import org.incendo.cloud.execution.postprocessor.CommandPostprocessor;
|
||||
import org.incendo.cloud.services.type.ConsumerService;
|
||||
|
||||
public class CommandTypePostprocessor implements CommandPostprocessor<CmdSender>{
|
||||
@Override
|
||||
public void accept(@NonNull CommandPostprocessingContext<CmdSender> context){
|
||||
CmdSender sender = context.commandContext().sender();
|
||||
CommandType.Type type = context.commandContext().command().commandMeta().get(CommandHandler.COMMAND_TYPE);
|
||||
|
||||
if(type == CommandType.Type.ALL || (type == CommandType.Type.PLAYER_ONLY && sender.isPlayer()))
|
||||
return;
|
||||
|
||||
sender.sendErrorMsg("<red>This command can only be executed by players!");
|
||||
ConsumerService.interrupt();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -145,7 +145,7 @@ public class ProfileOptionsSender{
|
||||
|
||||
builder.append(displayName);
|
||||
|
||||
if(option != null && !option.isEmpty())
|
||||
if(option != null && !option.isEmpty() && file != null && !file.isEmpty())
|
||||
builder.append("</click>");
|
||||
|
||||
if(hover != null && !hover.isEmpty())
|
||||
@@ -159,7 +159,7 @@ public class ProfileOptionsSender{
|
||||
}
|
||||
}
|
||||
|
||||
enum ColorName{
|
||||
public enum ColorName{
|
||||
RED,
|
||||
GREEN,
|
||||
AQUA;
|
||||
|
||||
+5
-2
@@ -4,7 +4,10 @@ import ch.andre601.advancedserverlist.api.PlaceholderProvider;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericServer;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class MaintenancePlaceholder extends PlaceholderProvider{
|
||||
|
||||
private final AdvancedServerList<?> plugin;
|
||||
@@ -15,8 +18,8 @@ public class MaintenancePlaceholder extends PlaceholderProvider{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
if(!placeholder.equals("maintenanceEnabled") || !plugin.getPlugin().isPluginEnabled("Maintenance"))
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
if(!placeholder.equals("maintenanceEnabled") || !plugin.plugin().isPluginEnabled("Maintenance"))
|
||||
return null;
|
||||
|
||||
return String.valueOf(MaintenanceUtil.get().isMaintenanceEnabled());
|
||||
|
||||
+24
-24
@@ -44,28 +44,28 @@ import java.util.List;
|
||||
public class PingEventHandler{
|
||||
|
||||
public static <F, P extends GenericPlayer> ProfileEntry handleEvent(GenericEventWrapper<F, P> event){
|
||||
event.getPlugin().getPluginLogger().debug(PingEventHandler.class, "Received ping event. Handling it...");
|
||||
event.plugin().pluginLogger().debug(PingEventHandler.class, "Received ping event. Handling it...");
|
||||
if(event.isInvalidProtocol()){
|
||||
event.getPlugin().getPluginLogger().debug(PingEventHandler.class, "Not handling event. Protocol was invalid.");
|
||||
event.plugin().pluginLogger().debug(PingEventHandler.class, "Not handling event. Protocol was invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
PluginCore<F> plugin = event.getPlugin();
|
||||
String host = event.getVirtualHost();
|
||||
PluginLogger logger = plugin.getPluginLogger();
|
||||
PluginCore<F> plugin = event.plugin();
|
||||
String host = event.virtualHost();
|
||||
PluginLogger logger = plugin.pluginLogger();
|
||||
|
||||
logger.debug(PingEventHandler.class, "Protocol valid. Continue handling...");
|
||||
|
||||
int online = event.getOnlinePlayers();
|
||||
int max = event.getMaxPlayers();
|
||||
int online = event.onlinePlayers();
|
||||
int max = event.maxPlayers();
|
||||
|
||||
P player = event.createPlayer(
|
||||
plugin.getCore().getPlayerHandler().getCachedPlayer(event.getPlayerIP()),
|
||||
event.getProtocolVersion()
|
||||
plugin.core().playerHandler().getCachedPlayer(event.playerIP()),
|
||||
event.protocolVersion()
|
||||
);
|
||||
GenericServer server = event.createGenericServer(online, max, host);
|
||||
GenericServer server = event.createServer(online, max, host);
|
||||
|
||||
ServerListProfile profile = ProfileManager.resolveProfile(plugin.getCore(), player, server);
|
||||
ServerListProfile profile = ProfileManager.resolveProfile(plugin.core(), player, server);
|
||||
|
||||
if(profile == null){
|
||||
logger.debugWarn(PingEventHandler.class, "Server List Profile couldn't be resolved properly. Cancelling event handling...");
|
||||
@@ -97,7 +97,7 @@ public class PingEventHandler{
|
||||
|
||||
try{
|
||||
online = onlinePlayers == null ? online : Integer.parseInt(onlinePlayers);
|
||||
event.setOnlinePlayers(online);
|
||||
event.onlinePlayers(online);
|
||||
}catch(NumberFormatException ex){
|
||||
logger.warn("Option 'playerCount -> onlinePlayers -> amount' is not a valid Number!");
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class PingEventHandler{
|
||||
max = online + (extraPlayers == null ? 0 : Integer.parseInt(extraPlayers));
|
||||
|
||||
logger.debug(PingEventHandler.class, "'playerCount -> extraPlayers -> amount' is a valid number. Applying it...");
|
||||
event.setMaxPlayers(max);
|
||||
event.maxPlayers(max);
|
||||
}catch(NumberFormatException ex){
|
||||
logger.warn("Option 'playerCount -> extraPlayers -> amount' is not a valid Number!");
|
||||
}
|
||||
@@ -133,13 +133,13 @@ public class PingEventHandler{
|
||||
max = maxPlayers == null ? 0 : Integer.parseInt(maxPlayers);
|
||||
|
||||
logger.debug(PingEventHandler.class, "'playerCount -> maxPlayers -> amount' is a valid number. Applying it...");
|
||||
event.setMaxPlayers(max);
|
||||
event.maxPlayers(max);
|
||||
}catch(NumberFormatException ex){
|
||||
logger.warn("Option 'playerCount -> maxPlayers -> amount' is not a valid Number!");
|
||||
}
|
||||
}
|
||||
|
||||
GenericServer finalServer = event.createGenericServer(online, max, host);
|
||||
GenericServer finalServer = event.createServer(online, max, host);
|
||||
|
||||
if(ProfileManager.checkOption(entry.motd()) && ignoreMaintenance(event, "motd")){
|
||||
logger.debug(PingEventHandler.class, "'motd' option present. Applying ['%s']...", String.join("', '", entry.motd()));
|
||||
@@ -148,12 +148,12 @@ public class PingEventHandler{
|
||||
.map(line -> ComponentParser.text(line)
|
||||
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
|
||||
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
|
||||
.modifyText(text -> plugin.getCore().getTextCenterUtil().getCenteredText(text))
|
||||
.modifyText(text -> plugin.core().textCenterUtil().getCenteredText(text))
|
||||
.toComponent()
|
||||
)
|
||||
.toList();
|
||||
|
||||
event.setMotd(Component.join(JoinConfiguration.separator(Component.newline()), motd));
|
||||
event.motd(Component.join(JoinConfiguration.separator(Component.newline()), motd));
|
||||
}
|
||||
|
||||
boolean hidePlayers = ProfileManager.checkOption(entry.hidePlayersEnabled());
|
||||
@@ -167,7 +167,7 @@ public class PingEventHandler{
|
||||
if(ProfileManager.checkOption(entry.playerCountText()) && !hidePlayers && ignoreMaintenance(event, "playerCountText")){
|
||||
logger.debug(PingEventHandler.class, "'playerCount -> text' option set. Applying '%s'...", entry.playerCountText());
|
||||
|
||||
event.setPlayerCount(
|
||||
event.playerCount(
|
||||
ComponentParser.text(entry.playerCountText())
|
||||
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
|
||||
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
|
||||
@@ -178,13 +178,13 @@ public class PingEventHandler{
|
||||
boolean hidePlayersHover = ProfileManager.checkOption(entry.hidePlayersHoverEnabled());
|
||||
if(hidePlayersHover){
|
||||
logger.debug(PingEventHandler.class, "'playerCount -> hidePlayersHover' option set. Hiding Player Hover...");
|
||||
event.setPlayersHidden();
|
||||
event.playersHidden();
|
||||
}
|
||||
|
||||
if(ProfileManager.checkOption(entry.players()) && !hidePlayers && !hidePlayersHover && ignoreMaintenance(event, "playerCountHover")){
|
||||
logger.debug(PingEventHandler.class, "'playerCount -> hover' option set. Applying ['%s']...", String.join("', '", entry.players()));
|
||||
|
||||
event.setPlayers(entry.players(), player, server);
|
||||
event.players(entry.players(), player, server);
|
||||
}
|
||||
|
||||
if(ProfileManager.checkOption(entry.favicon()) && ignoreMaintenance(event, "favicon")){
|
||||
@@ -195,16 +195,16 @@ public class PingEventHandler{
|
||||
.modify(text -> event.parsePAPIPlaceholders(text, player))
|
||||
.asString();
|
||||
|
||||
F favicon = plugin.getFaviconHandler().favicon(faviconString);
|
||||
F favicon = plugin.faviconHandler().favicon(faviconString);
|
||||
|
||||
if(favicon == null){
|
||||
logger.debugWarn(PingEventHandler.class, "Favicon was invalid or not yet resolved! Using default favicon of Server/Proxy...");
|
||||
|
||||
event.setDefaultFavicon();
|
||||
event.defaultFavicon();
|
||||
}else{
|
||||
logger.debug(PingEventHandler.class, "Applying favicon...");
|
||||
|
||||
event.setFavicon(favicon);
|
||||
event.favicon(favicon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +218,6 @@ public class PingEventHandler{
|
||||
if(!event.isMaintenanceModeActive())
|
||||
return true;
|
||||
|
||||
return !event.getPlugin().getCore().getFileHandler().getBool(true, "disableDuringMaintenance", option);
|
||||
return !event.plugin().core().fileHandler().getBool(true, "disableDuringMaintenance", option);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.profile.ProfileSerializer;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.yaml.NodeStyle;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
@@ -46,6 +47,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FileHandler{
|
||||
|
||||
@@ -61,18 +63,27 @@ public class FileHandler{
|
||||
|
||||
public FileHandler(AdvancedServerList<?> core){
|
||||
this.plugin = core;
|
||||
this.logger = core.getPlugin().getPluginLogger();
|
||||
this.logger = core.plugin().pluginLogger();
|
||||
|
||||
this.config = core.getPlugin().getFolderPath().resolve("config.yml");
|
||||
this.profilesFolder = core.getPlugin().getFolderPath().resolve("profiles");
|
||||
this.config = core.plugin().folderPath().resolve("config.yml");
|
||||
this.profilesFolder = core.plugin().folderPath().resolve("profiles");
|
||||
}
|
||||
|
||||
public List<ServerListProfile> getProfiles(){
|
||||
public List<ServerListProfile> profiles(){
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public ServerListProfile profile(String file){
|
||||
for(ServerListProfile profile : profiles){
|
||||
if(profile.file().equalsIgnoreCase(file))
|
||||
return profile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean loadConfig(){
|
||||
File folder = plugin.getPlugin().getFolderPath().toFile();
|
||||
File folder = plugin.plugin().folderPath().toFile();
|
||||
if(!folder.exists() && !folder.mkdirs()){
|
||||
logger.warn("Couldn't create folder for plugin. Is it missing Write permissions?");
|
||||
return false;
|
||||
@@ -106,6 +117,48 @@ public class FileHandler{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean saveProfile(String file, int priority, String condition, List<ProfileEntry> profiles, ProfileEntry defaultProfile){
|
||||
String filename = file.toLowerCase(Locale.ROOT);
|
||||
Path filePath = profilesFolder.resolve(filename.endsWith(".yml") ? filename : filename + ".yml");
|
||||
if(!Files.exists(filePath)){
|
||||
logger.warn("Cannot find profile with file name '<white>%s</white>'", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder()
|
||||
.defaultOptions(opts -> opts.serializers(build -> build.register(ProfileEntry.class, ProfileSerializer.INSTANCE)))
|
||||
.path(filePath)
|
||||
.nodeStyle(NodeStyle.BLOCK)
|
||||
.build();
|
||||
|
||||
ConfigurationNode node;
|
||||
try{
|
||||
node = loader.load();
|
||||
}catch(IOException ex){
|
||||
logger.warn("Encountered an IOException while loading file '<white>%s</white>'", ex, filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(node == null)
|
||||
return false;
|
||||
|
||||
try{
|
||||
node.node("priority").set(priority);
|
||||
node.node("condition").set(condition);
|
||||
node.node("profiles").setList(ProfileEntry.class, profiles);
|
||||
node.set(ProfileEntry.class, defaultProfile);
|
||||
|
||||
loader.save(node);
|
||||
return true;
|
||||
}catch(SerializationException ex){
|
||||
logger.warn("Encountered a SerializationException while saving file '<white>%s</white>'", ex, filename);
|
||||
return false;
|
||||
}catch(IOException ex){
|
||||
logger.warn("Encountered an IOException while saving file '<white>%s</white>'", ex, filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean createFile(String name){
|
||||
if(Files.notExists(profilesFolder) && profilesFolder.toFile().mkdirs()){
|
||||
logger.debugSuccess(FileHandler.class, "Successfully created profiles folder.");
|
||||
@@ -219,7 +272,7 @@ public class FileHandler{
|
||||
private boolean makeBackup(){
|
||||
logger.info("[-] Making backup of old config.yml...");
|
||||
|
||||
File backups = plugin.getPlugin().getFolderPath().resolve("backups").toFile();
|
||||
File backups = plugin.plugin().folderPath().resolve("backups").toFile();
|
||||
if(!backups.exists() && !backups.mkdirs()){
|
||||
logger.failure("Cannot create backups folder for migration!");
|
||||
return false;
|
||||
|
||||
+18
-9
@@ -26,8 +26,11 @@
|
||||
package ch.andre601.advancedserverlist.core.interfaces.core;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialog;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialogList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.handlers.FaviconHandler;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
|
||||
@@ -48,28 +51,34 @@ public interface PluginCore<F>{
|
||||
|
||||
void startScheduler();
|
||||
|
||||
AdvancedServerList<F> getCore();
|
||||
AdvancedServerList<F> core();
|
||||
|
||||
Path getFolderPath();
|
||||
Path folderPath();
|
||||
|
||||
PluginLogger getPluginLogger();
|
||||
PluginLogger pluginLogger();
|
||||
|
||||
FaviconHandler<F> getFaviconHandler();
|
||||
FaviconHandler<F> faviconHandler();
|
||||
|
||||
CommandManager<CmdSender> getCommandManager();
|
||||
CommandManager<CmdSender> commandManager();
|
||||
|
||||
String getPlatformInfo();
|
||||
String platformInfo();
|
||||
|
||||
String getLoader();
|
||||
String loader();
|
||||
|
||||
boolean isPluginEnabled(String plugin);
|
||||
|
||||
boolean isDialogsSupported();
|
||||
|
||||
F createFavicon(BufferedImage image) throws Exception;
|
||||
|
||||
IDialogList.IDialogListBuilder createDialogListBuilder(String title);
|
||||
|
||||
IDialog.IDialogBuilder createDialogBuilder(String title, ServerListProfile profile, int profilesPosition);
|
||||
|
||||
default boolean isDebugEnabled(){
|
||||
if(getCore() == null)
|
||||
if(core() == null)
|
||||
return false;
|
||||
|
||||
return getCore().getFileHandler().getBoolean("debug");
|
||||
return core().fileHandler().getBoolean("debug");
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package ch.andre601.advancedserverlist.core.interfaces.dialogs;
|
||||
|
||||
import ch.andre601.advancedserverlist.api.objects.NullBool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDialog<T>{
|
||||
T createDialog();
|
||||
|
||||
interface IDialogBuilder{
|
||||
IDialogBuilder appendBody(String body);
|
||||
|
||||
IDialogBuilder appendTextInput(String key, String title, String initValue, int maxLength);
|
||||
|
||||
IDialogBuilder appendTextbox(String key, String title, List<String> initValue, int maxLength, int rows);
|
||||
|
||||
IDialogBuilder appendNumberRange(String key, String title, int initValue);
|
||||
|
||||
IDialogBuilder appendBoolean(String key, String title, NullBool initValue);
|
||||
|
||||
IDialog<?> build();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package ch.andre601.advancedserverlist.core.interfaces.dialogs;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
|
||||
public interface IDialogList{
|
||||
|
||||
void show(CmdSender sender);
|
||||
|
||||
interface IDialogListBuilder{
|
||||
IDialogListBuilder appendBody(String body);
|
||||
|
||||
IDialogListBuilder appendDialog(IDialog<?> dialog);
|
||||
|
||||
IDialogList build();
|
||||
}
|
||||
}
|
||||
+15
-15
@@ -40,23 +40,23 @@ public interface GenericEventWrapper<F, P extends GenericPlayer>{
|
||||
|
||||
GenericServerListEvent callEvent(ProfileEntry entry);
|
||||
|
||||
void setMaxPlayers(int maxPlayers);
|
||||
void maxPlayers(int maxPlayers);
|
||||
|
||||
void setOnlinePlayers(int onlinePlayers);
|
||||
void onlinePlayers(int onlinePlayers);
|
||||
|
||||
void setMotd(Component component);
|
||||
void motd(Component component);
|
||||
|
||||
void hidePlayers();
|
||||
|
||||
void setPlayerCount(String name);
|
||||
void playerCount(String name);
|
||||
|
||||
void setPlayers(List<String> players, P player, GenericServer server);
|
||||
void players(List<String> players, P player, GenericServer server);
|
||||
|
||||
void setPlayersHidden();
|
||||
void playersHidden();
|
||||
|
||||
void setFavicon(F favicon);
|
||||
void favicon(F favicon);
|
||||
|
||||
void setDefaultFavicon();
|
||||
void defaultFavicon();
|
||||
|
||||
void updateEvent();
|
||||
|
||||
@@ -64,23 +64,23 @@ public interface GenericEventWrapper<F, P extends GenericPlayer>{
|
||||
|
||||
boolean isMaintenanceModeActive();
|
||||
|
||||
int getProtocolVersion();
|
||||
int protocolVersion();
|
||||
|
||||
int getOnlinePlayers();
|
||||
int onlinePlayers();
|
||||
|
||||
int getMaxPlayers();
|
||||
int maxPlayers();
|
||||
|
||||
String getPlayerIP();
|
||||
String playerIP();
|
||||
|
||||
String parsePAPIPlaceholders(String text, P player);
|
||||
|
||||
String getVirtualHost();
|
||||
String virtualHost();
|
||||
|
||||
PluginCore<F> getPlugin();
|
||||
PluginCore<F> plugin();
|
||||
|
||||
P createPlayer(CachedPlayer player, int protocol);
|
||||
|
||||
GenericServer createGenericServer(int playersOnline, int playersMax, String host);
|
||||
GenericServer createServer(int playersOnline, int playersMax, String host);
|
||||
|
||||
default String resolveHost(InetSocketAddress address){
|
||||
return address == null ? null : address.getHostString();
|
||||
|
||||
+9
-7
@@ -49,12 +49,14 @@ import java.util.List;
|
||||
public class MiniMOTDConfigMigrator{
|
||||
|
||||
public static boolean migrate(AdvancedServerList<?> core, CmdSender sender){
|
||||
core.getPlugin().downloadLibrary("org.spongepowered", "configurate-hocon", "4.1.2");
|
||||
sender.sendMsg("Loading Configurate-Hocon library. This may take a while...");
|
||||
core.plugin().downloadLibrary("org.spongepowered", "configurate-hocon", "4.1.2");
|
||||
sender.sendMsg("<green>Library loaded!");
|
||||
|
||||
PluginLogger logger = core.getPlugin().getPluginLogger();
|
||||
String folder = core.getPlugin().getLoader().equals("velocity") ? "minimotd-velocity" : "MiniMOTD";
|
||||
PluginLogger logger = core.plugin().pluginLogger();
|
||||
String folder = core.plugin().loader().equals("velocity") ? "minimotd-velocity" : "MiniMOTD";
|
||||
|
||||
Path mainConf = core.getPlugin().getFolderPath().getParent().resolve(folder).resolve("main.conf");
|
||||
Path mainConf = core.plugin().folderPath().getParent().resolve(folder).resolve("main.conf");
|
||||
if(!Files.exists(mainConf)){
|
||||
logger.warn("[<white>Migrator - MiniMOTD</white>] Cannot find a main.conf file in <white>/plugins/%s/</white> folder.", folder);
|
||||
sender.sendErrorMsg(" -> <red>No main.conf file found.");
|
||||
@@ -98,7 +100,7 @@ public class MiniMOTDConfigMigrator{
|
||||
|
||||
if(config.motdEnabled()){
|
||||
if(config.motds().size() == 1){
|
||||
applyMotd(profileBuilder, config.motds().get(0));
|
||||
applyMotd(profileBuilder, config.motds().getFirst());
|
||||
}else
|
||||
if(config.motds().size() > 1){
|
||||
for(int i = 0; i < config.motds().size(); i++){
|
||||
@@ -109,7 +111,7 @@ public class MiniMOTDConfigMigrator{
|
||||
|
||||
if(config.iconEnabled()){
|
||||
if(config.motds().size() == 1){
|
||||
MiniMOTDConfig.Motd motd = config.motds().get(0);
|
||||
MiniMOTDConfig.Motd motd = config.motds().getFirst();
|
||||
if(!motd.icon().isEmpty()){
|
||||
profileBuilder.favicon(motd.icon());
|
||||
}
|
||||
@@ -152,7 +154,7 @@ public class MiniMOTDConfigMigrator{
|
||||
return false;
|
||||
}
|
||||
|
||||
Path profile = core.getPlugin().getFolderPath().resolve("profiles").resolve("minimotd_migrated.yml");
|
||||
Path profile = core.plugin().folderPath().resolve("profiles").resolve("minimotd_migrated.yml");
|
||||
if(Files.exists(profile)){
|
||||
logger.warn("[<white>Migrator - MiniMOTD</white>] Cannot create new file minimotd_migrated.yml. One with the same name is already present.");
|
||||
sender.sendErrorMsg(" -> <red>File</red> minimotd_migrated.yml <red>already present.");
|
||||
|
||||
+4
-4
@@ -99,7 +99,7 @@ public class SLPConfigMigrator{
|
||||
|
||||
public static int migrate(AdvancedServerList<?> core, CmdSender sender){
|
||||
ServerListPlusCore slpCore = ServerListPlusCore.getInstance();
|
||||
PluginLogger logger = core.getPlugin().getPluginLogger();
|
||||
PluginLogger logger = core.plugin().pluginLogger();
|
||||
if(slpCore == null){
|
||||
logger.warn("[<white>Migrator - ServerListPlus</white>] Cannot migrate ServerListPlus config. ServerListPlus is not active!");
|
||||
return 0;
|
||||
@@ -128,7 +128,7 @@ public class SLPConfigMigrator{
|
||||
}
|
||||
|
||||
private static int parseConf(AdvancedServerList<?> core, CmdSender sender, PersonalizedStatusConf.StatusConf conf, Type type){
|
||||
PluginLogger logger = core.getPlugin().getPluginLogger();
|
||||
PluginLogger logger = core.plugin().pluginLogger();
|
||||
if(conf == null){
|
||||
logger.info("[<white>Migrator - ServerListPlus</white>] No StatusConf found for type <white>%s</white>. Skipping...", type.getName());
|
||||
sender.sendPrefixedMsg(" -> Not found! Skipping...");
|
||||
@@ -176,7 +176,7 @@ public class SLPConfigMigrator{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Path profile = core.getPlugin().getFolderPath().resolve("profiles").resolve(type.getFile());
|
||||
Path profile = core.plugin().folderPath().resolve("profiles").resolve(type.getFile());
|
||||
if(Files.exists(profile)){
|
||||
logger.warn("[<white>Migrator - ServerListPlus</white>] Cannot create new file <white>%s</white>. One with the same name is already present", type.getFile());
|
||||
sender.sendErrorMsg(" -> <red>File</red> %s <red>already present.", type.getFile());
|
||||
@@ -223,7 +223,7 @@ public class SLPConfigMigrator{
|
||||
|
||||
if(type == Type.PERSONALIZED){
|
||||
node.node("condition")
|
||||
.set("${player name} != \"" + core.getFileHandler().getString("Anonymous", "unknownPlayer", "name") + "\"");
|
||||
.set("${player name} != \"" + core.fileHandler().getString("Anonymous", "unknownPlayer", "name") + "\"");
|
||||
}else
|
||||
if(type == Type.BANNED){
|
||||
node.node("condition")
|
||||
|
||||
@@ -77,8 +77,8 @@ public class TextCenterUtil{
|
||||
private Map<String, FontInfo> loadFontWidths(AdvancedServerList<?> plugin){
|
||||
try(InputStream stream = plugin.getClass().getResourceAsStream("/char-widths.json.gz")){
|
||||
if(stream == null){
|
||||
plugin.getPlugin().getPluginLogger().warn("Internal char-widths.json.gz couldn't be retrieved.");
|
||||
plugin.getPlugin().getPluginLogger().warn("The <center> Placeholder won't work.");
|
||||
plugin.plugin().pluginLogger().warn("Internal char-widths.json.gz couldn't be retrieved.");
|
||||
plugin.plugin().pluginLogger().warn("The <center> Placeholder won't work.");
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ public class TextCenterUtil{
|
||||
|
||||
return new Gson().fromJson(reader, new TypeToken<Map<String, FontInfo>>(){}.getType());
|
||||
}catch(IOException ex){
|
||||
plugin.getPlugin().getPluginLogger().warn("Encountered IOException while loading font widths.");
|
||||
plugin.getPlugin().getPluginLogger().warn("The <center> Placeholder won't work.");
|
||||
plugin.getPlugin().getPluginLogger().warn("Cause: <white>%s</white>", ex.getMessage());
|
||||
plugin.plugin().pluginLogger().warn("Encountered IOException while loading font widths.");
|
||||
plugin.plugin().pluginLogger().warn("The <center> Placeholder won't work.");
|
||||
plugin.plugin().pluginLogger().warn("Cause: <white>%s</white>", ex.getMessage());
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,9 +46,9 @@ public record ServerListProfile(int priority, String condition, ProfileEntry def
|
||||
return true;
|
||||
|
||||
ParseWarnCollector collector = new ParseWarnCollector(condition);
|
||||
PluginLogger logger = core.getPlugin().getPluginLogger();
|
||||
PluginLogger logger = core.plugin().pluginLogger();
|
||||
|
||||
boolean result = core.getParser().evaluate(condition, player, server, collector);
|
||||
boolean result = core.parser().evaluate(condition, player, server, collector);
|
||||
|
||||
if(collector.hasWarnings()){
|
||||
logger.warn("Encountered <white>%d</white> Error(s) while parsing condition for file '<white>%s</white>':", collector.getWarnings().size(), file);
|
||||
|
||||
+8
-8
@@ -38,10 +38,10 @@ public class FaviconHandler<F>{
|
||||
|
||||
public FaviconHandler(AdvancedServerList<F> core){
|
||||
this.core = core;
|
||||
this.logger = core.getPlugin().getPluginLogger();
|
||||
this.logger = core.plugin().pluginLogger();
|
||||
this.faviconThreadPool = createThreadPool();
|
||||
this.faviconCache = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(core.getFileHandler().getLong(1, 1, "faviconCacheTime"), TimeUnit.MINUTES)
|
||||
.expireAfterWrite(core.fileHandler().getLong(1, 1, "faviconCacheTime"), TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
loadLocalFavicons();
|
||||
@@ -118,7 +118,7 @@ public class FaviconHandler<F>{
|
||||
BufferedImage image = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = image.createGraphics();
|
||||
|
||||
String strategy = core.getFileHandler().getString("resize", "faviconStrategy");
|
||||
String strategy = core.fileHandler().getString("resize", "faviconStrategy");
|
||||
int layer = 0;
|
||||
for(BufferedImage img : images){
|
||||
layer++;
|
||||
@@ -200,7 +200,7 @@ public class FaviconHandler<F>{
|
||||
|
||||
logger.info("[-] Loading local images as Favicons...");
|
||||
|
||||
Path folder = core.getPlugin().getFolderPath().resolve("favicons");
|
||||
Path folder = core.plugin().folderPath().resolve("favicons");
|
||||
if(!Files.exists(folder)){
|
||||
try{
|
||||
Files.createDirectories(folder);
|
||||
@@ -228,7 +228,7 @@ public class FaviconHandler<F>{
|
||||
if(image == null)
|
||||
return;
|
||||
|
||||
F favicon = core.getPlugin().createFavicon(image);
|
||||
F favicon = core.plugin().createFavicon(image);
|
||||
if(favicon == null)
|
||||
return;
|
||||
|
||||
@@ -245,7 +245,7 @@ public class FaviconHandler<F>{
|
||||
logger.debug(FaviconHandler.class, "Creating request for URL '%s'...", url);
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI(url))
|
||||
.header("User-Agent", "AdvancedServerList-" + core.getPlugin().getLoader() + "/" + core.getVersion())
|
||||
.header("User-Agent", "AdvancedServerList-" + core.plugin().loader() + "/" + core.version())
|
||||
.build();
|
||||
|
||||
try(InputStream stream = client.send(request, HttpResponse.BodyHandlers.ofInputStream()).body()){
|
||||
@@ -282,7 +282,7 @@ public class FaviconHandler<F>{
|
||||
BufferedImage image = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = image.createGraphics();
|
||||
|
||||
String resizeMode = core.getFileHandler().getString("resize", "faviconStrategy");
|
||||
String resizeMode = core.fileHandler().getString("resize", "faviconStrategy");
|
||||
switch(resizeMode.toLowerCase(Locale.ROOT)){
|
||||
case "center" -> {
|
||||
int height = original.getHeight();
|
||||
@@ -316,7 +316,7 @@ public class FaviconHandler<F>{
|
||||
|
||||
private F createFavicon(BufferedImage image){
|
||||
try{
|
||||
return core.getPlugin().createFavicon(image);
|
||||
return core.plugin().createFavicon(image);
|
||||
}catch(Exception ex){
|
||||
logger.warn("Encountered an Exception while trying to create a Favicon instance.", ex);
|
||||
return null;
|
||||
|
||||
+8
-8
@@ -61,8 +61,8 @@ public class PlayerHandler{
|
||||
|
||||
public PlayerHandler(AdvancedServerList<?> core){
|
||||
this.core = core;
|
||||
this.logger = core.getPlugin().getPluginLogger();
|
||||
this.cache = core.getPlugin().getFolderPath().resolve("playercache.json");
|
||||
this.logger = core.plugin().pluginLogger();
|
||||
this.cache = core.plugin().folderPath().resolve("playercache.json");
|
||||
}
|
||||
|
||||
public void load(){
|
||||
@@ -71,7 +71,7 @@ public class PlayerHandler{
|
||||
return;
|
||||
}
|
||||
|
||||
if(core.getFileHandler().getBoolean("disableCache")){
|
||||
if(core.fileHandler().getBoolean("disableCache")){
|
||||
logger.info("'disableCache' is set to true. Skipping playercache.json loading...");
|
||||
return;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class PlayerHandler{
|
||||
return;
|
||||
}
|
||||
|
||||
if(core.getFileHandler().getBoolean("disableCache")){
|
||||
if(core.fileHandler().getBoolean("disableCache")){
|
||||
logger.debug(PlayerHandler.class, "[-] 'disable_cache' is set to true. Not saving cached players.");
|
||||
return;
|
||||
}
|
||||
@@ -117,14 +117,14 @@ public class PlayerHandler{
|
||||
}
|
||||
|
||||
public void addPlayer(String ip, String name, UUID uuid){
|
||||
if(contains(ip) || core.getFileHandler().getBoolean("disableCache"))
|
||||
if(contains(ip) || core.fileHandler().getBoolean("disableCache"))
|
||||
return;
|
||||
|
||||
cachedPlayers.add(new CachedPlayer(ip, name, uuid));
|
||||
}
|
||||
|
||||
public CachedPlayer getCachedPlayer(String key){
|
||||
if(!contains(key) || core.getFileHandler().getBoolean("disableCache"))
|
||||
if(!contains(key) || core.fileHandler().getBoolean("disableCache"))
|
||||
return getDefaultPlayer();
|
||||
|
||||
for(CachedPlayer player : cachedPlayers){
|
||||
@@ -164,8 +164,8 @@ public class PlayerHandler{
|
||||
|
||||
return (defaultPlayer = new CachedPlayer(
|
||||
"0.0.0.0",
|
||||
core.getFileHandler().getString("Anonymous", "unknownPlayer", "name"),
|
||||
convertToUUID(core.getFileHandler().getString(defaultUUID.toString(), "unknownPlayer", "uuid"))
|
||||
core.fileHandler().getString("Anonymous", "unknownPlayer", "name"),
|
||||
convertToUUID(core.fileHandler().getString(defaultUUID.toString(), "unknownPlayer", "uuid"))
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public class ProfileManager{
|
||||
}
|
||||
|
||||
public static ServerListProfile resolveProfile(AdvancedServerList<?> core, GenericPlayer player, GenericServer server){
|
||||
for(ServerListProfile profile : core.getFileHandler().getProfiles()){
|
||||
for(ServerListProfile profile : core.fileHandler().profiles()){
|
||||
if(profile.isInvalidProfile())
|
||||
continue;
|
||||
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public class StringReplacer{
|
||||
}
|
||||
|
||||
private static String parsePlaceholder0(String input, ParsePosition position, GenericPlayer player, GenericServer server, ParseWarnCollector collector){
|
||||
AdvancedServerListAPI api = AdvancedServerList.getApi();
|
||||
AdvancedServerListAPI api = AdvancedServerList.api();
|
||||
int index = position.getIndex();
|
||||
|
||||
StringBuilder identifier = new StringBuilder();
|
||||
|
||||
+2
-2
@@ -78,7 +78,7 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.7-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<version>5.4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -26,11 +26,16 @@
|
||||
package ch.andre601.advancedserverlist.paper;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialog;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialogList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.handlers.FaviconHandler;
|
||||
import ch.andre601.advancedserverlist.paper.commands.PaperCommandManagerInterface;
|
||||
import ch.andre601.advancedserverlist.paper.dialogs.PaperDialog;
|
||||
import ch.andre601.advancedserverlist.paper.dialogs.PaperDialogList;
|
||||
import ch.andre601.advancedserverlist.paper.listeners.ServerLoadEventListener;
|
||||
import ch.andre601.advancedserverlist.paper.logging.PaperLogger;
|
||||
import ch.andre601.advancedserverlist.paper.objects.WorldCache;
|
||||
@@ -95,7 +100,7 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
|
||||
if(worldCache != null)
|
||||
worldCache = null;
|
||||
|
||||
getCore().disable();
|
||||
core().disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +111,7 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
|
||||
@Override
|
||||
public void loadMetrics(){
|
||||
new Metrics(this, 15584).addCustomChart(new SimplePie("profiles",
|
||||
() -> String.valueOf(core.getFileHandler().getProfiles().size())
|
||||
() -> String.valueOf(core.fileHandler().profiles().size())
|
||||
));
|
||||
}
|
||||
|
||||
@@ -146,22 +151,22 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedServerList<CachedServerIcon> getCore(){
|
||||
public AdvancedServerList<CachedServerIcon> core(){
|
||||
return core;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFolderPath(){
|
||||
public Path folderPath(){
|
||||
return getDataFolder().toPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginLogger getPluginLogger(){
|
||||
public PluginLogger pluginLogger(){
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaviconHandler<CachedServerIcon> getFaviconHandler(){
|
||||
public FaviconHandler<CachedServerIcon> faviconHandler(){
|
||||
if(faviconHandler == null)
|
||||
faviconHandler = new FaviconHandler<>(core);
|
||||
|
||||
@@ -169,23 +174,23 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager<CmdSender> getCommandManager(){
|
||||
public CommandManager<CmdSender> commandManager(){
|
||||
return commandHandler.commandHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformInfo(){
|
||||
public String platformInfo(){
|
||||
try{
|
||||
Class.forName("io.papermc.paper.ServerBuildInfo");
|
||||
return getNewVersion();
|
||||
return buildInfo();
|
||||
}catch(ClassNotFoundException ignored){
|
||||
// Old Paper versions (Before 16th of May 2024)
|
||||
return getOldVersion();
|
||||
return version();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLoader(){
|
||||
public String loader(){
|
||||
return "paper";
|
||||
}
|
||||
|
||||
@@ -194,19 +199,39 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
|
||||
return Bukkit.getPluginManager().isPluginEnabled(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDialogsSupported(){
|
||||
try{
|
||||
Class.forName("io.papermc.paper.dialog.Dialog");
|
||||
return true;
|
||||
}catch(ClassNotFoundException ignored){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CachedServerIcon createFavicon(BufferedImage image) throws Exception{
|
||||
return Bukkit.loadServerIcon(image);
|
||||
}
|
||||
|
||||
public WorldCache getWorldCache(){
|
||||
@Override
|
||||
public IDialogList.IDialogListBuilder createDialogListBuilder(String title){
|
||||
return PaperDialogList.PaperDialogListBuilder.create(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDialog.IDialogBuilder createDialogBuilder(String title, ServerListProfile profile, int profilesPosition){
|
||||
return PaperDialog.PaperDialogBuilder.create(core(), title, profile, profilesPosition);
|
||||
}
|
||||
|
||||
public WorldCache worldCache(){
|
||||
if(worldCache != null)
|
||||
return worldCache;
|
||||
|
||||
return (worldCache = new WorldCache());
|
||||
}
|
||||
|
||||
public int getPlayersOnline(World world){
|
||||
public int playersOnline(World world){
|
||||
List<? extends Player> players = new ArrayList<>(world == null ? getServer().getOnlinePlayers() : world.getPlayers());
|
||||
|
||||
players.removeIf(player -> {
|
||||
@@ -221,7 +246,7 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
|
||||
return players.size();
|
||||
}
|
||||
|
||||
private String getNewVersion(){
|
||||
private String buildInfo(){
|
||||
ServerBuildInfo info = ServerBuildInfo.buildInfo();
|
||||
|
||||
String name = info.brandName();
|
||||
@@ -235,20 +260,20 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
|
||||
return String.format("%s (ID: %s, Version: %s, Build: %d)", name, id, version, build.getAsInt());
|
||||
}
|
||||
|
||||
private String getOldVersion(){
|
||||
private String version(){
|
||||
return getServer().getName() + " " + getServer().getVersion();
|
||||
}
|
||||
|
||||
private void printOutdatedPaper(){
|
||||
getPluginLogger().warn("================================================================");
|
||||
getPluginLogger().warn("OUTDATED PAPER VERSION DETECTED!");
|
||||
getPluginLogger().warn("");
|
||||
getPluginLogger().warn("AdvancedServerList detected an outdated Paper version.");
|
||||
getPluginLogger().warn("The plugin requires at least 1.20.6 of Paper due to required");
|
||||
getPluginLogger().warn("classes only existing within this version onwards.");
|
||||
getPluginLogger().warn("");
|
||||
getPluginLogger().warn("Please use at least Paper 1.20.6 or downgrade AdvancedServerList");
|
||||
getPluginLogger().warn("to v5.4.1.");
|
||||
getPluginLogger().warn("================================================================");
|
||||
pluginLogger().warn("================================================================");
|
||||
pluginLogger().warn("OUTDATED PAPER VERSION DETECTED!");
|
||||
pluginLogger().warn("");
|
||||
pluginLogger().warn("AdvancedServerList detected an outdated Paper version.");
|
||||
pluginLogger().warn("The plugin requires at least 1.20.6 of Paper due to required");
|
||||
pluginLogger().warn("classes only existing within this version onwards.");
|
||||
pluginLogger().warn("");
|
||||
pluginLogger().warn("Please use at least Paper 1.20.6 or downgrade AdvancedServerList");
|
||||
pluginLogger().warn("to v5.4.1.");
|
||||
pluginLogger().warn("================================================================");
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -32,7 +32,6 @@ import net.kyori.adventure.audience.Audience;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class PaperCmdSender implements CmdSender{
|
||||
|
||||
private final CommandSender sender;
|
||||
@@ -70,7 +69,7 @@ public class PaperCmdSender implements CmdSender{
|
||||
return sender;
|
||||
}
|
||||
|
||||
public CommandSourceStack getCommandSourceStack(){
|
||||
public CommandSourceStack commandSourceStack(){
|
||||
return commandSourceStack;
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -33,7 +33,6 @@ import org.incendo.cloud.SenderMapper;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.paper.PaperCommandManager;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class PaperCommandManagerInterface implements CommandManagerInterface<CommandSourceStack>{
|
||||
|
||||
private final PaperCore plugin;
|
||||
@@ -45,7 +44,7 @@ public class PaperCommandManagerInterface implements CommandManagerInterface<Com
|
||||
@Override
|
||||
public CommandManager<CmdSender> commandHandler(){
|
||||
return PaperCommandManager.builder(senderMapper())
|
||||
.executionCoordinator(ExecutionCoordinator.asyncCoordinator())
|
||||
.executionCoordinator(ExecutionCoordinator.simpleCoordinator())
|
||||
.buildOnEnable(plugin);
|
||||
}
|
||||
|
||||
@@ -53,7 +52,7 @@ public class PaperCommandManagerInterface implements CommandManagerInterface<Com
|
||||
public SenderMapper<CommandSourceStack, CmdSender> senderMapper(){
|
||||
return SenderMapper.create(
|
||||
PaperCmdSender::new,
|
||||
sender -> ((PaperCmdSender)sender).getCommandSourceStack()
|
||||
sender -> ((PaperCmdSender)sender).commandSourceStack()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package ch.andre601.advancedserverlist.paper.dialogs;
|
||||
|
||||
import ch.andre601.advancedserverlist.api.objects.NullBool;
|
||||
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialog;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import io.papermc.paper.dialog.Dialog;
|
||||
import io.papermc.paper.dialog.DialogResponseView;
|
||||
import io.papermc.paper.registry.data.dialog.ActionButton;
|
||||
import io.papermc.paper.registry.data.dialog.DialogBase;
|
||||
import io.papermc.paper.registry.data.dialog.action.DialogAction;
|
||||
import io.papermc.paper.registry.data.dialog.body.DialogBody;
|
||||
import io.papermc.paper.registry.data.dialog.input.DialogInput;
|
||||
import io.papermc.paper.registry.data.dialog.input.TextDialogInput;
|
||||
import io.papermc.paper.registry.data.dialog.type.DialogType;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickCallback;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class PaperDialog implements IDialog<Dialog>{
|
||||
|
||||
private final AdvancedServerList<?> core;
|
||||
private final String title;
|
||||
private final ServerListProfile profile;
|
||||
private final int profilesPosition;
|
||||
private final List<DialogBody> bodies;
|
||||
private final List<DialogInput> inputs;
|
||||
|
||||
private PaperDialog(AdvancedServerList<?> core, String title, ServerListProfile profile, int profilesPosition, List<DialogBody> bodies, List<DialogInput> inputs){
|
||||
this.core = core;
|
||||
this.title = title;
|
||||
this.profile = profile;
|
||||
this.profilesPosition = profilesPosition;
|
||||
this.bodies = bodies;
|
||||
this.inputs = inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog createDialog(){
|
||||
return Dialog.create(
|
||||
factory -> factory.empty().base(
|
||||
DialogBase.builder(ComponentParser.text(title).toComponent())
|
||||
.body(bodies)
|
||||
.inputs(inputs)
|
||||
.afterAction(DialogBase.DialogAfterAction.NONE)
|
||||
.pause(false)
|
||||
.build()
|
||||
).type(DialogType.confirmation(
|
||||
ActionButton.builder(ComponentParser.text("<green>Save changes").toComponent())
|
||||
.tooltip(ComponentParser.text("""
|
||||
<grey>Saves your changes made in this Dialog.
|
||||
<grey>Applying changes requires the use of <aqua>/asl reload""").toComponent())
|
||||
.action(
|
||||
DialogAction.customClick(
|
||||
(view, audience) -> handle(audience, view, profile, profilesPosition),
|
||||
ClickCallback.Options.builder().build()
|
||||
)
|
||||
)
|
||||
.build(),
|
||||
ActionButton.builder(ComponentParser.text("Back...").toComponent())
|
||||
.tooltip(ComponentParser.text("""
|
||||
<grey>Returns you to the main Dialog Screen.
|
||||
<grey>Any unsaved changes will be <red>lost</red>!
|
||||
|
||||
<grey>Click the <green>Save changes</green> button to save your changes.""").toComponent())
|
||||
.action(DialogAction.staticAction(ClickEvent.runCommand("/asl profiles edit " + profile.file())))
|
||||
.build()
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
private void handle(Audience audience, DialogResponseView view, ServerListProfile slp, int profilesPosition){
|
||||
Float priority = view.getFloat("priority");
|
||||
String condition = view.getText("condition");
|
||||
|
||||
String motd = view.getText("motd");
|
||||
String favicon = view.getText("favicon");
|
||||
|
||||
NullBool hidePlayers = NullBool.resolve(view.getBoolean("hidePlayers"));
|
||||
NullBool hidePlayersHover = NullBool.resolve(view.getBoolean("hidePlayersHover"));
|
||||
|
||||
String hover = view.getText("hover");
|
||||
String playerCountText = view.getText("text");
|
||||
|
||||
NullBool extraPlayersEnabled = NullBool.resolve(view.getBoolean("extraPlayersEnabled"));
|
||||
String extraPlayersCount = view.getText("extraPlayersCount");
|
||||
|
||||
NullBool maxPlayersEnabled = NullBool.resolve(view.getBoolean("maxPlayersEnabled"));
|
||||
String maxPlayersCount = view.getText("maxPlayersCount");
|
||||
|
||||
NullBool onlinePlayersEnabled = NullBool.resolve(view.getBoolean("onlinePlayersEnabled"));
|
||||
String onlinePlayersCount = view.getText("onlinePlayersCount");
|
||||
|
||||
ProfileEntry.Builder builder = ProfileEntry.empty().builder();
|
||||
if(motd != null && !motd.isEmpty())
|
||||
builder.motd(List.of(motd.split("\n")));
|
||||
|
||||
if(favicon != null && !favicon.isEmpty())
|
||||
builder.favicon(favicon);
|
||||
|
||||
builder.hidePlayersEnabled(hidePlayers);
|
||||
builder.hidePlayersHoverEnabled(hidePlayersHover);
|
||||
|
||||
if(hover != null && !hover.isEmpty())
|
||||
builder.players(List.of(hover.split("\n")));
|
||||
|
||||
if(playerCountText != null && !playerCountText.isEmpty())
|
||||
builder.playerCountText(playerCountText);
|
||||
|
||||
builder.extraPlayersEnabled(extraPlayersEnabled);
|
||||
if(extraPlayersCount != null && !extraPlayersCount.isEmpty())
|
||||
builder.extraPlayersCount(extraPlayersCount);
|
||||
|
||||
builder.maxPlayersEnabled(maxPlayersEnabled);
|
||||
if(maxPlayersCount != null && !maxPlayersCount.isEmpty())
|
||||
builder.maxPlayersCount(maxPlayersCount);
|
||||
|
||||
builder.onlinePlayersEnabled(onlinePlayersEnabled);
|
||||
if(onlinePlayersCount != null && !onlinePlayersCount.isEmpty())
|
||||
builder.onlinePlayersCount(onlinePlayersCount);
|
||||
|
||||
ProfileEntry entry = slp.defaultProfile();
|
||||
List<ProfileEntry> entries = slp.profiles();
|
||||
|
||||
if(profilesPosition >= 0){
|
||||
if(profilesPosition >= entries.size()){
|
||||
entries.add(builder.build());
|
||||
}else{
|
||||
entries.set(profilesPosition, builder.build());
|
||||
}
|
||||
}else{
|
||||
entry = builder.build();
|
||||
}
|
||||
|
||||
float newPriority = priority == null ? slp.priority() : priority;
|
||||
|
||||
if(core.fileHandler().saveProfile(slp.file(), (int)newPriority, condition, entries, entry)){
|
||||
audience.sendMessage(ComponentParser.textFormatted(
|
||||
"<grey>[<aqua>ASL</aqua>] <green>Successfully saved changes for <white>%s</white>!",
|
||||
slp.file()
|
||||
).toComponent());
|
||||
}else{
|
||||
audience.sendMessage(ComponentParser.textFormatted(
|
||||
"<grey>[<red>ASL</red>] <red>Error while saving changes for <white>%s</white>! See console for details.",
|
||||
slp.file()
|
||||
).toComponent());
|
||||
}
|
||||
}
|
||||
|
||||
public static class PaperDialogBuilder implements IDialogBuilder{
|
||||
|
||||
public static PaperDialogBuilder create(AdvancedServerList<?> core, String title, ServerListProfile profile, int profilesPosition){
|
||||
return new PaperDialogBuilder(core, title, profile, profilesPosition);
|
||||
}
|
||||
|
||||
private final AdvancedServerList<?> core;
|
||||
private final String title;
|
||||
private final ServerListProfile profile;
|
||||
private final int profilesPosition;
|
||||
private final List<DialogBody> bodies = new ArrayList<>();
|
||||
private final List<DialogInput> inputs = new ArrayList<>();
|
||||
|
||||
private PaperDialogBuilder(AdvancedServerList<?> core, String title, ServerListProfile profile, int profilesPosition){
|
||||
this.core = core;
|
||||
this.title = title;
|
||||
this.profile = profile;
|
||||
this.profilesPosition = profilesPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogBuilder appendBody(String body){
|
||||
this.bodies.add(DialogBody.plainMessage(ComponentParser.text(body).toComponent()));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogBuilder appendTextInput(String key, String title, String initValue, int maxLength){
|
||||
this.inputs.add(DialogInput.text(key, Component.text(title))
|
||||
.initial(initValue == null ? "" : initValue)
|
||||
.maxLength(maxLength)
|
||||
.build()
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogBuilder appendTextbox(String key, String title, List<String> initValue, int maxLength, int rows){
|
||||
this.inputs.add(DialogInput.text(key, Component.text(title))
|
||||
.initial(initValue == null ? "" : String.join("\n", initValue))
|
||||
.maxLength(maxLength)
|
||||
.multiline(TextDialogInput.MultilineOptions.create(rows, null))
|
||||
.build()
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogBuilder appendNumberRange(String key, String title, int initValue){
|
||||
float minValue = Math.min((float)initValue, -100.0F);
|
||||
float maxValue = Math.max((float)initValue, 100.0F);
|
||||
|
||||
this.inputs.add(DialogInput.numberRange(key, Component.text(title), minValue, maxValue)
|
||||
.step(1.0F)
|
||||
.initial((float)initValue)
|
||||
.build()
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogBuilder appendBoolean(String key, String title, NullBool initValue){
|
||||
this.inputs.add(DialogInput.bool(key, Component.text(title))
|
||||
.initial(initValue.getOrDefault(false))
|
||||
.build()
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialog build(){
|
||||
return new PaperDialog(core, title, profile, profilesPosition, bodies, inputs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package ch.andre601.advancedserverlist.paper.dialogs;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialog;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialogList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import io.papermc.paper.dialog.Dialog;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.data.dialog.DialogBase;
|
||||
import io.papermc.paper.registry.data.dialog.body.DialogBody;
|
||||
import io.papermc.paper.registry.data.dialog.type.DialogType;
|
||||
import io.papermc.paper.registry.set.RegistrySet;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PaperDialogList implements IDialogList{
|
||||
|
||||
private final String title;
|
||||
private final List<String> bodies;
|
||||
private final List<IDialog<?>> dialogs;
|
||||
|
||||
protected PaperDialogList(String title, List<String> bodies, List<IDialog<?>> dialogs){
|
||||
this.title = title;
|
||||
this.bodies = bodies;
|
||||
this.dialogs = dialogs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public void show(CmdSender sender){
|
||||
List<DialogBody> dialogBodies = bodies.stream()
|
||||
.<DialogBody>map(text -> DialogBody.plainMessage(ComponentParser.text(text).toComponent()))
|
||||
.toList();
|
||||
List<Dialog> paperDialogs = dialogs.stream()
|
||||
.filter(dialog -> dialog instanceof PaperDialog)
|
||||
.map(dialog -> (PaperDialog)dialog)
|
||||
.map(PaperDialog::createDialog)
|
||||
.toList();
|
||||
|
||||
DialogBase.Builder builder = DialogBase.builder(Component.text(title))
|
||||
.body(dialogBodies);
|
||||
|
||||
RegistrySet<Dialog> dialogRegistry = RegistrySet.valueSet(RegistryKey.DIALOG, paperDialogs);
|
||||
|
||||
Dialog dialog = Dialog.create(
|
||||
factory -> factory.empty().base(builder.build())
|
||||
.type(DialogType.dialogList(dialogRegistry).columns(3).build())
|
||||
);
|
||||
|
||||
sender.audience().showDialog(dialog);
|
||||
}
|
||||
|
||||
public static class PaperDialogListBuilder implements IDialogListBuilder{
|
||||
|
||||
public static PaperDialogListBuilder create(String title){
|
||||
return new PaperDialogListBuilder(title);
|
||||
}
|
||||
|
||||
private final String title;
|
||||
private final List<String> bodies = new ArrayList<>();
|
||||
private final List<IDialog<?>> dialogs = new ArrayList<>();
|
||||
|
||||
private PaperDialogListBuilder(String title){
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogListBuilder appendBody(String body){
|
||||
this.bodies.add(body);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogListBuilder appendDialog(IDialog<?> dialog){
|
||||
this.dialogs.add(dialog);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperDialogList build(){
|
||||
return new PaperDialogList(this.title, this.bodies, this.dialogs);
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-17
@@ -70,17 +70,17 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxPlayers(int maxPlayers){
|
||||
public void maxPlayers(int maxPlayers){
|
||||
event.setMaxPlayers(maxPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnlinePlayers(int onlinePlayers){
|
||||
public void onlinePlayers(int onlinePlayers){
|
||||
event.setNumPlayers(onlinePlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMotd(Component component){
|
||||
public void motd(Component component){
|
||||
event.motd(component);
|
||||
}
|
||||
|
||||
@@ -90,13 +90,13 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerCount(String name){
|
||||
public void playerCount(String name){
|
||||
event.setVersion(name);
|
||||
event.setProtocolVersion(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayers(List<String> lines, PaperPlayerImpl player, GenericServer server){
|
||||
public void players(List<String> lines, PaperPlayerImpl player, GenericServer server){
|
||||
try{
|
||||
Class.forName("com.destroystokyo.paper.event.server.PaperServerListPingEvent$ListedPlayerInfo");
|
||||
setListedPlayers(lines, player, server);
|
||||
@@ -107,7 +107,7 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayersHidden(){
|
||||
public void playersHidden(){
|
||||
try{
|
||||
Class.forName("com.destroystokyo.paper.event.server.PaperServerListPingEvent$ListedPlayerInfo");
|
||||
clearListedPlayers();
|
||||
@@ -117,12 +117,12 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFavicon(CachedServerIcon favicon){
|
||||
public void favicon(CachedServerIcon favicon){
|
||||
event.setServerIcon(favicon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultFavicon(){
|
||||
public void defaultFavicon(){
|
||||
event.setServerIcon(event.getServerIcon());
|
||||
}
|
||||
|
||||
@@ -145,22 +145,22 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion(){
|
||||
public int protocolVersion(){
|
||||
return event.getClient().getProtocolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOnlinePlayers(){
|
||||
return plugin.getPlayersOnline(null);
|
||||
public int onlinePlayers(){
|
||||
return plugin.playersOnline(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers(){
|
||||
public int maxPlayers(){
|
||||
return event.getMaxPlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerIP(){
|
||||
public String playerIP(){
|
||||
return event.getClient().getAddress().getHostString();
|
||||
}
|
||||
|
||||
@@ -173,12 +173,12 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVirtualHost(){
|
||||
public String virtualHost(){
|
||||
return this.resolveHost(event.getClient().getVirtualHost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginCore<CachedServerIcon> getPlugin(){
|
||||
public PluginCore<CachedServerIcon> plugin(){
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -190,8 +190,8 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericServer createGenericServer(int playersOnline, int playersMax, String host){
|
||||
return new PaperServerImpl(plugin.getWorldCache().worlds(), playersOnline, playersMax, host);
|
||||
public GenericServer createServer(int playersOnline, int playersMax, String host){
|
||||
return new PaperServerImpl(plugin.worldCache().worlds(), playersOnline, playersMax, host);
|
||||
}
|
||||
|
||||
private void clearListedPlayers(){
|
||||
|
||||
+3
-3
@@ -51,15 +51,15 @@ public class PlayerJoinEventListener implements Listener{
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
plugin.getCore().getPlayerHandler().addPlayer(address.getHostString(), player.getName(), player.getUniqueId());
|
||||
plugin.core().playerHandler().addPlayer(address.getHostString(), player.getName(), player.getUniqueId());
|
||||
|
||||
if(player.hasPermission("advancedserverlist.admin") || player.hasPermission("advancedserverlist.updatecheck")){
|
||||
if(plugin.getCore().getUpdateChecker() == null)
|
||||
if(plugin.core().updateChecker() == null)
|
||||
return;
|
||||
|
||||
PaperCmdSender sender = new PaperCmdSender(player);
|
||||
|
||||
plugin.getCore().getUpdateChecker().performCachedUpdateCheck(sender);
|
||||
plugin.core().updateChecker().performCachedUpdateCheck(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -29,7 +29,6 @@ import ch.andre601.advancedserverlist.api.bukkit.events.PreServerListSetEvent;
|
||||
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
|
||||
|
||||
public class PreServerListSetEventImpl extends PreServerListSetEvent{
|
||||
|
||||
public PreServerListSetEventImpl(ProfileEntry entry){
|
||||
super(entry);
|
||||
}
|
||||
|
||||
+11
-11
@@ -47,21 +47,21 @@ public class ServerLoadEventListener implements Listener{
|
||||
new WorldEventsListener(plugin);
|
||||
|
||||
// Load currently loaded worlds into the WorldCache
|
||||
Bukkit.getWorlds().forEach(world -> plugin.getWorldCache().addWorld(world));
|
||||
Bukkit.getWorlds().forEach(world -> plugin.worldCache().addWorld(world));
|
||||
|
||||
// Print a warning if server load was after a reload.
|
||||
if(event.getType() != ServerLoadEvent.LoadType.RELOAD)
|
||||
return;
|
||||
|
||||
plugin.getPluginLogger().warn("======================================================================================");
|
||||
plugin.getPluginLogger().warn("SERVER RELOAD DETECTED!");
|
||||
plugin.getPluginLogger().warn("");
|
||||
plugin.getPluginLogger().warn("A server reload has been detected by AdvancedServerList, meaning either the /reload");
|
||||
plugin.getPluginLogger().warn("command or Bukkit.reload() was executed.");
|
||||
plugin.getPluginLogger().warn("");
|
||||
plugin.getPluginLogger().warn("YOU WILL GET NO SUPPORT FOR THE PLUGIN FOR ANY ISSUES YOU ENCOUNTER AFTER A SERVER");
|
||||
plugin.getPluginLogger().warn("RELOAD!");
|
||||
plugin.getPluginLogger().warn("ALWAYS RESTART YOUR SERVER. NEVER RELOAD IT!");
|
||||
plugin.getPluginLogger().warn("======================================================================================");
|
||||
plugin.pluginLogger().warn("======================================================================================");
|
||||
plugin.pluginLogger().warn("SERVER RELOAD DETECTED!");
|
||||
plugin.pluginLogger().warn("");
|
||||
plugin.pluginLogger().warn("A server reload has been detected by AdvancedServerList, meaning either the /reload");
|
||||
plugin.pluginLogger().warn("command or Bukkit.reload() was executed.");
|
||||
plugin.pluginLogger().warn("");
|
||||
plugin.pluginLogger().warn("YOU WILL GET NO SUPPORT FOR THE PLUGIN FOR ANY ISSUES YOU ENCOUNTER AFTER A SERVER");
|
||||
plugin.pluginLogger().warn("RELOAD!");
|
||||
plugin.pluginLogger().warn("ALWAYS RESTART YOUR SERVER. NEVER RELOAD IT!");
|
||||
plugin.pluginLogger().warn("======================================================================================");
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -41,11 +41,11 @@ public class WorldEventsListener implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event){
|
||||
plugin.getWorldCache().addWorld(event.getWorld());
|
||||
plugin.worldCache().addWorld(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent event){
|
||||
plugin.getWorldCache().removeWorld(event.getWorld().getName());
|
||||
plugin.worldCache().removeWorld(event.getWorld().getName());
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -28,14 +28,17 @@ package ch.andre601.advancedserverlist.paper.objects.impl;
|
||||
import ch.andre601.advancedserverlist.api.bukkit.objects.BukkitPlayer;
|
||||
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record PaperPlayerImpl(OfflinePlayer player, CachedPlayer cachedPlayer, int protocol) implements BukkitPlayer{
|
||||
@NullMarked
|
||||
public record PaperPlayerImpl(@Nullable OfflinePlayer player, CachedPlayer cachedPlayer, int protocol) implements BukkitPlayer{
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return player == null ? cachedPlayer.name() : player.getName();
|
||||
return player == null || player.getName() == null ? cachedPlayer.name() : player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +52,7 @@ public record PaperPlayerImpl(OfflinePlayer player, CachedPlayer cachedPlayer, i
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getPlayer(){
|
||||
public @Nullable OfflinePlayer getPlayer(){
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -27,12 +27,13 @@ package ch.andre601.advancedserverlist.paper.objects.impl;
|
||||
|
||||
import ch.andre601.advancedserverlist.api.bukkit.objects.BukkitServer;
|
||||
import org.bukkit.World;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record PaperServerImpl(Map<String, World> worlds, int playersOnline, int playersMax, String host) implements BukkitServer {
|
||||
@Override
|
||||
public Map<String, World> getWorlds(){
|
||||
public @NonNull Map<String, World> getWorlds(){
|
||||
return worlds;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -69,7 +69,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion(){
|
||||
return plugin.getCore().getVersion();
|
||||
return plugin.core().version();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,16 +80,16 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player pl, @NotNull String identifier){
|
||||
String host = pl.getVirtualHost() == null ? null : pl.getVirtualHost().getHostString();
|
||||
CachedPlayer cached = plugin.getCore().getPlayerHandler().getCachedPlayer(pl.getUniqueId());
|
||||
CachedPlayer cached = plugin.core().playerHandler().getCachedPlayer(pl.getUniqueId());
|
||||
|
||||
int protocol = resolveProtocol(pl);
|
||||
int online = Bukkit.getOnlinePlayers().size();
|
||||
int max = Bukkit.getMaxPlayers();
|
||||
|
||||
BukkitServer server = new PaperServerImpl(plugin.getWorldCache().worlds(), online, max, host);
|
||||
BukkitServer server = new PaperServerImpl(plugin.worldCache().worlds(), online, max, host);
|
||||
BukkitPlayer player = new PaperPlayerImpl(pl, cached, protocol);
|
||||
|
||||
ServerListProfile profile = ProfileManager.resolveProfile(plugin.getCore(), player, server);
|
||||
ServerListProfile profile = ProfileManager.resolveProfile(plugin.core(), player, server);
|
||||
if(profile == null)
|
||||
return null;
|
||||
|
||||
@@ -113,7 +113,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
|
||||
max = online + (extraPlayers == null ? 0 : extraPlayers);
|
||||
}
|
||||
|
||||
BukkitServer finalServer = new PaperServerImpl(plugin.getWorldCache().worlds(), online, max, host);
|
||||
BukkitServer finalServer = new PaperServerImpl(plugin.worldCache().worlds(), online, max, host);
|
||||
return switch(identifier.toLowerCase(Locale.ROOT)){
|
||||
case "favicon" -> getOption(entry.favicon(), pl, player, finalServer);
|
||||
case "motd" -> getOption(entry.motd(), pl, player, finalServer, true);
|
||||
@@ -155,7 +155,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
|
||||
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
|
||||
.modifyText(text -> {
|
||||
if(isMotd)
|
||||
return plugin.getCore().getTextCenterUtil().getCenteredText(text);
|
||||
return plugin.core().textCenterUtil().getCenteredText(text);
|
||||
|
||||
return text;
|
||||
})
|
||||
|
||||
+4
-1
@@ -29,7 +29,10 @@ import ch.andre601.advancedserverlist.api.PlaceholderProvider;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericServer;
|
||||
import ch.andre601.advancedserverlist.paper.objects.impl.PaperPlayerImpl;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class PaperPlayerPlaceholders extends PlaceholderProvider{
|
||||
|
||||
public PaperPlayerPlaceholders(){
|
||||
@@ -37,7 +40,7 @@ public class PaperPlayerPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
if(!(player instanceof PaperPlayerImpl paperPlayer))
|
||||
return null;
|
||||
|
||||
|
||||
+5
-2
@@ -32,7 +32,10 @@ import ch.andre601.advancedserverlist.paper.PaperCore;
|
||||
import ch.andre601.advancedserverlist.paper.objects.impl.PaperServerImpl;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class PaperServerPlaceholders extends PlaceholderProvider{
|
||||
|
||||
private final PaperCore plugin;
|
||||
@@ -43,7 +46,7 @@ public class PaperServerPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
if(!(server instanceof PaperServerImpl paperServer))
|
||||
return null;
|
||||
|
||||
@@ -63,7 +66,7 @@ public class PaperServerPlaceholders extends PlaceholderProvider{
|
||||
if(world == null)
|
||||
continue;
|
||||
|
||||
players += plugin.getPlayersOnline(world);
|
||||
players += plugin.playersOnline(world);
|
||||
}
|
||||
|
||||
yield String.valueOf(players);
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<project.build.build_id/>
|
||||
|
||||
<plugin.version>5.6.0</plugin.version>
|
||||
<plugin.version>5.7.0-b2</plugin.version>
|
||||
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
|
||||
|
||||
<api.version>4.1.1</api.version>
|
||||
@@ -58,7 +58,7 @@
|
||||
<dependency.cloud-bungee>2.0.0-SNAPSHOT</dependency.cloud-bungee>
|
||||
<dependency.cloud-paper>2.0.0-SNAPSHOT</dependency.cloud-paper>
|
||||
<dependency.cloud-velocity>2.0.0-SNAPSHOT</dependency.cloud-velocity>
|
||||
<dependency.cloud-minecraft-extras>2.0.0-beta.10</dependency.cloud-minecraft-extras>
|
||||
<dependency.cloud-minecraft-extras>2.0.0-beta.11</dependency.cloud-minecraft-extras>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
mkdocs-material==9.6.14
|
||||
mkdocs-material==9.6.15
|
||||
mkdocs-glightbox==0.4.0
|
||||
mkdocs-redirects==1.2.2
|
||||
git+https://github.com/Andre601/mkdocs-pagenav-generator
|
||||
|
||||
@@ -26,9 +26,12 @@
|
||||
package ch.andre601.advancedserverlist.velocity;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialog;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.dialogs.IDialogList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
|
||||
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
|
||||
import ch.andre601.advancedserverlist.core.profiles.handlers.FaviconHandler;
|
||||
import ch.andre601.advancedserverlist.velocity.commands.VelocityCommandManagerInterface;
|
||||
import ch.andre601.advancedserverlist.velocity.listeners.PlayerJoinEventListener;
|
||||
@@ -120,7 +123,7 @@ public class VelocityCore implements PluginCore<Favicon>{
|
||||
@Override
|
||||
public void loadMetrics(){
|
||||
metrics.make(this, 15587).addCustomChart(new SimplePie("profiles",
|
||||
() -> String.valueOf(core.getFileHandler().getProfiles().size())
|
||||
() -> String.valueOf(core.fileHandler().profiles().size())
|
||||
));
|
||||
}
|
||||
|
||||
@@ -140,7 +143,7 @@ public class VelocityCore implements PluginCore<Favicon>{
|
||||
@Override
|
||||
public void downloadLibrary(String groupId, String artifactId, String version){
|
||||
if(libraryManager == null){
|
||||
libraryManager = new VelocityLibraryManager<>(this, this.logger, getFolderPath(), getProxy().getPluginManager());
|
||||
libraryManager = new VelocityLibraryManager<>(this, this.logger, folderPath(), proxy().getPluginManager());
|
||||
libraryManager.addRepository("https://repo.papermc.io/repository/maven-public");
|
||||
}
|
||||
|
||||
@@ -156,28 +159,28 @@ public class VelocityCore implements PluginCore<Favicon>{
|
||||
|
||||
@Override
|
||||
public void startScheduler(){
|
||||
scheduledTask = getProxy().getScheduler().buildTask(this, this::fetchServers)
|
||||
scheduledTask = proxy().getScheduler().buildTask(this, this::fetchServers)
|
||||
.repeat(10, TimeUnit.SECONDS)
|
||||
.schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancedServerList<Favicon> getCore(){
|
||||
public AdvancedServerList<Favicon> core(){
|
||||
return core;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFolderPath(){
|
||||
public Path folderPath(){
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginLogger getPluginLogger(){
|
||||
public PluginLogger pluginLogger(){
|
||||
return pluginLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaviconHandler<Favicon> getFaviconHandler(){
|
||||
public FaviconHandler<Favicon> faviconHandler(){
|
||||
if(faviconHandler == null)
|
||||
faviconHandler = new FaviconHandler<>(core);
|
||||
|
||||
@@ -185,26 +188,31 @@ public class VelocityCore implements PluginCore<Favicon>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager<CmdSender> getCommandManager(){
|
||||
public CommandManager<CmdSender> commandManager(){
|
||||
return commandHandler.commandHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformInfo(){
|
||||
return getProxy().getVersion().getName() + " " + getProxy().getVersion().getVersion();
|
||||
public String platformInfo(){
|
||||
return proxy().getVersion().getName() + " " + proxy().getVersion().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLoader(){
|
||||
public String loader(){
|
||||
return "velocity";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(String plugin){
|
||||
if(getProxy() == null)
|
||||
if(proxy() == null)
|
||||
return false;
|
||||
|
||||
return getProxy().getPluginManager().isLoaded(plugin.toLowerCase(Locale.ROOT));
|
||||
return proxy().getPluginManager().isLoaded(plugin.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDialogsSupported(){
|
||||
return false; // Velocity lacks a Dialog System
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,21 +220,31 @@ public class VelocityCore implements PluginCore<Favicon>{
|
||||
return Favicon.create(image);
|
||||
}
|
||||
|
||||
public ProxyServer getProxy(){
|
||||
@Override
|
||||
public IDialogList.IDialogListBuilder createDialogListBuilder(String title){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDialog.IDialogBuilder createDialogBuilder(String title, ServerListProfile profile, int profilesPosition){
|
||||
return null;
|
||||
}
|
||||
|
||||
public ProxyServer proxy(){
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public int getOnlinePlayers(RegisteredServer server){
|
||||
if(getProxy() == null)
|
||||
public int onlinePlayers(RegisteredServer server){
|
||||
if(proxy() == null)
|
||||
return -1;
|
||||
|
||||
List<Player> players = new ArrayList<>(server == null ? getProxy().getAllPlayers() : server.getPlayersConnected());
|
||||
List<Player> players = new ArrayList<>(server == null ? proxy().getAllPlayers() : server.getPlayersConnected());
|
||||
|
||||
// Exclude players when PremiumVanish is enabled and player is hidden.
|
||||
if(getProxy().getPluginManager().isLoaded("premiumvanish")){
|
||||
if(proxy().getPluginManager().isLoaded("premiumvanish")){
|
||||
players.removeIf(VelocityVanishAPI::isInvisible);
|
||||
}else // Do the same if SayanVanish is enabled.
|
||||
if(getProxy().getPluginManager().isLoaded("sayanvanish")){
|
||||
if(proxy().getPluginManager().isLoaded("sayanvanish")){
|
||||
players.removeIf(player -> SayanVanishVelocityAPI.getInstance().isVanished(player.getUniqueId()));
|
||||
}
|
||||
|
||||
@@ -239,7 +257,7 @@ public class VelocityCore implements PluginCore<Favicon>{
|
||||
|
||||
private void fetchServers(){
|
||||
fetchedServers.clear();
|
||||
getProxy().getAllServers().forEach(server -> server.ping().whenComplete((ping, throwable) -> {
|
||||
proxy().getAllServers().forEach(server -> server.ping().whenComplete((ping, throwable) -> {
|
||||
if(throwable != null)
|
||||
return;
|
||||
|
||||
|
||||
+4
-4
@@ -39,7 +39,7 @@ public class PlayerJoinEventListener{
|
||||
|
||||
public PlayerJoinEventListener(VelocityCore plugin){
|
||||
this.plugin = plugin;
|
||||
plugin.getProxy().getEventManager().register(plugin, this);
|
||||
plugin.proxy().getEventManager().register(plugin, this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -47,15 +47,15 @@ public class PlayerJoinEventListener{
|
||||
InetSocketAddress address = event.getPlayer().getRemoteAddress();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
plugin.getCore().getPlayerHandler().addPlayer(address.getHostString(), player.getUsername(), player.getUniqueId());
|
||||
plugin.core().playerHandler().addPlayer(address.getHostString(), player.getUsername(), player.getUniqueId());
|
||||
|
||||
if(player.hasPermission("advancedserverlist.admin") || player.hasPermission("advancedserverlist.updatecheck")){
|
||||
if(plugin.getCore().getUpdateChecker() == null)
|
||||
if(plugin.core().updateChecker() == null)
|
||||
return;
|
||||
|
||||
VelocityCmdSender sender = new VelocityCmdSender(player);
|
||||
|
||||
plugin.getCore().getUpdateChecker().performCachedUpdateCheck(sender);
|
||||
plugin.core().updateChecker().performCachedUpdateCheck(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -38,13 +38,13 @@ public class ProxyPingEventListener{
|
||||
|
||||
public ProxyPingEventListener(VelocityCore plugin){
|
||||
this.plugin = plugin;
|
||||
plugin.getProxy().getEventManager().register(plugin, this);
|
||||
plugin.proxy().getEventManager().register(plugin, this);
|
||||
}
|
||||
|
||||
@Subscribe(priority = Short.MIN_VALUE + 1) // Equivalent to PostOrder.LAST which maintenance uses.
|
||||
public void onProxyPing(ProxyPingEvent event){
|
||||
ProfileEntry entry = PingEventHandler.handleEvent(new VelocityEventWrapper(plugin, event));
|
||||
|
||||
plugin.getProxy().getEventManager().fire(new PostServerListSetEvent(entry));
|
||||
plugin.proxy().getEventManager().fire(new PostServerListSetEvent(entry));
|
||||
}
|
||||
}
|
||||
+21
-21
@@ -69,7 +69,7 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
public GenericServerListEvent callEvent(ProfileEntry entry){
|
||||
PreServerListSetEventImpl event = new PreServerListSetEventImpl(entry);
|
||||
try{
|
||||
plugin.getProxy().getEventManager().fire(event).get();
|
||||
plugin.proxy().getEventManager().fire(event).get();
|
||||
}catch(InterruptedException | ExecutionException ignored){
|
||||
return null;
|
||||
}
|
||||
@@ -78,17 +78,17 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxPlayers(int maxPlayers){
|
||||
public void maxPlayers(int maxPlayers){
|
||||
builder.maximumPlayers(maxPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnlinePlayers(int onlinePlayers){
|
||||
public void onlinePlayers(int onlinePlayers){
|
||||
builder.onlinePlayers(onlinePlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMotd(Component component){
|
||||
public void motd(Component component){
|
||||
builder.description(component);
|
||||
}
|
||||
|
||||
@@ -98,12 +98,12 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerCount(String name){
|
||||
public void playerCount(String name){
|
||||
builder.version(new ServerPing.Version(-1, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayers(List<String> lines, VelocityPlayerImpl player, GenericServer server){
|
||||
public void players(List<String> lines, VelocityPlayerImpl player, GenericServer server){
|
||||
ServerPing.SamplePlayer[] players = new ServerPing.SamplePlayer[lines.size()];
|
||||
|
||||
for(int i = 0; i < players.length; i++){
|
||||
@@ -120,18 +120,18 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayersHidden(){
|
||||
public void playersHidden(){
|
||||
builder.clearSamplePlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFavicon(Favicon favicon){
|
||||
public void favicon(Favicon favicon){
|
||||
builder.favicon(favicon);
|
||||
}
|
||||
|
||||
// Not used in Velocity
|
||||
@Override
|
||||
public void setDefaultFavicon(){}
|
||||
public void defaultFavicon(){}
|
||||
|
||||
@Override
|
||||
public void updateEvent(){
|
||||
@@ -145,20 +145,20 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
|
||||
@Override
|
||||
public boolean isMaintenanceModeActive(){
|
||||
if(!plugin.getProxy().getPluginManager().isLoaded("maintenance"))
|
||||
if(!plugin.proxy().getPluginManager().isLoaded("maintenance"))
|
||||
return false;
|
||||
|
||||
return MaintenanceUtil.get().isMaintenanceEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion(){
|
||||
public int protocolVersion(){
|
||||
return event.getConnection().getProtocolVersion().getProtocol();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOnlinePlayers(){
|
||||
int players = plugin.getOnlinePlayers(null);
|
||||
public int onlinePlayers(){
|
||||
int players = plugin.onlinePlayers(null);
|
||||
if(players == -1)
|
||||
return builder.getOnlinePlayers();
|
||||
|
||||
@@ -166,18 +166,18 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers(){
|
||||
public int maxPlayers(){
|
||||
return builder.getMaximumPlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerIP(){
|
||||
public String playerIP(){
|
||||
return event.getConnection().getRemoteAddress().getHostString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePAPIPlaceholders(String text, VelocityPlayerImpl player){
|
||||
if(!plugin.getProxy().getPluginManager().isLoaded("papiproxybridge"))
|
||||
if(!plugin.proxy().getPluginManager().isLoaded("papiproxybridge"))
|
||||
return text;
|
||||
|
||||
if(!PAPIUtil.get().isCompatible())
|
||||
@@ -187,7 +187,7 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
if(server == null || server.isEmpty())
|
||||
return text;
|
||||
|
||||
RegisteredServer registeredServer = plugin.getProxy().getServer(server).orElse(null);
|
||||
RegisteredServer registeredServer = plugin.proxy().getServer(server).orElse(null);
|
||||
if(registeredServer == null || registeredServer.getPlayersConnected().isEmpty())
|
||||
return text;
|
||||
|
||||
@@ -199,12 +199,12 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVirtualHost(){
|
||||
public String virtualHost(){
|
||||
return this.resolveHost(event.getConnection().getVirtualHost().orElse(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginCore<Favicon> getPlugin(){
|
||||
public PluginCore<Favicon> plugin(){
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -214,9 +214,9 @@ public class VelocityEventWrapper implements GenericEventWrapper<Favicon, Veloci
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericServer createGenericServer(int playersOnline, int playersMax, String host){
|
||||
public GenericServer createServer(int playersOnline, int playersMax, String host){
|
||||
Map<String, RegisteredServer> servers = new HashMap<>();
|
||||
plugin.getProxy().getAllServers().forEach(server -> servers.put(server.getServerInfo().getName(), server));
|
||||
plugin.proxy().getAllServers().forEach(server -> servers.put(server.getServerInfo().getName(), server));
|
||||
|
||||
return new VelocityProxyImpl(servers, playersOnline, playersMax, host);
|
||||
}
|
||||
|
||||
+2
@@ -28,9 +28,11 @@ package ch.andre601.advancedserverlist.velocity.objects.impl;
|
||||
import ch.andre601.advancedserverlist.api.velocity.objects.VelocityPlayer;
|
||||
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@NullMarked
|
||||
public record VelocityPlayerImpl(CachedPlayer player, int protocol) implements VelocityPlayer{
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -27,12 +27,13 @@ package ch.andre601.advancedserverlist.velocity.objects.impl;
|
||||
|
||||
import ch.andre601.advancedserverlist.api.velocity.objects.VelocityProxy;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record VelocityProxyImpl(Map<String, RegisteredServer> servers, int playersOnline, int playersMax, String host) implements VelocityProxy{
|
||||
@Override
|
||||
public Map<String, RegisteredServer> getServers(){
|
||||
public @NonNull Map<String, RegisteredServer> getServers(){
|
||||
return servers;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -29,7 +29,10 @@ import ch.andre601.advancedserverlist.api.PlaceholderProvider;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
|
||||
import ch.andre601.advancedserverlist.api.objects.GenericServer;
|
||||
import ch.andre601.advancedserverlist.api.velocity.objects.VelocityPlayer;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class VelocityPlayerPlaceholders extends PlaceholderProvider{
|
||||
|
||||
private VelocityPlayerPlaceholders(){
|
||||
@@ -41,7 +44,7 @@ public class VelocityPlayerPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
if(!(player instanceof VelocityPlayer velocityPlayer))
|
||||
return null;
|
||||
|
||||
|
||||
+4
-1
@@ -6,7 +6,10 @@ import ch.andre601.advancedserverlist.api.objects.GenericServer;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import ch.andre601.advancedserverlist.velocity.VelocityCore;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class VelocityProxyPlaceholders extends PlaceholderProvider{
|
||||
|
||||
private final VelocityCore plugin;
|
||||
@@ -22,7 +25,7 @@ public class VelocityProxyPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
String[] args = placeholder.split("\\s", 2);
|
||||
if(args.length < 2)
|
||||
return null;
|
||||
|
||||
+6
-3
@@ -31,7 +31,10 @@ import ch.andre601.advancedserverlist.api.objects.GenericServer;
|
||||
import ch.andre601.advancedserverlist.api.velocity.objects.VelocityProxy;
|
||||
import ch.andre601.advancedserverlist.velocity.VelocityCore;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class VelocityServerPlaceholders extends PlaceholderProvider{
|
||||
|
||||
private final VelocityCore plugin;
|
||||
@@ -46,7 +49,7 @@ public class VelocityServerPlaceholders extends PlaceholderProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
public @Nullable String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
|
||||
if(!(server instanceof VelocityProxy proxy))
|
||||
return null;
|
||||
|
||||
@@ -66,7 +69,7 @@ public class VelocityServerPlaceholders extends PlaceholderProvider{
|
||||
if(registeredServer == null)
|
||||
continue;
|
||||
|
||||
int connected = plugin.getOnlinePlayers(registeredServer);
|
||||
int connected = plugin.onlinePlayers(registeredServer);
|
||||
if(connected == -1)
|
||||
continue;
|
||||
|
||||
@@ -88,7 +91,7 @@ public class VelocityServerPlaceholders extends PlaceholderProvider{
|
||||
if(args.length > 2)
|
||||
yield "";
|
||||
|
||||
if(args.length == 2 && args[1] != null && !args[1].isEmpty()){
|
||||
if(args.length == 2 && !args[1].isEmpty()){
|
||||
RegisteredServer info = proxy.getServers().get(args[1]);
|
||||
if(info == null)
|
||||
yield "";
|
||||
|
||||
@@ -63,8 +63,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
<artifactId>okhttp-jvm</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
+4
-4
@@ -34,7 +34,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.time.Duration;
|
||||
|
||||
public class CodebergReleaseFetcher{
|
||||
|
||||
@@ -43,9 +43,9 @@ public class CodebergReleaseFetcher{
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
private static final OkHttpClient CLIENT = new OkHttpClient.Builder()
|
||||
.callTimeout(30, TimeUnit.SECONDS)
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.callTimeout(Duration.ofSeconds(30))
|
||||
.connectTimeout(Duration.ofSeconds(30))
|
||||
.readTimeout(Duration.ofSeconds(30))
|
||||
.build();
|
||||
|
||||
public static CodebergRelease fetch(){
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ public class HangarVersionUploader{
|
||||
Map.of(
|
||||
Platform.PAPER, List.of("1.20.6", "1.21.x"),
|
||||
Platform.WATERFALL, List.of("1.19.x", "1.20.x", "1.21"),
|
||||
Platform.VELOCITY, Collections.singletonList("3.2")
|
||||
Platform.VELOCITY, List.of("3.2", "3.3", "3.4")
|
||||
),
|
||||
changelog.replaceAll("\r\n", "\n"),
|
||||
fileInfo,
|
||||
|
||||
+6
-5
@@ -55,11 +55,11 @@ public class ModrinthVersionUploader{
|
||||
);
|
||||
private final List<String> paperVersions = List.of(
|
||||
"1.20.6",
|
||||
"1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4"
|
||||
"1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7"
|
||||
);
|
||||
private final List<String> versions = List.of(
|
||||
"1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6",
|
||||
"1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4"
|
||||
"1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7"
|
||||
);
|
||||
|
||||
private final ModrinthAPI api;
|
||||
@@ -146,9 +146,10 @@ public class ModrinthVersionUploader{
|
||||
|
||||
String url = versionUrl + projectVersion.getId();
|
||||
|
||||
logger.info("Created new release!");
|
||||
logger.info("Link: {}", url);
|
||||
logger.info("Platform: {}", platformInfo.getPlatform());
|
||||
logger.info("""
|
||||
New release created:
|
||||
- Link: {}
|
||||
- Platform: {}""", url, platformInfo.getPlatform());
|
||||
|
||||
releaseHolder.addRelease(
|
||||
"modrinth",
|
||||
|
||||
Reference in new issue
Block a user