From f399ed68868f36fad57127eb0d107c9f4cc9a91c Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 9 Jan 2023 17:42:54 +0100 Subject: [PATCH 1/3] Fix some NullPointerExceptions --- .../bungeecord/logging/BungeeLogger.java | 5 ++ .../core/events/PingEventHandler.java | 4 +- .../core/file/FileHandler.java | 2 +- .../core/interfaces/PluginLogger.java | 2 + .../replacer => objects}/EntryList.java | 4 +- .../core/objects/NullBool.java | 46 +++++++++++++++++++ .../core/profiles/ServerListProfile.java | 20 ++++++-- .../core/profiles/players/PlayerHandler.java | 2 +- .../core/profiles/profile/ProfileEntry.java | 31 +++++++------ .../core/profiles/profile/ProfileManager.java | 27 +++++------ .../paper/logging/PaperLogger.java | 5 ++ pom.xml | 2 +- .../spigot/logging/SpigotLogger.java | 5 ++ .../velocity/logging/VelocityLogger.java | 5 ++ 14 files changed, 120 insertions(+), 40 deletions(-) rename core/src/main/java/ch/andre601/advancedserverlist/core/{profiles/replacer => objects}/EntryList.java (94%) create mode 100644 core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java diff --git a/bungeecord/src/main/java/ch/andre601/advancedserverlist/bungeecord/logging/BungeeLogger.java b/bungeecord/src/main/java/ch/andre601/advancedserverlist/bungeecord/logging/BungeeLogger.java index bb336905..7182726b 100644 --- a/bungeecord/src/main/java/ch/andre601/advancedserverlist/bungeecord/logging/BungeeLogger.java +++ b/bungeecord/src/main/java/ch/andre601/advancedserverlist/bungeecord/logging/BungeeLogger.java @@ -52,4 +52,9 @@ public void warn(String msg, Object... args){ public void warn(String msg, Throwable throwable){ logger.log(Level.WARNING, msg, throwable); } + + @Override + public void warn(String msg, Throwable throwable, Object... args){ + logger.log(Level.WARNING, String.format(msg, args), throwable); + } } diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/events/PingEventHandler.java b/core/src/main/java/ch/andre601/advancedserverlist/core/events/PingEventHandler.java index be8d2123..2006c362 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/events/PingEventHandler.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/events/PingEventHandler.java @@ -66,7 +66,7 @@ public static void handleEvent(GenericEventWrapper event){ ProfileEntry entry = ProfileManager.merge(profile); - if(entry.isExtraPlayersEnabled() != null && entry.isExtraPlayersEnabled()){ + if(entry.isExtraPlayersEnabled().getValue(false)){ max = online + (entry.getExtraPlayersCount() == null ? 0 : entry.getExtraPlayersCount()); event.setMaxPlayers(max); } @@ -83,7 +83,7 @@ public static void handleEvent(GenericEventWrapper event){ ); } - boolean hidePlayers = entry.isHidePlayersEnabled() != null && entry.isHidePlayersEnabled(); + boolean hidePlayers = entry.isHidePlayersEnabled().getValue(false); if(hidePlayers){ event.hidePlayers(); diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/file/FileHandler.java b/core/src/main/java/ch/andre601/advancedserverlist/core/file/FileHandler.java index 18a87131..7e5541eb 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/file/FileHandler.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/file/FileHandler.java @@ -130,7 +130,7 @@ public boolean reloadProfiles(){ if(tmp == null) continue; - profiles.add(ServerListProfile.Builder.resolve(tmp, logger).build()); + profiles.add(ServerListProfile.Builder.resolve(file.getName(), tmp, logger).build()); logger.info("Loaded " + file.getName()); } diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/interfaces/PluginLogger.java b/core/src/main/java/ch/andre601/advancedserverlist/core/interfaces/PluginLogger.java index b761bde5..0d3b16c6 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/interfaces/PluginLogger.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/interfaces/PluginLogger.java @@ -32,4 +32,6 @@ public interface PluginLogger{ void warn(String msg, Object... args); void warn(String msg, Throwable throwable); + + void warn(String msg, Throwable throwable, Object... args); } diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/replacer/EntryList.java b/core/src/main/java/ch/andre601/advancedserverlist/core/objects/EntryList.java similarity index 94% rename from core/src/main/java/ch/andre601/advancedserverlist/core/profiles/replacer/EntryList.java rename to core/src/main/java/ch/andre601/advancedserverlist/core/objects/EntryList.java index 4d61b0e1..a77340e3 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/replacer/EntryList.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/objects/EntryList.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 Andre_601 + * Copyright (c) 2022-2023 Andre_601 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ * */ -package ch.andre601.advancedserverlist.core.profiles.replacer; +package ch.andre601.advancedserverlist.core.objects; import java.util.AbstractMap; import java.util.ArrayList; diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java b/core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java new file mode 100644 index 00000000..e3811cda --- /dev/null +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java @@ -0,0 +1,46 @@ +/* + * MIT License + * + * Copyright (c) 2022-2023 Andre_601 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +package ch.andre601.advancedserverlist.core.objects; + +public class NullBool{ + + public static final NullBool FALSE = new NullBool(false); + public static final NullBool NULL = new NullBool(null); + + private final Boolean value; + + public NullBool(Boolean value){ + this.value = value; + } + + public boolean isNull(){ + return value == null; + } + + public boolean getValue(boolean def){ + return isNull() ? def : value; + } +} diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/ServerListProfile.java b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/ServerListProfile.java index 8bcc7d86..5366d5ef 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/ServerListProfile.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/ServerListProfile.java @@ -94,6 +94,9 @@ public ProfileEntry getDefaultProfile(){ * ...doesn't have a favicon set. */ public boolean isInvalidProfile(){ + if(profiles.isEmpty()) + return defaultProfile.isInvalidProfile(); + boolean profilesValid = false; for(ProfileEntry profile : profiles){ @@ -109,6 +112,7 @@ public boolean isInvalidProfile(){ public static class Builder{ + private final String fileName; private final ConfigurationNode node; private final int priority; private final List expressions = new ArrayList<>(); @@ -118,14 +122,15 @@ public static class Builder{ private List profiles = new ArrayList<>(); private ProfileEntry defaultProfile = ProfileEntry.empty(); - private Builder(ConfigurationNode node, PluginLogger logger){ + private Builder(String fileName, ConfigurationNode node, PluginLogger logger){ + this.fileName = fileName; this.node = node; this.priority = node.node("priority").getInt(); this.logger = logger; } - public static Builder resolve(ConfigurationNode node, PluginLogger logger){ - return new Builder(node, logger) + public static Builder resolve(String fileName, ConfigurationNode node, PluginLogger logger){ + return new Builder(fileName, node, logger) .resolveExpressions() .resolveProfiles() .resolveDefaultProfile(); @@ -136,6 +141,7 @@ private Builder resolveExpressions(){ try{ temp = node.node("conditions").getList(String.class); }catch(SerializationException ex){ + logger.warn("Encountered a SerializationException while resolving conditions for %s", ex, fileName); return this; } @@ -159,7 +165,9 @@ private Builder resolveExpressions(){ private Builder resolveProfiles(){ try{ this.profiles = node.node("profiles").getList(ProfileEntry.class); - }catch(SerializationException ignored){} + }catch(SerializationException ex){ + logger.warn("Encountered a SerializationException while resolving the profiles entry for %s", ex, fileName); + } return this; } @@ -167,7 +175,9 @@ private Builder resolveProfiles(){ private Builder resolveDefaultProfile(){ try{ this.defaultProfile = node.get(ProfileEntry.class); - }catch(SerializationException ignored){} + }catch(SerializationException ex){ + logger.warn("Encountered a SerializationException while resolving the global profile for %s", ex, fileName); + } return this; } diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/players/PlayerHandler.java b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/players/PlayerHandler.java index 8e90a065..2192e387 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/players/PlayerHandler.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/players/PlayerHandler.java @@ -26,7 +26,7 @@ package ch.andre601.advancedserverlist.core.profiles.players; import ch.andre601.advancedserverlist.core.AdvancedServerList; -import ch.andre601.advancedserverlist.core.profiles.replacer.EntryList; +import ch.andre601.advancedserverlist.core.objects.EntryList; import java.io.BufferedWriter; import java.io.IOException; diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileEntry.java b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileEntry.java index 99ef2459..21b2022e 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileEntry.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileEntry.java @@ -25,6 +25,7 @@ package ch.andre601.advancedserverlist.core.profiles.profile; +import ch.andre601.advancedserverlist.core.objects.NullBool; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.serialize.SerializationException; @@ -38,13 +39,13 @@ public class ProfileEntry{ private final List players; private final String playerCountText; private final String favicon; - private final Boolean hidePlayersEnabled; - private final Boolean extraPlayersEnabled; + private final NullBool hidePlayersEnabled; + private final NullBool extraPlayersEnabled; private final Integer extraPlayersCount; public ProfileEntry(List motd, List players, - String playerCountText, String favicon, Boolean hidePlayersEnabled, - Boolean extraPlayersEnabled, Integer extraPlayersCount){ + String playerCountText, String favicon, NullBool hidePlayersEnabled, + NullBool extraPlayersEnabled, Integer extraPlayersCount){ this.motd = motd; this.players = players; this.playerCountText = playerCountText; @@ -56,7 +57,7 @@ public ProfileEntry(List motd, List players, public static ProfileEntry empty(){ return new ProfileEntry(Collections.emptyList(), Collections.emptyList(), "", "", - false, false, 0); + NullBool.FALSE, NullBool.FALSE, 0); } public List getMOTD(){ @@ -75,11 +76,11 @@ public String getFavicon(){ return favicon; } - public Boolean isHidePlayersEnabled(){ + public NullBool isHidePlayersEnabled(){ return hidePlayersEnabled; } - public Boolean isExtraPlayersEnabled(){ + public NullBool isExtraPlayersEnabled(){ return extraPlayersEnabled; } @@ -90,7 +91,7 @@ public Integer getExtraPlayersCount(){ public boolean isInvalidProfile(){ return getMOTD().isEmpty() && getPlayers().isEmpty() && - (getPlayerCountText().isEmpty() && !isHidePlayersEnabled()) && + (getPlayerCountText().isEmpty() && !isHidePlayersEnabled().getValue(false)) && getFavicon().isEmpty(); } @@ -102,8 +103,8 @@ public static class Builder{ private List players = new ArrayList<>(); private String playerCountText = null; private String favicon = null; - private Boolean hidePlayersEnabled = false; - private Boolean extraPlayersEnabled = false; + private NullBool hidePlayersEnabled = NullBool.FALSE; + private NullBool extraPlayersEnabled = NullBool.FALSE; private Integer extraPlayersCount = 0; private Builder(ConfigurationNode node){ @@ -149,21 +150,21 @@ public Builder resolveFavicon(){ public Builder resolveHidePlayersEnabled(){ if(node.node("playerCount", "hidePlayers").virtual()){ - this.hidePlayersEnabled = null; + this.hidePlayersEnabled = NullBool.NULL; return this; } - - this.hidePlayersEnabled = node.node("playerCount", "hidePlayers").getBoolean(); + + this.hidePlayersEnabled = new NullBool(node.node("playerCount", "hidePlayers").getBoolean()); return this; } public Builder resolveExtraPlayersEnabled(){ if(node.node("playerCount", "extraPlayers", "enabled").virtual()){ - this.extraPlayersEnabled = null; + this.extraPlayersEnabled = NullBool.NULL; return this; } - this.extraPlayersEnabled = node.node("playerCount", "extraPlayers", "enabled").getBoolean(); + this.extraPlayersEnabled = new NullBool(node.node("playerCount", "extraPlayers", "enabled").getBoolean()); return this; } diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileManager.java b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileManager.java index c694bcf6..6cca1d73 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileManager.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/profiles/profile/ProfileManager.java @@ -26,6 +26,7 @@ package ch.andre601.advancedserverlist.core.profiles.profile; import ch.andre601.advancedserverlist.core.AdvancedServerList; +import ch.andre601.advancedserverlist.core.objects.NullBool; import ch.andre601.advancedserverlist.core.profiles.ServerListProfile; import ch.andre601.advancedserverlist.core.profiles.replacer.placeholders.Placeholders; @@ -76,12 +77,12 @@ public static ProfileEntry merge(ServerListProfile profile){ List players = resolvePlayers(entry, defEntry); String playerCountText = resolvePlayerCountText(entry, defEntry); String favicon = resolveFavicon(entry, defEntry); - Boolean isHidePlayersEnabled = resolveHidePlayersEnabled(entry, defEntry); - Boolean isExtraPlayersEnabled = resolveExtraPlayersEnabled(entry, defEntry); + boolean isHidePlayersEnabled = resolveHidePlayersEnabled(entry, defEntry); + boolean isExtraPlayersEnabled = resolveExtraPlayersEnabled(entry, defEntry); Integer extraPlayersCount = resolveExtraPlayersCount(entry, defEntry); - return new ProfileEntry(motd, players, playerCountText, favicon, isHidePlayersEnabled, isExtraPlayersEnabled, - extraPlayersCount); + return new ProfileEntry(motd, players, playerCountText, favicon, + new NullBool(isHidePlayersEnabled), new NullBool(isExtraPlayersEnabled), extraPlayersCount); } private static List resolveMOTD(ProfileEntry profile, ProfileEntry defaultProfile){ @@ -112,23 +113,23 @@ private static String resolveFavicon(ProfileEntry profile, ProfileEntry defaultP return profile.getFavicon(); } - private static Boolean resolveHidePlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){ - if(profile == null || profile.isHidePlayersEnabled() == null) - return defaultProfile.isHidePlayersEnabled(); + private static boolean resolveHidePlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){ + if(profile == null || profile.isHidePlayersEnabled().isNull()) + return defaultProfile.isHidePlayersEnabled().getValue(false); - return profile.isHidePlayersEnabled(); + return profile.isHidePlayersEnabled().getValue(false); } - private static Boolean resolveExtraPlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){ - if(profile == null || profile.isExtraPlayersEnabled() == null) - return defaultProfile.isExtraPlayersEnabled(); + private static boolean resolveExtraPlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){ + if(profile == null || profile.isExtraPlayersEnabled().isNull()) + return defaultProfile.isExtraPlayersEnabled().getValue(false); - return profile.isExtraPlayersEnabled(); + return profile.isExtraPlayersEnabled().getValue(false); } private static Integer resolveExtraPlayersCount(ProfileEntry profile, ProfileEntry defaultProfile){ if(profile == null || profile.getExtraPlayersCount() == null) - return defaultProfile.getExtraPlayersCount(); + return defaultProfile.getExtraPlayersCount() == null ? 0 : defaultProfile.getExtraPlayersCount(); return profile.getExtraPlayersCount(); } diff --git a/paper/src/main/java/ch/andre601/advancedserverlist/paper/logging/PaperLogger.java b/paper/src/main/java/ch/andre601/advancedserverlist/paper/logging/PaperLogger.java index 68c05fb0..ce179b9f 100644 --- a/paper/src/main/java/ch/andre601/advancedserverlist/paper/logging/PaperLogger.java +++ b/paper/src/main/java/ch/andre601/advancedserverlist/paper/logging/PaperLogger.java @@ -52,4 +52,9 @@ public void warn(String msg, Object... args){ public void warn(String msg, Throwable throwable){ logger.log(Level.WARNING, msg, throwable); } + + @Override + public void warn(String msg, Throwable throwable, Object... args){ + logger.log(Level.WARNING, String.format(msg, args), throwable); + } } diff --git a/pom.xml b/pom.xml index 5628f514..6f63810d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ UTF-8 - 1.10.1 + 1.10.2 Create multiple Server lists based on conditions. 16 diff --git a/spigot/src/main/java/ch/andre601/advancedserverlist/spigot/logging/SpigotLogger.java b/spigot/src/main/java/ch/andre601/advancedserverlist/spigot/logging/SpigotLogger.java index d1bfdbd0..6fd558e4 100644 --- a/spigot/src/main/java/ch/andre601/advancedserverlist/spigot/logging/SpigotLogger.java +++ b/spigot/src/main/java/ch/andre601/advancedserverlist/spigot/logging/SpigotLogger.java @@ -52,4 +52,9 @@ public void warn(String msg, Object... args){ public void warn(String msg, Throwable throwable){ logger.log(Level.WARNING, msg, throwable); } + + @Override + public void warn(String msg, Throwable throwable, Object... args){ + logger.log(Level.WARNING, String.format(msg, args), throwable); + } } diff --git a/velocity/src/main/java/ch/andre601/advancedserverlist/velocity/logging/VelocityLogger.java b/velocity/src/main/java/ch/andre601/advancedserverlist/velocity/logging/VelocityLogger.java index da962f0d..9ac2d164 100644 --- a/velocity/src/main/java/ch/andre601/advancedserverlist/velocity/logging/VelocityLogger.java +++ b/velocity/src/main/java/ch/andre601/advancedserverlist/velocity/logging/VelocityLogger.java @@ -50,4 +50,9 @@ public void warn(String msg, Object... args){ public void warn(String msg, Throwable throwable){ logger.warn(msg, throwable); } + + @Override + public void warn(String msg, Throwable throwable, Object... args){ + logger.warn(String.format(msg, args), throwable); + } } From ec0dec8e7d9d69030ee28cc4d8de3993cf96e957 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 9 Jan 2023 17:59:23 +0100 Subject: [PATCH 2/3] Try to fix errors with OkHttpClient --- .../core/check/UpdateChecker.java | 7 +++++ .../advancedserverlist/paper/PaperCore.java | 30 +++++++++++-------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/check/UpdateChecker.java b/core/src/main/java/ch/andre601/advancedserverlist/core/check/UpdateChecker.java index afa3d26f..88c6879c 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/check/UpdateChecker.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/check/UpdateChecker.java @@ -97,12 +97,19 @@ public void startUpdateChecker(){ public void disable(){ executor.shutdown(); + client.dispatcher().executorService().shutdown(); try{ if(!executor.awaitTermination(1, TimeUnit.SECONDS)){ executor.shutdownNow(); if(!executor.awaitTermination(1, TimeUnit.SECONDS)) logger.warn("Scheduler didn't terminate in time!"); } + + if(!client.dispatcher().executorService().awaitTermination(1, TimeUnit.SECONDS)){ + client.dispatcher().executorService().shutdownNow(); + if(!client.dispatcher().executorService().awaitTermination(1, TimeUnit.SECONDS)) + logger.warn("OkHttp's Scheduler didn't terminate in time!"); + } }catch(InterruptedException ex){ executor.shutdownNow(); Thread.currentThread().interrupt(); diff --git a/paper/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java b/paper/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java index 80ff899a..55f98c81 100644 --- a/paper/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java +++ b/paper/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java @@ -67,18 +67,7 @@ public void onEnable(){ Class.forName("com.destroystokyo.paper.PaperConfig"); enable(); }catch(ClassNotFoundException ex1){ - getPluginLogger().warn("======================================== WARNING ========================================"); - getPluginLogger().warn(""); - getPluginLogger().warn("You are using the PaperMC version of AdvancedServerList on a SpigotMC server."); - getPluginLogger().warn("The PaperMC version is ONLY compatible with PaperMC itself due to it using exclusive"); - getPluginLogger().warn("methods and events not available within SpigotMC."); - getPluginLogger().warn(""); - getPluginLogger().warn("To avoid any exceptions and errors will AdvancedServerList disable itself now."); - getPluginLogger().warn("Please stop your server and either switch to PaperMC or use the Spigot version"); - getPluginLogger().warn("of AdvancedServerList."); - getPluginLogger().warn(""); - getPluginLogger().warn("======================================== WARNING ========================================"); - + printSpigotWarning(); getServer().getPluginManager().disablePlugin(this); } } @@ -186,4 +175,21 @@ public List createPlayers(List lines, OfflinePlayer playe private void enable(){ this.core = new AdvancedServerList(this); } + + private void printSpigotWarning(){ + getPluginLogger().warn("======================================== WARNING ========================================"); + getPluginLogger().warn(""); + getPluginLogger().warn("You are using the Paper version of AdvancedServerList on a SpigotMC server."); + getPluginLogger().warn("The Paper version is ONLY compatible with Paper itself due to it using exclusive"); + getPluginLogger().warn("methods and events not available within SpigotMC."); + getPluginLogger().warn(""); + getPluginLogger().warn("To avoid any exceptions and errors will AdvancedServerList disable itself now."); + getPluginLogger().warn("Please stop your server and either switch to Paper or use the Spigot version"); + getPluginLogger().warn("of AdvancedServerList."); + getPluginLogger().warn(""); + getPluginLogger().warn("Paper can be downloaded here:"); + getPluginLogger().warn("https://papermc.io/downloads"); + getPluginLogger().warn(""); + getPluginLogger().warn("======================================== WARNING ========================================"); + } } From 0dccdaf7e43629ff86ff532c2dbb9645999d5388 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 9 Jan 2023 20:31:31 +0100 Subject: [PATCH 3/3] Add a comment --- .../andre601/advancedserverlist/core/objects/NullBool.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java b/core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java index e3811cda..39bb5374 100644 --- a/core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java +++ b/core/src/main/java/ch/andre601/advancedserverlist/core/objects/NullBool.java @@ -25,6 +25,13 @@ package ch.andre601.advancedserverlist.core.objects; +/* + * A simple class to allow having a nullable boolean without having to deal with possible NPEs + * when trying to get Boolean.getValue() while it is null... + * + * Here, it simply checks if the value is null and if it is, returns a default. Otherwise it gives + * the value. + */ public class NullBool{ public static final NullBool FALSE = new NullBool(false);