🆙 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
@@ -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" />