Point the update checker to the premium version
This commit is contained in:
parent
e5799d7a5e
commit
65777f036f
@ -6,20 +6,17 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class UpdateChecker
|
public class UpdateChecker {
|
||||||
{
|
|
||||||
|
|
||||||
private String latestVersion;
|
private String latestVersion;
|
||||||
|
|
||||||
private boolean checkHigher(String currentVersion, String newVersion)
|
private boolean checkHigher(String currentVersion, String newVersion) {
|
||||||
{
|
|
||||||
String current = toReadable(currentVersion);
|
String current = toReadable(currentVersion);
|
||||||
String newVers = toReadable(newVersion);
|
String newVers = toReadable(newVersion);
|
||||||
return current.compareTo(newVers) < 0;
|
return current.compareTo(newVers) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkUpdate(String currentVersion)
|
public void checkUpdate(String currentVersion) {
|
||||||
{
|
|
||||||
String version = getSpigotVersion();
|
String version = getSpigotVersion();
|
||||||
|
|
||||||
if (version == null)
|
if (version == null)
|
||||||
@ -31,42 +28,35 @@ public class UpdateChecker
|
|||||||
latestVersion = version;
|
latestVersion = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLatestVersion()
|
public String getLatestVersion() {
|
||||||
{
|
|
||||||
return latestVersion;
|
return latestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks spigot for the version
|
* Asks spigot for the version
|
||||||
*/
|
*/
|
||||||
private String getSpigotVersion()
|
private String getSpigotVersion() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpURLConnection con = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
HttpURLConnection con = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
con.getOutputStream().write(
|
con.getOutputStream().write(
|
||||||
("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=81").getBytes("UTF-8"));
|
("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=32453").getBytes("UTF-8"));
|
||||||
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
||||||
if (version.length() <= 7)
|
if (version.length() <= 7) {
|
||||||
{
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex) {
|
||||||
{
|
|
||||||
System.out.print("[LibsDisguises] Failed to check for a update on spigot.");
|
System.out.print("[LibsDisguises] Failed to check for a update on spigot.");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toReadable(String version)
|
private String toReadable(String version) {
|
||||||
{
|
|
||||||
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
||||||
version = "";
|
version = "";
|
||||||
for (String s : split)
|
for (String s : split) {
|
||||||
{
|
|
||||||
version += String.format("%4s", s);
|
version += String.format("%4s", s);
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
|
Loading…
Reference in New Issue
Block a user