From 8aafcb95069c579420a134f801feb047c7de4e3d Mon Sep 17 00:00:00 2001 From: LlmDl Date: Sat, 11 Jan 2025 07:37:59 -0600 Subject: [PATCH] - Replace a couple of deprecations required when we supported MC 1.16.*. --- Towny/pom.xml | 2 +- .../bukkit/towny/object/metadata/DataFieldIO.java | 4 +--- .../palmergames/bukkit/towny/tasks/UpdateCheckerTask.java | 6 +++--- Towny/src/main/resources/ChangeLog.txt | 4 +++- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Towny/pom.xml b/Towny/pom.xml index 11d92e39da0..6dc0a312227 100644 --- a/Towny/pom.xml +++ b/Towny/pom.xml @@ -13,7 +13,7 @@ towny jar - 0.101.1.0 + 0.101.1.1 diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/object/metadata/DataFieldIO.java b/Towny/src/main/java/com/palmergames/bukkit/towny/object/metadata/DataFieldIO.java index e0895a31ee5..67bf593084a 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/object/metadata/DataFieldIO.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/object/metadata/DataFieldIO.java @@ -59,9 +59,7 @@ public static Collection> deserializeMeta(String metadata) th private static JsonArray convertToArray(String metadata) throws IOException { try { - // TODO: Replace this when support for MC 1.16.* is dropped. - @SuppressWarnings("deprecation") - JsonElement element = new JsonParser().parse(metadata); + JsonElement element = JsonParser.parseString(metadata); if (!element.isJsonArray()) throw new IOException("Metadata cannot be read as a JSON Array!"); diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/UpdateCheckerTask.java b/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/UpdateCheckerTask.java index 6f47bb42087..84a587b59c7 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/UpdateCheckerTask.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/UpdateCheckerTask.java @@ -26,14 +26,14 @@ public void run() { towny.getLogger().info(Translation.of("msg_checking_for_updates")); try { + // TODO: Replace deprecation when we are running on Java 20. + @SuppressWarnings("deprecation") URL url = new URL("https://api.github.com/repos/TownyAdvanced/Towny/releases"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { try { - // TODO: Replace this when support for MC 1.16.* is dropped. - @SuppressWarnings("deprecation") - Version latestVersion = Version.fromString(new JsonParser().parse(reader).getAsJsonArray().get(0).getAsJsonObject().get("tag_name").getAsString()); + Version latestVersion = Version.fromString(JsonParser.parseReader(reader).getAsJsonArray().get(0).getAsJsonObject().get("tag_name").getAsString()); boolean upToDate = Version.fromString(towny.getVersion()).isNewerThanOrEquals(latestVersion); if (!upToDate) { diff --git a/Towny/src/main/resources/ChangeLog.txt b/Towny/src/main/resources/ChangeLog.txt index e5f42983596..8da07c14d52 100644 --- a/Towny/src/main/resources/ChangeLog.txt +++ b/Towny/src/main/resources/ChangeLog.txt @@ -10201,4 +10201,6 @@ v0.92.0.11: - Bump net.kyori:adventure-text-serializer-plain from 4.17.0 to 4.18.0. - Bump net.kyori:adventure-text-minimessage from 4.17.0 to 4.18.0. 0.101.1.0: - - Bump version for release. \ No newline at end of file + - Bump version for release. +0.101.1.1: + - Replace a couple of deprecations required when we supported MC 1.16.*. \ No newline at end of file