Compare commits

...
8 Commits
Author SHA1 Message Date
Andre_601 8f9ae4a835 Merge pull request #43 from Andre601/fix/nullpointerexceptions
Fix some NullPointerExceptions
2023-01-09 20:32:01 +01:00
Andre601 0dccdaf7e4 Add a comment 2023-01-09 20:31:31 +01:00
Andre601 ec0dec8e7d Try to fix errors with OkHttpClient 2023-01-09 17:59:23 +01:00
Andre601 f399ed6886 Fix some NullPointerExceptions 2023-01-09 17:42:54 +01:00
Andre_601 f2737f2b19 Merge pull request #42 from Andre601/dependabot/maven/core/com.google.code.gson-gson-2.10.1
Bump gson from 2.10 to 2.10.1 in /core
2023-01-09 16:20:46 +01:00
dependabot[bot] 504e669ce7 Bump gson from 2.10 to 2.10.1 in /core
Bumps [gson](https://github.com/google/gson) from 2.10 to 2.10.1.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.10...gson-parent-2.10.1)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-09 15:16:41 +00:00
Andre_601 1effc2574a Update release.yml 2022-12-28 20:15:16 +01:00
Andre_601 eb7a7fa6c7 Delete prerelease.yml 2022-12-28 20:15:07 +01:00
19 changed files with 153 additions and 160 deletions

No files matched your search

-106
View File
@@ -1,106 +0,0 @@
#
# Big thank you to @Kir-Antipov for providing this workflow file.
# Check out his mc-publish action here: https://github.com/Kir-Antipov/mc-publish
#
name: Publish Assets
on:
release:
types:
- published
- prereleased
jobs:
buildJars:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.16
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '16'
cache: 'maven'
- name: Build Jar files
run: mvn clean install
- name: Save BungeeCord Jar file
uses: actions/upload-artifact@v3
with:
name: asl-bungeecord
path: bungeecord/target/AdvancedServerList-*.jar
if-no-files-found: error
retention-days: 1
- name: Save Paper Jar file
uses: actions/upload-artifact@v3
with:
name: asl-paper
path: paper/target/AdvancedServerList-*.jar
if-no-files-found: error
retention-days: 1
- name: Save Spigot Jar file
uses: actions/upload-artifact@v3
with:
name: asl-spigot
path: spigot/target/AdvancedServerList-*.jar
if-no-files-found: error
retention-days: 1
- name: Save Velocity Jar file
uses: actions/upload-artifact@v3
with:
name: asl-velocity
path: velocity/target/AdvancedServerList-*.jar
if-no-files-found: error
retention-days: 1
publish:
needs: [buildJars]
strategy:
matrix:
include:
- platforms: BungeeCord, Waterfall
directory: bungeecord
loaders: |
bungeecord
waterfall
- platforms: Paper
directory: paper
loaders: paper
- platforms: Spigot
directory: spigot
loaders: spigot
- platforms: Velocity
directory: velocity
loaders: velocity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Jar files
uses: actions/download-artifact@v3
with:
name: asl-${{ matrix.directory }}
path: ${{ matrix.directory }}/target
- name: Get Version
id: github-release
run: |
version=$(echo ${{ github.event.release.tag_name }} | cut -d'v' -f2)
echo "PLUGIN_RELEASE=$version" >> $GITHUB_OUTPUT
- name: Upload AdvancedServerList (${{ matrix.loaders }}) to GitHub and Modrinth
uses: Kir-Antipov/mc-publish@v3.2
with:
name: ${{ github.event.release.tag_name }} (${{ matrix.platforms }}) BETA
version: ${{ steps.github-release.outputs.PLUGIN_RELEASE }}
version-type: beta
files: ${{ matrix.directory}}/target/AdvancedServerList-*.jar
files-secondary: ""
loaders: ${{ matrix.loaders }}
version-resolver: releases
game-versions: |
1.19
1.19.1
1.19.2
1.19.3
java: 16
modrinth-id: xss83sOY
modrinth-featured: false
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
-1
View File
@@ -9,7 +9,6 @@ on:
release:
types:
- published
- released
jobs:
buildJars:
@@ -52,4 +52,9 @@ public class BungeeLogger implements PluginLogger{
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);
}
}
+1 -1
View File
@@ -80,7 +80,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10</version>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
@@ -97,12 +97,19 @@ public class UpdateChecker{
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();
@@ -66,7 +66,7 @@ public class PingEventHandler{
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 class PingEventHandler{
);
}
boolean hidePlayers = entry.isHidePlayersEnabled() != null && entry.isHidePlayersEnabled();
boolean hidePlayers = entry.isHidePlayersEnabled().getValue(false);
if(hidePlayers){
event.hidePlayers();
@@ -130,7 +130,7 @@ public class FileHandler{
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());
}
@@ -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);
}
@@ -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;
@@ -0,0 +1,53 @@
/*
* 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;
/*
* 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);
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;
}
}
@@ -94,6 +94,9 @@ public class ServerListProfile{
* ...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 class ServerListProfile{
public static class Builder{
private final String fileName;
private final ConfigurationNode node;
private final int priority;
private final List<Expression> expressions = new ArrayList<>();
@@ -118,14 +122,15 @@ public class ServerListProfile{
private List<ProfileEntry> 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 @@ public class ServerListProfile{
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 @@ public class ServerListProfile{
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 @@ public class ServerListProfile{
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;
}
@@ -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;
@@ -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<String> 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<String> motd, List<String> 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 class ProfileEntry{
public static ProfileEntry empty(){
return new ProfileEntry(Collections.emptyList(), Collections.emptyList(), "", "",
false, false, 0);
NullBool.FALSE, NullBool.FALSE, 0);
}
public List<String> getMOTD(){
@@ -75,11 +76,11 @@ public class ProfileEntry{
return favicon;
}
public Boolean isHidePlayersEnabled(){
public NullBool isHidePlayersEnabled(){
return hidePlayersEnabled;
}
public Boolean isExtraPlayersEnabled(){
public NullBool isExtraPlayersEnabled(){
return extraPlayersEnabled;
}
@@ -90,7 +91,7 @@ public class ProfileEntry{
public boolean isInvalidProfile(){
return getMOTD().isEmpty() &&
getPlayers().isEmpty() &&
(getPlayerCountText().isEmpty() && !isHidePlayersEnabled()) &&
(getPlayerCountText().isEmpty() && !isHidePlayersEnabled().getValue(false)) &&
getFavicon().isEmpty();
}
@@ -102,8 +103,8 @@ public class ProfileEntry{
private List<String> 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 class ProfileEntry{
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;
}
@@ -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 class ProfileManager{
List<String> 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<String> resolveMOTD(ProfileEntry profile, ProfileEntry defaultProfile){
@@ -112,23 +113,23 @@ public class ProfileManager{
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();
}
@@ -67,18 +67,7 @@ public class PaperCore extends JavaPlugin implements ServerCore<CachedServerIcon
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 class PaperCore extends JavaPlugin implements ServerCore<CachedServerIcon
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 ========================================");
}
}
@@ -52,4 +52,9 @@ public class PaperLogger implements PluginLogger{
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);
}
}
+1 -1
View File
@@ -12,7 +12,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.version>1.10.1</plugin.version>
<plugin.version>1.10.2</plugin.version>
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
<maven.compiler.source>16</maven.compiler.source>
@@ -52,4 +52,9 @@ public class SpigotLogger implements PluginLogger{
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);
}
}
@@ -50,4 +50,9 @@ public class VelocityLogger implements PluginLogger{
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);
}
}