From 82e05afacfc3efa0f08e53de7bd026ba1a0409f2 Mon Sep 17 00:00:00 2001 From: Jo0001 <47455182+Jo0001@users.noreply.github.com> Date: Wed, 13 Dec 2023 15:08:06 +0000 Subject: [PATCH 1/2] Use GitHub for update check --- .../com/viaversion/viaversion/update/UpdateUtil.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java b/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java index 915a4e675..4ef9870a5 100644 --- a/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java @@ -21,6 +21,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.util.GsonUtil; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -28,14 +29,15 @@ import java.net.HttpURLConnection; import java.net.URL; import java.util.Locale; import java.util.UUID; + import org.checkerframework.checker.nullness.qual.Nullable; public final class UpdateUtil { private static final String PREFIX = "§a§l[ViaVersion] §a"; - private static final String URL = "https://api.spiget.org/v2/resources/"; - private static final int PLUGIN = 19254; - private static final String LATEST_VERSION = "/versions/latest"; + private static final String URL = "https://api.github.com/repos/ViaVersion/"; + private static final String PLUGIN = "ViaVersion"; + private static final String LATEST_VERSION = "/releases/latest"; public static void sendUpdateMessage(final UUID uuid) { Via.getPlatform().runAsync(() -> { @@ -91,8 +93,9 @@ public final class UpdateUtil { try { URL url = new URL(URL + PLUGIN + LATEST_VERSION + "?" + System.currentTimeMillis()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setUseCaches(true); + connection.setUseCaches(false); connection.addRequestProperty("User-Agent", "ViaVersion " + Via.getPlatform().getPluginVersion() + " " + Via.getPlatform().getPlatformName()); + connection.addRequestProperty("Accept", "application/json"); connection.setDoOutput(true); BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); String input; From dcd4502f5ae98e4124605279b9a4ca0d8023e34d Mon Sep 17 00:00:00 2001 From: Jo0001 <47455182+Jo0001@users.noreply.github.com> Date: Sat, 16 Dec 2023 18:02:35 +0000 Subject: [PATCH 2/2] Use own update site --- .../java/com/viaversion/viaversion/update/UpdateUtil.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java b/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java index 4ef9870a5..39e76605f 100644 --- a/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java @@ -35,9 +35,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class UpdateUtil { private static final String PREFIX = "§a§l[ViaVersion] §a"; - private static final String URL = "https://api.github.com/repos/ViaVersion/"; - private static final String PLUGIN = "ViaVersion"; - private static final String LATEST_VERSION = "/releases/latest"; + private static final String URL = "https://update.viaversion.com"; + private static final String PLUGIN = "/ViaVersion/"; public static void sendUpdateMessage(final UUID uuid) { Via.getPlatform().runAsync(() -> { @@ -91,7 +90,7 @@ public final class UpdateUtil { private static @Nullable String getNewestVersion() { try { - URL url = new URL(URL + PLUGIN + LATEST_VERSION + "?" + System.currentTimeMillis()); + URL url = new URL(URL + PLUGIN); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setUseCaches(false); connection.addRequestProperty("User-Agent", "ViaVersion " + Via.getPlatform().getPluginVersion() + " " + Via.getPlatform().getPlatformName());