mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
Switch to HttpRequest util.
Former-commit-id: 52b65d3821d1bfe04b838c7c86c00c72e52459b2
This commit is contained in:
1 parent
79d78c9bca
commit
997f6f2e02
3 files changed
+11
-12
No files matched your search
@@ -29,7 +29,6 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.Github.GithubAPI;
|
||||
import org.maxgamer.quickshop.Util.Github.ReleaseJsonContainer;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
@@ -45,18 +44,18 @@ public class Updater {
|
||||
return new UpdateInfomation(false, null);
|
||||
}
|
||||
try {
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=62575")
|
||||
.openConnection();
|
||||
int timed_out = 300000;
|
||||
connection.setConnectTimeout(timed_out);
|
||||
connection.setReadTimeout(timed_out);
|
||||
|
||||
String localPluginVersion = QuickShop.instance.getDescription().getVersion();
|
||||
String spigotPluginVersion = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
|
||||
if (spigotPluginVersion != null && !spigotPluginVersion.isEmpty() && !spigotPluginVersion.equals(localPluginVersion)) {
|
||||
connection.disconnect();
|
||||
String spigotPluginVersion = HttpRequest.get(new URL("https://api.spigotmc.org/legacy/update.php?resource=62575"))
|
||||
.execute()
|
||||
.expectResponseCode(200)
|
||||
.returnContent()
|
||||
.asString("UTF-8")
|
||||
.trim();
|
||||
if (!spigotPluginVersion.isEmpty() && !spigotPluginVersion.equals(localPluginVersion)) {
|
||||
Util.debugLog(spigotPluginVersion);
|
||||
return new UpdateInfomation(spigotPluginVersion.toLowerCase().contains("beta"), spigotPluginVersion);
|
||||
}
|
||||
connection.disconnect();
|
||||
return new UpdateInfomation(false, spigotPluginVersion);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getConsoleSender()
|
||||
|
||||
@@ -67,7 +67,7 @@ public class UpdateWatcher implements Listener {
|
||||
hasNewUpdate = true;
|
||||
|
||||
if (!info.isBeta()) {
|
||||
QuickShop.instance.getLogger().info("A new version of QuickShop has been released!");
|
||||
QuickShop.instance.getLogger().info("A new version of QuickShop has been released! ["+info.getVersion()+"]");
|
||||
QuickShop.instance.getLogger().info("Update here: https://www.spigotmc.org/resources/62575/");
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
|
||||
Reference in new issue
Block a user