mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-27 10:57:44 +01:00
Change it so when there is no connection we don't bug them. Also change it to use http instead of https, as https requires certain certificate info by linux.
This commit is contained in:
parent
c4185e3056
commit
4124c3454e
@ -19,7 +19,7 @@ import java.util.UUID;
|
||||
|
||||
public class UpdateUtil {
|
||||
|
||||
private final static String URL = "https://api.spiget.org/v1/resources/";
|
||||
private final static String URL = "http://api.spiget.org/v1/resources/";
|
||||
private final static int PLUGIN = 19254;
|
||||
|
||||
public final static String PREFIX = ChatColor.GREEN + "" + ChatColor.BOLD + "[ViaVersion] " + ChatColor.GREEN;
|
||||
@ -69,9 +69,17 @@ public class UpdateUtil {
|
||||
if (ViaVersion.getInstance().getVersion().equals("${project.version}")) {
|
||||
return "You are using a debug/custom version, consider updating.";
|
||||
}
|
||||
String newestString = getNewestVersion();
|
||||
if (newestString == null) {
|
||||
if (console) {
|
||||
return "Could not check for updates, check your connection.";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Version current = new Version(ViaVersion.getInstance().getVersion());
|
||||
Version newest = new Version(getNewestVersion());
|
||||
Version newest = new Version(newestString);
|
||||
if (current.compareTo(newest) < 0)
|
||||
return "There is a newer version available: " + newest.toString();
|
||||
else if (console) {
|
||||
@ -81,7 +89,6 @@ public class UpdateUtil {
|
||||
}
|
||||
|
||||
private static String getNewestVersion() {
|
||||
String result = "";
|
||||
try {
|
||||
URL url = new URL(URL + PLUGIN + "?" + System.currentTimeMillis());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
@ -97,12 +104,11 @@ public class UpdateUtil {
|
||||
br.close();
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject statistics = (JsonObject) parser.parse(content);
|
||||
result = statistics.get("version").getAsString();
|
||||
return statistics.get("version").getAsString();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user