0.0.3 | Combined functions with and without serverId into one

This commit is contained in:
Patrick
2026-06-01 18:15:14 +02:00
parent fd5f058d2e
commit 84805bd978
2 changed files with 6 additions and 34 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
}
group = 'de.winniepat'
version = '0.0.2'
version = '0.0.3'
java {
@@ -34,7 +34,7 @@ public class LicenseClient {
String apiUrl,
String plugin,
String licenseKey,
String serverId
String serverId // can be null
) {
Http http = new Http();
@@ -42,40 +42,12 @@ public class LicenseClient {
JsonObject payload = new JsonObject();
payload.addProperty("plugin", plugin);
payload.addProperty("licenseKey", licenseKey);
if (serverId != null) {
payload.addProperty("serverId", serverId);
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()
);
}
/**
* 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(