From fd5f058d2e1ee1a64733b0d1afde30decfc640f9 Mon Sep 17 00:00:00 2001 From: Patrick <147879351+WinniePatGG@users.noreply.github.com> Date: Mon, 1 Jun 2026 18:06:16 +0200 Subject: [PATCH] 0.0.2 | Added check without serverId --- build.gradle | 2 +- .../winniepat/licenselib/LicenseClient.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e89de01..85bda87 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'de.winniepat' -version = '0.0.1' +version = '0.0.2' java { diff --git a/src/main/java/de/winniepat/licenselib/LicenseClient.java b/src/main/java/de/winniepat/licenselib/LicenseClient.java index 6c8bf8c..2c11b2d 100644 --- a/src/main/java/de/winniepat/licenselib/LicenseClient.java +++ b/src/main/java/de/winniepat/licenselib/LicenseClient.java @@ -55,6 +55,36 @@ public class LicenseClient { ); } + /** + * Checks if license is valid (without serverId) + * @param apiUrl Server API url + * @param plugin Plugin id matching the one on the backend api + * @param licenseKey License key issued by the api + * @return LicenseResult with the data from the backend + */ + public static LicenseResult check( + String apiUrl, + String plugin, + String licenseKey + ) { + + Http http = new Http(); + + JsonObject payload = new JsonObject(); + payload.addProperty("plugin", plugin); + payload.addProperty("licenseKey", licenseKey); + + HttpResponse response = http.post(apiUrl, GSON.toJson(payload)); + + JsonObject json = GSON.fromJson(response.body(), JsonObject.class); + + return new LicenseResult( + json.get("valid").getAsBoolean(), + json.get("status").getAsString(), + json.get("message").getAsString() + ); + } + /** * Represents the result of a license check. * @param isValid boolean if the license is valid or not