🆙 Upgrade project dependencies and Java version; refactor code for improved compatibility and performance

This commit is contained in:
duckietm
2026-01-06 16:12:04 +01:00
parent 984aea5284
commit 60ccfae79d
8 changed files with 47 additions and 54 deletions
+34 -37
View File
@@ -10,39 +10,27 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<additionalparam>-Xdoclint:none</additionalparam> <maven.compiler.target>21</maven.compiler.target>
</properties> </properties>
<profiles>
<profile>
<id>java8-doclint-disabled</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<javadoc.opts>-Xdoclint:none</javadoc.opts>
</properties>
</profile>
</profiles>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.13.0</version>
<configuration> <configuration>
<source>16</source> <source>19</source>
<target>16</target> <target>19</target>
<release>21</release>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version> <version>3.7.1</version>
<configuration> <configuration>
<descriptorRefs> <descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>jar-with-dependencies</descriptorRef>
@@ -67,9 +55,9 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version> <version>3.10.1</version>
<configuration> <configuration>
<additionalOptions><additionalOption>-Xdoclint:none</additionalOption></additionalOptions> <doclint>none</doclint>
<show>public</show> <show>public</show>
</configuration> </configuration>
</plugin> </plugin>
@@ -81,10 +69,6 @@
<id>central</id> <id>central</id>
<url>https://repo1.maven.org/maven2/</url> <url>https://repo1.maven.org/maven2/</url>
</repository> </repository>
<repository>
<id>mvnrepo</id>
<url>https://mvnrepository.com/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@@ -92,21 +76,21 @@
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-all</artifactId> <artifactId>netty-all</artifactId>
<version>4.1.49.Final</version> <version>4.1.115.Final</version>
</dependency> </dependency>
<!-- GSON --> <!-- GSON -->
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.8.6</version> <version>2.11.0</version>
</dependency> </dependency>
<!-- MySQL Connector --> <!-- MySQL Connector -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>com.mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-j</artifactId>
<version>8.0.22</version> <version>9.1.0</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
@@ -118,21 +102,23 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.zaxxer/HikariCP --> <!-- HikariCP -->
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>3.4.3</version> <version>6.2.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Apache Commons Lang -->
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.10</version> <version>3.17.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Apache Commons Math -->
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId> <artifactId>commons-math3</artifactId>
@@ -140,30 +126,41 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- JSoup -->
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.13.1</version> <version>1.18.3</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- SLF4J API -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.16</version>
</dependency>
<!-- Logback -->
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.2.3</version> <version>1.5.15</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Jansi -->
<dependency> <dependency>
<groupId>org.fusesource.jansi</groupId> <groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId> <artifactId>jansi</artifactId>
<version>1.18</version> <version>2.4.1</version>
</dependency> </dependency>
<!-- Joda Time -->
<dependency> <dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.10.6</version> <version>2.13.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
@@ -97,7 +97,7 @@ public final class Emulator {
appender.start(); appender.start();
} }
Locale.setDefault(new Locale("en")); Locale.setDefault(Locale.of("en"));
setBuild(); setBuild();
Emulator.stopped = false; Emulator.stopped = false;
ConsoleCommand.load(); ConsoleCommand.load();
@@ -53,7 +53,7 @@ public class CommandHandler {
public static void addCommand(Class<? extends Command> command) { public static void addCommand(Class<? extends Command> command) {
try { try {
//command.getConstructor().setAccessible(true); //command.getConstructor().setAccessible(true);
addCommand(command.newInstance()); addCommand(command.getDeclaredConstructor().newInstance());
LOGGER.debug("Added command: {}", command.getName()); LOGGER.debug("Added command: {}", command.getName());
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Caught exception", e); LOGGER.error("Caught exception", e);
@@ -14,6 +14,7 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URI;
import java.net.URL; import java.net.URL;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@@ -130,7 +131,7 @@ public class YoutubeManager {
if(apiKey.isEmpty()) return null; if(apiKey.isEmpty()) return null;
YoutubePlaylist playlist; YoutubePlaylist playlist;
URL playlistInfo = new URL("https://youtube.googleapis.com/youtube/v3/playlists?part=snippet&id=" + playlistId + "&maxResults=1&key=" + apiKey); URL playlistInfo = URI.create("https://youtube.googleapis.com/youtube/v3/playlists?part=snippet&id=" + playlistId + "&maxResults=1&key=" + apiKey).toURL();
HttpsURLConnection playlistCon = (HttpsURLConnection) playlistInfo.openConnection(); HttpsURLConnection playlistCon = (HttpsURLConnection) playlistInfo.openConnection();
if (playlistCon.getResponseCode() != 200) { if (playlistCon.getResponseCode() != 200) {
InputStream errorInputStream = playlistCon.getErrorStream(); InputStream errorInputStream = playlistCon.getErrorStream();
@@ -164,9 +165,9 @@ public class YoutubeManager {
URL playlistItems; URL playlistItems;
if (nextPageToken.isEmpty()) { if (nextPageToken.isEmpty()) {
playlistItems = new URL("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&maxResults=50&key=" + apiKey); playlistItems = URI.create("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&maxResults=50&key=" + apiKey).toURL();
} else { } else {
playlistItems = new URL("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&pageToken=" + nextPageToken + "&maxResults=50&key=" + apiKey); playlistItems = URI.create("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&pageToken=" + nextPageToken + "&maxResults=50&key=" + apiKey).toURL();
} }
HttpsURLConnection con = (HttpsURLConnection) playlistItems.openConnection(); HttpsURLConnection con = (HttpsURLConnection) playlistItems.openConnection();
@@ -190,7 +191,7 @@ public class YoutubeManager {
String commaSeparatedVideos = String.join(",", videoIds); String commaSeparatedVideos = String.join(",", videoIds);
VideoItems = new URL("https://youtube.googleapis.com/youtube/v3/videos?part=contentDetails&id=" + commaSeparatedVideos + "&maxResults=50&key=" + apiKey); VideoItems = URI.create("https://youtube.googleapis.com/youtube/v3/videos?part=contentDetails&id=" + commaSeparatedVideos + "&maxResults=50&key=" + apiKey).toURL();
HttpsURLConnection con1 = (HttpsURLConnection) VideoItems.openConnection(); HttpsURLConnection con1 = (HttpsURLConnection) VideoItems.openConnection();
InputStream is1 = con1.getInputStream(); InputStream is1 = con1.getInputStream();
InputStreamReader isr1 = new InputStreamReader(is1); InputStreamReader isr1 = new InputStreamReader(is1);
@@ -29,7 +29,7 @@ public class WiredHighscoreManager {
private final static String locale = (System.getProperty("user.language") != null ? System.getProperty("user.language") : "en"); private final static String locale = (System.getProperty("user.language") != null ? System.getProperty("user.language") : "en");
private final static String country = (System.getProperty("user.country") != null ? System.getProperty("user.country") : "US"); private final static String country = (System.getProperty("user.country") != null ? System.getProperty("user.country") : "US");
private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(locale, country)).getFirstDayOfWeek(); private final static DayOfWeek firstDayOfWeek = WeekFields.of(Locale.of(locale, country)).getFirstDayOfWeek();
private final static DayOfWeek lastDayOfWeek = DayOfWeek.of(((firstDayOfWeek.getValue() + 5) % DayOfWeek.values().length) + 1); private final static DayOfWeek lastDayOfWeek = DayOfWeek.of(((firstDayOfWeek.getValue() + 5) % DayOfWeek.values().length) + 1);
private final static ZoneId zoneId = ZoneId.systemDefault(); private final static ZoneId zoneId = ZoneId.systemDefault();
@@ -179,7 +179,7 @@ public class PacketManager {
return; return;
} }
final MessageHandler handler = handlerClass.newInstance(); final MessageHandler handler = handlerClass.getDeclaredConstructor().newInstance();
if (handler.getRatelimit() > 0) { if (handler.getRatelimit() > 0) {
if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) { if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) {
+4 -9
View File
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender"> <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>false</withJansi>
<encoder> <encoder>
<pattern>%d{HH:mm:ss.SSS} [%-14thread] %highlight(%-5level) %cyan(%-36logger{36}) - %msg%n</pattern> <pattern>%d{HH:mm:ss.SSS} [%-14thread] %-5level %-36logger{36} - %msg%n</pattern>
</encoder> </encoder>
</appender> </appender>
@@ -54,15 +53,11 @@
</encoder> </encoder>
</appender> </appender>
<logger name="io.netty"> <logger name="io.netty" level="INFO"/>
<level value="info"/>
</logger>
<logger name="com.zaxxer.hikari"> <logger name="com.zaxxer.hikari" level="ERROR"/>
<level value="error"/>
</logger>
<root level="info"> <root level="INFO">
<appender-ref ref="Console" /> <appender-ref ref="Console" />
<appender-ref ref="FileDebug" /> <appender-ref ref="FileDebug" />
<appender-ref ref="FileErrors" /> <appender-ref ref="FileErrors" />