From acce02a1b72f49e18031f644c0c70c6a643eed8a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 14 May 2020 09:04:48 +1200 Subject: [PATCH] Remove obsolete update calls --- .../libraryaddict/disguise/LibsDisguises.java | 2 +- .../utilities/updates/UpdateChecker.java | 39 +------------------ 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index e6d4f323..44592b98 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -45,7 +45,7 @@ public class LibsDisguises extends JavaPlugin { @Getter private boolean reloaded; @Getter - private final UpdateChecker updateChecker = new UpdateChecker("32453"); + private final UpdateChecker updateChecker = new UpdateChecker(); @Override public void onLoad() { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java b/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java index 9649e530..5aa9736e 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java @@ -26,22 +26,17 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; public class UpdateChecker { - private final String resourceID; private final long started = System.currentTimeMillis(); @Getter private PluginInformation lastDownload; private final AtomicBoolean downloading = new AtomicBoolean(false); @Getter private DisguiseUpdate update; - private LDGithub githubUpdater = new LDGithub(); - private LDJenkins jenkinsUpdater = new LDJenkins(); + private final LDGithub githubUpdater = new LDGithub(); + private final LDJenkins jenkinsUpdater = new LDJenkins(); @Getter private String[] updateMessage = new String[0]; - public UpdateChecker(String resourceID) { - this.resourceID = resourceID; - } - public boolean isServerLatestVersion() { return isOnLatestUpdate(false); } @@ -260,36 +255,6 @@ public class UpdateChecker { return null; } - /** - * Asks spigot for the version - */ - private String fetchSpigotVersion() { - try { - // We're connecting to spigot's API - URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + resourceID); - // Creating a connection - HttpURLConnection con = (HttpURLConnection) url.openConnection(); - con.setDefaultUseCaches(false); - - // Get the input stream, what we receive - try (InputStream input = con.getInputStream()) { - // Read it to string - String version = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines() - .collect(Collectors.joining("\n")); - - // If the version is not empty, return it - if (!version.isEmpty()) { - return version; - } - } - } - catch (Exception ex) { - DisguiseUtilities.getLogger().warning("Failed to check for a update on spigot."); - } - - return null; - } - private boolean isNewerVersion(String currentVersion, String newVersion) { currentVersion = currentVersion.replaceAll("(v)|(-SNAPSHOT)", ""); newVersion = newVersion.replaceAll("(v)|(-SNAPSHOT)", "");