mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-06 18:47:44 +01:00
Use Gson api for update checking to fix build with 1.14
This commit is contained in:
parent
f4af4c3f00
commit
8fdfa41cc2
4
pom.xml
4
pom.xml
@ -117,10 +117,6 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
|
@ -176,7 +176,11 @@ public class P extends JavaPlugin {
|
||||
p.getServer().getScheduler().runTaskTimer(p, new DrunkRunnable(), 120, 120);
|
||||
|
||||
if (updateCheck) {
|
||||
p.getServer().getScheduler().runTaskLaterAsynchronously(p, new UpdateChecker(), 135);
|
||||
try {
|
||||
p.getServer().getScheduler().runTaskLaterAsynchronously(p, new UpdateChecker(), 135);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
this.log(this.getDescription().getName() + " enabled!");
|
||||
|
@ -1,5 +1,11 @@
|
||||
package com.dre.brewery.filedata;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -7,13 +13,6 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
|
||||
/**
|
||||
* Update Checker modified from the Gravity Update Checker Example:
|
||||
@ -80,19 +79,20 @@ public class UpdateChecker implements Runnable {
|
||||
conn.addRequestProperty("User-Agent", "Brewery UpdateChecker (by Gravity)");
|
||||
|
||||
// Read the response of the query
|
||||
// The response will be in a JSON format, so only reading one line is necessary.
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String response = reader.readLine();
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
|
||||
|
||||
// Parse the array of files from the query's response
|
||||
JSONArray array = (JSONArray) JSONValue.parse(response);
|
||||
JsonArray array = parser.parse(reader).getAsJsonArray();
|
||||
|
||||
if (array.size() > 0) {
|
||||
// Get the newest file's details
|
||||
JSONObject latest = (JSONObject) array.get(array.size() - 1);
|
||||
JsonObject latest = array.get(array.size() - 1).getAsJsonObject();
|
||||
|
||||
// Get the version's title
|
||||
String versionName = (String) latest.get(API_NAME_VALUE);
|
||||
String versionName = latest.get(API_NAME_VALUE).getAsString();
|
||||
|
||||
/*// Get the version's link
|
||||
String versionLink = (String) latest.get(API_LINK_VALUE);
|
||||
|
Loading…
Reference in New Issue
Block a user