Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Merge pull request #3581 from Jo0001/master
Use our own site for update check
Dieser Commit ist enthalten in:
Commit
9b1716b662
@ -21,6 +21,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.util.GsonUtil;
|
import com.viaversion.viaversion.util.GsonUtil;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -28,14 +29,14 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class UpdateUtil {
|
public final class UpdateUtil {
|
||||||
|
|
||||||
private static final String PREFIX = "§a§l[ViaVersion] §a";
|
private static final String PREFIX = "§a§l[ViaVersion] §a";
|
||||||
private static final String URL = "https://api.spiget.org/v2/resources/";
|
private static final String URL = "https://update.viaversion.com";
|
||||||
private static final int PLUGIN = 19254;
|
private static final String PLUGIN = "/ViaVersion/";
|
||||||
private static final String LATEST_VERSION = "/versions/latest";
|
|
||||||
|
|
||||||
public static void sendUpdateMessage(final UUID uuid) {
|
public static void sendUpdateMessage(final UUID uuid) {
|
||||||
Via.getPlatform().runAsync(() -> {
|
Via.getPlatform().runAsync(() -> {
|
||||||
@ -89,10 +90,11 @@ public final class UpdateUtil {
|
|||||||
|
|
||||||
private static @Nullable String getNewestVersion() {
|
private static @Nullable String getNewestVersion() {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(URL + PLUGIN + LATEST_VERSION + "?" + System.currentTimeMillis());
|
URL url = new URL(URL + PLUGIN);
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
connection.setUseCaches(true);
|
connection.setUseCaches(false);
|
||||||
connection.addRequestProperty("User-Agent", "ViaVersion " + Via.getPlatform().getPluginVersion() + " " + Via.getPlatform().getPlatformName());
|
connection.addRequestProperty("User-Agent", "ViaVersion " + Via.getPlatform().getPluginVersion() + " " + Via.getPlatform().getPlatformName());
|
||||||
|
connection.addRequestProperty("Accept", "application/json");
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
String input;
|
String input;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren