🆙 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>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<additionalparam>-Xdoclint:none</additionalparam>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</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>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.13.0</version>
<configuration>
<source>16</source>
<target>16</target>
<source>19</source>
<target>19</target>
<release>21</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<version>3.7.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
@@ -67,9 +55,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<version>3.10.1</version>
<configuration>
<additionalOptions><additionalOption>-Xdoclint:none</additionalOption></additionalOptions>
<doclint>none</doclint>
<show>public</show>
</configuration>
</plugin>
@@ -81,10 +69,6 @@
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>mvnrepo</id>
<url>https://mvnrepository.com/</url>
</repository>
</repositories>
<dependencies>
@@ -92,21 +76,21 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.49.Final</version>
<version>4.1.115.Final</version>
</dependency>
<!-- GSON -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<version>2.11.0</version>
</dependency>
<!-- MySQL Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.1.0</version>
<scope>runtime</scope>
</dependency>
@@ -118,21 +102,23 @@
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.zaxxer/HikariCP -->
<!-- HikariCP -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.4.3</version>
<version>6.2.1</version>
<scope>compile</scope>
</dependency>
<!-- Apache Commons Lang -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
<version>3.17.0</version>
<scope>compile</scope>
</dependency>
<!-- Apache Commons Math -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
@@ -140,30 +126,41 @@
<scope>compile</scope>
</dependency>
<!-- JSoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
<version>1.18.3</version>
<scope>compile</scope>
</dependency>
<!-- SLF4J API -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.16</version>
</dependency>
<!-- Logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>1.5.15</version>
<scope>compile</scope>
</dependency>
<!-- Jansi -->
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.18</version>
<version>2.4.1</version>
</dependency>
<!-- Joda Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.6</version>
<version>2.13.0</version>
</dependency>
</dependencies>
</project>
@@ -97,7 +97,7 @@ public final class Emulator {
appender.start();
}
Locale.setDefault(new Locale("en"));
Locale.setDefault(Locale.of("en"));
setBuild();
Emulator.stopped = false;
ConsoleCommand.load();
@@ -53,7 +53,7 @@ public class CommandHandler {
public static void addCommand(Class<? extends Command> command) {
try {
//command.getConstructor().setAccessible(true);
addCommand(command.newInstance());
addCommand(command.getDeclaredConstructor().newInstance());
LOGGER.debug("Added command: {}", command.getName());
} catch (Exception e) {
LOGGER.error("Caught exception", e);
@@ -14,6 +14,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -130,7 +131,7 @@ public class YoutubeManager {
if(apiKey.isEmpty()) return null;
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();
if (playlistCon.getResponseCode() != 200) {
InputStream errorInputStream = playlistCon.getErrorStream();
@@ -164,9 +165,9 @@ public class YoutubeManager {
URL playlistItems;
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 {
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();
@@ -190,7 +191,7 @@ public class YoutubeManager {
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();
InputStream is1 = con1.getInputStream();
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 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 ZoneId zoneId = ZoneId.systemDefault();
@@ -179,7 +179,7 @@ public class PacketManager {
return;
}
final MessageHandler handler = handlerClass.newInstance();
final MessageHandler handler = handlerClass.getDeclaredConstructor().newInstance();
if (handler.getRatelimit() > 0) {
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"?>
<configuration>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>false</withJansi>
<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>
</appender>
@@ -54,15 +53,11 @@
</encoder>
</appender>
<logger name="io.netty">
<level value="info"/>
</logger>
<logger name="io.netty" level="INFO"/>
<logger name="com.zaxxer.hikari">
<level value="error"/>
</logger>
<logger name="com.zaxxer.hikari" level="ERROR"/>
<root level="info">
<root level="INFO">
<appender-ref ref="Console" />
<appender-ref ref="FileDebug" />
<appender-ref ref="FileErrors" />