From 35204610387b010a64260d76bf39cf1f6cd368df Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Wed, 3 Apr 2024 18:22:15 +0200 Subject: [PATCH] Update to 24w14a and Java 21 --- .github/workflows/gradle.yml | 4 ++-- README.md | 2 +- build.gradle | 8 ++++---- .../net/wurstclient/altmanager/MicrosoftLoginManager.java | 5 +++-- .../analytics/dmurph/JGoogleAnalyticsTracker.java | 3 ++- .../hacks/autocomplete/OobaboogaMessageCompleter.java | 4 +++- .../hacks/autocomplete/OpenAiMessageCompleter.java | 8 +++++--- src/main/java/net/wurstclient/util/GoogleTranslate.java | 3 ++- src/main/resources/fabric.mod.json | 4 ++-- 9 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 7f4b1a79f2..daa6bd3d67 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -23,10 +23,10 @@ jobs: - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v2 - - name: Set up Java 17 + - name: Set up Java 21 uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'microsoft' - name: Grant execute permission for gradlew diff --git a/README.md b/README.md index c0b9e6447d..10645cfc62 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Setup (for developers) -(This assumes that you are using Windows with [Eclipse](https://www.eclipse.org/downloads/) and [Java Development Kit 17](https://adoptium.net/?variant=openjdk17&jvmVariant=hotspot) already installed.) +(This assumes that you are using Windows with [Eclipse](https://www.eclipse.org/downloads/) and [Java Development Kit 21](https://adoptium.net/?variant=openjdk21&jvmVariant=hotspot) already installed.) 1. Run this command in PowerShell: diff --git a/build.gradle b/build.gradle index 5750e1eb20..d54de53b08 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,8 @@ plugins { def ENV = System.getenv() -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 archivesBaseName = project.archives_base_name version = project.mod_version @@ -58,8 +58,8 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + // Minecraft 1.20.5 (24w14a) upwards uses Java 21. + it.options.release = 21 } java { diff --git a/src/main/java/net/wurstclient/altmanager/MicrosoftLoginManager.java b/src/main/java/net/wurstclient/altmanager/MicrosoftLoginManager.java index f5fbbd10f3..8179146cea 100644 --- a/src/main/java/net/wurstclient/altmanager/MicrosoftLoginManager.java +++ b/src/main/java/net/wurstclient/altmanager/MicrosoftLoginManager.java @@ -14,6 +14,7 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.net.URLDecoder; @@ -197,7 +198,7 @@ private static String microsoftLogin(String email, String password, try { - URL url = new URL(urlPost); + URL url = URI.create(urlPost).toURL(); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); @@ -504,7 +505,7 @@ private static URL createURL(String url) { try { - return new URL(url); + return URI.create(url).toURL(); }catch(MalformedURLException e) { diff --git a/src/main/java/net/wurstclient/analytics/dmurph/JGoogleAnalyticsTracker.java b/src/main/java/net/wurstclient/analytics/dmurph/JGoogleAnalyticsTracker.java index 0fd3d8146d..e558257bca 100644 --- a/src/main/java/net/wurstclient/analytics/dmurph/JGoogleAnalyticsTracker.java +++ b/src/main/java/net/wurstclient/analytics/dmurph/JGoogleAnalyticsTracker.java @@ -30,6 +30,7 @@ import java.net.Proxy; import java.net.Proxy.Type; import java.net.SocketAddress; +import java.net.URI; import java.net.URL; import java.util.LinkedList; import java.util.Scanner; @@ -532,7 +533,7 @@ private static void dispatchRequest(String argURL, String userAgent) { try { - URL url = new URL(argURL); + URL url = URI.create(argURL).toURL(); HttpURLConnection connection = (HttpURLConnection)url.openConnection(proxy); connection.setRequestMethod("GET"); diff --git a/src/main/java/net/wurstclient/hacks/autocomplete/OobaboogaMessageCompleter.java b/src/main/java/net/wurstclient/hacks/autocomplete/OobaboogaMessageCompleter.java index d68479702a..575c98d676 100644 --- a/src/main/java/net/wurstclient/hacks/autocomplete/OobaboogaMessageCompleter.java +++ b/src/main/java/net/wurstclient/hacks/autocomplete/OobaboogaMessageCompleter.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import com.google.gson.JsonArray; @@ -50,7 +51,8 @@ protected WsonObject requestCompletion(JsonObject parameters) throws IOException, JsonException { // set up the API request - URL url = new URL(modelSettings.oobaboogaEndpoint.getValue()); + URL url = + URI.create(modelSettings.oobaboogaEndpoint.getValue()).toURL(); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); diff --git a/src/main/java/net/wurstclient/hacks/autocomplete/OpenAiMessageCompleter.java b/src/main/java/net/wurstclient/hacks/autocomplete/OpenAiMessageCompleter.java index 2b74290c60..9555c613ad 100644 --- a/src/main/java/net/wurstclient/hacks/autocomplete/OpenAiMessageCompleter.java +++ b/src/main/java/net/wurstclient/hacks/autocomplete/OpenAiMessageCompleter.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import com.google.gson.JsonArray; @@ -64,9 +65,10 @@ protected WsonObject requestCompletion(JsonObject parameters) throws IOException, JsonException { // get the API URL - URL url = modelSettings.openAiModel.getSelected().isChatModel() - ? new URL(modelSettings.openaiChatEndpoint.getValue()) - : new URL(modelSettings.openaiLegacyEndpoint.getValue()); + URL url = + URI.create(modelSettings.openAiModel.getSelected().isChatModel() + ? modelSettings.openaiChatEndpoint.getValue() + : modelSettings.openaiLegacyEndpoint.getValue()).toURL(); // set up the API request HttpURLConnection conn = (HttpURLConnection)url.openConnection(); diff --git a/src/main/java/net/wurstclient/util/GoogleTranslate.java b/src/main/java/net/wurstclient/util/GoogleTranslate.java index e3414e0625..705ca85b2f 100644 --- a/src/main/java/net/wurstclient/util/GoogleTranslate.java +++ b/src/main/java/net/wurstclient/util/GoogleTranslate.java @@ -12,6 +12,7 @@ import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; @@ -69,7 +70,7 @@ private static URL createURL(String text, String langFrom, String langTo) "https://translate.google.com/m?hl=en&sl=%s&tl=%s&ie=UTF-8&prev=_m&q=%s", langFrom, langTo, encodedText); - return new URL(urlString); + return URI.create(urlString).toURL(); }catch(MalformedURLException | UnsupportedEncodingException e) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 75f403b5cf..cae3c62cba 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,9 +30,9 @@ "depends": { "fabricloader": ">=0.15.9", - "fabric-api": ">=0.96.13", + "fabric-api": ">=0.96.14", "minecraft": "~1.20.5-alpha.24.13.a", - "java": ">=17" + "java": ">=21" }, "suggests": { "mo_glass": "*"