Plugin is no longer on BukkitDev

This commit is contained in:
libraryaddict 2014-06-29 17:07:59 +12:00
parent a89a1f88d7
commit 6742afdaec

View File

@ -4,13 +4,8 @@ import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class UpdateChecker { public class UpdateChecker {
private String latestVersion; private String latestVersion;
@ -22,9 +17,6 @@ public class UpdateChecker {
public void checkUpdate(String currentVersion) { public void checkUpdate(String currentVersion) {
String version = getSpigotVersion(); String version = getSpigotVersion();
if (version == null) {
version = getBukkitVersion();
}
if (version != null) { if (version != null) {
if (checkHigher(currentVersion, version)) { if (checkHigher(currentVersion, version)) {
latestVersion = version; latestVersion = version;
@ -32,29 +24,6 @@ public class UpdateChecker {
} }
} }
/**
* Asks bukkit for the version
*/
private String getBukkitVersion() {
try {
URLConnection conn = new URL("https://api.curseforge.com/servermods/files?projectIds=72490").openConnection();
conn.addRequestProperty("User-Agent", "Lib's Disguises Update Checker");
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
JSONArray array = (JSONArray) JSONValue.parse(reader.readLine());
if (!array.isEmpty()) {
JSONObject latest = (JSONObject) array.get(array.size() - 1);
String version = (String) latest.get("name");
version = version.substring(version.lastIndexOf(" ") + 1);
if (version.length() <= 7) {
return version;
}
}
} catch (Exception e) {
System.out.print("[LibsDisguises] Failed to check for a update on bukkit. " + e.getMessage());
}
return null;
}
public String getLatestVersion() { public String getLatestVersion() {
return latestVersion; return latestVersion;
} }