Remove dependencies

Update checker has been rewritten to use Java-native HTTP classes to fetch details and remove the redundant JSON dependency in favour of GSON which is already included
This commit is contained in:
ncurran02
2026-05-14 11:16:11 +10:00
parent 33d6df3029
commit f19ac597fb
2 changed files with 32 additions and 35 deletions
-2
View File
@@ -14,12 +14,10 @@ repositories {
dependencies {
library("org.projectlombok:lombok:1.18.46")
library("org.json:json:20251224")
library("commons-io:commons-io:2.22.0")
library("redis.clients:jedis:7.5.0")
library("org.mariadb.jdbc:mariadb-java-client:3.5.8")
library("com.zaxxer:HikariCP:7.0.2")
library("org.apache.maven.resolver:maven-resolver-transport-http:1.9.27")
library("org.jetbrains:annotations:26.1.0")
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
@@ -19,15 +19,9 @@ import lombok.NonNull;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.apache.commons.io.FileUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.json.JSONException;
import org.json.JSONObject;
public class UpdateChecker implements PlexBase
{
@@ -154,24 +148,24 @@ public class UpdateChecker implements PlexBase
public void updateJar(CommandSender sender, String name, boolean module)
{
CloseableHttpClient client = HttpClients.createDefault();
AtomicReference<String> url = new AtomicReference<>(DOWNLOAD_PAGE + name);
if (!module)
{
url.set(url.get() + "/job/" + BRANCH);
}
PlexLog.debug(url.toString());
HttpGet get = new HttpGet(url + "/lastSuccessfulBuild/api/json");
try
{
HttpResponse response = client.execute(get);
int statusCode = response.getStatusLine().getStatusCode();
HttpURLConnection connection = (HttpURLConnection) URI.create(url + "/lastSuccessfulBuild/api/json").toURL().openConnection();
int statusCode = connection.getResponseCode();
if (statusCode == HttpURLConnection.HTTP_OK)
{
JSONObject object = new JSONObject(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8));
JSONObject artifact = object.getJSONArray("artifacts").getJSONObject(0);
String jarFile = artifact.getString("fileName");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)))
{
JsonObject object = new Gson().fromJson(reader, JsonObject.class);
JsonObject artifact = object.getAsJsonArray("artifacts").asList().getFirst().getAsJsonObject();
String jarFile = artifact.get("fileName").getAsString();
sender.sendMessage(PlexUtils.mmDeserialize("<green>Downloading latest JAR file: " + jarFile));
File copyTo;
if (!module)
@@ -198,6 +192,11 @@ public class UpdateChecker implements PlexBase
}
});
}
catch (JsonSyntaxException | NumberFormatException e)
{
e.printStackTrace();
}
}
else if (statusCode == HttpURLConnection.HTTP_NOT_FOUND)
{
sender.sendMessage(PlexUtils.mmDeserialize("<red>Could not update " + name + " as it can't be found on Jenkins."));