From 13984d8a7beaa5ca2304f1a0dddc42733f69fbfa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 11:13:37 +0000 Subject: [PATCH 001/269] Bump maven-shade-plugin from 3.2.4 to 3.3.0 Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.4 to 3.3.0. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.2.4...maven-shade-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-shade-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 940b569e..c4183ecb 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 3.3.0 false true From 6f417b1ac0419dec26dce81f79fb967e17a9e036 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 30 Mar 2022 22:30:04 +0200 Subject: [PATCH 002/269] this was 5000 before, I made a typo --- src/com/namelessmc/java_api/NamelessApiBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 8ef49b4d..137307f7 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -16,7 +16,7 @@ public class NamelessApiBuilder { - private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(3); + private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(5); private static final String DEFAULT_USER_AGENT = "Nameless-Java-API"; private final @NotNull URL apiUrl; From dc228d927c296cb65dddeb5878e919b59289d606 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 1 Apr 2022 19:32:25 +0200 Subject: [PATCH 003/269] Remove, don't add! --- src/com/namelessmc/java_api/NamelessUser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 6f0fa940..bad158e4 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -291,7 +291,7 @@ public void addGroups(@NotNull final Group@NotNull ... groups) throws NamelessEx public void removeGroups(@NotNull final Group@NotNull... groups) throws NamelessException { final JsonObject post = new JsonObject(); post.add("groups", groupsToJsonArray(groups)); - this.requests.post("users/" + this.getUserTransformer() + "/groups/add", post); + this.requests.post("users/" + this.getUserTransformer() + "/groups/remove", post); invalidateCache(); // Groups modified, invalidate cache } From a5ea6417fd998adf1f5cd3964ecdda700e04163e Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 2 Apr 2022 12:43:55 +0200 Subject: [PATCH 004/269] Limit response size --- .../java_api/NamelessApiBuilder.java | 22 +++++++++++++++-- .../namelessmc/java_api/RequestHandler.java | 24 +++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 137307f7..e2f4ae00 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -18,6 +18,7 @@ public class NamelessApiBuilder { private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(5); private static final String DEFAULT_USER_AGENT = "Nameless-Java-API"; + private static final int DEFAULT_RESPONSE_SIZE_LIMIT = 32*1024*1024; private final @NotNull URL apiUrl; private final @NotNull String apiKey; @@ -25,7 +26,8 @@ public class NamelessApiBuilder { private final @NotNull GsonBuilder gsonBuilder; private @NotNull String userAgent = DEFAULT_USER_AGENT; private @Nullable ApiLogger debugLogger = null; - private Duration timeout = DEFAULT_TIMEOUT; + private @Nullable Duration timeout = DEFAULT_TIMEOUT; + private int responseSizeLimit = DEFAULT_RESPONSE_SIZE_LIMIT; NamelessApiBuilder(@NotNull URL apiUrl, @NotNull String apiKey) { this.apiUrl = apiUrl; @@ -90,8 +92,24 @@ public class NamelessApiBuilder { return this; } + public @NotNull NamelessApiBuilder withResponseSizeLimit(int responseSizeLimitBytes) { + this.responseSizeLimit = responseSizeLimitBytes; + return this; + } + public @NotNull NamelessAPI build() { - return new NamelessAPI(new RequestHandler(this.apiUrl, this.apiKey, this.httpClientBuilder.build(), this.gsonBuilder.create(), this.userAgent, this.debugLogger, this.timeout)); + return new NamelessAPI( + new RequestHandler( + this.apiUrl, + this.apiKey, + this.httpClientBuilder.build(), + this.gsonBuilder.create(), + this.userAgent, + this.debugLogger, + this.timeout, + this.responseSizeLimit + ) + ); } } diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 871546a8..901e993c 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -2,6 +2,7 @@ import com.google.common.base.Ascii; import com.google.common.base.Preconditions; +import com.google.common.io.ByteStreams; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -12,6 +13,7 @@ import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URL; @@ -35,6 +37,7 @@ public class RequestHandler { private final @Nullable ApiLogger debugLogger; private final @Nullable Duration timeout; private final @NotNull Gson gson; + private final int responseLengthLimit; RequestHandler(final @NotNull URL baseUrl, final @NotNull String apiKey, @@ -42,7 +45,8 @@ public class RequestHandler { final @NotNull Gson gson, final @NotNull String userAgent, final @Nullable ApiLogger debugLogger, - final @Nullable Duration timeout) { + final @Nullable Duration timeout, + final int responseLengthLimit) { this.baseUrl = Objects.requireNonNull(baseUrl, "Base URL is null"); this.apiKey = Objects.requireNonNull(apiKey, "Api key is null"); this.httpClient = Objects.requireNonNull(httpClient, "http client is null"); @@ -50,6 +54,7 @@ public class RequestHandler { this.userAgent = Objects.requireNonNull(userAgent, "User agent is null"); this.debugLogger = debugLogger; this.timeout = timeout; + this.responseLengthLimit = responseLengthLimit; } public @NotNull URL getApiUrl() { @@ -131,10 +136,10 @@ private void debug(final @NotNull String message, @NotNull Supplier ar int statusCode; String responseBody; try { - HttpResponse httpResponse = httpClient.send(httpRequest, - HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)); + HttpResponse httpResponse = httpClient.send(httpRequest, + HttpResponse.BodyHandlers.ofInputStream()); statusCode = httpResponse.statusCode(); - responseBody = httpResponse.body(); + responseBody = getBodyAsString(httpResponse); } catch (final IOException e) { final StringBuilder message = new StringBuilder("Network connection error (not a Nameless issue)."); if (e.getMessage().contains("unable to find valid certification path to requested target")) { @@ -207,6 +212,17 @@ private void debug(final @NotNull String message, @NotNull Supplier ar return json; } + private String getBodyAsString(HttpResponse response) throws IOException { + try (InputStream in = response.body(); + InputStream limited = ByteStreams.limit(in, this.responseLengthLimit)) { + byte[] bytes = limited.readAllBytes(); + if (bytes.length == this.responseLengthLimit) { + throw new IOException("Response larger than limit of " + this.responseLengthLimit + " bytes."); + } + return new String(bytes, StandardCharsets.UTF_8); + } + } + private static @NotNull String regularAsciiOnly(@NotNull String message) { char[] chars = message.toCharArray(); for (int i = 0; i < chars.length; i++) { From e4ad21f9c220531856f86d7a66a7b3e9bf649c4a Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 3 Apr 2022 11:33:05 +0200 Subject: [PATCH 005/269] Update for new register endpoint --- src/com/namelessmc/java_api/ApiError.java | 5 +- src/com/namelessmc/java_api/NamelessAPI.java | 63 +++++++++---------- .../IntegrationIdAlreadyExistsException.java | 13 ++++ ...grationUsernameAlreadyExistsException.java | 13 ++++ .../exception/UuidAlreadyExistsException.java | 13 ---- .../integrations/DiscordIntegrationData.java | 34 ++++++++++ .../integrations/IntegrationData.java | 21 +++++++ .../integrations/IntegrationType.java | 17 +++++ .../MinecraftIntegrationData.java | 37 +++++++++++ 9 files changed, 168 insertions(+), 48 deletions(-) create mode 100644 src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java create mode 100644 src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java delete mode 100644 src/com/namelessmc/java_api/exception/UuidAlreadyExistsException.java create mode 100644 src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java create mode 100644 src/com/namelessmc/java_api/integrations/IntegrationData.java create mode 100644 src/com/namelessmc/java_api/integrations/IntegrationType.java create mode 100644 src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java diff --git a/src/com/namelessmc/java_api/ApiError.java b/src/com/namelessmc/java_api/ApiError.java index 815416d3..94a63080 100644 --- a/src/com/namelessmc/java_api/ApiError.java +++ b/src/com/namelessmc/java_api/ApiError.java @@ -19,7 +19,7 @@ public class ApiError extends NamelessException { public static final int INVALID_UUID = 9; public static final int EMAIL_ALREADY_EXISTS = 10; public static final int USERNAME_ALREADY_EXISTS = 11; - public static final int UUID_ALREADY_EXISTS = 12; + // 12 intentionally missing public static final int UNABLE_TO_CREATE_ACCOUNT = 13; public static final int UNABLE_TO_SEND_REGISTRATION_EMAIL = 14; // 15 intentionally missing @@ -45,7 +45,8 @@ public class ApiError extends NamelessException { // 35 intentionally missing public static final int REQUEST_NOT_AUTHORIZED = 36; public static final int INVALID_INTEGRATION = 37; - // 38 intentionally missing + public static final int INTEGRATION_USERNAME_ALREADY_EXISTS = 38; + public static final int INTEGRATION_ID_ALREADY_EXISTS = 39; private static final long serialVersionUID = 3093028909912281912L; diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index e3872394..792cea27 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -6,6 +6,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.exception.*; +import com.namelessmc.java_api.integrations.IntegrationData; import com.namelessmc.java_api.modules.websend.WebsendAPI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -259,23 +260,33 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * * @param username Username (this should match the user's in-game username when specifying a UUID) * @param email Email address - * @param uuid Mojang UUID, if you wish to use the Minecraft integration. Nullable. + * @param integrationData Integration data objects. By supplying account information here, the user will + * an account connection will automatically be created without the user needing to + * verify. * @return Email verification disabled: A link which the user needs to click to complete registration *
Email verification enabled: An empty string (the user needs to check their email to complete registration) - * @see #registerUser(String, String) */ public @NotNull Optional registerUser(@NotNull final String username, @NotNull final String email, - @Nullable final UUID uuid) - throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, CannotSendEmailException, UuidAlreadyExistsException { + @NotNull IntegrationData@Nullable... integrationData) + throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, CannotSendEmailException, + IntegrationUsernameAlreadyExistsException, IntegrationIdAlreadyExistsException { + Objects.requireNonNull(username, "Username is null"); Objects.requireNonNull(email, "Email address is null"); final JsonObject post = new JsonObject(); post.addProperty("username", username); post.addProperty("email", email); - if (uuid != null) { - post.addProperty("uuid", uuid.toString()); + if (integrationData != null && integrationData.length > 0) { + JsonObject integrationsJson = new JsonObject(); + for (IntegrationData integration : integrationData) { + JsonObject integrationJson = new JsonObject(); + integrationJson.addProperty("id", integration.getRawId()); + integrationJson.addProperty("username", integration.getRawUsername()); + integrationsJson.add(integration.getIntegrationType().toString(), integrationJson); + } + post.add("integrations", integrationsJson); } try { @@ -287,37 +298,23 @@ public NamelessUser getUserLazyDiscord(final long discordId) { return Optional.empty(); } } catch (final ApiError e) { - if (e.getError() == ApiError.INVALID_USERNAME) { - throw new InvalidUsernameException(); - } else if (e.getError() == ApiError.USERNAME_ALREADY_EXISTS) { - throw new UsernameAlreadyExistsException(); - } else if (e.getError() == ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL) { - throw new CannotSendEmailException(); - } else if (e.getError() == ApiError.UUID_ALREADY_EXISTS) { - throw new UuidAlreadyExistsException(); - } else { - throw e; + switch (e.getError()) { + case ApiError.INVALID_USERNAME: + throw new InvalidUsernameException(); + case ApiError.USERNAME_ALREADY_EXISTS: + throw new UsernameAlreadyExistsException(); + case ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL: + throw new CannotSendEmailException(); + case ApiError.INTEGRATION_USERNAME_ALREADY_EXISTS: + throw new IntegrationUsernameAlreadyExistsException(); + case ApiError.INTEGRATION_ID_ALREADY_EXISTS: + throw new IntegrationIdAlreadyExistsException(); + default: + throw e; } } } - /** - * Register user without UUID {@link #registerUser(String, String, UUID)} - * WARNING: This will fail if the website has Minecraft integration enabled! - * @param username New username for this user - * @param email New email address for this user - * @return Verification URL if email verification is disabled. - */ - public @NotNull Optional registerUser(@NotNull final String username, - @NotNull final String email) - throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, CannotSendEmailException { - try { - return registerUser(username, email, null); - } catch (final UuidAlreadyExistsException e) { - throw new IllegalStateException("Website said duplicate uuid but we haven't specified a uuid?", e); - } - } - /** * Set Discord bot URL (Nameless-Link internal webserver) * @param url Discord bot URL diff --git a/src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java b/src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java new file mode 100644 index 00000000..e7faca30 --- /dev/null +++ b/src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java @@ -0,0 +1,13 @@ +package com.namelessmc.java_api.exception; + +import com.namelessmc.java_api.ApiError; + +public class IntegrationIdAlreadyExistsException extends ApiErrorException { + + private static final long serialVersionUID = 1L; + + public IntegrationIdAlreadyExistsException() { + super(ApiError.INTEGRATION_ID_ALREADY_EXISTS); + } + +} diff --git a/src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java b/src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java new file mode 100644 index 00000000..d2462008 --- /dev/null +++ b/src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java @@ -0,0 +1,13 @@ +package com.namelessmc.java_api.exception; + +import com.namelessmc.java_api.ApiError; + +public class IntegrationUsernameAlreadyExistsException extends ApiErrorException { + + private static final long serialVersionUID = 1L; + + public IntegrationUsernameAlreadyExistsException() { + super(ApiError.INTEGRATION_USERNAME_ALREADY_EXISTS); + } + +} diff --git a/src/com/namelessmc/java_api/exception/UuidAlreadyExistsException.java b/src/com/namelessmc/java_api/exception/UuidAlreadyExistsException.java deleted file mode 100644 index 27459c70..00000000 --- a/src/com/namelessmc/java_api/exception/UuidAlreadyExistsException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class UuidAlreadyExistsException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public UuidAlreadyExistsException() { - super(ApiError.UUID_ALREADY_EXISTS); - } - -} diff --git a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java new file mode 100644 index 00000000..7b17f81c --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java @@ -0,0 +1,34 @@ +package com.namelessmc.java_api.integrations; + +import org.jetbrains.annotations.NotNull; + +public class DiscordIntegrationData extends IntegrationData { + + private final long id; + private final @NotNull String username; + + public DiscordIntegrationData(final long id, + @NotNull String username) { + super(IntegrationType.DISCORD); + this.id = id; + this.username = username; + } + + public long getId() { + return this.id; + } + + public @NotNull String getUsername() { + return this.getUsername(); + } + + @Override + public @NotNull String getRawId() { + return String.valueOf(this.id); + } + + @Override + public @NotNull String getRawUsername() { + return this.username; + } +} diff --git a/src/com/namelessmc/java_api/integrations/IntegrationData.java b/src/com/namelessmc/java_api/integrations/IntegrationData.java new file mode 100644 index 00000000..c2518577 --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/IntegrationData.java @@ -0,0 +1,21 @@ +package com.namelessmc.java_api.integrations; + +import org.jetbrains.annotations.NotNull; + +public abstract class IntegrationData { + + private final @NotNull IntegrationType integrationType; + + IntegrationData(final @NotNull IntegrationType integrationType) { + this.integrationType = integrationType; + } + + public @NotNull IntegrationType getIntegrationType() { + return this.integrationType; + } + + public abstract @NotNull String getRawId(); + + public abstract @NotNull String getRawUsername(); + +} diff --git a/src/com/namelessmc/java_api/integrations/IntegrationType.java b/src/com/namelessmc/java_api/integrations/IntegrationType.java new file mode 100644 index 00000000..2bcd26ce --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/IntegrationType.java @@ -0,0 +1,17 @@ +package com.namelessmc.java_api.integrations; + +import java.util.Locale; + +public enum IntegrationType { + + MINECRAFT, + DISCORD, + ; + + + @Override + public String toString() { + return this.name().toLowerCase(Locale.ROOT); + } + +} diff --git a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java new file mode 100644 index 00000000..a17d7450 --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java @@ -0,0 +1,37 @@ +package com.namelessmc.java_api.integrations; + +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public class MinecraftIntegrationData extends IntegrationData { + + private final @NotNull UUID uuid; + private final @NotNull String username; + + public MinecraftIntegrationData(final @NotNull UUID uuid, + final @NotNull String username) { + super(IntegrationType.MINECRAFT); + this.uuid = uuid; + this.username = username; + } + + public @NotNull UUID getUniqueId() { + return this.uuid; + } + + public @NotNull String getUsername() { + return this.username; + } + + @Override + public @NotNull String getRawId() { + return this.uuid.toString(); + } + + @Override + public @NotNull String getRawUsername() { + return this.username; + } + +} From fc9cafa895332bece7dbde1e875447d43fc08a15 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 3 Apr 2022 11:36:57 +0200 Subject: [PATCH 006/269] Use switch case for checking error code --- src/com/namelessmc/java_api/NamelessAPI.java | 27 ++++++-------- src/com/namelessmc/java_api/NamelessUser.java | 36 +++++++++---------- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 792cea27..a15d4588 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -299,18 +299,12 @@ public NamelessUser getUserLazyDiscord(final long discordId) { } } catch (final ApiError e) { switch (e.getError()) { - case ApiError.INVALID_USERNAME: - throw new InvalidUsernameException(); - case ApiError.USERNAME_ALREADY_EXISTS: - throw new UsernameAlreadyExistsException(); - case ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL: - throw new CannotSendEmailException(); - case ApiError.INTEGRATION_USERNAME_ALREADY_EXISTS: - throw new IntegrationUsernameAlreadyExistsException(); - case ApiError.INTEGRATION_ID_ALREADY_EXISTS: - throw new IntegrationIdAlreadyExistsException(); - default: - throw e; + case ApiError.INVALID_USERNAME: throw new InvalidUsernameException(); + case ApiError.USERNAME_ALREADY_EXISTS: throw new UsernameAlreadyExistsException(); + case ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL: throw new CannotSendEmailException(); + case ApiError.INTEGRATION_USERNAME_ALREADY_EXISTS: throw new IntegrationUsernameAlreadyExistsException(); + case ApiError.INTEGRATION_ID_ALREADY_EXISTS: throw new IntegrationIdAlreadyExistsException(); + default: throw e; } } } @@ -456,10 +450,11 @@ private void verifyIntegration(final @NotNull IntegrationType type, try { this.requests.post("integration/verify", data); } catch (ApiError e) { - if (e.getError() == ApiError.INVALID_VALIDATE_CODE) { - throw new InvalidValidateCodeException(); - } else { - throw e; + switch (e.getError()) { + case ApiError.INVALID_VALIDATE_CODE: + throw new InvalidValidateCodeException(); + default: + throw e; } } } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index bad158e4..8007bbae 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -346,16 +346,14 @@ public void createReport(@NotNull final NamelessUser user, @NotNull final String try { this.requests.post("reports/create", post); } catch (final ApiError e) { - if (e.getError() == ApiError.USER_CREATING_REPORT_BANNED) { - throw new ReportUserBannedException(); - } else if (e.getError() == ApiError.REPORT_CONTENT_TOO_LARGE) { - throw new IllegalStateException("Website said report reason is too long, but we have client-side validation for this"); - } else if (e.getError() == ApiError.USER_ALREADY_HAS_OPEN_REPORT) { - throw new AlreadyHasOpenReportException(); - } else if (e.getError() == ApiError.CANNOT_REPORT_YOURSELF) { - throw new CannotReportSelfException(); - } else { - throw e; + switch (e.getError()) { + case ApiError.USER_CREATING_REPORT_BANNED: throw new ReportUserBannedException(); + case ApiError.REPORT_CONTENT_TOO_LARGE: + throw new IllegalStateException("Website said report reason is too long, but we have " + + "client-side validation for this so it should be impossible"); + case ApiError.USER_ALREADY_HAS_OPEN_REPORT: throw new AlreadyHasOpenReportException(); + case ApiError.CANNOT_REPORT_YOURSELF: throw new CannotReportSelfException(); + default: throw e; } } } @@ -388,16 +386,14 @@ public void createReport(final @NotNull UUID reportedUuid, try { this.requests.post("reports/create", post); } catch (final ApiError e) { - if (e.getError() == ApiError.USER_CREATING_REPORT_BANNED) { - throw new ReportUserBannedException(); - } else if (e.getError() == ApiError.REPORT_CONTENT_TOO_LARGE) { - throw new IllegalStateException("Website said report reason is too long, but we have client-side validation for this"); - } else if (e.getError() == ApiError.USER_ALREADY_HAS_OPEN_REPORT) { - throw new AlreadyHasOpenReportException(); - } else if (e.getError() == ApiError.CANNOT_REPORT_YOURSELF) { - throw new CannotReportSelfException(); - } else { - throw e; + switch (e.getError()) { + case ApiError.USER_CREATING_REPORT_BANNED: throw new ReportUserBannedException(); + case ApiError.REPORT_CONTENT_TOO_LARGE: + throw new IllegalStateException("Website said report reason is too long, but we have " + + "client-side validation for this so it should be impossible"); + case ApiError.USER_ALREADY_HAS_OPEN_REPORT: throw new AlreadyHasOpenReportException(); + case ApiError.CANNOT_REPORT_YOURSELF: throw new CannotReportSelfException(); + default: throw e; } } } From 492d4f38c9aee6bedc35113de756b11915eafc78 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 3 Apr 2022 11:44:18 +0200 Subject: [PATCH 007/269] handle invalid/used email --- src/com/namelessmc/java_api/NamelessAPI.java | 7 +++++-- .../exception/EmailAlreadyUsedException.java | 13 +++++++++++++ .../exception/InvalidEmailAddressException.java | 13 +++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java create mode 100644 src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index a15d4588..7321834e 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -269,8 +269,9 @@ public NamelessUser getUserLazyDiscord(final long discordId) { public @NotNull Optional registerUser(@NotNull final String username, @NotNull final String email, @NotNull IntegrationData@Nullable... integrationData) - throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, CannotSendEmailException, - IntegrationUsernameAlreadyExistsException, IntegrationIdAlreadyExistsException { + throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, + CannotSendEmailException, IntegrationUsernameAlreadyExistsException, + IntegrationIdAlreadyExistsException, InvalidEmailAddressException, EmailAlreadyUsedException { Objects.requireNonNull(username, "Username is null"); Objects.requireNonNull(email, "Email address is null"); @@ -304,6 +305,8 @@ public NamelessUser getUserLazyDiscord(final long discordId) { case ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL: throw new CannotSendEmailException(); case ApiError.INTEGRATION_USERNAME_ALREADY_EXISTS: throw new IntegrationUsernameAlreadyExistsException(); case ApiError.INTEGRATION_ID_ALREADY_EXISTS: throw new IntegrationIdAlreadyExistsException(); + case ApiError.INVALID_EMAIL_ADDRESS: throw new InvalidEmailAddressException(); + case ApiError.EMAIL_ALREADY_EXISTS: throw new EmailAlreadyUsedException(); default: throw e; } } diff --git a/src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java b/src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java new file mode 100644 index 00000000..97108316 --- /dev/null +++ b/src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java @@ -0,0 +1,13 @@ +package com.namelessmc.java_api.exception; + +import com.namelessmc.java_api.ApiError; + +public class EmailAlreadyUsedException extends ApiErrorException { + + private static final long serialVersionUID = 1L; + + public EmailAlreadyUsedException() { + super(ApiError.EMAIL_ALREADY_EXISTS); + } + +} diff --git a/src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java b/src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java new file mode 100644 index 00000000..9e3014b5 --- /dev/null +++ b/src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java @@ -0,0 +1,13 @@ +package com.namelessmc.java_api.exception; + +import com.namelessmc.java_api.ApiError; + +public class InvalidEmailAddressException extends ApiErrorException { + + private static final long serialVersionUID = 1L; + + public InvalidEmailAddressException() { + super(ApiError.INVALID_EMAIL_ADDRESS); + } + +} From c181f9c17e36a85fde06785f62452fabf85457f5 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 3 Apr 2022 17:22:31 +0200 Subject: [PATCH 008/269] but why??? --- src/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 901e993c..e324d697 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -182,7 +182,7 @@ private void debug(final @NotNull String message, @NotNull Supplier ar } else if (responseBody.contains("Please Wait... | Cloudflare")) { message.append("HINT: CloudFlare is blocking our request. Please see https://docs.namelessmc.com/cloudflare-apis\n"); } else if (responseBody.startsWith("\ufeff")) { - message.append("HINT: The website response contains invisible unicode characters.\n"); + message.append("HINT: The website response contains invisible unicode characters. This seems to be caused by Partydragen's Store module, we have no idea why.\n"); } message.append("Website response:\n"); From 9724e5736227f4d64d52f1078e36345832a28846 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 4 Apr 2022 20:24:19 +0200 Subject: [PATCH 009/269] Untested integrations API --- src/com/namelessmc/java_api/NamelessAPI.java | 6 +-- src/com/namelessmc/java_api/NamelessUser.java | 45 +++++++++-------- .../DetailedDiscordIntegrationData.java | 19 +++++++ .../integrations/DetailedIntegrationData.java | 49 +++++++++++++++++++ .../DetailedMinecraftIntegrationData.java | 22 +++++++++ .../integrations/DiscordIntegrationData.java | 21 ++------ .../integrations/IDiscordIntegrationData.java | 7 +++ .../IMinecraftIntegrationData.java | 11 +++++ .../integrations/IntegrationData.java | 22 ++++++--- .../integrations/IntegrationType.java | 17 ------- .../MinecraftIntegrationData.java | 20 +------- .../StandardIntegrationTypes.java | 8 +++ 12 files changed, 164 insertions(+), 83 deletions(-) create mode 100644 src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java create mode 100644 src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java create mode 100644 src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java create mode 100644 src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java create mode 100644 src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java delete mode 100644 src/com/namelessmc/java_api/integrations/IntegrationType.java create mode 100644 src/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 7321834e..ea595a04 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -283,8 +283,8 @@ public NamelessUser getUserLazyDiscord(final long discordId) { JsonObject integrationsJson = new JsonObject(); for (IntegrationData integration : integrationData) { JsonObject integrationJson = new JsonObject(); - integrationJson.addProperty("id", integration.getRawId()); - integrationJson.addProperty("username", integration.getRawUsername()); + integrationJson.addProperty("identifier", integration.getIdentifier()); + integrationJson.addProperty("username", integration.getUsername()); integrationsJson.add(integration.getIntegrationType().toString(), integrationJson); } post.add("integrations", integrationsJson); @@ -484,7 +484,7 @@ public void verifyDiscord(final @NotNull String verificationCode, * @param uuid UUID without dashes * @return UUID with dashes */ - static @NotNull UUID websiteUuidToJavaUuid(@NotNull final String uuid) { + public static @NotNull UUID websiteUuidToJavaUuid(@NotNull final String uuid) { Objects.requireNonNull(uuid, "UUID string is null"); // Website sends UUIDs without dashes, so we can't use UUID#fromString // https://stackoverflow.com/a/30760478 diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 8007bbae..b8ed2bc0 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -8,6 +8,7 @@ import com.namelessmc.java_api.exception.AlreadyHasOpenReportException; import com.namelessmc.java_api.exception.CannotReportSelfException; import com.namelessmc.java_api.exception.ReportUserBannedException; +import com.namelessmc.java_api.integrations.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -134,27 +135,6 @@ public void updateUsername(final @NotNull String username) throws NamelessExcept this.requests.post("users/" + this.getUserTransformer() + "/update-username", post); } - public @NotNull Optional<@NotNull UUID> getUniqueId() throws NamelessException { - if (!this.uuidKnown) { - JsonObject userInfo = this.getUserInfo(); - if (userInfo.has("uuid")) { - final String uuidString = userInfo.get("uuid").getAsString(); - if (uuidString == null || - uuidString.equals("none") || - uuidString.equals("")) { - this.uuid = null; - } else { - this.uuid = NamelessAPI.websiteUuidToJavaUuid(uuidString); - } - } else { - this.uuid = null; - } - this.uuidKnown = true; - } - - return Optional.ofNullable(this.uuid); - } - public @NotNull Optional<@NotNull Long> getDiscordId() throws NamelessException { if (!this.discordIdKnown) { JsonObject userInfo = this.getUserInfo(); @@ -449,4 +429,27 @@ public void banUser() throws NamelessException { return fieldValues; } + public Map getIntegrations() throws NamelessException { + final JsonObject userInfo = this.getUserInfo(); + final JsonArray integrationsJsonArray = userInfo.getAsJsonArray("integrations"); + Map integrationDataMap = new HashMap<>(integrationsJsonArray.size()); + for (JsonElement integrationElement : integrationsJsonArray) { + JsonObject integrationJson = integrationElement.getAsJsonObject(); + String integrationName = integrationJson.get("integration").getAsString(); + DetailedIntegrationData integrationData; + switch(integrationName) { + case StandardIntegrationTypes.MINECRAFT: + integrationData = new DetailedMinecraftIntegrationData(integrationJson); + break; + case StandardIntegrationTypes.DISCORD: + integrationData = new DetailedDiscordIntegrationData(integrationJson); + break; + default: + integrationData = new DetailedIntegrationData(integrationJson); + } + integrationDataMap.put(integrationName, integrationData); + } + return integrationDataMap; + } + } diff --git a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java new file mode 100644 index 00000000..798e18b7 --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java @@ -0,0 +1,19 @@ +package com.namelessmc.java_api.integrations; + +import com.google.gson.JsonObject; +import org.jetbrains.annotations.NotNull; + +public class DetailedDiscordIntegrationData extends DetailedIntegrationData implements IDiscordIntegrationData { + + private final long idLong; + + public DetailedDiscordIntegrationData(@NotNull JsonObject json) { + super(json); + this.idLong = Integer.parseInt(this.getIdentifier()); + } + + @Override + public long getIdLong() { + return this.idLong; + } +} diff --git a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java new file mode 100644 index 00000000..77e607d4 --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java @@ -0,0 +1,49 @@ +package com.namelessmc.java_api.integrations; + +import com.google.gson.JsonObject; +import org.jetbrains.annotations.NotNull; + +import java.util.Date; + +public class DetailedIntegrationData extends IntegrationData { + + private final boolean verified; + private final @NotNull Date linkedDate; + private final boolean shownPublicly; + + public DetailedIntegrationData(final @NotNull String integrationType, + final @NotNull String identifier, + final @NotNull String username, + final boolean verified, + final @NotNull Date linkedDate, + final boolean shownPublicly) { + super(integrationType, identifier, username); + this.verified = verified; + this.linkedDate = linkedDate; + this.shownPublicly = shownPublicly; + } + + public DetailedIntegrationData(final @NotNull JsonObject json) { + this( + json.get("integration").getAsString(), + json.get("identifier").getAsString(), + json.get("username").getAsString(), + json.get("verified").getAsBoolean(), + new Date(json.get("linked_date").getAsLong()), + json.get("show_publicly").getAsBoolean() + ); + } + + public boolean isVerified() { + return verified; + } + + public @NotNull Date getLinkedDate() { + return this.linkedDate; + } + + public boolean isShownPublicly() { + return this.shownPublicly; + } + +} diff --git a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java new file mode 100644 index 00000000..31f9fe83 --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java @@ -0,0 +1,22 @@ +package com.namelessmc.java_api.integrations; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public class DetailedMinecraftIntegrationData extends DetailedIntegrationData implements IMinecraftIntegrationData { + + private final @NotNull UUID uuid; + + public DetailedMinecraftIntegrationData(@NotNull JsonObject json) { + super(json); + this.uuid = NamelessAPI.websiteUuidToJavaUuid(this.getIdentifier()); + } + + @Override + public @NotNull UUID getUniqueId() { + return this.uuid; + } +} diff --git a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java index 7b17f81c..b3e6c519 100644 --- a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java @@ -5,30 +5,15 @@ public class DiscordIntegrationData extends IntegrationData { private final long id; - private final @NotNull String username; public DiscordIntegrationData(final long id, - @NotNull String username) { - super(IntegrationType.DISCORD); + final @NotNull String username) { + super(StandardIntegrationTypes.DISCORD, String.valueOf(id), username); this.id = id; - this.username = username; } - public long getId() { + public long getIdLong() { return this.id; } - public @NotNull String getUsername() { - return this.getUsername(); - } - - @Override - public @NotNull String getRawId() { - return String.valueOf(this.id); - } - - @Override - public @NotNull String getRawUsername() { - return this.username; - } } diff --git a/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java new file mode 100644 index 00000000..7635ebe0 --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java @@ -0,0 +1,7 @@ +package com.namelessmc.java_api.integrations; + +public interface IDiscordIntegrationData { + + long getIdLong(); + +} diff --git a/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java new file mode 100644 index 00000000..1385831d --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java @@ -0,0 +1,11 @@ +package com.namelessmc.java_api.integrations; + +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public interface IMinecraftIntegrationData { + + @NotNull UUID getUniqueId(); + +} diff --git a/src/com/namelessmc/java_api/integrations/IntegrationData.java b/src/com/namelessmc/java_api/integrations/IntegrationData.java index c2518577..84aa07c8 100644 --- a/src/com/namelessmc/java_api/integrations/IntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/IntegrationData.java @@ -2,20 +2,30 @@ import org.jetbrains.annotations.NotNull; -public abstract class IntegrationData { +public class IntegrationData { - private final @NotNull IntegrationType integrationType; + private final @NotNull String integrationType; + private final @NotNull String identifier; + private final @NotNull String username; - IntegrationData(final @NotNull IntegrationType integrationType) { + public IntegrationData(final @NotNull String integrationType, + final @NotNull String identifier, + final @NotNull String username) { this.integrationType = integrationType; + this.identifier = identifier; + this.username = username; } - public @NotNull IntegrationType getIntegrationType() { + public @NotNull String getIntegrationType() { return this.integrationType; } - public abstract @NotNull String getRawId(); + public @NotNull String getIdentifier() { + return this.identifier; + } - public abstract @NotNull String getRawUsername(); + public @NotNull String getUsername() { + return this.username; + } } diff --git a/src/com/namelessmc/java_api/integrations/IntegrationType.java b/src/com/namelessmc/java_api/integrations/IntegrationType.java deleted file mode 100644 index 2bcd26ce..00000000 --- a/src/com/namelessmc/java_api/integrations/IntegrationType.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.namelessmc.java_api.integrations; - -import java.util.Locale; - -public enum IntegrationType { - - MINECRAFT, - DISCORD, - ; - - - @Override - public String toString() { - return this.name().toLowerCase(Locale.ROOT); - } - -} diff --git a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java index a17d7450..d8544a7f 100644 --- a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java @@ -4,34 +4,18 @@ import java.util.UUID; -public class MinecraftIntegrationData extends IntegrationData { +public class MinecraftIntegrationData extends IntegrationData implements IMinecraftIntegrationData { private final @NotNull UUID uuid; - private final @NotNull String username; public MinecraftIntegrationData(final @NotNull UUID uuid, final @NotNull String username) { - super(IntegrationType.MINECRAFT); + super(StandardIntegrationTypes.MINECRAFT, uuid.toString(), username); this.uuid = uuid; - this.username = username; } public @NotNull UUID getUniqueId() { return this.uuid; } - public @NotNull String getUsername() { - return this.username; - } - - @Override - public @NotNull String getRawId() { - return this.uuid.toString(); - } - - @Override - public @NotNull String getRawUsername() { - return this.username; - } - } diff --git a/src/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java b/src/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java new file mode 100644 index 00000000..f94d0b74 --- /dev/null +++ b/src/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java @@ -0,0 +1,8 @@ +package com.namelessmc.java_api.integrations; + +public class StandardIntegrationTypes { + + public static final String MINECRAFT = "Minecraft"; + public static final String DISCORD = "Discord"; + +} From 40935944ac727008bbcc427f294b07930b8815de Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 4 Apr 2022 20:41:35 +0200 Subject: [PATCH 010/269] Add integration user filter --- src/com/namelessmc/java_api/UserFilter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/namelessmc/java_api/UserFilter.java b/src/com/namelessmc/java_api/UserFilter.java index 204f8fbb..9ed467ce 100644 --- a/src/com/namelessmc/java_api/UserFilter.java +++ b/src/com/namelessmc/java_api/UserFilter.java @@ -8,6 +8,7 @@ public class UserFilter { public static UserFilter VERIFIED = new UserFilter<>("verified"); public static UserFilter DISCORD_LINKED = new UserFilter<>("discord_linked"); public static UserFilter GROUP_ID = new UserFilter<>("group_id"); + public static UserFilter INTEGRATION = new UserFilter<>("integration"); private final @NotNull String filterName; From ee103ebc98dd74146dcf8f5edd02a4bfd52b0d33 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 4 Apr 2022 20:44:48 +0200 Subject: [PATCH 011/269] Remove discord_linked filter --- src/com/namelessmc/java_api/UserFilter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/com/namelessmc/java_api/UserFilter.java b/src/com/namelessmc/java_api/UserFilter.java index 9ed467ce..5c37ab31 100644 --- a/src/com/namelessmc/java_api/UserFilter.java +++ b/src/com/namelessmc/java_api/UserFilter.java @@ -6,7 +6,6 @@ public class UserFilter { public static UserFilter BANNED = new UserFilter<>("banned"); public static UserFilter VERIFIED = new UserFilter<>("verified"); - public static UserFilter DISCORD_LINKED = new UserFilter<>("discord_linked"); public static UserFilter GROUP_ID = new UserFilter<>("group_id"); public static UserFilter INTEGRATION = new UserFilter<>("integration"); From 82456db307d0e120085d3dbe54a6a87a3fd85d88 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 5 Apr 2022 23:25:24 +0200 Subject: [PATCH 012/269] Methanol for transparent decompression support! --- pom.xml | 6 ++ src/com/namelessmc/java_api/NamelessAPI.java | 36 ++++---- .../java_api/NamelessApiBuilder.java | 90 +++++++++++++++---- .../namelessmc/java_api/RequestHandler.java | 40 ++------- 4 files changed, 101 insertions(+), 71 deletions(-) diff --git a/pom.xml b/pom.xml index 2af7c983..5bf9e507 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,12 @@ 23.0.0 + + com.github.mizosoft.methanol + methanol + 1.6.0 + + diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index ea595a04..bc3779a2 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -33,24 +33,24 @@ RequestHandler getRequestHandler() { return this.requests; } - @NotNull - public URL getApiUrl() { - return this.getRequestHandler().getApiUrl(); - } - - @NotNull - public String getApiKey() { - return getApiKey(this.getApiUrl().toString()); - } - - @NotNull - static String getApiKey(@NotNull final String url) { - if (url.endsWith("/")) { - return getApiKey(url.substring(0, url.length() - 1)); - } - - return url.substring(url.lastIndexOf('/') + 1); - } +// @NotNull +// public URL getApiUrl() { +// return this.getRequestHandler().getApiUrl(); +// } +// +// @NotNull +// public String getApiKey() { +// return getApiKey(this.getApiUrl().toString()); +// } + +// @NotNull +// static String getApiKey(@NotNull final String url) { +// if (url.endsWith("/")) { +// return getApiKey(url.substring(0, url.length() - 1)); +// } +// +// return url.substring(url.lastIndexOf('/') + 1); +// } /** * Get announcements visible to guests. Use {@link NamelessUser#getAnnouncements()} for non-guest announcements. diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index e2f4ae00..472573fd 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -1,5 +1,6 @@ package com.namelessmc.java_api; +import com.github.mizosoft.methanol.Methanol; import com.google.gson.GsonBuilder; import com.namelessmc.java_api.logger.ApiLogger; import com.namelessmc.java_api.logger.PrintStreamLogger; @@ -10,9 +11,8 @@ import java.net.Authenticator; import java.net.ProxySelector; import java.net.URL; -import java.net.http.HttpClient; import java.time.Duration; -import java.util.Objects; +import java.util.concurrent.Executor; public class NamelessApiBuilder { @@ -20,25 +20,27 @@ public class NamelessApiBuilder { private static final String DEFAULT_USER_AGENT = "Nameless-Java-API"; private static final int DEFAULT_RESPONSE_SIZE_LIMIT = 32*1024*1024; - private final @NotNull URL apiUrl; - private final @NotNull String apiKey; - private final @NotNull HttpClient.Builder httpClientBuilder; private final @NotNull GsonBuilder gsonBuilder; - private @NotNull String userAgent = DEFAULT_USER_AGENT; private @Nullable ApiLogger debugLogger = null; - private @Nullable Duration timeout = DEFAULT_TIMEOUT; + private final @NotNull Methanol.Builder httpClientBuilder; private int responseSizeLimit = DEFAULT_RESPONSE_SIZE_LIMIT; NamelessApiBuilder(@NotNull URL apiUrl, @NotNull String apiKey) { - this.apiUrl = apiUrl; - this.apiKey = apiKey; - this.httpClientBuilder = HttpClient.newBuilder(); this.gsonBuilder = new GsonBuilder(); this.gsonBuilder.disableHtmlEscaping(); + + this.httpClientBuilder = Methanol.newBuilder() + .baseUri(apiUrl + "/") + .defaultHeader("X-Api-Key", apiKey) + .userAgent(DEFAULT_USER_AGENT) + .readTimeout(DEFAULT_TIMEOUT) + .requestTimeout(DEFAULT_TIMEOUT) + .connectTimeout(DEFAULT_TIMEOUT) + .autoAcceptEncoding(true); } public @NotNull NamelessApiBuilder userAgent(@NotNull final String userAgent) { - this.userAgent = Objects.requireNonNull(userAgent, "User agent is null"); + this.httpClientBuilder.userAgent(userAgent); return this; } @@ -51,29 +53,56 @@ public class NamelessApiBuilder { } } + @Deprecated public @NotNull NamelessApiBuilder withStdErrDebugLogging() { this.debugLogger = PrintStreamLogger.DEFAULT_INSTANCE; return this; } + public @NotNull NamelessApiBuilder stdErrDebugLogger() { + this.debugLogger = PrintStreamLogger.DEFAULT_INSTANCE; + return this; + } + + @Deprecated public @NotNull NamelessApiBuilder withSlf4jDebugLogging() { this.debugLogger = Slf4jLogger.DEFAULT_INSTANCE; return this; } + public @NotNull NamelessApiBuilder slf4jDebugLogger() { + this.debugLogger = Slf4jLogger.DEFAULT_INSTANCE; + return this; + } + + @Deprecated public @NotNull NamelessApiBuilder withCustomDebugLogger(final @Nullable ApiLogger debugLogger) { this.debugLogger = debugLogger; return this; } + public @NotNull NamelessApiBuilder customDebugLogger(final @Nullable ApiLogger debugLogger) { + this.debugLogger = debugLogger; + return this; + } + @Deprecated public @NotNull NamelessApiBuilder withTimeoutMillis(final int timeout) { - this.timeout = Duration.ofMillis(timeout); + return this.withTimeout(Duration.ofMillis(timeout)); + } + + @Deprecated + public @NotNull NamelessApiBuilder withTimeout(final @NotNull Duration timeout) { + this.httpClientBuilder.readTimeout(timeout) + .requestTimeout(timeout) + .connectTimeout(timeout); return this; } - public @NotNull NamelessApiBuilder withTimeout(final @Nullable Duration timeout) { - this.timeout = timeout; + public @NotNull NamelessApiBuilder timeout(final @NotNull Duration timeout) { + this.httpClientBuilder.readTimeout(timeout) + .requestTimeout(timeout) + .connectTimeout(timeout); return this; } @@ -82,31 +111,56 @@ public class NamelessApiBuilder { return this; } + @Deprecated + public @NotNull NamelessApiBuilder proxy(ProxySelector proxy) { + this.httpClientBuilder.proxy(proxy); + return this; + } + + @Deprecated public @NotNull NamelessApiBuilder withAuthenticator(Authenticator authenticator) { this.httpClientBuilder.authenticator(authenticator); return this; } + public @NotNull NamelessApiBuilder authenticator(Authenticator authenticator) { + this.httpClientBuilder.authenticator(authenticator); + return this; + } + + @Deprecated public @NotNull NamelessApiBuilder withPrettyJson() { gsonBuilder.setPrettyPrinting(); return this; } + public @NotNull NamelessApiBuilder pettyJsonRequests() { + gsonBuilder.setPrettyPrinting(); + return this; + } + + @Deprecated public @NotNull NamelessApiBuilder withResponseSizeLimit(int responseSizeLimitBytes) { this.responseSizeLimit = responseSizeLimitBytes; return this; } + public @NotNull NamelessApiBuilder responseSizeLimit(int responseSizeLimitBytes) { + this.responseSizeLimit = responseSizeLimitBytes; + return this; + } + + public @NotNull NamelessApiBuilder executor(final @NotNull Executor executor) { + this.httpClientBuilder.executor(executor); + return this; + } + public @NotNull NamelessAPI build() { return new NamelessAPI( new RequestHandler( - this.apiUrl, - this.apiKey, this.httpClientBuilder.build(), this.gsonBuilder.create(), - this.userAgent, this.debugLogger, - this.timeout, this.responseSizeLimit ) ); diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index e324d697..acddbfcf 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -1,5 +1,6 @@ package com.namelessmc.java_api; +import com.github.mizosoft.methanol.Methanol; import com.google.common.base.Ascii; import com.google.common.base.Preconditions; import com.google.common.io.ByteStreams; @@ -16,13 +17,10 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; -import java.net.URL; import java.net.URLEncoder; -import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; -import java.time.Duration; import java.util.Arrays; import java.util.Objects; import java.util.function.Supplier; @@ -30,53 +28,31 @@ public class RequestHandler { - private final @NotNull URL baseUrl; - private final @NotNull String apiKey; - private final @NotNull HttpClient httpClient; - private final @NotNull String userAgent; + private final @NotNull Methanol httpClient; private final @Nullable ApiLogger debugLogger; - private final @Nullable Duration timeout; private final @NotNull Gson gson; private final int responseLengthLimit; - RequestHandler(final @NotNull URL baseUrl, - final @NotNull String apiKey, - final @NotNull HttpClient httpClient, + RequestHandler(final @NotNull Methanol httpClient, final @NotNull Gson gson, - final @NotNull String userAgent, final @Nullable ApiLogger debugLogger, - final @Nullable Duration timeout, final int responseLengthLimit) { - this.baseUrl = Objects.requireNonNull(baseUrl, "Base URL is null"); - this.apiKey = Objects.requireNonNull(apiKey, "Api key is null"); this.httpClient = Objects.requireNonNull(httpClient, "http client is null"); this.gson = gson; - this.userAgent = Objects.requireNonNull(userAgent, "User agent is null"); this.debugLogger = debugLogger; - this.timeout = timeout; this.responseLengthLimit = responseLengthLimit; } - public @NotNull URL getApiUrl() { - return this.baseUrl; - } - - public @NotNull String getApiKey() { - return this.apiKey; - } - public @NotNull JsonObject post(final @NotNull String route, final @Nullable JsonObject postData) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); - URI uri = URI.create(this.baseUrl + "/" + route); + URI uri = URI.create(route); return makeConnection(uri, postData); } public @NotNull JsonObject get(final @NotNull String route, final @NotNull Object @NotNull... parameters) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); - final StringBuilder urlBuilder = new StringBuilder(this.baseUrl.toString()); - urlBuilder.append("/"); - urlBuilder.append(route); + final StringBuilder urlBuilder = new StringBuilder(route); if (parameters.length > 0) { if (parameters.length % 2 != 0) { @@ -111,9 +87,6 @@ private void debug(final @NotNull String message, @NotNull Supplier ar private @NotNull JsonObject makeConnection(final URI uri, final @Nullable JsonObject postBody) throws NamelessException { HttpRequest.Builder reqBuilder = HttpRequest.newBuilder(uri); - if (timeout != null) { - reqBuilder.timeout(timeout); - } debug("Making connection %s to url %s", () -> new Object[]{ postBody != null ? "POST" : "GET", uri}); @@ -128,9 +101,6 @@ private void debug(final @NotNull String message, @NotNull Supplier ar reqBuilder.GET(); } - reqBuilder.header("User-Agent", this.userAgent); - reqBuilder.header("X-API-Key", this.apiKey); - HttpRequest httpRequest = reqBuilder.build(); int statusCode; From f677d54cb974084039f06916cd3c705272ceac97 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 5 Apr 2022 23:29:58 +0200 Subject: [PATCH 013/269] do provide api key and url for third parties --- src/com/namelessmc/java_api/NamelessAPI.java | 41 +++++++++---------- .../java_api/NamelessApiBuilder.java | 10 ++++- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index bc3779a2..3f5216f9 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -24,33 +24,32 @@ public final class NamelessAPI { @NotNull private final RequestHandler requests; - NamelessAPI(@NotNull final RequestHandler requests) { + // Not actually used by the Nameless Java API, but could be useful to applications using it. + private final @NotNull URL apiUrl; + private final @NotNull String apiKey; + + NamelessAPI(final @NotNull RequestHandler requests, + final @NotNull URL apiUrl, + final @NotNull String apiKey) { this.requests = Objects.requireNonNull(requests, "Request handler is null"); + this.apiUrl = apiUrl; + this.apiKey = apiKey; } - @NotNull - RequestHandler getRequestHandler() { + + @NotNull RequestHandler getRequestHandler() { return this.requests; } -// @NotNull -// public URL getApiUrl() { -// return this.getRequestHandler().getApiUrl(); -// } -// -// @NotNull -// public String getApiKey() { -// return getApiKey(this.getApiUrl().toString()); -// } - -// @NotNull -// static String getApiKey(@NotNull final String url) { -// if (url.endsWith("/")) { -// return getApiKey(url.substring(0, url.length() - 1)); -// } -// -// return url.substring(url.lastIndexOf('/') + 1); -// } + + public @NotNull URL getApiUrl() { + return this.apiUrl; + } + + + public @NotNull String getApiKey() { + return this.apiKey; + } /** * Get announcements visible to guests. Use {@link NamelessUser#getAnnouncements()} for non-guest announcements. diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 472573fd..1525bf3c 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -20,12 +20,18 @@ public class NamelessApiBuilder { private static final String DEFAULT_USER_AGENT = "Nameless-Java-API"; private static final int DEFAULT_RESPONSE_SIZE_LIMIT = 32*1024*1024; + private final @NotNull URL apiUrl; + private final @NotNull String apiKey; + private final @NotNull GsonBuilder gsonBuilder; private @Nullable ApiLogger debugLogger = null; private final @NotNull Methanol.Builder httpClientBuilder; private int responseSizeLimit = DEFAULT_RESPONSE_SIZE_LIMIT; NamelessApiBuilder(@NotNull URL apiUrl, @NotNull String apiKey) { + this.apiUrl = apiUrl; + this.apiKey = apiKey; + this.gsonBuilder = new GsonBuilder(); this.gsonBuilder.disableHtmlEscaping(); @@ -162,7 +168,9 @@ public class NamelessApiBuilder { this.gsonBuilder.create(), this.debugLogger, this.responseSizeLimit - ) + ), + this.apiUrl, + this.apiKey ); } From 01ce0f13d142c5bb0888d6e2b13c2370665a615f Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 6 Apr 2022 15:17:08 +0200 Subject: [PATCH 014/269] Fix baseUri not being prepended to request uri --- .../java_api/NamelessApiBuilder.java | 21 ++++++++++------ .../namelessmc/java_api/RequestHandler.java | 25 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 1525bf3c..84743113 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -10,6 +10,7 @@ import java.net.Authenticator; import java.net.ProxySelector; +import java.net.URISyntaxException; import java.net.URL; import java.time.Duration; import java.util.concurrent.Executor; @@ -35,14 +36,18 @@ public class NamelessApiBuilder { this.gsonBuilder = new GsonBuilder(); this.gsonBuilder.disableHtmlEscaping(); - this.httpClientBuilder = Methanol.newBuilder() - .baseUri(apiUrl + "/") - .defaultHeader("X-Api-Key", apiKey) - .userAgent(DEFAULT_USER_AGENT) - .readTimeout(DEFAULT_TIMEOUT) - .requestTimeout(DEFAULT_TIMEOUT) - .connectTimeout(DEFAULT_TIMEOUT) - .autoAcceptEncoding(true); + try { + this.httpClientBuilder = Methanol.newBuilder() + .baseUri(apiUrl.toURI()) + .defaultHeader("X-Api-Key", apiKey) + .userAgent(DEFAULT_USER_AGENT) + .readTimeout(DEFAULT_TIMEOUT) + .requestTimeout(DEFAULT_TIMEOUT) + .connectTimeout(DEFAULT_TIMEOUT) + .autoAcceptEncoding(true); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } } public @NotNull NamelessApiBuilder userAgent(@NotNull final String userAgent) { diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index acddbfcf..40e0730a 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -1,6 +1,7 @@ package com.namelessmc.java_api; import com.github.mizosoft.methanol.Methanol; +import com.github.mizosoft.methanol.MutableRequest; import com.google.common.base.Ascii; import com.google.common.base.Preconditions; import com.google.common.io.ByteStreams; @@ -43,13 +44,15 @@ public class RequestHandler { this.responseLengthLimit = responseLengthLimit; } - public @NotNull JsonObject post(final @NotNull String route, final @Nullable JsonObject postData) throws NamelessException { + public @NotNull JsonObject post(final @NotNull String route, + final @Nullable JsonObject postData) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); URI uri = URI.create(route); return makeConnection(uri, postData); } - public @NotNull JsonObject get(final @NotNull String route, final @NotNull Object @NotNull... parameters) throws NamelessException { + public @NotNull JsonObject get(final @NotNull String route, + final @NotNull Object @NotNull... parameters) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); final StringBuilder urlBuilder = new StringBuilder(route); @@ -79,34 +82,34 @@ public class RequestHandler { return makeConnection(uri, null); } - private void debug(final @NotNull String message, @NotNull Supplier argsSupplier) { + private void debug(final @NotNull String message, + final @NotNull Supplier argsSupplier) { if (this.debugLogger != null) { this.debugLogger.log(String.format(message, argsSupplier.get())); } } - private @NotNull JsonObject makeConnection(final URI uri, final @Nullable JsonObject postBody) throws NamelessException { - HttpRequest.Builder reqBuilder = HttpRequest.newBuilder(uri); + private @NotNull JsonObject makeConnection(final @NotNull URI uri, + final @Nullable JsonObject postBody) throws NamelessException { + MutableRequest request = MutableRequest.create(uri); debug("Making connection %s to url %s", () -> new Object[]{ postBody != null ? "POST" : "GET", uri}); if (postBody != null) { byte[] postBytes = gson.toJson(postBody).getBytes(StandardCharsets.UTF_8); - reqBuilder.POST(HttpRequest.BodyPublishers.ofByteArray(postBytes)); - reqBuilder.header("Content-Type", "application/json"); + request.POST(HttpRequest.BodyPublishers.ofByteArray(postBytes)); + request.header("Content-Type", "application/json"); debug("Post body below\n-----------------\n%s\n-----------------", () -> new Object[] { new String(postBytes, StandardCharsets.UTF_8) }); } else { - reqBuilder.GET(); + request.GET(); } - HttpRequest httpRequest = reqBuilder.build(); - int statusCode; String responseBody; try { - HttpResponse httpResponse = httpClient.send(httpRequest, + HttpResponse httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); statusCode = httpResponse.statusCode(); responseBody = getBodyAsString(httpResponse); From 33cb929b7749346f2dce1d9a1d4068fba34ac962 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 6 Apr 2022 15:32:02 +0200 Subject: [PATCH 015/269] can't use baseUri provided by methanol --- .../java_api/NamelessApiBuilder.java | 34 +++++++++---------- src/com/namelessmc/java_api/NamelessUser.java | 2 +- .../namelessmc/java_api/RequestHandler.java | 25 +++++++------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 84743113..f31411b3 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -8,10 +8,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.net.Authenticator; -import java.net.ProxySelector; -import java.net.URISyntaxException; -import java.net.URL; +import java.net.*; import java.time.Duration; import java.util.concurrent.Executor; @@ -29,25 +26,25 @@ public class NamelessApiBuilder { private final @NotNull Methanol.Builder httpClientBuilder; private int responseSizeLimit = DEFAULT_RESPONSE_SIZE_LIMIT; - NamelessApiBuilder(@NotNull URL apiUrl, @NotNull String apiKey) { - this.apiUrl = apiUrl; + NamelessApiBuilder(final @NotNull URL apiUrl, + final @NotNull String apiKey) { + try { + this.apiUrl = apiUrl.toString().endsWith("/") ? apiUrl : new URL(apiUrl + "/"); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } this.apiKey = apiKey; this.gsonBuilder = new GsonBuilder(); this.gsonBuilder.disableHtmlEscaping(); - try { - this.httpClientBuilder = Methanol.newBuilder() - .baseUri(apiUrl.toURI()) - .defaultHeader("X-Api-Key", apiKey) - .userAgent(DEFAULT_USER_AGENT) - .readTimeout(DEFAULT_TIMEOUT) - .requestTimeout(DEFAULT_TIMEOUT) - .connectTimeout(DEFAULT_TIMEOUT) - .autoAcceptEncoding(true); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } + this.httpClientBuilder = Methanol.newBuilder() + .defaultHeader("X-Api-Key", this.apiKey) + .userAgent(DEFAULT_USER_AGENT) + .readTimeout(DEFAULT_TIMEOUT) + .requestTimeout(DEFAULT_TIMEOUT) + .connectTimeout(DEFAULT_TIMEOUT) + .autoAcceptEncoding(true); } public @NotNull NamelessApiBuilder userAgent(@NotNull final String userAgent) { @@ -169,6 +166,7 @@ public class NamelessApiBuilder { public @NotNull NamelessAPI build() { return new NamelessAPI( new RequestHandler( + this.apiUrl, this.httpClientBuilder.build(), this.gsonBuilder.create(), this.debugLogger, diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index b8ed2bc0..0be0d93b 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -400,7 +400,7 @@ public void setDiscordRoles(final long@NotNull[] roleIds) throws NamelessExcepti * @since 2021-10-24 commit cce8d262b0be3f70818c188725cd7e7fc4fdbb9a */ public void banUser() throws NamelessException { - this.requests.post("users/" + this.getUserTransformer() + "/ban", null); + this.requests.post("users/" + this.getUserTransformer() + "/ban", new JsonObject()); } public @NotNull Collection<@NotNull CustomProfileFieldValue> getProfileFields() throws NamelessException { diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 40e0730a..dd8363b9 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -18,6 +18,7 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; +import java.net.URL; import java.net.URLEncoder; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -29,15 +30,18 @@ public class RequestHandler { + private final @NotNull URL apiUrl; private final @NotNull Methanol httpClient; private final @Nullable ApiLogger debugLogger; private final @NotNull Gson gson; private final int responseLengthLimit; - RequestHandler(final @NotNull Methanol httpClient, + RequestHandler(final @NotNull URL apiUrl, + final @NotNull Methanol httpClient, final @NotNull Gson gson, final @Nullable ApiLogger debugLogger, final int responseLengthLimit) { + this.apiUrl = Objects.requireNonNull(apiUrl, "API URL is null"); this.httpClient = Objects.requireNonNull(httpClient, "http client is null"); this.gson = gson; this.debugLogger = debugLogger; @@ -45,16 +49,12 @@ public class RequestHandler { } public @NotNull JsonObject post(final @NotNull String route, - final @Nullable JsonObject postData) throws NamelessException { - Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); - URI uri = URI.create(route); - return makeConnection(uri, postData); + final @NotNull JsonObject postData) throws NamelessException { + return makeConnection(route, postData); } public @NotNull JsonObject get(final @NotNull String route, final @NotNull Object @NotNull... parameters) throws NamelessException { - Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); - final StringBuilder urlBuilder = new StringBuilder(route); if (parameters.length > 0) { @@ -78,8 +78,7 @@ public class RequestHandler { } } - final @NotNull URI uri = URI.create(urlBuilder.toString()); - return makeConnection(uri, null); + return makeConnection(urlBuilder.toString(), null); } private void debug(final @NotNull String message, @@ -89,11 +88,13 @@ private void debug(final @NotNull String message, } } - private @NotNull JsonObject makeConnection(final @NotNull URI uri, + private @NotNull JsonObject makeConnection(final @NotNull String route, final @Nullable JsonObject postBody) throws NamelessException { - MutableRequest request = MutableRequest.create(uri); + Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); + final MutableRequest request = MutableRequest.create(URI.create(this.apiUrl.toString() + route)); - debug("Making connection %s to url %s", () -> new Object[]{ postBody != null ? "POST" : "GET", uri}); + debug("Making connection %s to %s", + () -> new Object[]{ postBody != null ? "POST" : "GET", request.uri()}); if (postBody != null) { byte[] postBytes = gson.toJson(postBody).getBytes(StandardCharsets.UTF_8); From a338f83db47ad96ab1215b348d53eb363aad381b Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 6 Apr 2022 17:23:07 +0200 Subject: [PATCH 016/269] Remove duplicate integration type class --- .../namelessmc/java_api/IntegrationType.java | 21 --------------- src/com/namelessmc/java_api/NamelessAPI.java | 26 +++++-------------- 2 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 src/com/namelessmc/java_api/IntegrationType.java diff --git a/src/com/namelessmc/java_api/IntegrationType.java b/src/com/namelessmc/java_api/IntegrationType.java deleted file mode 100644 index 40e541ed..00000000 --- a/src/com/namelessmc/java_api/IntegrationType.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.namelessmc.java_api; - -import org.jetbrains.annotations.NotNull; - -public enum IntegrationType { - - MINECRAFT("Minecraft"), - DISCORD("Discord"), - ; - - private final @NotNull String apiValue; - - IntegrationType(final @NotNull String apiValue) { - this.apiValue = apiValue; - } - - public @NotNull String apiValue() { - return apiValue; - } - -} diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 3f5216f9..b6bd16e2 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -440,15 +440,14 @@ public void updateDiscordUsernames(final long@NotNull[] discordUserIds, this.requests.post("discord/update-usernames", json); } - private void verifyIntegration(final @NotNull IntegrationType type, - final @NotNull String verificationCode, - final @NotNull String identifier, - final @NotNull String username) throws NamelessException, InvalidValidateCodeException { + public void verifyIntegration(final @NotNull IntegrationData integrationData, + final @NotNull String verificationCode) + throws NamelessException, InvalidValidateCodeException { JsonObject data = new JsonObject(); - data.addProperty("integration", type.apiValue()); + data.addProperty("integration", integrationData.getIntegrationType()); + data.addProperty("identifier", integrationData.getIdentifier()); + data.addProperty("username", integrationData.getUsername()); data.addProperty("code", Objects.requireNonNull(verificationCode, "Verification code is null")); - data.addProperty("identifier", Objects.requireNonNull(identifier, "Identifier is null")); - data.addProperty("username", Objects.requireNonNull(username, "Username is null")); try { this.requests.post("integration/verify", data); } catch (ApiError e) { @@ -461,23 +460,10 @@ private void verifyIntegration(final @NotNull IntegrationType type, } } - public void verifyMinecraft(final @NotNull String verificationCode, - final @NotNull UUID uuid, - final @NotNull String username) throws NamelessException, InvalidValidateCodeException { - this.verifyIntegration(IntegrationType.MINECRAFT, verificationCode, uuid.toString(), username); - } - - public void verifyDiscord(final @NotNull String verificationCode, - final long id, - final String username) throws NamelessException, InvalidValidateCodeException { - this.verifyIntegration(IntegrationType.DISCORD, verificationCode, String.valueOf(id), username); - } - public @NotNull WebsendAPI websend() { return new WebsendAPI(this.requests); } - /** * Adds back dashes to a UUID string and converts it to a Java UUID object * @param uuid UUID without dashes From 94129fdf8cd6cf5293ff082b19f3fd497f3b5ed1 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 6 Apr 2022 17:42:41 +0200 Subject: [PATCH 017/269] Restore convenience methods for getting discord/minecraft id --- src/com/namelessmc/java_api/NamelessUser.java | 87 ++++++++++++++----- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 0be0d93b..002cbf18 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -30,8 +30,10 @@ public final class NamelessUser implements LanguageEntity { private boolean discordIdKnown; private long discordId; // -1 if not known or not present - @Nullable - private JsonObject _userInfo; // Do not use directly, instead use getUserInfo() + // Do not use directly, instead use getUserInfo() and getIntegrations() + private @Nullable JsonObject _cachedUserInfo; + private @Nullable Map _cachedIntegrationData; + /** * Create a Nameless user. Only one of 'id', 'uuid', 'discordId' has to be provided. @@ -67,17 +69,17 @@ public final class NamelessUser implements LanguageEntity { } private JsonObject getUserInfo() throws NamelessException { - if (this._userInfo == null) { + if (this._cachedUserInfo == null) { final JsonObject response = this.requests.get("users/" + this.getUserTransformer()); if (!response.get("exists").getAsBoolean()) { throw new UserNotExistException(); } - this._userInfo = response; + this._cachedUserInfo = response; } - return this._userInfo; + return this._cachedUserInfo; } public String getUserTransformer() { @@ -110,7 +112,16 @@ public NamelessAPI getApi() { * effect. */ public void invalidateCache() { - this._userInfo = null; + this._cachedUserInfo = null; + this._cachedIntegrationData = null; + if (this.id != -1) { + // Only clear if we know the user's NamelessMC user id, otherwise we remove + // the only way to identify this user + this.uuidKnown = false; + this.uuid = null; + this.discordIdKnown = false; + this.username = null; + } } public int getId() throws NamelessException { @@ -135,21 +146,6 @@ public void updateUsername(final @NotNull String username) throws NamelessExcept this.requests.post("users/" + this.getUserTransformer() + "/update-username", post); } - public @NotNull Optional<@NotNull Long> getDiscordId() throws NamelessException { - if (!this.discordIdKnown) { - JsonObject userInfo = this.getUserInfo(); - //noinspection ConstantConditions - if (userInfo.has("discord_id")) { - this.discordId = userInfo.get("discord_id").getAsLong(); - } else { - this.discordId = -1; - } - this.discordIdKnown = true; - } - - return this.discordId > 0 ? Optional.of(this.discordId) : Optional.empty(); - } - public boolean exists() throws NamelessException { try { this.getUserInfo(); @@ -430,9 +426,13 @@ public void banUser() throws NamelessException { } public Map getIntegrations() throws NamelessException { + if (this._cachedIntegrationData != null) { + return this._cachedIntegrationData; + } + final JsonObject userInfo = this.getUserInfo(); final JsonArray integrationsJsonArray = userInfo.getAsJsonArray("integrations"); - Map integrationDataMap = new HashMap<>(integrationsJsonArray.size()); + this._cachedIntegrationData = new HashMap<>(integrationsJsonArray.size()); for (JsonElement integrationElement : integrationsJsonArray) { JsonObject integrationJson = integrationElement.getAsJsonObject(); String integrationName = integrationJson.get("integration").getAsString(); @@ -447,9 +447,48 @@ public Map getIntegrations() throws NamelessExc default: integrationData = new DetailedIntegrationData(integrationJson); } - integrationDataMap.put(integrationName, integrationData); + this._cachedIntegrationData.put(integrationName, integrationData); } - return integrationDataMap; + return this._cachedIntegrationData; + } + + public Optional getMinecraftUuid() throws NamelessException { + if (this.uuidKnown) { + return Optional.ofNullable(this.uuid); + } + + final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.MINECRAFT); + this.uuidKnown = true; + + if (integration == null) { + this.uuid = null; + } else { + this.uuid = ((IMinecraftIntegrationData) integration).getUniqueId(); + } + + return this.getMinecraftUuid(); + } + + public Optional getDiscordId() throws NamelessException { + if (this.discordIdKnown) { + if (this.discordId == -1) { + return Optional.empty(); + } else { + return Optional.of(this.discordId); + } + } + + final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.DISCORD); + + this.discordIdKnown = true; + if (integration == null) { + this.discordId = -1; + return Optional.empty(); + } else { + this.discordId = ((IDiscordIntegrationData) integration).getIdLong(); + } + + return this.getDiscordId(); } } From 561f5d61dadcd1e1a43d6230ef90ead398e85c2f Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 6 Apr 2022 19:58:40 +0200 Subject: [PATCH 018/269] no need for return here --- src/com/namelessmc/java_api/NamelessUser.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 002cbf18..408f6e4b 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -483,7 +483,6 @@ public Optional getDiscordId() throws NamelessException { this.discordIdKnown = true; if (integration == null) { this.discordId = -1; - return Optional.empty(); } else { this.discordId = ((IDiscordIntegrationData) integration).getIdLong(); } From 51c262c3e71972863f57f40fcfc6dc6ebd6f2a99 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 12 Apr 2022 23:08:46 +0200 Subject: [PATCH 019/269] Handle unable to find user error --- src/com/namelessmc/java_api/NamelessUser.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 408f6e4b..0de9e9ba 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -70,7 +70,16 @@ public final class NamelessUser implements LanguageEntity { private JsonObject getUserInfo() throws NamelessException { if (this._cachedUserInfo == null) { - final JsonObject response = this.requests.get("users/" + this.getUserTransformer()); + final JsonObject response; + try { + response = this.requests.get("users/" + this.getUserTransformer()); + } catch (final ApiError e) { + if (e.getError() == ApiError.UNABLE_TO_FIND_USER) { + throw new UserNotExistException(); + } else { + throw e; + } + } if (!response.get("exists").getAsBoolean()) { throw new UserNotExistException(); From 025a8766e174a36313efcd754d5422ae011b3995 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 14 Apr 2022 22:53:38 +0200 Subject: [PATCH 020/269] Exception message is nullable --- src/com/namelessmc/java_api/RequestHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index dd8363b9..5dfa8320 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -115,8 +115,10 @@ private void debug(final @NotNull String message, statusCode = httpResponse.statusCode(); responseBody = getBodyAsString(httpResponse); } catch (final IOException e) { + final @Nullable String exceptionMessage = e.getMessage(); final StringBuilder message = new StringBuilder("Network connection error (not a Nameless issue)."); - if (e.getMessage().contains("unable to find valid certification path to requested target")) { + if (exceptionMessage != null && + exceptionMessage.contains("unable to find valid certification path to requested target")) { message.append("\n HINT: Your certificate is invalid or incomplete. Ensure your website uses a valid *full chain* SSL/TLS certificate."); } message.append(" IOException: "); From 4c0fdd2fb001151a480e2c7ca34ae99a7778d489 Mon Sep 17 00:00:00 2001 From: Hyfalls Date: Fri, 15 Apr 2022 21:47:51 +0200 Subject: [PATCH 021/269] Update License Year 2022 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index b62c9918..de7a1b38 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017-2020 NamelessMC +Copyright (c) 2017-2022 NamelessMC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 1c239f9f248e6619ce5783a1c0ebd021a7a7526e Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 19 Apr 2022 17:54:08 +0200 Subject: [PATCH 022/269] don't match bukkit version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5bf9e507..d2913433 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ com.google.guava guava - 21.0 + 23.0 From 0f4ce87d12150010d163afbc91ac61a0ff4b0e57 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 20 Apr 2022 11:22:39 +0200 Subject: [PATCH 023/269] Update for i18n (untested) --- .../namelessmc/java_api/LanguageCodeMap.java | 41 ------------------- .../namelessmc/java_api/LanguageEntity.java | 13 +++++- src/com/namelessmc/java_api/NamelessUser.java | 11 +---- src/com/namelessmc/java_api/Website.java | 19 +++------ 4 files changed, 18 insertions(+), 66 deletions(-) delete mode 100644 src/com/namelessmc/java_api/LanguageCodeMap.java diff --git a/src/com/namelessmc/java_api/LanguageCodeMap.java b/src/com/namelessmc/java_api/LanguageCodeMap.java deleted file mode 100644 index 459fd911..00000000 --- a/src/com/namelessmc/java_api/LanguageCodeMap.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.namelessmc.java_api; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Map; - -public class LanguageCodeMap { - - private static final Map NAMELESS_TO_POSIX = new HashMap<>(); - - static { - NAMELESS_TO_POSIX.put("Czech", "cs_CZ"); - NAMELESS_TO_POSIX.put("German", "de_DE"); - NAMELESS_TO_POSIX.put("Greek", "el_GR"); - NAMELESS_TO_POSIX.put("EnglishUK", "en_UK"); - NAMELESS_TO_POSIX.put("EnglishUS", "en_US"); - NAMELESS_TO_POSIX.put("Spanish", "es_419"); - NAMELESS_TO_POSIX.put("SpanishES", "es_ES"); - NAMELESS_TO_POSIX.put("French", "fr_FR"); - NAMELESS_TO_POSIX.put("Hungarian", "hu_HU"); - NAMELESS_TO_POSIX.put("Italian", "it_IT"); - NAMELESS_TO_POSIX.put("Lithuanian", "lt_LT"); - NAMELESS_TO_POSIX.put("Norwegian", "nb_NO"); - NAMELESS_TO_POSIX.put("Dutch", "nl_NL"); - NAMELESS_TO_POSIX.put("Polish", "pl_PL"); - NAMELESS_TO_POSIX.put("Portuguese", "pt_BR"); - NAMELESS_TO_POSIX.put("Romanian", "ro_RO"); - NAMELESS_TO_POSIX.put("Russian", "ru_RU"); - NAMELESS_TO_POSIX.put("Slovak", "sk_SK"); - NAMELESS_TO_POSIX.put("SwedishSE", "sv_SE"); - NAMELESS_TO_POSIX.put("Turkish", "tr_TR"); - NAMELESS_TO_POSIX.put("Chinese(Simplified)", "zh_CN"); - } - - static @Nullable String getLanguagePosix(final @NotNull String language) { - return NAMELESS_TO_POSIX.get(language); - } - -} diff --git a/src/com/namelessmc/java_api/LanguageEntity.java b/src/com/namelessmc/java_api/LanguageEntity.java index 36943e84..faa1934d 100644 --- a/src/com/namelessmc/java_api/LanguageEntity.java +++ b/src/com/namelessmc/java_api/LanguageEntity.java @@ -3,10 +3,19 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Locale; + public interface LanguageEntity { - @NotNull String getLanguage() throws NamelessException; + @NotNull String getRawLanguage() throws NamelessException; - @Nullable String getLanguagePosix() throws NamelessException; + default @NotNull Locale getLocale() throws NamelessException { + final String language = this.getRawLanguage(); + final String[] langSplit = language.split("_"); + if (langSplit.length != 2) { + throw new IllegalArgumentException("Invalid language: " + language); + } + return new Locale(langSplit[0], langSplit[1]); + } } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 0de9e9ba..733d0394 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -191,19 +191,10 @@ public boolean isVerified() throws NamelessException { } @Override - public @NotNull String getLanguage() throws NamelessException { + public @NotNull String getRawLanguage() throws NamelessException { return this.getUserInfo().get("language").getAsString(); } - /** - * Get POSIX code for user language (uses lookup table) - * @return Language code or null if the user's language does not exist in our lookup table - */ - @Override - public @Nullable String getLanguagePosix() throws NamelessException { - return LanguageCodeMap.getLanguagePosix(this.getLanguage()); - } - public @NotNull VerificationInfo getVerificationInfo() throws NamelessException { final boolean verified = isVerified(); final JsonObject verification = this.getUserInfo().getAsJsonObject("verification"); diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 57d324ef..1c20cddc 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Locale; import java.util.Objects; import java.util.Optional; import java.util.stream.StreamSupport; @@ -16,7 +17,7 @@ public class Website implements LanguageEntity { private final @NotNull String version; private final @Nullable Update update; private final @NotNull String@NotNull[] modules; - private final @NotNull String language; + private final @NotNull String rawLanguage; Website(@NotNull final JsonObject json) { Objects.requireNonNull(json, "Provided json object is null"); @@ -41,7 +42,8 @@ public class Website implements LanguageEntity { this.update = null; } - this.language = json.get("language").getAsString(); + this.rawLanguage = json.get("language").getAsString(); + } @NotNull @@ -66,17 +68,8 @@ public NamelessVersion getParsedVersion() throws UnknownNamelessVersionException } @Override - public @NotNull String getLanguage() { - return this.language; - } - - /** - * Get POSIX code for website language (uses lookup table) - * @return Language code or null if the website's language does not exist in our lookup table - */ - @Override - public @Nullable String getLanguagePosix() { - return LanguageCodeMap.getLanguagePosix(this.language); + public @NotNull String getRawLanguage() throws NamelessException { + return this.rawLanguage; } public static class Update { From cc3c2c6b0acf1bf335c7e9b268dba0d881ae2f7e Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 20 Apr 2022 11:33:18 +0200 Subject: [PATCH 024/269] language -> locale --- src/com/namelessmc/java_api/LanguageEntity.java | 5 ++--- src/com/namelessmc/java_api/NamelessUser.java | 4 ++-- src/com/namelessmc/java_api/Website.java | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/com/namelessmc/java_api/LanguageEntity.java b/src/com/namelessmc/java_api/LanguageEntity.java index faa1934d..69f3d0d0 100644 --- a/src/com/namelessmc/java_api/LanguageEntity.java +++ b/src/com/namelessmc/java_api/LanguageEntity.java @@ -1,16 +1,15 @@ package com.namelessmc.java_api; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Locale; public interface LanguageEntity { - @NotNull String getRawLanguage() throws NamelessException; + @NotNull String getRawLocale() throws NamelessException; default @NotNull Locale getLocale() throws NamelessException { - final String language = this.getRawLanguage(); + final String language = this.getRawLocale(); final String[] langSplit = language.split("_"); if (langSplit.length != 2) { throw new IllegalArgumentException("Invalid language: " + language); diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 733d0394..a5d04618 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -191,8 +191,8 @@ public boolean isVerified() throws NamelessException { } @Override - public @NotNull String getRawLanguage() throws NamelessException { - return this.getUserInfo().get("language").getAsString(); + public @NotNull String getRawLocale() throws NamelessException { + return this.getUserInfo().get("locale").getAsString(); } public @NotNull VerificationInfo getVerificationInfo() throws NamelessException { diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 1c20cddc..786ce7fd 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -42,8 +42,7 @@ public class Website implements LanguageEntity { this.update = null; } - this.rawLanguage = json.get("language").getAsString(); - + this.rawLanguage = json.get("locale").getAsString(); } @NotNull @@ -68,7 +67,7 @@ public NamelessVersion getParsedVersion() throws UnknownNamelessVersionException } @Override - public @NotNull String getRawLanguage() throws NamelessException { + public @NotNull String getRawLocale() throws NamelessException { return this.rawLanguage; } From 14829cf2d2f49673495ba76dcebde35617ce79cd Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 20 Apr 2022 12:15:54 +0200 Subject: [PATCH 025/269] Use checker framework instead of jetbrains annotations --- pom.xml | 6 +- src/com/namelessmc/java_api/Announcement.java | 22 ++-- src/com/namelessmc/java_api/ApiError.java | 8 +- .../java_api/CustomProfileField.java | 20 ++-- .../java_api/CustomProfileFieldValue.java | 10 +- .../java_api/FilteredUserListBuilder.java | 27 ++--- src/com/namelessmc/java_api/Group.java | 13 +-- .../namelessmc/java_api/LanguageCodeMap.java | 6 +- .../namelessmc/java_api/LanguageEntity.java | 6 +- src/com/namelessmc/java_api/NamelessAPI.java | 100 +++++++++--------- .../java_api/NamelessApiBuilder.java | 63 +++++------ .../java_api/NamelessException.java | 8 +- src/com/namelessmc/java_api/NamelessUser.java | 58 +++++----- .../namelessmc/java_api/NamelessVersion.java | 14 +-- .../namelessmc/java_api/RequestHandler.java | 32 +++--- src/com/namelessmc/java_api/UserFilter.java | 8 +- .../namelessmc/java_api/VerificationInfo.java | 8 +- src/com/namelessmc/java_api/Website.java | 28 ++--- .../DetailedDiscordIntegrationData.java | 4 +- .../integrations/DetailedIntegrationData.java | 16 +-- .../DetailedMinecraftIntegrationData.java | 8 +- .../integrations/DiscordIntegrationData.java | 4 +- .../IMinecraftIntegrationData.java | 4 +- .../integrations/IntegrationData.java | 20 ++-- .../MinecraftIntegrationData.java | 10 +- .../java_api/modules/websend/WebsendAPI.java | 16 ++- .../modules/websend/WebsendCommand.java | 15 +-- 27 files changed, 263 insertions(+), 271 deletions(-) diff --git a/pom.xml b/pom.xml index d2913433..45d600ac 100644 --- a/pom.xml +++ b/pom.xml @@ -61,9 +61,9 @@ - org.jetbrains - annotations - 23.0.0 + org.checkerframework + checker-qual + 3.21.4 diff --git a/src/com/namelessmc/java_api/Announcement.java b/src/com/namelessmc/java_api/Announcement.java index 69e197fb..04a15e08 100644 --- a/src/com/namelessmc/java_api/Announcement.java +++ b/src/com/namelessmc/java_api/Announcement.java @@ -2,7 +2,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Collections; import java.util.Set; @@ -12,12 +12,12 @@ public class Announcement { private final int id; - private final @NotNull String header; - private final @NotNull String message; - private final @NotNull Set<@NotNull String> displayPages; - private final int @NotNull[] displayGroups; + private final @NonNull String header; + private final @NonNull String message; + private final @NonNull Set<@NonNull String> displayPages; + private final int @NonNull[] displayGroups; - Announcement(@NotNull JsonObject announcementJson) { + Announcement(@NonNull JsonObject announcementJson) { this.id = announcementJson.get("id").getAsInt(); this.header = announcementJson.get("header").getAsString(); this.message = announcementJson.get("message").getAsString(); @@ -35,24 +35,24 @@ public int getId() { return id; } - public @NotNull String getHeader() { + public @NonNull String getHeader() { return this.header; } - public @NotNull String getMessage() { + public @NonNull String getMessage() { return this.message; } @Deprecated - public @NotNull String getContent() { + public @NonNull String getContent() { return this.message; } - public @NotNull Set<@NotNull String> getDisplayPages() { + public @NonNull Set<@NonNull String> getDisplayPages() { return this.displayPages; } - public int @NotNull[] getDisplayGroupIds() { + public int @NonNull[] getDisplayGroupIds() { return this.displayGroups; } diff --git a/src/com/namelessmc/java_api/ApiError.java b/src/com/namelessmc/java_api/ApiError.java index 94a63080..2af15597 100644 --- a/src/com/namelessmc/java_api/ApiError.java +++ b/src/com/namelessmc/java_api/ApiError.java @@ -1,7 +1,7 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Optional; @@ -53,7 +53,7 @@ public class ApiError extends NamelessException { private final int code; private final @Nullable String meta; - public ApiError(final int code, @Nullable String meta) { + public ApiError(final int code, final @Nullable String meta) { super("An unexpected API error occurred with error code " + code + " and " + (meta == null ? "no meta" : "meta " + meta)); this.code = code; this.meta = meta; @@ -63,7 +63,7 @@ public int getError() { return this.code; } - public @NotNull Optional<@NotNull String> getMeta() { + public @NonNull Optional<@NonNull String> getMeta() { return Optional.ofNullable(meta); } diff --git a/src/com/namelessmc/java_api/CustomProfileField.java b/src/com/namelessmc/java_api/CustomProfileField.java index acac403d..5f3a8156 100644 --- a/src/com/namelessmc/java_api/CustomProfileField.java +++ b/src/com/namelessmc/java_api/CustomProfileField.java @@ -1,24 +1,24 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Objects; public class CustomProfileField { private final int id; - private final @NotNull String name; - private final @NotNull CustomProfileFieldType type; + private final @NonNull String name; + private final @NonNull CustomProfileFieldType type; private final boolean isPublic; private final boolean isRequired; - private final @NotNull String description; + private final @NonNull String description; CustomProfileField(final int id, - final @NotNull String name, - final @NotNull CustomProfileFieldType type, + final @NonNull String name, + final @NonNull CustomProfileFieldType type, final boolean isPublic, final boolean isRequired, - final @NotNull String description) { + final @NonNull String description) { this.id = id; this.name = name; this.type = type; @@ -31,11 +31,11 @@ public int getId() { return id; } - public @NotNull String getName() { + public @NonNull String getName() { return name; } - public @NotNull CustomProfileFieldType getType() { + public @NonNull CustomProfileFieldType getType() { return type; } @@ -47,7 +47,7 @@ public boolean isRequired() { return isRequired; } - public @NotNull String getDescription() { + public @NonNull String getDescription() { return description; } diff --git a/src/com/namelessmc/java_api/CustomProfileFieldValue.java b/src/com/namelessmc/java_api/CustomProfileFieldValue.java index ee25851b..b272785c 100644 --- a/src/com/namelessmc/java_api/CustomProfileFieldValue.java +++ b/src/com/namelessmc/java_api/CustomProfileFieldValue.java @@ -1,19 +1,19 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; public class CustomProfileFieldValue { - private final @NotNull CustomProfileField field; + private final @NonNull CustomProfileField field; private final @Nullable String value; - CustomProfileFieldValue(@NotNull CustomProfileField field, @Nullable String value) { + CustomProfileFieldValue(@NonNull CustomProfileField field, @Nullable String value) { this.field = field; this.value = value; } - public @NotNull CustomProfileField getField() { + public @NonNull CustomProfileField getField() { return this.field; } diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index 8ea3160d..4c5d6764 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -3,28 +3,23 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; public class FilteredUserListBuilder { - private final @NotNull NamelessAPI api; + private final @NonNull NamelessAPI api; private @Nullable Map, Object> filters; - private @NotNull String operator = "AND"; + private @NonNull String operator = "AND"; - FilteredUserListBuilder(@NotNull NamelessAPI api) { + FilteredUserListBuilder(@NonNull NamelessAPI api) { this.api = api; } - public FilteredUserListBuilder withFilter(UserFilter filter, T value) { + public @NonNull FilteredUserListBuilder withFilter(final @NonNull UserFilter filter, + final @NonNull T value) { if (filters == null) { filters = new HashMap<>(); } @@ -33,17 +28,17 @@ public FilteredUserListBuilder withFilter(UserFilter filter, T value) { return this; } - public FilteredUserListBuilder all() { + public @NonNull FilteredUserListBuilder all() { this.operator = "AND"; return this; } - public FilteredUserListBuilder any() { + public @NonNull FilteredUserListBuilder any() { this.operator = "OR"; return this; } - public List makeRequest() throws NamelessException { + public @NonNull List<@NonNull NamelessUser> makeRequest() throws NamelessException { final Object[] parameters; if (filters != null) { int filterCount = filters.size(); diff --git a/src/com/namelessmc/java_api/Group.java b/src/com/namelessmc/java_api/Group.java index e7631fcb..f0d36f35 100644 --- a/src/com/namelessmc/java_api/Group.java +++ b/src/com/namelessmc/java_api/Group.java @@ -1,20 +1,18 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; - import com.google.gson.JsonObject; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Objects; public class Group implements Comparable { private final int id; - @NotNull - private final String name; + private final @NonNull String name; private final int order; private final boolean staff; - Group(@NotNull final JsonObject group) { + Group(final @NonNull JsonObject group) { this.id = group.get("id").getAsInt(); this.name = group.get("name").getAsString(); this.order = group.get("order").getAsInt(); @@ -25,8 +23,7 @@ public int getId() { return this.id; } - @NotNull - public String getName() { + public @NonNull String getName() { return this.name; } @@ -55,7 +52,7 @@ public int hashCode() { } @Override - public String toString() { + public @NonNull String toString() { return "Group[id=" + id + ",name=" + name + "]"; } diff --git a/src/com/namelessmc/java_api/LanguageCodeMap.java b/src/com/namelessmc/java_api/LanguageCodeMap.java index 459fd911..3459dc2b 100644 --- a/src/com/namelessmc/java_api/LanguageCodeMap.java +++ b/src/com/namelessmc/java_api/LanguageCodeMap.java @@ -1,7 +1,7 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.HashMap; import java.util.Map; @@ -34,7 +34,7 @@ public class LanguageCodeMap { NAMELESS_TO_POSIX.put("Chinese(Simplified)", "zh_CN"); } - static @Nullable String getLanguagePosix(final @NotNull String language) { + static @Nullable String getLanguagePosix(final @NonNull String language) { return NAMELESS_TO_POSIX.get(language); } diff --git a/src/com/namelessmc/java_api/LanguageEntity.java b/src/com/namelessmc/java_api/LanguageEntity.java index 36943e84..28245506 100644 --- a/src/com/namelessmc/java_api/LanguageEntity.java +++ b/src/com/namelessmc/java_api/LanguageEntity.java @@ -1,11 +1,11 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; public interface LanguageEntity { - @NotNull String getLanguage() throws NamelessException; + @NonNull String getLanguage() throws NamelessException; @Nullable String getLanguagePosix() throws NamelessException; diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index b6bd16e2..e02c6366 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -8,8 +8,8 @@ import com.namelessmc.java_api.exception.*; import com.namelessmc.java_api.integrations.IntegrationData; import com.namelessmc.java_api.modules.websend.WebsendAPI; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.math.BigInteger; import java.net.URL; @@ -21,33 +21,33 @@ public final class NamelessAPI { static final Gson GSON = new Gson(); - @NotNull + @NonNull private final RequestHandler requests; // Not actually used by the Nameless Java API, but could be useful to applications using it. - private final @NotNull URL apiUrl; - private final @NotNull String apiKey; + private final @NonNull URL apiUrl; + private final @NonNull String apiKey; - NamelessAPI(final @NotNull RequestHandler requests, - final @NotNull URL apiUrl, - final @NotNull String apiKey) { + NamelessAPI(final @NonNull RequestHandler requests, + final @NonNull URL apiUrl, + final @NonNull String apiKey) { this.requests = Objects.requireNonNull(requests, "Request handler is null"); this.apiUrl = apiUrl; this.apiKey = apiKey; } - @NotNull RequestHandler getRequestHandler() { + @NonNull RequestHandler getRequestHandler() { return this.requests; } - public @NotNull URL getApiUrl() { + public @NonNull URL getApiUrl() { return this.apiUrl; } - public @NotNull String getApiKey() { + public @NonNull String getApiKey() { return this.apiKey; } @@ -55,8 +55,8 @@ public final class NamelessAPI { * Get announcements visible to guests. Use {@link NamelessUser#getAnnouncements()} for non-guest announcements. * @return List of announcements */ - @NotNull - public List<@NotNull Announcement> getAnnouncements() throws NamelessException { + @NonNull + public List<@NonNull Announcement> getAnnouncements() throws NamelessException { final JsonObject response = this.requests.get("announcements"); return getAnnouncements(response); } @@ -67,9 +67,9 @@ public final class NamelessAPI { * @return List of announcements visible to the user * @deprecated Use {@link NamelessUser#getAnnouncements()} */ - @NotNull + @NonNull @Deprecated - public List<@NotNull Announcement> getAnnouncements(@NotNull final NamelessUser user) throws NamelessException { + public List<@NonNull Announcement> getAnnouncements(@NonNull final NamelessUser user) throws NamelessException { final JsonObject response = this.requests.get("users/" + user.getUserTransformer() + "/announcements"); return getAnnouncements(response); @@ -80,8 +80,8 @@ public final class NamelessAPI { * @param response Announcements json API response * @return List of {@link Announcement} objects */ - @NotNull - static List<@NotNull Announcement> getAnnouncements(@NotNull final JsonObject response) { + @NonNull + static List<@NonNull Announcement> getAnnouncements(@NonNull final JsonObject response) { return StreamSupport.stream(response.getAsJsonArray("announcements").spliterator(), false) .map(JsonElement::getAsJsonObject) .map(Announcement::new) @@ -92,7 +92,7 @@ public final class NamelessAPI { * Send Minecraft server information to the website. Currently, the exact JSON contents are undocumented. * @param jsonData Json data to submit */ - public void submitServerInfo(final @NotNull JsonObject jsonData) throws NamelessException { + public void submitServerInfo(final @NonNull JsonObject jsonData) throws NamelessException { this.requests.post("minecraft/server-info", jsonData); } @@ -109,7 +109,7 @@ public FilteredUserListBuilder getRegisteredUsers() { return new FilteredUserListBuilder(this); } - public @NotNull Optional getUser(final int id) throws NamelessException { + public @NonNull Optional getUser(final int id) throws NamelessException { final NamelessUser user = getUserLazy(id); if (user.exists()) { return Optional.of(user); @@ -118,7 +118,7 @@ public FilteredUserListBuilder getRegisteredUsers() { } } - public @NotNull Optional getUser(@NotNull final String username) throws NamelessException { + public @NonNull Optional getUser(@NonNull final String username) throws NamelessException { final NamelessUser user = getUserLazy(username); if (user.exists()) { return Optional.of(user); @@ -127,7 +127,7 @@ public FilteredUserListBuilder getRegisteredUsers() { } } - public @NotNull Optional getUser(@NotNull final UUID uuid) throws NamelessException { + public @NonNull Optional getUser(@NonNull final UUID uuid) throws NamelessException { final NamelessUser user = getUserLazy(uuid); if (user.exists()) { return Optional.of(user); @@ -136,7 +136,7 @@ public FilteredUserListBuilder getRegisteredUsers() { } } - public @NotNull Optional getUserByDiscordId(final long discordId) throws NamelessException { + public @NonNull Optional getUserByDiscordId(final long discordId) throws NamelessException { final NamelessUser user = getUserLazyDiscord(discordId); if (user.exists()) { return Optional.of(user); @@ -150,7 +150,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param id NamelessMC user id * @return Nameless user object, never null */ - public @NotNull NamelessUser getUserLazy(final int id) { + public @NonNull NamelessUser getUserLazy(final int id) { return new NamelessUser(this, id, null, false, null, false, -1L); } @@ -159,7 +159,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param username NamelessMC user * @return Nameless user object, never null */ - public @NotNull NamelessUser getUserLazy(final @NotNull String username) { + public @NonNull NamelessUser getUserLazy(final @NonNull String username) { return new NamelessUser(this, -1, username, false, null, false, -1L); } @@ -168,7 +168,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param uuid Minecraft UUID * @return Nameless user object, never null */ - public @NotNull NamelessUser getUserLazy(@NotNull final UUID uuid) { + public @NonNull NamelessUser getUserLazy(@NonNull final UUID uuid) { return new NamelessUser(this, -1, null, true, uuid, false, -1L); } @@ -178,7 +178,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param uuid The user's Mojang UUID * @return Nameless user object, never null */ - public NamelessUser getUserLazy(@NotNull final String username, @NotNull final UUID uuid) { + public NamelessUser getUserLazy(@NonNull final String username, @NonNull final UUID uuid) { return new NamelessUser(this, -1, username, true, uuid, false,-1L); } @@ -187,7 +187,7 @@ public NamelessUser getUserLazy(@NotNull final String username, @NotNull final U * @param id NamelessMC user id * @return Nameless user object, never null */ - public NamelessUser getUserLazy(final int id, final @NotNull String username, final @NotNull UUID uuid) { + public NamelessUser getUserLazy(final int id, final @NonNull String username, final @NonNull UUID uuid) { return new NamelessUser(this, id, username, true, uuid, false, -1L); } @@ -206,8 +206,8 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * @param id Group id * @return Optional with a group if the group exists, empty optional if it doesn't */ - @NotNull - public Optional<@NotNull Group> getGroup(final int id) throws NamelessException { + @NonNull + public Optional<@NonNull Group> getGroup(final int id) throws NamelessException { final JsonObject response = this.requests.get("groups", "id", id); final JsonArray jsonArray = response.getAsJsonArray("groups"); if (jsonArray.size() != 1) { @@ -222,8 +222,8 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * @param name NamelessMC groups name * @return List of groups with this name, empty if there are no groups with this name. */ - @NotNull - public List<@NotNull Group> getGroup(@NotNull final String name) throws NamelessException { + @NonNull + public List<@NonNull Group> getGroup(@NonNull final String name) throws NamelessException { Objects.requireNonNull(name, "Group name is null"); final JsonObject response = this.requests.get("groups", "name", name); return groupListFromJsonArray(response.getAsJsonArray("groups")); @@ -233,13 +233,13 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * Get a list of all groups on the website * @return list of groups */ - public @NotNull List getAllGroups() throws NamelessException { + public @NonNull List getAllGroups() throws NamelessException { final JsonObject response = this.requests.get("groups"); return groupListFromJsonArray(response.getAsJsonArray("groups")); } - public int @NotNull[] getAllGroupIds() throws NamelessException { + public int @NonNull[] getAllGroupIds() throws NamelessException { final JsonObject response = this.requests.get("groups"); return StreamSupport.stream(response.getAsJsonArray("groups").spliterator(), false) .map(JsonElement::getAsJsonObject) @@ -247,7 +247,7 @@ public NamelessUser getUserLazyDiscord(final long discordId) { .toArray(); } - private @NotNull List groupListFromJsonArray(@NotNull final JsonArray array) { + private @NonNull List groupListFromJsonArray(@NonNull final JsonArray array) { return StreamSupport.stream(array.spliterator(), false) .map(JsonElement::getAsJsonObject) .map(Group::new) @@ -265,9 +265,9 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * @return Email verification disabled: A link which the user needs to click to complete registration *
Email verification enabled: An empty string (the user needs to check their email to complete registration) */ - public @NotNull Optional registerUser(@NotNull final String username, - @NotNull final String email, - @NotNull IntegrationData@Nullable... integrationData) + public @NonNull Optional registerUser(@NonNull final String username, + @NonNull final String email, + @NonNull IntegrationData@Nullable ... integrationData) throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, CannotSendEmailException, IntegrationUsernameAlreadyExistsException, IntegrationIdAlreadyExistsException, InvalidEmailAddressException, EmailAlreadyUsedException { @@ -315,7 +315,7 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * Set Discord bot URL (Nameless-Link internal webserver) * @param url Discord bot URL */ - public void setDiscordBotUrl(@NotNull final URL url) throws NamelessException { + public void setDiscordBotUrl(@NonNull final URL url) throws NamelessException { Objects.requireNonNull(url, "Bot url is null"); final JsonObject json = new JsonObject(); @@ -339,7 +339,7 @@ public void setDiscordGuildId(final long guildId) throws NamelessException { * @param userId Bot user id * @see #setDiscordBotSettings(URL, long, String, long) */ - public void setDiscordBotUser(@NotNull final String username, final long userId) throws NamelessException { + public void setDiscordBotUser(@NonNull final String username, final long userId) throws NamelessException { Objects.requireNonNull(username, "Bot username is null"); final JsonObject json = new JsonObject(); @@ -358,7 +358,7 @@ public void setDiscordBotUser(@NotNull final String username, final long userId) * @see #setDiscordGuildId(long) * @see #setDiscordBotUser(String, long) */ - public void setDiscordBotSettings(@NotNull final URL url, final long guildId, @NotNull final String username, final long userId) throws NamelessException { + public void setDiscordBotSettings(@NonNull final URL url, final long guildId, @NonNull final String username, final long userId) throws NamelessException { Objects.requireNonNull(url, "Bot url is null"); Objects.requireNonNull(username, "Bot username is null"); @@ -374,7 +374,7 @@ public void setDiscordBotSettings(@NotNull final URL url, final long guildId, @N * Send list of Discord roles to the website for populating the dropdown in StaffCP > API > Group sync * @param discordRoles Map of Discord roles, key is role id, value is role name */ - public void submitDiscordRoleList(@NotNull final Map discordRoles) throws NamelessException { + public void submitDiscordRoleList(@NonNull final Map discordRoles) throws NamelessException { final JsonArray roles = new JsonArray(); discordRoles.forEach((id, name) -> { final JsonObject role = new JsonObject(); @@ -394,7 +394,7 @@ public void submitDiscordRoleList(@NotNull final Map discordRoles) * @see #updateDiscordUsernames(long[], String[]) */ public void updateDiscordUsername(final long discordUserId, - final @NotNull String discordUsername) + final @NonNull String discordUsername) throws NamelessException { Objects.requireNonNull(discordUsername, "Discord username is null"); @@ -414,8 +414,8 @@ public void updateDiscordUsername(final long discordUserId, * @param discordUsernames New Discord [username#tag]s * @see #updateDiscordUsername(long, String) */ - public void updateDiscordUsernames(final long@NotNull[] discordUserIds, - final @NotNull String@NotNull[] discordUsernames) + public void updateDiscordUsernames(final long@NonNull[] discordUserIds, + final @NonNull String@NonNull[] discordUsernames) throws NamelessException { Objects.requireNonNull(discordUserIds, "User ids array is null"); Objects.requireNonNull(discordUsernames, "Usernames array is null"); @@ -440,8 +440,8 @@ public void updateDiscordUsernames(final long@NotNull[] discordUserIds, this.requests.post("discord/update-usernames", json); } - public void verifyIntegration(final @NotNull IntegrationData integrationData, - final @NotNull String verificationCode) + public void verifyIntegration(final @NonNull IntegrationData integrationData, + final @NonNull String verificationCode) throws NamelessException, InvalidValidateCodeException { JsonObject data = new JsonObject(); data.addProperty("integration", integrationData.getIntegrationType()); @@ -460,7 +460,7 @@ public void verifyIntegration(final @NotNull IntegrationData integrationData, } } - public @NotNull WebsendAPI websend() { + public @NonNull WebsendAPI websend() { return new WebsendAPI(this.requests); } @@ -469,7 +469,7 @@ public void verifyIntegration(final @NotNull IntegrationData integrationData, * @param uuid UUID without dashes * @return UUID with dashes */ - public static @NotNull UUID websiteUuidToJavaUuid(@NotNull final String uuid) { + public static @NonNull UUID websiteUuidToJavaUuid(@NonNull final String uuid) { Objects.requireNonNull(uuid, "UUID string is null"); // Website sends UUIDs without dashes, so we can't use UUID#fromString // https://stackoverflow.com/a/30760478 @@ -482,8 +482,8 @@ public void verifyIntegration(final @NotNull IntegrationData integrationData, } } - @NotNull - public static NamelessApiBuilder builder(@NotNull URL apiUrl, @NotNull String apiKey) { + @NonNull + public static NamelessApiBuilder builder(@NonNull URL apiUrl, @NonNull String apiKey) { return new NamelessApiBuilder(apiUrl, apiKey); } diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index f31411b3..4dddd411 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -5,10 +5,13 @@ import com.namelessmc.java_api.logger.ApiLogger; import com.namelessmc.java_api.logger.PrintStreamLogger; import com.namelessmc.java_api.logger.Slf4jLogger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; -import java.net.*; +import java.net.Authenticator; +import java.net.MalformedURLException; +import java.net.ProxySelector; +import java.net.URL; import java.time.Duration; import java.util.concurrent.Executor; @@ -18,16 +21,16 @@ public class NamelessApiBuilder { private static final String DEFAULT_USER_AGENT = "Nameless-Java-API"; private static final int DEFAULT_RESPONSE_SIZE_LIMIT = 32*1024*1024; - private final @NotNull URL apiUrl; - private final @NotNull String apiKey; + private final @NonNull URL apiUrl; + private final @NonNull String apiKey; - private final @NotNull GsonBuilder gsonBuilder; + private final @NonNull GsonBuilder gsonBuilder; private @Nullable ApiLogger debugLogger = null; - private final @NotNull Methanol.Builder httpClientBuilder; + private final Methanol.@NonNull Builder httpClientBuilder; private int responseSizeLimit = DEFAULT_RESPONSE_SIZE_LIMIT; - NamelessApiBuilder(final @NotNull URL apiUrl, - final @NotNull String apiKey) { + NamelessApiBuilder(final @NonNull URL apiUrl, + final @NonNull String apiKey) { try { this.apiUrl = apiUrl.toString().endsWith("/") ? apiUrl : new URL(apiUrl + "/"); } catch (MalformedURLException e) { @@ -47,12 +50,12 @@ public class NamelessApiBuilder { .autoAcceptEncoding(true); } - public @NotNull NamelessApiBuilder userAgent(@NotNull final String userAgent) { + public @NonNull NamelessApiBuilder userAgent(@NonNull final String userAgent) { this.httpClientBuilder.userAgent(userAgent); return this; } - public @NotNull NamelessApiBuilder debug(final boolean debug) { + public @NonNull NamelessApiBuilder debug(final boolean debug) { if (debug) { return this.withStdErrDebugLogging(); } else { @@ -62,108 +65,108 @@ public class NamelessApiBuilder { } @Deprecated - public @NotNull NamelessApiBuilder withStdErrDebugLogging() { + public @NonNull NamelessApiBuilder withStdErrDebugLogging() { this.debugLogger = PrintStreamLogger.DEFAULT_INSTANCE; return this; } - public @NotNull NamelessApiBuilder stdErrDebugLogger() { + public @NonNull NamelessApiBuilder stdErrDebugLogger() { this.debugLogger = PrintStreamLogger.DEFAULT_INSTANCE; return this; } @Deprecated - public @NotNull NamelessApiBuilder withSlf4jDebugLogging() { + public @NonNull NamelessApiBuilder withSlf4jDebugLogging() { this.debugLogger = Slf4jLogger.DEFAULT_INSTANCE; return this; } - public @NotNull NamelessApiBuilder slf4jDebugLogger() { + public @NonNull NamelessApiBuilder slf4jDebugLogger() { this.debugLogger = Slf4jLogger.DEFAULT_INSTANCE; return this; } @Deprecated - public @NotNull NamelessApiBuilder withCustomDebugLogger(final @Nullable ApiLogger debugLogger) { + public @NonNull NamelessApiBuilder withCustomDebugLogger(final @Nullable ApiLogger debugLogger) { this.debugLogger = debugLogger; return this; } - public @NotNull NamelessApiBuilder customDebugLogger(final @Nullable ApiLogger debugLogger) { + public @NonNull NamelessApiBuilder customDebugLogger(final @Nullable ApiLogger debugLogger) { this.debugLogger = debugLogger; return this; } @Deprecated - public @NotNull NamelessApiBuilder withTimeoutMillis(final int timeout) { + public @NonNull NamelessApiBuilder withTimeoutMillis(final int timeout) { return this.withTimeout(Duration.ofMillis(timeout)); } @Deprecated - public @NotNull NamelessApiBuilder withTimeout(final @NotNull Duration timeout) { + public @NonNull NamelessApiBuilder withTimeout(final @NonNull Duration timeout) { this.httpClientBuilder.readTimeout(timeout) .requestTimeout(timeout) .connectTimeout(timeout); return this; } - public @NotNull NamelessApiBuilder timeout(final @NotNull Duration timeout) { + public @NonNull NamelessApiBuilder timeout(final @NonNull Duration timeout) { this.httpClientBuilder.readTimeout(timeout) .requestTimeout(timeout) .connectTimeout(timeout); return this; } - public @NotNull NamelessApiBuilder withProxy(ProxySelector proxy) { + public @NonNull NamelessApiBuilder withProxy(ProxySelector proxy) { this.httpClientBuilder.proxy(proxy); return this; } @Deprecated - public @NotNull NamelessApiBuilder proxy(ProxySelector proxy) { + public @NonNull NamelessApiBuilder proxy(ProxySelector proxy) { this.httpClientBuilder.proxy(proxy); return this; } @Deprecated - public @NotNull NamelessApiBuilder withAuthenticator(Authenticator authenticator) { + public @NonNull NamelessApiBuilder withAuthenticator(Authenticator authenticator) { this.httpClientBuilder.authenticator(authenticator); return this; } - public @NotNull NamelessApiBuilder authenticator(Authenticator authenticator) { + public @NonNull NamelessApiBuilder authenticator(Authenticator authenticator) { this.httpClientBuilder.authenticator(authenticator); return this; } @Deprecated - public @NotNull NamelessApiBuilder withPrettyJson() { + public @NonNull NamelessApiBuilder withPrettyJson() { gsonBuilder.setPrettyPrinting(); return this; } - public @NotNull NamelessApiBuilder pettyJsonRequests() { + public @NonNull NamelessApiBuilder pettyJsonRequests() { gsonBuilder.setPrettyPrinting(); return this; } @Deprecated - public @NotNull NamelessApiBuilder withResponseSizeLimit(int responseSizeLimitBytes) { + public @NonNull NamelessApiBuilder withResponseSizeLimit(int responseSizeLimitBytes) { this.responseSizeLimit = responseSizeLimitBytes; return this; } - public @NotNull NamelessApiBuilder responseSizeLimit(int responseSizeLimitBytes) { + public @NonNull NamelessApiBuilder responseSizeLimit(int responseSizeLimitBytes) { this.responseSizeLimit = responseSizeLimitBytes; return this; } - public @NotNull NamelessApiBuilder executor(final @NotNull Executor executor) { + public @NonNull NamelessApiBuilder executor(final @NonNull Executor executor) { this.httpClientBuilder.executor(executor); return this; } - public @NotNull NamelessAPI build() { + public @NonNull NamelessAPI build() { return new NamelessAPI( new RequestHandler( this.apiUrl, diff --git a/src/com/namelessmc/java_api/NamelessException.java b/src/com/namelessmc/java_api/NamelessException.java index 549ee5e5..7f7c6ad4 100644 --- a/src/com/namelessmc/java_api/NamelessException.java +++ b/src/com/namelessmc/java_api/NamelessException.java @@ -1,6 +1,6 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Generic exception thrown by many methods in the Nameless API @@ -9,15 +9,15 @@ public class NamelessException extends Exception { private static final long serialVersionUID = -3698433855091611529L; - public NamelessException(@NotNull final String message) { + public NamelessException(final @NonNull String message) { super(message); } - public NamelessException(@NotNull final String message, @NotNull final Throwable cause) { + public NamelessException(final @NonNull String message, final @NonNull Throwable cause) { super(message, cause); } - public NamelessException(@NotNull final Throwable cause) { + public NamelessException(final @NonNull Throwable cause) { super(cause); } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 0de9e9ba..d7bd9417 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -9,8 +9,8 @@ import com.namelessmc.java_api.exception.CannotReportSelfException; import com.namelessmc.java_api.exception.ReportUserBannedException; import com.namelessmc.java_api.integrations.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.*; import java.util.stream.Collectors; @@ -18,9 +18,9 @@ public final class NamelessUser implements LanguageEntity { - @NotNull + @NonNull private final NamelessAPI api; - @NotNull + @NonNull private final RequestHandler requests; private int id; // -1 if not known @@ -45,7 +45,7 @@ public final class NamelessUser implements LanguageEntity { * @param discordIdKnown True if it is known whether this user has a linked Discord id or not * @param discordId The user's discord id, or -1 if the user doesn't have a linked Discord id, or it is not known whether the user has a Discord id */ - NamelessUser(@NotNull final NamelessAPI api, + NamelessUser(@NonNull final NamelessAPI api, final int id, @Nullable final String username, boolean uuidKnown, @@ -106,7 +106,7 @@ public String getUserTransformer() { } } - @NotNull + @NonNull public NamelessAPI getApi() { return this.api; } @@ -141,7 +141,7 @@ public int getId() throws NamelessException { return this.id; } - public @NotNull String getUsername() throws NamelessException { + public @NonNull String getUsername() throws NamelessException { if (this.username == null) { this.username = this.getUserInfo().get("username").getAsString(); } @@ -149,7 +149,7 @@ public int getId() throws NamelessException { return this.username; } - public void updateUsername(final @NotNull String username) throws NamelessException { + public void updateUsername(final @NonNull String username) throws NamelessException { JsonObject post = new JsonObject(); post.addProperty("username", username); this.requests.post("users/" + this.getUserTransformer() + "/update-username", post); @@ -164,18 +164,18 @@ public boolean exists() throws NamelessException { } } - public @NotNull String getDisplayName() throws NamelessException { + public @NonNull String getDisplayName() throws NamelessException { return this.getUserInfo().get("displayname").getAsString(); } /** * @return The date the user registered on the website. */ - public @NotNull Date getRegisteredDate() throws NamelessException { + public @NonNull Date getRegisteredDate() throws NamelessException { return new Date(this.getUserInfo().get("registered_timestamp").getAsLong() * 1000); } - public @NotNull Date getLastOnline() throws NamelessException { + public @NonNull Date getLastOnline() throws NamelessException { return new Date(this.getUserInfo().get("last_online_timestamp").getAsLong() * 1000); } @@ -191,7 +191,7 @@ public boolean isVerified() throws NamelessException { } @Override - public @NotNull String getLanguage() throws NamelessException { + public @NonNull String getLanguage() throws NamelessException { return this.getUserInfo().get("language").getAsString(); } @@ -200,11 +200,11 @@ public boolean isVerified() throws NamelessException { * @return Language code or null if the user's language does not exist in our lookup table */ @Override - public @Nullable String getLanguagePosix() throws NamelessException { + public @NonNull String getLanguagePosix() throws NamelessException { return LanguageCodeMap.getLanguagePosix(this.getLanguage()); } - public @NotNull VerificationInfo getVerificationInfo() throws NamelessException { + public @NonNull VerificationInfo getVerificationInfo() throws NamelessException { final boolean verified = isVerified(); final JsonObject verification = this.getUserInfo().getAsJsonObject("verification"); return new VerificationInfo(verified, verification); @@ -229,7 +229,7 @@ public boolean isStaff() throws NamelessException { * @return Set of user's groups * @see #getSortedGroups() */ - public @NotNull Set<@NotNull Group> getGroups() throws NamelessException { + public @NonNull Set<@NonNull Group> getGroups() throws NamelessException { return Collections.unmodifiableSet( StreamSupport.stream(this.getUserInfo().getAsJsonArray("groups").spliterator(), false) .map(JsonElement::getAsJsonObject) @@ -241,7 +241,7 @@ public boolean isStaff() throws NamelessException { * @return List of the user's groups, sorted from low order to high order. * @see #getGroups() */ - public @NotNull List<@NotNull Group> getSortedGroups() throws NamelessException { + public @NonNull List<@NonNull Group> getSortedGroups() throws NamelessException { return Collections.unmodifiableList( StreamSupport.stream(this.getUserInfo().getAsJsonArray("groups").spliterator(), false) .map(JsonElement::getAsJsonObject) @@ -257,7 +257,7 @@ public boolean isStaff() throws NamelessException { * * @return Player's group with the lowest order */ - public @NotNull Optional<@NotNull Group> getPrimaryGroup() throws NamelessException { + public @NonNull Optional<@NonNull Group> getPrimaryGroup() throws NamelessException { final JsonArray groups = this.getUserInfo().getAsJsonArray("groups"); if (groups.size() > 0) { return Optional.of(new Group(groups.get(0).getAsJsonObject())); @@ -266,21 +266,21 @@ public boolean isStaff() throws NamelessException { } } - public void addGroups(@NotNull final Group@NotNull ... groups) throws NamelessException { + public void addGroups(@NonNull final Group@NonNull ... groups) throws NamelessException { final JsonObject post = new JsonObject(); post.add("groups", groupsToJsonArray(groups)); this.requests.post("users/" + this.getUserTransformer() + "/groups/add", post); invalidateCache(); // Groups modified, invalidate cache } - public void removeGroups(@NotNull final Group@NotNull... groups) throws NamelessException { + public void removeGroups(@NonNull final Group@NonNull... groups) throws NamelessException { final JsonObject post = new JsonObject(); post.add("groups", groupsToJsonArray(groups)); this.requests.post("users/" + this.getUserTransformer() + "/groups/remove", post); invalidateCache(); // Groups modified, invalidate cache } - private JsonArray groupsToJsonArray(@NotNull final Group@NotNull [] groups) { + private JsonArray groupsToJsonArray(@NonNull final Group@NonNull [] groups) { final JsonArray array = new JsonArray(); for (final Group group : groups) { array.add(group.getId()); @@ -293,7 +293,7 @@ public int getNotificationCount() throws NamelessException { return response.getAsJsonArray("notifications").size(); } - public @NotNull List getNotifications() throws NamelessException { + public @NonNull List getNotifications() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.getUserTransformer() + "/notifications"); final List notifications = new ArrayList<>(); @@ -318,7 +318,7 @@ public int getNotificationCount() throws NamelessException { * @throws AlreadyHasOpenReportException If the user creating this report already has an open report for this user * @throws CannotReportSelfException If the user tries to report themselves */ - public void createReport(@NotNull final NamelessUser user, @NotNull final String reason) + public void createReport(@NonNull final NamelessUser user, @NonNull final String reason) throws NamelessException, ReportUserBannedException, AlreadyHasOpenReportException, CannotReportSelfException { Objects.requireNonNull(user, "User to report is null"); Objects.requireNonNull(reason, "Report reason is null"); @@ -354,9 +354,9 @@ public void createReport(@NotNull final NamelessUser user, @NotNull final String * @throws AlreadyHasOpenReportException If the user creating this report already has an open report for this user * @throws CannotReportSelfException If the user tries to report themselves */ - public void createReport(final @NotNull UUID reportedUuid, - final @NotNull String reportedName, - final @NotNull String reason) + public void createReport(final @NonNull UUID reportedUuid, + final @NonNull String reportedName, + final @NonNull String reason) throws NamelessException, ReportUserBannedException, AlreadyHasOpenReportException, CannotReportSelfException { Objects.requireNonNull(reportedUuid, "Reported uuid is null"); Objects.requireNonNull(reportedName, "Reported name is null"); @@ -383,7 +383,7 @@ public void createReport(final @NotNull UUID reportedUuid, } } - public void setDiscordRoles(final long@NotNull[] roleIds) throws NamelessException { + public void setDiscordRoles(final long@NonNull[] roleIds) throws NamelessException { final JsonObject post = new JsonObject(); post.addProperty("user", this.getId()); post.add("roles", NamelessAPI.GSON.toJsonTree(roleIds)); @@ -394,8 +394,8 @@ public void setDiscordRoles(final long@NotNull[] roleIds) throws NamelessExcepti * Get announcements visible to this user * @return List of announcements visible to this user */ - @NotNull - public List<@NotNull Announcement> getAnnouncements() throws NamelessException { + @NonNull + public List<@NonNull Announcement> getAnnouncements() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.getUserTransformer() + "/announcements"); return NamelessAPI.getAnnouncements(response); } @@ -408,7 +408,7 @@ public void banUser() throws NamelessException { this.requests.post("users/" + this.getUserTransformer() + "/ban", new JsonObject()); } - public @NotNull Collection<@NotNull CustomProfileFieldValue> getProfileFields() throws NamelessException { + public @NonNull Collection<@NonNull CustomProfileFieldValue> getProfileFields() throws NamelessException { if (!this.getUserInfo().has("profile_fields")) { return Collections.emptyList(); } diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index d4b56553..c3e3258f 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -1,7 +1,7 @@ package com.namelessmc.java_api; import com.namelessmc.java_api.exception.UnknownNamelessVersionException; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.*; @@ -23,14 +23,14 @@ public enum NamelessVersion { V2_0_0_PR_13 ); - private final @NotNull String name; - private final @NotNull String friendlyName; + private final @NonNull String name; + private final @NonNull String friendlyName; private final int major; private final int minor; private final boolean isBeta; @SuppressWarnings("SameParameterValue") - NamelessVersion(@NotNull final String name, @NotNull String friendlyName, final int major, final int minor, final boolean isBeta) { + NamelessVersion(@NonNull final String name, @NonNull String friendlyName, final int major, final int minor, final boolean isBeta) { this.name = name; this.friendlyName = friendlyName; this.major = major; @@ -38,11 +38,11 @@ public enum NamelessVersion { this.isBeta = isBeta; } - public @NotNull String getName() { + public @NonNull String getName() { return this.name; } - public @NotNull String getFriendlyName() { + public @NonNull String getFriendlyName() { return this.friendlyName; } @@ -74,7 +74,7 @@ public String toString() { } } - public static @NotNull NamelessVersion parse(@NotNull final String versionName) throws UnknownNamelessVersionException { + public static @NonNull NamelessVersion parse(@NonNull final String versionName) throws UnknownNamelessVersionException { Objects.requireNonNull(versionName, "Version name is null"); final NamelessVersion version = BY_NAME.get(versionName); if (version == null) { diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 5dfa8320..d8a66d67 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -11,8 +11,8 @@ import com.google.gson.JsonSyntaxException; import com.namelessmc.java_api.exception.ApiDisabledException; import com.namelessmc.java_api.logger.ApiLogger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.io.IOException; import java.io.InputStream; @@ -30,15 +30,15 @@ public class RequestHandler { - private final @NotNull URL apiUrl; - private final @NotNull Methanol httpClient; + private final @NonNull URL apiUrl; + private final @NonNull Methanol httpClient; private final @Nullable ApiLogger debugLogger; - private final @NotNull Gson gson; + private final @NonNull Gson gson; private final int responseLengthLimit; - RequestHandler(final @NotNull URL apiUrl, - final @NotNull Methanol httpClient, - final @NotNull Gson gson, + RequestHandler(final @NonNull URL apiUrl, + final @NonNull Methanol httpClient, + final @NonNull Gson gson, final @Nullable ApiLogger debugLogger, final int responseLengthLimit) { this.apiUrl = Objects.requireNonNull(apiUrl, "API URL is null"); @@ -48,13 +48,13 @@ public class RequestHandler { this.responseLengthLimit = responseLengthLimit; } - public @NotNull JsonObject post(final @NotNull String route, - final @NotNull JsonObject postData) throws NamelessException { + public @NonNull JsonObject post(final @NonNull String route, + final @NonNull JsonObject postData) throws NamelessException { return makeConnection(route, postData); } - public @NotNull JsonObject get(final @NotNull String route, - final @NotNull Object @NotNull... parameters) throws NamelessException { + public @NonNull JsonObject get(final @NonNull String route, + final @NonNull Object @NonNull... parameters) throws NamelessException { final StringBuilder urlBuilder = new StringBuilder(route); if (parameters.length > 0) { @@ -81,14 +81,14 @@ public class RequestHandler { return makeConnection(urlBuilder.toString(), null); } - private void debug(final @NotNull String message, - final @NotNull Supplier argsSupplier) { + private void debug(final @NonNull String message, + final @NonNull Supplier argsSupplier) { if (this.debugLogger != null) { this.debugLogger.log(String.format(message, argsSupplier.get())); } } - private @NotNull JsonObject makeConnection(final @NotNull String route, + private @NonNull JsonObject makeConnection(final @NonNull String route, final @Nullable JsonObject postBody) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); final MutableRequest request = MutableRequest.create(URI.create(this.apiUrl.toString() + route)); @@ -199,7 +199,7 @@ private String getBodyAsString(HttpResponse response) throws IOExce } } - private static @NotNull String regularAsciiOnly(@NotNull String message) { + private static @NonNull String regularAsciiOnly(@NonNull String message) { char[] chars = message.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; diff --git a/src/com/namelessmc/java_api/UserFilter.java b/src/com/namelessmc/java_api/UserFilter.java index 5c37ab31..bfb14a12 100644 --- a/src/com/namelessmc/java_api/UserFilter.java +++ b/src/com/namelessmc/java_api/UserFilter.java @@ -1,6 +1,6 @@ package com.namelessmc.java_api; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; public class UserFilter { @@ -9,13 +9,13 @@ public class UserFilter { public static UserFilter GROUP_ID = new UserFilter<>("group_id"); public static UserFilter INTEGRATION = new UserFilter<>("integration"); - private final @NotNull String filterName; + private final @NonNull String filterName; - public UserFilter(final @NotNull String filterName) { + public UserFilter(final @NonNull String filterName) { this.filterName = filterName; } - public @NotNull String getName() { + public @NonNull String getName() { return this.filterName; } diff --git a/src/com/namelessmc/java_api/VerificationInfo.java b/src/com/namelessmc/java_api/VerificationInfo.java index a1ab7975..3a60b3bd 100644 --- a/src/com/namelessmc/java_api/VerificationInfo.java +++ b/src/com/namelessmc/java_api/VerificationInfo.java @@ -2,14 +2,14 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; public class VerificationInfo { private final boolean verified; - private final @NotNull JsonObject json; + private final @NonNull JsonObject json; - VerificationInfo(final boolean verified, @NotNull final JsonObject json) { + VerificationInfo(final boolean verified, @NonNull final JsonObject json) { this.verified = verified; this.json = json; } @@ -18,7 +18,7 @@ public boolean isVerified() { return this.verified; } - public boolean isVerifiedCustom(@NotNull final String name) { + public boolean isVerifiedCustom(@NonNull final String name) { final JsonElement e = this.json.get(name); if (e == null) { throw new UnsupportedOperationException("The API did not return verification for '" + name + "'"); diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 57d324ef..9d00704d 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -3,8 +3,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.exception.UnknownNamelessVersionException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Objects; import java.util.Optional; @@ -13,12 +13,12 @@ public class Website implements LanguageEntity { - private final @NotNull String version; + private final @NonNull String version; private final @Nullable Update update; - private final @NotNull String@NotNull[] modules; - private final @NotNull String language; + private final @NonNull String@NonNull[] modules; + private final @NonNull String language; - Website(@NotNull final JsonObject json) { + Website(final @NonNull JsonObject json) { Objects.requireNonNull(json, "Provided json object is null"); this.version = json.get("nameless_version").getAsString(); @@ -44,12 +44,12 @@ public class Website implements LanguageEntity { this.language = json.get("language").getAsString(); } - @NotNull + @NonNull public String getVersion() { return this.version; } - @NotNull + @NonNull public NamelessVersion getParsedVersion() throws UnknownNamelessVersionException { return NamelessVersion.parse(this.version); } @@ -57,16 +57,16 @@ public NamelessVersion getParsedVersion() throws UnknownNamelessVersionException /** * @return Information about an update, or empty if no update is available. */ - public @NotNull Optional<@NotNull Update> getUpdate() { + public @NonNull Optional<@NonNull Update> getUpdate() { return Optional.ofNullable(this.update); } - public @NotNull String@NotNull [] getModules() { + public @NonNull String@NonNull [] getModules() { return this.modules; } @Override - public @NotNull String getLanguage() { + public @NonNull String getLanguage() { return this.language; } @@ -82,9 +82,9 @@ public NamelessVersion getParsedVersion() throws UnknownNamelessVersionException public static class Update { private final boolean isUrgent; - private final @NotNull String version; + private final @NonNull String version; - Update(final boolean isUrgent, @NotNull final String version) { + Update(final boolean isUrgent, @NonNull final String version) { this.isUrgent = isUrgent; this.version = version; } @@ -93,7 +93,7 @@ public boolean isUrgent() { return this.isUrgent; } - @NotNull + @NonNull public String getVersion() { return this.version; } diff --git a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java index 798e18b7..5d7b77d5 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java @@ -1,13 +1,13 @@ package com.namelessmc.java_api.integrations; import com.google.gson.JsonObject; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; public class DetailedDiscordIntegrationData extends DetailedIntegrationData implements IDiscordIntegrationData { private final long idLong; - public DetailedDiscordIntegrationData(@NotNull JsonObject json) { + public DetailedDiscordIntegrationData(final @NonNull JsonObject json) { super(json); this.idLong = Integer.parseInt(this.getIdentifier()); } diff --git a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java index 77e607d4..373c4113 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java @@ -1,21 +1,21 @@ package com.namelessmc.java_api.integrations; import com.google.gson.JsonObject; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Date; public class DetailedIntegrationData extends IntegrationData { private final boolean verified; - private final @NotNull Date linkedDate; + private final @NonNull Date linkedDate; private final boolean shownPublicly; - public DetailedIntegrationData(final @NotNull String integrationType, - final @NotNull String identifier, - final @NotNull String username, + public DetailedIntegrationData(final @NonNull String integrationType, + final @NonNull String identifier, + final @NonNull String username, final boolean verified, - final @NotNull Date linkedDate, + final @NonNull Date linkedDate, final boolean shownPublicly) { super(integrationType, identifier, username); this.verified = verified; @@ -23,7 +23,7 @@ public DetailedIntegrationData(final @NotNull String integrationType, this.shownPublicly = shownPublicly; } - public DetailedIntegrationData(final @NotNull JsonObject json) { + public DetailedIntegrationData(final @NonNull JsonObject json) { this( json.get("integration").getAsString(), json.get("identifier").getAsString(), @@ -38,7 +38,7 @@ public boolean isVerified() { return verified; } - public @NotNull Date getLinkedDate() { + public @NonNull Date getLinkedDate() { return this.linkedDate; } diff --git a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java index 31f9fe83..ad92dae1 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java @@ -2,21 +2,21 @@ import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.UUID; public class DetailedMinecraftIntegrationData extends DetailedIntegrationData implements IMinecraftIntegrationData { - private final @NotNull UUID uuid; + private final @NonNull UUID uuid; - public DetailedMinecraftIntegrationData(@NotNull JsonObject json) { + public DetailedMinecraftIntegrationData(final @NonNull JsonObject json) { super(json); this.uuid = NamelessAPI.websiteUuidToJavaUuid(this.getIdentifier()); } @Override - public @NotNull UUID getUniqueId() { + public @NonNull UUID getUniqueId() { return this.uuid; } } diff --git a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java index b3e6c519..48ebef72 100644 --- a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java @@ -1,13 +1,13 @@ package com.namelessmc.java_api.integrations; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; public class DiscordIntegrationData extends IntegrationData { private final long id; public DiscordIntegrationData(final long id, - final @NotNull String username) { + final @NonNull String username) { super(StandardIntegrationTypes.DISCORD, String.valueOf(id), username); this.id = id; } diff --git a/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java index 1385831d..f22732c4 100644 --- a/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java @@ -1,11 +1,11 @@ package com.namelessmc.java_api.integrations; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.UUID; public interface IMinecraftIntegrationData { - @NotNull UUID getUniqueId(); + @NonNull UUID getUniqueId(); } diff --git a/src/com/namelessmc/java_api/integrations/IntegrationData.java b/src/com/namelessmc/java_api/integrations/IntegrationData.java index 84aa07c8..81c5247b 100644 --- a/src/com/namelessmc/java_api/integrations/IntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/IntegrationData.java @@ -1,30 +1,30 @@ package com.namelessmc.java_api.integrations; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; public class IntegrationData { - private final @NotNull String integrationType; - private final @NotNull String identifier; - private final @NotNull String username; + private final @NonNull String integrationType; + private final @NonNull String identifier; + private final @NonNull String username; - public IntegrationData(final @NotNull String integrationType, - final @NotNull String identifier, - final @NotNull String username) { + public IntegrationData(final @NonNull String integrationType, + final @NonNull String identifier, + final @NonNull String username) { this.integrationType = integrationType; this.identifier = identifier; this.username = username; } - public @NotNull String getIntegrationType() { + public @NonNull String getIntegrationType() { return this.integrationType; } - public @NotNull String getIdentifier() { + public @NonNull String getIdentifier() { return this.identifier; } - public @NotNull String getUsername() { + public @NonNull String getUsername() { return this.username; } diff --git a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java index d8544a7f..1abd2b49 100644 --- a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java @@ -1,20 +1,20 @@ package com.namelessmc.java_api.integrations; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.UUID; public class MinecraftIntegrationData extends IntegrationData implements IMinecraftIntegrationData { - private final @NotNull UUID uuid; + private final @NonNull UUID uuid; - public MinecraftIntegrationData(final @NotNull UUID uuid, - final @NotNull String username) { + public MinecraftIntegrationData(final @NonNull UUID uuid, + final @NonNull String username) { super(StandardIntegrationTypes.MINECRAFT, uuid.toString(), username); this.uuid = uuid; } - public @NotNull UUID getUniqueId() { + public @NonNull UUID getUniqueId() { return this.uuid; } diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java index b95e443d..1cbc7d63 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java @@ -5,23 +5,19 @@ import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessException; import com.namelessmc.java_api.RequestHandler; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; +import java.util.*; public class WebsendAPI { - private final @NotNull RequestHandler requests; + private final @NonNull RequestHandler requests; - public WebsendAPI(@NotNull RequestHandler requests) { + public WebsendAPI(@NonNull RequestHandler requests) { this.requests = Objects.requireNonNull(requests, "Request handler is null"); } - public @NotNull List getCommands(int serverId) throws NamelessException { + public @NonNull List getCommands(int serverId) throws NamelessException { JsonObject response = this.requests.get("websend/commands","server_id", serverId); JsonArray commandsJson = response.getAsJsonArray("commands"); List commands = new ArrayList<>(commandsJson.size()); @@ -34,7 +30,7 @@ public WebsendAPI(@NotNull RequestHandler requests) { return Collections.unmodifiableList(commands); } - public void sendConsoleLog(int serverId, @NotNull Collection lines) throws NamelessException { + public void sendConsoleLog(int serverId, @NonNull Collection lines) throws NamelessException { JsonObject body = new JsonObject(); body.addProperty("server_id", serverId); JsonArray content = new JsonArray(); diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java b/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java index 05e3c21b..d4c97be3 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java @@ -1,23 +1,24 @@ package com.namelessmc.java_api.modules.websend; -import org.jetbrains.annotations.NotNull; +import org.checkerframework.checker.index.qual.Positive; +import org.checkerframework.checker.nullness.qual.NonNull; public class WebsendCommand { - private final int id; - private final @NotNull String commandLine; + private final @Positive int id; + private final @NonNull String commandLine; - public WebsendCommand(final int id, - final @NotNull String commandLine) { + public WebsendCommand(final @Positive int id, + final @NonNull String commandLine) { this.id = id; this.commandLine = commandLine; } - public int getId() { + public @Positive int getId() { return id; } - public @NotNull String getCommandLine() { + public @NonNull String getCommandLine() { return this.commandLine; } From d207bca6daf3589ea4d047ebf7ce88568d4c2af0 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 21 Apr 2022 15:34:25 +0200 Subject: [PATCH 026/269] Remove unused shade plugin --- pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pom.xml b/pom.xml index 45d600ac..4c424ef5 100644 --- a/pom.xml +++ b/pom.xml @@ -26,16 +26,6 @@ 11
- - - org.apache.maven.plugins - maven-shade-plugin - 3.3.0 - - false - true - - From 5127fc44e6fecd6206f1d4cadfbaedda36dc977c Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 21 Apr 2022 15:42:49 +0200 Subject: [PATCH 027/269] Enable checker framework warnings on compile --- pom.xml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pom.xml b/pom.xml index 4c424ef5..c6c2b939 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,36 @@ 11 11 + true + + 100 + 100 + + + + org.checkerframework + checker + 3.21.4 + + + + org.checkerframework.checker.nullness.NullnessChecker + org.checkerframework.checker.optional.OptionalChecker + org.checkerframework.checker.regex.RegexChecker + org.checkerframework.checker.formatter.FormatterChecker + + + -Awarns + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + From 0f5266d193a1b20419d49eb3fab0960d326f311c Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 21 Apr 2022 15:58:37 +0200 Subject: [PATCH 028/269] Resolved checker framework warnings --- .../java_api/CustomProfileField.java | 3 +- src/com/namelessmc/java_api/Group.java | 3 +- src/com/namelessmc/java_api/NamelessAPI.java | 52 +++++++++---------- .../java_api/NamelessApiBuilder.java | 10 ++-- src/com/namelessmc/java_api/NamelessUser.java | 37 ++++++------- .../namelessmc/java_api/NamelessVersion.java | 8 ++- .../namelessmc/java_api/VerificationInfo.java | 4 +- src/com/namelessmc/java_api/Website.java | 12 ++--- 8 files changed, 64 insertions(+), 65 deletions(-) diff --git a/src/com/namelessmc/java_api/CustomProfileField.java b/src/com/namelessmc/java_api/CustomProfileField.java index 5f3a8156..46c8b6d2 100644 --- a/src/com/namelessmc/java_api/CustomProfileField.java +++ b/src/com/namelessmc/java_api/CustomProfileField.java @@ -1,6 +1,7 @@ package com.namelessmc.java_api; import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Objects; @@ -52,7 +53,7 @@ public boolean isRequired() { } @Override - public boolean equals(Object other) { + public boolean equals(final @Nullable Object other) { return other instanceof CustomProfileField && ((CustomProfileField) other).id == this.id; } diff --git a/src/com/namelessmc/java_api/Group.java b/src/com/namelessmc/java_api/Group.java index f0d36f35..8451a60e 100644 --- a/src/com/namelessmc/java_api/Group.java +++ b/src/com/namelessmc/java_api/Group.java @@ -2,6 +2,7 @@ import com.google.gson.JsonObject; import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Objects; @@ -41,7 +42,7 @@ public int compareTo(final Group other) { } @Override - public boolean equals(Object other) { + public boolean equals(final @Nullable Object other) { return other instanceof Group && ((Group) other).id == this.id; } diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index e02c6366..83d11706 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -21,8 +21,7 @@ public final class NamelessAPI { static final Gson GSON = new Gson(); - @NonNull - private final RequestHandler requests; + private final @NonNull RequestHandler requests; // Not actually used by the Nameless Java API, but could be useful to applications using it. private final @NonNull URL apiUrl; @@ -55,8 +54,8 @@ public final class NamelessAPI { * Get announcements visible to guests. Use {@link NamelessUser#getAnnouncements()} for non-guest announcements. * @return List of announcements */ - @NonNull - public List<@NonNull Announcement> getAnnouncements() throws NamelessException { + + public @NonNull List<@NonNull Announcement> getAnnouncements() throws NamelessException { final JsonObject response = this.requests.get("announcements"); return getAnnouncements(response); } @@ -67,9 +66,8 @@ public final class NamelessAPI { * @return List of announcements visible to the user * @deprecated Use {@link NamelessUser#getAnnouncements()} */ - @NonNull @Deprecated - public List<@NonNull Announcement> getAnnouncements(@NonNull final NamelessUser user) throws NamelessException { + public @NonNull List<@NonNull Announcement> getAnnouncements(final @NonNull NamelessUser user) throws NamelessException { final JsonObject response = this.requests.get("users/" + user.getUserTransformer() + "/announcements"); return getAnnouncements(response); @@ -80,8 +78,7 @@ public final class NamelessAPI { * @param response Announcements json API response * @return List of {@link Announcement} objects */ - @NonNull - static List<@NonNull Announcement> getAnnouncements(@NonNull final JsonObject response) { + static @NonNull List<@NonNull Announcement> getAnnouncements(final @NonNull JsonObject response) { return StreamSupport.stream(response.getAsJsonArray("announcements").spliterator(), false) .map(JsonElement::getAsJsonObject) .map(Announcement::new) @@ -118,7 +115,7 @@ public FilteredUserListBuilder getRegisteredUsers() { } } - public @NonNull Optional getUser(@NonNull final String username) throws NamelessException { + public @NonNull Optional getUser(final @NonNull String username) throws NamelessException { final NamelessUser user = getUserLazy(username); if (user.exists()) { return Optional.of(user); @@ -127,7 +124,7 @@ public FilteredUserListBuilder getRegisteredUsers() { } } - public @NonNull Optional getUser(@NonNull final UUID uuid) throws NamelessException { + public @NonNull Optional getUser(final @NonNull UUID uuid) throws NamelessException { final NamelessUser user = getUserLazy(uuid); if (user.exists()) { return Optional.of(user); @@ -168,7 +165,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param uuid Minecraft UUID * @return Nameless user object, never null */ - public @NonNull NamelessUser getUserLazy(@NonNull final UUID uuid) { + public @NonNull NamelessUser getUserLazy(final @NonNull UUID uuid) { return new NamelessUser(this, -1, null, true, uuid, false, -1L); } @@ -178,7 +175,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param uuid The user's Mojang UUID * @return Nameless user object, never null */ - public NamelessUser getUserLazy(@NonNull final String username, @NonNull final UUID uuid) { + public NamelessUser getUserLazy(final @NonNull String username, final @NonNull UUID uuid) { return new NamelessUser(this, -1, username, true, uuid, false,-1L); } @@ -206,8 +203,7 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * @param id Group id * @return Optional with a group if the group exists, empty optional if it doesn't */ - @NonNull - public Optional<@NonNull Group> getGroup(final int id) throws NamelessException { + public @NonNull Optional<@NonNull Group> getGroup(final int id) throws NamelessException { final JsonObject response = this.requests.get("groups", "id", id); final JsonArray jsonArray = response.getAsJsonArray("groups"); if (jsonArray.size() != 1) { @@ -222,8 +218,7 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * @param name NamelessMC groups name * @return List of groups with this name, empty if there are no groups with this name. */ - @NonNull - public List<@NonNull Group> getGroup(@NonNull final String name) throws NamelessException { + public @NonNull List<@NonNull Group> getGroup(final @NonNull String name) throws NamelessException { Objects.requireNonNull(name, "Group name is null"); final JsonObject response = this.requests.get("groups", "name", name); return groupListFromJsonArray(response.getAsJsonArray("groups")); @@ -247,7 +242,7 @@ public NamelessUser getUserLazyDiscord(final long discordId) { .toArray(); } - private @NonNull List groupListFromJsonArray(@NonNull final JsonArray array) { + private @NonNull List groupListFromJsonArray(final @NonNull JsonArray array) { return StreamSupport.stream(array.spliterator(), false) .map(JsonElement::getAsJsonObject) .map(Group::new) @@ -265,9 +260,9 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * @return Email verification disabled: A link which the user needs to click to complete registration *
Email verification enabled: An empty string (the user needs to check their email to complete registration) */ - public @NonNull Optional registerUser(@NonNull final String username, - @NonNull final String email, - @NonNull IntegrationData@Nullable ... integrationData) + public @NonNull Optional registerUser(final @NonNull String username, + final @NonNull String email, + final @NonNull IntegrationData@Nullable ... integrationData) throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, CannotSendEmailException, IntegrationUsernameAlreadyExistsException, IntegrationIdAlreadyExistsException, InvalidEmailAddressException, EmailAlreadyUsedException { @@ -315,7 +310,7 @@ public NamelessUser getUserLazyDiscord(final long discordId) { * Set Discord bot URL (Nameless-Link internal webserver) * @param url Discord bot URL */ - public void setDiscordBotUrl(@NonNull final URL url) throws NamelessException { + public void setDiscordBotUrl(final @NonNull URL url) throws NamelessException { Objects.requireNonNull(url, "Bot url is null"); final JsonObject json = new JsonObject(); @@ -339,7 +334,7 @@ public void setDiscordGuildId(final long guildId) throws NamelessException { * @param userId Bot user id * @see #setDiscordBotSettings(URL, long, String, long) */ - public void setDiscordBotUser(@NonNull final String username, final long userId) throws NamelessException { + public void setDiscordBotUser(final @NonNull String username, final long userId) throws NamelessException { Objects.requireNonNull(username, "Bot username is null"); final JsonObject json = new JsonObject(); @@ -358,7 +353,10 @@ public void setDiscordBotUser(@NonNull final String username, final long userId) * @see #setDiscordGuildId(long) * @see #setDiscordBotUser(String, long) */ - public void setDiscordBotSettings(@NonNull final URL url, final long guildId, @NonNull final String username, final long userId) throws NamelessException { + public void setDiscordBotSettings(final @NonNull URL url, + final long guildId, + final @NonNull String username, + final long userId) throws NamelessException { Objects.requireNonNull(url, "Bot url is null"); Objects.requireNonNull(username, "Bot username is null"); @@ -374,7 +372,7 @@ public void setDiscordBotSettings(@NonNull final URL url, final long guildId, @N * Send list of Discord roles to the website for populating the dropdown in StaffCP > API > Group sync * @param discordRoles Map of Discord roles, key is role id, value is role name */ - public void submitDiscordRoleList(@NonNull final Map discordRoles) throws NamelessException { + public void submitDiscordRoleList(final @NonNull Map discordRoles) throws NamelessException { final JsonArray roles = new JsonArray(); discordRoles.forEach((id, name) -> { final JsonObject role = new JsonObject(); @@ -469,7 +467,7 @@ public void verifyIntegration(final @NonNull IntegrationData integrationData, * @param uuid UUID without dashes * @return UUID with dashes */ - public static @NonNull UUID websiteUuidToJavaUuid(@NonNull final String uuid) { + public static @NonNull UUID websiteUuidToJavaUuid(final @NonNull String uuid) { Objects.requireNonNull(uuid, "UUID string is null"); // Website sends UUIDs without dashes, so we can't use UUID#fromString // https://stackoverflow.com/a/30760478 @@ -482,8 +480,8 @@ public void verifyIntegration(final @NonNull IntegrationData integrationData, } } - @NonNull - public static NamelessApiBuilder builder(@NonNull URL apiUrl, @NonNull String apiKey) { + public static @NonNull NamelessApiBuilder builder(final @NonNull URL apiUrl, + final @NonNull String apiKey) { return new NamelessApiBuilder(apiUrl, apiKey); } diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 4dddd411..61181e9f 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -50,7 +50,7 @@ public class NamelessApiBuilder { .autoAcceptEncoding(true); } - public @NonNull NamelessApiBuilder userAgent(@NonNull final String userAgent) { + public @NonNull NamelessApiBuilder userAgent(final @NonNull String userAgent) { this.httpClientBuilder.userAgent(userAgent); return this; } @@ -117,24 +117,24 @@ public class NamelessApiBuilder { return this; } - public @NonNull NamelessApiBuilder withProxy(ProxySelector proxy) { + public @NonNull NamelessApiBuilder withProxy(final ProxySelector proxy) { this.httpClientBuilder.proxy(proxy); return this; } @Deprecated - public @NonNull NamelessApiBuilder proxy(ProxySelector proxy) { + public @NonNull NamelessApiBuilder proxy(final ProxySelector proxy) { this.httpClientBuilder.proxy(proxy); return this; } @Deprecated - public @NonNull NamelessApiBuilder withAuthenticator(Authenticator authenticator) { + public @NonNull NamelessApiBuilder withAuthenticator(final Authenticator authenticator) { this.httpClientBuilder.authenticator(authenticator); return this; } - public @NonNull NamelessApiBuilder authenticator(Authenticator authenticator) { + public @NonNull NamelessApiBuilder authenticator(final Authenticator authenticator) { this.httpClientBuilder.authenticator(authenticator); return this; } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index d7bd9417..16322589 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -18,10 +18,9 @@ public final class NamelessUser implements LanguageEntity { - @NonNull - private final NamelessAPI api; - @NonNull - private final RequestHandler requests; + + private final @NonNull NamelessAPI api; + private final @NonNull RequestHandler requests; private int id; // -1 if not known private @Nullable String username; // null if not known @@ -45,13 +44,13 @@ public final class NamelessUser implements LanguageEntity { * @param discordIdKnown True if it is known whether this user has a linked Discord id or not * @param discordId The user's discord id, or -1 if the user doesn't have a linked Discord id, or it is not known whether the user has a Discord id */ - NamelessUser(@NonNull final NamelessAPI api, + NamelessUser(final @NonNull NamelessAPI api, final int id, - @Nullable final String username, - boolean uuidKnown, - @Nullable UUID uuid, - boolean discordIdKnown, - long discordId + final @Nullable String username, + final boolean uuidKnown, + final @Nullable UUID uuid, + final boolean discordIdKnown, + final long discordId ) { this.api = api; this.requests = api.getRequestHandler(); @@ -68,7 +67,7 @@ public final class NamelessUser implements LanguageEntity { this.discordId = discordId; } - private JsonObject getUserInfo() throws NamelessException { + private @NonNull JsonObject getUserInfo() throws NamelessException { if (this._cachedUserInfo == null) { final JsonObject response; try { @@ -91,7 +90,7 @@ private JsonObject getUserInfo() throws NamelessException { return this._cachedUserInfo; } - public String getUserTransformer() { + public @NonNull String getUserTransformer() { if (id != -1) { return "id:" + this.id; } else if (this.uuidKnown && this.uuid != null) { @@ -106,8 +105,7 @@ public String getUserTransformer() { } } - @NonNull - public NamelessAPI getApi() { + public @NonNull NamelessAPI getApi() { return this.api; } @@ -266,21 +264,21 @@ public boolean isStaff() throws NamelessException { } } - public void addGroups(@NonNull final Group@NonNull ... groups) throws NamelessException { + public void addGroups(final @NonNull Group@NonNull ... groups) throws NamelessException { final JsonObject post = new JsonObject(); post.add("groups", groupsToJsonArray(groups)); this.requests.post("users/" + this.getUserTransformer() + "/groups/add", post); invalidateCache(); // Groups modified, invalidate cache } - public void removeGroups(@NonNull final Group@NonNull... groups) throws NamelessException { + public void removeGroups(final @NonNull Group@NonNull... groups) throws NamelessException { final JsonObject post = new JsonObject(); post.add("groups", groupsToJsonArray(groups)); this.requests.post("users/" + this.getUserTransformer() + "/groups/remove", post); invalidateCache(); // Groups modified, invalidate cache } - private JsonArray groupsToJsonArray(@NonNull final Group@NonNull [] groups) { + private JsonArray groupsToJsonArray(final @NonNull Group@NonNull [] groups) { final JsonArray array = new JsonArray(); for (final Group group : groups) { array.add(group.getId()); @@ -318,7 +316,7 @@ public int getNotificationCount() throws NamelessException { * @throws AlreadyHasOpenReportException If the user creating this report already has an open report for this user * @throws CannotReportSelfException If the user tries to report themselves */ - public void createReport(@NonNull final NamelessUser user, @NonNull final String reason) + public void createReport(final @NonNull NamelessUser user, final @NonNull String reason) throws NamelessException, ReportUserBannedException, AlreadyHasOpenReportException, CannotReportSelfException { Objects.requireNonNull(user, "User to report is null"); Objects.requireNonNull(reason, "Report reason is null"); @@ -394,8 +392,7 @@ public void setDiscordRoles(final long@NonNull[] roleIds) throws NamelessExcepti * Get announcements visible to this user * @return List of announcements visible to this user */ - @NonNull - public List<@NonNull Announcement> getAnnouncements() throws NamelessException { + public @NonNull List<@NonNull Announcement> getAnnouncements() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.getUserTransformer() + "/announcements"); return NamelessAPI.getAnnouncements(response); } diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index c3e3258f..476988b3 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -30,7 +30,11 @@ public enum NamelessVersion { private final boolean isBeta; @SuppressWarnings("SameParameterValue") - NamelessVersion(@NonNull final String name, @NonNull String friendlyName, final int major, final int minor, final boolean isBeta) { + NamelessVersion(final @NonNull String name, + final @NonNull String friendlyName, + final int major, + final int minor, + final boolean isBeta) { this.name = name; this.friendlyName = friendlyName; this.major = major; @@ -74,7 +78,7 @@ public String toString() { } } - public static @NonNull NamelessVersion parse(@NonNull final String versionName) throws UnknownNamelessVersionException { + public static @NonNull NamelessVersion parse(final @NonNull String versionName) throws UnknownNamelessVersionException { Objects.requireNonNull(versionName, "Version name is null"); final NamelessVersion version = BY_NAME.get(versionName); if (version == null) { diff --git a/src/com/namelessmc/java_api/VerificationInfo.java b/src/com/namelessmc/java_api/VerificationInfo.java index 3a60b3bd..8b164240 100644 --- a/src/com/namelessmc/java_api/VerificationInfo.java +++ b/src/com/namelessmc/java_api/VerificationInfo.java @@ -9,7 +9,7 @@ public class VerificationInfo { private final boolean verified; private final @NonNull JsonObject json; - VerificationInfo(final boolean verified, @NonNull final JsonObject json) { + VerificationInfo(final boolean verified, final @NonNull JsonObject json) { this.verified = verified; this.json = json; } @@ -18,7 +18,7 @@ public boolean isVerified() { return this.verified; } - public boolean isVerifiedCustom(@NonNull final String name) { + public boolean isVerifiedCustom(final @NonNull String name) { final JsonElement e = this.json.get(name); if (e == null) { throw new UnsupportedOperationException("The API did not return verification for '" + name + "'"); diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 9d00704d..df6e2683 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -44,13 +44,11 @@ public class Website implements LanguageEntity { this.language = json.get("language").getAsString(); } - @NonNull - public String getVersion() { + public @NonNull String getVersion() { return this.version; } - @NonNull - public NamelessVersion getParsedVersion() throws UnknownNamelessVersionException { + public @NonNull NamelessVersion getParsedVersion() throws UnknownNamelessVersionException { return NamelessVersion.parse(this.version); } @@ -84,7 +82,7 @@ public static class Update { private final boolean isUrgent; private final @NonNull String version; - Update(final boolean isUrgent, @NonNull final String version) { + Update(final boolean isUrgent, final @NonNull String version) { this.isUrgent = isUrgent; this.version = version; } @@ -93,8 +91,8 @@ public boolean isUrgent() { return this.isUrgent; } - @NonNull - public String getVersion() { + + public @NonNull String getVersion() { return this.version; } From 20a3f42037836b822737ad5a1751ddf036be867c Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 21 Apr 2022 16:00:56 +0200 Subject: [PATCH 029/269] Use gson instance from requesthandler --- src/com/namelessmc/java_api/NamelessAPI.java | 6 ------ src/com/namelessmc/java_api/NamelessUser.java | 2 +- src/com/namelessmc/java_api/RequestHandler.java | 4 ++++ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 83d11706..7b8aa58f 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -1,7 +1,6 @@ package com.namelessmc.java_api; import com.google.common.base.Preconditions; -import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -19,8 +18,6 @@ public final class NamelessAPI { - static final Gson GSON = new Gson(); - private final @NonNull RequestHandler requests; // Not actually used by the Nameless Java API, but could be useful to applications using it. @@ -35,17 +32,14 @@ public final class NamelessAPI { this.apiKey = apiKey; } - @NonNull RequestHandler getRequestHandler() { return this.requests; } - public @NonNull URL getApiUrl() { return this.apiUrl; } - public @NonNull String getApiKey() { return this.apiKey; } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 16322589..a5877ce8 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -384,7 +384,7 @@ public void createReport(final @NonNull UUID reportedUuid, public void setDiscordRoles(final long@NonNull[] roleIds) throws NamelessException { final JsonObject post = new JsonObject(); post.addProperty("user", this.getId()); - post.add("roles", NamelessAPI.GSON.toJsonTree(roleIds)); + post.add("roles", this.requests.gson().toJsonTree(roleIds)); this.requests.post("discord/set-roles", post); } diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index d8a66d67..4767a872 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -48,6 +48,10 @@ public class RequestHandler { this.responseLengthLimit = responseLengthLimit; } + @NonNull Gson gson() { + return this.gson; + } + public @NonNull JsonObject post(final @NonNull String route, final @NonNull JsonObject postData) throws NamelessException { return makeConnection(route, postData); From 17d794dcc1303ed1261bf8f27f3a9ee19c48d2bb Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 11:00:03 +0200 Subject: [PATCH 030/269] off by one error --- src/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 4767a872..ccf60d9f 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -170,7 +170,7 @@ private void debug(final @NonNull String message, int totalLengthLimit = 1950; // fit in a Discord message with safety margin String printableResponse = regularAsciiOnly(responseBody); message.append(Ascii.truncate(printableResponse, totalLengthLimit - printableResponse.length(), "[truncated]\n")); - if (message.charAt(message.length()) != '\n') { + if (message.charAt(message.length() - 1) != '\n') { message.append('\n'); } From 552d8cb87c23a8c95d5b0a7a2989b6448af0720c Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 12:34:35 +0200 Subject: [PATCH 031/269] Send UUIDs without dashes --- src/com/namelessmc/java_api/NamelessAPI.java | 4 ++++ src/com/namelessmc/java_api/NamelessUser.java | 2 +- .../java_api/integrations/MinecraftIntegrationData.java | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 7b8aa58f..7179dcab 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -474,6 +474,10 @@ public void verifyIntegration(final @NonNull IntegrationData integrationData, } } + public static @NonNull String javaUuidToWebsiteUuid(final @NonNull UUID uuid) { + return uuid.toString().replace("-", ""); + } + public static @NonNull NamelessApiBuilder builder(final @NonNull URL apiUrl, final @NonNull String apiKey) { return new NamelessApiBuilder(apiUrl, apiKey); diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index e43a8cd4..8a9840a5 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -94,7 +94,7 @@ public final class NamelessUser implements LanguageEntity { if (id != -1) { return "id:" + this.id; } else if (this.uuidKnown && this.uuid != null) { - return "integration_id:minecraft:" + this.uuid; + return "integration_id:minecraft:" + NamelessAPI.javaUuidToWebsiteUuid(uuid); } else if (this.discordIdKnown && this.discordId != -1) { return "integration_id:discord:" + this.discordId; } else if (this.username != null) { diff --git a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java index 1abd2b49..ba2e6c0a 100644 --- a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java @@ -1,5 +1,6 @@ package com.namelessmc.java_api.integrations; +import com.namelessmc.java_api.NamelessAPI; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.UUID; @@ -10,7 +11,7 @@ public class MinecraftIntegrationData extends IntegrationData implements IMinecr public MinecraftIntegrationData(final @NonNull UUID uuid, final @NonNull String username) { - super(StandardIntegrationTypes.MINECRAFT, uuid.toString(), username); + super(StandardIntegrationTypes.MINECRAFT, NamelessAPI.javaUuidToWebsiteUuid(uuid), username); this.uuid = uuid; } From 1f57231d5c7436a650775d7d1c94a62c51836b89 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 13:39:18 +0200 Subject: [PATCH 032/269] rewrite confusing NamelessUser constructor, allow any transformer --- .../java_api/FilteredUserListBuilder.java | 14 +- src/com/namelessmc/java_api/NamelessAPI.java | 112 +++++----------- src/com/namelessmc/java_api/NamelessUser.java | 122 +++++------------- 3 files changed, 68 insertions(+), 180 deletions(-) diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index 4c5d6764..d921fcf3 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -61,19 +61,7 @@ public class FilteredUserListBuilder { for (final JsonElement e : array) { final JsonObject o = e.getAsJsonObject(); final int id = o.get("id").getAsInt(); - final String username = o.get("username").getAsString(); - final UUID uuid; - if (o.has("uuid")) { - final String uuidString = o.get("uuid").getAsString(); - if (uuidString == null || uuidString.equals("none") || uuidString.equals("")) { - uuid = null; - } else { - uuid = NamelessAPI.websiteUuidToJavaUuid(uuidString); - } - } else { - uuid = null; - } - users.add(new NamelessUser(this.api, id, username, true, uuid, false, -1L)); + users.add(this.api.getUserLazy(id)); } return Collections.unmodifiableList(users); diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 7179dcab..a422c7e0 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -54,19 +54,6 @@ public final class NamelessAPI { return getAnnouncements(response); } - /** - * Get announcements visible to a {@link NamelessUser} - * @param user User to get visible announcements for - * @return List of announcements visible to the user - * @deprecated Use {@link NamelessUser#getAnnouncements()} - */ - @Deprecated - public @NonNull List<@NonNull Announcement> getAnnouncements(final @NonNull NamelessUser user) throws NamelessException { - final JsonObject response = this.requests.get("users/" + user.getUserTransformer() + "/announcements"); - - return getAnnouncements(response); - } - /** * Convert announcement json to objects * @param response Announcements json API response @@ -102,38 +89,32 @@ public FilteredUserListBuilder getRegisteredUsers() { public @NonNull Optional getUser(final int id) throws NamelessException { final NamelessUser user = getUserLazy(id); - if (user.exists()) { - return Optional.of(user); - } else { - return Optional.empty(); - } + return user.exists() ? Optional.of(user) : Optional.empty(); } - public @NonNull Optional getUser(final @NonNull String username) throws NamelessException { - final NamelessUser user = getUserLazy(username); - if (user.exists()) { - return Optional.of(user); - } else { - return Optional.empty(); - } + public @NonNull Optional getUserByUsername(final @NonNull String username) throws NamelessException { + final NamelessUser user = getUserByUsernameLazy(username); + return user.exists() ? Optional.of(user) : Optional.empty(); } - public @NonNull Optional getUser(final @NonNull UUID uuid) throws NamelessException { - final NamelessUser user = getUserLazy(uuid); - if (user.exists()) { - return Optional.of(user); - } else { - return Optional.empty(); - } + public @NonNull Optional getUserByMinecraftUuid(final @NonNull UUID uuid) throws NamelessException { + final NamelessUser user = getUserByMinecraftUuidLazy(uuid); + return user.exists() ? Optional.of(user) : Optional.empty(); } - public @NonNull Optional getUserByDiscordId(final long discordId) throws NamelessException { - final NamelessUser user = getUserLazyDiscord(discordId); - if (user.exists()) { - return Optional.of(user); - } else { - return Optional.empty(); - } + public @NonNull Optional getUserByMinecraftUsername(final @NonNull String username) throws NamelessException { + final NamelessUser user = getUserByMinecraftUsernameLazy(username); + return user.exists() ? Optional.of(user) : Optional.empty(); + } + + public @NonNull Optional getUserByDiscordId(final long id) throws NamelessException { + final NamelessUser user = getUserByDiscordIdLazy(id); + return user.exists() ? Optional.of(user) : Optional.empty(); + } + + public @NonNull Optional getUserByDiscordUsername(final @NonNull String username) throws NamelessException { + final NamelessUser user = getUserByDiscordUsernameLazy(username); + return user.exists() ? Optional.of(user) : Optional.empty(); } /** @@ -142,54 +123,31 @@ public FilteredUserListBuilder getRegisteredUsers() { * @return Nameless user object, never null */ public @NonNull NamelessUser getUserLazy(final int id) { - return new NamelessUser(this, id, null, false, null, false, -1L); + return new NamelessUser(this, id); } - /** - * Construct a NamelessUser object without making API requests (so without checking if the user exists) - * @param username NamelessMC user - * @return Nameless user object, never null - */ - public @NonNull NamelessUser getUserLazy(final @NonNull String username) { - return new NamelessUser(this, -1, username, false, null, false, -1L); + public @NonNull NamelessUser getUserLazy(final @NonNull String userTransformer) { + return new NamelessUser(this, userTransformer); } - /** - * Construct a NamelessUser object without making API requests (so without checking if the user exists) - * @param uuid Minecraft UUID - * @return Nameless user object, never null - */ - public @NonNull NamelessUser getUserLazy(final @NonNull UUID uuid) { - return new NamelessUser(this, -1, null, true, uuid, false, -1L); + public @NonNull NamelessUser getUserByUsernameLazy(final @NonNull String username) { + return getUserLazy("username:" + username); } - /** - * Construct a NamelessUser object without making API requests (so without checking if the user exists) - * @param username The user's username - * @param uuid The user's Mojang UUID - * @return Nameless user object, never null - */ - public NamelessUser getUserLazy(final @NonNull String username, final @NonNull UUID uuid) { - return new NamelessUser(this, -1, username, true, uuid, false,-1L); + public @NonNull NamelessUser getUserByMinecraftUuidLazy(final @NonNull UUID uuid) { + return getUserLazy("integration_id:minecraft:" + javaUuidToWebsiteUuid(uuid)); } - /** - * Construct a NamelessUser object without making API requests (so without checking if the user exists) - * @param id NamelessMC user id - * @return Nameless user object, never null - */ - public NamelessUser getUserLazy(final int id, final @NonNull String username, final @NonNull UUID uuid) { - return new NamelessUser(this, id, username, true, uuid, false, -1L); + public @NonNull NamelessUser getUserByMinecraftUsernameLazy(final @NonNull String username) { + return getUserLazy("integration_username:minecraft:" + username); } - /** - * Construct a NamelessUser object without making API requests (so without checking if the user exists) - * @param discordId Discord user id - * @return Nameless user object, never null - */ - public NamelessUser getUserLazyDiscord(final long discordId) { - Preconditions.checkArgument(discordId > 0, "Discord id must be a positive long"); - return new NamelessUser(this, -1, null, false, null, true, discordId); + public @NonNull NamelessUser getUserByDiscordIdLazy(final long id) { + return getUserLazy("integration_id:discord:" + id); + } + + public @NonNull NamelessUser getUserByDiscordUsernameLazy(final @NonNull String username) { + return getUserLazy("integration_username:discord:" + username); } /** diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 8a9840a5..282bfa46 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -9,6 +9,7 @@ import com.namelessmc.java_api.exception.CannotReportSelfException; import com.namelessmc.java_api.exception.ReportUserBannedException; import com.namelessmc.java_api.integrations.*; +import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -22,56 +23,36 @@ public final class NamelessUser implements LanguageEntity { private final @NonNull NamelessAPI api; private final @NonNull RequestHandler requests; + private @NonNull String userTransformer; private int id; // -1 if not known - private @Nullable String username; // null if not known - private boolean uuidKnown; - private @Nullable UUID uuid; // null if not known or not present - private boolean discordIdKnown; - private long discordId; // -1 if not known or not present // Do not use directly, instead use getUserInfo() and getIntegrations() private @Nullable JsonObject _cachedUserInfo; private @Nullable Map _cachedIntegrationData; - - /** - * Create a Nameless user. Only one of 'id', 'uuid', 'discordId' has to be provided. - * @param api Nameless API - * @param id The user's id, or -1 if not known - * @param username The user's username, or null if not known - * @param uuidKnown True if it is known whether this user has a UUID or not - * @param uuid The user's uuid, or null if the user doesn't have a UUID, or it is not known whether the user has a UUID - * @param discordIdKnown True if it is known whether this user has a linked Discord id or not - * @param discordId The user's discord id, or -1 if the user doesn't have a linked Discord id, or it is not known whether the user has a Discord id - */ NamelessUser(final @NonNull NamelessAPI api, - final int id, - final @Nullable String username, - final boolean uuidKnown, - final @Nullable UUID uuid, - final boolean discordIdKnown, - final long discordId + final @Positive int id ) { this.api = api; this.requests = api.getRequestHandler(); - if (id == -1 && username == null && !uuidKnown && !discordIdKnown) { - throw new IllegalArgumentException("You must specify at least one of ID, uuid, username, discordId"); - } - this.id = id; - this.username = username; - this.uuidKnown = uuidKnown; - this.uuid = uuid; - this.discordIdKnown = discordIdKnown; - this.discordId = discordId; + this.userTransformer = "id:" + id; + } + + NamelessUser(final @NonNull NamelessAPI api, final @NonNull String userTransformer) { + this.api = api; + this.requests = api.getRequestHandler(); + + this.id = -1; + this.userTransformer = userTransformer; } private @NonNull JsonObject getUserInfo() throws NamelessException { if (this._cachedUserInfo == null) { final JsonObject response; try { - response = this.requests.get("users/" + this.getUserTransformer()); + response = this.requests.get("users/" + this.userTransformer); } catch (final ApiError e) { if (e.getError() == ApiError.UNABLE_TO_FIND_USER) { throw new UserNotExistException(); @@ -85,26 +66,18 @@ public final class NamelessUser implements LanguageEntity { } this._cachedUserInfo = response; + + if (this.id < 0) { + // The id was unknown before (we were using some other identifier to find the user) + // Now that we do know the id, use the id to identify the user instead + this.id = response.get("id").getAsInt(); + this.userTransformer = "id:" + this.id; + } } return this._cachedUserInfo; } - public @NonNull String getUserTransformer() { - if (id != -1) { - return "id:" + this.id; - } else if (this.uuidKnown && this.uuid != null) { - return "integration_id:minecraft:" + NamelessAPI.javaUuidToWebsiteUuid(uuid); - } else if (this.discordIdKnown && this.discordId != -1) { - return "integration_id:discord:" + this.discordId; - } else if (this.username != null) { - return "username:" + username; - } else { - throw new IllegalStateException("ID, uuid, and username not known for this player. " + - "This should be impossible, the constructor checks for this."); - } - } - public @NonNull NamelessAPI getApi() { return this.api; } @@ -121,14 +94,6 @@ public final class NamelessUser implements LanguageEntity { public void invalidateCache() { this._cachedUserInfo = null; this._cachedIntegrationData = null; - if (this.id != -1) { - // Only clear if we know the user's NamelessMC user id, otherwise we remove - // the only way to identify this user - this.uuidKnown = false; - this.uuid = null; - this.discordIdKnown = false; - this.username = null; - } } public int getId() throws NamelessException { @@ -140,17 +105,13 @@ public int getId() throws NamelessException { } public @NonNull String getUsername() throws NamelessException { - if (this.username == null) { - this.username = this.getUserInfo().get("username").getAsString(); - } - - return this.username; + return this.getUserInfo().get("username").getAsString(); } public void updateUsername(final @NonNull String username) throws NamelessException { JsonObject post = new JsonObject(); post.addProperty("username", username); - this.requests.post("users/" + this.getUserTransformer() + "/update-username", post); + this.requests.post("users/" + this.userTransformer + "/update-username", post); } public boolean exists() throws NamelessException { @@ -258,14 +219,14 @@ public boolean isStaff() throws NamelessException { public void addGroups(final @NonNull Group@NonNull ... groups) throws NamelessException { final JsonObject post = new JsonObject(); post.add("groups", groupsToJsonArray(groups)); - this.requests.post("users/" + this.getUserTransformer() + "/groups/add", post); + this.requests.post("users/" + this.userTransformer + "/groups/add", post); invalidateCache(); // Groups modified, invalidate cache } public void removeGroups(final @NonNull Group@NonNull... groups) throws NamelessException { final JsonObject post = new JsonObject(); post.add("groups", groupsToJsonArray(groups)); - this.requests.post("users/" + this.getUserTransformer() + "/groups/remove", post); + this.requests.post("users/" + this.userTransformer + "/groups/remove", post); invalidateCache(); // Groups modified, invalidate cache } @@ -278,12 +239,12 @@ private JsonArray groupsToJsonArray(final @NonNull Group@NonNull [] groups) { } public int getNotificationCount() throws NamelessException { - final JsonObject response = this.requests.get("users/" + this.getUserTransformer() + "/notifications"); + final JsonObject response = this.requests.get("users/" + this.userTransformer + "/notifications"); return response.getAsJsonArray("notifications").size(); } public @NonNull List getNotifications() throws NamelessException { - final JsonObject response = this.requests.get("users/" + this.getUserTransformer() + "/notifications"); + final JsonObject response = this.requests.get("users/" + this.userTransformer + "/notifications"); final List notifications = new ArrayList<>(); response.getAsJsonArray("notifications").forEach((element) -> { @@ -384,7 +345,7 @@ public void setDiscordRoles(final long@NonNull[] roleIds) throws NamelessExcepti * @return List of announcements visible to this user */ public @NonNull List<@NonNull Announcement> getAnnouncements() throws NamelessException { - final JsonObject response = this.requests.get("users/" + this.getUserTransformer() + "/announcements"); + final JsonObject response = this.requests.get("users/" + this.userTransformer + "/announcements"); return NamelessAPI.getAnnouncements(response); } @@ -393,7 +354,7 @@ public void setDiscordRoles(final long@NonNull[] roleIds) throws NamelessExcepti * @since 2021-10-24 commit cce8d262b0be3f70818c188725cd7e7fc4fdbb9a */ public void banUser() throws NamelessException { - this.requests.post("users/" + this.getUserTransformer() + "/ban", new JsonObject()); + this.requests.post("users/" + this.userTransformer + "/ban", new JsonObject()); } public @NonNull Collection<@NonNull CustomProfileFieldValue> getProfileFields() throws NamelessException { @@ -450,41 +411,22 @@ public Map getIntegrations() throws NamelessExc } public Optional getMinecraftUuid() throws NamelessException { - if (this.uuidKnown) { - return Optional.ofNullable(this.uuid); - } - final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.MINECRAFT); - this.uuidKnown = true; - if (integration == null) { - this.uuid = null; - } else { - this.uuid = ((IMinecraftIntegrationData) integration).getUniqueId(); + return Optional.empty(); } - return this.getMinecraftUuid(); + return Optional.of(((IMinecraftIntegrationData) integration).getUniqueId()); } public Optional getDiscordId() throws NamelessException { - if (this.discordIdKnown) { - if (this.discordId == -1) { - return Optional.empty(); - } else { - return Optional.of(this.discordId); - } - } - final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.DISCORD); - this.discordIdKnown = true; if (integration == null) { - this.discordId = -1; - } else { - this.discordId = ((IDiscordIntegrationData) integration).getIdLong(); + return Optional.empty(); } - return this.getDiscordId(); + return Optional.of(((IDiscordIntegrationData) integration).getIdLong()); } } From 6f41a984aeee903135832173042fec6612a4cd51 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 14:03:06 +0200 Subject: [PATCH 033/269] update error code 38/39 to mean invalid in general --- src/com/namelessmc/java_api/ApiError.java | 6 +++--- src/com/namelessmc/java_api/NamelessAPI.java | 8 ++++---- .../IntegrationIdAlreadyExistsException.java | 13 ------------- .../IntegrationIdentifierInvalidException.java | 13 +++++++++++++ .../IntegrationUsernameAlreadyExistsException.java | 13 ------------- .../IntegrationUsernameInvalidException.java | 13 +++++++++++++ 6 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java create mode 100644 src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java delete mode 100644 src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java create mode 100644 src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java diff --git a/src/com/namelessmc/java_api/ApiError.java b/src/com/namelessmc/java_api/ApiError.java index 2af15597..11b1e26e 100644 --- a/src/com/namelessmc/java_api/ApiError.java +++ b/src/com/namelessmc/java_api/ApiError.java @@ -44,9 +44,9 @@ public class ApiError extends NamelessException { public static final int DISCORD_INTEGRATION_DISABLED = 34; // 35 intentionally missing public static final int REQUEST_NOT_AUTHORIZED = 36; - public static final int INVALID_INTEGRATION = 37; - public static final int INTEGRATION_USERNAME_ALREADY_EXISTS = 38; - public static final int INTEGRATION_ID_ALREADY_EXISTS = 39; + public static final int INTEGRATION_INVALID = 37; + public static final int INTEGRATION_USERNAME_INVALID = 38; + public static final int INTEGRATION_IDENTIFIER_INVALID = 39; private static final long serialVersionUID = 3093028909912281912L; diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index a422c7e0..939c54a6 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -216,8 +216,8 @@ public FilteredUserListBuilder getRegisteredUsers() { final @NonNull String email, final @NonNull IntegrationData@Nullable ... integrationData) throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, - CannotSendEmailException, IntegrationUsernameAlreadyExistsException, - IntegrationIdAlreadyExistsException, InvalidEmailAddressException, EmailAlreadyUsedException { + CannotSendEmailException, IntegrationUsernameInvalidException, + IntegrationIdentifierInvalidException, InvalidEmailAddressException, EmailAlreadyUsedException { Objects.requireNonNull(username, "Username is null"); Objects.requireNonNull(email, "Email address is null"); @@ -249,8 +249,8 @@ public FilteredUserListBuilder getRegisteredUsers() { case ApiError.INVALID_USERNAME: throw new InvalidUsernameException(); case ApiError.USERNAME_ALREADY_EXISTS: throw new UsernameAlreadyExistsException(); case ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL: throw new CannotSendEmailException(); - case ApiError.INTEGRATION_USERNAME_ALREADY_EXISTS: throw new IntegrationUsernameAlreadyExistsException(); - case ApiError.INTEGRATION_ID_ALREADY_EXISTS: throw new IntegrationIdAlreadyExistsException(); + case ApiError.INTEGRATION_USERNAME_INVALID: throw new IntegrationUsernameInvalidException(); + case ApiError.INTEGRATION_IDENTIFIER_INVALID: throw new IntegrationIdentifierInvalidException(); case ApiError.INVALID_EMAIL_ADDRESS: throw new InvalidEmailAddressException(); case ApiError.EMAIL_ALREADY_EXISTS: throw new EmailAlreadyUsedException(); default: throw e; diff --git a/src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java b/src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java deleted file mode 100644 index e7faca30..00000000 --- a/src/com/namelessmc/java_api/exception/IntegrationIdAlreadyExistsException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class IntegrationIdAlreadyExistsException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public IntegrationIdAlreadyExistsException() { - super(ApiError.INTEGRATION_ID_ALREADY_EXISTS); - } - -} diff --git a/src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java b/src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java new file mode 100644 index 00000000..7d2ad16b --- /dev/null +++ b/src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java @@ -0,0 +1,13 @@ +package com.namelessmc.java_api.exception; + +import com.namelessmc.java_api.ApiError; + +public class IntegrationIdentifierInvalidException extends ApiErrorException { + + private static final long serialVersionUID = 1L; + + public IntegrationIdentifierInvalidException() { + super(ApiError.INTEGRATION_IDENTIFIER_INVALID); + } + +} diff --git a/src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java b/src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java deleted file mode 100644 index d2462008..00000000 --- a/src/com/namelessmc/java_api/exception/IntegrationUsernameAlreadyExistsException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class IntegrationUsernameAlreadyExistsException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public IntegrationUsernameAlreadyExistsException() { - super(ApiError.INTEGRATION_USERNAME_ALREADY_EXISTS); - } - -} diff --git a/src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java b/src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java new file mode 100644 index 00000000..1d6bbd6b --- /dev/null +++ b/src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java @@ -0,0 +1,13 @@ +package com.namelessmc.java_api.exception; + +import com.namelessmc.java_api.ApiError; + +public class IntegrationUsernameInvalidException extends ApiErrorException { + + private static final long serialVersionUID = 1L; + + public IntegrationUsernameInvalidException() { + super(ApiError.INTEGRATION_USERNAME_INVALID); + } + +} From a29fe2863cd4891d5ac4baa552bcd094c85b2e82 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 15:01:06 +0200 Subject: [PATCH 034/269] Fix 1970 linked date --- .../java_api/integrations/DetailedIntegrationData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java index 373c4113..a8a99226 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java @@ -29,7 +29,7 @@ public DetailedIntegrationData(final @NonNull JsonObject json) { json.get("identifier").getAsString(), json.get("username").getAsString(), json.get("verified").getAsBoolean(), - new Date(json.get("linked_date").getAsLong()), + new Date(json.get("linked_date").getAsLong() * 1000), json.get("show_publicly").getAsBoolean() ); } From 1744211b1a23f6d639d139aafc6893d13365f4be Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 21:26:42 +0200 Subject: [PATCH 035/269] Update to new header --- src/com/namelessmc/java_api/NamelessApiBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 61181e9f..171c8da2 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -42,7 +42,7 @@ public class NamelessApiBuilder { this.gsonBuilder.disableHtmlEscaping(); this.httpClientBuilder = Methanol.newBuilder() - .defaultHeader("X-Api-Key", this.apiKey) + .defaultHeader("Authorization", "Bearer " + this.apiKey) .userAgent(DEFAULT_USER_AGENT) .readTimeout(DEFAULT_TIMEOUT) .requestTimeout(DEFAULT_TIMEOUT) From e66e65c1ef0cae39e24cbeaf506d5f1bbeca97be Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 21:35:54 +0200 Subject: [PATCH 036/269] Remove deprecated builder methods --- .../java_api/NamelessApiBuilder.java | 58 +------------------ 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 171c8da2..dc4305d5 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -55,61 +55,31 @@ public class NamelessApiBuilder { return this; } + @Deprecated public @NonNull NamelessApiBuilder debug(final boolean debug) { if (debug) { - return this.withStdErrDebugLogging(); + return this.stdErrDebugLogger(); } else { this.debugLogger = null; return this; } } - @Deprecated - public @NonNull NamelessApiBuilder withStdErrDebugLogging() { - this.debugLogger = PrintStreamLogger.DEFAULT_INSTANCE; - return this; - } - public @NonNull NamelessApiBuilder stdErrDebugLogger() { this.debugLogger = PrintStreamLogger.DEFAULT_INSTANCE; return this; } - @Deprecated - public @NonNull NamelessApiBuilder withSlf4jDebugLogging() { - this.debugLogger = Slf4jLogger.DEFAULT_INSTANCE; - return this; - } - public @NonNull NamelessApiBuilder slf4jDebugLogger() { this.debugLogger = Slf4jLogger.DEFAULT_INSTANCE; return this; } - @Deprecated - public @NonNull NamelessApiBuilder withCustomDebugLogger(final @Nullable ApiLogger debugLogger) { - this.debugLogger = debugLogger; - return this; - } - public @NonNull NamelessApiBuilder customDebugLogger(final @Nullable ApiLogger debugLogger) { this.debugLogger = debugLogger; return this; } - @Deprecated - public @NonNull NamelessApiBuilder withTimeoutMillis(final int timeout) { - return this.withTimeout(Duration.ofMillis(timeout)); - } - - @Deprecated - public @NonNull NamelessApiBuilder withTimeout(final @NonNull Duration timeout) { - this.httpClientBuilder.readTimeout(timeout) - .requestTimeout(timeout) - .connectTimeout(timeout); - return this; - } - public @NonNull NamelessApiBuilder timeout(final @NonNull Duration timeout) { this.httpClientBuilder.readTimeout(timeout) .requestTimeout(timeout) @@ -122,40 +92,16 @@ public class NamelessApiBuilder { return this; } - @Deprecated - public @NonNull NamelessApiBuilder proxy(final ProxySelector proxy) { - this.httpClientBuilder.proxy(proxy); - return this; - } - - @Deprecated - public @NonNull NamelessApiBuilder withAuthenticator(final Authenticator authenticator) { - this.httpClientBuilder.authenticator(authenticator); - return this; - } - public @NonNull NamelessApiBuilder authenticator(final Authenticator authenticator) { this.httpClientBuilder.authenticator(authenticator); return this; } - @Deprecated - public @NonNull NamelessApiBuilder withPrettyJson() { - gsonBuilder.setPrettyPrinting(); - return this; - } - public @NonNull NamelessApiBuilder pettyJsonRequests() { gsonBuilder.setPrettyPrinting(); return this; } - @Deprecated - public @NonNull NamelessApiBuilder withResponseSizeLimit(int responseSizeLimitBytes) { - this.responseSizeLimit = responseSizeLimitBytes; - return this; - } - public @NonNull NamelessApiBuilder responseSizeLimit(int responseSizeLimitBytes) { this.responseSizeLimit = responseSizeLimitBytes; return this; From 946c1ecf7887d64b554d152dd3f41a935dfaa649 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 22:05:36 +0200 Subject: [PATCH 037/269] Fix checker framework warnings --- src/com/namelessmc/java_api/NamelessUser.java | 49 ++++++++++--------- .../namelessmc/java_api/RequestHandler.java | 28 ++++++----- .../DetailedDiscordIntegrationData.java | 2 +- .../integrations/DetailedIntegrationData.java | 8 +-- .../DetailedMinecraftIntegrationData.java | 2 +- .../integrations/DiscordIntegrationData.java | 2 +- .../integrations/IntegrationData.java | 7 +-- .../MinecraftIntegrationData.java | 2 +- 8 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 282bfa46..744b621a 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -49,33 +49,35 @@ public final class NamelessUser implements LanguageEntity { } private @NonNull JsonObject getUserInfo() throws NamelessException { - if (this._cachedUserInfo == null) { - final JsonObject response; - try { - response = this.requests.get("users/" + this.userTransformer); - } catch (final ApiError e) { - if (e.getError() == ApiError.UNABLE_TO_FIND_USER) { - throw new UserNotExistException(); - } else { - throw e; - } - } + if (this._cachedUserInfo != null) { + return this._cachedUserInfo; + } - if (!response.get("exists").getAsBoolean()) { + final JsonObject response; + try { + response = this.requests.get("users/" + this.userTransformer); + } catch (final ApiError e) { + if (e.getError() == ApiError.UNABLE_TO_FIND_USER) { throw new UserNotExistException(); + } else { + throw e; } + } + + if (!response.get("exists").getAsBoolean()) { + throw new UserNotExistException(); + } - this._cachedUserInfo = response; + this._cachedUserInfo = response; - if (this.id < 0) { - // The id was unknown before (we were using some other identifier to find the user) - // Now that we do know the id, use the id to identify the user instead - this.id = response.get("id").getAsInt(); - this.userTransformer = "id:" + this.id; - } + if (this.id < 0) { + // The id was unknown before (we were using some other identifier to find the user) + // Now that we do know the id, use the id to identify the user instead + this.id = response.get("id").getAsInt(); + this.userTransformer = "id:" + this.id; } - return this._cachedUserInfo; + return response; } public @NonNull NamelessAPI getApi() { @@ -390,7 +392,7 @@ public Map getIntegrations() throws NamelessExc final JsonObject userInfo = this.getUserInfo(); final JsonArray integrationsJsonArray = userInfo.getAsJsonArray("integrations"); - this._cachedIntegrationData = new HashMap<>(integrationsJsonArray.size()); + Map integrationDataMap = new HashMap<>(integrationsJsonArray.size()); for (JsonElement integrationElement : integrationsJsonArray) { JsonObject integrationJson = integrationElement.getAsJsonObject(); String integrationName = integrationJson.get("integration").getAsString(); @@ -405,9 +407,10 @@ public Map getIntegrations() throws NamelessExc default: integrationData = new DetailedIntegrationData(integrationJson); } - this._cachedIntegrationData.put(integrationName, integrationData); + integrationDataMap.put(integrationName, integrationData); } - return this._cachedIntegrationData; + this._cachedIntegrationData = integrationDataMap; + return integrationDataMap; } public Optional getMinecraftUuid() throws NamelessException { diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index ccf60d9f..c629c850 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -85,28 +85,33 @@ public class RequestHandler { return makeConnection(urlBuilder.toString(), null); } - private void debug(final @NonNull String message, - final @NonNull Supplier argsSupplier) { + private void debug(final @NonNull String message) { if (this.debugLogger != null) { - this.debugLogger.log(String.format(message, argsSupplier.get())); + this.debugLogger.log(message); + } + } + + private void debug(final @NonNull Supplier messageSupplier) { + if (this.debugLogger != null) { + this.debugLogger.log(messageSupplier.get()); } } private @NonNull JsonObject makeConnection(final @NonNull String route, final @Nullable JsonObject postBody) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); - final MutableRequest request = MutableRequest.create(URI.create(this.apiUrl.toString() + route)); + final MutableRequest request = MutableRequest.create(URI.create(this.apiUrl + route)); - debug("Making connection %s to %s", - () -> new Object[]{ postBody != null ? "POST" : "GET", request.uri()}); + debug(() -> "Making connection " + (postBody != null ? "POST" : "GET") + " to " + request.uri()); if (postBody != null) { byte[] postBytes = gson.toJson(postBody).getBytes(StandardCharsets.UTF_8); request.POST(HttpRequest.BodyPublishers.ofByteArray(postBytes)); request.header("Content-Type", "application/json"); - debug("Post body below\n-----------------\n%s\n-----------------", - () -> new Object[] { new String(postBytes, StandardCharsets.UTF_8) }); + debug("Post body below\n-----------------"); + debug(() -> new String(postBytes, StandardCharsets.UTF_8)); + debug("\n-----------------"); } else { request.GET(); } @@ -123,7 +128,7 @@ private void debug(final @NonNull String message, final StringBuilder message = new StringBuilder("Network connection error (not a Nameless issue)."); if (exceptionMessage != null && exceptionMessage.contains("unable to find valid certification path to requested target")) { - message.append("\n HINT: Your certificate is invalid or incomplete. Ensure your website uses a valid *full chain* SSL/TLS certificate."); + message.append("\nHINT: Your certificate is invalid or incomplete. Ensure your website uses a valid *full chain* SSL/TLS certificate."); } message.append(" IOException: "); message.append(e.getMessage()); @@ -132,8 +137,9 @@ private void debug(final @NonNull String message, throw new RuntimeException(e); } - debug("Website response below\n-----------------\n%s\n-----------------", - () -> new Object[] { regularAsciiOnly(responseBody) }); + debug("Website response below\n-----------------"); + debug(() -> regularAsciiOnly(responseBody)); + debug("\n-----------------"); if (responseBody.length() == 0) { throw new NamelessException("Website sent empty response with status code " + statusCode); diff --git a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java index 5d7b77d5..e66da813 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java @@ -13,7 +13,7 @@ public DetailedDiscordIntegrationData(final @NonNull JsonObject json) { } @Override - public long getIdLong() { + public final long getIdLong() { return this.idLong; } } diff --git a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java index a8a99226..5b33ec63 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java @@ -34,15 +34,15 @@ public DetailedIntegrationData(final @NonNull JsonObject json) { ); } - public boolean isVerified() { - return verified; + public final boolean isVerified() { + return this.verified; } - public @NonNull Date getLinkedDate() { + public final @NonNull Date getLinkedDate() { return this.linkedDate; } - public boolean isShownPublicly() { + public final boolean isShownPublicly() { return this.shownPublicly; } diff --git a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java index ad92dae1..71e2a4a3 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java @@ -16,7 +16,7 @@ public DetailedMinecraftIntegrationData(final @NonNull JsonObject json) { } @Override - public @NonNull UUID getUniqueId() { + public final @NonNull UUID getUniqueId() { return this.uuid; } } diff --git a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java index 48ebef72..812ccec6 100644 --- a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java @@ -12,7 +12,7 @@ public DiscordIntegrationData(final long id, this.id = id; } - public long getIdLong() { + public final long getIdLong() { return this.id; } diff --git a/src/com/namelessmc/java_api/integrations/IntegrationData.java b/src/com/namelessmc/java_api/integrations/IntegrationData.java index 81c5247b..7b3108e4 100644 --- a/src/com/namelessmc/java_api/integrations/IntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/IntegrationData.java @@ -1,5 +1,6 @@ package com.namelessmc.java_api.integrations; +import org.checkerframework.checker.initialization.qual.UnknownInitialization; import org.checkerframework.checker.nullness.qual.NonNull; public class IntegrationData { @@ -16,15 +17,15 @@ public IntegrationData(final @NonNull String integrationType, this.username = username; } - public @NonNull String getIntegrationType() { + public final @NonNull String getIntegrationType(@UnknownInitialization(IntegrationData.class) IntegrationData this) { return this.integrationType; } - public @NonNull String getIdentifier() { + public final @NonNull String getIdentifier(@UnknownInitialization(IntegrationData.class) IntegrationData this) { return this.identifier; } - public @NonNull String getUsername() { + public final @NonNull String getUsername(@UnknownInitialization(IntegrationData.class) IntegrationData this) { return this.username; } diff --git a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java index ba2e6c0a..05a7bf04 100644 --- a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java @@ -15,7 +15,7 @@ public MinecraftIntegrationData(final @NonNull UUID uuid, this.uuid = uuid; } - public @NonNull UUID getUniqueId() { + public final @NonNull UUID getUniqueId() { return this.uuid; } From 7e5b0c28c1947caefc5caa2d3a54b1f9bfbb8196 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Apr 2022 23:05:03 +0200 Subject: [PATCH 038/269] Add support for verify endpoint --- src/com/namelessmc/java_api/NamelessUser.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 744b621a..41e55eea 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -5,9 +5,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.Notification.NotificationType; -import com.namelessmc.java_api.exception.AlreadyHasOpenReportException; -import com.namelessmc.java_api.exception.CannotReportSelfException; -import com.namelessmc.java_api.exception.ReportUserBannedException; +import com.namelessmc.java_api.exception.*; import com.namelessmc.java_api.integrations.*; import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.checker.nullness.qual.NonNull; @@ -432,4 +430,21 @@ public Optional getDiscordId() throws NamelessException { return Optional.of(((IDiscordIntegrationData) integration).getIdLong()); } + public void verify(final @NonNull String verificationCode) throws NamelessException, AccountAlreadyActivatedException, InvalidValidateCodeException { + final JsonObject body = new JsonObject(); + body.addProperty("code", verificationCode); + try { + this.requests.post("users/" + this.userTransformer + "/verify", body); + } catch (final ApiError e) { + switch(e.getError()) { + case ApiError.ACCOUNT_ALREADY_ACTIVATED: + throw new AccountAlreadyActivatedException(); + case ApiError.INVALID_VALIDATE_CODE: + throw new InvalidValidateCodeException(); + default: + throw e; + } + } + } + } From 653d01468bd9f79295c32a36cb8d6278889d7311 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 25 Apr 2022 11:03:24 +0200 Subject: [PATCH 039/269] Remove invalid api key error code --- src/com/namelessmc/java_api/ApiError.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/ApiError.java b/src/com/namelessmc/java_api/ApiError.java index 11b1e26e..ff38be50 100644 --- a/src/com/namelessmc/java_api/ApiError.java +++ b/src/com/namelessmc/java_api/ApiError.java @@ -8,7 +8,7 @@ public class ApiError extends NamelessException { public static final int UNKNOWN_ERROR = 0; - public static final int INVALID_API_KEY = 1; + // 1 intentionally missing // 2 intentionally missing public static final int INVALID_API_METHOD = 3; public static final int NO_UNIQUE_SITE_ID_AVAILABLE = 4; From d3fb77cf1614eb092a6b012bf0aa8d12789b774d Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 28 Apr 2022 10:20:04 +0200 Subject: [PATCH 040/269] Check if uri host is valid --- src/com/namelessmc/java_api/RequestHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index c629c850..e936f736 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -100,7 +100,11 @@ private void debug(final @NonNull Supplier messageSupplier) { private @NonNull JsonObject makeConnection(final @NonNull String route, final @Nullable JsonObject postBody) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); - final MutableRequest request = MutableRequest.create(URI.create(this.apiUrl + route)); + final URI uri = URI.create(this.apiUrl + route); + if (uri.getHost() == null) { + throw new NamelessException("URI has empty host, does it contain invalid characters? Please note that although underscores are legal in subdomains, the Java URI class does not accept them."); + } + final MutableRequest request = MutableRequest.create(uri); debug(() -> "Making connection " + (postBody != null ? "POST" : "GET") + " to " + request.uri()); From 81c178fcac94c3e2db2a9e11047849d26c27ccf6 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 28 Apr 2022 10:23:29 +0200 Subject: [PATCH 041/269] Fix negative max length issue --- src/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index e936f736..3c6b9218 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -179,7 +179,7 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append("-----------------\n"); int totalLengthLimit = 1950; // fit in a Discord message with safety margin String printableResponse = regularAsciiOnly(responseBody); - message.append(Ascii.truncate(printableResponse, totalLengthLimit - printableResponse.length(), "[truncated]\n")); + message.append(Ascii.truncate(printableResponse, totalLengthLimit, "[truncated]\n")); if (message.charAt(message.length() - 1) != '\n') { message.append('\n'); } From c15b376ff92b369fa49b2a8f1473293a6b3151eb Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 28 Apr 2022 10:29:32 +0200 Subject: [PATCH 042/269] more explanation --- src/com/namelessmc/java_api/RequestHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 3c6b9218..ef6e37be 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -102,7 +102,9 @@ private void debug(final @NonNull Supplier messageSupplier) { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); final URI uri = URI.create(this.apiUrl + route); if (uri.getHost() == null) { - throw new NamelessException("URI has empty host, does it contain invalid characters? Please note that although underscores are legal in subdomains, the Java URI class does not accept them."); + throw new NamelessException("URI has empty host, does it contain invalid characters? Please note that although underscores are " + + "legal in domain names, the Java URI class (and the Java HttpClient) does not accept them, because it uses the specification " + + "for 'host names' not 'domain names'."); } final MutableRequest request = MutableRequest.create(uri); From f7fbb29a23361a00d0c91204bcaf52d1acfc03b8 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 30 Apr 2022 12:09:43 +0200 Subject: [PATCH 043/269] improve exception hints --- .../namelessmc/java_api/RequestHandler.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index ef6e37be..9436ec73 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -131,13 +131,21 @@ private void debug(final @NonNull Supplier messageSupplier) { responseBody = getBodyAsString(httpResponse); } catch (final IOException e) { final @Nullable String exceptionMessage = e.getMessage(); - final StringBuilder message = new StringBuilder("Network connection error (not a Nameless issue)."); - if (exceptionMessage != null && - exceptionMessage.contains("unable to find valid certification path to requested target")) { - message.append("\nHINT: Your certificate is invalid or incomplete. Ensure your website uses a valid *full chain* SSL/TLS certificate."); - } - message.append(" IOException: "); + final StringBuilder message = new StringBuilder("Network connection error (not a Nameless issue). IOException message: \""); message.append(e.getMessage()); + message.append('"'); + if (exceptionMessage != null) { + if (exceptionMessage.contains("unable to find valid certification path to requested target")) { + message.append("\nHINT: Your HTTPS certificate is probably valid, but is it complete? Ensure your website uses a valid *full chain* SSL/TLS certificate."); + } else if (exceptionMessage.contains("No subject alternative DNS name matching")) { + message.append("\nHINT: Is your HTTPS certificate valid? Is it for the correct domain?"); + } else if (exceptionMessage.contains("Connect timed out")) { + message.append("\nHINT: Is a webserver running at the provided domain? Are we blocked by a firewall? Is your webserver fast enough?"); + } else if (exceptionMessage.contains("Connection refused")) { + message.append("\nHINT: Is the domain correct? Is your webserver running? Are we blocked by a firewall?"); + } + } + throw new NamelessException(message.toString(), e); } catch (InterruptedException e) { throw new RuntimeException(e); @@ -167,7 +175,7 @@ private void debug(final @NonNull Supplier messageSupplier) { if (statusCode >= 301 && statusCode <= 303) { message.append("HINT: The URL results in a redirect. If your URL uses http://, change to https://. If your website forces www., make sure to add www. to the url.\n"); } else if (statusCode == 520 || statusCode == 521) { - message.append("HINT: Status code 520/521 is sent by CloudFlare when the backend webserver is down or having issues.\n"); + message.append("HINT: Status code 520/521 is sent by CloudFlare when the backend webserver is down or having issues. Check your webserver and CloudFlare configuration.\n"); } else if (responseBody.contains("/aes.js")) { message.append("HINT: It looks like requests are being blocked by your web server or a proxy. "); message.append("This is a common occurrence with free web hosting services; they usually don't allow API access.\n"); From 711d9ae0aaa05927ea678c4f9342c87e29bca0c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 May 2022 11:09:07 +0000 Subject: [PATCH 044/269] Bump checker-qual from 3.21.4 to 3.22.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.21.4 to 3.22.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.21.4...checker-framework-3.22.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6c2b939..ac07f493 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.21.4 + 3.22.0 From 9e0e6621d4e54e07bc95e688d13c96fc5be567b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 11:15:35 +0000 Subject: [PATCH 045/269] Bump methanol from 1.6.0 to 1.7.0 Bumps [methanol](https://github.com/mizosoft/methanol) from 1.6.0 to 1.7.0. - [Release notes](https://github.com/mizosoft/methanol/releases) - [Changelog](https://github.com/mizosoft/methanol/blob/master/CHANGELOG.md) - [Commits](https://github.com/mizosoft/methanol/compare/v1.6.0...v1.7.0) --- updated-dependencies: - dependency-name: com.github.mizosoft.methanol:methanol dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ac07f493..e619207b 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ com.github.mizosoft.methanol methanol - 1.6.0 + 1.7.0 From f2757a6f488a7a25a96ec82d995cea657e67c95c Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 18 May 2022 15:30:27 +0200 Subject: [PATCH 046/269] Add method to get raw json --- .../namelessmc/java_api/FilteredUserListBuilder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index d921fcf3..f8703c19 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -38,7 +38,7 @@ public class FilteredUserListBuilder { return this; } - public @NonNull List<@NonNull NamelessUser> makeRequest() throws NamelessException { + public JsonObject makeRawRequest() throws NamelessException { final Object[] parameters; if (filters != null) { int filterCount = filters.size(); @@ -55,15 +55,18 @@ public class FilteredUserListBuilder { parameters = new Object[0]; } - final JsonObject response = this.api.getRequestHandler().get("users", parameters); + return this.api.getRequestHandler().get("users", parameters); + } + + public @NonNull List<@NonNull NamelessUser> makeRequest() throws NamelessException { + final JsonObject response = this.makeRawRequest(); final JsonArray array = response.getAsJsonArray("users"); final List users = new ArrayList<>(array.size()); for (final JsonElement e : array) { final JsonObject o = e.getAsJsonObject(); final int id = o.get("id").getAsInt(); - users.add(this.api.getUserLazy(id)); + users.add(new NamelessUser(this.api, id)); } - return Collections.unmodifiableList(users); } From 106b3590f8df56523d587581f600933fb6546836 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 19 May 2022 10:20:55 +0200 Subject: [PATCH 047/269] More compact debug logging --- src/com/namelessmc/java_api/RequestHandler.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 9436ec73..802ce55e 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -115,9 +115,7 @@ private void debug(final @NonNull Supplier messageSupplier) { request.POST(HttpRequest.BodyPublishers.ofByteArray(postBytes)); request.header("Content-Type", "application/json"); - debug("Post body below\n-----------------"); - debug(() -> new String(postBytes, StandardCharsets.UTF_8)); - debug("\n-----------------"); + debug(() -> "POST request body:\n" + new String(postBytes, StandardCharsets.UTF_8)); } else { request.GET(); } @@ -151,9 +149,7 @@ private void debug(final @NonNull Supplier messageSupplier) { throw new RuntimeException(e); } - debug("Website response below\n-----------------"); - debug(() -> regularAsciiOnly(responseBody)); - debug("\n-----------------"); + debug(() -> "Website response body:\n" + regularAsciiOnly(responseBody)); if (responseBody.length() == 0) { throw new NamelessException("Website sent empty response with status code " + statusCode); From 58ffa02545a12c6a1ce2ddbfa9842352a8852ff5 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 24 May 2022 10:30:23 +0200 Subject: [PATCH 048/269] Use nullables instead of optionals --- src/com/namelessmc/java_api/ApiError.java | 4 +- src/com/namelessmc/java_api/NamelessAPI.java | 44 ++++++++++--------- src/com/namelessmc/java_api/NamelessUser.java | 19 ++++---- src/com/namelessmc/java_api/Website.java | 10 ++--- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/com/namelessmc/java_api/ApiError.java b/src/com/namelessmc/java_api/ApiError.java index ff38be50..72ccdc0c 100644 --- a/src/com/namelessmc/java_api/ApiError.java +++ b/src/com/namelessmc/java_api/ApiError.java @@ -63,8 +63,8 @@ public int getError() { return this.code; } - public @NonNull Optional<@NonNull String> getMeta() { - return Optional.ofNullable(meta); + public @Nullable String getMeta() { + return meta; } } diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 939c54a6..13d05b74 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -87,34 +87,34 @@ public FilteredUserListBuilder getRegisteredUsers() { return new FilteredUserListBuilder(this); } - public @NonNull Optional getUser(final int id) throws NamelessException { + public @Nullable NamelessUser getUser(final int id) throws NamelessException { final NamelessUser user = getUserLazy(id); - return user.exists() ? Optional.of(user) : Optional.empty(); + return user.exists() ? user : null; } - public @NonNull Optional getUserByUsername(final @NonNull String username) throws NamelessException { + public @Nullable NamelessUser getUserByUsername(final @NonNull String username) throws NamelessException { final NamelessUser user = getUserByUsernameLazy(username); - return user.exists() ? Optional.of(user) : Optional.empty(); + return user.exists() ? user : null; } - public @NonNull Optional getUserByMinecraftUuid(final @NonNull UUID uuid) throws NamelessException { + public @Nullable NamelessUser getUserByMinecraftUuid(final @NonNull UUID uuid) throws NamelessException { final NamelessUser user = getUserByMinecraftUuidLazy(uuid); - return user.exists() ? Optional.of(user) : Optional.empty(); + return user.exists() ? user : null; } - public @NonNull Optional getUserByMinecraftUsername(final @NonNull String username) throws NamelessException { + public @Nullable NamelessUser getUserByMinecraftUsername(final @NonNull String username) throws NamelessException { final NamelessUser user = getUserByMinecraftUsernameLazy(username); - return user.exists() ? Optional.of(user) : Optional.empty(); + return user.exists() ? user : null; } - public @NonNull Optional getUserByDiscordId(final long id) throws NamelessException { + public @Nullable NamelessUser getUserByDiscordId(final long id) throws NamelessException { final NamelessUser user = getUserByDiscordIdLazy(id); - return user.exists() ? Optional.of(user) : Optional.empty(); + return user.exists() ? user : null; } - public @NonNull Optional getUserByDiscordUsername(final @NonNull String username) throws NamelessException { + public @Nullable NamelessUser getUserByDiscordUsername(final @NonNull String username) throws NamelessException { final NamelessUser user = getUserByDiscordUsernameLazy(username); - return user.exists() ? Optional.of(user) : Optional.empty(); + return user.exists() ? user : null; } /** @@ -153,15 +153,17 @@ public FilteredUserListBuilder getRegisteredUsers() { /** * Get NamelessMC group by ID * @param id Group id - * @return Optional with a group if the group exists, empty optional if it doesn't + * @return Group or null if it doesn't exist */ - public @NonNull Optional<@NonNull Group> getGroup(final int id) throws NamelessException { + public @Nullable Group getGroup(final int id) throws NamelessException { final JsonObject response = this.requests.get("groups", "id", id); final JsonArray jsonArray = response.getAsJsonArray("groups"); - if (jsonArray.size() != 1) { - return Optional.empty(); + if (jsonArray.size() == 1) { + return new Group(jsonArray.get(0).getAsJsonObject()); + } else if (jsonArray.isEmpty()) { + return null; } else { - return Optional.of(new Group(jsonArray.get(0).getAsJsonObject())); + throw new IllegalStateException("Website returned multiple groups for one id"); } } @@ -170,7 +172,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param name NamelessMC groups name * @return List of groups with this name, empty if there are no groups with this name. */ - public @NonNull List<@NonNull Group> getGroup(final @NonNull String name) throws NamelessException { + public List getGroup(final @NonNull String name) throws NamelessException { Objects.requireNonNull(name, "Group name is null"); final JsonObject response = this.requests.get("groups", "name", name); return groupListFromJsonArray(response.getAsJsonArray("groups")); @@ -180,13 +182,13 @@ public FilteredUserListBuilder getRegisteredUsers() { * Get a list of all groups on the website * @return list of groups */ - public @NonNull List getAllGroups() throws NamelessException { + public List getAllGroups() throws NamelessException { final JsonObject response = this.requests.get("groups"); return groupListFromJsonArray(response.getAsJsonArray("groups")); } - public int @NonNull[] getAllGroupIds() throws NamelessException { + public int[] getAllGroupIds() throws NamelessException { final JsonObject response = this.requests.get("groups"); return StreamSupport.stream(response.getAsJsonArray("groups").spliterator(), false) .map(JsonElement::getAsJsonObject) @@ -212,7 +214,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @return Email verification disabled: A link which the user needs to click to complete registration *
Email verification enabled: An empty string (the user needs to check their email to complete registration) */ - public @NonNull Optional registerUser(final @NonNull String username, + public Optional registerUser(final @NonNull String username, final @NonNull String email, final @NonNull IntegrationData@Nullable ... integrationData) throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 41e55eea..d9c02aec 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -207,12 +207,13 @@ public boolean isStaff() throws NamelessException { * * @return Player's group with the lowest order */ - public @NonNull Optional<@NonNull Group> getPrimaryGroup() throws NamelessException { + public @Nullable Group getPrimaryGroup() throws NamelessException { final JsonArray groups = this.getUserInfo().getAsJsonArray("groups"); if (groups.size() > 0) { - return Optional.of(new Group(groups.get(0).getAsJsonObject())); + // Website group response is ordered, first group is primary group. + return new Group(groups.get(0).getAsJsonObject()); } else { - return Optional.empty(); + return null; } } @@ -411,23 +412,23 @@ public Map getIntegrations() throws NamelessExc return integrationDataMap; } - public Optional getMinecraftUuid() throws NamelessException { + public @Nullable UUID getMinecraftUuid() throws NamelessException { final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.MINECRAFT); if (integration == null) { - return Optional.empty(); + return null; } - return Optional.of(((IMinecraftIntegrationData) integration).getUniqueId()); + return ((IMinecraftIntegrationData) integration).getUniqueId(); } - public Optional getDiscordId() throws NamelessException { + public @Nullable Long getDiscordId() throws NamelessException { final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.DISCORD); if (integration == null) { - return Optional.empty(); + return null; } - return Optional.of(((IDiscordIntegrationData) integration).getIdLong()); + return ((IDiscordIntegrationData) integration).getIdLong(); } public void verify(final @NonNull String verificationCode) throws NamelessException, AccountAlreadyActivatedException, InvalidValidateCodeException { diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index a300ebfc..2b492a7e 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -56,8 +56,8 @@ public class Website implements LanguageEntity { /** * @return Information about an update, or empty if no update is available. */ - public @NonNull Optional<@NonNull Update> getUpdate() { - return Optional.ofNullable(this.update); + public @Nullable Update getUpdate() { + return this.update; } public @NonNull String@NonNull [] getModules() { @@ -72,9 +72,9 @@ public class Website implements LanguageEntity { public static class Update { private final boolean isUrgent; - private final @NonNull String version; + private final String version; - Update(final boolean isUrgent, final @NonNull String version) { + Update(final boolean isUrgent, final String version) { this.isUrgent = isUrgent; this.version = version; } @@ -84,7 +84,7 @@ public boolean isUrgent() { } - public @NonNull String getVersion() { + public String getVersion() { return this.version; } From 2808e3b527dfcce62b03056361d2992e1393ae12 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 May 2022 16:23:49 +0200 Subject: [PATCH 049/269] API error constants --- src/com/namelessmc/java_api/ApiError.java | 70 ---------------- src/com/namelessmc/java_api/NamelessAPI.java | 71 ++++++---------- src/com/namelessmc/java_api/NamelessUser.java | 84 +++++-------------- .../namelessmc/java_api/NamelessVersion.java | 10 +-- .../namelessmc/java_api/RequestHandler.java | 23 ++--- .../java_api/UserNotExistException.java | 7 -- src/com/namelessmc/java_api/Website.java | 7 +- .../AccountAlreadyActivatedException.java | 13 --- .../AlreadyHasOpenReportException.java | 13 --- .../exception/ApiDisabledException.java | 11 --- .../java_api/exception/ApiError.java | 84 +++++++++++++++++++ .../java_api/exception/ApiErrorException.java | 11 --- .../java_api/exception/ApiException.java | 21 +++++ .../exception/CannotReportSelfException.java | 13 --- .../exception/CannotSendEmailException.java | 13 --- .../exception/EmailAlreadyUsedException.java | 13 --- ...IntegrationIdentifierInvalidException.java | 13 --- .../IntegrationUsernameInvalidException.java | 13 --- .../InvalidEmailAddressException.java | 13 --- .../exception/InvalidUsernameException.java | 13 --- .../InvalidValidateCodeException.java | 13 --- .../exception/ReportUserBannedException.java | 13 --- .../UnknownNamelessVersionException.java | 11 --- .../UsernameAlreadyExistsException.java | 13 --- 24 files changed, 167 insertions(+), 399 deletions(-) delete mode 100644 src/com/namelessmc/java_api/ApiError.java delete mode 100644 src/com/namelessmc/java_api/UserNotExistException.java delete mode 100644 src/com/namelessmc/java_api/exception/AccountAlreadyActivatedException.java delete mode 100644 src/com/namelessmc/java_api/exception/AlreadyHasOpenReportException.java delete mode 100644 src/com/namelessmc/java_api/exception/ApiDisabledException.java create mode 100644 src/com/namelessmc/java_api/exception/ApiError.java delete mode 100644 src/com/namelessmc/java_api/exception/ApiErrorException.java create mode 100644 src/com/namelessmc/java_api/exception/ApiException.java delete mode 100644 src/com/namelessmc/java_api/exception/CannotReportSelfException.java delete mode 100644 src/com/namelessmc/java_api/exception/CannotSendEmailException.java delete mode 100644 src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java delete mode 100644 src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java delete mode 100644 src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java delete mode 100644 src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java delete mode 100644 src/com/namelessmc/java_api/exception/InvalidUsernameException.java delete mode 100644 src/com/namelessmc/java_api/exception/InvalidValidateCodeException.java delete mode 100644 src/com/namelessmc/java_api/exception/ReportUserBannedException.java delete mode 100644 src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java delete mode 100644 src/com/namelessmc/java_api/exception/UsernameAlreadyExistsException.java diff --git a/src/com/namelessmc/java_api/ApiError.java b/src/com/namelessmc/java_api/ApiError.java deleted file mode 100644 index 72ccdc0c..00000000 --- a/src/com/namelessmc/java_api/ApiError.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.namelessmc.java_api; - -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; - -import java.util.Optional; - -public class ApiError extends NamelessException { - - public static final int UNKNOWN_ERROR = 0; - // 1 intentionally missing - // 2 intentionally missing - public static final int INVALID_API_METHOD = 3; - public static final int NO_UNIQUE_SITE_ID_AVAILABLE = 4; - // 5 intentionally missing - public static final int INVALID_GET_POST_CONTENTS = 6; - public static final int INVALID_EMAIL_ADDRESS = 7; - public static final int INVALID_USERNAME = 8; - public static final int INVALID_UUID = 9; - public static final int EMAIL_ALREADY_EXISTS = 10; - public static final int USERNAME_ALREADY_EXISTS = 11; - // 12 intentionally missing - public static final int UNABLE_TO_CREATE_ACCOUNT = 13; - public static final int UNABLE_TO_SEND_REGISTRATION_EMAIL = 14; - // 15 intentionally missing - public static final int UNABLE_TO_FIND_USER = 16; - public static final int UNABLE_TO_FIND_GROUP = 17; - // 18 intentionally missing - public static final int REPORT_CONTENT_TOO_LARGE = 19; - // 20 intentionally missing - public static final int USER_CREATING_REPORT_BANNED = 21; - public static final int USER_ALREADY_HAS_OPEN_REPORT = 22; - // 23 intentionally missing - public static final int UNABLE_TO_UPDATE_USERNAME = 24; - public static final int UNABLE_TO_UPDATE_SERVER_INFO = 25; - public static final int CANNOT_REPORT_YOURSELF = 26; - public static final int INVALID_SERVER_ID = 27; - public static final int INVALID_VALIDATE_CODE = 28; - public static final int UNABLE_TO_SET_USER_DISCORD_ID = 29; - public static final int UNABLE_TO_SET_DISCORD_BOT_URL = 30; - // 31 intentionally missing - public static final int ACCOUNT_ALREADY_ACTIVATED = 32; - public static final int UNABLE_TO_SET_DISCORD_GUILD_ID = 33; - public static final int DISCORD_INTEGRATION_DISABLED = 34; - // 35 intentionally missing - public static final int REQUEST_NOT_AUTHORIZED = 36; - public static final int INTEGRATION_INVALID = 37; - public static final int INTEGRATION_USERNAME_INVALID = 38; - public static final int INTEGRATION_IDENTIFIER_INVALID = 39; - - private static final long serialVersionUID = 3093028909912281912L; - - private final int code; - private final @Nullable String meta; - - public ApiError(final int code, final @Nullable String meta) { - super("An unexpected API error occurred with error code " + code + " and " + (meta == null ? "no meta" : "meta " + meta)); - this.code = code; - this.meta = meta; - } - - public int getError() { - return this.code; - } - - public @Nullable String getMeta() { - return meta; - } - -} diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 13d05b74..185fd1b6 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -87,34 +87,40 @@ public FilteredUserListBuilder getRegisteredUsers() { return new FilteredUserListBuilder(this); } + public @Nullable NamelessUser userAsNullable(NamelessUser user) throws NamelessException { + try { + user.getUserInfo(); + return user; + } catch (ApiException e) { + if (e.apiError() == ApiError.NAMELESS_CANNOT_FIND_USER) { + return null; + } + throw e; + } + } + public @Nullable NamelessUser getUser(final int id) throws NamelessException { - final NamelessUser user = getUserLazy(id); - return user.exists() ? user : null; + return userAsNullable(getUserLazy(id)); } public @Nullable NamelessUser getUserByUsername(final @NonNull String username) throws NamelessException { - final NamelessUser user = getUserByUsernameLazy(username); - return user.exists() ? user : null; + return userAsNullable(getUserByUsernameLazy(username)); } public @Nullable NamelessUser getUserByMinecraftUuid(final @NonNull UUID uuid) throws NamelessException { - final NamelessUser user = getUserByMinecraftUuidLazy(uuid); - return user.exists() ? user : null; + return userAsNullable(getUserByMinecraftUuidLazy(uuid)); } public @Nullable NamelessUser getUserByMinecraftUsername(final @NonNull String username) throws NamelessException { - final NamelessUser user = getUserByMinecraftUsernameLazy(username); - return user.exists() ? user : null; + return userAsNullable(getUserByMinecraftUsernameLazy(username)); } public @Nullable NamelessUser getUserByDiscordId(final long id) throws NamelessException { - final NamelessUser user = getUserByDiscordIdLazy(id); - return user.exists() ? user : null; + return userAsNullable(getUserByDiscordIdLazy(id)); } public @Nullable NamelessUser getUserByDiscordUsername(final @NonNull String username) throws NamelessException { - final NamelessUser user = getUserByDiscordUsernameLazy(username); - return user.exists() ? user : null; + return userAsNullable(getUserByDiscordUsernameLazy(username)); } /** @@ -217,9 +223,7 @@ public int[] getAllGroupIds() throws NamelessException { public Optional registerUser(final @NonNull String username, final @NonNull String email, final @NonNull IntegrationData@Nullable ... integrationData) - throws NamelessException, InvalidUsernameException, UsernameAlreadyExistsException, - CannotSendEmailException, IntegrationUsernameInvalidException, - IntegrationIdentifierInvalidException, InvalidEmailAddressException, EmailAlreadyUsedException { + throws NamelessException { Objects.requireNonNull(username, "Username is null"); Objects.requireNonNull(email, "Email address is null"); @@ -238,25 +242,12 @@ public Optional registerUser(final @NonNull String username, post.add("integrations", integrationsJson); } - try { - final JsonObject response = this.requests.post("users/register", post); + final JsonObject response = this.requests.post("users/register", post); - if (response.has("link")) { - return Optional.of(response.get("link").getAsString()); - } else { - return Optional.empty(); - } - } catch (final ApiError e) { - switch (e.getError()) { - case ApiError.INVALID_USERNAME: throw new InvalidUsernameException(); - case ApiError.USERNAME_ALREADY_EXISTS: throw new UsernameAlreadyExistsException(); - case ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL: throw new CannotSendEmailException(); - case ApiError.INTEGRATION_USERNAME_INVALID: throw new IntegrationUsernameInvalidException(); - case ApiError.INTEGRATION_IDENTIFIER_INVALID: throw new IntegrationIdentifierInvalidException(); - case ApiError.INVALID_EMAIL_ADDRESS: throw new InvalidEmailAddressException(); - case ApiError.EMAIL_ALREADY_EXISTS: throw new EmailAlreadyUsedException(); - default: throw e; - } + if (response.has("link")) { + return Optional.of(response.get("link").getAsString()); + } else { + return Optional.empty(); } } @@ -393,23 +384,13 @@ public void updateDiscordUsernames(final long@NonNull[] discordUserIds, } public void verifyIntegration(final @NonNull IntegrationData integrationData, - final @NonNull String verificationCode) - throws NamelessException, InvalidValidateCodeException { + final @NonNull String verificationCode) throws NamelessException { JsonObject data = new JsonObject(); data.addProperty("integration", integrationData.getIntegrationType()); data.addProperty("identifier", integrationData.getIdentifier()); data.addProperty("username", integrationData.getUsername()); data.addProperty("code", Objects.requireNonNull(verificationCode, "Verification code is null")); - try { - this.requests.post("integration/verify", data); - } catch (ApiError e) { - switch (e.getError()) { - case ApiError.INVALID_VALIDATE_CODE: - throw new InvalidValidateCodeException(); - default: - throw e; - } - } + this.requests.post("integration/verify", data); } public @NonNull WebsendAPI websend() { diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index d9c02aec..ad67ea11 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -5,7 +5,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.Notification.NotificationType; -import com.namelessmc.java_api.exception.*; +import com.namelessmc.java_api.exception.ApiError; +import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.integrations.*; import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.checker.nullness.qual.NonNull; @@ -46,24 +47,15 @@ public final class NamelessUser implements LanguageEntity { this.userTransformer = userTransformer; } - private @NonNull JsonObject getUserInfo() throws NamelessException { + @NonNull JsonObject getUserInfo() throws NamelessException { if (this._cachedUserInfo != null) { return this._cachedUserInfo; } - final JsonObject response; - try { - response = this.requests.get("users/" + this.userTransformer); - } catch (final ApiError e) { - if (e.getError() == ApiError.UNABLE_TO_FIND_USER) { - throw new UserNotExistException(); - } else { - throw e; - } - } + final JsonObject response = this.requests.get("users/" + this.userTransformer); if (!response.get("exists").getAsBoolean()) { - throw new UserNotExistException(); + throw new IllegalStateException("User was returned by the API without an error code so it should exist"); } this._cachedUserInfo = response; @@ -114,15 +106,6 @@ public void updateUsername(final @NonNull String username) throws NamelessExcept this.requests.post("users/" + this.userTransformer + "/update-username", post); } - public boolean exists() throws NamelessException { - try { - this.getUserInfo(); - return true; - } catch (final UserNotExistException e) { - return false; - } - } - public @NonNull String getDisplayName() throws NamelessException { return this.getUserInfo().get("displayname").getAsString(); } @@ -264,13 +247,8 @@ public int getNotificationCount() throws NamelessException { * @param reason Reason why this player has been reported * @throws IllegalArgumentException Report reason is too long (>255 characters) * @throws IllegalArgumentException Report reason is too long (>255 characters) - * @throws NamelessException Unexpected http or api error - * @throws ReportUserBannedException If the user creating this report is banned - * @throws AlreadyHasOpenReportException If the user creating this report already has an open report for this user - * @throws CannotReportSelfException If the user tries to report themselves */ - public void createReport(final @NonNull NamelessUser user, final @NonNull String reason) - throws NamelessException, ReportUserBannedException, AlreadyHasOpenReportException, CannotReportSelfException { + public void createReport(final @NonNull NamelessUser user, final @NonNull String reason) throws NamelessException { Objects.requireNonNull(user, "User to report is null"); Objects.requireNonNull(reason, "Report reason is null"); Preconditions.checkArgument(reason.length() < 255, @@ -281,16 +259,12 @@ public void createReport(final @NonNull NamelessUser user, final @NonNull String post.addProperty("content", reason); try { this.requests.post("reports/create", post); - } catch (final ApiError e) { - switch (e.getError()) { - case ApiError.USER_CREATING_REPORT_BANNED: throw new ReportUserBannedException(); - case ApiError.REPORT_CONTENT_TOO_LARGE: - throw new IllegalStateException("Website said report reason is too long, but we have " + - "client-side validation for this so it should be impossible"); - case ApiError.USER_ALREADY_HAS_OPEN_REPORT: throw new AlreadyHasOpenReportException(); - case ApiError.CANNOT_REPORT_YOURSELF: throw new CannotReportSelfException(); - default: throw e; + } catch (final ApiException e) { + if (e.apiError() == ApiError.CORE_REPORT_CONTENT_TOO_LONG) { + throw new IllegalStateException("Website said report reason is too long, but we have " + + "client-side validation for this so it should be impossible"); } + throw e; } } @@ -300,15 +274,10 @@ public void createReport(final @NonNull NamelessUser user, final @NonNull String * @param reportedName The Minecraft username of this player * @param reason Report reason * @throws IllegalArgumentException Report reason is too long (>255 characters) - * @throws NamelessException Unexpected http or api error - * @throws ReportUserBannedException If the user creating this report is banned - * @throws AlreadyHasOpenReportException If the user creating this report already has an open report for this user - * @throws CannotReportSelfException If the user tries to report themselves */ public void createReport(final @NonNull UUID reportedUuid, final @NonNull String reportedName, - final @NonNull String reason) - throws NamelessException, ReportUserBannedException, AlreadyHasOpenReportException, CannotReportSelfException { + final @NonNull String reason) throws NamelessException { Objects.requireNonNull(reportedUuid, "Reported uuid is null"); Objects.requireNonNull(reportedName, "Reported name is null"); Objects.requireNonNull(reason, "Report reason is null"); @@ -321,16 +290,12 @@ public void createReport(final @NonNull UUID reportedUuid, post.addProperty("content", reason); try { this.requests.post("reports/create", post); - } catch (final ApiError e) { - switch (e.getError()) { - case ApiError.USER_CREATING_REPORT_BANNED: throw new ReportUserBannedException(); - case ApiError.REPORT_CONTENT_TOO_LARGE: - throw new IllegalStateException("Website said report reason is too long, but we have " + - "client-side validation for this so it should be impossible"); - case ApiError.USER_ALREADY_HAS_OPEN_REPORT: throw new AlreadyHasOpenReportException(); - case ApiError.CANNOT_REPORT_YOURSELF: throw new CannotReportSelfException(); - default: throw e; + } catch (final ApiException e) { + if (e.apiError() == ApiError.CORE_REPORT_CONTENT_TOO_LONG) { + throw new IllegalStateException("Website said report reason is too long, but we have " + + "client-side validation for this so it should be impossible"); } + throw e; } } @@ -431,21 +396,10 @@ public Map getIntegrations() throws NamelessExc return ((IDiscordIntegrationData) integration).getIdLong(); } - public void verify(final @NonNull String verificationCode) throws NamelessException, AccountAlreadyActivatedException, InvalidValidateCodeException { + public void verify(final @NonNull String verificationCode) throws NamelessException { final JsonObject body = new JsonObject(); body.addProperty("code", verificationCode); - try { - this.requests.post("users/" + this.userTransformer + "/verify", body); - } catch (final ApiError e) { - switch(e.getError()) { - case ApiError.ACCOUNT_ALREADY_ACTIVATED: - throw new AccountAlreadyActivatedException(); - case ApiError.INVALID_VALIDATE_CODE: - throw new InvalidValidateCodeException(); - default: - throw e; - } - } + this.requests.post("users/" + this.userTransformer + "/verify", body); } } diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index 476988b3..c4262b53 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -1,7 +1,7 @@ package com.namelessmc.java_api; -import com.namelessmc.java_api.exception.UnknownNamelessVersionException; import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.*; @@ -78,13 +78,9 @@ public String toString() { } } - public static @NonNull NamelessVersion parse(final @NonNull String versionName) throws UnknownNamelessVersionException { + public static @Nullable NamelessVersion parse(final @NonNull String versionName) { Objects.requireNonNull(versionName, "Version name is null"); - final NamelessVersion version = BY_NAME.get(versionName); - if (version == null) { - throw new UnknownNamelessVersionException(versionName); - } - return version; + return BY_NAME.get(versionName); } /** diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 802ce55e..2ff354c9 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -9,7 +9,8 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; -import com.namelessmc.java_api.exception.ApiDisabledException; +import com.namelessmc.java_api.exception.ApiError; +import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.logger.ApiLogger; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -155,10 +156,6 @@ private void debug(final @NonNull Supplier messageSupplier) { throw new NamelessException("Website sent empty response with status code " + statusCode); } - if (responseBody.equals("API is disabled")) { - throw new ApiDisabledException(); - } - JsonObject json; try { @@ -193,16 +190,20 @@ private void debug(final @NonNull Supplier messageSupplier) { throw new NamelessException(message.toString(), e); } - if (!json.has("error")) { - throw new NamelessException("Unexpected response from website (missing json key 'error')"); - } + if (json.has("error")) { + final String errorString = json.get("error").getAsString(); + final ApiError apiError = ApiError.fromString(errorString); + if (apiError == null) { + throw new NamelessException("Unknown API error: " + errorString); + } - if (json.get("error").getAsBoolean()) { - @Nullable String meta = null; + final String meta; if (json.has("meta") && !json.get("meta").isJsonNull()) { meta = json.get("meta").toString(); + } else { + meta = null; } - throw new ApiError(json.get("code").getAsInt(), meta); + throw new ApiException(apiError, meta); } return json; diff --git a/src/com/namelessmc/java_api/UserNotExistException.java b/src/com/namelessmc/java_api/UserNotExistException.java deleted file mode 100644 index 88ce6ed5..00000000 --- a/src/com/namelessmc/java_api/UserNotExistException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.namelessmc.java_api; - -public class UserNotExistException extends NamelessException { - - private static final long serialVersionUID = 1L; - -} diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 2b492a7e..6bfe08e6 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -2,13 +2,10 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.namelessmc.java_api.exception.UnknownNamelessVersionException; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import java.util.Locale; import java.util.Objects; -import java.util.Optional; import java.util.stream.StreamSupport; public class Website implements LanguageEntity { @@ -49,7 +46,7 @@ public class Website implements LanguageEntity { return this.version; } - public @NonNull NamelessVersion getParsedVersion() throws UnknownNamelessVersionException { + public @Nullable NamelessVersion getParsedVersion() { return NamelessVersion.parse(this.version); } @@ -88,7 +85,7 @@ public String getVersion() { return this.version; } - public NamelessVersion getParsedVersion() throws UnknownNamelessVersionException { + public @Nullable NamelessVersion getParsedVersion() { return NamelessVersion.parse(this.version); } diff --git a/src/com/namelessmc/java_api/exception/AccountAlreadyActivatedException.java b/src/com/namelessmc/java_api/exception/AccountAlreadyActivatedException.java deleted file mode 100644 index fe2bf576..00000000 --- a/src/com/namelessmc/java_api/exception/AccountAlreadyActivatedException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class AccountAlreadyActivatedException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public AccountAlreadyActivatedException() { - super(ApiError.ACCOUNT_ALREADY_ACTIVATED); - } - -} diff --git a/src/com/namelessmc/java_api/exception/AlreadyHasOpenReportException.java b/src/com/namelessmc/java_api/exception/AlreadyHasOpenReportException.java deleted file mode 100644 index 96b7130b..00000000 --- a/src/com/namelessmc/java_api/exception/AlreadyHasOpenReportException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class AlreadyHasOpenReportException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public AlreadyHasOpenReportException() { - super(ApiError.USER_ALREADY_HAS_OPEN_REPORT); - } - -} diff --git a/src/com/namelessmc/java_api/exception/ApiDisabledException.java b/src/com/namelessmc/java_api/exception/ApiDisabledException.java deleted file mode 100644 index 85c1f293..00000000 --- a/src/com/namelessmc/java_api/exception/ApiDisabledException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.NamelessException; - -public class ApiDisabledException extends NamelessException { - - public ApiDisabledException() { - super("API is disabled, please enable it in StaffCP > Configuration > API"); - } - -} diff --git a/src/com/namelessmc/java_api/exception/ApiError.java b/src/com/namelessmc/java_api/exception/ApiError.java new file mode 100644 index 00000000..0f03322b --- /dev/null +++ b/src/com/namelessmc/java_api/exception/ApiError.java @@ -0,0 +1,84 @@ +package com.namelessmc.java_api.exception; + +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public enum ApiError { + + // https://github.com/NamelessMC/Nameless/blob/v2/modules/Core/classes/Misc/Nameless2API.php + NAMELESS_API_IS_DISABLED("nameless", "api_is_disabled"), + NAMELESS_UNKNOWN_ERROR("nameless", "unknown_error"), + NAMELESS_NOT_AUTHORIZED("nameless", "not_authorized"), + NAMELESS_INVALID_API_KEY("nameless", "invalid_api_key"), + NAMELESS_INVALID_API_METHOD("nameless", "invalid_api_method"), + NAMELESS_CANNOT_FIND_USER("nameless", "cannot_find_user"), + NAMELESS_INVALID_POST_CONTENTS("nameless", "invalid_post_contents"), + NAMELESS_INVALID_GET_CONTENTS("nameless", "invalid_get_contents"), + NAMELESS_NO_SITE_UID("nameless", "no_site_uid"), + + // https://github.com/NamelessMC/Nameless/blob/v2/modules/Core/classes/Misc/CoreApiErrors.php + CORE_UNABLE_TO_FIND_GROUP("core", "unable_to_find_group"), + CORE_BANNED_FROM_WEBSITE("core", "banned_from_website"), + CORE_REPORT_CONTENT_TOO_LONG("core", "report_content_too_long"), + CORE_CANNOT_REPORT_YOURSELF("core", "cannot_report_yourself"), + CORE_OPEN_REPORT_ALREADY("core", "open_report_already"), + CORE_UNABLE_TO_UPDATE_SERVER_INFO("core", "unable_to_update_server_info"), + CORE_INVALID_SERVER_ID("core", "invalid_server_id"), + CORE_EMAIL_ALREADY_EXISTS("core", "email_already_exists"), + CORE_USERNAME_ALREADY_EXISTS("core", "username_already_exists"), + CORE_INVALID_EMAIL_ADDRESS("core", "invalid_email_address"), + CORE_INVALID_USERNAME("core", "invalid_username"), + CORE_UNABLE_TO_CREATE_ACCOUNT("core", "unable_to_create_account"), + CORE_UNABLE_TO_SEND_REGISTRATION_EMAIL("core", "unable_to_send_registration_email"), + CORE_INVALID_INTEGRATION("core", "invalid_integration"), + CORE_INVALID_CODE("core", "invalid_code"), + CORE_USER_ALREADY_ACTIVE("core", "user_already_active"), + CORE_UNABLE_TO_UPDATE_USERNAME("core", "unable_to_update_username"), + + // https://github.com/NamelessMC/Nameless/blob/v2/modules/Discord%20Integration/classes/DiscordApiErrors.php + DISCORD_DISCORD_INTEGRATION_DISABLED("discord_integration", "discord_integration_disabled"), + DISCORD_UNABLE_TO_UPDATE_DISCORD_ROLES("discord_integration", "unable_to_update_discord_roles"), + DISCORD_UNABLE_TO_SET_DISCORD_BOT_URL("discord_integration", "unable_to_set_discord_bot_url"), + DISCORD_UNABLE_TO_SET_DISCORD_GUILD_ID("discord_integration", "unable_to_set_discord_guild_id"), + DISCORD_UNABLE_TO_SET_DISCORD_BOT_USERNAME("discord_integration", "unable_to_set_discord_bot_username"), + + ; + + private final String key; + private final String value; + private final String string; + + ApiError(final String namespaceKey, final String namespaceValue) { + this.key = namespaceKey; + this.value = namespaceValue; + this.string = this.key + ":" + this.value; + } + + public String key() { + return this.key; + } + + public String value() { + return this.value; + } + + @Override + public String toString() { + return this.string; + } + + private static final Map FROM_STRING = new HashMap<>(); + + static { + for (ApiError apiError : ApiError.values()) { + FROM_STRING.put(apiError.string, apiError); + } + } + + public static @Nullable ApiError fromString(final String string) { + return FROM_STRING.get(string); + } + +} diff --git a/src/com/namelessmc/java_api/exception/ApiErrorException.java b/src/com/namelessmc/java_api/exception/ApiErrorException.java deleted file mode 100644 index 7cec8361..00000000 --- a/src/com/namelessmc/java_api/exception/ApiErrorException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.namelessmc.java_api.exception; - -public class ApiErrorException extends Exception { - - private static final long serialVersionUID = 1L; - - public ApiErrorException(final int code) { - super("API error code " + code); - } - -} diff --git a/src/com/namelessmc/java_api/exception/ApiException.java b/src/com/namelessmc/java_api/exception/ApiException.java new file mode 100644 index 00000000..acb49c18 --- /dev/null +++ b/src/com/namelessmc/java_api/exception/ApiException.java @@ -0,0 +1,21 @@ +package com.namelessmc.java_api.exception; + +import com.namelessmc.java_api.NamelessException; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class ApiException extends NamelessException { + + private static final long serialVersionUID = 1L; + + private final ApiError apiError; + + public ApiException(final ApiError apiError, final @Nullable String meta) { + super("API error " + apiError + (meta == null ? "" : " (meta: " + meta + ")")); + this.apiError = apiError; + } + + public ApiError apiError() { + return this.apiError; + } + +} diff --git a/src/com/namelessmc/java_api/exception/CannotReportSelfException.java b/src/com/namelessmc/java_api/exception/CannotReportSelfException.java deleted file mode 100644 index 6abd3dc7..00000000 --- a/src/com/namelessmc/java_api/exception/CannotReportSelfException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class CannotReportSelfException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public CannotReportSelfException() { - super(ApiError.CANNOT_REPORT_YOURSELF); - } - -} diff --git a/src/com/namelessmc/java_api/exception/CannotSendEmailException.java b/src/com/namelessmc/java_api/exception/CannotSendEmailException.java deleted file mode 100644 index e24b003b..00000000 --- a/src/com/namelessmc/java_api/exception/CannotSendEmailException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class CannotSendEmailException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public CannotSendEmailException() { - super(ApiError.UNABLE_TO_SEND_REGISTRATION_EMAIL); - } - -} diff --git a/src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java b/src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java deleted file mode 100644 index 97108316..00000000 --- a/src/com/namelessmc/java_api/exception/EmailAlreadyUsedException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class EmailAlreadyUsedException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public EmailAlreadyUsedException() { - super(ApiError.EMAIL_ALREADY_EXISTS); - } - -} diff --git a/src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java b/src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java deleted file mode 100644 index 7d2ad16b..00000000 --- a/src/com/namelessmc/java_api/exception/IntegrationIdentifierInvalidException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class IntegrationIdentifierInvalidException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public IntegrationIdentifierInvalidException() { - super(ApiError.INTEGRATION_IDENTIFIER_INVALID); - } - -} diff --git a/src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java b/src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java deleted file mode 100644 index 1d6bbd6b..00000000 --- a/src/com/namelessmc/java_api/exception/IntegrationUsernameInvalidException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class IntegrationUsernameInvalidException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public IntegrationUsernameInvalidException() { - super(ApiError.INTEGRATION_USERNAME_INVALID); - } - -} diff --git a/src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java b/src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java deleted file mode 100644 index 9e3014b5..00000000 --- a/src/com/namelessmc/java_api/exception/InvalidEmailAddressException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class InvalidEmailAddressException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public InvalidEmailAddressException() { - super(ApiError.INVALID_EMAIL_ADDRESS); - } - -} diff --git a/src/com/namelessmc/java_api/exception/InvalidUsernameException.java b/src/com/namelessmc/java_api/exception/InvalidUsernameException.java deleted file mode 100644 index 1fdcf121..00000000 --- a/src/com/namelessmc/java_api/exception/InvalidUsernameException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class InvalidUsernameException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public InvalidUsernameException() { - super(ApiError.INVALID_USERNAME); - } - -} diff --git a/src/com/namelessmc/java_api/exception/InvalidValidateCodeException.java b/src/com/namelessmc/java_api/exception/InvalidValidateCodeException.java deleted file mode 100644 index 20389f9f..00000000 --- a/src/com/namelessmc/java_api/exception/InvalidValidateCodeException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class InvalidValidateCodeException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public InvalidValidateCodeException() { - super(ApiError.INVALID_VALIDATE_CODE); - } - -} diff --git a/src/com/namelessmc/java_api/exception/ReportUserBannedException.java b/src/com/namelessmc/java_api/exception/ReportUserBannedException.java deleted file mode 100644 index dbf8996a..00000000 --- a/src/com/namelessmc/java_api/exception/ReportUserBannedException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class ReportUserBannedException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public ReportUserBannedException() { - super(ApiError.USER_CREATING_REPORT_BANNED); - } - -} diff --git a/src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java b/src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java deleted file mode 100644 index 0ec6844c..00000000 --- a/src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.namelessmc.java_api.exception; - -public class UnknownNamelessVersionException extends Exception { - - private static final long serialVersionUID = 1L; - - public UnknownNamelessVersionException(final String versionString) { - super("Cannot parse version string '" + versionString + "'. Try updating the API or the software using it."); - } - -} diff --git a/src/com/namelessmc/java_api/exception/UsernameAlreadyExistsException.java b/src/com/namelessmc/java_api/exception/UsernameAlreadyExistsException.java deleted file mode 100644 index 47559717..00000000 --- a/src/com/namelessmc/java_api/exception/UsernameAlreadyExistsException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.namelessmc.java_api.exception; - -import com.namelessmc.java_api.ApiError; - -public class UsernameAlreadyExistsException extends ApiErrorException { - - private static final long serialVersionUID = 1L; - - public UsernameAlreadyExistsException() { - super(ApiError.USERNAME_ALREADY_EXISTS); - } - -} From a790134ccabfde209f0a519fdf079f2a64a9bc10 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 29 May 2022 11:37:22 +0200 Subject: [PATCH 050/269] Store module basic payments and products implementation --- src/com/namelessmc/java_api/NamelessAPI.java | 12 ++- .../java_api/modules/store/PaymentStatus.java | 15 +++ .../java_api/modules/store/StoreAPI.java | 43 ++++++++ .../java_api/modules/store/StoreCustomer.java | 41 +++++++ .../java_api/modules/store/StorePayment.java | 101 ++++++++++++++++++ .../modules/store/StorePaymentProduct.java | 23 ++++ .../java_api/modules/store/StoreProduct.java | 52 +++++++++ 7 files changed, 284 insertions(+), 3 deletions(-) create mode 100644 src/com/namelessmc/java_api/modules/store/PaymentStatus.java create mode 100644 src/com/namelessmc/java_api/modules/store/StoreAPI.java create mode 100644 src/com/namelessmc/java_api/modules/store/StoreCustomer.java create mode 100644 src/com/namelessmc/java_api/modules/store/StorePayment.java create mode 100644 src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java create mode 100644 src/com/namelessmc/java_api/modules/store/StoreProduct.java diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 185fd1b6..bf89ef84 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -4,8 +4,10 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.namelessmc.java_api.exception.*; +import com.namelessmc.java_api.exception.ApiError; +import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.integrations.IntegrationData; +import com.namelessmc.java_api.modules.store.StoreAPI; import com.namelessmc.java_api.modules.websend.WebsendAPI; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -32,7 +34,7 @@ public final class NamelessAPI { this.apiKey = apiKey; } - @NonNull RequestHandler getRequestHandler() { + public @NonNull RequestHandler getRequestHandler() { return this.requests; } @@ -393,10 +395,14 @@ public void verifyIntegration(final @NonNull IntegrationData integrationData, this.requests.post("integration/verify", data); } - public @NonNull WebsendAPI websend() { + public WebsendAPI websend() { return new WebsendAPI(this.requests); } + public StoreAPI store() { + return new StoreAPI(this); + } + /** * Adds back dashes to a UUID string and converts it to a Java UUID object * @param uuid UUID without dashes diff --git a/src/com/namelessmc/java_api/modules/store/PaymentStatus.java b/src/com/namelessmc/java_api/modules/store/PaymentStatus.java new file mode 100644 index 00000000..eac20841 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/PaymentStatus.java @@ -0,0 +1,15 @@ +package com.namelessmc.java_api.modules.store; + +public enum PaymentStatus { + + PAYMENT_PENDING, // 0 + PAYMENT_COMPLETE, // 1 + PAYMENT_REFUNDED, // 2 + PAYMENT_CHARGED_BACK, // 3 + PAYMENT_DENIED, // 4 + + ; + + static final PaymentStatus[] BY_ID = PaymentStatus.values(); + +} diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java new file mode 100644 index 00000000..00ba3f13 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -0,0 +1,43 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.RequestHandler; + +import java.util.ArrayList; +import java.util.List; + +public class StoreAPI { + + private final NamelessAPI api; + private final RequestHandler requests; + + public StoreAPI(NamelessAPI api) { + this.api = api; + this.requests = api.getRequestHandler(); + } + + public List getProducts() throws NamelessException { + JsonObject response = this.requests.get("store/products"); + JsonArray productsJson = response.getAsJsonArray("products"); + List products = new ArrayList<>(productsJson.size()); + for (JsonElement productElement : productsJson) { + products.add(new StoreProduct(productElement.getAsJsonObject())); + } + return products; + } + + public List getPayments() throws NamelessException { + JsonObject response = this.requests.get("store/payments"); + JsonArray paymentsJson = response.getAsJsonArray("payments"); + List payments = new ArrayList<>(paymentsJson.size()); + for (JsonElement productElement : paymentsJson) { + payments.add(new StorePayment(this.api, productElement.getAsJsonObject())); + } + return payments; + } + +} diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java new file mode 100644 index 00000000..4665b145 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java @@ -0,0 +1,41 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.NamelessUser; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class StoreCustomer { + + private final NamelessAPI api; + private final int id; + private final @Nullable Integer userId; + private final @Nullable String username; + private final @Nullable String identifier; + + StoreCustomer(NamelessAPI api, JsonObject json) { + this.api = api; + this.id = json.get("id").getAsInt(); + this.userId = json.has("user_id") ? json.get("user_id").getAsInt() : null; + this.username = json.has("username") ? json.get("username").getAsString() : null; + this.identifier = json.has("identifier") ? json.get("identifier").getAsString() : null; + } + + public int getId() { + return this.id; + } + + public @Nullable NamelessUser getNamelessUser() throws NamelessException { + return this.userId != null ? this.api.getUser(this.userId) : null; + } + + public @Nullable String getUsername() { + return this.username; + } + + public @Nullable String getIdentifier() { + return this.identifier; + } + +} diff --git a/src/com/namelessmc/java_api/modules/store/StorePayment.java b/src/com/namelessmc/java_api/modules/store/StorePayment.java new file mode 100644 index 00000000..e8371b76 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StorePayment.java @@ -0,0 +1,101 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class StorePayment { + + private final int id; + private final int orderId; + private final int gatewayId; + private final String transaction; + private final String amount; + private final String currency; + private final String fee; + private final PaymentStatus status; + private final Date creationDate; + private final Date lastUpdateDate; + private final StoreCustomer payingCustomer; + private final StoreCustomer receivingCustomer; + private final List products; + + StorePayment(NamelessAPI api, JsonObject json) { + this.id = json.get("id").getAsInt(); + this.orderId = json.get("order_id").getAsInt(); + this.gatewayId = json.get("gateway_id").getAsInt(); + this.transaction = json.get("transaction").getAsString(); + this.amount = json.get("amount").getAsString(); + this.currency = json.get("currency").getAsString(); + this.fee = json.get("fee").getAsString(); + this.status = PaymentStatus.BY_ID[json.get("status_id").getAsInt()]; + this.creationDate = new Date(json.get("created").getAsLong() * 1000); + this.lastUpdateDate = new Date(json.get("last_updated").getAsLong() * 1000); + this.payingCustomer = new StoreCustomer(api, json.getAsJsonObject("customer")); + this.receivingCustomer = new StoreCustomer(api, json.getAsJsonObject("recipient")); + + JsonArray productsJson = json.getAsJsonArray("products"); + this.products = new ArrayList<>(productsJson.size()); + for (JsonElement element : productsJson) { + this.products.add(new StorePaymentProduct(element.getAsJsonObject())); + } + } + + public int getId() { + return id; + } + + public int getOrderId() { + return orderId; + } + + public int getGatewayId() { + return gatewayId; + } + + public String getTransaction() { + return transaction; + } + + public String getAmount() { + return amount; + } + + public String getCurrency() { + return currency; + } + + public String getFee() { + return fee; + } + + public PaymentStatus getStatus() { + return status; + } + + public Date getCreationDate() { + return creationDate; + } + + public Date getLastUpdateDate() { + return lastUpdateDate; + } + + public StoreCustomer getPayingCustomer() { + return payingCustomer; + } + + public StoreCustomer getReceivingCustomer() { + return receivingCustomer; + } + + public List getProducts() { + return products; + } + +} diff --git a/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java b/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java new file mode 100644 index 00000000..13509d91 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java @@ -0,0 +1,23 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonObject; + +public class StorePaymentProduct { + + private final int id; + private final String name; + + StorePaymentProduct(JsonObject json) { + this.id = json.get("id").getAsInt(); + this.name = json.get("name").getAsString(); + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + +} diff --git a/src/com/namelessmc/java_api/modules/store/StoreProduct.java b/src/com/namelessmc/java_api/modules/store/StoreProduct.java new file mode 100644 index 00000000..7fb62ad8 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StoreProduct.java @@ -0,0 +1,52 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonObject; + +public class StoreProduct { + + private final int id; + private final int categoryId; + private final String name; + private final float price; + private final int order; + private final boolean hidden; + private final boolean disabled; + + StoreProduct(JsonObject json) { + this.id = json.get("id").getAsInt(); + this.categoryId = json.get("category_id").getAsInt(); + this.name = json.get("name").getAsString(); + this.price = json.get("price").getAsFloat(); + this.order = json.get("order").getAsInt(); + this.hidden = json.get("hidden").getAsBoolean(); + this.disabled = json.get("disabled").getAsBoolean(); + } + + public int getId() { + return this.id; + } + + public int getCategoryId() { + return this.categoryId; + } + + public String getName() { + return this.name; + } + + public float getPrice() { + return this.price; + } + + public int getOrder() { + return this.order; + } + + public boolean isHidden() { + return this.hidden; + } + + public boolean isDisabled() { + return this.disabled; + } +} From 8e535800719d7f0172d8df24c6ca215d8bf2163d Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 29 May 2022 11:49:10 +0200 Subject: [PATCH 051/269] URL-encode user transformer --- src/com/namelessmc/java_api/NamelessUser.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index ad67ea11..b6c3b731 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -12,6 +12,8 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -22,13 +24,14 @@ public final class NamelessUser implements LanguageEntity { private final @NonNull NamelessAPI api; private final @NonNull RequestHandler requests; - private @NonNull String userTransformer; private int id; // -1 if not known + private String userTransformer; // Do not use directly, instead use getUserInfo() and getIntegrations() private @Nullable JsonObject _cachedUserInfo; private @Nullable Map _cachedIntegrationData; + NamelessUser(final @NonNull NamelessAPI api, final @Positive int id ) { @@ -44,7 +47,7 @@ public final class NamelessUser implements LanguageEntity { this.requests = api.getRequestHandler(); this.id = -1; - this.userTransformer = userTransformer; + this.userTransformer = URLEncoder.encode(userTransformer, StandardCharsets.UTF_8); } @NonNull JsonObject getUserInfo() throws NamelessException { @@ -88,6 +91,10 @@ public void invalidateCache() { this._cachedIntegrationData = null; } + public String getEncodedUserTransformer() { + return return this.userTransformer; + } + public int getId() throws NamelessException { if (this.id == -1) { this.id = this.getUserInfo().get("id").getAsInt(); From d7768e183a18e97c14543cce172b4d411a8a4449 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 29 May 2022 11:51:58 +0200 Subject: [PATCH 052/269] Implement credit endpoints --- src/com/namelessmc/java_api/NamelessUser.java | 7 ++++- .../java_api/modules/store/StoreUser.java | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/com/namelessmc/java_api/modules/store/StoreUser.java diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index b6c3b731..5c9a3d47 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -8,6 +8,7 @@ import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.integrations.*; +import com.namelessmc.java_api.modules.store.StoreUser; import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -92,7 +93,7 @@ public void invalidateCache() { } public String getEncodedUserTransformer() { - return return this.userTransformer; + return this.userTransformer; } public int getId() throws NamelessException { @@ -409,4 +410,8 @@ public void verify(final @NonNull String verificationCode) throws NamelessExcept this.requests.post("users/" + this.userTransformer + "/verify", body); } + public StoreUser store() { + return new StoreUser(this); + } + } diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java new file mode 100644 index 00000000..5ba85823 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -0,0 +1,30 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.NamelessUser; +import com.namelessmc.java_api.RequestHandler; + +public class StoreUser { + + private final NamelessUser user; + private final RequestHandler requests; + + public StoreUser(NamelessUser user) { + this.user = user; + this.requests = user.getApi().getRequestHandler(); + } + + public void addCredits(float creditsToAdd) throws NamelessException { + JsonObject body = new JsonObject(); + body.addProperty("credits", creditsToAdd); + this.requests.post("users/" + this.user.getEncodedUserTransformer() + "/add-credits", body); + } + + public void removeCredits(float creditsToRemove) throws NamelessException { + JsonObject body = new JsonObject(); + body.addProperty("credits", creditsToRemove); + this.requests.post("users/" + this.user.getEncodedUserTransformer() + "/remove-credits", body); + } + +} From 8cb2740c9426240253df18defb448126db35cb9f Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 29 May 2022 12:16:53 +0200 Subject: [PATCH 053/269] Store module commands and errors --- .../java_api/exception/ApiError.java | 4 + .../store/PendingCommandsResponse.java | 81 +++++++++++++++++++ .../java_api/modules/store/StoreAPI.java | 16 ++++ .../java_api/modules/store/StoreProduct.java | 6 -- 4 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java diff --git a/src/com/namelessmc/java_api/exception/ApiError.java b/src/com/namelessmc/java_api/exception/ApiError.java index 0f03322b..31fc3cd1 100644 --- a/src/com/namelessmc/java_api/exception/ApiError.java +++ b/src/com/namelessmc/java_api/exception/ApiError.java @@ -44,6 +44,10 @@ public enum ApiError { DISCORD_UNABLE_TO_SET_DISCORD_GUILD_ID("discord_integration", "unable_to_set_discord_guild_id"), DISCORD_UNABLE_TO_SET_DISCORD_BOT_USERNAME("discord_integration", "unable_to_set_discord_bot_username"), + // https://github.com/partydragen/Nameless-Store/blob/master/upload/modules/Store/classes/StoreApiErrors.php + STORE_PAYMENT_NOT_FOUND("store", "payment_not_found"), + ERROR_INVALID_CREDITS_AMOUNT("store", "invalid_credits_amount"), + ; private final String key; diff --git a/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java b/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java new file mode 100644 index 00000000..76e3035b --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java @@ -0,0 +1,81 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; + +import java.util.ArrayList; +import java.util.List; + +public class PendingCommandsResponse { + + private final boolean useUuids; + private final List customers; + + PendingCommandsResponse(NamelessAPI api, JsonObject json) { + this.useUuids = json.get("online_mode").getAsBoolean(); + JsonArray customers = json.getAsJsonArray("customers"); + this.customers = new ArrayList<>(customers.size()); + for (JsonElement element : customers) { + this.customers.add(new PendingCommandsCustomer(api, element.getAsJsonObject())); + } + } + + public boolean shouldUseUuids() { + return this.useUuids; + } + + public List getCustomers() { + return this.customers; + } + + public static class PendingCommandsCustomer extends StoreCustomer { + + private List pendingCommands; + + private PendingCommandsCustomer(NamelessAPI api, JsonObject json) { + super(api, json); + + JsonArray commands = json.getAsJsonArray("commands"); + this.pendingCommands = new ArrayList<>(commands.size()); + for (JsonElement element : commands) { + this.pendingCommands.add(new PendingCommand(element.getAsJsonObject())); + } + } + + } + + public static class PendingCommand { + + private final int id; + private final String command; + private final int orderId; + private final boolean requireOnline; + + private PendingCommand(JsonObject json) { + this.id = json.get("id").getAsInt(); + this.command = json.get("command").getAsString(); + this.orderId = json.get("order_id").getAsInt(); + this.requireOnline = json.get("require_online").getAsBoolean(); + } + + public int getId() { + return id; + } + + public String getCommand() { + return command; + } + + public int getOrderId() { + return orderId; + } + + public boolean isOnlineRequired() { + return requireOnline; + } + + } + +} diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index 00ba3f13..adf7aff2 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -8,6 +8,7 @@ import com.namelessmc.java_api.RequestHandler; import java.util.ArrayList; +import java.util.Collection; import java.util.List; public class StoreAPI { @@ -40,4 +41,19 @@ public List getPayments() throws NamelessException { return payments; } + public PendingCommandsResponse getPendingCommands() throws NamelessException { + JsonObject response = this.requests.get("store/pending-commands"); + return new PendingCommandsResponse(this.api, response); + } + + public void markCommandsExecuted(Collection commands) throws NamelessException { + JsonArray array = new JsonArray(commands.size()); + for (PendingCommandsResponse.PendingCommand command : commands) { + array.add(command.getId()); + } + JsonObject body = new JsonObject(); + body.add("commands", array); + this.requests.post("store/commands-executed", body); + } + } diff --git a/src/com/namelessmc/java_api/modules/store/StoreProduct.java b/src/com/namelessmc/java_api/modules/store/StoreProduct.java index 7fb62ad8..0bf1e180 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreProduct.java +++ b/src/com/namelessmc/java_api/modules/store/StoreProduct.java @@ -8,7 +8,6 @@ public class StoreProduct { private final int categoryId; private final String name; private final float price; - private final int order; private final boolean hidden; private final boolean disabled; @@ -17,7 +16,6 @@ public class StoreProduct { this.categoryId = json.get("category_id").getAsInt(); this.name = json.get("name").getAsString(); this.price = json.get("price").getAsFloat(); - this.order = json.get("order").getAsInt(); this.hidden = json.get("hidden").getAsBoolean(); this.disabled = json.get("disabled").getAsBoolean(); } @@ -38,10 +36,6 @@ public float getPrice() { return this.price; } - public int getOrder() { - return this.order; - } - public boolean isHidden() { return this.hidden; } From 60338efc1f2a1011f72c5dcace124abaa984585f Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 29 May 2022 12:43:53 +0200 Subject: [PATCH 054/269] Use short style getters --- src/com/namelessmc/java_api/Announcement.java | 15 +-- .../java_api/CustomProfileField.java | 8 +- .../java_api/CustomProfileFieldValue.java | 4 +- .../java_api/FilteredUserListBuilder.java | 2 +- .../namelessmc/java_api/LanguageEntity.java | 6 +- src/com/namelessmc/java_api/NamelessAPI.java | 16 +-- src/com/namelessmc/java_api/NamelessUser.java | 98 ++++++++----------- .../namelessmc/java_api/NamelessVersion.java | 12 +-- src/com/namelessmc/java_api/Notification.java | 18 ++-- src/com/namelessmc/java_api/UserFilter.java | 2 +- .../namelessmc/java_api/VerificationInfo.java | 1 + src/com/namelessmc/java_api/Website.java | 16 +-- .../DetailedDiscordIntegrationData.java | 5 +- .../integrations/DetailedIntegrationData.java | 2 +- .../DetailedMinecraftIntegrationData.java | 4 +- .../integrations/DiscordIntegrationData.java | 2 +- .../integrations/IDiscordIntegrationData.java | 2 +- .../IMinecraftIntegrationData.java | 2 +- .../integrations/IntegrationData.java | 6 +- .../MinecraftIntegrationData.java | 2 +- .../store/PendingCommandsResponse.java | 14 ++- .../java_api/modules/store/StoreAPI.java | 8 +- .../java_api/modules/store/StoreCustomer.java | 8 +- .../java_api/modules/store/StorePayment.java | 26 ++--- .../modules/store/StorePaymentProduct.java | 4 +- .../java_api/modules/store/StoreProduct.java | 8 +- .../java_api/modules/store/StoreUser.java | 6 +- .../java_api/modules/websend/WebsendAPI.java | 2 +- .../modules/websend/WebsendCommand.java | 4 +- 29 files changed, 147 insertions(+), 156 deletions(-) diff --git a/src/com/namelessmc/java_api/Announcement.java b/src/com/namelessmc/java_api/Announcement.java index 04a15e08..e2286454 100644 --- a/src/com/namelessmc/java_api/Announcement.java +++ b/src/com/namelessmc/java_api/Announcement.java @@ -31,28 +31,23 @@ public class Announcement { .toArray(); } - public int getId() { + public int id() { return id; } - public @NonNull String getHeader() { + public @NonNull String header() { return this.header; } - public @NonNull String getMessage() { + public @NonNull String message() { return this.message; } - @Deprecated - public @NonNull String getContent() { - return this.message; - } - - public @NonNull Set<@NonNull String> getDisplayPages() { + public @NonNull Set<@NonNull String> displayedPages() { return this.displayPages; } - public int @NonNull[] getDisplayGroupIds() { + public int @NonNull[] displayedGroupIds() { return this.displayGroups; } diff --git a/src/com/namelessmc/java_api/CustomProfileField.java b/src/com/namelessmc/java_api/CustomProfileField.java index 46c8b6d2..5b989448 100644 --- a/src/com/namelessmc/java_api/CustomProfileField.java +++ b/src/com/namelessmc/java_api/CustomProfileField.java @@ -28,15 +28,15 @@ public class CustomProfileField { this.description = description; } - public int getId() { + public int id() { return id; } - public @NonNull String getName() { + public @NonNull String name() { return name; } - public @NonNull CustomProfileFieldType getType() { + public @NonNull CustomProfileFieldType type() { return type; } @@ -48,7 +48,7 @@ public boolean isRequired() { return isRequired; } - public @NonNull String getDescription() { + public @NonNull String description() { return description; } diff --git a/src/com/namelessmc/java_api/CustomProfileFieldValue.java b/src/com/namelessmc/java_api/CustomProfileFieldValue.java index b272785c..91360aae 100644 --- a/src/com/namelessmc/java_api/CustomProfileFieldValue.java +++ b/src/com/namelessmc/java_api/CustomProfileFieldValue.java @@ -13,11 +13,11 @@ public class CustomProfileFieldValue { this.value = value; } - public @NonNull CustomProfileField getField() { + public @NonNull CustomProfileField field() { return this.field; } - public @Nullable String getValue() { + public @Nullable String value() { return value; } diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index f8703c19..e11f3bff 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -48,7 +48,7 @@ public JsonObject makeRawRequest() throws NamelessException { Iterator, Object>> iterator = filters.entrySet().iterator(); for (int i = 1; i < filterCount; i++) { Map.Entry, Object> entry = iterator.next(); - parameters[i*2] = entry.getKey().getName(); + parameters[i*2] = entry.getKey().name(); parameters[i*2+1] = entry.getValue(); } } else { diff --git a/src/com/namelessmc/java_api/LanguageEntity.java b/src/com/namelessmc/java_api/LanguageEntity.java index 0a2c0752..a0d92529 100644 --- a/src/com/namelessmc/java_api/LanguageEntity.java +++ b/src/com/namelessmc/java_api/LanguageEntity.java @@ -6,10 +6,10 @@ public interface LanguageEntity { - @NonNull String getRawLocale() throws NamelessException; + @NonNull String rawLocale() throws NamelessException; - default @NonNull Locale getLocale() throws NamelessException { - final String language = this.getRawLocale(); + default @NonNull Locale locale() throws NamelessException { + final String language = this.rawLocale(); final String[] langSplit = language.split("_"); if (langSplit.length != 2) { throw new IllegalArgumentException("Invalid language: " + language); diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index bf89ef84..2c83073f 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -47,7 +47,7 @@ public final class NamelessAPI { } /** - * Get announcements visible to guests. Use {@link NamelessUser#getAnnouncements()} for non-guest announcements. + * Get announcements visible to guests. Use {@link NamelessUser#announcements()} for non-guest announcements. * @return List of announcements */ @@ -91,7 +91,7 @@ public FilteredUserListBuilder getRegisteredUsers() { public @Nullable NamelessUser userAsNullable(NamelessUser user) throws NamelessException { try { - user.getUserInfo(); + user.userInfo(); return user; } catch (ApiException e) { if (e.apiError() == ApiError.NAMELESS_CANNOT_FIND_USER) { @@ -237,9 +237,9 @@ public Optional registerUser(final @NonNull String username, JsonObject integrationsJson = new JsonObject(); for (IntegrationData integration : integrationData) { JsonObject integrationJson = new JsonObject(); - integrationJson.addProperty("identifier", integration.getIdentifier()); - integrationJson.addProperty("username", integration.getUsername()); - integrationsJson.add(integration.getIntegrationType().toString(), integrationJson); + integrationJson.addProperty("identifier", integration.identifier()); + integrationJson.addProperty("username", integration.username()); + integrationsJson.add(integration.type().toString(), integrationJson); } post.add("integrations", integrationsJson); } @@ -388,9 +388,9 @@ public void updateDiscordUsernames(final long@NonNull[] discordUserIds, public void verifyIntegration(final @NonNull IntegrationData integrationData, final @NonNull String verificationCode) throws NamelessException { JsonObject data = new JsonObject(); - data.addProperty("integration", integrationData.getIntegrationType()); - data.addProperty("identifier", integrationData.getIdentifier()); - data.addProperty("username", integrationData.getUsername()); + data.addProperty("integration", integrationData.type()); + data.addProperty("identifier", integrationData.identifier()); + data.addProperty("username", integrationData.username()); data.addProperty("code", Objects.requireNonNull(verificationCode, "Verification code is null")); this.requests.post("integration/verify", data); } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 5c9a3d47..8c2ae0d7 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -4,7 +4,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.namelessmc.java_api.Notification.NotificationType; +import com.namelessmc.java_api.Notification.Type; import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.integrations.*; @@ -28,7 +28,7 @@ public final class NamelessUser implements LanguageEntity { private int id; // -1 if not known private String userTransformer; - // Do not use directly, instead use getUserInfo() and getIntegrations() + // Do not use directly, instead use userInfo() and integrations() private @Nullable JsonObject _cachedUserInfo; private @Nullable Map _cachedIntegrationData; @@ -51,7 +51,7 @@ public final class NamelessUser implements LanguageEntity { this.userTransformer = URLEncoder.encode(userTransformer, StandardCharsets.UTF_8); } - @NonNull JsonObject getUserInfo() throws NamelessException { + @NonNull JsonObject userInfo() throws NamelessException { if (this._cachedUserInfo != null) { return this._cachedUserInfo; } @@ -74,7 +74,7 @@ public final class NamelessUser implements LanguageEntity { return response; } - public @NonNull NamelessAPI getApi() { + public @NonNull NamelessAPI api() { return this.api; } @@ -92,20 +92,20 @@ public void invalidateCache() { this._cachedIntegrationData = null; } - public String getEncodedUserTransformer() { + public String userTransformer() { return this.userTransformer; } public int getId() throws NamelessException { if (this.id == -1) { - this.id = this.getUserInfo().get("id").getAsInt(); + this.id = this.userInfo().get("id").getAsInt(); } return this.id; } - public @NonNull String getUsername() throws NamelessException { - return this.getUserInfo().get("username").getAsString(); + public @NonNull String username() throws NamelessException { + return this.userInfo().get("username").getAsString(); } public void updateUsername(final @NonNull String username) throws NamelessException { @@ -114,40 +114,40 @@ public void updateUsername(final @NonNull String username) throws NamelessExcept this.requests.post("users/" + this.userTransformer + "/update-username", post); } - public @NonNull String getDisplayName() throws NamelessException { - return this.getUserInfo().get("displayname").getAsString(); + public @NonNull String displayName() throws NamelessException { + return this.userInfo().get("displayname").getAsString(); } /** * @return The date the user registered on the website. */ - public @NonNull Date getRegisteredDate() throws NamelessException { - return new Date(this.getUserInfo().get("registered_timestamp").getAsLong() * 1000); + public @NonNull Date registeredDate() throws NamelessException { + return new Date(this.userInfo().get("registered_timestamp").getAsLong() * 1000); } - public @NonNull Date getLastOnline() throws NamelessException { - return new Date(this.getUserInfo().get("last_online_timestamp").getAsLong() * 1000); + public @NonNull Date lastOnline() throws NamelessException { + return new Date(this.userInfo().get("last_online_timestamp").getAsLong() * 1000); } /** * @return Whether this account is banned from the website. */ public boolean isBanned() throws NamelessException { - return this.getUserInfo().get("banned").getAsBoolean(); + return this.userInfo().get("banned").getAsBoolean(); } public boolean isVerified() throws NamelessException { - return this.getUserInfo().get("validated").getAsBoolean(); + return this.userInfo().get("validated").getAsBoolean(); } @Override - public @NonNull String getRawLocale() throws NamelessException { - return this.getUserInfo().get("locale").getAsString(); + public @NonNull String rawLocale() throws NamelessException { + return this.userInfo().get("locale").getAsString(); } - public @NonNull VerificationInfo getVerificationInfo() throws NamelessException { + public @NonNull VerificationInfo verificationInfo() throws NamelessException { final boolean verified = isVerified(); - final JsonObject verification = this.getUserInfo().getAsJsonObject("verification"); + final JsonObject verification = this.userInfo().getAsJsonObject("verification"); return new VerificationInfo(verified, verification); } @@ -155,7 +155,7 @@ public boolean isVerified() throws NamelessException { * @return True if the user is member of at least one staff group, otherwise false */ public boolean isStaff() throws NamelessException { - JsonArray groups = this.getUserInfo().getAsJsonArray("groups"); + JsonArray groups = this.userInfo().getAsJsonArray("groups"); for (JsonElement elem : groups) { JsonObject group = elem.getAsJsonObject(); if (group.has("staff") && @@ -166,25 +166,13 @@ public boolean isStaff() throws NamelessException { return false; } - /** - * @return Set of user's groups - * @see #getSortedGroups() - */ - public @NonNull Set<@NonNull Group> getGroups() throws NamelessException { - return Collections.unmodifiableSet( - StreamSupport.stream(this.getUserInfo().getAsJsonArray("groups").spliterator(), false) - .map(JsonElement::getAsJsonObject) - .map(Group::new) - .collect(Collectors.toSet())); - } - /** * @return List of the user's groups, sorted from low order to high order. - * @see #getGroups() */ - public @NonNull List<@NonNull Group> getSortedGroups() throws NamelessException { + public @NonNull List<@NonNull Group> groups() throws NamelessException { + // TODO sorting may be unnecessary since the website already returns sorted groups return Collections.unmodifiableList( - StreamSupport.stream(this.getUserInfo().getAsJsonArray("groups").spliterator(), false) + StreamSupport.stream(this.userInfo().getAsJsonArray("groups").spliterator(), false) .map(JsonElement::getAsJsonObject) .map(Group::new) .sorted() @@ -192,14 +180,14 @@ public boolean isStaff() throws NamelessException { } /** - * Same as doing {@link #getGroups()}.get(0), but with better performance + * Same as doing {@link #groups()}.get(0), but with better performance * since it doesn't need to create and sort a list of group objects. * Empty if the user is not in any groups. * * @return Player's group with the lowest order */ - public @Nullable Group getPrimaryGroup() throws NamelessException { - final JsonArray groups = this.getUserInfo().getAsJsonArray("groups"); + public @Nullable Group primaryGroup() throws NamelessException { + final JsonArray groups = this.userInfo().getAsJsonArray("groups"); if (groups.size() > 0) { // Website group response is ordered, first group is primary group. return new Group(groups.get(0).getAsJsonObject()); @@ -230,19 +218,19 @@ private JsonArray groupsToJsonArray(final @NonNull Group@NonNull [] groups) { return array; } - public int getNotificationCount() throws NamelessException { + public int notificationCount() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.userTransformer + "/notifications"); return response.getAsJsonArray("notifications").size(); } - public @NonNull List getNotifications() throws NamelessException { + public List notifications() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.userTransformer + "/notifications"); final List notifications = new ArrayList<>(); response.getAsJsonArray("notifications").forEach((element) -> { final String message = element.getAsJsonObject().get("message").getAsString(); final String url = element.getAsJsonObject().get("url").getAsString(); - final NotificationType type = NotificationType.fromString(element.getAsJsonObject().get("type").getAsString()); + final Type type = Type.fromString(element.getAsJsonObject().get("type").getAsString()); notifications.add(new Notification(message, url, type)); }); @@ -307,7 +295,7 @@ public void createReport(final @NonNull UUID reportedUuid, } } - public void setDiscordRoles(final long@NonNull[] roleIds) throws NamelessException { + public void discordRoles(final long@NonNull[] roleIds) throws NamelessException { final JsonObject post = new JsonObject(); post.addProperty("user", this.getId()); post.add("roles", this.requests.gson().toJsonTree(roleIds)); @@ -318,7 +306,7 @@ public void setDiscordRoles(final long@NonNull[] roleIds) throws NamelessExcepti * Get announcements visible to this user * @return List of announcements visible to this user */ - public @NonNull List<@NonNull Announcement> getAnnouncements() throws NamelessException { + public @NonNull List<@NonNull Announcement> announcements() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.userTransformer + "/announcements"); return NamelessAPI.getAnnouncements(response); } @@ -331,12 +319,12 @@ public void banUser() throws NamelessException { this.requests.post("users/" + this.userTransformer + "/ban", new JsonObject()); } - public @NonNull Collection<@NonNull CustomProfileFieldValue> getProfileFields() throws NamelessException { - if (!this.getUserInfo().has("profile_fields")) { + public Collection profileFields() throws NamelessException { + if (!this.userInfo().has("profile_fields")) { return Collections.emptyList(); } - final JsonObject fieldsJson = this.getUserInfo().getAsJsonObject("profile_fields"); + final JsonObject fieldsJson = this.userInfo().getAsJsonObject("profile_fields"); final List fieldValues = new ArrayList<>(fieldsJson.size()); for (final Map.Entry e : fieldsJson.entrySet()) { int id = Integer.parseInt(e.getKey()); @@ -357,12 +345,12 @@ public void banUser() throws NamelessException { return fieldValues; } - public Map getIntegrations() throws NamelessException { + public Map integrations() throws NamelessException { if (this._cachedIntegrationData != null) { return this._cachedIntegrationData; } - final JsonObject userInfo = this.getUserInfo(); + final JsonObject userInfo = this.userInfo(); final JsonArray integrationsJsonArray = userInfo.getAsJsonArray("integrations"); Map integrationDataMap = new HashMap<>(integrationsJsonArray.size()); for (JsonElement integrationElement : integrationsJsonArray) { @@ -385,23 +373,23 @@ public Map getIntegrations() throws NamelessExc return integrationDataMap; } - public @Nullable UUID getMinecraftUuid() throws NamelessException { - final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.MINECRAFT); + public @Nullable UUID minecraftUuid() throws NamelessException { + final DetailedIntegrationData integration = this.integrations().get(StandardIntegrationTypes.MINECRAFT); if (integration == null) { return null; } - return ((IMinecraftIntegrationData) integration).getUniqueId(); + return ((IMinecraftIntegrationData) integration).uuid(); } - public @Nullable Long getDiscordId() throws NamelessException { - final DetailedIntegrationData integration = this.getIntegrations().get(StandardIntegrationTypes.DISCORD); + public @Nullable Long discordId() throws NamelessException { + final DetailedIntegrationData integration = this.integrations().get(StandardIntegrationTypes.DISCORD); if (integration == null) { return null; } - return ((IDiscordIntegrationData) integration).getIdLong(); + return ((IDiscordIntegrationData) integration).idLong(); } public void verify(final @NonNull String verificationCode) throws NamelessException { diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index c4262b53..344d1720 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -42,19 +42,19 @@ public enum NamelessVersion { this.isBeta = isBeta; } - public @NonNull String getName() { + public @NonNull String internalName() { return this.name; } - public @NonNull String getFriendlyName() { + public @NonNull String friendlyName() { return this.friendlyName; } - public int getMajor() { + public int major() { return this.major; } - public int getMinor() { + public int minor() { return this.minor; } @@ -74,7 +74,7 @@ public String toString() { static { for (final NamelessVersion version : values()) { - BY_NAME.put(version.getName(), version); + BY_NAME.put(version.internalName(), version); } } @@ -86,7 +86,7 @@ public String toString() { /** * @return List of NamelessMC versions supported by the Java API */ - public static Set getSupportedVersions() { + public static Set supportedVersions() { return SUPPORTED_VERSIONS; } diff --git a/src/com/namelessmc/java_api/Notification.java b/src/com/namelessmc/java_api/Notification.java index 83c39a2d..cbf74d05 100644 --- a/src/com/namelessmc/java_api/Notification.java +++ b/src/com/namelessmc/java_api/Notification.java @@ -4,27 +4,27 @@ public class Notification { private final String message; private final String url; - private final NotificationType type; + private final Type type; - public Notification(final String message, final String url, final NotificationType type) { + public Notification(final String message, final String url, final Type type) { this.message = message; this.url = url; this.type = type; } - public String getMessage() { + public String message() { return this.message; } - public String getUrl() { + public String url() { return this.url; } - public NotificationType getType() { + public Type type() { return this.type; } - public enum NotificationType { + public enum Type { TAG, MESSAGE, @@ -36,11 +36,11 @@ public enum NotificationType { UNKNOWN; - public static NotificationType fromString(final String string) { + public static Type fromString(final String string) { try { - return NotificationType.valueOf(string.replace('-', '_').toUpperCase()); + return Type.valueOf(string.replace('-', '_').toUpperCase()); } catch (final IllegalArgumentException e) { - return NotificationType.UNKNOWN; + return Type.UNKNOWN; } } diff --git a/src/com/namelessmc/java_api/UserFilter.java b/src/com/namelessmc/java_api/UserFilter.java index bfb14a12..3a797fd1 100644 --- a/src/com/namelessmc/java_api/UserFilter.java +++ b/src/com/namelessmc/java_api/UserFilter.java @@ -15,7 +15,7 @@ public UserFilter(final @NonNull String filterName) { this.filterName = filterName; } - public @NonNull String getName() { + public @NonNull String name() { return this.filterName; } diff --git a/src/com/namelessmc/java_api/VerificationInfo.java b/src/com/namelessmc/java_api/VerificationInfo.java index 8b164240..0909664c 100644 --- a/src/com/namelessmc/java_api/VerificationInfo.java +++ b/src/com/namelessmc/java_api/VerificationInfo.java @@ -31,6 +31,7 @@ public boolean isVerifiedEmail() { return isVerifiedCustom("email"); } + // TODO are these still relevant with the new integration system? public boolean isVerifiedMinecraft() { return isVerifiedCustom("minecraft"); } diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 6bfe08e6..0bbb6396 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -10,7 +10,6 @@ public class Website implements LanguageEntity { - private final @NonNull String version; private final @Nullable Update update; private final @NonNull String@NonNull[] modules; @@ -42,18 +41,18 @@ public class Website implements LanguageEntity { this.rawLanguage = json.get("locale").getAsString(); } - public @NonNull String getVersion() { + public @NonNull String rawVersion() { return this.version; } - public @Nullable NamelessVersion getParsedVersion() { + public @Nullable NamelessVersion parsedVersion() { return NamelessVersion.parse(this.version); } /** * @return Information about an update, or empty if no update is available. */ - public @Nullable Update getUpdate() { + public @Nullable Update update() { return this.update; } @@ -62,7 +61,7 @@ public class Website implements LanguageEntity { } @Override - public @NonNull String getRawLocale() throws NamelessException { + public @NonNull String rawLocale() throws NamelessException { return this.rawLanguage; } @@ -80,11 +79,14 @@ public boolean isUrgent() { return this.isUrgent; } - - public String getVersion() { + public String rawVersion() { return this.version; } + public @Nullable NamelessVersion parsedVersion() { + return NamelessVersion.parse(this.version); + } + public @Nullable NamelessVersion getParsedVersion() { return NamelessVersion.parse(this.version); } diff --git a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java index e66da813..4f2b34dd 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java @@ -9,11 +9,12 @@ public class DetailedDiscordIntegrationData extends DetailedIntegrationData impl public DetailedDiscordIntegrationData(final @NonNull JsonObject json) { super(json); - this.idLong = Integer.parseInt(this.getIdentifier()); + this.idLong = Integer.parseInt(this.identifier()); } @Override - public final long getIdLong() { + public final long idLong() { return this.idLong; } + } diff --git a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java index 5b33ec63..708453b1 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java @@ -38,7 +38,7 @@ public final boolean isVerified() { return this.verified; } - public final @NonNull Date getLinkedDate() { + public final @NonNull Date linkedDate() { return this.linkedDate; } diff --git a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java index 71e2a4a3..75afbedf 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java @@ -12,11 +12,11 @@ public class DetailedMinecraftIntegrationData extends DetailedIntegrationData im public DetailedMinecraftIntegrationData(final @NonNull JsonObject json) { super(json); - this.uuid = NamelessAPI.websiteUuidToJavaUuid(this.getIdentifier()); + this.uuid = NamelessAPI.websiteUuidToJavaUuid(this.identifier()); } @Override - public final @NonNull UUID getUniqueId() { + public final @NonNull UUID uuid() { return this.uuid; } } diff --git a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java index 812ccec6..b7ded0cf 100644 --- a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java @@ -12,7 +12,7 @@ public DiscordIntegrationData(final long id, this.id = id; } - public final long getIdLong() { + public final long idLong() { return this.id; } diff --git a/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java index 7635ebe0..a86a7676 100644 --- a/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java @@ -2,6 +2,6 @@ public interface IDiscordIntegrationData { - long getIdLong(); + long idLong(); } diff --git a/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java index f22732c4..6b639f42 100644 --- a/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java @@ -6,6 +6,6 @@ public interface IMinecraftIntegrationData { - @NonNull UUID getUniqueId(); + @NonNull UUID uuid(); } diff --git a/src/com/namelessmc/java_api/integrations/IntegrationData.java b/src/com/namelessmc/java_api/integrations/IntegrationData.java index 7b3108e4..43a1f77d 100644 --- a/src/com/namelessmc/java_api/integrations/IntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/IntegrationData.java @@ -17,15 +17,15 @@ public IntegrationData(final @NonNull String integrationType, this.username = username; } - public final @NonNull String getIntegrationType(@UnknownInitialization(IntegrationData.class) IntegrationData this) { + public final @NonNull String type(@UnknownInitialization(IntegrationData.class) IntegrationData this) { return this.integrationType; } - public final @NonNull String getIdentifier(@UnknownInitialization(IntegrationData.class) IntegrationData this) { + public final @NonNull String identifier(@UnknownInitialization(IntegrationData.class) IntegrationData this) { return this.identifier; } - public final @NonNull String getUsername(@UnknownInitialization(IntegrationData.class) IntegrationData this) { + public final @NonNull String username(@UnknownInitialization(IntegrationData.class) IntegrationData this) { return this.username; } diff --git a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java index 05a7bf04..e2834f63 100644 --- a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java @@ -15,7 +15,7 @@ public MinecraftIntegrationData(final @NonNull UUID uuid, this.uuid = uuid; } - public final @NonNull UUID getUniqueId() { + public final @NonNull UUID uuid() { return this.uuid; } diff --git a/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java b/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java index 76e3035b..41ad7b58 100644 --- a/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java +++ b/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java @@ -26,13 +26,13 @@ public boolean shouldUseUuids() { return this.useUuids; } - public List getCustomers() { + public List customers() { return this.customers; } public static class PendingCommandsCustomer extends StoreCustomer { - private List pendingCommands; + private final List pendingCommands; private PendingCommandsCustomer(NamelessAPI api, JsonObject json) { super(api, json); @@ -44,6 +44,10 @@ private PendingCommandsCustomer(NamelessAPI api, JsonObject json) { } } + public List pendingCommands() { + return this.pendingCommands; + } + } public static class PendingCommand { @@ -60,15 +64,15 @@ private PendingCommand(JsonObject json) { this.requireOnline = json.get("require_online").getAsBoolean(); } - public int getId() { + public int id() { return id; } - public String getCommand() { + public String command() { return command; } - public int getOrderId() { + public int orderId() { return orderId; } diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index adf7aff2..ecffe2ae 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -21,7 +21,7 @@ public StoreAPI(NamelessAPI api) { this.requests = api.getRequestHandler(); } - public List getProducts() throws NamelessException { + public List products() throws NamelessException { JsonObject response = this.requests.get("store/products"); JsonArray productsJson = response.getAsJsonArray("products"); List products = new ArrayList<>(productsJson.size()); @@ -31,7 +31,7 @@ public List getProducts() throws NamelessException { return products; } - public List getPayments() throws NamelessException { + public List payments() throws NamelessException { JsonObject response = this.requests.get("store/payments"); JsonArray paymentsJson = response.getAsJsonArray("payments"); List payments = new ArrayList<>(paymentsJson.size()); @@ -41,7 +41,7 @@ public List getPayments() throws NamelessException { return payments; } - public PendingCommandsResponse getPendingCommands() throws NamelessException { + public PendingCommandsResponse pendingCommands() throws NamelessException { JsonObject response = this.requests.get("store/pending-commands"); return new PendingCommandsResponse(this.api, response); } @@ -49,7 +49,7 @@ public PendingCommandsResponse getPendingCommands() throws NamelessException { public void markCommandsExecuted(Collection commands) throws NamelessException { JsonArray array = new JsonArray(commands.size()); for (PendingCommandsResponse.PendingCommand command : commands) { - array.add(command.getId()); + array.add(command.id()); } JsonObject body = new JsonObject(); body.add("commands", array); diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java index 4665b145..e91dbe23 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java +++ b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java @@ -22,19 +22,19 @@ public class StoreCustomer { this.identifier = json.has("identifier") ? json.get("identifier").getAsString() : null; } - public int getId() { + public int id() { return this.id; } - public @Nullable NamelessUser getNamelessUser() throws NamelessException { + public @Nullable NamelessUser user() throws NamelessException { return this.userId != null ? this.api.getUser(this.userId) : null; } - public @Nullable String getUsername() { + public @Nullable String username() { return this.username; } - public @Nullable String getIdentifier() { + public @Nullable String identifier() { return this.identifier; } diff --git a/src/com/namelessmc/java_api/modules/store/StorePayment.java b/src/com/namelessmc/java_api/modules/store/StorePayment.java index e8371b76..a6fe1e19 100644 --- a/src/com/namelessmc/java_api/modules/store/StorePayment.java +++ b/src/com/namelessmc/java_api/modules/store/StorePayment.java @@ -46,55 +46,55 @@ public class StorePayment { } } - public int getId() { + public int id() { return id; } - public int getOrderId() { + public int orderId() { return orderId; } - public int getGatewayId() { + public int gatewayId() { return gatewayId; } - public String getTransaction() { + public String transaction() { return transaction; } - public String getAmount() { + public String amount() { return amount; } - public String getCurrency() { + public String currency() { return currency; } - public String getFee() { + public String fee() { return fee; } - public PaymentStatus getStatus() { + public PaymentStatus status() { return status; } - public Date getCreationDate() { + public Date creationDate() { return creationDate; } - public Date getLastUpdateDate() { + public Date lastUpdatedDate() { return lastUpdateDate; } - public StoreCustomer getPayingCustomer() { + public StoreCustomer payingCustomer() { return payingCustomer; } - public StoreCustomer getReceivingCustomer() { + public StoreCustomer receivingCustomer() { return receivingCustomer; } - public List getProducts() { + public List products() { return products; } diff --git a/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java b/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java index 13509d91..05ba7cb9 100644 --- a/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java +++ b/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java @@ -12,11 +12,11 @@ public class StorePaymentProduct { this.name = json.get("name").getAsString(); } - public int getId() { + public int id() { return id; } - public String getName() { + public String name() { return name; } diff --git a/src/com/namelessmc/java_api/modules/store/StoreProduct.java b/src/com/namelessmc/java_api/modules/store/StoreProduct.java index 0bf1e180..51182f45 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreProduct.java +++ b/src/com/namelessmc/java_api/modules/store/StoreProduct.java @@ -20,19 +20,19 @@ public class StoreProduct { this.disabled = json.get("disabled").getAsBoolean(); } - public int getId() { + public int id() { return this.id; } - public int getCategoryId() { + public int categoryId() { return this.categoryId; } - public String getName() { + public String name() { return this.name; } - public float getPrice() { + public float price() { return this.price; } diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index 5ba85823..342fddce 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -12,19 +12,19 @@ public class StoreUser { public StoreUser(NamelessUser user) { this.user = user; - this.requests = user.getApi().getRequestHandler(); + this.requests = user.api().getRequestHandler(); } public void addCredits(float creditsToAdd) throws NamelessException { JsonObject body = new JsonObject(); body.addProperty("credits", creditsToAdd); - this.requests.post("users/" + this.user.getEncodedUserTransformer() + "/add-credits", body); + this.requests.post("users/" + this.user.userTransformer() + "/add-credits", body); } public void removeCredits(float creditsToRemove) throws NamelessException { JsonObject body = new JsonObject(); body.addProperty("credits", creditsToRemove); - this.requests.post("users/" + this.user.getEncodedUserTransformer() + "/remove-credits", body); + this.requests.post("users/" + this.user.userTransformer() + "/remove-credits", body); } } diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java index 1cbc7d63..7a2cb563 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java @@ -17,7 +17,7 @@ public WebsendAPI(@NonNull RequestHandler requests) { this.requests = Objects.requireNonNull(requests, "Request handler is null"); } - public @NonNull List getCommands(int serverId) throws NamelessException { + public @NonNull List commands(int serverId) throws NamelessException { JsonObject response = this.requests.get("websend/commands","server_id", serverId); JsonArray commandsJson = response.getAsJsonArray("commands"); List commands = new ArrayList<>(commandsJson.size()); diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java b/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java index d4c97be3..180afce0 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java @@ -14,11 +14,11 @@ public WebsendCommand(final @Positive int id, this.commandLine = commandLine; } - public @Positive int getId() { + public @Positive int id() { return id; } - public @NonNull String getCommandLine() { + public @NonNull String command() { return this.commandLine; } From a767d56aa7cbf63304f152e05ee9ded8e668361a Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 29 May 2022 15:00:41 +0200 Subject: [PATCH 055/269] some fixes --- .../namelessmc/java_api/modules/store/StoreAPI.java | 4 ++-- .../java_api/modules/store/StoreCustomer.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index ecffe2ae..14b6cea4 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -41,8 +41,8 @@ public List payments() throws NamelessException { return payments; } - public PendingCommandsResponse pendingCommands() throws NamelessException { - JsonObject response = this.requests.get("store/pending-commands"); + public PendingCommandsResponse pendingCommands(int connectionId) throws NamelessException { + JsonObject response = this.requests.get("store/pending-commands", "connection_id", connectionId); return new PendingCommandsResponse(this.api, response); } diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java index e91dbe23..87474031 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java +++ b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java @@ -6,6 +6,8 @@ import com.namelessmc.java_api.NamelessUser; import org.checkerframework.checker.nullness.qual.Nullable; +import java.util.UUID; + public class StoreCustomer { private final NamelessAPI api; @@ -20,6 +22,10 @@ public class StoreCustomer { this.userId = json.has("user_id") ? json.get("user_id").getAsInt() : null; this.username = json.has("username") ? json.get("username").getAsString() : null; this.identifier = json.has("identifier") ? json.get("identifier").getAsString() : null; + + if (this.username == null && this.identifier == null) { + throw new IllegalStateException("Username and identifier cannot be null at the same time"); + } } public int id() { @@ -38,4 +44,9 @@ public int id() { return this.identifier; } + public @Nullable UUID identifierAsUuid() { + // Unlike NamelessMC, the store module sends UUIDs with dashes + return this.identifier != null ? UUID.fromString(this.identifier) : null; + } + } From ba435eb192b9c66a45fb57640651cc2b82bc7171 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 29 May 2022 15:02:38 +0200 Subject: [PATCH 056/269] In pending commands response, username is never null --- .../modules/store/PendingCommandsResponse.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java b/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java index 41ad7b58..7a001ac5 100644 --- a/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java +++ b/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java @@ -4,6 +4,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; +import org.checkerframework.checker.nullness.qual.NonNull; import java.util.ArrayList; import java.util.List; @@ -44,6 +45,15 @@ private PendingCommandsCustomer(NamelessAPI api, JsonObject json) { } } + @Override + public @NonNull String username() { + String username = super.username(); + if (username == null) { + throw new IllegalStateException("Pending commands response cannot contain null username"); + } + return username; + } + public List pendingCommands() { return this.pendingCommands; } From 8bb92e13e0a29e216f536073ef64600279449321 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 30 May 2022 10:55:33 +0200 Subject: [PATCH 057/269] Add payments filters --- .../modules/store/PaymentsFilter.java | 55 +++++++++++++++++++ .../java_api/modules/store/StoreAPI.java | 9 ++- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/com/namelessmc/java_api/modules/store/PaymentsFilter.java diff --git a/src/com/namelessmc/java_api/modules/store/PaymentsFilter.java b/src/com/namelessmc/java_api/modules/store/PaymentsFilter.java new file mode 100644 index 00000000..9d7de754 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/PaymentsFilter.java @@ -0,0 +1,55 @@ +package com.namelessmc.java_api.modules.store; + +import java.util.Objects; + +public class PaymentsFilter { + + private final String name; + private final String value; + + private PaymentsFilter(String name, String value) { + this.name = Objects.requireNonNull(name); + this.value = Objects.requireNonNull(value); + } + + public String name() { + return this.name; + } + + public String value() { + return this.value; + } + + public static PaymentsFilter order(int orderId) { + return new PaymentsFilter("order", String.valueOf(orderId)); + } + + public static PaymentsFilter gateway(int gatewayId) { + return new PaymentsFilter("gateway", String.valueOf(gatewayId)); + } + + public static PaymentsFilter status(PaymentStatus status) { + return new PaymentsFilter("status", String.valueOf(status.ordinal())); + } + + public static PaymentsFilter payingCustomer(int customerId) { + return new PaymentsFilter("customer", String.valueOf(customerId)); + } + + public static PaymentsFilter payingCustomer(StoreCustomer customer) { + return payingCustomer(customer.id()); + } + + public static PaymentsFilter receivingCustomer(int customerId) { + return new PaymentsFilter("recipient", String.valueOf(customerId)); + } + + public static PaymentsFilter receivingCustomer(StoreCustomer customer) { + return payingCustomer(customer.id()); + } + + public static PaymentsFilter limit(int limit) { + return new PaymentsFilter("limit", String.valueOf(limit)); + } + +} diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index 14b6cea4..3fceedbf 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -31,8 +31,13 @@ public List products() throws NamelessException { return products; } - public List payments() throws NamelessException { - JsonObject response = this.requests.get("store/payments"); + public List payments(PaymentsFilter... filters) throws NamelessException { + Object[] params = new Object[filters.length * 2]; + for (int i = 0; i < filters.length; i++) { + params[i*2] = filters[i].name(); + params[i*2+1] = filters[i].value(); + } + JsonObject response = this.requests.get("store/payments", params); JsonArray paymentsJson = response.getAsJsonArray("payments"); List payments = new ArrayList<>(paymentsJson.size()); for (JsonElement productElement : paymentsJson) { From 37adfd7087e939285bbc09521f7af11883024464 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 30 May 2022 10:59:30 +0200 Subject: [PATCH 058/269] Add store categories --- .../java_api/modules/store/StoreAPI.java | 15 ++++++-- .../java_api/modules/store/StoreCategory.java | 35 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/com/namelessmc/java_api/modules/store/StoreCategory.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index 3fceedbf..f6cf3586 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; public class StoreAPI { @@ -28,7 +29,7 @@ public List products() throws NamelessException { for (JsonElement productElement : productsJson) { products.add(new StoreProduct(productElement.getAsJsonObject())); } - return products; + return Collections.unmodifiableList(products); } public List payments(PaymentsFilter... filters) throws NamelessException { @@ -43,7 +44,17 @@ public List payments(PaymentsFilter... filters) throws NamelessExc for (JsonElement productElement : paymentsJson) { payments.add(new StorePayment(this.api, productElement.getAsJsonObject())); } - return payments; + return Collections.unmodifiableList(payments); + } + + public List categories() throws NamelessException { + JsonObject response = this.requests.get("store/products"); + JsonArray array = response.getAsJsonArray("categories"); + List categories = new ArrayList<>(array.size()); + for (JsonElement element : array) { + categories.add(new StoreCategory(element.getAsJsonObject())); + } + return Collections.unmodifiableList(categories); } public PendingCommandsResponse pendingCommands(int connectionId) throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/store/StoreCategory.java b/src/com/namelessmc/java_api/modules/store/StoreCategory.java new file mode 100644 index 00000000..62401a33 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StoreCategory.java @@ -0,0 +1,35 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonObject; + +public class StoreCategory { + + private final int id; + private final String name; + private final boolean hidden; + private final boolean disabled; + + StoreCategory(JsonObject json) { + this.id = json.get("id").getAsInt(); + this.name = json.get("name").getAsString(); + this.hidden = json.get("hidden").getAsBoolean(); + this.disabled = json.get("disabled").getAsBoolean(); + } + + public int id() { + return this.id; + } + + public String name() { + return this.name; + } + + public boolean isHidden() { + return this.hidden; + } + + public boolean isDisabled() { + return this.disabled; + } + +} From ccdc8a288a53bf87497723fe1cac3a538c1cce89 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Jun 2022 11:10:32 +0000 Subject: [PATCH 059/269] Bump checker-qual from 3.22.0 to 3.22.1 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.22.0 to 3.22.1. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/checker-framework-3.22.1/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.22.0...checker-framework-3.22.1) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e619207b..c737f4ee 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.22.0 + 3.22.1 From b5d21b56b0c19b7eb70d89ce992069f4cc8fce73 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 4 Jun 2022 22:18:13 +0200 Subject: [PATCH 060/269] pr12 can be removed from supported versions now --- src/com/namelessmc/java_api/NamelessVersion.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index 344d1720..836171c1 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -18,8 +18,6 @@ public enum NamelessVersion { ; private static final Set SUPPORTED_VERSIONS = EnumSet.of( - // Actually, only pr13 is supported but pr13 development releases still report as pr12 - V2_0_0_PR_12, V2_0_0_PR_13 ); From 357762e15489af3c0c0d7fcf6b6e3b039a1e2a17 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 4 Jun 2022 22:27:50 +0200 Subject: [PATCH 061/269] Rename methods, fix nameless_version check --- .../java_api/FilteredUserListBuilder.java | 2 +- src/com/namelessmc/java_api/NamelessAPI.java | 68 +++++++++---------- src/com/namelessmc/java_api/NamelessUser.java | 6 +- src/com/namelessmc/java_api/Website.java | 9 ++- .../java_api/modules/store/StoreAPI.java | 2 +- .../java_api/modules/store/StoreCustomer.java | 2 +- .../java_api/modules/store/StoreUser.java | 2 +- 7 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index e11f3bff..ecb2e4e2 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -55,7 +55,7 @@ public JsonObject makeRawRequest() throws NamelessException { parameters = new Object[0]; } - return this.api.getRequestHandler().get("users", parameters); + return this.api.requests().get("users", parameters); } public @NonNull List<@NonNull NamelessUser> makeRequest() throws NamelessException { diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 2c83073f..1ff3cc44 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -34,15 +34,15 @@ public final class NamelessAPI { this.apiKey = apiKey; } - public @NonNull RequestHandler getRequestHandler() { + public @NonNull RequestHandler requests() { return this.requests; } - public @NonNull URL getApiUrl() { + public @NonNull URL apiUrl() { return this.apiUrl; } - public @NonNull String getApiKey() { + public @NonNull String apiKey() { return this.apiKey; } @@ -51,9 +51,9 @@ public final class NamelessAPI { * @return List of announcements */ - public @NonNull List<@NonNull Announcement> getAnnouncements() throws NamelessException { + public @NonNull List<@NonNull Announcement> announcements() throws NamelessException { final JsonObject response = this.requests.get("announcements"); - return getAnnouncements(response); + return announcements(response); } /** @@ -61,7 +61,7 @@ public final class NamelessAPI { * @param response Announcements json API response * @return List of {@link Announcement} objects */ - static @NonNull List<@NonNull Announcement> getAnnouncements(final @NonNull JsonObject response) { + static @NonNull List<@NonNull Announcement> announcements(final @NonNull JsonObject response) { return StreamSupport.stream(response.getAsJsonArray("announcements").spliterator(), false) .map(JsonElement::getAsJsonObject) .map(Announcement::new) @@ -80,12 +80,12 @@ public void submitServerInfo(final @NonNull JsonObject jsonData) throws Nameless * Get website information * @return {@link Website} object containing website information */ - public Website getWebsite() throws NamelessException { + public Website website() throws NamelessException { final JsonObject json = this.requests.get("info"); return new Website(json); } - public FilteredUserListBuilder getRegisteredUsers() { + public FilteredUserListBuilder users() { return new FilteredUserListBuilder(this); } @@ -101,28 +101,28 @@ public FilteredUserListBuilder getRegisteredUsers() { } } - public @Nullable NamelessUser getUser(final int id) throws NamelessException { - return userAsNullable(getUserLazy(id)); + public @Nullable NamelessUser user(final int id) throws NamelessException { + return userAsNullable(userLazy(id)); } - public @Nullable NamelessUser getUserByUsername(final @NonNull String username) throws NamelessException { - return userAsNullable(getUserByUsernameLazy(username)); + public @Nullable NamelessUser userByUsername(final @NonNull String username) throws NamelessException { + return userAsNullable(userByUsernameLazy(username)); } - public @Nullable NamelessUser getUserByMinecraftUuid(final @NonNull UUID uuid) throws NamelessException { - return userAsNullable(getUserByMinecraftUuidLazy(uuid)); + public @Nullable NamelessUser userByMinecraftUuid(final @NonNull UUID uuid) throws NamelessException { + return userAsNullable(userByMinecraftUuidLazy(uuid)); } - public @Nullable NamelessUser getUserByMinecraftUsername(final @NonNull String username) throws NamelessException { - return userAsNullable(getUserByMinecraftUsernameLazy(username)); + public @Nullable NamelessUser userByMinecraftUsername(final @NonNull String username) throws NamelessException { + return userAsNullable(userByMinecraftUsernameLazy(username)); } - public @Nullable NamelessUser getUserByDiscordId(final long id) throws NamelessException { - return userAsNullable(getUserByDiscordIdLazy(id)); + public @Nullable NamelessUser userByDiscordId(final long id) throws NamelessException { + return userAsNullable(userByDiscordIdLazy(id)); } - public @Nullable NamelessUser getUserByDiscordUsername(final @NonNull String username) throws NamelessException { - return userAsNullable(getUserByDiscordUsernameLazy(username)); + public @Nullable NamelessUser userByDiscordUsername(final @NonNull String username) throws NamelessException { + return userAsNullable(userByDiscordUsernameLazy(username)); } /** @@ -130,32 +130,32 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param id NamelessMC user id * @return Nameless user object, never null */ - public @NonNull NamelessUser getUserLazy(final int id) { + public @NonNull NamelessUser userLazy(final int id) { return new NamelessUser(this, id); } - public @NonNull NamelessUser getUserLazy(final @NonNull String userTransformer) { + public @NonNull NamelessUser userLazy(final @NonNull String userTransformer) { return new NamelessUser(this, userTransformer); } - public @NonNull NamelessUser getUserByUsernameLazy(final @NonNull String username) { - return getUserLazy("username:" + username); + public @NonNull NamelessUser userByUsernameLazy(final @NonNull String username) { + return userLazy("username:" + username); } - public @NonNull NamelessUser getUserByMinecraftUuidLazy(final @NonNull UUID uuid) { - return getUserLazy("integration_id:minecraft:" + javaUuidToWebsiteUuid(uuid)); + public @NonNull NamelessUser userByMinecraftUuidLazy(final @NonNull UUID uuid) { + return userLazy("integration_id:minecraft:" + javaUuidToWebsiteUuid(uuid)); } - public @NonNull NamelessUser getUserByMinecraftUsernameLazy(final @NonNull String username) { - return getUserLazy("integration_username:minecraft:" + username); + public @NonNull NamelessUser userByMinecraftUsernameLazy(final @NonNull String username) { + return userLazy("integration_username:minecraft:" + username); } - public @NonNull NamelessUser getUserByDiscordIdLazy(final long id) { - return getUserLazy("integration_id:discord:" + id); + public @NonNull NamelessUser userByDiscordIdLazy(final long id) { + return userLazy("integration_id:discord:" + id); } - public @NonNull NamelessUser getUserByDiscordUsernameLazy(final @NonNull String username) { - return getUserLazy("integration_username:discord:" + username); + public @NonNull NamelessUser userByDiscordUsernameLazy(final @NonNull String username) { + return userLazy("integration_username:discord:" + username); } /** @@ -163,7 +163,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param id Group id * @return Group or null if it doesn't exist */ - public @Nullable Group getGroup(final int id) throws NamelessException { + public @Nullable Group group(final int id) throws NamelessException { final JsonObject response = this.requests.get("groups", "id", id); final JsonArray jsonArray = response.getAsJsonArray("groups"); if (jsonArray.size() == 1) { @@ -180,7 +180,7 @@ public FilteredUserListBuilder getRegisteredUsers() { * @param name NamelessMC groups name * @return List of groups with this name, empty if there are no groups with this name. */ - public List getGroup(final @NonNull String name) throws NamelessException { + public List group(final @NonNull String name) throws NamelessException { Objects.requireNonNull(name, "Group name is null"); final JsonObject response = this.requests.get("groups", "name", name); return groupListFromJsonArray(response.getAsJsonArray("groups")); diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 8c2ae0d7..fef6f63a 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -37,7 +37,7 @@ public final class NamelessUser implements LanguageEntity { final @Positive int id ) { this.api = api; - this.requests = api.getRequestHandler(); + this.requests = api.requests(); this.id = id; this.userTransformer = "id:" + id; @@ -45,7 +45,7 @@ public final class NamelessUser implements LanguageEntity { NamelessUser(final @NonNull NamelessAPI api, final @NonNull String userTransformer) { this.api = api; - this.requests = api.getRequestHandler(); + this.requests = api.requests(); this.id = -1; this.userTransformer = URLEncoder.encode(userTransformer, StandardCharsets.UTF_8); @@ -308,7 +308,7 @@ public void discordRoles(final long@NonNull[] roleIds) throws NamelessException */ public @NonNull List<@NonNull Announcement> announcements() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.userTransformer + "/announcements"); - return NamelessAPI.getAnnouncements(response); + return NamelessAPI.announcements(response); } /** diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 0bbb6396..65d63bac 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -15,9 +15,16 @@ public class Website implements LanguageEntity { private final @NonNull String@NonNull[] modules; private final @NonNull String rawLanguage; - Website(final @NonNull JsonObject json) { + Website(final @NonNull JsonObject json) throws NamelessException { Objects.requireNonNull(json, "Provided json object is null"); + if (!json.has("nameless_version")) { + // This is usually the point where people run into issues if the response is not from NamelessMC + // but from something else like a proxy or denial of service protection system, so we throw a useful + // exception. + throw new NamelessException("Website didn't include namelessmc_version in the info response. Is the response from NamelessMC?"); + } + this.version = json.get("nameless_version").getAsString(); this.modules = StreamSupport.stream(json.get("modules").getAsJsonArray().spliterator(), false) diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index f6cf3586..e3aa8e79 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -19,7 +19,7 @@ public class StoreAPI { public StoreAPI(NamelessAPI api) { this.api = api; - this.requests = api.getRequestHandler(); + this.requests = api.requests(); } public List products() throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java index 87474031..31495d90 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java +++ b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java @@ -33,7 +33,7 @@ public int id() { } public @Nullable NamelessUser user() throws NamelessException { - return this.userId != null ? this.api.getUser(this.userId) : null; + return this.userId != null ? this.api.user(this.userId) : null; } public @Nullable String username() { diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index 342fddce..f6f9bad5 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -12,7 +12,7 @@ public class StoreUser { public StoreUser(NamelessUser user) { this.user = user; - this.requests = user.api().getRequestHandler(); + this.requests = user.api().requests(); } public void addCredits(float creditsToAdd) throws NamelessException { From 8318a867480c33f81f84a5ce5431d7a06a95845c Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 4 Jun 2022 22:47:04 +0200 Subject: [PATCH 062/269] Add integration errors --- src/com/namelessmc/java_api/exception/ApiError.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/namelessmc/java_api/exception/ApiError.java b/src/com/namelessmc/java_api/exception/ApiError.java index 31fc3cd1..67f9660a 100644 --- a/src/com/namelessmc/java_api/exception/ApiError.java +++ b/src/com/namelessmc/java_api/exception/ApiError.java @@ -36,6 +36,8 @@ public enum ApiError { CORE_INVALID_CODE("core", "invalid_code"), CORE_USER_ALREADY_ACTIVE("core", "user_already_active"), CORE_UNABLE_TO_UPDATE_USERNAME("core", "unable_to_update_username"), + CORE_INTEGRATION_IDENTIFIER_ERROR("core", "integration_identifier_errors"), + CORE_INTEGRATION_USERNAME_ERROR("core", "integration_username_errors"), // https://github.com/NamelessMC/Nameless/blob/v2/modules/Discord%20Integration/classes/DiscordApiErrors.php DISCORD_DISCORD_INTEGRATION_DISABLED("discord_integration", "discord_integration_disabled"), From 4469de8fb1d0d92a1d8a1c89d8fc9800d24cde20 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 6 Jun 2022 11:30:18 +0200 Subject: [PATCH 063/269] Truncate more --- src/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 2ff354c9..73052e69 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -180,7 +180,7 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append("Website response:\n"); message.append("-----------------\n"); - int totalLengthLimit = 1950; // fit in a Discord message with safety margin + int totalLengthLimit = 1500; // fit in a Discord message String printableResponse = regularAsciiOnly(responseBody); message.append(Ascii.truncate(printableResponse, totalLengthLimit, "[truncated]\n")); if (message.charAt(message.length() - 1) != '\n') { From 05d8be2339637d09802f4885d16c537467cc2021 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 6 Jun 2022 21:00:50 +0200 Subject: [PATCH 064/269] add sendConsoleLog clearPrevious boolean --- .../namelessmc/java_api/modules/websend/WebsendAPI.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java index 7a2cb563..8dfe08e3 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java @@ -30,9 +30,14 @@ public WebsendAPI(@NonNull RequestHandler requests) { return Collections.unmodifiableList(commands); } - public void sendConsoleLog(int serverId, @NonNull Collection lines) throws NamelessException { + public void sendConsoleLog(int serverId, Collection lines) throws NamelessException { + sendConsoleLog(serverId, lines, false); + } + + public void sendConsoleLog(int serverId, Collection lines, boolean clearPrevious) throws NamelessException { JsonObject body = new JsonObject(); body.addProperty("server_id", serverId); + body.addProperty("clear_previous", clearPrevious); JsonArray content = new JsonArray(); for (String line : lines) { content.add(line); From 5efeb56d239f47c157b90c8edd7a41a9bd58d694 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 6 Jun 2022 22:08:14 +0200 Subject: [PATCH 065/269] remove stray s --- src/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 73052e69..2a70af07 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -173,7 +173,7 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append("HINT: It looks like requests are being blocked by your web server or a proxy. "); message.append("This is a common occurrence with free web hosting services; they usually don't allow API access.\n"); } else if (responseBody.contains("Please Wait... | Cloudflare")) { - message.append("HINT: CloudFlare is blocking our request. Please see https://docs.namelessmc.com/cloudflare-apis\n"); + message.append("HINT: CloudFlare is blocking our request. Please see https://docs.namelessmc.com/cloudflare-api\n"); } else if (responseBody.startsWith("\ufeff")) { message.append("HINT: The website response contains invisible unicode characters. This seems to be caused by Partydragen's Store module, we have no idea why.\n"); } From c6dbcd172e4f1d01640f865f56a4f19c9de02a60 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 10 Jun 2022 10:39:58 +0200 Subject: [PATCH 066/269] Also set headers timeout --- src/com/namelessmc/java_api/NamelessApiBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index dc4305d5..d264e217 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -47,6 +47,7 @@ public class NamelessApiBuilder { .readTimeout(DEFAULT_TIMEOUT) .requestTimeout(DEFAULT_TIMEOUT) .connectTimeout(DEFAULT_TIMEOUT) + .headersTimeout(DEFAULT_TIMEOUT) .autoAcceptEncoding(true); } From 402e1acb06931e2d32f5e1ae0843f2ce40aa1a3c Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 10 Jun 2022 11:23:27 +0200 Subject: [PATCH 067/269] Improve cloudflare check --- src/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 2a70af07..b880bcaf 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -172,7 +172,7 @@ private void debug(final @NonNull Supplier messageSupplier) { } else if (responseBody.contains("/aes.js")) { message.append("HINT: It looks like requests are being blocked by your web server or a proxy. "); message.append("This is a common occurrence with free web hosting services; they usually don't allow API access.\n"); - } else if (responseBody.contains("Please Wait... | Cloudflare")) { + } else if (responseBody.contains("Please Wait... | Cloudflare") || responseBody.contains("#cf-bubbles")) { message.append("HINT: CloudFlare is blocking our request. Please see https://docs.namelessmc.com/cloudflare-api\n"); } else if (responseBody.startsWith("\ufeff")) { message.append("HINT: The website response contains invisible unicode characters. This seems to be caused by Partydragen's Store module, we have no idea why.\n"); From 41cc626cb6e2801bd012bb56fabf49859c9dc444 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 10 Jun 2022 11:44:11 +0200 Subject: [PATCH 068/269] Ensure timeouts are set consistently --- src/com/namelessmc/java_api/NamelessApiBuilder.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index d264e217..40b90bed 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -44,11 +44,8 @@ public class NamelessApiBuilder { this.httpClientBuilder = Methanol.newBuilder() .defaultHeader("Authorization", "Bearer " + this.apiKey) .userAgent(DEFAULT_USER_AGENT) - .readTimeout(DEFAULT_TIMEOUT) - .requestTimeout(DEFAULT_TIMEOUT) - .connectTimeout(DEFAULT_TIMEOUT) - .headersTimeout(DEFAULT_TIMEOUT) .autoAcceptEncoding(true); + this.timeout(DEFAULT_TIMEOUT); } public @NonNull NamelessApiBuilder userAgent(final @NonNull String userAgent) { @@ -84,7 +81,8 @@ public class NamelessApiBuilder { public @NonNull NamelessApiBuilder timeout(final @NonNull Duration timeout) { this.httpClientBuilder.readTimeout(timeout) .requestTimeout(timeout) - .connectTimeout(timeout); + .connectTimeout(timeout) + .headersTimeout(timeout); return this; } From f490e7e525443891e70aba4b7a385710a6026d06 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 10 Jun 2022 11:48:50 +0200 Subject: [PATCH 069/269] Log current timeout --- src/com/namelessmc/java_api/RequestHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index b880bcaf..f62dad65 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -131,7 +131,7 @@ private void debug(final @NonNull Supplier messageSupplier) { } catch (final IOException e) { final @Nullable String exceptionMessage = e.getMessage(); final StringBuilder message = new StringBuilder("Network connection error (not a Nameless issue). IOException message: \""); - message.append(e.getMessage()); + message.append(exceptionMessage); message.append('"'); if (exceptionMessage != null) { if (exceptionMessage.contains("unable to find valid certification path to requested target")) { @@ -142,6 +142,10 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append("\nHINT: Is a webserver running at the provided domain? Are we blocked by a firewall? Is your webserver fast enough?"); } else if (exceptionMessage.contains("Connection refused")) { message.append("\nHINT: Is the domain correct? Is your webserver running? Are we blocked by a firewall?"); + } else if (exceptionMessage.contains("timed out")) { + // All timeouts are set to the same value, so we only need to print one. + long seconds = httpClient.connectTimeout().orElseThrow().getSeconds(); + message.append("\nHINT: The website responded too slow, timeout is set to ").append(seconds).append(" seconds."); } } From 780c8014b935f62ac094b7ccd9221a2fa7390f6e Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 11 Jun 2022 13:47:54 +0200 Subject: [PATCH 070/269] Send helpful message if error == true --- src/com/namelessmc/java_api/RequestHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index f62dad65..8d14dac4 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -196,6 +196,9 @@ private void debug(final @NonNull Supplier messageSupplier) { if (json.has("error")) { final String errorString = json.get("error").getAsString(); + if (errorString.equals("true")) { + throw new NamelessException("Error string is 'true', are you using an older NamelessMC version?"); + } final ApiError apiError = ApiError.fromString(errorString); if (apiError == null) { throw new NamelessException("Unknown API error: " + errorString); From 5625198d668516f0827afc6b506185e13339bed3 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 11 Jun 2022 16:54:47 +0200 Subject: [PATCH 071/269] Move discord module methods to separate classes --- src/com/namelessmc/java_api/NamelessAPI.java | 142 +--------------- src/com/namelessmc/java_api/NamelessUser.java | 13 +- .../namelessmc/java_api/RequestHandler.java | 2 +- .../java_api/modules/discord/DiscordAPI.java | 157 ++++++++++++++++++ .../java_api/modules/discord/DiscordUser.java | 26 +++ .../java_api/modules/websend/WebsendAPI.java | 7 +- 6 files changed, 200 insertions(+), 147 deletions(-) create mode 100644 src/com/namelessmc/java_api/modules/discord/DiscordAPI.java create mode 100644 src/com/namelessmc/java_api/modules/discord/DiscordUser.java diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 1ff3cc44..ef97501a 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -1,12 +1,12 @@ package com.namelessmc.java_api; -import com.google.common.base.Preconditions; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.integrations.IntegrationData; +import com.namelessmc.java_api.modules.discord.DiscordAPI; import com.namelessmc.java_api.modules.store.StoreAPI; import com.namelessmc.java_api.modules.websend.WebsendAPI; import org.checkerframework.checker.nullness.qual.NonNull; @@ -253,138 +253,6 @@ public Optional registerUser(final @NonNull String username, } } - /** - * Set Discord bot URL (Nameless-Link internal webserver) - * @param url Discord bot URL - */ - public void setDiscordBotUrl(final @NonNull URL url) throws NamelessException { - Objects.requireNonNull(url, "Bot url is null"); - - final JsonObject json = new JsonObject(); - json.addProperty("url", url.toString()); - this.requests.post("discord/update-bot-settings", json); - } - - /** - * Set Discord guild (server) id - * @param guildId Discord guild (server) id - */ - public void setDiscordGuildId(final long guildId) throws NamelessException { - final JsonObject json = new JsonObject(); - json.addProperty("guild_id", guildId + ""); - this.requests.post("discord/update-bot-settings", json); - } - - /** - * Set discord bot username and user id - * @param username Bot username#tag - * @param userId Bot user id - * @see #setDiscordBotSettings(URL, long, String, long) - */ - public void setDiscordBotUser(final @NonNull String username, final long userId) throws NamelessException { - Objects.requireNonNull(username, "Bot username is null"); - - final JsonObject json = new JsonObject(); - json.addProperty("bot_username", username); - json.addProperty("bot_user_id", userId + ""); - this.requests.post("discord/update-bot-settings", json); - } - - /** - * Update all Discord bot settings. - * @param url Discord bot URL - * @param guildId Discord guild (server) id - * @param username Discord bot username#tag - * @param userId Discord bot user id - * @see #setDiscordBotUrl(URL) - * @see #setDiscordGuildId(long) - * @see #setDiscordBotUser(String, long) - */ - public void setDiscordBotSettings(final @NonNull URL url, - final long guildId, - final @NonNull String username, - final long userId) throws NamelessException { - Objects.requireNonNull(url, "Bot url is null"); - Objects.requireNonNull(username, "Bot username is null"); - - final JsonObject json = new JsonObject(); - json.addProperty("url", url.toString()); - json.addProperty("guild_id", guildId + ""); - json.addProperty("bot_username", username); - json.addProperty("bot_user_id", userId + ""); - this.requests.post("discord/update-bot-settings", json); - } - - /** - * Send list of Discord roles to the website for populating the dropdown in StaffCP > API > Group sync - * @param discordRoles Map of Discord roles, key is role id, value is role name - */ - public void submitDiscordRoleList(final @NonNull Map discordRoles) throws NamelessException { - final JsonArray roles = new JsonArray(); - discordRoles.forEach((id, name) -> { - final JsonObject role = new JsonObject(); - role.addProperty("id", id); - role.addProperty("name", name); - roles.add(role); - }); - final JsonObject json = new JsonObject(); - json.add("roles", roles); - this.requests.post("discord/submit-role-list", json); - } - - /** - * Update Discord username for a NamelessMC user associated with the provided Discord user id - * @param discordUserId Discord user id - * @param discordUsername New Discord [username#tag]s - * @see #updateDiscordUsernames(long[], String[]) - */ - public void updateDiscordUsername(final long discordUserId, - final @NonNull String discordUsername) - throws NamelessException { - Objects.requireNonNull(discordUsername, "Discord username is null"); - - final JsonObject user = new JsonObject(); - user.addProperty("id", discordUserId); - user.addProperty("name", discordUsername); - final JsonArray users = new JsonArray(); - users.add(user); - final JsonObject json = new JsonObject(); - json.add("users", users); - this.requests.post("discord/update-usernames", json); - } - - /** - * Update Discord usernames in bulk - * @param discordUserIds Discord user ids - * @param discordUsernames New Discord [username#tag]s - * @see #updateDiscordUsername(long, String) - */ - public void updateDiscordUsernames(final long@NonNull[] discordUserIds, - final @NonNull String@NonNull[] discordUsernames) - throws NamelessException { - Objects.requireNonNull(discordUserIds, "User ids array is null"); - Objects.requireNonNull(discordUsernames, "Usernames array is null"); - Preconditions.checkArgument(discordUserIds.length == discordUsernames.length, - "discord user ids and discord usernames must be of same length"); - - if (discordUserIds.length == 0) { - return; - } - - final JsonArray users = new JsonArray(); - - for (int i = 0; i < discordUserIds.length; i++) { - final JsonObject user = new JsonObject(); - user.addProperty("id", discordUserIds[i]); - user.addProperty("name", discordUsernames[i]); - users.add(user); - } - - final JsonObject json = new JsonObject(); - json.add("users", users); - this.requests.post("discord/update-usernames", json); - } - public void verifyIntegration(final @NonNull IntegrationData integrationData, final @NonNull String verificationCode) throws NamelessException { JsonObject data = new JsonObject(); @@ -395,14 +263,18 @@ public void verifyIntegration(final @NonNull IntegrationData integrationData, this.requests.post("integration/verify", data); } - public WebsendAPI websend() { - return new WebsendAPI(this.requests); + public DiscordAPI discord() { + return new DiscordAPI(this); } public StoreAPI store() { return new StoreAPI(this); } + public WebsendAPI websend() { + return new WebsendAPI(this); + } + /** * Adds back dashes to a UUID string and converts it to a Java UUID object * @param uuid UUID without dashes diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index fef6f63a..95448a39 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -8,6 +8,7 @@ import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.integrations.*; +import com.namelessmc.java_api.modules.discord.DiscordUser; import com.namelessmc.java_api.modules.store.StoreUser; import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.checker.nullness.qual.NonNull; @@ -21,7 +22,6 @@ public final class NamelessUser implements LanguageEntity { - private final @NonNull NamelessAPI api; private final @NonNull RequestHandler requests; @@ -295,13 +295,6 @@ public void createReport(final @NonNull UUID reportedUuid, } } - public void discordRoles(final long@NonNull[] roleIds) throws NamelessException { - final JsonObject post = new JsonObject(); - post.addProperty("user", this.getId()); - post.add("roles", this.requests.gson().toJsonTree(roleIds)); - this.requests.post("discord/set-roles", post); - } - /** * Get announcements visible to this user * @return List of announcements visible to this user @@ -398,6 +391,10 @@ public void verify(final @NonNull String verificationCode) throws NamelessExcept this.requests.post("users/" + this.userTransformer + "/verify", body); } + public DiscordUser discord() { + return new DiscordUser(this); + } + public StoreUser store() { return new StoreUser(this); } diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 8d14dac4..5599ef42 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -49,7 +49,7 @@ public class RequestHandler { this.responseLengthLimit = responseLengthLimit; } - @NonNull Gson gson() { + public Gson gson() { return this.gson; } diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java b/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java new file mode 100644 index 00000000..3f433903 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java @@ -0,0 +1,157 @@ +package com.namelessmc.java_api.modules.discord; + +import com.google.common.base.Preconditions; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.RequestHandler; +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.net.URL; +import java.util.Map; +import java.util.Objects; + +public class DiscordAPI { + + private final RequestHandler requests; + + public DiscordAPI(NamelessAPI api) { + this.requests = api.requests(); + } + + /** + * Set Discord bot URL (Nameless-Link internal webserver) + * @param url Discord bot URL + * @see #updateBotSettings(URL, long, String, long) + */ + public void updateBotUrl(final @NonNull URL url) throws NamelessException { + Objects.requireNonNull(url, "Bot url is null"); + + final JsonObject json = new JsonObject(); + json.addProperty("url", url.toString()); + this.requests.post("discord/update-bot-settings", json); + } + + /** + * Set discord bot username and user id + * @param username Bot username#tag + * @param userId Bot user id + * @see #updateBotSettings(URL, long, String, long) + */ + public void updateBotUser(final @NonNull String username, final long userId) throws NamelessException { + Objects.requireNonNull(username, "Bot username is null"); + + final JsonObject json = new JsonObject(); + json.addProperty("bot_username", username); + json.addProperty("bot_user_id", userId + ""); + this.requests.post("discord/update-bot-settings", json); + } + + /** + * Set Discord guild (server) id + * @param guildId Discord guild (server) id + * @see #updateBotSettings(URL, long, String, long) + */ + public void updateGuildId(final long guildId) throws NamelessException { + final JsonObject json = new JsonObject(); + json.addProperty("guild_id", guildId + ""); + this.requests.post("discord/update-bot-settings", json); + } + + /** + * Update all Discord bot settings. + * @param url Discord bot URL + * @param guildId Discord guild (server) id + * @param username Discord bot username#tag + * @param userId Discord bot user id + * @see #updateBotUrl(URL) + * @see #updateGuildId(long) + * @see #updateBotUser(String, long) + */ + public void updateBotSettings(final @NonNull URL url, + final long guildId, + final @NonNull String username, + final long userId) throws NamelessException { + Objects.requireNonNull(url, "Bot url is null"); + Objects.requireNonNull(username, "Bot username is null"); + + final JsonObject json = new JsonObject(); + json.addProperty("url", url.toString()); + json.addProperty("guild_id", guildId + ""); + json.addProperty("bot_username", username); + json.addProperty("bot_user_id", userId + ""); + this.requests.post("discord/update-bot-settings", json); + } + + /** + * Update Discord username for a NamelessMC user associated with the provided Discord user id + * @param discordUserId Discord user id + * @param discordUsername New Discord [username#tag]s + * @see #updateDiscordUsernames(long[], String[]) + */ + public void updateDiscordUsername(final long discordUserId, + final @NonNull String discordUsername) + throws NamelessException { + Objects.requireNonNull(discordUsername, "Discord username is null"); + + final JsonObject user = new JsonObject(); + user.addProperty("id", discordUserId); + user.addProperty("name", discordUsername); + final JsonArray users = new JsonArray(); + users.add(user); + final JsonObject json = new JsonObject(); + json.add("users", users); + this.requests.post("discord/update-usernames", json); + } + + /** + * Update Discord usernames in bulk + * @param discordUserIds Discord user ids + * @param discordUsernames New Discord [username#tag]s + * @see #updateDiscordUsername(long, String) + */ + public void updateDiscordUsernames(final long@NonNull[] discordUserIds, + final @NonNull String@NonNull[] discordUsernames) + throws NamelessException { + Objects.requireNonNull(discordUserIds, "User ids array is null"); + Objects.requireNonNull(discordUsernames, "Usernames array is null"); + Preconditions.checkArgument(discordUserIds.length == discordUsernames.length, + "discord user ids and discord usernames must be of same length"); + + if (discordUserIds.length == 0) { + return; + } + + final JsonArray users = new JsonArray(); + + for (int i = 0; i < discordUserIds.length; i++) { + final JsonObject user = new JsonObject(); + user.addProperty("id", discordUserIds[i]); + user.addProperty("name", discordUsernames[i]); + users.add(user); + } + + final JsonObject json = new JsonObject(); + json.add("users", users); + this.requests.post("discord/update-usernames", json); + } + + /** + * Send list of Discord roles to the website for populating the dropdown in StaffCP > API > Group sync + * @param discordRoles Map of Discord roles, key is role id, value is role name + */ + public void updateRoleList(final @NonNull Map discordRoles) throws NamelessException { + final JsonArray roles = new JsonArray(); + discordRoles.forEach((id, name) -> { + final JsonObject role = new JsonObject(); + role.addProperty("id", id); + role.addProperty("name", name); + roles.add(role); + }); + final JsonObject json = new JsonObject(); + json.add("roles", roles); + this.requests.post("discord/submit-role-list", json); + } + +} diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java new file mode 100644 index 00000000..c694dff9 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java @@ -0,0 +1,26 @@ +package com.namelessmc.java_api.modules.discord; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.NamelessUser; +import com.namelessmc.java_api.RequestHandler; +import org.checkerframework.checker.nullness.qual.NonNull; + +public class DiscordUser { + + private final NamelessUser user; + private final RequestHandler requests; + + public DiscordUser(NamelessUser user) { + this.user = user; + this.requests = user.api().requests(); + } + + public void updateDiscordRoles(final long@NonNull [] roleIds) throws NamelessException { + final JsonObject post = new JsonObject(); + post.addProperty("user", this.user.getId()); + post.add("roles", this.requests.gson().toJsonTree(roleIds)); + this.requests.post("discord/set-roles", post); + } + +} diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java index 8dfe08e3..e764079f 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java @@ -3,6 +3,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; import com.namelessmc.java_api.NamelessException; import com.namelessmc.java_api.RequestHandler; import org.checkerframework.checker.nullness.qual.NonNull; @@ -11,10 +12,10 @@ public class WebsendAPI { - private final @NonNull RequestHandler requests; + private final RequestHandler requests; - public WebsendAPI(@NonNull RequestHandler requests) { - this.requests = Objects.requireNonNull(requests, "Request handler is null"); + public WebsendAPI(final NamelessAPI api) { + this.requests = api.requests(); } public @NonNull List commands(int serverId) throws NamelessException { From 5efdc5bec9c076101817220d5fa90124157e0e26 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 11 Jun 2022 17:01:17 +0200 Subject: [PATCH 072/269] Cache website info --- src/com/namelessmc/java_api/NamelessAPI.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index ef97501a..08e384e8 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -26,6 +26,10 @@ public final class NamelessAPI { private final @NonNull URL apiUrl; private final @NonNull String apiKey; + private static final long CACHED_WEBSITE_INFO_VALIDITY = 60_000; + private @Nullable Website cachedWebsiteInfo = null; + private long cachedWebsiteInfoTime = 0; + NamelessAPI(final @NonNull RequestHandler requests, final @NonNull URL apiUrl, final @NonNull String apiKey) { @@ -81,8 +85,16 @@ public void submitServerInfo(final @NonNull JsonObject jsonData) throws Nameless * @return {@link Website} object containing website information */ public Website website() throws NamelessException { + if (this.cachedWebsiteInfoTime + CACHED_WEBSITE_INFO_VALIDITY > System.currentTimeMillis() && + this.cachedWebsiteInfo != null) { + return this.cachedWebsiteInfo; + } + final JsonObject json = this.requests.get("info"); - return new Website(json); + final Website website = new Website(json); + this.cachedWebsiteInfo = website; + this.cachedWebsiteInfoTime = System.currentTimeMillis(); + return website; } public FilteredUserListBuilder users() { From 7c07ea2bb9a74e9f7dd9f63dd4b13417d97bc057 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 11 Jun 2022 17:11:36 +0200 Subject: [PATCH 073/269] Build all at once in build() --- .../java_api/NamelessApiBuilder.java | 93 +++++++++---------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 40b90bed..e6299079 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -13,21 +13,21 @@ import java.net.ProxySelector; import java.net.URL; import java.time.Duration; -import java.util.concurrent.Executor; +import java.util.Objects; public class NamelessApiBuilder { - private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(5); - private static final String DEFAULT_USER_AGENT = "Nameless-Java-API"; - private static final int DEFAULT_RESPONSE_SIZE_LIMIT = 32*1024*1024; - private final @NonNull URL apiUrl; private final @NonNull String apiKey; - private final @NonNull GsonBuilder gsonBuilder; + private Duration timeout = Duration.ofSeconds(10); + private int responseSizeLimit = 32*1024*1024; + private String userAgent = "Nameless-Java-API"; private @Nullable ApiLogger debugLogger = null; - private final Methanol.@NonNull Builder httpClientBuilder; - private int responseSizeLimit = DEFAULT_RESPONSE_SIZE_LIMIT; + private @Nullable ProxySelector proxy = null; + private @Nullable Authenticator authenticator = null; + + private boolean pettyJsonRequests = false; NamelessApiBuilder(final @NonNull URL apiUrl, final @NonNull String apiKey) { @@ -37,67 +37,45 @@ public class NamelessApiBuilder { throw new RuntimeException(e); } this.apiKey = apiKey; - - this.gsonBuilder = new GsonBuilder(); - this.gsonBuilder.disableHtmlEscaping(); - - this.httpClientBuilder = Methanol.newBuilder() - .defaultHeader("Authorization", "Bearer " + this.apiKey) - .userAgent(DEFAULT_USER_AGENT) - .autoAcceptEncoding(true); - this.timeout(DEFAULT_TIMEOUT); } - public @NonNull NamelessApiBuilder userAgent(final @NonNull String userAgent) { - this.httpClientBuilder.userAgent(userAgent); + public NamelessApiBuilder userAgent(final String userAgent) { + this.userAgent = userAgent; return this; } - @Deprecated - public @NonNull NamelessApiBuilder debug(final boolean debug) { - if (debug) { - return this.stdErrDebugLogger(); - } else { - this.debugLogger = null; - return this; - } - } - - public @NonNull NamelessApiBuilder stdErrDebugLogger() { + public NamelessApiBuilder stdErrDebugLogger() { this.debugLogger = PrintStreamLogger.DEFAULT_INSTANCE; return this; } - public @NonNull NamelessApiBuilder slf4jDebugLogger() { + public NamelessApiBuilder slf4jDebugLogger() { this.debugLogger = Slf4jLogger.DEFAULT_INSTANCE; return this; } - public @NonNull NamelessApiBuilder customDebugLogger(final @Nullable ApiLogger debugLogger) { + public NamelessApiBuilder customDebugLogger(final @Nullable ApiLogger debugLogger) { this.debugLogger = debugLogger; return this; } - public @NonNull NamelessApiBuilder timeout(final @NonNull Duration timeout) { - this.httpClientBuilder.readTimeout(timeout) - .requestTimeout(timeout) - .connectTimeout(timeout) - .headersTimeout(timeout); + public NamelessApiBuilder timeout(final Duration timeout) { + this.timeout = Objects.requireNonNull(timeout); return this; } - public @NonNull NamelessApiBuilder withProxy(final ProxySelector proxy) { - this.httpClientBuilder.proxy(proxy); + public NamelessApiBuilder withProxy(final @Nullable ProxySelector proxy) { + this.proxy = proxy; return this; } - public @NonNull NamelessApiBuilder authenticator(final Authenticator authenticator) { - this.httpClientBuilder.authenticator(authenticator); + public NamelessApiBuilder authenticator(final @Nullable Authenticator authenticator) { + this.authenticator = authenticator; return this; } public @NonNull NamelessApiBuilder pettyJsonRequests() { - gsonBuilder.setPrettyPrinting(); + this.pettyJsonRequests = true; return this; } @@ -106,17 +84,34 @@ public class NamelessApiBuilder { return this; } - public @NonNull NamelessApiBuilder executor(final @NonNull Executor executor) { - this.httpClientBuilder.executor(executor); - return this; - } - public @NonNull NamelessAPI build() { + final Methanol.Builder methanolBuilder = Methanol.newBuilder() + .defaultHeader("Authorization", "Bearer " + this.apiKey) + .userAgent(this.userAgent) + .autoAcceptEncoding(true) + .readTimeout(this.timeout) + .requestTimeout(this.timeout) + .connectTimeout(this.timeout) + .headersTimeout(this.timeout); + if (this.proxy != null) { + methanolBuilder.proxy(this.proxy); + } + if (this.authenticator != null) { + methanolBuilder.authenticator(this.authenticator); + } + + GsonBuilder gsonBuilder = new GsonBuilder() + .disableHtmlEscaping(); + + if (this.pettyJsonRequests) { + gsonBuilder.setPrettyPrinting(); + } + return new NamelessAPI( new RequestHandler( this.apiUrl, - this.httpClientBuilder.build(), - this.gsonBuilder.create(), + methanolBuilder.build(), + gsonBuilder.create(), this.debugLogger, this.responseSizeLimit ), From e7b1b6ae725121e3b549b5185605254f8b77bc57 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 11 Jun 2022 17:13:35 +0200 Subject: [PATCH 074/269] Store modules as set for faster contains() --- src/com/namelessmc/java_api/Website.java | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 65d63bac..c1da2cad 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -2,22 +2,20 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.StreamSupport; public class Website implements LanguageEntity { - private final @NonNull String version; + private final String version; private final @Nullable Update update; - private final @NonNull String@NonNull[] modules; - private final @NonNull String rawLanguage; - - Website(final @NonNull JsonObject json) throws NamelessException { - Objects.requireNonNull(json, "Provided json object is null"); + private final Set modules; + private final String rawLanguage; + Website(final JsonObject json) throws NamelessException { if (!json.has("nameless_version")) { // This is usually the point where people run into issues if the response is not from NamelessMC // but from something else like a proxy or denial of service protection system, so we throw a useful @@ -29,7 +27,7 @@ public class Website implements LanguageEntity { this.modules = StreamSupport.stream(json.get("modules").getAsJsonArray().spliterator(), false) .map(JsonElement::getAsString) - .toArray(String[]::new); + .collect(Collectors.toUnmodifiableSet()); if (json.has("version_update")) { final JsonObject updateJson = json.get("version_update").getAsJsonObject(); @@ -48,7 +46,7 @@ public class Website implements LanguageEntity { this.rawLanguage = json.get("locale").getAsString(); } - public @NonNull String rawVersion() { + public String rawVersion() { return this.version; } @@ -63,12 +61,12 @@ public class Website implements LanguageEntity { return this.update; } - public @NonNull String@NonNull [] getModules() { + public Set modules() { return this.modules; } @Override - public @NonNull String rawLocale() throws NamelessException { + public String rawLocale() throws NamelessException { return this.rawLanguage; } From 876e4893ec5703ac4f5b432e2671493e0cbfee99 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 11 Jun 2022 17:22:26 +0200 Subject: [PATCH 075/269] Check if module is installed To prevent confusing invalid API method error --- .../java_api/FilteredUserListBuilder.java | 1 + .../namelessmc/java_api/LanguageEntity.java | 1 + src/com/namelessmc/java_api/NamelessAPI.java | 19 ++++++++++++++++--- src/com/namelessmc/java_api/NamelessUser.java | 5 +++-- .../namelessmc/java_api/RequestHandler.java | 1 + src/com/namelessmc/java_api/Website.java | 1 + .../java_api/exception/ApiException.java | 1 - .../exception/MissingModuleException.java | 11 +++++++++++ .../{ => exception}/NamelessException.java | 4 ++-- .../java_api/modules/ModuleNames.java | 17 +++++++++++++++++ .../java_api/modules/discord/DiscordAPI.java | 6 ++++-- .../java_api/modules/discord/DiscordUser.java | 6 ++++-- .../java_api/modules/store/StoreAPI.java | 6 ++++-- .../java_api/modules/store/StoreCustomer.java | 2 +- .../java_api/modules/store/StoreUser.java | 6 ++++-- .../java_api/modules/websend/WebsendAPI.java | 6 ++++-- 16 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 src/com/namelessmc/java_api/exception/MissingModuleException.java rename src/com/namelessmc/java_api/{ => exception}/NamelessException.java (83%) create mode 100644 src/com/namelessmc/java_api/modules/ModuleNames.java diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index ecb2e4e2..054d8ad8 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -3,6 +3,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.namelessmc.java_api.exception.NamelessException; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/src/com/namelessmc/java_api/LanguageEntity.java b/src/com/namelessmc/java_api/LanguageEntity.java index a0d92529..806af76f 100644 --- a/src/com/namelessmc/java_api/LanguageEntity.java +++ b/src/com/namelessmc/java_api/LanguageEntity.java @@ -1,5 +1,6 @@ package com.namelessmc.java_api; +import com.namelessmc.java_api.exception.NamelessException; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Locale; diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 08e384e8..96e15a18 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -5,6 +5,8 @@ import com.google.gson.JsonObject; import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; +import com.namelessmc.java_api.exception.MissingModuleException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.integrations.IntegrationData; import com.namelessmc.java_api.modules.discord.DiscordAPI; import com.namelessmc.java_api.modules.store.StoreAPI; @@ -275,15 +277,26 @@ public void verifyIntegration(final @NonNull IntegrationData integrationData, this.requests.post("integration/verify", data); } - public DiscordAPI discord() { + /** + * Ensures the given module is installed, throwing {@link MissingModuleException} if missing. + * @param moduleName Module name to check + * @see com.namelessmc.java_api.modules.ModuleNames + */ + public void ensureModuleInstalled(String moduleName) throws NamelessException { + if (!this.website().modules().contains(moduleName)) { + throw new MissingModuleException(moduleName); + } + } + + public DiscordAPI discord() throws NamelessException { return new DiscordAPI(this); } - public StoreAPI store() { + public StoreAPI store() throws NamelessException { return new StoreAPI(this); } - public WebsendAPI websend() { + public WebsendAPI websend() throws NamelessException { return new WebsendAPI(this); } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 95448a39..4fe1aac5 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -7,6 +7,7 @@ import com.namelessmc.java_api.Notification.Type; import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.integrations.*; import com.namelessmc.java_api.modules.discord.DiscordUser; import com.namelessmc.java_api.modules.store.StoreUser; @@ -391,11 +392,11 @@ public void verify(final @NonNull String verificationCode) throws NamelessExcept this.requests.post("users/" + this.userTransformer + "/verify", body); } - public DiscordUser discord() { + public DiscordUser discord() throws NamelessException { return new DiscordUser(this); } - public StoreUser store() { + public StoreUser store() throws NamelessException { return new StoreUser(this); } diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 5599ef42..25112129 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -11,6 +11,7 @@ import com.google.gson.JsonSyntaxException; import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.logger.ApiLogger; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index c1da2cad..b143463b 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -2,6 +2,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.namelessmc.java_api.exception.NamelessException; import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Set; diff --git a/src/com/namelessmc/java_api/exception/ApiException.java b/src/com/namelessmc/java_api/exception/ApiException.java index acb49c18..c33514c5 100644 --- a/src/com/namelessmc/java_api/exception/ApiException.java +++ b/src/com/namelessmc/java_api/exception/ApiException.java @@ -1,6 +1,5 @@ package com.namelessmc.java_api.exception; -import com.namelessmc.java_api.NamelessException; import org.checkerframework.checker.nullness.qual.Nullable; public class ApiException extends NamelessException { diff --git a/src/com/namelessmc/java_api/exception/MissingModuleException.java b/src/com/namelessmc/java_api/exception/MissingModuleException.java new file mode 100644 index 00000000..4121b085 --- /dev/null +++ b/src/com/namelessmc/java_api/exception/MissingModuleException.java @@ -0,0 +1,11 @@ +package com.namelessmc.java_api.exception; + +public class MissingModuleException extends NamelessException { + + private static final long serialVersionUID = 1L; + + public MissingModuleException(final String moduleName) { + super("Required module not installed: " + moduleName); + } + +} diff --git a/src/com/namelessmc/java_api/NamelessException.java b/src/com/namelessmc/java_api/exception/NamelessException.java similarity index 83% rename from src/com/namelessmc/java_api/NamelessException.java rename to src/com/namelessmc/java_api/exception/NamelessException.java index 7f7c6ad4..bc588a71 100644 --- a/src/com/namelessmc/java_api/NamelessException.java +++ b/src/com/namelessmc/java_api/exception/NamelessException.java @@ -1,4 +1,4 @@ -package com.namelessmc.java_api; +package com.namelessmc.java_api.exception; import org.checkerframework.checker.nullness.qual.NonNull; @@ -7,7 +7,7 @@ */ public class NamelessException extends Exception { - private static final long serialVersionUID = -3698433855091611529L; + private static final long serialVersionUID = 1L; public NamelessException(final @NonNull String message) { super(message); diff --git a/src/com/namelessmc/java_api/modules/ModuleNames.java b/src/com/namelessmc/java_api/modules/ModuleNames.java new file mode 100644 index 00000000..d88ca1a4 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/ModuleNames.java @@ -0,0 +1,17 @@ +package com.namelessmc.java_api.modules; + +public class ModuleNames { + + // Official modules + + public static final String CORE = "Core"; + public static final String FORUM = "Forum"; + public static final String DISCORD_INTEGRATION = "Discord Integration"; + public static final String COOKIE_CONSENT = "Cookie Consent"; + + // Third party modules + + public static final String STORE = "Store"; + public static final String WEBSEND = "Websend"; + +} diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java b/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java index 3f433903..e1a3e7f2 100644 --- a/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java +++ b/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java @@ -4,8 +4,9 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.RequestHandler; +import com.namelessmc.java_api.modules.ModuleNames; import org.checkerframework.checker.nullness.qual.NonNull; import java.net.URL; @@ -16,8 +17,9 @@ public class DiscordAPI { private final RequestHandler requests; - public DiscordAPI(NamelessAPI api) { + public DiscordAPI(NamelessAPI api) throws NamelessException { this.requests = api.requests(); + api.ensureModuleInstalled(ModuleNames.DISCORD_INTEGRATION); } /** diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java index c694dff9..ea39badf 100644 --- a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java +++ b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java @@ -1,9 +1,10 @@ package com.namelessmc.java_api.modules.discord; import com.google.gson.JsonObject; -import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.NamelessUser; import com.namelessmc.java_api.RequestHandler; +import com.namelessmc.java_api.modules.ModuleNames; import org.checkerframework.checker.nullness.qual.NonNull; public class DiscordUser { @@ -11,9 +12,10 @@ public class DiscordUser { private final NamelessUser user; private final RequestHandler requests; - public DiscordUser(NamelessUser user) { + public DiscordUser(NamelessUser user) throws NamelessException { this.user = user; this.requests = user.api().requests(); + user.api().ensureModuleInstalled(ModuleNames.DISCORD_INTEGRATION); } public void updateDiscordRoles(final long@NonNull [] roleIds) throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index e3aa8e79..736f5f79 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -4,8 +4,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.RequestHandler; +import com.namelessmc.java_api.modules.ModuleNames; import java.util.ArrayList; import java.util.Collection; @@ -17,9 +18,10 @@ public class StoreAPI { private final NamelessAPI api; private final RequestHandler requests; - public StoreAPI(NamelessAPI api) { + public StoreAPI(final NamelessAPI api) throws NamelessException { this.api = api; this.requests = api.requests(); + this.api.ensureModuleInstalled(ModuleNames.STORE); } public List products() throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java index 31495d90..931da043 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java +++ b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java @@ -2,7 +2,7 @@ import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.NamelessUser; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index f6f9bad5..a17e5672 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -1,18 +1,20 @@ package com.namelessmc.java_api.modules.store; import com.google.gson.JsonObject; -import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.NamelessUser; import com.namelessmc.java_api.RequestHandler; +import com.namelessmc.java_api.modules.ModuleNames; public class StoreUser { private final NamelessUser user; private final RequestHandler requests; - public StoreUser(NamelessUser user) { + public StoreUser(NamelessUser user) throws NamelessException { this.user = user; this.requests = user.api().requests(); + user.api().ensureModuleInstalled(ModuleNames.STORE); } public void addCredits(float creditsToAdd) throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java index e764079f..522c9716 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java @@ -4,8 +4,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.NamelessException; +import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.RequestHandler; +import com.namelessmc.java_api.modules.ModuleNames; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.*; @@ -14,8 +15,9 @@ public class WebsendAPI { private final RequestHandler requests; - public WebsendAPI(final NamelessAPI api) { + public WebsendAPI(final NamelessAPI api) throws NamelessException { this.requests = api.requests(); + api.ensureModuleInstalled(ModuleNames.WEBSEND); } public @NonNull List commands(int serverId) throws NamelessException { From c13ef2454783def919f5634f0a61e20fbe20b682 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 12 Jun 2022 12:09:35 +0200 Subject: [PATCH 076/269] Attempt to fix filter builder --- .../java_api/FilteredUserListBuilder.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index 054d8ad8..00e9aac4 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -25,7 +25,10 @@ public class FilteredUserListBuilder { filters = new HashMap<>(); } - filters.put(filter, value); + filters.put( + Objects.requireNonNull(filter, "Filter is null"), + Objects.requireNonNull(value, "Value for filter " + filter.name() + " is null") + ); return this; } @@ -46,11 +49,10 @@ public JsonObject makeRawRequest() throws NamelessException { parameters = new Object[filterCount * 2 + 2]; parameters[0] = "operator"; parameters[1] = operator; - Iterator, Object>> iterator = filters.entrySet().iterator(); - for (int i = 1; i < filterCount; i++) { - Map.Entry, Object> entry = iterator.next(); - parameters[i*2] = entry.getKey().name(); - parameters[i*2+1] = entry.getValue(); + int i = 2; + for (Map.Entry, Object> filter : this.filters.entrySet()) { + parameters[i++] = filter.getKey().name(); + parameters[i++] = filter.getValue(); } } else { parameters = new Object[0]; From 91b9202417b4e734d795337da51ee0286920086b Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 12 Jun 2022 21:50:23 +0200 Subject: [PATCH 077/269] Check if locale is null and print helpful message --- src/com/namelessmc/java_api/Website.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index b143463b..68281d73 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -44,6 +44,10 @@ public class Website implements LanguageEntity { this.update = null; } + if (json.get("locale").isJsonNull()) { + throw new NamelessException("Website returned null locale. This can happen if you upgraded from v2-pr12 to v2-pr13, please try switching the site's language to something else and back."); + } + this.rawLanguage = json.get("locale").getAsString(); } From 17ab7269ccd56c7e1e53516a600e9f0adb89c3f4 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 12 Jun 2022 22:23:39 +0200 Subject: [PATCH 078/269] Add suggestions module API --- src/com/namelessmc/java_api/NamelessAPI.java | 10 ++- src/com/namelessmc/java_api/NamelessUser.java | 8 +- .../java_api/modules/ModuleNames.java | 1 + .../java_api/modules/discord/DiscordUser.java | 2 +- .../modules/suggestions/Suggestion.java | 86 +++++++++++++++++++ .../suggestions/SuggestionCategory.java | 23 +++++ .../modules/suggestions/SuggestionStatus.java | 29 +++++++ .../modules/suggestions/SuggestionUser.java | 34 ++++++++ .../modules/suggestions/SuggestionsAPI.java | 25 ++++++ .../modules/suggestions/SuggestionsUser.java | 67 +++++++++++++++ 10 files changed, 279 insertions(+), 6 deletions(-) create mode 100644 src/com/namelessmc/java_api/modules/suggestions/Suggestion.java create mode 100644 src/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java create mode 100644 src/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java create mode 100644 src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java create mode 100644 src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java create mode 100644 src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 96e15a18..b512e155 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -10,13 +10,17 @@ import com.namelessmc.java_api.integrations.IntegrationData; import com.namelessmc.java_api.modules.discord.DiscordAPI; import com.namelessmc.java_api.modules.store.StoreAPI; +import com.namelessmc.java_api.modules.suggestions.SuggestionsAPI; import com.namelessmc.java_api.modules.websend.WebsendAPI; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import java.math.BigInteger; import java.net.URL; -import java.util.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -296,6 +300,10 @@ public StoreAPI store() throws NamelessException { return new StoreAPI(this); } + public SuggestionsAPI suggestions() throws NamelessException { + return new SuggestionsAPI(this); + } + public WebsendAPI websend() throws NamelessException { return new WebsendAPI(this); } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 4fe1aac5..ec2fc0d9 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -97,7 +97,7 @@ public String userTransformer() { return this.userTransformer; } - public int getId() throws NamelessException { + public int id() throws NamelessException { if (this.id == -1) { this.id = this.userInfo().get("id").getAsInt(); } @@ -251,8 +251,8 @@ public void createReport(final @NonNull NamelessUser user, final @NonNull String Preconditions.checkArgument(reason.length() < 255, "Report reason too long, it's %s characters but must be less than 255", reason.length()); final JsonObject post = new JsonObject(); - post.addProperty("reporter", this.getId()); - post.addProperty("reported", user.getId()); + post.addProperty("reporter", this.id()); + post.addProperty("reported", user.id()); post.addProperty("content", reason); try { this.requests.post("reports/create", post); @@ -281,7 +281,7 @@ public void createReport(final @NonNull UUID reportedUuid, Preconditions.checkArgument(reason.length() < 255, "Report reason too long, it's %s characters but must be less than 255", reason.length()); final JsonObject post = new JsonObject(); - post.addProperty("reporter", this.getId()); + post.addProperty("reporter", this.id()); post.addProperty("reported_uid", reportedUuid.toString()); post.addProperty("reported_username", reportedName); post.addProperty("content", reason); diff --git a/src/com/namelessmc/java_api/modules/ModuleNames.java b/src/com/namelessmc/java_api/modules/ModuleNames.java index d88ca1a4..b46a7a16 100644 --- a/src/com/namelessmc/java_api/modules/ModuleNames.java +++ b/src/com/namelessmc/java_api/modules/ModuleNames.java @@ -13,5 +13,6 @@ public class ModuleNames { public static final String STORE = "Store"; public static final String WEBSEND = "Websend"; + public static final String SUGGESTIONS = "Suggestions"; } diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java index ea39badf..7cf56e37 100644 --- a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java +++ b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java @@ -20,7 +20,7 @@ public DiscordUser(NamelessUser user) throws NamelessException { public void updateDiscordRoles(final long@NonNull [] roleIds) throws NamelessException { final JsonObject post = new JsonObject(); - post.addProperty("user", this.user.getId()); + post.addProperty("user", this.user.id()); post.add("roles", this.requests.gson().toJsonTree(roleIds)); this.requests.post("discord/set-roles", post); } diff --git a/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java b/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java new file mode 100644 index 00000000..fa0339b4 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java @@ -0,0 +1,86 @@ +package com.namelessmc.java_api.modules.suggestions; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; + +import java.util.Date; + +public class Suggestion { + + private final int id; + private final SuggestionUser author; + private final SuggestionUser updatedBy; + private final SuggestionStatus status; + private final SuggestionCategory category; + private final String title; + private final String content; + private final int views; + private final Date createdTime; + private final Date lastUpdatedTime; + private final int likeCount; + private final int dislikeCount; + + Suggestion(final NamelessAPI api, final JsonObject json) { + this.id = json.get("id").getAsInt(); + this.author = new SuggestionUser(api, json.getAsJsonObject("author")); + this.updatedBy = new SuggestionUser(api, json.getAsJsonObject("updated_by")); + this.status = new SuggestionStatus(json.getAsJsonObject("status")); + this.category = new SuggestionCategory(json.getAsJsonObject("category")); + this.title = json.get("title").getAsString(); + this.content = json.get("content").getAsString(); + this.views = json.get("views").getAsInt(); + this.createdTime = new Date(json.get("created").getAsLong() * 1000); + this.lastUpdatedTime = new Date(json.get("last_updated").getAsLong() * 1000); + this.likeCount = json.get("likes_count").getAsInt(); + this.dislikeCount = json.get("dislikes_count").getAsInt(); + } + + public int id() { + return this.id; + } + + public SuggestionUser author() { + return this.author; + } + + public SuggestionUser updatedBy() { + return this.updatedBy; + } + + public SuggestionStatus status() { + return this.status; + } + + public SuggestionCategory category() { + return this.category; + } + + public String title() { + return this.title; + } + + public String content() { + return this.content; + } + + public int views() { + return this.views; + } + + public Date createdTime() { + return this.createdTime; + } + + public Date lastUpdatedTime() { + return this.lastUpdatedTime; + } + + public int likeCount() { + return this.likeCount; + } + + public int dislikeCount() { + return this.dislikeCount; + } + +} diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java new file mode 100644 index 00000000..b62269fc --- /dev/null +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java @@ -0,0 +1,23 @@ +package com.namelessmc.java_api.modules.suggestions; + +import com.google.gson.JsonObject; + +public class SuggestionCategory { + + private final int id; + private final String name; + + SuggestionCategory(final JsonObject json) { + this.id = json.get("id").getAsInt(); + this.name = json.get("name").getAsString(); + } + + public int id() { + return this.id; + } + + public String name() { + return this.name; + } + +} diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java new file mode 100644 index 00000000..7d0c5231 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java @@ -0,0 +1,29 @@ +package com.namelessmc.java_api.modules.suggestions; + +import com.google.gson.JsonObject; + +public class SuggestionStatus { + + private final int id; + private final String name; + private final boolean open; + + SuggestionStatus(JsonObject json) { + this.id = json.get("id").getAsInt(); + this.name = json.get("name").getAsString(); + this.open = json.get("open").getAsBoolean(); + } + + public int id() { + return this.id; + } + + public String name() { + return this.name; + } + + public boolean isOpen() { + return this.open; + } + +} diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java new file mode 100644 index 00000000..5dcbba88 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java @@ -0,0 +1,34 @@ +package com.namelessmc.java_api.modules.suggestions; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.NamelessUser; +import com.namelessmc.java_api.exception.NamelessException; + +public class SuggestionUser { + + private final NamelessAPI api; + + private final int id; + private final String username; + + SuggestionUser(final NamelessAPI api, final JsonObject json) { + this.api = api; + + this.id = json.get("id").getAsInt(); + this.username = json.get("username").getAsString(); + } + + public int userId() { + return this.id; + } + + public NamelessUser user() throws NamelessException { + return this.api.user(this.id); + } + + public String username() { + return username; + } + +} diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java new file mode 100644 index 00000000..78a707b8 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java @@ -0,0 +1,25 @@ +package com.namelessmc.java_api.modules.suggestions; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.RequestHandler; +import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.ModuleNames; + +public class SuggestionsAPI { + + private final NamelessAPI api; + private final RequestHandler requests; + + public SuggestionsAPI(final NamelessAPI api) throws NamelessException { + this.api = api; + this.requests = api.requests(); + api.ensureModuleInstalled(ModuleNames.SUGGESTIONS); + } + + public Suggestion suggestion(int suggestionId) throws NamelessException { + final JsonObject response = this.requests.get("suggestions/" + suggestionId); + return new Suggestion(this.api, response); + } + +} diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java new file mode 100644 index 00000000..0c77ae9b --- /dev/null +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java @@ -0,0 +1,67 @@ +package com.namelessmc.java_api.modules.suggestions; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.NamelessUser; +import com.namelessmc.java_api.RequestHandler; +import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.ModuleNames; + +import java.util.Objects; + +public class SuggestionsUser { + + private final NamelessUser user; + private final NamelessAPI api; + private final RequestHandler requests; + + public SuggestionsUser(final NamelessUser user) throws NamelessException { + this.user = user; + this.api = this.user.api(); + this.requests = this.api.requests(); + + this.api.ensureModuleInstalled(ModuleNames.SUGGESTIONS); + } + + public void like(final int suggestionId) throws NamelessException { + JsonObject body = new JsonObject(); + body.addProperty("user", this.user.userTransformer()); + this.requests.post("suggestions/like", body); + } + + public void like(final Suggestion suggestion) throws NamelessException { + this.like(suggestion.id()); + } + + public void dislike(final int suggestionId) throws NamelessException { + final JsonObject body = new JsonObject(); + body.addProperty("user", this.user.userTransformer()); + this.requests.post("suggestions/dislike", body); + } + + public void dislike(final Suggestion suggestion) throws NamelessException { + this.dislike(suggestion.id()); + } + + public Suggestion createSuggestion(final String title, final String content, final int categoryId) throws NamelessException { + final JsonObject body = new JsonObject(); + body.addProperty("user", this.user.userTransformer()); + body.addProperty("title", Objects.requireNonNull(title, "title is null")); + body.addProperty("content", Objects.requireNonNull(content, "content is null")); + if (categoryId > 0) { + body.addProperty("category", categoryId); + } + final JsonObject response = this.requests.post("suggestions/create", body); + final int suggestionId = response.get("id").getAsInt(); + return this.api.suggestions().suggestion(suggestionId); + } + + public Suggestion createSuggestion(final String title, final String content) throws NamelessException { + return this.createSuggestion(title, content, -1); + } + + public Suggestion createSuggestion(final String title, final String content, final SuggestionCategory category) throws NamelessException { + return this.createSuggestion(title, content, category.id()); + } + +} From 6a1e0e4c4267133db827b0d5e03bd2ee029afc84 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 12 Jun 2022 22:26:12 +0200 Subject: [PATCH 079/269] Add suggestions() to user --- src/com/namelessmc/java_api/NamelessUser.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index ec2fc0d9..9dc898ca 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -11,6 +11,7 @@ import com.namelessmc.java_api.integrations.*; import com.namelessmc.java_api.modules.discord.DiscordUser; import com.namelessmc.java_api.modules.store.StoreUser; +import com.namelessmc.java_api.modules.suggestions.SuggestionsUser; import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -400,4 +401,8 @@ public StoreUser store() throws NamelessException { return new StoreUser(this); } + public SuggestionsUser suggestions() throws NamelessException { + return new SuggestionsUser(this); + } + } From 94d08b727be30fcfb16804abc03e60784469c314 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Jun 2022 11:10:58 +0000 Subject: [PATCH 080/269] Bump checker-qual from 3.22.1 to 3.22.2 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.22.1 to 3.22.2. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.22.1...checker-framework-3.22.2) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c737f4ee..05009911 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.22.1 + 3.22.2 From ecb6a029364e3993951ca5f793a06d8e09371ec2 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 15 Jun 2022 16:54:56 +0200 Subject: [PATCH 081/269] Fix field name --- src/com/namelessmc/java_api/modules/store/StoreCustomer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java index 931da043..9979da33 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java +++ b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java @@ -18,7 +18,7 @@ public class StoreCustomer { StoreCustomer(NamelessAPI api, JsonObject json) { this.api = api; - this.id = json.get("id").getAsInt(); + this.id = json.get("customer_id").getAsInt(); this.userId = json.has("user_id") ? json.get("user_id").getAsInt() : null; this.username = json.has("username") ? json.get("username").getAsString() : null; this.identifier = json.has("identifier") ? json.get("identifier").getAsString() : null; From 68c6a9df0f29c655e322d1b966b0f31ae03191bd Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 15 Jun 2022 21:23:25 +0200 Subject: [PATCH 082/269] Allow forcing http version --- .../namelessmc/java_api/NamelessApiBuilder.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index e6299079..4634a9c6 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -12,6 +12,7 @@ import java.net.MalformedURLException; import java.net.ProxySelector; import java.net.URL; +import java.net.http.HttpClient; import java.time.Duration; import java.util.Objects; @@ -26,6 +27,7 @@ public class NamelessApiBuilder { private @Nullable ApiLogger debugLogger = null; private @Nullable ProxySelector proxy = null; private @Nullable Authenticator authenticator = null; + private HttpClient.@Nullable Version httpVersion = null; private boolean pettyJsonRequests = false; @@ -74,17 +76,22 @@ public NamelessApiBuilder authenticator(final @Nullable Authenticator authentica return this; } - public @NonNull NamelessApiBuilder pettyJsonRequests() { + public NamelessApiBuilder pettyJsonRequests() { this.pettyJsonRequests = true; return this; } - public @NonNull NamelessApiBuilder responseSizeLimit(int responseSizeLimitBytes) { + public NamelessApiBuilder responseSizeLimit(int responseSizeLimitBytes) { this.responseSizeLimit = responseSizeLimitBytes; return this; } - public @NonNull NamelessAPI build() { + public NamelessApiBuilder httpversion(final HttpClient. @Nullable Version httpVersion) { + this.httpVersion = httpVersion; + return this; + } + + public NamelessAPI build() { final Methanol.Builder methanolBuilder = Methanol.newBuilder() .defaultHeader("Authorization", "Bearer " + this.apiKey) .userAgent(this.userAgent) @@ -99,6 +106,9 @@ public NamelessApiBuilder authenticator(final @Nullable Authenticator authentica if (this.authenticator != null) { methanolBuilder.authenticator(this.authenticator); } + if (this.httpVersion != null) { + methanolBuilder.version(this.httpVersion); + } GsonBuilder gsonBuilder = new GsonBuilder() .disableHtmlEscaping(); From b8e47b28509e8c36fdc490a165e4cdf2b723ab5f Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 18 Jun 2022 10:54:34 +0200 Subject: [PATCH 083/269] Print request time where relevant --- src/com/namelessmc/java_api/RequestHandler.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 25112129..42f12fbd 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -112,6 +112,8 @@ private void debug(final @NonNull Supplier messageSupplier) { debug(() -> "Making connection " + (postBody != null ? "POST" : "GET") + " to " + request.uri()); + final long requestStartTime = System.currentTimeMillis(); + if (postBody != null) { byte[] postBytes = gson.toJson(postBody).getBytes(StandardCharsets.UTF_8); request.POST(HttpRequest.BodyPublishers.ofByteArray(postBytes)); @@ -146,7 +148,9 @@ private void debug(final @NonNull Supplier messageSupplier) { } else if (exceptionMessage.contains("timed out")) { // All timeouts are set to the same value, so we only need to print one. long seconds = httpClient.connectTimeout().orElseThrow().getSeconds(); - message.append("\nHINT: The website responded too slow, timeout is set to ").append(seconds).append(" seconds."); + message.append("\nHINT: The website responded too slow, no response after waiting for "); + message.append((System.currentTimeMillis() - requestStartTime) / 1000); + message.append(" seconds."); } } @@ -155,7 +159,7 @@ private void debug(final @NonNull Supplier messageSupplier) { throw new RuntimeException(e); } - debug(() -> "Website response body:\n" + regularAsciiOnly(responseBody)); + debug(() -> "Website response body, after " + (System.currentTimeMillis() - requestStartTime) + "ms:\n" + regularAsciiOnly(responseBody)); if (responseBody.length() == 0) { throw new NamelessException("Website sent empty response with status code " + statusCode); @@ -183,7 +187,9 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append("HINT: The website response contains invisible unicode characters. This seems to be caused by Partydragen's Store module, we have no idea why.\n"); } - message.append("Website response:\n"); + message.append("Website response, after "); + message.append(System.currentTimeMillis() - requestStartTime); + message.append("ms:\n"); message.append("-----------------\n"); int totalLengthLimit = 1500; // fit in a Discord message String printableResponse = regularAsciiOnly(responseBody); From f85b37c44377be5d39576ed4a813d2091fe93f0c Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 25 Jun 2022 16:42:35 +0200 Subject: [PATCH 084/269] discord id is long, not int --- .../java_api/integrations/DetailedDiscordIntegrationData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java index 4f2b34dd..32923ecb 100644 --- a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java +++ b/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java @@ -9,7 +9,7 @@ public class DetailedDiscordIntegrationData extends DetailedIntegrationData impl public DetailedDiscordIntegrationData(final @NonNull JsonObject json) { super(json); - this.idLong = Integer.parseInt(this.identifier()); + this.idLong = Long.parseLong(this.identifier()); } @Override From 2078fd565ef026c7db47026b656440daa02045ce Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 27 Jun 2022 21:57:30 +0200 Subject: [PATCH 085/269] Add method to get website info if cached --- src/com/namelessmc/java_api/NamelessAPI.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index b512e155..d1436fa3 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -103,6 +103,10 @@ public Website website() throws NamelessException { return website; } + public @Nullable Website websiteIfCached() { + return this.cachedWebsiteInfo; + } + public FilteredUserListBuilder users() { return new FilteredUserListBuilder(this); } From 36eca028098ede7d282975e6be9b95d8cfedb79d Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 27 Jun 2022 22:41:21 +0200 Subject: [PATCH 086/269] suggestions module now returns full info in create request --- .../java_api/modules/suggestions/SuggestionsUser.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java index 0c77ae9b..dac8073b 100644 --- a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java @@ -52,8 +52,7 @@ public Suggestion createSuggestion(final String title, final String content, fin body.addProperty("category", categoryId); } final JsonObject response = this.requests.post("suggestions/create", body); - final int suggestionId = response.get("id").getAsInt(); - return this.api.suggestions().suggestion(suggestionId); + return new Suggestion(this.api, response); } public Suggestion createSuggestion(final String title, final String content) throws NamelessException { From 265736a21cd778d38d138575c5299dc799d9f956 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 28 Jun 2022 15:06:11 +0200 Subject: [PATCH 087/269] disable user list limit, we don't support it --- .../namelessmc/java_api/FilteredUserListBuilder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index 00e9aac4..df36895f 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -46,10 +46,12 @@ public JsonObject makeRawRequest() throws NamelessException { final Object[] parameters; if (filters != null) { int filterCount = filters.size(); - parameters = new Object[filterCount * 2 + 2]; - parameters[0] = "operator"; - parameters[1] = operator; - int i = 2; + parameters = new Object[4 + filterCount * 2]; + int i = 0; + parameters[i++] = "operator"; + parameters[i++] = operator; + parameters[i++] = "limit"; + parameters[i++] = 0; for (Map.Entry, Object> filter : this.filters.entrySet()) { parameters[i++] = filter.getKey().name(); parameters[i++] = filter.getValue(); From 327af8c7d00a4268319d7c3c00fb100a559e4d83 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 3 Jul 2022 19:03:57 +0200 Subject: [PATCH 088/269] log exception class name --- src/com/namelessmc/java_api/RequestHandler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 42f12fbd..b8bf8cdf 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -133,9 +133,11 @@ private void debug(final @NonNull Supplier messageSupplier) { responseBody = getBodyAsString(httpResponse); } catch (final IOException e) { final @Nullable String exceptionMessage = e.getMessage(); - final StringBuilder message = new StringBuilder("Network connection error (not a Nameless issue). IOException message: \""); + final StringBuilder message = new StringBuilder(); + message.append("Network connection error (not a Nameless issue). "); + message.append(e.getClass().getSimpleName()); + message.append(": "); message.append(exceptionMessage); - message.append('"'); if (exceptionMessage != null) { if (exceptionMessage.contains("unable to find valid certification path to requested target")) { message.append("\nHINT: Your HTTPS certificate is probably valid, but is it complete? Ensure your website uses a valid *full chain* SSL/TLS certificate."); From e981ce8ae1976fc18bc8848f8830f2283640e1e2 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 8 Jul 2022 22:55:00 +0200 Subject: [PATCH 089/269] Create users with cached user info --- src/com/namelessmc/java_api/FilteredUserListBuilder.java | 3 +-- src/com/namelessmc/java_api/NamelessUser.java | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index df36895f..57a46af2 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -69,8 +69,7 @@ public JsonObject makeRawRequest() throws NamelessException { final List users = new ArrayList<>(array.size()); for (final JsonElement e : array) { final JsonObject o = e.getAsJsonObject(); - final int id = o.get("id").getAsInt(); - users.add(new NamelessUser(this.api, id)); + users.add(new NamelessUser(this.api, e.getAsJsonObject())); } return Collections.unmodifiableList(users); } diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 9dc898ca..18cdd629 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -35,9 +35,7 @@ public final class NamelessUser implements LanguageEntity { private @Nullable Map _cachedIntegrationData; - NamelessUser(final @NonNull NamelessAPI api, - final @Positive int id - ) { + NamelessUser(final @NonNull NamelessAPI api, final @Positive int id) { this.api = api; this.requests = api.requests(); @@ -53,6 +51,11 @@ public final class NamelessUser implements LanguageEntity { this.userTransformer = URLEncoder.encode(userTransformer, StandardCharsets.UTF_8); } + NamelessUser(final NamelessAPI api, final JsonObject userInfo) { + this(api, userInfo.get("id").getAsInt()); + this._cachedUserInfo = userInfo; + } + @NonNull JsonObject userInfo() throws NamelessException { if (this._cachedUserInfo != null) { return this._cachedUserInfo; From 80456ccee7226c3e50c2a4f6628c84531885f098 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 9 Jul 2022 20:03:41 +0200 Subject: [PATCH 090/269] Add new integration_already_verified API error --- src/com/namelessmc/java_api/exception/ApiError.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/namelessmc/java_api/exception/ApiError.java b/src/com/namelessmc/java_api/exception/ApiError.java index 67f9660a..b707d3c2 100644 --- a/src/com/namelessmc/java_api/exception/ApiError.java +++ b/src/com/namelessmc/java_api/exception/ApiError.java @@ -35,6 +35,7 @@ public enum ApiError { CORE_INVALID_INTEGRATION("core", "invalid_integration"), CORE_INVALID_CODE("core", "invalid_code"), CORE_USER_ALREADY_ACTIVE("core", "user_already_active"), + CORE_INTEGRATION_ALREADY_VERIFIED("core", "integration_already_verified"), CORE_UNABLE_TO_UPDATE_USERNAME("core", "unable_to_update_username"), CORE_INTEGRATION_IDENTIFIER_ERROR("core", "integration_identifier_errors"), CORE_INTEGRATION_USERNAME_ERROR("core", "integration_username_errors"), From ca35d3913a2026da335759eab9b2966b82fd13c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Jul 2022 11:16:31 +0000 Subject: [PATCH 091/269] Bump checker-qual from 3.22.2 to 3.23.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.22.2 to 3.23.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.22.2...checker-framework-3.23.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05009911..0653a356 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.22.2 + 3.23.0 From da94e00d30abfce362292c4ea09421c5e5a13363 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 14 Jul 2022 19:14:34 +0200 Subject: [PATCH 092/269] Indicate that we can only handle json responses --- src/com/namelessmc/java_api/RequestHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index b8bf8cdf..5fc7d9cf 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -124,6 +124,8 @@ private void debug(final @NonNull Supplier messageSupplier) { request.GET(); } + request.header("Accept", "application/json"); + int statusCode; String responseBody; try { From e36fabe066341eb88f547c9bbd9ffa6cc7469d77 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 17 Jul 2022 23:38:51 +0200 Subject: [PATCH 093/269] Fix lookup by integration username --- src/com/namelessmc/java_api/NamelessAPI.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index d1436fa3..412516b3 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -8,6 +8,7 @@ import com.namelessmc.java_api.exception.MissingModuleException; import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.integrations.IntegrationData; +import com.namelessmc.java_api.integrations.StandardIntegrationTypes; import com.namelessmc.java_api.modules.discord.DiscordAPI; import com.namelessmc.java_api.modules.store.StoreAPI; import com.namelessmc.java_api.modules.suggestions.SuggestionsAPI; @@ -165,19 +166,27 @@ public FilteredUserListBuilder users() { } public @NonNull NamelessUser userByMinecraftUuidLazy(final @NonNull UUID uuid) { - return userLazy("integration_id:minecraft:" + javaUuidToWebsiteUuid(uuid)); + return byIntegrationIdentifierLazy(StandardIntegrationTypes.MINECRAFT, javaUuidToWebsiteUuid(uuid)); } public @NonNull NamelessUser userByMinecraftUsernameLazy(final @NonNull String username) { - return userLazy("integration_username:minecraft:" + username); + return byIntegrationUsernameLazy(StandardIntegrationTypes.MINECRAFT, username); } public @NonNull NamelessUser userByDiscordIdLazy(final long id) { - return userLazy("integration_id:discord:" + id); + return byIntegrationIdentifierLazy(StandardIntegrationTypes.DISCORD, String.valueOf(id)); } public @NonNull NamelessUser userByDiscordUsernameLazy(final @NonNull String username) { - return userLazy("integration_username:discord:" + username); + return byIntegrationUsernameLazy(StandardIntegrationTypes.DISCORD, username); + } + + public NamelessUser byIntegrationIdentifierLazy(String integrationName, String identifier) { + return userLazy("integration_id:" + integrationName + ":" + identifier); + } + + public NamelessUser byIntegrationUsernameLazy(String integrationName, String username) { + return userLazy("integration_name:" + integrationName + ":" + username); } /** From d23723f5e296ac1a8de1e93e7c5a6f53ca562163 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 22 Jul 2022 12:53:35 +0200 Subject: [PATCH 094/269] support new credits endpoint --- src/com/namelessmc/java_api/modules/store/StoreUser.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index a17e5672..7c25b8ec 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -29,4 +29,9 @@ public void removeCredits(float creditsToRemove) throws NamelessException { this.requests.post("users/" + this.user.userTransformer() + "/remove-credits", body); } + public float credits() throws NamelessException { + JsonObject response = this.requests.get("users/" + this.user.userTransformer() + "/credits"); + return response.get("credits").getAsFloat(); + } + } From b910a4d23ba319ca8f9f01e08be933ab5eb8cccc Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 24 Jul 2022 20:02:36 +0200 Subject: [PATCH 095/269] Add convenience methods for integration usernames --- src/com/namelessmc/java_api/NamelessUser.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 18cdd629..96b409a7 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -372,22 +372,23 @@ public Map integrations() throws NamelessExcept } public @Nullable UUID minecraftUuid() throws NamelessException { - final DetailedIntegrationData integration = this.integrations().get(StandardIntegrationTypes.MINECRAFT); - if (integration == null) { - return null; - } + final IntegrationData integration = this.integrations().get(StandardIntegrationTypes.MINECRAFT); + return integration == null ? null : ((IMinecraftIntegrationData) integration).uuid(); + } - return ((IMinecraftIntegrationData) integration).uuid(); + public @Nullable String minecraftUsername() throws NamelessException { + final IntegrationData integration = this.integrations().get(StandardIntegrationTypes.MINECRAFT); + return integration == null ? null : integration.username(); } public @Nullable Long discordId() throws NamelessException { - final DetailedIntegrationData integration = this.integrations().get(StandardIntegrationTypes.DISCORD); - - if (integration == null) { - return null; - } + final IntegrationData integration = this.integrations().get(StandardIntegrationTypes.DISCORD); + return integration == null ? null : ((IDiscordIntegrationData) integration).idLong(); + } - return ((IDiscordIntegrationData) integration).idLong(); + public @Nullable String discordUsername() throws NamelessException { + final IntegrationData integration = this.integrations().get(StandardIntegrationTypes.DISCORD); + return integration == null ? null : integration.username(); } public void verify(final @NonNull String verificationCode) throws NamelessException { From a84ded8a7d38a3c329a0c24ceca209c27b5a1bae Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 27 Jul 2022 13:40:18 +0200 Subject: [PATCH 096/269] Allow getting suggestion URL --- .../java_api/modules/suggestions/Suggestion.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java b/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java index fa0339b4..cfa8221b 100644 --- a/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java +++ b/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java @@ -2,12 +2,16 @@ import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.exception.NamelessException; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Date; public class Suggestion { private final int id; + private final URL url; private final SuggestionUser author; private final SuggestionUser updatedBy; private final SuggestionStatus status; @@ -20,8 +24,14 @@ public class Suggestion { private final int likeCount; private final int dislikeCount; - Suggestion(final NamelessAPI api, final JsonObject json) { + Suggestion(final NamelessAPI api, final JsonObject json) throws NamelessException { this.id = json.get("id").getAsInt(); + final String urlString = json.get("link").getAsString(); + try { + this.url = new URL(urlString); + } catch (MalformedURLException e) { + throw new NamelessException("Website provided invalid suggestion URL: " + urlString, e); + } this.author = new SuggestionUser(api, json.getAsJsonObject("author")); this.updatedBy = new SuggestionUser(api, json.getAsJsonObject("updated_by")); this.status = new SuggestionStatus(json.getAsJsonObject("status")); @@ -39,6 +49,10 @@ public int id() { return this.id; } + public URL url() { + return this.url; + } + public SuggestionUser author() { return this.author; } From 29548b0c01709448762170c9e6010a334646230a Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 29 Jul 2022 19:51:13 +0200 Subject: [PATCH 097/269] Properly check if username/identifier is not null --- .../namelessmc/java_api/modules/store/StoreCustomer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java index 9979da33..6aa9474c 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java +++ b/src/com/namelessmc/java_api/modules/store/StoreCustomer.java @@ -20,8 +20,10 @@ public class StoreCustomer { this.api = api; this.id = json.get("customer_id").getAsInt(); this.userId = json.has("user_id") ? json.get("user_id").getAsInt() : null; - this.username = json.has("username") ? json.get("username").getAsString() : null; - this.identifier = json.has("identifier") ? json.get("identifier").getAsString() : null; + this.username = json.has("username") && !json.get("username").isJsonNull() + ? json.get("username").getAsString() : null; + this.identifier = json.has("identifier") && !json.get("identifier").isJsonNull() + ? json.get("identifier").getAsString() : null; if (this.username == null && this.identifier == null) { throw new IllegalStateException("Username and identifier cannot be null at the same time"); From b0453373d901fd7ef3762afd48c6a7893368f4b2 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 30 Jul 2022 08:17:00 +0200 Subject: [PATCH 098/269] Handle new cloudlare page --- src/com/namelessmc/java_api/RequestHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 5fc7d9cf..45d9dea4 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -185,7 +185,9 @@ private void debug(final @NonNull Supplier messageSupplier) { } else if (responseBody.contains("/aes.js")) { message.append("HINT: It looks like requests are being blocked by your web server or a proxy. "); message.append("This is a common occurrence with free web hosting services; they usually don't allow API access.\n"); - } else if (responseBody.contains("Please Wait... | Cloudflare") || responseBody.contains("#cf-bubbles")) { + } else if (responseBody.contains("Please Wait... | Cloudflare") || + responseBody.contains("#cf-bubbles") || + responseBody.contains("_cf_ch1_opt")) { message.append("HINT: CloudFlare is blocking our request. Please see https://docs.namelessmc.com/cloudflare-api\n"); } else if (responseBody.startsWith("\ufeff")) { message.append("HINT: The website response contains invisible unicode characters. This seems to be caused by Partydragen's Store module, we have no idea why.\n"); From a0f46b9ee700a4bf8b3f0d3f4067abb05faf88c3 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 Jul 2022 21:44:07 +0200 Subject: [PATCH 099/269] Deprecate float credits, add integer cents methods --- .../java_api/modules/store/StoreProduct.java | 12 ++++++++++++ .../java_api/modules/store/StoreUser.java | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/com/namelessmc/java_api/modules/store/StoreProduct.java b/src/com/namelessmc/java_api/modules/store/StoreProduct.java index 51182f45..bfd94822 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreProduct.java +++ b/src/com/namelessmc/java_api/modules/store/StoreProduct.java @@ -8,6 +8,7 @@ public class StoreProduct { private final int categoryId; private final String name; private final float price; + private final int priceCents; private final boolean hidden; private final boolean disabled; @@ -16,6 +17,12 @@ public class StoreProduct { this.categoryId = json.get("category_id").getAsInt(); this.name = json.get("name").getAsString(); this.price = json.get("price").getAsFloat(); + if (json.has("price_cents")) { + this.priceCents = json.get("price_cents").getAsInt(); + } else { + // Old module version that does not send cents yet + this.priceCents = (int) this.price; + } this.hidden = json.get("hidden").getAsBoolean(); this.disabled = json.get("disabled").getAsBoolean(); } @@ -32,10 +39,15 @@ public String name() { return this.name; } + @Deprecated public float price() { return this.price; } + public int priceCents() { + return this.priceCents; + } + public boolean isHidden() { return this.hidden; } diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index 7c25b8ec..e92c0c9b 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -17,21 +17,39 @@ public StoreUser(NamelessUser user) throws NamelessException { user.api().ensureModuleInstalled(ModuleNames.STORE); } + @Deprecated public void addCredits(float creditsToAdd) throws NamelessException { JsonObject body = new JsonObject(); body.addProperty("credits", creditsToAdd); this.requests.post("users/" + this.user.userTransformer() + "/add-credits", body); } + public void addCredits(int cents) throws NamelessException { + // Module does not support adding cents yet + this.addCredits(cents * 100f); + } + + @Deprecated public void removeCredits(float creditsToRemove) throws NamelessException { JsonObject body = new JsonObject(); body.addProperty("credits", creditsToRemove); this.requests.post("users/" + this.user.userTransformer() + "/remove-credits", body); } + public void removeCredits(int cents) throws NamelessException { + // Module does not support removing cents yet + this.removeCredits(cents * 100f); + } + + @Deprecated public float credits() throws NamelessException { JsonObject response = this.requests.get("users/" + this.user.userTransformer() + "/credits"); return response.get("credits").getAsFloat(); } + public int creditsCents() throws NamelessException { + JsonObject response = this.requests.get("users/" + this.user.userTransformer() + "/credits"); + return response.get("cents").getAsInt(); + } + } From e2169efefd223555d7224fdc5aa3026893b58a0a Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 31 Jul 2022 21:54:23 +0200 Subject: [PATCH 100/269] Add basic usage instructions to readme --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af909a6a..8de14d31 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ # Nameless-Java-API -Java library for interacting with a NamelessMC website. It is used by for example the NamelessMC Spigot plugin and Nameless-Link Discord bot. + +Java library for interacting with a NamelessMC website. It is used by for example the NamelessMC Minecraft server plugin and Nameless-Link Discord bot. + +## Install to local maven repository + +We don't publish builds to maven central (yet). You will need to build and install this project locally. + +OpenJDK 11, git and maven should be installed. Run in a terminal: + +``` +git clone https://github.com/NamelessMC/Nameless-Java-API +cd Nameless-Java-API +mvn install +``` + +## Include as dependency + +```xml + + com.namelessmc + java-api + canary + +``` + +## Usage + +Create an API instance: + +```java +String apiUrl = ""; +String apiKey = ""; +NamelessAPI api = NamelessAPI.builder(apiUrl, apiKey).build(); +``` From 3e3484dbe38d1fa4544b24cb5323ecb09cbdcb2d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 11:16:39 +0000 Subject: [PATCH 101/269] Bump gson from 2.9.0 to 2.9.1 Bumps [gson](https://github.com/google/gson) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.9.0...gson-parent-2.9.1) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0653a356..8a46d84c 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ com.google.code.gson gson - 2.9.0 + 2.9.1 From d44e29d74467e49f66280990a9953e86284caffa Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Aug 2022 14:23:26 +0200 Subject: [PATCH 102/269] Add methods to create order --- .../java_api/modules/store/StoreUser.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index e92c0c9b..b2d859fb 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -1,11 +1,14 @@ package com.namelessmc.java_api.modules.store; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.NamelessUser; import com.namelessmc.java_api.RequestHandler; import com.namelessmc.java_api.modules.ModuleNames; +import java.util.List; + public class StoreUser { private final NamelessUser user; @@ -52,4 +55,21 @@ public int creditsCents() throws NamelessException { return response.get("cents").getAsInt(); } + public void createOrder(StoreCustomer purchaser, StoreCustomer recipient, List products) throws NamelessException { + JsonArray productIds = new JsonArray(products.size()); + for (int i = 0; i < products.size(); i++) { + productIds.add(products.get(i).id()); + } + this.createOrder(purchaser.id(), recipient.id(), productIds); + } + + public void createOrder(int purchaserCustomerId, int recipientCustomerId, JsonArray productIds) throws NamelessException { + JsonObject body = new JsonObject(); + body.addProperty("user", this.user.userTransformer()); + body.addProperty("customer", purchaserCustomerId); + body.addProperty("recipient", recipientCustomerId); + body.add("products", productIds); + this.requests.post("store/order/create", body); + } + } From 67625cbd218c600a7d5d3390d93eac5b446cb716 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Aug 2022 22:40:56 +0200 Subject: [PATCH 103/269] Add method to get customer id --- src/com/namelessmc/java_api/modules/store/StoreUser.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index b2d859fb..ee305d3e 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -55,6 +55,11 @@ public int creditsCents() throws NamelessException { return response.get("cents").getAsInt(); } + public int customerId() throws NamelessException { + JsonObject response = this.requests.get("users/" + this.user.userTransformer() + "/credits"); + return response.get("customer_id").getAsInt(); + } + public void createOrder(StoreCustomer purchaser, StoreCustomer recipient, List products) throws NamelessException { JsonArray productIds = new JsonArray(products.size()); for (int i = 0; i < products.size(); i++) { From b7356fe679b0c369625e10c866223ce090cffd95 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Aug 2022 22:43:04 +0200 Subject: [PATCH 104/269] Overly complex module class for friendly error messages --- src/com/namelessmc/java_api/NamelessAPI.java | 11 +-- src/com/namelessmc/java_api/Website.java | 6 +- .../exception/MissingModuleException.java | 26 +++++- .../java_api/modules/ModuleNames.java | 18 ---- .../java_api/modules/NamelessModule.java | 84 +++++++++++++++++++ 5 files changed, 118 insertions(+), 27 deletions(-) delete mode 100644 src/com/namelessmc/java_api/modules/ModuleNames.java create mode 100644 src/com/namelessmc/java_api/modules/NamelessModule.java diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 412516b3..4bd46081 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -9,6 +9,7 @@ import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.integrations.IntegrationData; import com.namelessmc.java_api.integrations.StandardIntegrationTypes; +import com.namelessmc.java_api.modules.NamelessModule; import com.namelessmc.java_api.modules.discord.DiscordAPI; import com.namelessmc.java_api.modules.store.StoreAPI; import com.namelessmc.java_api.modules.suggestions.SuggestionsAPI; @@ -296,12 +297,12 @@ public void verifyIntegration(final @NonNull IntegrationData integrationData, /** * Ensures the given module is installed, throwing {@link MissingModuleException} if missing. - * @param moduleName Module name to check - * @see com.namelessmc.java_api.modules.ModuleNames + * @param module Module to check + * @see NamelessModule */ - public void ensureModuleInstalled(String moduleName) throws NamelessException { - if (!this.website().modules().contains(moduleName)) { - throw new MissingModuleException(moduleName); + public void ensureModuleInstalled(NamelessModule module) throws NamelessException { + if (!this.website().modules().contains(module)) { + throw new MissingModuleException(module); } } diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 68281d73..0e40fe47 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.NamelessModule; import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Set; @@ -13,7 +14,7 @@ public class Website implements LanguageEntity { private final String version; private final @Nullable Update update; - private final Set modules; + private final Set modules; private final String rawLanguage; Website(final JsonObject json) throws NamelessException { @@ -28,6 +29,7 @@ public class Website implements LanguageEntity { this.modules = StreamSupport.stream(json.get("modules").getAsJsonArray().spliterator(), false) .map(JsonElement::getAsString) + .map(NamelessModule::byName) .collect(Collectors.toUnmodifiableSet()); if (json.has("version_update")) { @@ -66,7 +68,7 @@ public String rawVersion() { return this.update; } - public Set modules() { + public Set modules() { return this.modules; } diff --git a/src/com/namelessmc/java_api/exception/MissingModuleException.java b/src/com/namelessmc/java_api/exception/MissingModuleException.java index 4121b085..4f968e78 100644 --- a/src/com/namelessmc/java_api/exception/MissingModuleException.java +++ b/src/com/namelessmc/java_api/exception/MissingModuleException.java @@ -1,11 +1,33 @@ package com.namelessmc.java_api.exception; +import com.namelessmc.java_api.modules.NamelessModule; + public class MissingModuleException extends NamelessException { private static final long serialVersionUID = 1L; - public MissingModuleException(final String moduleName) { - super("Required module not installed: " + moduleName); + public MissingModuleException(final NamelessModule module) { + super(getExceptionMessage(module)); + } + + private static String getExceptionMessage(final NamelessModule module) { + StringBuilder builder = new StringBuilder("Required module not installed: "); + builder.append(module.name()); + builder.append("."); + + if (module.isIncluded()) { + builder.append(" This module is an official module, included with NamelessMC. Please enable it."); + } else { + builder.append(" This module is a third-party module."); + if (module.downloadLink() != null) { + builder.append(" It can be downloaded here: "); + builder.append(module.downloadLink()); + } else { + builder.append(" It can be downloaded externally."); + } + } + + return builder.toString(); } } diff --git a/src/com/namelessmc/java_api/modules/ModuleNames.java b/src/com/namelessmc/java_api/modules/ModuleNames.java deleted file mode 100644 index b46a7a16..00000000 --- a/src/com/namelessmc/java_api/modules/ModuleNames.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.namelessmc.java_api.modules; - -public class ModuleNames { - - // Official modules - - public static final String CORE = "Core"; - public static final String FORUM = "Forum"; - public static final String DISCORD_INTEGRATION = "Discord Integration"; - public static final String COOKIE_CONSENT = "Cookie Consent"; - - // Third party modules - - public static final String STORE = "Store"; - public static final String WEBSEND = "Websend"; - public static final String SUGGESTIONS = "Suggestions"; - -} diff --git a/src/com/namelessmc/java_api/modules/NamelessModule.java b/src/com/namelessmc/java_api/modules/NamelessModule.java new file mode 100644 index 00000000..1212196b --- /dev/null +++ b/src/com/namelessmc/java_api/modules/NamelessModule.java @@ -0,0 +1,84 @@ +package com.namelessmc.java_api.modules; + +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class NamelessModule { + + public static final NamelessModule CORE = new NamelessModule("Core", true, null); + public static final NamelessModule FORUM = new NamelessModule("Forum", true, null); + public static final NamelessModule DISCORD_INTEGRATION = new NamelessModule("Discord Integration", true, null); + public static final NamelessModule COOKIE_CONSENT = new NamelessModule("Cookie Consent", true, null); + + public static final NamelessModule STORE = new NamelessModule("Store", false, "https://namelessmc.com/resources/resource/139"); + public static final NamelessModule WEBSEND = new NamelessModule("Websend", false, "https://github.com/supercrafter100/Nameless-Websend/archive/refs/heads/master.zip"); + public static final NamelessModule SUGGESTIONS = new NamelessModule("Suggestions", false, "https://namelessmc.com/resources/resource/129"); + + private final String name; + private final boolean included; + private final @Nullable String downloadLink; + + private NamelessModule(String name, boolean included, @Nullable String downloadLink) { + this.name = name; + this.included = included; + this.downloadLink = downloadLink; + } + + public String name() { + return this.name; + } + + public boolean isIncluded() { + return this.included; + } + + public @Nullable String downloadLink() { + return downloadLink; + } + + private static final List MODULES = List.of( + CORE, + FORUM, + DISCORD_INTEGRATION, + COOKIE_CONSENT, + STORE, + WEBSEND, + SUGGESTIONS + ); + + private static final Map BY_NAME = new HashMap<>(); + + static { + for (NamelessModule module : MODULES) { + BY_NAME.put(module.name(), module); + } + } + + public static NamelessModule custom(String name) { + return new NamelessModule(Objects.requireNonNull(name), false, null); + } + + public static NamelessModule byName(String name) { + if (BY_NAME.containsKey(name)) { + return BY_NAME.get(name); + } else { + return custom(name); + } + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof NamelessModule && + ((NamelessModule) obj).name().equals(this.name); + } + +} From e30dbbc5c58ef0e2f9722597ebc3df421e2bf3ce Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Aug 2022 22:51:27 +0200 Subject: [PATCH 105/269] Use new class internally --- .../java_api/modules/discord/DiscordAPI.java | 6 +++--- .../java_api/modules/discord/DiscordUser.java | 6 +++--- .../namelessmc/java_api/modules/store/StoreAPI.java | 6 +++--- .../namelessmc/java_api/modules/store/StoreUser.java | 6 +++--- .../java_api/modules/suggestions/SuggestionsAPI.java | 4 ++-- .../java_api/modules/suggestions/SuggestionsUser.java | 4 ++-- .../java_api/modules/websend/WebsendAPI.java | 11 +++++++---- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java b/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java index e1a3e7f2..18946771 100644 --- a/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java +++ b/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java @@ -4,9 +4,9 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.RequestHandler; -import com.namelessmc.java_api.modules.ModuleNames; +import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.NamelessModule; import org.checkerframework.checker.nullness.qual.NonNull; import java.net.URL; @@ -19,7 +19,7 @@ public class DiscordAPI { public DiscordAPI(NamelessAPI api) throws NamelessException { this.requests = api.requests(); - api.ensureModuleInstalled(ModuleNames.DISCORD_INTEGRATION); + api.ensureModuleInstalled(NamelessModule.DISCORD_INTEGRATION); } /** diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java index 7cf56e37..49a51f89 100644 --- a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java +++ b/src/com/namelessmc/java_api/modules/discord/DiscordUser.java @@ -1,10 +1,10 @@ package com.namelessmc.java_api.modules.discord; import com.google.gson.JsonObject; -import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.NamelessUser; import com.namelessmc.java_api.RequestHandler; -import com.namelessmc.java_api.modules.ModuleNames; +import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.NamelessModule; import org.checkerframework.checker.nullness.qual.NonNull; public class DiscordUser { @@ -15,7 +15,7 @@ public class DiscordUser { public DiscordUser(NamelessUser user) throws NamelessException { this.user = user; this.requests = user.api().requests(); - user.api().ensureModuleInstalled(ModuleNames.DISCORD_INTEGRATION); + user.api().ensureModuleInstalled(NamelessModule.DISCORD_INTEGRATION); } public void updateDiscordRoles(final long@NonNull [] roleIds) throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/com/namelessmc/java_api/modules/store/StoreAPI.java index 736f5f79..883f3a77 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreAPI.java +++ b/src/com/namelessmc/java_api/modules/store/StoreAPI.java @@ -4,9 +4,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.RequestHandler; -import com.namelessmc.java_api.modules.ModuleNames; +import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.NamelessModule; import java.util.ArrayList; import java.util.Collection; @@ -21,7 +21,7 @@ public class StoreAPI { public StoreAPI(final NamelessAPI api) throws NamelessException { this.api = api; this.requests = api.requests(); - this.api.ensureModuleInstalled(ModuleNames.STORE); + this.api.ensureModuleInstalled(NamelessModule.STORE); } public List products() throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/com/namelessmc/java_api/modules/store/StoreUser.java index ee305d3e..3709381f 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/com/namelessmc/java_api/modules/store/StoreUser.java @@ -2,10 +2,10 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.NamelessUser; import com.namelessmc.java_api.RequestHandler; -import com.namelessmc.java_api.modules.ModuleNames; +import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.NamelessModule; import java.util.List; @@ -17,7 +17,7 @@ public class StoreUser { public StoreUser(NamelessUser user) throws NamelessException { this.user = user; this.requests = user.api().requests(); - user.api().ensureModuleInstalled(ModuleNames.STORE); + user.api().ensureModuleInstalled(NamelessModule.STORE); } @Deprecated diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java index 78a707b8..8542c6d2 100644 --- a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java @@ -4,7 +4,7 @@ import com.namelessmc.java_api.NamelessAPI; import com.namelessmc.java_api.RequestHandler; import com.namelessmc.java_api.exception.NamelessException; -import com.namelessmc.java_api.modules.ModuleNames; +import com.namelessmc.java_api.modules.NamelessModule; public class SuggestionsAPI { @@ -14,7 +14,7 @@ public class SuggestionsAPI { public SuggestionsAPI(final NamelessAPI api) throws NamelessException { this.api = api; this.requests = api.requests(); - api.ensureModuleInstalled(ModuleNames.SUGGESTIONS); + api.ensureModuleInstalled(NamelessModule.SUGGESTIONS); } public Suggestion suggestion(int suggestionId) throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java index dac8073b..c98cd566 100644 --- a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java @@ -5,7 +5,7 @@ import com.namelessmc.java_api.NamelessUser; import com.namelessmc.java_api.RequestHandler; import com.namelessmc.java_api.exception.NamelessException; -import com.namelessmc.java_api.modules.ModuleNames; +import com.namelessmc.java_api.modules.NamelessModule; import java.util.Objects; @@ -20,7 +20,7 @@ public SuggestionsUser(final NamelessUser user) throws NamelessException { this.api = this.user.api(); this.requests = this.api.requests(); - this.api.ensureModuleInstalled(ModuleNames.SUGGESTIONS); + this.api.ensureModuleInstalled(NamelessModule.SUGGESTIONS); } public void like(final int suggestionId) throws NamelessException { diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java index 522c9716..4eb5cf84 100644 --- a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java +++ b/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java @@ -4,12 +4,15 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.RequestHandler; -import com.namelessmc.java_api.modules.ModuleNames; +import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.modules.NamelessModule; import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; public class WebsendAPI { @@ -17,7 +20,7 @@ public class WebsendAPI { public WebsendAPI(final NamelessAPI api) throws NamelessException { this.requests = api.requests(); - api.ensureModuleInstalled(ModuleNames.WEBSEND); + api.ensureModuleInstalled(NamelessModule.WEBSEND); } public @NonNull List commands(int serverId) throws NamelessException { From b2d9c876d1a59bd4f00f1315b6d1f51bf64b8070 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 1 Aug 2022 22:58:03 +0200 Subject: [PATCH 106/269] Fix nullability warnings --- src/com/namelessmc/java_api/RequestHandler.java | 2 -- src/com/namelessmc/java_api/modules/NamelessModule.java | 2 +- .../java_api/modules/suggestions/SuggestionUser.java | 6 +++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 45d9dea4..00ceea32 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -150,8 +150,6 @@ private void debug(final @NonNull Supplier messageSupplier) { } else if (exceptionMessage.contains("Connection refused")) { message.append("\nHINT: Is the domain correct? Is your webserver running? Are we blocked by a firewall?"); } else if (exceptionMessage.contains("timed out")) { - // All timeouts are set to the same value, so we only need to print one. - long seconds = httpClient.connectTimeout().orElseThrow().getSeconds(); message.append("\nHINT: The website responded too slow, no response after waiting for "); message.append((System.currentTimeMillis() - requestStartTime) / 1000); message.append(" seconds."); diff --git a/src/com/namelessmc/java_api/modules/NamelessModule.java b/src/com/namelessmc/java_api/modules/NamelessModule.java index 1212196b..697dc50c 100644 --- a/src/com/namelessmc/java_api/modules/NamelessModule.java +++ b/src/com/namelessmc/java_api/modules/NamelessModule.java @@ -76,7 +76,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final @Nullable Object obj) { return obj instanceof NamelessModule && ((NamelessModule) obj).name().equals(this.name); } diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java b/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java index 5dcbba88..a22ef15c 100644 --- a/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java +++ b/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java @@ -24,7 +24,11 @@ public int userId() { } public NamelessUser user() throws NamelessException { - return this.api.user(this.id); + NamelessUser user = this.api.user(this.id); + if (user == null) { + throw new IllegalStateException("Suggestions module returned a user id that doesn't exist"); + } + return user; } public String username() { From df47e8989c7af7b25a1dc0d63b00f9d78a850c5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Aug 2022 11:12:44 +0000 Subject: [PATCH 107/269] Bump checker-qual from 3.23.0 to 3.24.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.23.0 to 3.24.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.23.0...checker-framework-3.24.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8a46d84c..a0f1bdf3 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.23.0 + 3.24.0 From 87b9d3468d76a02d17a05290bec726c7edbf1a4c Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 5 Aug 2022 20:24:33 +0200 Subject: [PATCH 108/269] Add user friendly warning for empty 301/302/303 response --- src/com/namelessmc/java_api/RequestHandler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 00ceea32..34e81fb4 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -164,7 +164,10 @@ private void debug(final @NonNull Supplier messageSupplier) { debug(() -> "Website response body, after " + (System.currentTimeMillis() - requestStartTime) + "ms:\n" + regularAsciiOnly(responseBody)); if (responseBody.length() == 0) { - throw new NamelessException("Website sent empty response with status code " + statusCode); + if (statusCode >= 301 && statusCode <= 303) { + throw new NamelessException("Website returned a redirect. Please ensure your URL is correct, paying attention to whether it should use HTTP or HTTPS, or whether it should or should not contain 'www.'."); + } + throw new NamelessException("Website returned empty response with status code " + statusCode); } JsonObject json; @@ -177,7 +180,7 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append(statusCode); message.append(".\n"); if (statusCode >= 301 && statusCode <= 303) { - message.append("HINT: The URL results in a redirect. If your URL uses http://, change to https://. If your website forces www., make sure to add www. to the url.\n"); + message.append("HINT: The web server returned a redirect. If your URL uses http://, change to https://. If your website forces www., make sure to add www. to the url.\n"); } else if (statusCode == 520 || statusCode == 521) { message.append("HINT: Status code 520/521 is sent by CloudFlare when the backend webserver is down or having issues. Check your webserver and CloudFlare configuration.\n"); } else if (responseBody.contains("/aes.js")) { From b66423594eb5644d20c953ac1989e59a372ae6e4 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 5 Aug 2022 21:32:09 +0200 Subject: [PATCH 109/269] Add v2.0.0, mark as supported --- src/com/namelessmc/java_api/NamelessVersion.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index 836171c1..686ab653 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -14,11 +14,13 @@ public enum NamelessVersion { V2_0_0_PR_11("2.0.0-pr11", "2.0.0 pre-release 11", 2, 0, true), V2_0_0_PR_12("2.0.0-pr12", "2.0.0 pre-release 12", 2, 0, true), V2_0_0_PR_13("2.0.0-pr13", "2.0.0 pre-release 13", 2, 0, true), + V2_0_0("2.0.0", "2.0.0", 2, 0, false), ; private static final Set SUPPORTED_VERSIONS = EnumSet.of( - V2_0_0_PR_13 + V2_0_0_PR_13, + V2_0_0 ); private final @NonNull String name; From 36ef73951f879664c980b15a207a30b1f8ff512e Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 5 Aug 2022 22:00:39 +0200 Subject: [PATCH 110/269] Treat all patch versions as the same --- .../namelessmc/java_api/LanguageEntity.java | 2 +- .../namelessmc/java_api/NamelessVersion.java | 72 ++++++++++++++----- src/com/namelessmc/java_api/Website.java | 11 ++- .../UnknownNamelessVersionException.java | 9 +++ 4 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java diff --git a/src/com/namelessmc/java_api/LanguageEntity.java b/src/com/namelessmc/java_api/LanguageEntity.java index 806af76f..a946d4f6 100644 --- a/src/com/namelessmc/java_api/LanguageEntity.java +++ b/src/com/namelessmc/java_api/LanguageEntity.java @@ -7,7 +7,7 @@ public interface LanguageEntity { - @NonNull String rawLocale() throws NamelessException; + String rawLocale() throws NamelessException; default @NonNull Locale locale() throws NamelessException { final String language = this.rawLocale(); diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index 686ab653..1b4a27b5 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -1,5 +1,6 @@ package com.namelessmc.java_api; +import com.namelessmc.java_api.exception.UnknownNamelessVersionException; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -7,42 +8,42 @@ public enum NamelessVersion { - V2_0_0_PR_7("2.0.0-pr7", "2.0.0 pre-release 7", 2, 0, true), + V2_0_0_PR_7("2.0.0-pr7", "2.0.0 pre-release 7", 2, 0, true), V2_0_0_PR_8("2.0.0-pr8", "2.0.0 pre-release 8", 2, 0, true), V2_0_0_PR_9("2.0.0-pr9", "2.0.0 pre-release 9", 2, 0, true), V2_0_0_PR_10("2.0.0-pr10", "2.0.0 pre-release 10", 2, 0, true), V2_0_0_PR_11("2.0.0-pr11", "2.0.0 pre-release 11", 2, 0, true), V2_0_0_PR_12("2.0.0-pr12", "2.0.0 pre-release 12", 2, 0, true), V2_0_0_PR_13("2.0.0-pr13", "2.0.0 pre-release 13", 2, 0, true), - V2_0_0("2.0.0", "2.0.0", 2, 0, false), + V2_0(null, "2.0.*", 2, 0, false), ; private static final Set SUPPORTED_VERSIONS = EnumSet.of( V2_0_0_PR_13, - V2_0_0 + V2_0 ); - private final @NonNull String name; + private final @Nullable String name; // Only for pre-releases that use literal name matching private final @NonNull String friendlyName; private final int major; private final int minor; - private final boolean isBeta; + private final boolean preRelease; @SuppressWarnings("SameParameterValue") - NamelessVersion(final @NonNull String name, + NamelessVersion(final @Nullable String name, final @NonNull String friendlyName, final int major, final int minor, - final boolean isBeta) { + final boolean preRelease) { this.name = name; this.friendlyName = friendlyName; this.major = major; this.minor = minor; - this.isBeta = isBeta; + this.preRelease = preRelease; } - public @NonNull String internalName() { + public @Nullable String preReleaseName() { return this.name; } @@ -59,10 +60,10 @@ public int minor() { } /** - * @return True if this version is a release candidate, pre-release, beta, alpha. + * @return True if this version is a pre-release */ - public boolean isBeta() { - return this.isBeta; + public boolean isPreRelease() { + return this.preRelease; } @Override @@ -72,15 +73,54 @@ public String toString() { private static final Map BY_NAME = new HashMap<>(); + private static final NamelessVersion[] CACHED_VALUES = NamelessVersion.values(); + static { - for (final NamelessVersion version : values()) { - BY_NAME.put(version.internalName(), version); + for (final NamelessVersion version : allVersions()) { + if (version.isPreRelease()) { + BY_NAME.put(version.preReleaseName(), version); + } } } - public static @Nullable NamelessVersion parse(final @NonNull String versionName) { + public static NamelessVersion parse(final @NonNull String versionName) throws UnknownNamelessVersionException { Objects.requireNonNull(versionName, "Version name is null"); - return BY_NAME.get(versionName); + if (versionName.contains("-pr")) { + // Pre-release version should match exactly + NamelessVersion version = BY_NAME.get(versionName); + if (version == null) { + throw new UnknownNamelessVersionException(versionName, "no pre-release matches exactly"); + } + return version; + } + String[] split = versionName.split("\\."); + if (split.length != 3) { + throw new UnknownNamelessVersionException(versionName, "version doesn't split to 3 components"); + } + int[] splitInts = new int[3]; + for (int i = 0; i < 3; i++) { + try { + splitInts[i] = Integer.parseInt(split[i]); + } catch (NumberFormatException e) { + throw new UnknownNamelessVersionException(versionName, "split component " + i + " is not an integer"); + } + } + + int major = splitInts[0]; + int minor = splitInts[1]; + + for (NamelessVersion version : allVersions()) { + if (version.major == major && version.minor == minor) { + return version; + } + } + + throw new UnknownNamelessVersionException(versionName, "no match for major=" + major + " minor=" + minor); + + } + + public static NamelessVersion[] allVersions() { + return CACHED_VALUES; } /** diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index 0e40fe47..ecf7862a 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.exception.NamelessException; +import com.namelessmc.java_api.exception.UnknownNamelessVersionException; import com.namelessmc.java_api.modules.NamelessModule; import org.checkerframework.checker.nullness.qual.Nullable; @@ -57,7 +58,7 @@ public String rawVersion() { return this.version; } - public @Nullable NamelessVersion parsedVersion() { + public NamelessVersion parsedVersion() throws UnknownNamelessVersionException { return NamelessVersion.parse(this.version); } @@ -73,7 +74,7 @@ public Set modules() { } @Override - public String rawLocale() throws NamelessException { + public String rawLocale() { return this.rawLanguage; } @@ -95,11 +96,7 @@ public String rawVersion() { return this.version; } - public @Nullable NamelessVersion parsedVersion() { - return NamelessVersion.parse(this.version); - } - - public @Nullable NamelessVersion getParsedVersion() { + public NamelessVersion parsedVersion() throws UnknownNamelessVersionException { return NamelessVersion.parse(this.version); } diff --git a/src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java b/src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java new file mode 100644 index 00000000..a643179a --- /dev/null +++ b/src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java @@ -0,0 +1,9 @@ +package com.namelessmc.java_api.exception; + +public class UnknownNamelessVersionException extends NamelessException { + + public UnknownNamelessVersionException(String versionName, String reason) { + super("Unknown Nameless version:" + versionName + ": " + reason); + } + +} From e375528a377897c5fb92bcdeca24d7eb1e1577c4 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 6 Aug 2022 13:54:11 +0200 Subject: [PATCH 111/269] attempt emergency fix using web editor on mobile phone --- src/com/namelessmc/java_api/NamelessVersion.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index 1b4a27b5..04825c96 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -110,7 +110,7 @@ public static NamelessVersion parse(final @NonNull String versionName) throws Un int minor = splitInts[1]; for (NamelessVersion version : allVersions()) { - if (version.major == major && version.minor == minor) { + if (version.major == major && version.minor == minor && !version.isPreRelease()) { return version; } } From e3c99f07e5cf7c539d0955b9014387041565b139 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 6 Aug 2022 14:01:57 +0200 Subject: [PATCH 112/269] another emergency patch --- src/com/namelessmc/java_api/Website.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/Website.java b/src/com/namelessmc/java_api/Website.java index ecf7862a..aaeb1f9d 100644 --- a/src/com/namelessmc/java_api/Website.java +++ b/src/com/namelessmc/java_api/Website.java @@ -33,7 +33,7 @@ public class Website implements LanguageEntity { .map(NamelessModule::byName) .collect(Collectors.toUnmodifiableSet()); - if (json.has("version_update")) { + if (json.has("version_update") && false) { final JsonObject updateJson = json.get("version_update").getAsJsonObject(); final boolean updateAvailable = updateJson.get("update").getAsBoolean(); if (updateAvailable) { From 2d03d56391480f8d65f5e42031e2b377efe033d5 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 8 Aug 2022 10:05:16 +0200 Subject: [PATCH 113/269] Add missing 'missing api key' api error --- src/com/namelessmc/java_api/exception/ApiError.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/namelessmc/java_api/exception/ApiError.java b/src/com/namelessmc/java_api/exception/ApiError.java index b707d3c2..bf2b3e9a 100644 --- a/src/com/namelessmc/java_api/exception/ApiError.java +++ b/src/com/namelessmc/java_api/exception/ApiError.java @@ -12,6 +12,7 @@ public enum ApiError { NAMELESS_UNKNOWN_ERROR("nameless", "unknown_error"), NAMELESS_NOT_AUTHORIZED("nameless", "not_authorized"), NAMELESS_INVALID_API_KEY("nameless", "invalid_api_key"), + NAMELESS_MISSING_API_KEY("nameless", "missing_api_key"), NAMELESS_INVALID_API_METHOD("nameless", "invalid_api_method"), NAMELESS_CANNOT_FIND_USER("nameless", "cannot_find_user"), NAMELESS_INVALID_POST_CONTENTS("nameless", "invalid_post_contents"), From eacb156d75bf82131511e012e2a1a3607ac9fa9a Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 8 Aug 2022 11:13:47 +0200 Subject: [PATCH 114/269] Update to new store api --- .../java_api/modules/store/StoreProduct.java | 57 ++++++++++++++----- .../modules/store/StoreProductAction.java | 48 ++++++++++++++++ .../modules/store/StoreProductField.java | 56 ++++++++++++++++++ .../namelessmc/java_api/util/GsonHelper.java | 55 ++++++++++++++++++ 4 files changed, 203 insertions(+), 13 deletions(-) create mode 100644 src/com/namelessmc/java_api/modules/store/StoreProductAction.java create mode 100644 src/com/namelessmc/java_api/modules/store/StoreProductField.java create mode 100644 src/com/namelessmc/java_api/util/GsonHelper.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreProduct.java b/src/com/namelessmc/java_api/modules/store/StoreProduct.java index bfd94822..5920239f 100644 --- a/src/com/namelessmc/java_api/modules/store/StoreProduct.java +++ b/src/com/namelessmc/java_api/modules/store/StoreProduct.java @@ -1,30 +1,41 @@ package com.namelessmc.java_api.modules.store; import com.google.gson.JsonObject; +import com.namelessmc.java_api.util.GsonHelper; + +import java.util.List; public class StoreProduct { private final int id; private final int categoryId; private final String name; - private final float price; private final int priceCents; private final boolean hidden; private final boolean disabled; + private final int[] requiredProductsIds; + private final int[] requiredGroupsIds; + private final int[] requiredIntegrationsIds; + private final String descriptionHtml; + private final List fields; + private final List actions; StoreProduct(JsonObject json) { + if (!json.has("price_cents")) { + throw new IllegalArgumentException("Missing price_cents, are you using an old store module version?"); + } this.id = json.get("id").getAsInt(); this.categoryId = json.get("category_id").getAsInt(); this.name = json.get("name").getAsString(); - this.price = json.get("price").getAsFloat(); - if (json.has("price_cents")) { - this.priceCents = json.get("price_cents").getAsInt(); - } else { - // Old module version that does not send cents yet - this.priceCents = (int) this.price; - } + this.priceCents = json.get("price_cents").getAsInt(); this.hidden = json.get("hidden").getAsBoolean(); this.disabled = json.get("disabled").getAsBoolean(); + this.requiredProductsIds = GsonHelper.toIntArray(json.getAsJsonArray("required_products")); + this.requiredGroupsIds = GsonHelper.toIntArray(json.getAsJsonArray("required_groups")); + this.requiredIntegrationsIds = GsonHelper.toIntArray(json.getAsJsonArray("required_integrations")); + this.descriptionHtml = json.get("description").getAsString(); + this.fields = GsonHelper.toObjectList(json.getAsJsonArray("fields"), StoreProductField::new); + this.actions = GsonHelper.toObjectList(json.getAsJsonArray("actions"), StoreProductAction::new); } public int id() { @@ -39,11 +50,6 @@ public String name() { return this.name; } - @Deprecated - public float price() { - return this.price; - } - public int priceCents() { return this.priceCents; } @@ -55,4 +61,29 @@ public boolean isHidden() { public boolean isDisabled() { return this.disabled; } + + public int[] requiredProductsIds() { + return this.requiredProductsIds; + } + + public int[] requiredGroupsIds() { + return this.requiredGroupsIds; + } + + public int[] requiredIntegrationsIds() { + return this.requiredIntegrationsIds; + } + + public String descriptionHtml() { + return this.descriptionHtml; + } + + public List fields() { + return this.fields; + } + + public List actions() { + return this.actions; + } + } diff --git a/src/com/namelessmc/java_api/modules/store/StoreProductAction.java b/src/com/namelessmc/java_api/modules/store/StoreProductAction.java new file mode 100644 index 00000000..1f4dc467 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StoreProductAction.java @@ -0,0 +1,48 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonObject; + +public class StoreProductAction { + + private final int id; + private final int typeId; // TODO enum + private final int serviceId; + private final String command; + private final boolean requireOnline; + private final boolean ownConnections; + + StoreProductAction(JsonObject json) { + this.id = json.get("id").getAsInt(); + this.typeId = json.get("type").getAsInt(); + this.serviceId = json.get("service_id").getAsInt(); + this.command = json.get("command").getAsString(); + this.requireOnline = json.get("require_online").getAsBoolean(); + this.ownConnections = json.get("own_connections").getAsBoolean(); + } + + public int id() { + return this.id; + } + + @Deprecated + public int typeId() { + return this.typeId; + } + + public int serviceId() { + return this.serviceId; + } + + public String command() { + return this.command; + } + + public boolean requireOnline() { + return this.requireOnline; + } + + public boolean ownConnections() { + return this.ownConnections; + } + +} diff --git a/src/com/namelessmc/java_api/modules/store/StoreProductField.java b/src/com/namelessmc/java_api/modules/store/StoreProductField.java new file mode 100644 index 00000000..982d7671 --- /dev/null +++ b/src/com/namelessmc/java_api/modules/store/StoreProductField.java @@ -0,0 +1,56 @@ +package com.namelessmc.java_api.modules.store; + +import com.google.gson.JsonObject; +import com.namelessmc.java_api.util.GsonHelper; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class StoreProductField { + + private final int id; + private final String identifier; + private final int typeId; // TODO enum + private final boolean required; + private final int min; + private final @Nullable String regex; + private final String defaultValue; + + public StoreProductField(JsonObject json) { + this.id = json.get("id").getAsInt(); + this.identifier = json.get("identifier").getAsString(); + this.typeId = json.get("type").getAsInt(); + this.required = json.get("required").getAsBoolean(); + this.min = json.get("min").getAsInt(); + this.regex = GsonHelper.getNullableString(json, "regex"); + this.defaultValue = json.get("default_value").getAsString(); + } + + public int id() { + return this.id; + } + + public String identifier() { + return this.identifier; + } + + @Deprecated + public int typeId() { + return this.typeId; + } + + public boolean required() { + return this.required; + } + + public int min() { + return this.min; + } + + public @Nullable String regex() { + return this.regex; + } + + public String defaultValue() { + return this.defaultValue; + } + +} diff --git a/src/com/namelessmc/java_api/util/GsonHelper.java b/src/com/namelessmc/java_api/util/GsonHelper.java new file mode 100644 index 00000000..07be020a --- /dev/null +++ b/src/com/namelessmc/java_api/util/GsonHelper.java @@ -0,0 +1,55 @@ +package com.namelessmc.java_api.util; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.*; +import java.util.function.Function; + +public class GsonHelper { + + public static int[] toIntArray(JsonArray jsonArray) { + int[] array = new int[jsonArray.size()]; + for (int i = 0; i < jsonArray.size(); i++) { + array[i] = jsonArray.get(i).getAsInt(); + } + return array; + } + + public static long[] toLongArray(JsonArray jsonArray) { + long[] array = new long[jsonArray.size()]; + for (int i = 0; i < jsonArray.size(); i++) { + array[i] = jsonArray.get(i).getAsLong(); + } + return array; + } + + public static Set toIntegerSet(JsonArray jsonArray) { + Set set = new HashSet<>(); + for (JsonElement elem : jsonArray) { + set.add(elem.getAsInt()); + } + return Collections.unmodifiableSet(set); + } + + public static List toObjectList(JsonArray array, Function constructor) { + List list = new ArrayList<>(array.size()); + for (JsonElement e : array) { + list.add(constructor.apply(e.getAsJsonObject())); + } + return Collections.unmodifiableList(list); + } + + public static @Nullable String getNullableString(JsonObject object, String key) { + if (object.has(key)) { + JsonElement e = object.get(key); + if (!e.isJsonNull()) { + return e.getAsString(); + } + } + return null; + } + +} From 6481409a15e51de117616d21b8d152ffd60d0acc Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 8 Aug 2022 11:16:12 +0200 Subject: [PATCH 115/269] Simplify groups() --- src/com/namelessmc/java_api/NamelessUser.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 96b409a7..f8c2d8ed 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -12,6 +12,7 @@ import com.namelessmc.java_api.modules.discord.DiscordUser; import com.namelessmc.java_api.modules.store.StoreUser; import com.namelessmc.java_api.modules.suggestions.SuggestionsUser; +import com.namelessmc.java_api.util.GsonHelper; import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -19,8 +20,6 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; public final class NamelessUser implements LanguageEntity { @@ -175,13 +174,7 @@ public boolean isStaff() throws NamelessException { * @return List of the user's groups, sorted from low order to high order. */ public @NonNull List<@NonNull Group> groups() throws NamelessException { - // TODO sorting may be unnecessary since the website already returns sorted groups - return Collections.unmodifiableList( - StreamSupport.stream(this.userInfo().getAsJsonArray("groups").spliterator(), false) - .map(JsonElement::getAsJsonObject) - .map(Group::new) - .sorted() - .collect(Collectors.toList())); + return GsonHelper.toObjectList(this.userInfo().getAsJsonArray("groups"), Group::new); } /** From af7ecd3cce455ea231a4e895131e836515a0fef9 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 8 Aug 2022 11:21:21 +0200 Subject: [PATCH 116/269] simplify notifications() --- src/com/namelessmc/java_api/NamelessUser.java | 12 +----------- src/com/namelessmc/java_api/Notification.java | 10 ++++++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index f8c2d8ed..e8892641 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -4,7 +4,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.namelessmc.java_api.Notification.Type; import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.exception.NamelessException; @@ -223,16 +222,7 @@ public int notificationCount() throws NamelessException { public List notifications() throws NamelessException { final JsonObject response = this.requests.get("users/" + this.userTransformer + "/notifications"); - - final List notifications = new ArrayList<>(); - response.getAsJsonArray("notifications").forEach((element) -> { - final String message = element.getAsJsonObject().get("message").getAsString(); - final String url = element.getAsJsonObject().get("url").getAsString(); - final Type type = Type.fromString(element.getAsJsonObject().get("type").getAsString()); - notifications.add(new Notification(message, url, type)); - }); - - return notifications; + return GsonHelper.toObjectList(response.getAsJsonArray("notifications"), Notification::new); } /** diff --git a/src/com/namelessmc/java_api/Notification.java b/src/com/namelessmc/java_api/Notification.java index cbf74d05..dcab79fa 100644 --- a/src/com/namelessmc/java_api/Notification.java +++ b/src/com/namelessmc/java_api/Notification.java @@ -1,15 +1,17 @@ package com.namelessmc.java_api; +import com.google.gson.JsonObject; + public class Notification { private final String message; private final String url; private final Type type; - public Notification(final String message, final String url, final Type type) { - this.message = message; - this.url = url; - this.type = type; + public Notification(JsonObject json) { + this.message = json.get("message").getAsString(); + this.url = json.get("url").getAsString(); + this.type = Type.fromString(json.get("type").getAsString()); } public String message() { From 179bc13c1fa39f76a3ed50d07d31c41cce38a1d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Aug 2022 11:15:46 +0000 Subject: [PATCH 117/269] Bump slf4j-api from 2.0.0-alpha7 to 2.0.0-beta1 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.0-alpha7 to 2.0.0-beta1. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.0-alpha7...v_2.0.0-beta1) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a0f1bdf3..97c46739 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.0-alpha7 + 2.0.0-beta1 provided From e809e6731e5b2f752237a00b5c2aa29d80e2062f Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 13 Aug 2022 07:06:53 +0200 Subject: [PATCH 118/269] Support nullable profile field values --- src/com/namelessmc/java_api/NamelessUser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index e8892641..55ca40cc 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -319,7 +319,7 @@ public Collection profileFields() throws NamelessExcept values.get("required").getAsBoolean(), values.get("description").getAsString() ), - values.get("value").getAsString() + GsonHelper.getNullableString(values, "value") )); } From 61c02dfe3cfc9684a6d28c6950bd640c5313d6c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Aug 2022 11:07:51 +0000 Subject: [PATCH 119/269] Bump slf4j-api from 2.0.0-beta1 to 2.0.0 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.0-beta1 to 2.0.0. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.0-beta1...v_2.0.0) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 97c46739..429099fe 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.0-beta1 + 2.0.0 provided From 9eb899fb2f43a9069fecdf685dd94d2b4136c558 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 30 Aug 2022 10:23:06 +0200 Subject: [PATCH 120/269] If groups is missing, link to issue --- src/com/namelessmc/java_api/NamelessUser.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/com/namelessmc/java_api/NamelessUser.java index 55ca40cc..7adce858 100644 --- a/src/com/namelessmc/java_api/NamelessUser.java +++ b/src/com/namelessmc/java_api/NamelessUser.java @@ -158,6 +158,10 @@ public boolean isVerified() throws NamelessException { * @return True if the user is member of at least one staff group, otherwise false */ public boolean isStaff() throws NamelessException { + if (!this.userInfo().has("groups")) { + throw new IllegalStateException("Groups array missing: https://github.com/NamelessMC/Nameless/issues/3052"); + } + JsonArray groups = this.userInfo().getAsJsonArray("groups"); for (JsonElement elem : groups) { JsonObject group = elem.getAsJsonObject(); @@ -173,6 +177,9 @@ public boolean isStaff() throws NamelessException { * @return List of the user's groups, sorted from low order to high order. */ public @NonNull List<@NonNull Group> groups() throws NamelessException { + if (!this.userInfo().has("groups")) { + throw new IllegalStateException("Groups array missing: https://github.com/NamelessMC/Nameless/issues/3052"); + } return GsonHelper.toObjectList(this.userInfo().getAsJsonArray("groups"), Group::new); } @@ -184,6 +191,9 @@ public boolean isStaff() throws NamelessException { * @return Player's group with the lowest order */ public @Nullable Group primaryGroup() throws NamelessException { + if (!this.userInfo().has("groups")) { + throw new IllegalStateException("Groups array missing: https://github.com/NamelessMC/Nameless/issues/3052"); + } final JsonArray groups = this.userInfo().getAsJsonArray("groups"); if (groups.size() > 0) { // Website group response is ordered, first group is primary group. From df238f54613dfce8dfbc72347cce1d7315930403 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Sep 2022 11:16:13 +0000 Subject: [PATCH 121/269] Bump checker-qual from 3.24.0 to 3.25.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.24.0 to 3.25.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.24.0...checker-framework-3.25.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 429099fe..3358d812 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.24.0 + 3.25.0 From 5658f96f5d9fdce5aa4c7dbe5bfb0674406c21b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Sep 2022 11:14:06 +0000 Subject: [PATCH 122/269] Bump slf4j-api from 2.0.0 to 2.0.2 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.0 to 2.0.2. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/commits) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3358d812..17b082fc 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.0 + 2.0.2 provided From 0b0fdd4df06fb68a287d72513ae87ef675f8cb22 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Sep 2022 11:20:35 +0000 Subject: [PATCH 123/269] Bump slf4j-api from 2.0.2 to 2.0.3 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.2...v_2.0.3) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 17b082fc..78e3114d 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.2 + 2.0.3 provided From 83db999590ceca06fb039eea806945e8d7b5109d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Oct 2022 11:18:56 +0000 Subject: [PATCH 124/269] Bump checker-qual from 3.25.0 to 3.26.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.25.0 to 3.26.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.25.0...checker-framework-3.26.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 78e3114d..84c90c0b 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.25.0 + 3.26.0 From 616670883099af1afca6702863f0f19f3650f0ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:11:14 +0000 Subject: [PATCH 125/269] Bump gson from 2.9.1 to 2.10 Bumps [gson](https://github.com/google/gson) from 2.9.1 to 2.10. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.9.1...gson-parent-2.10) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84c90c0b..3ce51dd8 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ com.google.code.gson gson - 2.9.1 + 2.10 From 3cc2a5141172c041e1abd05509fd754b6a2a49da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 11:39:30 +0000 Subject: [PATCH 126/269] Bump checker-qual from 3.26.0 to 3.27.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.26.0 to 3.27.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.26.0...checker-framework-3.27.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ce51dd8..232cfe81 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.26.0 + 3.27.0 From 9cb9af14423b9395d633507975b2dce0c1ca1d1f Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 15 Nov 2022 22:27:05 +0100 Subject: [PATCH 127/269] Fix nullability warning --- src/com/namelessmc/java_api/NamelessVersion.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index 04825c96..e9f7716c 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -24,29 +24,25 @@ public enum NamelessVersion { V2_0 ); - private final @Nullable String name; // Only for pre-releases that use literal name matching + private final @Nullable String exactMatchName; // Only for pre-releases private final @NonNull String friendlyName; private final int major; private final int minor; private final boolean preRelease; @SuppressWarnings("SameParameterValue") - NamelessVersion(final @Nullable String name, + NamelessVersion(final @Nullable String exactMatchName, final @NonNull String friendlyName, final int major, final int minor, final boolean preRelease) { - this.name = name; + this.exactMatchName = exactMatchName; this.friendlyName = friendlyName; this.major = major; this.minor = minor; this.preRelease = preRelease; } - public @Nullable String preReleaseName() { - return this.name; - } - public @NonNull String friendlyName() { return this.friendlyName; } @@ -77,8 +73,8 @@ public String toString() { static { for (final NamelessVersion version : allVersions()) { - if (version.isPreRelease()) { - BY_NAME.put(version.preReleaseName(), version); + if (version.exactMatchName != null) { + BY_NAME.put(version.exactMatchName, version); } } } From 92ead751fe7074ed48183447cfdefcd6fb623db5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Nov 2022 11:02:05 +0000 Subject: [PATCH 128/269] Bump slf4j-api from 2.0.3 to 2.0.4 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.3 to 2.0.4. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.3...v_2.0.4) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 232cfe81..1b75dec3 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.3 + 2.0.4 provided From f6d0181020bdff036b045f11c0c32a78a7fc3c1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Nov 2022 11:02:53 +0000 Subject: [PATCH 129/269] Bump slf4j-api from 2.0.4 to 2.0.5 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.4 to 2.0.5. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.4...v_2.0.5) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1b75dec3..78137dcb 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.4 + 2.0.5 provided From 51aabbfdc78dc97bbdba81354e198a71ef4c894e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:02:14 +0000 Subject: [PATCH 130/269] Bump checker-qual from 3.27.0 to 3.28.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.27.0 to 3.28.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.27.0...checker-framework-3.28.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 78137dcb..9563d2bf 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.27.0 + 3.28.0 From dd0750e3c266a9f6c9c6c7547e09271d74d716df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Dec 2022 11:02:25 +0000 Subject: [PATCH 131/269] Bump slf4j-api from 2.0.5 to 2.0.6 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.5 to 2.0.6. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.5...v_2.0.6) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9563d2bf..0c8f945d 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.5 + 2.0.6 provided From 89b0c2933ce7f085a80926387f758de6d09a9d02 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 20 Dec 2022 12:07:37 +0100 Subject: [PATCH 132/269] Relicense under LGPLv3 --- LICENSE | 186 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 165 insertions(+), 21 deletions(-) diff --git a/LICENSE b/LICENSE index de7a1b38..0a041280 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,165 @@ -MIT License - -Copyright (c) 2017-2022 NamelessMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. From 226b36e59395856e62fad5c47b121bfe201a93d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 11:02:05 +0000 Subject: [PATCH 133/269] Bump checker-qual from 3.28.0 to 3.29.0 Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.28.0 to 3.29.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.28.0...checker-framework-3.29.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c8f945d..c7619463 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.28.0 + 3.29.0 From 3aa8e55cada2885084187b1936b01e3d51ccd8db Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 9 Jan 2023 11:32:43 +0100 Subject: [PATCH 134/269] Retry when GOAWAY is received --- src/com/namelessmc/java_api/RequestHandler.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 34e81fb4..9255544a 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -129,8 +129,20 @@ private void debug(final @NonNull Supplier messageSupplier) { int statusCode; String responseBody; try { - HttpResponse httpResponse = httpClient.send(request, - HttpResponse.BodyHandlers.ofInputStream()); + HttpResponse httpResponse; + try { + httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); + } catch (final IOException e) { + // Receiving a GOAWAY means the connection should be retried. For some reason, the Java + // HTTP client doesn't. See also: https://stackoverflow.com/a/55092354 + if (e.getMessage() != null && e.getMessage().contains("GOAWAY received")) { + // Manually retry, once + debug(() -> "Retrying after receiving GOAWAY"); + httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); + } else { + throw e; + } + } statusCode = httpResponse.statusCode(); responseBody = getBodyAsString(httpResponse); } catch (final IOException e) { From c51552fca8fbb943e602ae6d283443a9a4ff439a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 11:04:41 +0000 Subject: [PATCH 135/269] Bump gson from 2.10 to 2.10.1 Bumps [gson](https://github.com/google/gson) from 2.10 to 2.10.1. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.10...gson-parent-2.10.1) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c7619463..205dcaa0 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ com.google.code.gson gson - 2.10 + 2.10.1 From 6684b5425ea79edea8e9216a8e494e0ed4a64a53 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 10 Jan 2023 20:23:03 +0100 Subject: [PATCH 136/269] Re-throw InterruptedException as NamelessException --- src/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 9255544a..671caacc 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -170,7 +170,7 @@ private void debug(final @NonNull Supplier messageSupplier) { throw new NamelessException(message.toString(), e); } catch (InterruptedException e) { - throw new RuntimeException(e); + throw new NamelessException("In-progress request was aborted", e); } debug(() -> "Website response body, after " + (System.currentTimeMillis() - requestStartTime) + "ms:\n" + regularAsciiOnly(responseBody)); From 6a523163bf49e991099f98cf5c9039e602d39598 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 11 Jan 2023 21:21:58 +0100 Subject: [PATCH 137/269] Explicitly allow TLSv1.3 --- src/com/namelessmc/java_api/NamelessApiBuilder.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 4634a9c6..35e7bb8b 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -8,6 +8,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; +import javax.net.ssl.SSLParameters; import java.net.Authenticator; import java.net.MalformedURLException; import java.net.ProxySelector; @@ -18,6 +19,12 @@ public class NamelessApiBuilder { + private static final SSLParameters SSL_PARAMETERS = new SSLParameters(); + + static { + SSL_PARAMETERS.setProtocols(new String[]{"TLSv1.3", "TLSv1.2"}); + } + private final @NonNull URL apiUrl; private final @NonNull String apiKey; @@ -86,7 +93,7 @@ public NamelessApiBuilder responseSizeLimit(int responseSizeLimitBytes) { return this; } - public NamelessApiBuilder httpversion(final HttpClient. @Nullable Version httpVersion) { + public NamelessApiBuilder httpVersion(final HttpClient. @Nullable Version httpVersion) { this.httpVersion = httpVersion; return this; } @@ -110,6 +117,8 @@ public NamelessAPI build() { methanolBuilder.version(this.httpVersion); } + methanolBuilder.sslParameters(SSL_PARAMETERS); + GsonBuilder gsonBuilder = new GsonBuilder() .disableHtmlEscaping(); From 7a24c4a8187f4212768a0c45dd08b09f51609711 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 15 Jan 2023 18:04:45 +0100 Subject: [PATCH 138/269] Allow specifying URL parameter without value --- .../namelessmc/java_api/RequestHandler.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/com/namelessmc/java_api/RequestHandler.java index 671caacc..f21065a6 100644 --- a/src/com/namelessmc/java_api/RequestHandler.java +++ b/src/com/namelessmc/java_api/RequestHandler.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URL; import java.net.URLEncoder; @@ -54,32 +53,32 @@ public Gson gson() { return this.gson; } - public @NonNull JsonObject post(final @NonNull String route, - final @NonNull JsonObject postData) throws NamelessException { + public JsonObject post(final String route, + final JsonObject postData) throws NamelessException { return makeConnection(route, postData); } - public @NonNull JsonObject get(final @NonNull String route, - final @NonNull Object @NonNull... parameters) throws NamelessException { + public JsonObject get(final String route, + final @Nullable Object... parameters) throws NamelessException { final StringBuilder urlBuilder = new StringBuilder(route); if (parameters.length > 0) { if (parameters.length % 2 != 0) { - final String paramString = Arrays.stream(parameters).map(Object::toString).collect(Collectors.joining("|")); + final String paramString = Arrays.stream(parameters).map(Objects::toString).collect(Collectors.joining("|")); throw new IllegalArgumentException(String.format("Parameter string varargs array length must be even (length is %s - %s)", parameters.length, paramString)); } for (int i = 0; i < parameters.length; i++) { + Object param = parameters[i]; if (i % 2 == 0) { + if (param == null) { + throw new IllegalArgumentException("Parameter keys must never be null, only values may be null"); + } urlBuilder.append("&"); - urlBuilder.append(parameters[i]); - } else { + urlBuilder.append(param); + } else if (param != null) { urlBuilder.append("="); - try { - urlBuilder.append(URLEncoder.encode(parameters[i].toString(), StandardCharsets.UTF_8.toString())); - } catch (final UnsupportedEncodingException e) { - throw new RuntimeException(e); - } + urlBuilder.append(URLEncoder.encode(param.toString(), StandardCharsets.UTF_8)); } } } From 8144b5b79c0a881b851f4979f79e2ec29006e39b Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 15 Jan 2023 18:08:23 +0100 Subject: [PATCH 139/269] Ask for groups in user list request --- src/com/namelessmc/java_api/FilteredUserListBuilder.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/com/namelessmc/java_api/FilteredUserListBuilder.java index 57a46af2..5ab83250 100644 --- a/src/com/namelessmc/java_api/FilteredUserListBuilder.java +++ b/src/com/namelessmc/java_api/FilteredUserListBuilder.java @@ -46,8 +46,8 @@ public JsonObject makeRawRequest() throws NamelessException { final Object[] parameters; if (filters != null) { int filterCount = filters.size(); - parameters = new Object[4 + filterCount * 2]; - int i = 0; + parameters = new Object[2 + 4 + filterCount * 2]; + int i = 2; parameters[i++] = "operator"; parameters[i++] = operator; parameters[i++] = "limit"; @@ -57,9 +57,11 @@ public JsonObject makeRawRequest() throws NamelessException { parameters[i++] = filter.getValue(); } } else { - parameters = new Object[0]; + parameters = new Object[2]; } + parameters[0] = "groups"; // Request NamelessMC to include groups in response + return this.api.requests().get("users", parameters); } @@ -68,7 +70,6 @@ public JsonObject makeRawRequest() throws NamelessException { final JsonArray array = response.getAsJsonArray("users"); final List users = new ArrayList<>(array.size()); for (final JsonElement e : array) { - final JsonObject o = e.getAsJsonObject(); users.add(new NamelessUser(this.api, e.getAsJsonObject())); } return Collections.unmodifiableList(users); From a4ac98e3a9b6afecbc8b7b33cca6fdc827b6d5c0 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Fri, 20 Jan 2023 17:16:39 +0100 Subject: [PATCH 140/269] Transaction is nullable --- .../namelessmc/java_api/modules/store/StorePayment.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/namelessmc/java_api/modules/store/StorePayment.java b/src/com/namelessmc/java_api/modules/store/StorePayment.java index a6fe1e19..f8f53f7e 100644 --- a/src/com/namelessmc/java_api/modules/store/StorePayment.java +++ b/src/com/namelessmc/java_api/modules/store/StorePayment.java @@ -4,6 +4,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.util.GsonHelper; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.ArrayList; import java.util.Date; @@ -14,7 +16,7 @@ public class StorePayment { private final int id; private final int orderId; private final int gatewayId; - private final String transaction; + private final @Nullable String transaction; private final String amount; private final String currency; private final String fee; @@ -29,7 +31,7 @@ public class StorePayment { this.id = json.get("id").getAsInt(); this.orderId = json.get("order_id").getAsInt(); this.gatewayId = json.get("gateway_id").getAsInt(); - this.transaction = json.get("transaction").getAsString(); + this.transaction = GsonHelper.getNullableString(json, "transaction"); this.amount = json.get("amount").getAsString(); this.currency = json.get("currency").getAsString(); this.fee = json.get("fee").getAsString(); @@ -58,7 +60,7 @@ public int gatewayId() { return gatewayId; } - public String transaction() { + public @Nullable String transaction() { return transaction; } From 1378fdf399e9c09e3a7518c9b062214dc3f7e1f8 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Sat, 21 Jan 2023 14:53:36 +0100 Subject: [PATCH 141/269] Also send fallback X-API-Key header --- src/com/namelessmc/java_api/NamelessApiBuilder.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/com/namelessmc/java_api/NamelessApiBuilder.java index 35e7bb8b..d28fe380 100644 --- a/src/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/com/namelessmc/java_api/NamelessApiBuilder.java @@ -100,7 +100,10 @@ public NamelessApiBuilder httpVersion(final HttpClient. @Nullable Version httpVe public NamelessAPI build() { final Methanol.Builder methanolBuilder = Methanol.newBuilder() - .defaultHeader("Authorization", "Bearer " + this.apiKey) + .defaultHeaders( + "Authorization", "Bearer " + this.apiKey, + "X-API-Key", this.apiKey + ) .userAgent(this.userAgent) .autoAcceptEncoding(true) .readTimeout(this.timeout) From 915723735f74b8452ee1e4871e4be4db2d3608ab Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Mon, 23 Jan 2023 23:08:39 +0100 Subject: [PATCH 142/269] Add minecraft/update-groups endpoint --- src/com/namelessmc/java_api/NamelessAPI.java | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 4bd46081..731fc1ed 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -1,5 +1,6 @@ package com.namelessmc.java_api; +import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -19,10 +20,7 @@ import java.math.BigInteger; import java.net.URL; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -88,6 +86,26 @@ public void submitServerInfo(final @NonNull JsonObject jsonData) throws Nameless this.requests.post("minecraft/server-info", jsonData); } + /** + * Send Minecraft groups to website. Only available in Nameless 2.1.0+ + * @param groups + * @throws NamelessException + */ + public void sendMinecraftGroups(final Map> groups) throws NamelessException { + final JsonObject groupsJson = new JsonObject(); + final Gson gson = this.requests().gson(); + groups.forEach((uuid, playerGroups) -> { + final JsonObject playerGroupsObject = new JsonObject(); + playerGroupsObject.add("groups", gson.toJsonTree(playerGroups)); + groupsJson.add(uuid.toString(), playerGroupsObject); + }); + + JsonObject body = new JsonObject(); + body.add("player_groups", groupsJson); + + this.requests.post("minecraft/update-groups", body); + } + /** * Get website information * @return {@link Website} object containing website information From 2f84731e67d7256fc45d406d89371749a498b1ed Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Mon, 23 Jan 2023 23:15:40 +0100 Subject: [PATCH 143/269] Include server id in request --- src/com/namelessmc/java_api/NamelessAPI.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 731fc1ed..2af45ad9 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -91,7 +91,7 @@ public void submitServerInfo(final @NonNull JsonObject jsonData) throws Nameless * @param groups * @throws NamelessException */ - public void sendMinecraftGroups(final Map> groups) throws NamelessException { + public void sendMinecraftGroups(final int serverId, final Map> groups) throws NamelessException { final JsonObject groupsJson = new JsonObject(); final Gson gson = this.requests().gson(); groups.forEach((uuid, playerGroups) -> { @@ -101,6 +101,7 @@ public void sendMinecraftGroups(final Map> groups) throws Name }); JsonObject body = new JsonObject(); + body.addProperty("server_id", serverId); body.add("player_groups", groupsJson); this.requests.post("minecraft/update-groups", body); From 646cfdfd1c00ddc791cee457ffc5762964e6a3c0 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Mon, 23 Jan 2023 23:34:57 +0100 Subject: [PATCH 144/269] Add v2.1.0 --- src/com/namelessmc/java_api/NamelessVersion.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index e9f7716c..e3255c83 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -16,6 +16,7 @@ public enum NamelessVersion { V2_0_0_PR_12("2.0.0-pr12", "2.0.0 pre-release 12", 2, 0, true), V2_0_0_PR_13("2.0.0-pr13", "2.0.0 pre-release 13", 2, 0, true), V2_0(null, "2.0.*", 2, 0, false), + V2_1(null, "2.1.*", 2, 1, false), ; From 2b15476a7c843c71946f7aa4dfa1906d8b044e55 Mon Sep 17 00:00:00 2001 From: Tadhg Boyle Date: Sat, 28 Jan 2023 01:27:26 -0800 Subject: [PATCH 145/269] Remove dashes from UUID (#61) --- src/com/namelessmc/java_api/NamelessAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/com/namelessmc/java_api/NamelessAPI.java index 2af45ad9..08961728 100755 --- a/src/com/namelessmc/java_api/NamelessAPI.java +++ b/src/com/namelessmc/java_api/NamelessAPI.java @@ -97,7 +97,7 @@ public void sendMinecraftGroups(final int serverId, final Map> groups.forEach((uuid, playerGroups) -> { final JsonObject playerGroupsObject = new JsonObject(); playerGroupsObject.add("groups", gson.toJsonTree(playerGroups)); - groupsJson.add(uuid.toString(), playerGroupsObject); + groupsJson.add(javaUuidToWebsiteUuid(uuid), playerGroupsObject); }); JsonObject body = new JsonObject(); From d6e33fc33e0352cc8d79dc0e66462c6f71bf362a Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Sat, 28 Jan 2023 10:29:42 +0100 Subject: [PATCH 146/269] NamelessMC v2.1.0 is supported --- src/com/namelessmc/java_api/NamelessVersion.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/com/namelessmc/java_api/NamelessVersion.java index e3255c83..032d51fd 100644 --- a/src/com/namelessmc/java_api/NamelessVersion.java +++ b/src/com/namelessmc/java_api/NamelessVersion.java @@ -22,7 +22,8 @@ public enum NamelessVersion { private static final Set SUPPORTED_VERSIONS = EnumSet.of( V2_0_0_PR_13, - V2_0 + V2_0, + V2_1 ); private final @Nullable String exactMatchName; // Only for pre-releases From 0b9b8648e033be411fdb1f9dce5ff4548abc044e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Feb 2023 10:40:53 +0100 Subject: [PATCH 147/269] Bump checker-qual from 3.29.0 to 3.30.0 (#62) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.29.0 to 3.30.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.29.0...checker-framework-3.30.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 205dcaa0..404cc97b 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.29.0 + 3.30.0 From cd5f2959d0208c841a6542cfb130e3f119c4daf7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Feb 2023 16:32:45 +0100 Subject: [PATCH 148/269] Bump checker-qual from 3.30.0 to 3.31.0 (#63) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.30.0 to 3.31.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.30.0...checker-framework-3.31.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 404cc97b..9a4eeae0 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.30.0 + 3.31.0 From 221bc95cb595af8e04dbdf1807bb332a868057cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Feb 2023 13:08:49 +0100 Subject: [PATCH 149/269] Bump maven-compiler-plugin from 3.10.1 to 3.11.0 (#64) Bumps [maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.10.1 to 3.11.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.10.1...maven-compiler-plugin-3.11.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a4eeae0..0889d00f 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.11.0 11 11 From ad4ae3fc06d9893e1d478449be8a4485a8d76502 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 13:12:38 +0100 Subject: [PATCH 150/269] Bump checker from 3.21.4 to 3.31.0 (#65) Bumps [checker](https://github.com/typetools/checker-framework) from 3.21.4 to 3.31.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.21.4...checker-framework-3.31.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0889d00f..5224138a 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.checkerframework checker - 3.21.4 + 3.31.0 From 5f6db5a2e0ec13a7f0ea58bc0841b0b693ae1306 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Mar 2023 13:46:15 +0100 Subject: [PATCH 151/269] Bump checker-qual from 3.31.0 to 3.32.0 (#67) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.31.0 to 3.32.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.31.0...checker-framework-3.32.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5224138a..839ed0dc 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ org.checkerframework checker-qual - 3.31.0 + 3.32.0 From dadedf45d84219f23efb53392467e692ab2c9fcf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Mar 2023 13:47:08 +0100 Subject: [PATCH 152/269] Bump checker from 3.31.0 to 3.32.0 (#66) Bumps [checker](https://github.com/typetools/checker-framework) from 3.31.0 to 3.32.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.31.0...checker-framework-3.32.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 839ed0dc..e04be44b 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.checkerframework checker - 3.31.0 + 3.32.0 From 09542474f9ec68324675ceaf501a9e0840880760 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Sat, 11 Mar 2023 16:19:37 +0100 Subject: [PATCH 153/269] Add TLS 1.3 test --- pom.xml | 13 ++++++++++-- .../com/namelessmc/java_api/Announcement.java | 0 .../java_api/CustomProfileField.java | 0 .../java_api/CustomProfileFieldType.java | 0 .../java_api/CustomProfileFieldValue.java | 0 .../java_api/FilteredUserListBuilder.java | 0 .../java}/com/namelessmc/java_api/Group.java | 0 .../namelessmc/java_api/LanguageEntity.java | 0 .../com/namelessmc/java_api/NamelessAPI.java | 0 .../java_api/NamelessApiBuilder.java | 0 .../com/namelessmc/java_api/NamelessUser.java | 0 .../namelessmc/java_api/NamelessVersion.java | 0 .../com/namelessmc/java_api/Notification.java | 0 .../namelessmc/java_api/RequestHandler.java | 0 .../com/namelessmc/java_api/UserFilter.java | 0 .../namelessmc/java_api/VerificationInfo.java | 0 .../com/namelessmc/java_api/Website.java | 0 .../java_api/exception/ApiError.java | 0 .../java_api/exception/ApiException.java | 0 .../exception/MissingModuleException.java | 0 .../java_api/exception/NamelessException.java | 0 .../UnknownNamelessVersionException.java | 0 .../DetailedDiscordIntegrationData.java | 0 .../integrations/DetailedIntegrationData.java | 0 .../DetailedMinecraftIntegrationData.java | 0 .../integrations/DiscordIntegrationData.java | 0 .../integrations/IDiscordIntegrationData.java | 0 .../IMinecraftIntegrationData.java | 0 .../integrations/IntegrationData.java | 0 .../MinecraftIntegrationData.java | 0 .../StandardIntegrationTypes.java | 0 .../namelessmc/java_api/logger/ApiLogger.java | 0 .../java_api/logger/JavaLoggerLogger.java | 0 .../java_api/logger/PrintStreamLogger.java | 0 .../java_api/logger/Slf4jLogger.java | 0 .../java_api/modules/NamelessModule.java | 0 .../java_api/modules/discord/DiscordAPI.java | 0 .../java_api/modules/discord/DiscordUser.java | 0 .../java_api/modules/store/PaymentStatus.java | 0 .../modules/store/PaymentsFilter.java | 0 .../store/PendingCommandsResponse.java | 0 .../java_api/modules/store/StoreAPI.java | 0 .../java_api/modules/store/StoreCategory.java | 0 .../java_api/modules/store/StoreCustomer.java | 0 .../java_api/modules/store/StorePayment.java | 0 .../modules/store/StorePaymentProduct.java | 0 .../java_api/modules/store/StoreProduct.java | 0 .../modules/store/StoreProductAction.java | 0 .../modules/store/StoreProductField.java | 0 .../java_api/modules/store/StoreUser.java | 0 .../modules/suggestions/Suggestion.java | 0 .../suggestions/SuggestionCategory.java | 0 .../modules/suggestions/SuggestionStatus.java | 0 .../modules/suggestions/SuggestionUser.java | 0 .../modules/suggestions/SuggestionsAPI.java | 0 .../modules/suggestions/SuggestionsUser.java | 0 .../java_api/modules/websend/WebsendAPI.java | 0 .../modules/websend/WebsendCommand.java | 0 .../namelessmc/java_api/util/GsonHelper.java | 0 src/test/java/TestTls.java | 21 +++++++++++++++++++ 60 files changed, 32 insertions(+), 2 deletions(-) rename src/{ => main/java}/com/namelessmc/java_api/Announcement.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/CustomProfileField.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/CustomProfileFieldType.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/CustomProfileFieldValue.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/FilteredUserListBuilder.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/Group.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/LanguageEntity.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/NamelessAPI.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/NamelessApiBuilder.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/NamelessUser.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/NamelessVersion.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/Notification.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/RequestHandler.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/UserFilter.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/VerificationInfo.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/Website.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/exception/ApiError.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/exception/ApiException.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/exception/MissingModuleException.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/exception/NamelessException.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/DetailedIntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/DiscordIntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/IntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/logger/ApiLogger.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/logger/JavaLoggerLogger.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/logger/PrintStreamLogger.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/logger/Slf4jLogger.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/NamelessModule.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/discord/DiscordAPI.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/discord/DiscordUser.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/PaymentStatus.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/PaymentsFilter.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StoreAPI.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StoreCategory.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StoreCustomer.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StorePayment.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StorePaymentProduct.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StoreProduct.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StoreProductAction.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StoreProductField.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/store/StoreUser.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/suggestions/Suggestion.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/websend/WebsendAPI.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/modules/websend/WebsendCommand.java (100%) rename src/{ => main/java}/com/namelessmc/java_api/util/GsonHelper.java (100%) create mode 100644 src/test/java/TestTls.java diff --git a/pom.xml b/pom.xml index e04be44b..ede7d498 100644 --- a/pom.xml +++ b/pom.xml @@ -14,8 +14,6 @@ - src - org.apache.maven.plugins @@ -56,6 +54,10 @@ + + maven-surefire-plugin + 3.0.0-M9 + @@ -92,6 +94,13 @@ 1.7.0 + + org.junit.jupiter + junit-jupiter-engine + 5.9.2 + test + + diff --git a/src/com/namelessmc/java_api/Announcement.java b/src/main/java/com/namelessmc/java_api/Announcement.java similarity index 100% rename from src/com/namelessmc/java_api/Announcement.java rename to src/main/java/com/namelessmc/java_api/Announcement.java diff --git a/src/com/namelessmc/java_api/CustomProfileField.java b/src/main/java/com/namelessmc/java_api/CustomProfileField.java similarity index 100% rename from src/com/namelessmc/java_api/CustomProfileField.java rename to src/main/java/com/namelessmc/java_api/CustomProfileField.java diff --git a/src/com/namelessmc/java_api/CustomProfileFieldType.java b/src/main/java/com/namelessmc/java_api/CustomProfileFieldType.java similarity index 100% rename from src/com/namelessmc/java_api/CustomProfileFieldType.java rename to src/main/java/com/namelessmc/java_api/CustomProfileFieldType.java diff --git a/src/com/namelessmc/java_api/CustomProfileFieldValue.java b/src/main/java/com/namelessmc/java_api/CustomProfileFieldValue.java similarity index 100% rename from src/com/namelessmc/java_api/CustomProfileFieldValue.java rename to src/main/java/com/namelessmc/java_api/CustomProfileFieldValue.java diff --git a/src/com/namelessmc/java_api/FilteredUserListBuilder.java b/src/main/java/com/namelessmc/java_api/FilteredUserListBuilder.java similarity index 100% rename from src/com/namelessmc/java_api/FilteredUserListBuilder.java rename to src/main/java/com/namelessmc/java_api/FilteredUserListBuilder.java diff --git a/src/com/namelessmc/java_api/Group.java b/src/main/java/com/namelessmc/java_api/Group.java similarity index 100% rename from src/com/namelessmc/java_api/Group.java rename to src/main/java/com/namelessmc/java_api/Group.java diff --git a/src/com/namelessmc/java_api/LanguageEntity.java b/src/main/java/com/namelessmc/java_api/LanguageEntity.java similarity index 100% rename from src/com/namelessmc/java_api/LanguageEntity.java rename to src/main/java/com/namelessmc/java_api/LanguageEntity.java diff --git a/src/com/namelessmc/java_api/NamelessAPI.java b/src/main/java/com/namelessmc/java_api/NamelessAPI.java similarity index 100% rename from src/com/namelessmc/java_api/NamelessAPI.java rename to src/main/java/com/namelessmc/java_api/NamelessAPI.java diff --git a/src/com/namelessmc/java_api/NamelessApiBuilder.java b/src/main/java/com/namelessmc/java_api/NamelessApiBuilder.java similarity index 100% rename from src/com/namelessmc/java_api/NamelessApiBuilder.java rename to src/main/java/com/namelessmc/java_api/NamelessApiBuilder.java diff --git a/src/com/namelessmc/java_api/NamelessUser.java b/src/main/java/com/namelessmc/java_api/NamelessUser.java similarity index 100% rename from src/com/namelessmc/java_api/NamelessUser.java rename to src/main/java/com/namelessmc/java_api/NamelessUser.java diff --git a/src/com/namelessmc/java_api/NamelessVersion.java b/src/main/java/com/namelessmc/java_api/NamelessVersion.java similarity index 100% rename from src/com/namelessmc/java_api/NamelessVersion.java rename to src/main/java/com/namelessmc/java_api/NamelessVersion.java diff --git a/src/com/namelessmc/java_api/Notification.java b/src/main/java/com/namelessmc/java_api/Notification.java similarity index 100% rename from src/com/namelessmc/java_api/Notification.java rename to src/main/java/com/namelessmc/java_api/Notification.java diff --git a/src/com/namelessmc/java_api/RequestHandler.java b/src/main/java/com/namelessmc/java_api/RequestHandler.java similarity index 100% rename from src/com/namelessmc/java_api/RequestHandler.java rename to src/main/java/com/namelessmc/java_api/RequestHandler.java diff --git a/src/com/namelessmc/java_api/UserFilter.java b/src/main/java/com/namelessmc/java_api/UserFilter.java similarity index 100% rename from src/com/namelessmc/java_api/UserFilter.java rename to src/main/java/com/namelessmc/java_api/UserFilter.java diff --git a/src/com/namelessmc/java_api/VerificationInfo.java b/src/main/java/com/namelessmc/java_api/VerificationInfo.java similarity index 100% rename from src/com/namelessmc/java_api/VerificationInfo.java rename to src/main/java/com/namelessmc/java_api/VerificationInfo.java diff --git a/src/com/namelessmc/java_api/Website.java b/src/main/java/com/namelessmc/java_api/Website.java similarity index 100% rename from src/com/namelessmc/java_api/Website.java rename to src/main/java/com/namelessmc/java_api/Website.java diff --git a/src/com/namelessmc/java_api/exception/ApiError.java b/src/main/java/com/namelessmc/java_api/exception/ApiError.java similarity index 100% rename from src/com/namelessmc/java_api/exception/ApiError.java rename to src/main/java/com/namelessmc/java_api/exception/ApiError.java diff --git a/src/com/namelessmc/java_api/exception/ApiException.java b/src/main/java/com/namelessmc/java_api/exception/ApiException.java similarity index 100% rename from src/com/namelessmc/java_api/exception/ApiException.java rename to src/main/java/com/namelessmc/java_api/exception/ApiException.java diff --git a/src/com/namelessmc/java_api/exception/MissingModuleException.java b/src/main/java/com/namelessmc/java_api/exception/MissingModuleException.java similarity index 100% rename from src/com/namelessmc/java_api/exception/MissingModuleException.java rename to src/main/java/com/namelessmc/java_api/exception/MissingModuleException.java diff --git a/src/com/namelessmc/java_api/exception/NamelessException.java b/src/main/java/com/namelessmc/java_api/exception/NamelessException.java similarity index 100% rename from src/com/namelessmc/java_api/exception/NamelessException.java rename to src/main/java/com/namelessmc/java_api/exception/NamelessException.java diff --git a/src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java b/src/main/java/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java similarity index 100% rename from src/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java rename to src/main/java/com/namelessmc/java_api/exception/UnknownNamelessVersionException.java diff --git a/src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/DetailedDiscordIntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/DetailedIntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/DetailedIntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/DetailedIntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/DetailedMinecraftIntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/DiscordIntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/DiscordIntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/DiscordIntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/IDiscordIntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/IMinecraftIntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/IntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/IntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/IntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/IntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java b/src/main/java/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java rename to src/main/java/com/namelessmc/java_api/integrations/MinecraftIntegrationData.java diff --git a/src/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java b/src/main/java/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java similarity index 100% rename from src/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java rename to src/main/java/com/namelessmc/java_api/integrations/StandardIntegrationTypes.java diff --git a/src/com/namelessmc/java_api/logger/ApiLogger.java b/src/main/java/com/namelessmc/java_api/logger/ApiLogger.java similarity index 100% rename from src/com/namelessmc/java_api/logger/ApiLogger.java rename to src/main/java/com/namelessmc/java_api/logger/ApiLogger.java diff --git a/src/com/namelessmc/java_api/logger/JavaLoggerLogger.java b/src/main/java/com/namelessmc/java_api/logger/JavaLoggerLogger.java similarity index 100% rename from src/com/namelessmc/java_api/logger/JavaLoggerLogger.java rename to src/main/java/com/namelessmc/java_api/logger/JavaLoggerLogger.java diff --git a/src/com/namelessmc/java_api/logger/PrintStreamLogger.java b/src/main/java/com/namelessmc/java_api/logger/PrintStreamLogger.java similarity index 100% rename from src/com/namelessmc/java_api/logger/PrintStreamLogger.java rename to src/main/java/com/namelessmc/java_api/logger/PrintStreamLogger.java diff --git a/src/com/namelessmc/java_api/logger/Slf4jLogger.java b/src/main/java/com/namelessmc/java_api/logger/Slf4jLogger.java similarity index 100% rename from src/com/namelessmc/java_api/logger/Slf4jLogger.java rename to src/main/java/com/namelessmc/java_api/logger/Slf4jLogger.java diff --git a/src/com/namelessmc/java_api/modules/NamelessModule.java b/src/main/java/com/namelessmc/java_api/modules/NamelessModule.java similarity index 100% rename from src/com/namelessmc/java_api/modules/NamelessModule.java rename to src/main/java/com/namelessmc/java_api/modules/NamelessModule.java diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordAPI.java b/src/main/java/com/namelessmc/java_api/modules/discord/DiscordAPI.java similarity index 100% rename from src/com/namelessmc/java_api/modules/discord/DiscordAPI.java rename to src/main/java/com/namelessmc/java_api/modules/discord/DiscordAPI.java diff --git a/src/com/namelessmc/java_api/modules/discord/DiscordUser.java b/src/main/java/com/namelessmc/java_api/modules/discord/DiscordUser.java similarity index 100% rename from src/com/namelessmc/java_api/modules/discord/DiscordUser.java rename to src/main/java/com/namelessmc/java_api/modules/discord/DiscordUser.java diff --git a/src/com/namelessmc/java_api/modules/store/PaymentStatus.java b/src/main/java/com/namelessmc/java_api/modules/store/PaymentStatus.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/PaymentStatus.java rename to src/main/java/com/namelessmc/java_api/modules/store/PaymentStatus.java diff --git a/src/com/namelessmc/java_api/modules/store/PaymentsFilter.java b/src/main/java/com/namelessmc/java_api/modules/store/PaymentsFilter.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/PaymentsFilter.java rename to src/main/java/com/namelessmc/java_api/modules/store/PaymentsFilter.java diff --git a/src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java b/src/main/java/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java rename to src/main/java/com/namelessmc/java_api/modules/store/PendingCommandsResponse.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreAPI.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreAPI.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StoreAPI.java rename to src/main/java/com/namelessmc/java_api/modules/store/StoreAPI.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreCategory.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreCategory.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StoreCategory.java rename to src/main/java/com/namelessmc/java_api/modules/store/StoreCategory.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreCustomer.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreCustomer.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StoreCustomer.java rename to src/main/java/com/namelessmc/java_api/modules/store/StoreCustomer.java diff --git a/src/com/namelessmc/java_api/modules/store/StorePayment.java b/src/main/java/com/namelessmc/java_api/modules/store/StorePayment.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StorePayment.java rename to src/main/java/com/namelessmc/java_api/modules/store/StorePayment.java diff --git a/src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java b/src/main/java/com/namelessmc/java_api/modules/store/StorePaymentProduct.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StorePaymentProduct.java rename to src/main/java/com/namelessmc/java_api/modules/store/StorePaymentProduct.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreProduct.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreProduct.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StoreProduct.java rename to src/main/java/com/namelessmc/java_api/modules/store/StoreProduct.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreProductAction.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreProductAction.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StoreProductAction.java rename to src/main/java/com/namelessmc/java_api/modules/store/StoreProductAction.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreProductField.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreProductField.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StoreProductField.java rename to src/main/java/com/namelessmc/java_api/modules/store/StoreProductField.java diff --git a/src/com/namelessmc/java_api/modules/store/StoreUser.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java similarity index 100% rename from src/com/namelessmc/java_api/modules/store/StoreUser.java rename to src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java diff --git a/src/com/namelessmc/java_api/modules/suggestions/Suggestion.java b/src/main/java/com/namelessmc/java_api/modules/suggestions/Suggestion.java similarity index 100% rename from src/com/namelessmc/java_api/modules/suggestions/Suggestion.java rename to src/main/java/com/namelessmc/java_api/modules/suggestions/Suggestion.java diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java b/src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java similarity index 100% rename from src/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java rename to src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionCategory.java diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java b/src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java similarity index 100% rename from src/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java rename to src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionStatus.java diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java b/src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java similarity index 100% rename from src/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java rename to src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionUser.java diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java b/src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java similarity index 100% rename from src/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java rename to src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionsAPI.java diff --git a/src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java b/src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java similarity index 100% rename from src/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java rename to src/main/java/com/namelessmc/java_api/modules/suggestions/SuggestionsUser.java diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendAPI.java b/src/main/java/com/namelessmc/java_api/modules/websend/WebsendAPI.java similarity index 100% rename from src/com/namelessmc/java_api/modules/websend/WebsendAPI.java rename to src/main/java/com/namelessmc/java_api/modules/websend/WebsendAPI.java diff --git a/src/com/namelessmc/java_api/modules/websend/WebsendCommand.java b/src/main/java/com/namelessmc/java_api/modules/websend/WebsendCommand.java similarity index 100% rename from src/com/namelessmc/java_api/modules/websend/WebsendCommand.java rename to src/main/java/com/namelessmc/java_api/modules/websend/WebsendCommand.java diff --git a/src/com/namelessmc/java_api/util/GsonHelper.java b/src/main/java/com/namelessmc/java_api/util/GsonHelper.java similarity index 100% rename from src/com/namelessmc/java_api/util/GsonHelper.java rename to src/main/java/com/namelessmc/java_api/util/GsonHelper.java diff --git a/src/test/java/TestTls.java b/src/test/java/TestTls.java new file mode 100644 index 00000000..76e245ca --- /dev/null +++ b/src/test/java/TestTls.java @@ -0,0 +1,21 @@ +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.exception.NamelessException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.net.MalformedURLException; +import java.net.URL; + +public class TestTls { + + @Test + void checkTlsVersion() throws MalformedURLException, NamelessException { + NamelessAPI api = NamelessAPI.builder(new URL("https://check-tls.akamai.io/"), "").build(); + JsonObject response = api.requests().get("v1/tlsinfo.json"); + Assertions.assertEquals(response.get("tls_sni_status").getAsString(), "present"); + Assertions.assertEquals(response.get("tls_version").getAsString(), "tls1.3"); + Assertions.assertEquals(response.get("tls_sni_value").getAsString(), "check-tls.akamai.io"); + } + +} From 31852f0c198da8cd4faf2c98b88335c3adf2af10 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Sat, 11 Mar 2023 16:21:41 +0100 Subject: [PATCH 154/269] Add uuid test --- src/test/java/TestUuid.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/java/TestUuid.java diff --git a/src/test/java/TestUuid.java b/src/test/java/TestUuid.java new file mode 100644 index 00000000..dbce2077 --- /dev/null +++ b/src/test/java/TestUuid.java @@ -0,0 +1,17 @@ +import com.namelessmc.java_api.NamelessAPI; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.UUID; + +public class TestUuid { + + @Test + void testUuidConversion() { + UUID java = UUID.fromString("09948878-fe20-44e3-a072-42c39869dd1f"); + String website = "09948878fe2044e3a07242c39869dd1f"; + Assertions.assertEquals(NamelessAPI.javaUuidToWebsiteUuid(java), website); + Assertions.assertEquals(NamelessAPI.websiteUuidToJavaUuid(website), java); + } + +} From 5f5e2518a32f0d5b3727e8372a91fa006716d23c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:18:44 +0100 Subject: [PATCH 155/269] Bump maven-surefire-plugin from 3.0.0-M9 to 3.0.0 (#68) Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.0.0-M9 to 3.0.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0-M9...surefire-3.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ede7d498..7e4bd30b 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ maven-surefire-plugin - 3.0.0-M9 + 3.0.0 From f83e4db1afa73e253f12a41a8cbc42e29aee3221 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:58:15 +0100 Subject: [PATCH 156/269] Bump slf4j-api from 2.0.6 to 2.0.7 (#69) Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 2.0.6 to 2.0.7. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/commits) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7e4bd30b..d0fe0757 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ org.slf4j slf4j-api - 2.0.6 + 2.0.7 provided From 2fd0794bb5faf2c66d1f28a456256a424e710914 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:33:20 +0200 Subject: [PATCH 157/269] Bump checker-qual from 3.32.0 to 3.33.0 (#70) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.32.0 to 3.33.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.32.0...checker-framework-3.33.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d0fe0757..844b8fe6 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ org.checkerframework checker-qual - 3.32.0 + 3.33.0 From df08b670b2f8c75bf33eeb55b98bd811e493ace5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:33:28 +0200 Subject: [PATCH 158/269] Bump checker from 3.32.0 to 3.33.0 (#71) Bumps [checker](https://github.com/typetools/checker-framework) from 3.32.0 to 3.33.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.32.0...checker-framework-3.33.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 844b8fe6..96fe4d72 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ org.checkerframework checker - 3.32.0 + 3.33.0 From d1d22ce97a813d7ce34b23760c1fb2f723551fce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:56:50 +0200 Subject: [PATCH 159/269] Bump junit-jupiter-engine from 5.9.2 to 5.9.3 (#72) Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.9.2 to 5.9.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.2...r5.9.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 96fe4d72..f8b32651 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ org.junit.jupiter junit-jupiter-engine - 5.9.2 + 5.9.3 test From ae230709935bc985f2f8581d568963df97b08cd4 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Sun, 30 Apr 2023 22:28:26 +0200 Subject: [PATCH 160/269] Add 307 and 308 as redirect status codes --- src/main/java/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/namelessmc/java_api/RequestHandler.java b/src/main/java/com/namelessmc/java_api/RequestHandler.java index f21065a6..1061a85f 100644 --- a/src/main/java/com/namelessmc/java_api/RequestHandler.java +++ b/src/main/java/com/namelessmc/java_api/RequestHandler.java @@ -175,7 +175,7 @@ private void debug(final @NonNull Supplier messageSupplier) { debug(() -> "Website response body, after " + (System.currentTimeMillis() - requestStartTime) + "ms:\n" + regularAsciiOnly(responseBody)); if (responseBody.length() == 0) { - if (statusCode >= 301 && statusCode <= 303) { + if (statusCode == 301 || statusCode == 302 || statusCode == 303 || statusCode == 307 || statusCode == 308) { throw new NamelessException("Website returned a redirect. Please ensure your URL is correct, paying attention to whether it should use HTTP or HTTPS, or whether it should or should not contain 'www.'."); } throw new NamelessException("Website returned empty response with status code " + statusCode); From 4a47a82d79a21bde80d6fdfa36551d8b2db5f7a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 May 2023 17:01:59 +0200 Subject: [PATCH 161/269] Bump checker from 3.33.0 to 3.34.0 (#74) Bumps [checker](https://github.com/typetools/checker-framework) from 3.33.0 to 3.34.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.33.0...checker-framework-3.34.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f8b32651..1fce81a9 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ org.checkerframework checker - 3.33.0 + 3.34.0 From 25551f4ff9dec035c7cc0a70cd6dcc19a27e2626 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 May 2023 17:31:35 +0200 Subject: [PATCH 162/269] Bump checker-qual from 3.33.0 to 3.34.0 (#73) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.33.0 to 3.34.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.33.0...checker-framework-3.34.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1fce81a9..9072777f 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ org.checkerframework checker-qual - 3.33.0 + 3.34.0 From fedb6e9cab211807e30c11b203d4921b73e9b8c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 May 2023 13:32:32 +0000 Subject: [PATCH 163/269] Bump maven-surefire-plugin from 3.0.0 to 3.1.0 (#75) Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0...surefire-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9072777f..f2e9b828 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ maven-surefire-plugin - 3.0.0 + 3.1.0 From 2322552a92ae9b9702c972b9f3b4b5fbcbb10057 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 Jun 2023 23:09:59 +0200 Subject: [PATCH 164/269] Bump checker from 3.34.0 to 3.35.0 (#77) Bumps [checker](https://github.com/typetools/checker-framework) from 3.34.0 to 3.35.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.34.0...checker-framework-3.35.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2e9b828..cfd711e2 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ org.checkerframework checker - 3.34.0 + 3.35.0 From 14c22692fc4e595470df283ab33cf1e8e0554430 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 4 Jun 2023 23:20:47 +0200 Subject: [PATCH 165/269] Bump checker-qual from 3.34.0 to 3.35.0 (#76) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.34.0 to 3.35.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.34.0...checker-framework-3.35.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cfd711e2..f32cbc9c 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ org.checkerframework checker-qual - 3.34.0 + 3.35.0 From 1b54af10c9effe27c73f4738966d37d5b46b83ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:32:30 +0200 Subject: [PATCH 166/269] Bump maven-surefire-plugin from 3.1.0 to 3.1.2 (#78) Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.1.0 to 3.1.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.0...surefire-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f32cbc9c..42589623 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ maven-surefire-plugin - 3.1.0 + 3.1.2 From 0508ed7e246e3144f2c3c0dd66900927d4ab6f1d Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Thu, 29 Jun 2023 14:14:17 +0200 Subject: [PATCH 167/269] Update websend URL to main github page --- .../java/com/namelessmc/java_api/modules/NamelessModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/namelessmc/java_api/modules/NamelessModule.java b/src/main/java/com/namelessmc/java_api/modules/NamelessModule.java index 697dc50c..d09bbaf8 100644 --- a/src/main/java/com/namelessmc/java_api/modules/NamelessModule.java +++ b/src/main/java/com/namelessmc/java_api/modules/NamelessModule.java @@ -15,7 +15,7 @@ public class NamelessModule { public static final NamelessModule COOKIE_CONSENT = new NamelessModule("Cookie Consent", true, null); public static final NamelessModule STORE = new NamelessModule("Store", false, "https://namelessmc.com/resources/resource/139"); - public static final NamelessModule WEBSEND = new NamelessModule("Websend", false, "https://github.com/supercrafter100/Nameless-Websend/archive/refs/heads/master.zip"); + public static final NamelessModule WEBSEND = new NamelessModule("Websend", false, "https://github.com/supercrafter100/Nameless-Websend"); public static final NamelessModule SUGGESTIONS = new NamelessModule("Suggestions", false, "https://namelessmc.com/resources/resource/129"); private final String name; From 4a2f2f100f80960f59bc90a65d1eceece52653a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:55:15 +0200 Subject: [PATCH 168/269] Bump checker from 3.35.0 to 3.36.0 (#80) Bumps [checker](https://github.com/typetools/checker-framework) from 3.35.0 to 3.36.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.35.0...checker-framework-3.36.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 42589623..72438b0f 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ org.checkerframework checker - 3.35.0 + 3.36.0 From 56555e871b68793c52ba949d2bc7d70ff4c8b038 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:55:23 +0200 Subject: [PATCH 169/269] Bump checker-qual from 3.35.0 to 3.36.0 (#79) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.35.0 to 3.36.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.35.0...checker-framework-3.36.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 72438b0f..f3deb798 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ org.checkerframework checker-qual - 3.35.0 + 3.36.0 From 2166b5e84c1b6ef75020ceb9a6c75680fd2eb884 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Tue, 4 Jul 2023 13:57:11 +0200 Subject: [PATCH 170/269] Extract checker framework version to property --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f3deb798..9ff70f74 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ UTF-8 + 3.36.0 @@ -31,7 +32,7 @@ org.checkerframework checker - 3.36.0 + ${checkerFrameworkVersion} @@ -85,7 +86,7 @@ org.checkerframework checker-qual - 3.36.0 + ${checkerFrameworkVersion} From d9b8a6011bfb703a731d0e13398d8a4e64c26736 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 13:30:16 +0200 Subject: [PATCH 171/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.9.3 to 5.10.0 (#81) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.9.3 to 5.10.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9ff70f74..eb48aed4 100644 --- a/pom.xml +++ b/pom.xml @@ -98,7 +98,7 @@ org.junit.jupiter junit-jupiter-engine - 5.9.3 + 5.10.0 test From 08d0823bac41802011e5cc2f380a4fd30a232865 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:51:21 +0200 Subject: [PATCH 172/269] Bump checkerFrameworkVersion from 3.36.0 to 3.37.0 (#82) Bumps `checkerFrameworkVersion` from 3.36.0 to 3.37.0. Updates `org.checkerframework:checker` from 3.36.0 to 3.37.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.36.0...checker-framework-3.37.0) Updates `org.checkerframework:checker-qual` from 3.36.0 to 3.37.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.36.0...checker-framework-3.37.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eb48aed4..4a0baa3a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.36.0 + 3.37.0 From f6847d93382569f386dd1a6cb822bf59a1f80dc1 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Tue, 8 Aug 2023 16:18:54 +0200 Subject: [PATCH 173/269] Improve GOAWAY retry --- .../namelessmc/java_api/RequestHandler.java | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/namelessmc/java_api/RequestHandler.java b/src/main/java/com/namelessmc/java_api/RequestHandler.java index 1061a85f..54ddf84d 100644 --- a/src/main/java/com/namelessmc/java_api/RequestHandler.java +++ b/src/main/java/com/namelessmc/java_api/RequestHandler.java @@ -31,6 +31,8 @@ public class RequestHandler { + private static final int RETRIES = 2; + private final @NonNull URL apiUrl; private final @NonNull Methanol httpClient; private final @Nullable ApiLogger debugLogger; @@ -55,7 +57,7 @@ public Gson gson() { public JsonObject post(final String route, final JsonObject postData) throws NamelessException { - return makeConnection(route, postData); + return makeConnection(route, postData, RETRIES); } public JsonObject get(final String route, @@ -83,7 +85,7 @@ public JsonObject get(final String route, } } - return makeConnection(urlBuilder.toString(), null); + return makeConnection(urlBuilder.toString(), null, RETRIES); } private void debug(final @NonNull String message) { @@ -99,7 +101,8 @@ private void debug(final @NonNull Supplier messageSupplier) { } private @NonNull JsonObject makeConnection(final @NonNull String route, - final @Nullable JsonObject postBody) throws NamelessException { + final @Nullable JsonObject postBody, + final int retries) throws NamelessException { Preconditions.checkArgument(!route.startsWith("/"), "Route must not start with a slash"); final URI uri = URI.create(this.apiUrl + route); if (uri.getHost() == null) { @@ -125,23 +128,10 @@ private void debug(final @NonNull Supplier messageSupplier) { request.header("Accept", "application/json"); - int statusCode; - String responseBody; + final int statusCode; + final String responseBody; try { - HttpResponse httpResponse; - try { - httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); - } catch (final IOException e) { - // Receiving a GOAWAY means the connection should be retried. For some reason, the Java - // HTTP client doesn't. See also: https://stackoverflow.com/a/55092354 - if (e.getMessage() != null && e.getMessage().contains("GOAWAY received")) { - // Manually retry, once - debug(() -> "Retrying after receiving GOAWAY"); - httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); - } else { - throw e; - } - } + HttpResponse httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); statusCode = httpResponse.statusCode(); responseBody = getBodyAsString(httpResponse); } catch (final IOException e) { @@ -152,7 +142,16 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append(": "); message.append(exceptionMessage); if (exceptionMessage != null) { - if (exceptionMessage.contains("unable to find valid certification path to requested target")) { + if (e.getMessage().contains("GOAWAY received")) { + // Receiving a GOAWAY means the connection should be retried. For some reason, the Java + // HTTP client doesn't seem to. See also: https://stackoverflow.com/a/55092354 + if (retries > 0) { + debug(() -> "Retrying after received GOAWAY"); + return makeConnection(route, postBody, retries - 1); + } else { + message.append("Already retried after GOAWAY multiple times, your web server is probably down."); + } + } else if (exceptionMessage.contains("unable to find valid certification path to requested target")) { message.append("\nHINT: Your HTTPS certificate is probably valid, but is it complete? Ensure your website uses a valid *full chain* SSL/TLS certificate."); } else if (exceptionMessage.contains("No subject alternative DNS name matching")) { message.append("\nHINT: Is your HTTPS certificate valid? Is it for the correct domain?"); From 59c5f96388e8116f811915da175e0b482cc00750 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Tue, 8 Aug 2023 16:22:31 +0200 Subject: [PATCH 174/269] Enable deprecation warnings during build --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 4a0baa3a..1942d8c0 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,7 @@ 11 11 + true true 100 From a476323002a2dbce3891c2a7afee397c034dff3d Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Tue, 8 Aug 2023 16:35:41 +0200 Subject: [PATCH 175/269] Add creditsDisplay() --- .../com/namelessmc/java_api/modules/store/StoreUser.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java index 3709381f..f4022078 100644 --- a/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java @@ -55,6 +55,13 @@ public int creditsCents() throws NamelessException { return response.get("cents").getAsInt(); } + /** + * Credits, formatted as a float string with 2 decimals + */ + public String creditsDisplay() throws NamelessException { + return String.format("%.2f", this.creditsCents() / 100f); + } + public int customerId() throws NamelessException { JsonObject response = this.requests.get("users/" + this.user.userTransformer() + "/credits"); return response.get("customer_id").getAsInt(); From e214779e9263857b433e54c99178288f077be7a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:12:37 +0200 Subject: [PATCH 176/269] Bump org.slf4j:slf4j-api from 2.0.7 to 2.0.9 (#83) Bumps org.slf4j:slf4j-api from 2.0.7 to 2.0.9. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1942d8c0..a33333a0 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.slf4j slf4j-api - 2.0.7 + 2.0.9 provided From 635e8b9c98305e85a4356d5eb82f7bcfb68b7df5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:12:47 +0200 Subject: [PATCH 177/269] Bump checkerFrameworkVersion from 3.37.0 to 3.38.0 (#84) Bumps `checkerFrameworkVersion` from 3.37.0 to 3.38.0. Updates `org.checkerframework:checker` from 3.37.0 to 3.38.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.37.0...checker-framework-3.38.0) Updates `org.checkerframework:checker-qual` from 3.37.0 to 3.38.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.37.0...checker-framework-3.38.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a33333a0..2b7fd301 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.37.0 + 3.38.0 From 380df79535ad10bfea98103a1baccb58ed43985b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:11:12 +0200 Subject: [PATCH 178/269] Bump checkerFrameworkVersion from 3.38.0 to 3.39.0 (#85) Bumps `checkerFrameworkVersion` from 3.38.0 to 3.39.0. Updates `org.checkerframework:checker` from 3.38.0 to 3.39.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.38.0...checker-framework-3.39.0) Updates `org.checkerframework:checker-qual` from 3.38.0 to 3.39.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.38.0...checker-framework-3.39.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b7fd301..2c307ffb 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.38.0 + 3.39.0 From 75cda4d6fb31e07f88088a1053b412f9bf7d197c Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Sat, 7 Oct 2023 14:47:30 +0200 Subject: [PATCH 179/269] Fix cloudflare detection --- src/main/java/com/namelessmc/java_api/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/namelessmc/java_api/RequestHandler.java b/src/main/java/com/namelessmc/java_api/RequestHandler.java index 54ddf84d..3ed2bff6 100644 --- a/src/main/java/com/namelessmc/java_api/RequestHandler.java +++ b/src/main/java/com/namelessmc/java_api/RequestHandler.java @@ -198,7 +198,7 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append("This is a common occurrence with free web hosting services; they usually don't allow API access.\n"); } else if (responseBody.contains("Please Wait... | Cloudflare") || responseBody.contains("#cf-bubbles") || - responseBody.contains("_cf_ch1_opt")) { + responseBody.contains("_cf_chl_opt")) { message.append("HINT: CloudFlare is blocking our request. Please see https://docs.namelessmc.com/cloudflare-api\n"); } else if (responseBody.startsWith("\ufeff")) { message.append("HINT: The website response contains invisible unicode characters. This seems to be caused by Partydragen's Store module, we have no idea why.\n"); From d11520f461139464819fba427f5837df31586198 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:37:03 +0200 Subject: [PATCH 180/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.1.2 to 3.2.1 (#86) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.1.2 to 3.2.1. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.2...surefire-3.2.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2c307ffb..e36fc5b9 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.1.2 + 3.2.1 From af7e8ce924ccf92a3e37a4808d907ff023b1b11c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:29:26 +0100 Subject: [PATCH 181/269] Bump checkerFrameworkVersion from 3.39.0 to 3.40.0 (#87) Bumps `checkerFrameworkVersion` from 3.39.0 to 3.40.0. Updates `org.checkerframework:checker` from 3.39.0 to 3.40.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.39.0...checker-framework-3.40.0) Updates `org.checkerframework:checker-qual` from 3.39.0 to 3.40.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.39.0...checker-framework-3.40.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e36fc5b9..00a67ae2 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.39.0 + 3.40.0 From e129a73f29e9f47aca83fbaced6b3bc5b1552add Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 13:55:54 +0100 Subject: [PATCH 182/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.10.0 to 5.10.1 (#88) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.10.0 to 5.10.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.0...r5.10.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 00a67ae2..a5f4c81a 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ org.junit.jupiter junit-jupiter-engine - 5.10.0 + 5.10.1 test From 10854e1166d92d024a2f8b233996784d0badaa11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Nov 2023 12:48:33 +0100 Subject: [PATCH 183/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.1 to 3.2.2 (#89) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.1 to 3.2.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.1...surefire-3.2.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a5f4c81a..8c9c05f5 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.2.1 + 3.2.2 From ebad731ab64e6e8912c99bd20ce737f2b2117613 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 19:34:53 +0100 Subject: [PATCH 184/269] Bump checkerFrameworkVersion from 3.40.0 to 3.41.0 (#90) Bumps `checkerFrameworkVersion` from 3.40.0 to 3.41.0. Updates `org.checkerframework:checker` from 3.40.0 to 3.41.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.40.0...checker-framework-3.41.0) Updates `org.checkerframework:checker-qual` from 3.40.0 to 3.41.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.40.0...checker-framework-3.41.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8c9c05f5..d8baa1c6 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.40.0 + 3.41.0 From 2856ab4e0abf605eec51eb9fd1af207ede778a4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 13:19:37 +0100 Subject: [PATCH 185/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.2 to 3.2.3 (#91) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.2 to 3.2.3. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.2...surefire-3.2.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d8baa1c6..fb513e9b 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.2.2 + 3.2.3 From 9b0622ac49c4420856aa151fa16c2ce5960b1d11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:25:18 +0100 Subject: [PATCH 186/269] Bump checkerFrameworkVersion from 3.41.0 to 3.42.0 (#92) Bumps `checkerFrameworkVersion` from 3.41.0 to 3.42.0. Updates `org.checkerframework:checker` from 3.41.0 to 3.42.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.41.0...checker-framework-3.42.0) Updates `org.checkerframework:checker-qual` from 3.41.0 to 3.42.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.41.0...checker-framework-3.42.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fb513e9b..eb9fb292 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.41.0 + 3.42.0 From d7741de45a16ec325a736312e319c3219e94c7aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 12:44:16 +0100 Subject: [PATCH 187/269] Bump org.apache.maven.plugins:maven-compiler-plugin (#93) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.11.0...maven-compiler-plugin-3.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eb9fb292..8391c496 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.0 11 11 From 5eeecd6548191582833a5e737a835b2f015599b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:13:27 +0100 Subject: [PATCH 188/269] Bump org.apache.maven.plugins:maven-compiler-plugin (#94) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.0 to 3.12.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.0...maven-compiler-plugin-3.12.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8391c496..68185a38 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.0 + 3.12.1 11 11 From 78592ea3d0726b9fe57ebbb1c45e61a71e9edf55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:10:55 +0100 Subject: [PATCH 189/269] Bump org.slf4j:slf4j-api from 2.0.9 to 2.0.10 (#95) Bumps org.slf4j:slf4j-api from 2.0.9 to 2.0.10. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68185a38..11197599 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.slf4j slf4j-api - 2.0.9 + 2.0.10 provided From c0fd6f1f8229cb69739aba0140b3f5fc1fed0728 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 20:04:19 +0100 Subject: [PATCH 190/269] Bump org.slf4j:slf4j-api from 2.0.10 to 2.0.11 (#96) Bumps org.slf4j:slf4j-api from 2.0.10 to 2.0.11. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 11197599..68b38a5f 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.slf4j slf4j-api - 2.0.10 + 2.0.11 provided From 7b4cc691473741ad6b6b3990db9f06f2ae94598c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 20:13:29 +0100 Subject: [PATCH 191/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.3 to 3.2.5 (#97) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.3 to 3.2.5. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.3...surefire-3.2.5) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68b38a5f..324c96d1 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.2.3 + 3.2.5 From 58b87b7b2a3d74bd2b6cc44ef3bb5d526a260310 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:15:32 +0100 Subject: [PATCH 192/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.10.1 to 5.10.2 (#98) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.10.1 to 5.10.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.1...r5.10.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 324c96d1..27b93b31 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ org.junit.jupiter junit-jupiter-engine - 5.10.1 + 5.10.2 test From d2c1aff0bbb0948e5b43d77ae51965f3649c27ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:40:27 +0100 Subject: [PATCH 193/269] Bump org.slf4j:slf4j-api from 2.0.11 to 2.0.12 (#99) Bumps org.slf4j:slf4j-api from 2.0.11 to 2.0.12. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27b93b31..e7b4b349 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.slf4j slf4j-api - 2.0.11 + 2.0.12 provided From 34bb9f859c662c682de1580d61a9d72bc145654c Mon Sep 17 00:00:00 2001 From: Derkades Date: Sun, 10 Mar 2024 09:40:29 +0100 Subject: [PATCH 194/269] Fix cents math --- .../java/com/namelessmc/java_api/modules/store/StoreUser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java b/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java index f4022078..ad3334ed 100644 --- a/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java +++ b/src/main/java/com/namelessmc/java_api/modules/store/StoreUser.java @@ -29,7 +29,7 @@ public void addCredits(float creditsToAdd) throws NamelessException { public void addCredits(int cents) throws NamelessException { // Module does not support adding cents yet - this.addCredits(cents * 100f); + this.addCredits(cents / 100f); } @Deprecated @@ -41,7 +41,7 @@ public void removeCredits(float creditsToRemove) throws NamelessException { public void removeCredits(int cents) throws NamelessException { // Module does not support removing cents yet - this.removeCredits(cents * 100f); + this.removeCredits(cents / 100f); } @Deprecated From e53e10ada50905d7df54fdeb1a8b95b6c2befb24 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:29:43 +0100 Subject: [PATCH 195/269] Bump org.apache.maven.plugins:maven-compiler-plugin (#100) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.1 to 3.13.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7b4b349..96b105fd 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 11 11 From 5240f1217de96ce0715774bd4d5fc58711c4003f Mon Sep 17 00:00:00 2001 From: Derkades Date: Sat, 13 Apr 2024 17:31:30 +0200 Subject: [PATCH 196/269] Fix improperly named error --- src/main/java/com/namelessmc/java_api/exception/ApiError.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/namelessmc/java_api/exception/ApiError.java b/src/main/java/com/namelessmc/java_api/exception/ApiError.java index bf2b3e9a..3c16ef15 100644 --- a/src/main/java/com/namelessmc/java_api/exception/ApiError.java +++ b/src/main/java/com/namelessmc/java_api/exception/ApiError.java @@ -50,7 +50,9 @@ public enum ApiError { // https://github.com/partydragen/Nameless-Store/blob/master/upload/modules/Store/classes/StoreApiErrors.php STORE_PAYMENT_NOT_FOUND("store", "payment_not_found"), + @Deprecated ERROR_INVALID_CREDITS_AMOUNT("store", "invalid_credits_amount"), + STORE_INVALID_CREDITS_AMOUNT("store", "invalid_credits_amount"), ; From b44570b146864abcce074ed312278e8891f4f76d Mon Sep 17 00:00:00 2001 From: Derkades Date: Sat, 13 Apr 2024 17:32:26 +0200 Subject: [PATCH 197/269] Add new store connection not found error --- src/main/java/com/namelessmc/java_api/exception/ApiError.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/namelessmc/java_api/exception/ApiError.java b/src/main/java/com/namelessmc/java_api/exception/ApiError.java index 3c16ef15..8c64999f 100644 --- a/src/main/java/com/namelessmc/java_api/exception/ApiError.java +++ b/src/main/java/com/namelessmc/java_api/exception/ApiError.java @@ -50,6 +50,7 @@ public enum ApiError { // https://github.com/partydragen/Nameless-Store/blob/master/upload/modules/Store/classes/StoreApiErrors.php STORE_PAYMENT_NOT_FOUND("store", "payment_not_found"), + STORE_CONNECTION_NOT_FOUND("store", "connection_not_found"), @Deprecated ERROR_INVALID_CREDITS_AMOUNT("store", "invalid_credits_amount"), STORE_INVALID_CREDITS_AMOUNT("store", "invalid_credits_amount"), From ac8f306fa08fb3882863a19496fefc4bd09bb76b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:44:18 +0200 Subject: [PATCH 198/269] Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 (#101) Bumps org.slf4j:slf4j-api from 2.0.12 to 2.0.13. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 96b105fd..9d0fefe9 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.slf4j slf4j-api - 2.0.12 + 2.0.13 provided From 18c3fa2f91ede0299747743631b69120b930131c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 17:51:38 +0200 Subject: [PATCH 199/269] Bump checkerFrameworkVersion from 3.42.0 to 3.43.0 (#102) Bumps `checkerFrameworkVersion` from 3.42.0 to 3.43.0. Updates `org.checkerframework:checker` from 3.42.0 to 3.43.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.42.0...checker-framework-3.43.0) Updates `org.checkerframework:checker-qual` from 3.42.0 to 3.43.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.42.0...checker-framework-3.43.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9d0fefe9..9d216ca5 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.42.0 + 3.43.0 From 54722dbc5b19817bed5356c663264f0b1dea8a19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 21:48:06 +0200 Subject: [PATCH 200/269] Bump com.google.code.gson:gson from 2.10.1 to 2.11.0 (#103) Bumps [com.google.code.gson:gson](https://github.com/google/gson) from 2.10.1 to 2.11.0. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.10.1...gson-parent-2.11.0) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9d216ca5..4245b3d0 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ com.google.code.gson gson - 2.10.1 + 2.11.0 From b124a0131399cea9da0798af99b7f33c3e7736f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 20:34:18 +0200 Subject: [PATCH 201/269] Bump checkerFrameworkVersion from 3.43.0 to 3.44.0 (#104) Bumps `checkerFrameworkVersion` from 3.43.0 to 3.44.0. Updates `org.checkerframework:checker` from 3.43.0 to 3.44.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.43.0...checker-framework-3.44.0) Updates `org.checkerframework:checker-qual` from 3.43.0 to 3.44.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.43.0...checker-framework-3.44.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4245b3d0..a71f41a8 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.43.0 + 3.44.0 From c5f8e4bb2f5330695bcb7ad9965c4cbe780dc719 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:40:21 +0200 Subject: [PATCH 202/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.0 (#105) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.3.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a71f41a8..4b4d9cc1 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.2.5 + 3.3.0 From db485883873c363b8acd8631f94dbce8d5576e00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 29 Jun 2024 11:19:48 +0200 Subject: [PATCH 203/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.10.2 to 5.10.3 (#106) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.10.2 to 5.10.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.2...r5.10.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4b4d9cc1..d1e82976 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ org.junit.jupiter junit-jupiter-engine - 5.10.2 + 5.10.3 test From 3863a536eeab3ec16c2c38019d5cc73c63025e61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 21:13:42 +0200 Subject: [PATCH 204/269] Bump checkerFrameworkVersion from 3.44.0 to 3.45.0 (#107) Bumps `checkerFrameworkVersion` from 3.44.0 to 3.45.0. Updates `org.checkerframework:checker` from 3.44.0 to 3.45.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.44.0...checker-framework-3.45.0) Updates `org.checkerframework:checker-qual` from 3.44.0 to 3.45.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.44.0...checker-framework-3.45.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d1e82976..d061ae2e 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.44.0 + 3.45.0 From 589e3e1ee7c3d9385a796be9ad66e0e752ab63e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:54:28 +0200 Subject: [PATCH 205/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.0 to 3.3.1 (#108) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.0...surefire-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d061ae2e..1b9f316b 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.3.0 + 3.3.1 From 0f8843d9047e9ad1c0fe5f8ac82777c94c705af6 Mon Sep 17 00:00:00 2001 From: Derkades Date: Wed, 17 Jul 2024 21:22:08 +0200 Subject: [PATCH 206/269] Add method for reporting with server id --- .../com/namelessmc/java_api/NamelessUser.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/namelessmc/java_api/NamelessUser.java b/src/main/java/com/namelessmc/java_api/NamelessUser.java index 7adce858..9ba025b8 100644 --- a/src/main/java/com/namelessmc/java_api/NamelessUser.java +++ b/src/main/java/com/namelessmc/java_api/NamelessUser.java @@ -272,6 +272,21 @@ public void createReport(final @NonNull NamelessUser user, final @NonNull String public void createReport(final @NonNull UUID reportedUuid, final @NonNull String reportedName, final @NonNull String reason) throws NamelessException { + createReport(reportedUuid, reportedName, reason, 0); + } + + /** + * Create a report for a user who may or may not have a website account + * @param reportedUuid The Mojang UUID of the Minecraft player to report + * @param reportedName The Minecraft username of this player + * @param reason Report reason + * @param serverId Minecraft server id + * @throws IllegalArgumentException Report reason is too long (>255 characters) + */ + public void createReport(final @NonNull UUID reportedUuid, + final @NonNull String reportedName, + final @NonNull String reason, + final int serverId) throws NamelessException { Objects.requireNonNull(reportedUuid, "Reported uuid is null"); Objects.requireNonNull(reportedName, "Reported name is null"); Objects.requireNonNull(reason, "Report reason is null"); @@ -282,6 +297,9 @@ public void createReport(final @NonNull UUID reportedUuid, post.addProperty("reported_uid", reportedUuid.toString()); post.addProperty("reported_username", reportedName); post.addProperty("content", reason); + if (serverId != 0) { + post.addProperty("server_id", serverId); + } try { this.requests.post("reports/create", post); } catch (final ApiException e) { From 084a23bd07dba242c34467e0e3495956627ba771 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:13:55 +0200 Subject: [PATCH 207/269] Bump checkerFrameworkVersion from 3.45.0 to 3.46.0 (#109) Bumps `checkerFrameworkVersion` from 3.45.0 to 3.46.0. Updates `org.checkerframework:checker` from 3.45.0 to 3.46.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.45.0...checker-framework-3.46.0) Updates `org.checkerframework:checker-qual` from 3.45.0 to 3.46.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.45.0...checker-framework-3.46.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1b9f316b..8e7f46d1 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.45.0 + 3.46.0 From 51182e18b9e4a61ce254b7e37583c9b08644f689 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 22:41:26 +0200 Subject: [PATCH 208/269] Bump org.slf4j:slf4j-api from 2.0.13 to 2.0.16 (#112) Bumps org.slf4j:slf4j-api from 2.0.13 to 2.0.16. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8e7f46d1..b06d0f63 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.slf4j slf4j-api - 2.0.13 + 2.0.16 provided From a37587222e68e596569f520c3d526ae690507473 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 21:45:12 +0200 Subject: [PATCH 209/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.1 to 3.4.0 (#114) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.3.1 to 3.4.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.1...surefire-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b06d0f63..56a1dbea 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.3.1 + 3.4.0 From 271070153f7963c992facab0e98f34ecf215e852 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 21:47:29 +0200 Subject: [PATCH 210/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.10.3 to 5.11.0 (#113) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.10.3 to 5.11.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.3...r5.11.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 56a1dbea..aac51928 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ org.junit.jupiter junit-jupiter-engine - 5.10.3 + 5.11.0 test From 21071376e8b00b3ff75eab3c9ea86e0a157af649 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 09:57:40 +0200 Subject: [PATCH 211/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.4.0 to 3.5.0 (#115) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.4.0...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aac51928..8ee67aa0 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ maven-surefire-plugin - 3.4.0 + 3.5.0 From 2cf6645dc4b23d4161907ea73107bfa3eeededa6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:18:46 +0200 Subject: [PATCH 212/269] Bump checkerFrameworkVersion from 3.46.0 to 3.47.0 (#116) Bumps `checkerFrameworkVersion` from 3.46.0 to 3.47.0. Updates `org.checkerframework:checker` from 3.46.0 to 3.47.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.46.0...checker-framework-3.47.0) Updates `org.checkerframework:checker-qual` from 3.46.0 to 3.47.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.46.0...checker-framework-3.47.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8ee67aa0..38ab3974 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.46.0 + 3.47.0 From e0e155c087dd1d35c488156a5921ac5e1589dd05 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Fri, 13 Sep 2024 13:47:12 +0200 Subject: [PATCH 213/269] Add new group sync endpoints --- pom.xml | 4 - .../com/namelessmc/java_api/NamelessAPI.java | 66 +++++++++------- .../com/namelessmc/java_api/NamelessUser.java | 68 +++++++++++------ .../namelessmc/java_api/RequestHandler.java | 75 +++++++++---------- .../java_api/modules/discord/DiscordUser.java | 19 ++++- 5 files changed, 134 insertions(+), 98 deletions(-) diff --git a/pom.xml b/pom.xml index 38ab3974..3de428ef 100644 --- a/pom.xml +++ b/pom.xml @@ -25,10 +25,6 @@ 11 true true - - 100 - 100 - org.checkerframework diff --git a/src/main/java/com/namelessmc/java_api/NamelessAPI.java b/src/main/java/com/namelessmc/java_api/NamelessAPI.java index 08961728..1b5d4337 100755 --- a/src/main/java/com/namelessmc/java_api/NamelessAPI.java +++ b/src/main/java/com/namelessmc/java_api/NamelessAPI.java @@ -1,5 +1,19 @@ package com.namelessmc.java_api; +import java.math.BigInteger; +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -15,14 +29,6 @@ import com.namelessmc.java_api.modules.store.StoreAPI; import com.namelessmc.java_api.modules.suggestions.SuggestionsAPI; import com.namelessmc.java_api.modules.websend.WebsendAPI; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; - -import java.math.BigInteger; -import java.net.URL; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; public final class NamelessAPI { @@ -90,7 +96,9 @@ public void submitServerInfo(final @NonNull JsonObject jsonData) throws Nameless * Send Minecraft groups to website. Only available in Nameless 2.1.0+ * @param groups * @throws NamelessException + * @deprecated Should use {@link com.namelessmc.java_api.NamelessUser#updateMinecraftGroups} for Nameless 2.2.0+ */ + @Deprecated public void sendMinecraftGroups(final int serverId, final Map> groups) throws NamelessException { final JsonObject groupsJson = new JsonObject(); final Gson gson = this.requests().gson(); @@ -100,7 +108,7 @@ public void sendMinecraftGroups(final int serverId, final Map> groupsJson.add(javaUuidToWebsiteUuid(uuid), playerGroupsObject); }); - JsonObject body = new JsonObject(); + final JsonObject body = new JsonObject(); body.addProperty("server_id", serverId); body.add("player_groups", groupsJson); @@ -136,7 +144,7 @@ public FilteredUserListBuilder users() { try { user.userInfo(); return user; - } catch (ApiException e) { + } catch (final ApiException e) { if (e.apiError() == ApiError.NAMELESS_CANNOT_FIND_USER) { return null; } @@ -145,27 +153,27 @@ public FilteredUserListBuilder users() { } public @Nullable NamelessUser user(final int id) throws NamelessException { - return userAsNullable(userLazy(id)); + return this.userAsNullable(this.userLazy(id)); } public @Nullable NamelessUser userByUsername(final @NonNull String username) throws NamelessException { - return userAsNullable(userByUsernameLazy(username)); + return this.userAsNullable(this.userByUsernameLazy(username)); } public @Nullable NamelessUser userByMinecraftUuid(final @NonNull UUID uuid) throws NamelessException { - return userAsNullable(userByMinecraftUuidLazy(uuid)); + return this.userAsNullable(this.userByMinecraftUuidLazy(uuid)); } public @Nullable NamelessUser userByMinecraftUsername(final @NonNull String username) throws NamelessException { - return userAsNullable(userByMinecraftUsernameLazy(username)); + return this.userAsNullable(this.userByMinecraftUsernameLazy(username)); } public @Nullable NamelessUser userByDiscordId(final long id) throws NamelessException { - return userAsNullable(userByDiscordIdLazy(id)); + return this.userAsNullable(this.userByDiscordIdLazy(id)); } public @Nullable NamelessUser userByDiscordUsername(final @NonNull String username) throws NamelessException { - return userAsNullable(userByDiscordUsernameLazy(username)); + return this.userAsNullable(this.userByDiscordUsernameLazy(username)); } /** @@ -182,31 +190,31 @@ public FilteredUserListBuilder users() { } public @NonNull NamelessUser userByUsernameLazy(final @NonNull String username) { - return userLazy("username:" + username); + return this.userLazy("username:" + username); } public @NonNull NamelessUser userByMinecraftUuidLazy(final @NonNull UUID uuid) { - return byIntegrationIdentifierLazy(StandardIntegrationTypes.MINECRAFT, javaUuidToWebsiteUuid(uuid)); + return this.byIntegrationIdentifierLazy(StandardIntegrationTypes.MINECRAFT, javaUuidToWebsiteUuid(uuid)); } public @NonNull NamelessUser userByMinecraftUsernameLazy(final @NonNull String username) { - return byIntegrationUsernameLazy(StandardIntegrationTypes.MINECRAFT, username); + return this.byIntegrationUsernameLazy(StandardIntegrationTypes.MINECRAFT, username); } public @NonNull NamelessUser userByDiscordIdLazy(final long id) { - return byIntegrationIdentifierLazy(StandardIntegrationTypes.DISCORD, String.valueOf(id)); + return this.byIntegrationIdentifierLazy(StandardIntegrationTypes.DISCORD, String.valueOf(id)); } public @NonNull NamelessUser userByDiscordUsernameLazy(final @NonNull String username) { - return byIntegrationUsernameLazy(StandardIntegrationTypes.DISCORD, username); + return this.byIntegrationUsernameLazy(StandardIntegrationTypes.DISCORD, username); } public NamelessUser byIntegrationIdentifierLazy(String integrationName, String identifier) { - return userLazy("integration_id:" + integrationName + ":" + identifier); + return this.userLazy("integration_id:" + integrationName + ":" + identifier); } public NamelessUser byIntegrationUsernameLazy(String integrationName, String username) { - return userLazy("integration_name:" + integrationName + ":" + username); + return this.userLazy("integration_name:" + integrationName + ":" + username); } /** @@ -234,7 +242,7 @@ public NamelessUser byIntegrationUsernameLazy(String integrationName, String use public List group(final @NonNull String name) throws NamelessException { Objects.requireNonNull(name, "Group name is null"); final JsonObject response = this.requests.get("groups", "name", name); - return groupListFromJsonArray(response.getAsJsonArray("groups")); + return this.groupListFromJsonArray(response.getAsJsonArray("groups")); } /** @@ -243,7 +251,7 @@ public List group(final @NonNull String name) throws NamelessException { */ public List getAllGroups() throws NamelessException { final JsonObject response = this.requests.get("groups"); - return groupListFromJsonArray(response.getAsJsonArray("groups")); + return this.groupListFromJsonArray(response.getAsJsonArray("groups")); } @@ -285,9 +293,9 @@ public Optional registerUser(final @NonNull String username, post.addProperty("username", username); post.addProperty("email", email); if (integrationData != null && integrationData.length > 0) { - JsonObject integrationsJson = new JsonObject(); - for (IntegrationData integration : integrationData) { - JsonObject integrationJson = new JsonObject(); + final JsonObject integrationsJson = new JsonObject(); + for (final IntegrationData integration : integrationData) { + final JsonObject integrationJson = new JsonObject(); integrationJson.addProperty("identifier", integration.identifier()); integrationJson.addProperty("username", integration.username()); integrationsJson.add(integration.type().toString(), integrationJson); @@ -306,7 +314,7 @@ public Optional registerUser(final @NonNull String username, public void verifyIntegration(final @NonNull IntegrationData integrationData, final @NonNull String verificationCode) throws NamelessException { - JsonObject data = new JsonObject(); + final JsonObject data = new JsonObject(); data.addProperty("integration", integrationData.type()); data.addProperty("identifier", integrationData.identifier()); data.addProperty("username", integrationData.username()); diff --git a/src/main/java/com/namelessmc/java_api/NamelessUser.java b/src/main/java/com/namelessmc/java_api/NamelessUser.java index 9ba025b8..51736e31 100644 --- a/src/main/java/com/namelessmc/java_api/NamelessUser.java +++ b/src/main/java/com/namelessmc/java_api/NamelessUser.java @@ -1,5 +1,21 @@ package com.namelessmc.java_api; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +import org.checkerframework.checker.index.qual.Positive; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import com.google.common.base.Preconditions; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -7,18 +23,17 @@ import com.namelessmc.java_api.exception.ApiError; import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.exception.NamelessException; -import com.namelessmc.java_api.integrations.*; +import com.namelessmc.java_api.integrations.DetailedDiscordIntegrationData; +import com.namelessmc.java_api.integrations.DetailedIntegrationData; +import com.namelessmc.java_api.integrations.DetailedMinecraftIntegrationData; +import com.namelessmc.java_api.integrations.IDiscordIntegrationData; +import com.namelessmc.java_api.integrations.IMinecraftIntegrationData; +import com.namelessmc.java_api.integrations.IntegrationData; +import com.namelessmc.java_api.integrations.StandardIntegrationTypes; import com.namelessmc.java_api.modules.discord.DiscordUser; import com.namelessmc.java_api.modules.store.StoreUser; import com.namelessmc.java_api.modules.suggestions.SuggestionsUser; import com.namelessmc.java_api.util.GsonHelper; -import org.checkerframework.checker.index.qual.Positive; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; - -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.*; public final class NamelessUser implements LanguageEntity { @@ -112,7 +127,7 @@ public int id() throws NamelessException { } public void updateUsername(final @NonNull String username) throws NamelessException { - JsonObject post = new JsonObject(); + final JsonObject post = new JsonObject(); post.addProperty("username", username); this.requests.post("users/" + this.userTransformer + "/update-username", post); } @@ -149,7 +164,7 @@ public boolean isVerified() throws NamelessException { } public @NonNull VerificationInfo verificationInfo() throws NamelessException { - final boolean verified = isVerified(); + final boolean verified = this.isVerified(); final JsonObject verification = this.userInfo().getAsJsonObject("verification"); return new VerificationInfo(verified, verification); } @@ -162,9 +177,9 @@ public boolean isStaff() throws NamelessException { throw new IllegalStateException("Groups array missing: https://github.com/NamelessMC/Nameless/issues/3052"); } - JsonArray groups = this.userInfo().getAsJsonArray("groups"); - for (JsonElement elem : groups) { - JsonObject group = elem.getAsJsonObject(); + final JsonArray groups = this.userInfo().getAsJsonArray("groups"); + for (final JsonElement elem : groups) { + final JsonObject group = elem.getAsJsonObject(); if (group.has("staff") && group.get("staff").getAsBoolean()) { return true; @@ -205,16 +220,23 @@ public boolean isStaff() throws NamelessException { public void addGroups(final @NonNull Group@NonNull ... groups) throws NamelessException { final JsonObject post = new JsonObject(); - post.add("groups", groupsToJsonArray(groups)); + post.add("groups", this.groupsToJsonArray(groups)); this.requests.post("users/" + this.userTransformer + "/groups/add", post); - invalidateCache(); // Groups modified, invalidate cache + this.invalidateCache(); // Groups modified, invalidate cache } public void removeGroups(final @NonNull Group@NonNull... groups) throws NamelessException { final JsonObject post = new JsonObject(); - post.add("groups", groupsToJsonArray(groups)); + post.add("groups", this.groupsToJsonArray(groups)); this.requests.post("users/" + this.userTransformer + "/groups/remove", post); - invalidateCache(); // Groups modified, invalidate cache + this.invalidateCache(); // Groups modified, invalidate cache + } + + public void updateMinecraftGroups(final String[] addedGroups, final String[] removedGroups) throws NamelessException { + final JsonObject post = new JsonObject(); + post.add("add", this.requests.gson().toJsonTree(addedGroups)); + post.add("remove", this.requests.gson().toJsonTree(removedGroups)); + this.requests.post("minecraft/" + this.userTransformer + "/sync-groups", post); } private JsonArray groupsToJsonArray(final @NonNull Group@NonNull [] groups) { @@ -272,7 +294,7 @@ public void createReport(final @NonNull NamelessUser user, final @NonNull String public void createReport(final @NonNull UUID reportedUuid, final @NonNull String reportedName, final @NonNull String reason) throws NamelessException { - createReport(reportedUuid, reportedName, reason, 0); + this.createReport(reportedUuid, reportedName, reason, 0); } /** @@ -336,7 +358,7 @@ public Collection profileFields() throws NamelessExcept final JsonObject fieldsJson = this.userInfo().getAsJsonObject("profile_fields"); final List fieldValues = new ArrayList<>(fieldsJson.size()); for (final Map.Entry e : fieldsJson.entrySet()) { - int id = Integer.parseInt(e.getKey()); + final int id = Integer.parseInt(e.getKey()); final JsonObject values = e.getValue().getAsJsonObject(); fieldValues.add(new CustomProfileFieldValue( new CustomProfileField( @@ -361,10 +383,10 @@ public Map integrations() throws NamelessExcept final JsonObject userInfo = this.userInfo(); final JsonArray integrationsJsonArray = userInfo.getAsJsonArray("integrations"); - Map integrationDataMap = new HashMap<>(integrationsJsonArray.size()); - for (JsonElement integrationElement : integrationsJsonArray) { - JsonObject integrationJson = integrationElement.getAsJsonObject(); - String integrationName = integrationJson.get("integration").getAsString(); + final Map integrationDataMap = new HashMap<>(integrationsJsonArray.size()); + for (final JsonElement integrationElement : integrationsJsonArray) { + final JsonObject integrationJson = integrationElement.getAsJsonObject(); + final String integrationName = integrationJson.get("integration").getAsString(); DetailedIntegrationData integrationData; switch(integrationName) { case StandardIntegrationTypes.MINECRAFT: diff --git a/src/main/java/com/namelessmc/java_api/RequestHandler.java b/src/main/java/com/namelessmc/java_api/RequestHandler.java index 3ed2bff6..066970ae 100644 --- a/src/main/java/com/namelessmc/java_api/RequestHandler.java +++ b/src/main/java/com/namelessmc/java_api/RequestHandler.java @@ -1,5 +1,21 @@ package com.namelessmc.java_api; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.net.URLEncoder; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + import com.github.mizosoft.methanol.Methanol; import com.github.mizosoft.methanol.MutableRequest; import com.google.common.base.Ascii; @@ -13,21 +29,6 @@ import com.namelessmc.java_api.exception.ApiException; import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.logger.ApiLogger; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; -import java.net.URLEncoder; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Objects; -import java.util.function.Supplier; -import java.util.stream.Collectors; public class RequestHandler { @@ -57,7 +58,7 @@ public Gson gson() { public JsonObject post(final String route, final JsonObject postData) throws NamelessException { - return makeConnection(route, postData, RETRIES); + return this.makeConnection(route, postData, RETRIES); } public JsonObject get(final String route, @@ -71,7 +72,7 @@ public JsonObject get(final String route, } for (int i = 0; i < parameters.length; i++) { - Object param = parameters[i]; + final Object param = parameters[i]; if (i % 2 == 0) { if (param == null) { throw new IllegalArgumentException("Parameter keys must never be null, only values may be null"); @@ -85,13 +86,7 @@ public JsonObject get(final String route, } } - return makeConnection(urlBuilder.toString(), null, RETRIES); - } - - private void debug(final @NonNull String message) { - if (this.debugLogger != null) { - this.debugLogger.log(message); - } + return this.makeConnection(urlBuilder.toString(), null, RETRIES); } private void debug(final @NonNull Supplier messageSupplier) { @@ -112,16 +107,16 @@ private void debug(final @NonNull Supplier messageSupplier) { } final MutableRequest request = MutableRequest.create(uri); - debug(() -> "Making connection " + (postBody != null ? "POST" : "GET") + " to " + request.uri()); + this.debug(() -> "Making connection " + (postBody != null ? "POST" : "GET") + " to " + request.uri()); final long requestStartTime = System.currentTimeMillis(); if (postBody != null) { - byte[] postBytes = gson.toJson(postBody).getBytes(StandardCharsets.UTF_8); + final byte[] postBytes = this.gson.toJson(postBody).getBytes(StandardCharsets.UTF_8); request.POST(HttpRequest.BodyPublishers.ofByteArray(postBytes)); request.header("Content-Type", "application/json"); - debug(() -> "POST request body:\n" + new String(postBytes, StandardCharsets.UTF_8)); + this.debug(() -> "POST request body:\n" + new String(postBytes, StandardCharsets.UTF_8)); } else { request.GET(); } @@ -131,9 +126,9 @@ private void debug(final @NonNull Supplier messageSupplier) { final int statusCode; final String responseBody; try { - HttpResponse httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); + final HttpResponse httpResponse = this.httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); statusCode = httpResponse.statusCode(); - responseBody = getBodyAsString(httpResponse); + responseBody = this.getBodyAsString(httpResponse); } catch (final IOException e) { final @Nullable String exceptionMessage = e.getMessage(); final StringBuilder message = new StringBuilder(); @@ -142,12 +137,12 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append(": "); message.append(exceptionMessage); if (exceptionMessage != null) { - if (e.getMessage().contains("GOAWAY received")) { + if (e.getMessage() != null && e.getMessage().contains("GOAWAY received")) { // Receiving a GOAWAY means the connection should be retried. For some reason, the Java // HTTP client doesn't seem to. See also: https://stackoverflow.com/a/55092354 if (retries > 0) { - debug(() -> "Retrying after received GOAWAY"); - return makeConnection(route, postBody, retries - 1); + this.debug(() -> "Retrying after received GOAWAY"); + return this.makeConnection(route, postBody, retries - 1); } else { message.append("Already retried after GOAWAY multiple times, your web server is probably down."); } @@ -167,11 +162,11 @@ private void debug(final @NonNull Supplier messageSupplier) { } throw new NamelessException(message.toString(), e); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new NamelessException("In-progress request was aborted", e); } - debug(() -> "Website response body, after " + (System.currentTimeMillis() - requestStartTime) + "ms:\n" + regularAsciiOnly(responseBody)); + this.debug(() -> "Website response body, after " + (System.currentTimeMillis() - requestStartTime) + "ms:\n" + regularAsciiOnly(responseBody)); if (responseBody.length() == 0) { if (statusCode == 301 || statusCode == 302 || statusCode == 303 || statusCode == 307 || statusCode == 308) { @@ -185,7 +180,7 @@ private void debug(final @NonNull Supplier messageSupplier) { try { json = JsonParser.parseString(responseBody).getAsJsonObject(); } catch (final JsonSyntaxException | IllegalStateException e) { - StringBuilder message = new StringBuilder(); + final StringBuilder message = new StringBuilder(); message.append("Website returned invalid response with code "); message.append(statusCode); message.append(".\n"); @@ -208,8 +203,8 @@ private void debug(final @NonNull Supplier messageSupplier) { message.append(System.currentTimeMillis() - requestStartTime); message.append("ms:\n"); message.append("-----------------\n"); - int totalLengthLimit = 1500; // fit in a Discord message - String printableResponse = regularAsciiOnly(responseBody); + final int totalLengthLimit = 1500; // fit in a Discord message + final String printableResponse = regularAsciiOnly(responseBody); message.append(Ascii.truncate(printableResponse, totalLengthLimit, "[truncated]\n")); if (message.charAt(message.length() - 1) != '\n') { message.append('\n'); @@ -243,7 +238,7 @@ private void debug(final @NonNull Supplier messageSupplier) { private String getBodyAsString(HttpResponse response) throws IOException { try (InputStream in = response.body(); InputStream limited = ByteStreams.limit(in, this.responseLengthLimit)) { - byte[] bytes = limited.readAllBytes(); + final byte[] bytes = limited.readAllBytes(); if (bytes.length == this.responseLengthLimit) { throw new IOException("Response larger than limit of " + this.responseLengthLimit + " bytes."); } @@ -252,9 +247,9 @@ private String getBodyAsString(HttpResponse response) throws IOExce } private static @NonNull String regularAsciiOnly(@NonNull String message) { - char[] chars = message.toCharArray(); + final char[] chars = message.toCharArray(); for (int i = 0; i < chars.length; i++) { - char c = chars[i]; + final char c = chars[i]; // only allow standard symbols, letters, numbers // look up an ascii table if you don't understand this if statement if (c >= ' ' && c <= '~' || c == '\n') { diff --git a/src/main/java/com/namelessmc/java_api/modules/discord/DiscordUser.java b/src/main/java/com/namelessmc/java_api/modules/discord/DiscordUser.java index 49a51f89..1cb846bb 100644 --- a/src/main/java/com/namelessmc/java_api/modules/discord/DiscordUser.java +++ b/src/main/java/com/namelessmc/java_api/modules/discord/DiscordUser.java @@ -1,11 +1,12 @@ package com.namelessmc.java_api.modules.discord; +import org.checkerframework.checker.nullness.qual.NonNull; + import com.google.gson.JsonObject; import com.namelessmc.java_api.NamelessUser; import com.namelessmc.java_api.RequestHandler; import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.modules.NamelessModule; -import org.checkerframework.checker.nullness.qual.NonNull; public class DiscordUser { @@ -18,11 +19,25 @@ public DiscordUser(NamelessUser user) throws NamelessException { user.api().ensureModuleInstalled(NamelessModule.DISCORD_INTEGRATION); } + /** + * @deprecated Replaced by {@link #syncGroups(long[], long[])} + */ + @Deprecated public void updateDiscordRoles(final long@NonNull [] roleIds) throws NamelessException { final JsonObject post = new JsonObject(); post.addProperty("user", this.user.id()); post.add("roles", this.requests.gson().toJsonTree(roleIds)); this.requests.post("discord/set-roles", post); } - + + /** + * Available from NamelessMC 2.2.0+. Use with a fallback to {@link #syncRoles(long[], long[])}. + * @throws NamelessException + */ + public void syncRoles(final long[] addedRolesIds, final long[] removedRoleIds) throws NamelessException { + final JsonObject post = new JsonObject(); + post.add("add", this.requests.gson().toJsonTree(addedRolesIds)); + post.add("remove", this.requests.gson().toJsonTree(removedRoleIds)); + this.requests.post("discord/" + this.user.userTransformer() + "/sync-roles", post); + } } From a4b6568cdae33991670f244b8331587fbfb49564 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:43:20 +0200 Subject: [PATCH 214/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.11.0 to 5.11.1 (#117) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.0 to 5.11.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.0...r5.11.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3de428ef..2d33c66a 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.11.0 + 5.11.1 test From cc3942042f478f968116884f7d28a6df2ce0459d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:04:48 +0200 Subject: [PATCH 215/269] Bump checkerFrameworkVersion from 3.47.0 to 3.48.0 (#118) Bumps `checkerFrameworkVersion` from 3.47.0 to 3.48.0. Updates `org.checkerframework:checker` from 3.47.0 to 3.48.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.47.0...checker-framework-3.48.0) Updates `org.checkerframework:checker-qual` from 3.47.0 to 3.48.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.47.0...checker-framework-3.48.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2d33c66a..67263a58 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.47.0 + 3.48.0 From dcad143d0f78f0fe6199fc512487d750a7a24d69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 22:52:21 +0200 Subject: [PATCH 216/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.5.0 to 3.5.1 (#120) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.5.0...surefire-3.5.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 67263a58..02607e06 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 3.5.0 + 3.5.1 From 75b47f28006cf1fa4d032ec651ab7201b3ac718f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:46:08 +0200 Subject: [PATCH 217/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.11.1 to 5.11.2 (#119) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.1 to 5.11.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.1...r5.11.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 02607e06..000c1d70 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.11.1 + 5.11.2 test From fd6f3be9903e1ac994c3a1506bff9df7da74c8cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:04:41 +0200 Subject: [PATCH 218/269] Bump checkerFrameworkVersion from 3.48.0 to 3.48.1 (#121) Bumps `checkerFrameworkVersion` from 3.48.0 to 3.48.1. Updates `org.checkerframework:checker` from 3.48.0 to 3.48.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.0...checker-framework-3.48.1) Updates `org.checkerframework:checker-qual` from 3.48.0 to 3.48.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.0...checker-framework-3.48.1) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 000c1d70..9e8fc877 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.48.0 + 3.48.1 From eb06834729c63cdcbd466233d521f1b386055ed3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:32:11 +0100 Subject: [PATCH 219/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.11.2 to 5.11.3 (#122) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.2 to 5.11.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.2...r5.11.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9e8fc877..7b148514 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.11.2 + 5.11.3 test From 101c1d54118d00a8f2adbd7e23a3303c03130736 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:22:58 +0100 Subject: [PATCH 220/269] Bump checkerFrameworkVersion from 3.48.1 to 3.48.2 (#124) Bumps `checkerFrameworkVersion` from 3.48.1 to 3.48.2. Updates `org.checkerframework:checker` from 3.48.1 to 3.48.2 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.1...checker-framework-3.48.2) Updates `org.checkerframework:checker-qual` from 3.48.1 to 3.48.2 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.1...checker-framework-3.48.2) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7b148514..793ae16a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.48.1 + 3.48.2 From 0214bb9749befc6f65a8cbda8e44044b32a3910c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 00:34:30 +0100 Subject: [PATCH 221/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.5.1 to 3.5.2 (#123) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.5.1 to 3.5.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.5.1...surefire-3.5.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 793ae16a..a6d1e1ad 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 3.5.1 + 3.5.2 From d38129e5d3c1476b0df591c0ad165323e353d500 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:38:43 +0100 Subject: [PATCH 222/269] Bump checkerFrameworkVersion from 3.48.2 to 3.48.3 (#125) Bumps `checkerFrameworkVersion` from 3.48.2 to 3.48.3. Updates `org.checkerframework:checker` from 3.48.2 to 3.48.3 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.2...checker-framework-3.48.3) Updates `org.checkerframework:checker-qual` from 3.48.2 to 3.48.3 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.2...checker-framework-3.48.3) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6d1e1ad..7944d0a2 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.48.2 + 3.48.3 From f1bd69d2199340f51ee9ac48cf7ba104346e6b7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:55:07 +0100 Subject: [PATCH 223/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.11.3 to 5.11.4 (#126) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.3 to 5.11.4. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.3...r5.11.4) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7944d0a2..97d3f912 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.11.3 + 5.11.4 test From 6f62cc456c80f103dc3dd081f9b624c5466ed180 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:19:16 +0100 Subject: [PATCH 224/269] Bump checkerFrameworkVersion from 3.48.3 to 3.48.4 (#128) Bumps `checkerFrameworkVersion` from 3.48.3 to 3.48.4. Updates `org.checkerframework:checker` from 3.48.3 to 3.48.4 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.3...checker-framework-3.48.4) Updates `org.checkerframework:checker-qual` from 3.48.3 to 3.48.4 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.3...checker-framework-3.48.4) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 97d3f912..274c95f1 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.48.3 + 3.48.4 From bdec603ab0ebc50d5599d46c0cec43eb91a6a6bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Feb 2025 23:26:05 +0100 Subject: [PATCH 225/269] Bump com.google.code.gson:gson from 2.11.0 to 2.12.1 (#130) Bumps [com.google.code.gson:gson](https://github.com/google/gson) from 2.11.0 to 2.12.1. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.11.0...gson-parent-2.12.1) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 274c95f1..01c715cc 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ com.google.code.gson gson - 2.11.0 + 2.12.1 From b1edf459e813b98ece50a8d786574ead83575fe6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 13:39:55 +0100 Subject: [PATCH 226/269] Bump checkerFrameworkVersion from 3.48.4 to 3.49.0 (#131) Bumps `checkerFrameworkVersion` from 3.48.4 to 3.49.0. Updates `org.checkerframework:checker` from 3.48.4 to 3.49.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.4...checker-framework-3.49.0) Updates `org.checkerframework:checker-qual` from 3.48.4 to 3.49.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.48.4...checker-framework-3.49.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 01c715cc..65549e5b 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.48.4 + 3.49.0 From 8ffce7163051a770c9896d4b991060d922d71946 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 14:31:50 +0100 Subject: [PATCH 227/269] Bump com.github.mizosoft.methanol:methanol from 1.7.0 to 1.8.1 (#132) Bumps [com.github.mizosoft.methanol:methanol](https://github.com/mizosoft/methanol) from 1.7.0 to 1.8.1. - [Release notes](https://github.com/mizosoft/methanol/releases) - [Changelog](https://github.com/mizosoft/methanol/blob/master/CHANGELOG.md) - [Commits](https://github.com/mizosoft/methanol/commits) --- updated-dependencies: - dependency-name: com.github.mizosoft.methanol:methanol dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 65549e5b..f593a27a 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ com.github.mizosoft.methanol methanol - 1.7.0 + 1.8.1 From 90bc8453c1dfa1729544b08383bf31cad9a2a9d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 22 Feb 2025 12:41:48 +0100 Subject: [PATCH 228/269] Bump org.apache.maven.plugins:maven-compiler-plugin (#133) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.13.0 to 3.14.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.13.0...maven-compiler-plugin-3.14.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f593a27a..7b36d946 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.13.0 + 3.14.0 11 11 From 77abf42d164183e9054e20fee43c7f4b8bd85ccd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 14:04:52 +0100 Subject: [PATCH 229/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.11.4 to 5.12.0 (#134) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.4 to 5.12.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.4...r5.12.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7b36d946..da7a3cf9 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.11.4 + 5.12.0 test From c1e1d4de897bb7171971a7f8f61c7d2bb4169882 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:10:51 +0100 Subject: [PATCH 230/269] Bump org.slf4j:slf4j-api from 2.0.16 to 2.0.17 (#135) Bumps org.slf4j:slf4j-api from 2.0.16 to 2.0.17. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index da7a3cf9..56ecd62e 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ org.slf4j slf4j-api - 2.0.16 + 2.0.17 provided From 8f0136ef7659b00f18c4e5150f8e2fb457f4d092 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 13:36:05 +0100 Subject: [PATCH 231/269] Bump com.github.mizosoft.methanol:methanol from 1.8.1 to 1.8.2 (#136) Bumps [com.github.mizosoft.methanol:methanol](https://github.com/mizosoft/methanol) from 1.8.1 to 1.8.2. - [Release notes](https://github.com/mizosoft/methanol/releases) - [Changelog](https://github.com/mizosoft/methanol/blob/master/CHANGELOG.md) - [Commits](https://github.com/mizosoft/methanol/compare/v1.8.1...v1.8.2) --- updated-dependencies: - dependency-name: com.github.mizosoft.methanol:methanol dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 56ecd62e..6784979b 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ com.github.mizosoft.methanol methanol - 1.8.1 + 1.8.2 From 08d58369bcca1c2a4c591e89a9a674c0b9227b6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 15:02:03 +0100 Subject: [PATCH 232/269] Bump checkerFrameworkVersion from 3.49.0 to 3.49.1 (#137) Bumps `checkerFrameworkVersion` from 3.49.0 to 3.49.1. Updates `org.checkerframework:checker` from 3.49.0 to 3.49.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.0...checker-framework-3.49.1) Updates `org.checkerframework:checker-qual` from 3.49.0 to 3.49.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.0...checker-framework-3.49.1) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6784979b..a8835b38 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.49.0 + 3.49.1 From b8268592dcb0a34170c82fad7cb0af94c6250cbc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 22:56:28 +0100 Subject: [PATCH 233/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.12.0 to 5.12.1 (#138) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.12.0 to 5.12.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.12.0...r5.12.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8835b38..ff2f1137 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.12.0 + 5.12.1 test From 4682a17d7b646229e874d332bec5d31078ec1fcc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:07:10 +0200 Subject: [PATCH 234/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.5.2 to 3.5.3 (#139) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.5.2 to 3.5.3. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.5.2...surefire-3.5.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ff2f1137..e7896dd9 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 3.5.2 + 3.5.3 From f62d67de9f093cba836740fbcbcc878853a3c75d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:40:29 +0200 Subject: [PATCH 235/269] Bump checkerFrameworkVersion from 3.49.1 to 3.49.2 (#140) Bumps `checkerFrameworkVersion` from 3.49.1 to 3.49.2. Updates `org.checkerframework:checker` from 3.49.1 to 3.49.2 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.1...checker-framework-3.49.2) Updates `org.checkerframework:checker-qual` from 3.49.1 to 3.49.2 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.1...checker-framework-3.49.2) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7896dd9..e6a1b5d7 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.49.1 + 3.49.2 From 1dc8874777ed4f1a662d3737097277e2a5559ae7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 20:21:11 +0200 Subject: [PATCH 236/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.12.1 to 5.12.2 (#142) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.12.1 to 5.12.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.12.1...r5.12.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 5.12.2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6a1b5d7..3955871c 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.12.1 + 5.12.2 test From 66b86d51b6b74b461e76e80e25ae3b29cbdb49b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 20:21:43 +0200 Subject: [PATCH 237/269] Bump com.google.code.gson:gson from 2.12.1 to 2.13.0 (#141) Bumps [com.google.code.gson:gson](https://github.com/google/gson) from 2.12.1 to 2.13.0. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.12.1...gson-parent-2.13.0) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-version: 2.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3955871c..74fb42ed 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ com.google.code.gson gson - 2.12.1 + 2.13.0 From 4f11971b489d824331d6747c3da84a1eef8d474a Mon Sep 17 00:00:00 2001 From: Supercrafter100 <58982133+supercrafter100@users.noreply.github.com> Date: Sun, 20 Apr 2025 19:03:50 +0200 Subject: [PATCH 238/269] Add support for 2.2 (#143) --- src/main/java/com/namelessmc/java_api/NamelessVersion.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/namelessmc/java_api/NamelessVersion.java b/src/main/java/com/namelessmc/java_api/NamelessVersion.java index 032d51fd..0e16e209 100644 --- a/src/main/java/com/namelessmc/java_api/NamelessVersion.java +++ b/src/main/java/com/namelessmc/java_api/NamelessVersion.java @@ -17,13 +17,15 @@ public enum NamelessVersion { V2_0_0_PR_13("2.0.0-pr13", "2.0.0 pre-release 13", 2, 0, true), V2_0(null, "2.0.*", 2, 0, false), V2_1(null, "2.1.*", 2, 1, false), + V2_2(null, "2.2.*", 2, 2, false) ; private static final Set SUPPORTED_VERSIONS = EnumSet.of( V2_0_0_PR_13, V2_0, - V2_1 + V2_1, + V2_2 ); private final @Nullable String exactMatchName; // Only for pre-releases From bbc49d001bcbdee61a2f7b8ed01d5b9ff651d9d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:31:14 +0200 Subject: [PATCH 239/269] Bump com.google.code.gson:gson from 2.13.0 to 2.13.1 (#144) Bumps [com.google.code.gson:gson](https://github.com/google/gson) from 2.13.0 to 2.13.1. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.13.0...gson-parent-2.13.1) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-version: 2.13.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 74fb42ed..582396eb 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ com.google.code.gson gson - 2.13.0 + 2.13.1 From 93db13187f932da81e98ad5861450612141869d6 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Wed, 30 Apr 2025 22:10:49 +0200 Subject: [PATCH 240/269] Fix usage of deprecated URL constructor --- .../java_api/modules/suggestions/Suggestion.java | 14 ++++++++------ src/test/java/TestTls.java | 15 ++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/namelessmc/java_api/modules/suggestions/Suggestion.java b/src/main/java/com/namelessmc/java_api/modules/suggestions/Suggestion.java index cfa8221b..b3f4eee4 100644 --- a/src/main/java/com/namelessmc/java_api/modules/suggestions/Suggestion.java +++ b/src/main/java/com/namelessmc/java_api/modules/suggestions/Suggestion.java @@ -1,13 +1,15 @@ package com.namelessmc.java_api.modules.suggestions; -import com.google.gson.JsonObject; -import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.exception.NamelessException; - import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Date; +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.exception.NamelessException; + public class Suggestion { private final int id; @@ -28,8 +30,8 @@ public class Suggestion { this.id = json.get("id").getAsInt(); final String urlString = json.get("link").getAsString(); try { - this.url = new URL(urlString); - } catch (MalformedURLException e) { + this.url = new URI(urlString).toURL(); + } catch (MalformedURLException | URISyntaxException e) { throw new NamelessException("Website provided invalid suggestion URL: " + urlString, e); } this.author = new SuggestionUser(api, json.getAsJsonObject("author")); diff --git a/src/test/java/TestTls.java b/src/test/java/TestTls.java index 76e245ca..bc447761 100644 --- a/src/test/java/TestTls.java +++ b/src/test/java/TestTls.java @@ -1,18 +1,19 @@ -import com.google.gson.JsonObject; -import com.namelessmc.java_api.NamelessAPI; -import com.namelessmc.java_api.exception.NamelessException; +import java.net.MalformedURLException; +import java.net.URI; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.net.MalformedURLException; -import java.net.URL; +import com.google.gson.JsonObject; +import com.namelessmc.java_api.NamelessAPI; +import com.namelessmc.java_api.exception.NamelessException; public class TestTls { @Test void checkTlsVersion() throws MalformedURLException, NamelessException { - NamelessAPI api = NamelessAPI.builder(new URL("https://check-tls.akamai.io/"), "").build(); - JsonObject response = api.requests().get("v1/tlsinfo.json"); + final NamelessAPI api = NamelessAPI.builder(URI.create("https://check-tls.akamai.io/").toURL(), "").build(); + final JsonObject response = api.requests().get("v1/tlsinfo.json"); Assertions.assertEquals(response.get("tls_sni_status").getAsString(), "present"); Assertions.assertEquals(response.get("tls_version").getAsString(), "tls1.3"); Assertions.assertEquals(response.get("tls_sni_value").getAsString(), "check-tls.akamai.io"); From 95f8ff54425a9cb0fa01044059723e70193cac31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 10:46:56 +0200 Subject: [PATCH 241/269] Bump checkerFrameworkVersion from 3.49.2 to 3.49.3 (#145) Bumps `checkerFrameworkVersion` from 3.49.2 to 3.49.3. Updates `org.checkerframework:checker` from 3.49.2 to 3.49.3 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.2...checker-framework-3.49.3) Updates `org.checkerframework:checker-qual` from 3.49.2 to 3.49.3 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.2...checker-framework-3.49.3) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.49.3 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-version: 3.49.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 582396eb..28d171ea 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.49.2 + 3.49.3 From c860a0ce0f465a9f835aed57ec76ceaa7cff01ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 14:36:22 +0200 Subject: [PATCH 242/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.12.2 to 5.13.0 (#146) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.12.2 to 5.13.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.12.2...r5.13.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 5.13.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28d171ea..7900c33e 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.12.2 + 5.13.0 test From ecfa65a8635f641b1260a9491f7f293bb1c910a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 17:38:58 +0200 Subject: [PATCH 243/269] Bump checkerFrameworkVersion from 3.49.3 to 3.49.4 (#147) Bumps `checkerFrameworkVersion` from 3.49.3 to 3.49.4. Updates `org.checkerframework:checker` from 3.49.3 to 3.49.4 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.3...checker-framework-3.49.4) Updates `org.checkerframework:checker-qual` from 3.49.3 to 3.49.4 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.3...checker-framework-3.49.4) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.49.4 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-version: 3.49.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7900c33e..05820537 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.49.3 + 3.49.4 From 2a121db3ab81c8c501775ac1d2057fd1d179f3bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:59:57 +0200 Subject: [PATCH 244/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.13.0 to 5.13.1 (#148) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.13.0 to 5.13.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.13.0...r5.13.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 5.13.1 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05820537..89ab7f99 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.13.0 + 5.13.1 test From 5585f41f62d7e8fd2e0e9ad6eddcdc2b5e8ecefe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 12:30:49 +0200 Subject: [PATCH 245/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.13.1 to 5.13.2 (#149) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit-framework) from 5.13.1 to 5.13.2. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r5.13.1...r5.13.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 5.13.2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89ab7f99..ab859bab 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.13.1 + 5.13.2 test From c64e9de4e33875dadd2fe3bdd709ba3a8eeecb0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Jul 2025 14:35:28 +0200 Subject: [PATCH 246/269] Bump com.github.mizosoft.methanol:methanol from 1.8.2 to 1.8.3 (#150) Bumps [com.github.mizosoft.methanol:methanol](https://github.com/mizosoft/methanol) from 1.8.2 to 1.8.3. - [Release notes](https://github.com/mizosoft/methanol/releases) - [Changelog](https://github.com/mizosoft/methanol/blob/master/CHANGELOG.md) - [Commits](https://github.com/mizosoft/methanol/compare/v1.8.2...v1.8.3) --- updated-dependencies: - dependency-name: com.github.mizosoft.methanol:methanol dependency-version: 1.8.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab859bab..320307d7 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ com.github.mizosoft.methanol methanol - 1.8.2 + 1.8.3 From 8d2a49458f6d321345580e75549b61eecea1d33b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 21:34:04 +0200 Subject: [PATCH 247/269] Bump checkerFrameworkVersion from 3.49.4 to 3.49.5 (#151) Bumps `checkerFrameworkVersion` from 3.49.4 to 3.49.5. Updates `org.checkerframework:checker` from 3.49.4 to 3.49.5 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.4...checker-framework-3.49.5) Updates `org.checkerframework:checker-qual` from 3.49.4 to 3.49.5 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.4...checker-framework-3.49.5) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.49.5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-version: 3.49.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 320307d7..52d8ae18 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.49.4 + 3.49.5 From af04f5e782b8a6e2ac5a9a41e3d7c0f6111ceccc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 23:05:47 +0200 Subject: [PATCH 248/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.13.2 to 5.13.3 (#152) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit-framework) from 5.13.2 to 5.13.3. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r5.13.2...r5.13.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 5.13.3 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 52d8ae18..ef25ad3c 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.13.2 + 5.13.3 test From aeebe121be5478a31aaf40f68e90557932844fe5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 15:26:28 +0200 Subject: [PATCH 249/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.13.3 to 5.13.4 (#153) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit-framework) from 5.13.3 to 5.13.4. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r5.13.3...r5.13.4) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 5.13.4 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ef25ad3c..7bbb274d 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.junit.jupiter junit-jupiter-engine - 5.13.3 + 5.13.4 test From a27495c65ff84b45cc02d66be1b1155e2b4d0ef1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 13:47:00 +0200 Subject: [PATCH 250/269] Bump checkerFrameworkVersion from 3.49.5 to 3.50.0 (#154) Bumps `checkerFrameworkVersion` from 3.49.5 to 3.50.0. Updates `org.checkerframework:checker` from 3.49.5 to 3.50.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.5...checker-framework-3.50.0) Updates `org.checkerframework:checker-qual` from 3.49.5 to 3.50.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.5...checker-framework-3.50.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.50.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-version: 3.50.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7bbb274d..89d80215 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.49.5 + 3.50.0 From aa31225d9803b3b33c6f062b76db28f8fecb1d6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 22:30:13 +0200 Subject: [PATCH 251/269] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.5.3 to 3.5.4 (#157) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.5.3 to 3.5.4. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.5.3...surefire-3.5.4) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-version: 3.5.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89d80215..881bdbf4 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 3.5.3 + 3.5.4 From 1da6008e6395f6c3ad01d78bcb2c5078a94506d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 17:23:25 +0200 Subject: [PATCH 252/269] Bump checkerFrameworkVersion from 3.50.0 to 3.51.0 (#156) Bumps `checkerFrameworkVersion` from 3.50.0 to 3.51.0. Updates `org.checkerframework:checker` from 3.50.0 to 3.51.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.50.0...checker-framework-3.51.0) Updates `org.checkerframework:checker-qual` from 3.50.0 to 3.51.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.50.0...checker-framework-3.51.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.51.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-version: 3.51.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 881bdbf4..c715c8a8 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.50.0 + 3.51.0 From c5b73d30460cc475f9f3896799150579cecef8a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 17:23:35 +0200 Subject: [PATCH 253/269] Bump com.google.code.gson:gson from 2.13.1 to 2.13.2 (#155) Bumps [com.google.code.gson:gson](https://github.com/google/gson) from 2.13.1 to 2.13.2. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.13.1...gson-parent-2.13.2) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-version: 2.13.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c715c8a8..e4aa72ba 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ com.google.code.gson gson - 2.13.1 + 2.13.2 From 0e6e9898227827a1998d18f7edbc7c0ebfa90dcc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 14:41:11 +0200 Subject: [PATCH 254/269] Bump org.apache.maven.plugins:maven-compiler-plugin (#158) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.14.0 to 3.14.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.14.0...maven-compiler-plugin-3.14.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-version: 3.14.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e4aa72ba..8a3724f7 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.0 + 3.14.1 11 11 From 5c2350962b8637ef8df0d8ec368ab0c26d3dead4 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Tue, 23 Sep 2025 14:45:48 +0200 Subject: [PATCH 255/269] fix build --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 8a3724f7..8020f4dc 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED From 9889fd01e4725cc86a05e1ed60699510db61d480 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Tue, 23 Sep 2025 14:46:18 +0200 Subject: [PATCH 256/269] remove update() API, it didn't work anyway --- .../java/com/namelessmc/java_api/Website.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/src/main/java/com/namelessmc/java_api/Website.java b/src/main/java/com/namelessmc/java_api/Website.java index aaeb1f9d..b1a278ec 100644 --- a/src/main/java/com/namelessmc/java_api/Website.java +++ b/src/main/java/com/namelessmc/java_api/Website.java @@ -5,7 +5,6 @@ import com.namelessmc.java_api.exception.NamelessException; import com.namelessmc.java_api.exception.UnknownNamelessVersionException; import com.namelessmc.java_api.modules.NamelessModule; -import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Set; import java.util.stream.Collectors; @@ -14,7 +13,6 @@ public class Website implements LanguageEntity { private final String version; - private final @Nullable Update update; private final Set modules; private final String rawLanguage; @@ -33,20 +31,6 @@ public class Website implements LanguageEntity { .map(NamelessModule::byName) .collect(Collectors.toUnmodifiableSet()); - if (json.has("version_update") && false) { - final JsonObject updateJson = json.get("version_update").getAsJsonObject(); - final boolean updateAvailable = updateJson.get("update").getAsBoolean(); - if (updateAvailable) { - final String updateVersion = updateJson.get("version").getAsString(); - final boolean isUrgent = updateJson.get("urgent").getAsBoolean(); - this.update = new Update(isUrgent, updateVersion); - } else { - this.update = null; - } - } else { - this.update = null; - } - if (json.get("locale").isJsonNull()) { throw new NamelessException("Website returned null locale. This can happen if you upgraded from v2-pr12 to v2-pr13, please try switching the site's language to something else and back."); } @@ -62,13 +46,6 @@ public NamelessVersion parsedVersion() throws UnknownNamelessVersionException { return NamelessVersion.parse(this.version); } - /** - * @return Information about an update, or empty if no update is available. - */ - public @Nullable Update update() { - return this.update; - } - public Set modules() { return this.modules; } From fe8e6735bc0d83762acc52b9eb0d6502bcf4c603 Mon Sep 17 00:00:00 2001 From: Robin Slot Date: Tue, 23 Sep 2025 14:48:07 +0200 Subject: [PATCH 257/269] fix deprecation warning --- src/main/java/com/namelessmc/java_api/NamelessApiBuilder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/namelessmc/java_api/NamelessApiBuilder.java b/src/main/java/com/namelessmc/java_api/NamelessApiBuilder.java index d28fe380..f2e59727 100644 --- a/src/main/java/com/namelessmc/java_api/NamelessApiBuilder.java +++ b/src/main/java/com/namelessmc/java_api/NamelessApiBuilder.java @@ -12,6 +12,7 @@ import java.net.Authenticator; import java.net.MalformedURLException; import java.net.ProxySelector; +import java.net.URI; import java.net.URL; import java.net.http.HttpClient; import java.time.Duration; @@ -41,7 +42,7 @@ public class NamelessApiBuilder { NamelessApiBuilder(final @NonNull URL apiUrl, final @NonNull String apiKey) { try { - this.apiUrl = apiUrl.toString().endsWith("/") ? apiUrl : new URL(apiUrl + "/"); + this.apiUrl = apiUrl.toString().endsWith("/") ? apiUrl : (URI.create(apiUrl + "/").toURL()); } catch (MalformedURLException e) { throw new RuntimeException(e); } From 2dc98f43ed280fec3e331471df9812ab601d0c34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 19:49:57 +0200 Subject: [PATCH 258/269] Bump org.junit.jupiter:junit-jupiter-engine from 5.13.4 to 6.0.0 (#159) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit-framework) from 5.13.4 to 6.0.0. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r5.13.4...r6.0.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 6.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8020f4dc..82470125 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ org.junit.jupiter junit-jupiter-engine - 5.13.4 + 6.0.0 test From c54653d7c2f605e9bff4fbae549c6ac24ec8158b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 16:53:38 +0200 Subject: [PATCH 259/269] Bump checkerFrameworkVersion from 3.51.0 to 3.51.1 (#160) Bumps `checkerFrameworkVersion` from 3.51.0 to 3.51.1. Updates `org.checkerframework:checker` from 3.51.0 to 3.51.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.51.0...checker-framework-3.51.1) Updates `org.checkerframework:checker-qual` from 3.51.0 to 3.51.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.51.0...checker-framework-3.51.1) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.51.1 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-version: 3.51.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 82470125..43cffb7d 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.51.0 + 3.51.1 From 8ca22a9b0702a8fde492d082418f5604e4aae8a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Oct 2025 14:32:12 +0200 Subject: [PATCH 260/269] Bump com.github.mizosoft.methanol:methanol from 1.8.3 to 1.8.4 (#161) Bumps [com.github.mizosoft.methanol:methanol](https://github.com/mizosoft/methanol) from 1.8.3 to 1.8.4. - [Release notes](https://github.com/mizosoft/methanol/releases) - [Changelog](https://github.com/mizosoft/methanol/blob/master/CHANGELOG.md) - [Commits](https://github.com/mizosoft/methanol/compare/v1.8.3...v1.8.4) --- updated-dependencies: - dependency-name: com.github.mizosoft.methanol:methanol dependency-version: 1.8.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 43cffb7d..c71bda7c 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ com.github.mizosoft.methanol methanol - 1.8.3 + 1.8.4 From 4a3f4a50a0143e1556208cfabb31416084aaf445 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:10:04 +0100 Subject: [PATCH 261/269] Bump org.junit.jupiter:junit-jupiter-engine from 6.0.0 to 6.0.1 (#162) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit-framework) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r6.0.0...r6.0.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 6.0.1 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c71bda7c..4f210e6f 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ org.junit.jupiter junit-jupiter-engine - 6.0.0 + 6.0.1 test From 0b4240cec6d789f60678416d10d4c180960139f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Nov 2025 17:32:46 +0100 Subject: [PATCH 262/269] Bump checkerFrameworkVersion from 3.51.1 to 3.52.0 (#163) Bumps `checkerFrameworkVersion` from 3.51.1 to 3.52.0. Updates `org.checkerframework:checker` from 3.51.1 to 3.52.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.51.1...checker-framework-3.52.0) Updates `org.checkerframework:checker-qual` from 3.51.1 to 3.52.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.51.1...checker-framework-3.52.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.52.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-version: 3.52.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4f210e6f..d629cf03 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.51.1 + 3.52.0 From 299d3ff45ff2d50afb49315872cf76d35fb925fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Dec 2025 10:17:40 +0100 Subject: [PATCH 263/269] Bump checkerFrameworkVersion from 3.52.0 to 3.52.1 (#164) Bumps `checkerFrameworkVersion` from 3.52.0 to 3.52.1. Updates `org.checkerframework:checker` from 3.52.0 to 3.52.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.52.0...checker-framework-3.52.1) Updates `org.checkerframework:checker-qual` from 3.52.0 to 3.52.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.52.0...checker-framework-3.52.1) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.52.1 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-version: 3.52.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d629cf03..a6a9dd92 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.52.0 + 3.52.1 From 206b5eaac79e1e77bf3bdae45e41652be064d265 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jan 2026 07:23:17 +0100 Subject: [PATCH 264/269] Bump com.github.mizosoft.methanol:methanol from 1.8.4 to 1.9.0 (#165) Bumps [com.github.mizosoft.methanol:methanol](https://github.com/mizosoft/methanol) from 1.8.4 to 1.9.0. - [Release notes](https://github.com/mizosoft/methanol/releases) - [Changelog](https://github.com/mizosoft/methanol/blob/master/CHANGELOG.md) - [Commits](https://github.com/mizosoft/methanol/compare/v1.8.4...v1.9.0) --- updated-dependencies: - dependency-name: com.github.mizosoft.methanol:methanol dependency-version: 1.9.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6a9dd92..10c6d6f9 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ com.github.mizosoft.methanol methanol - 1.8.4 + 1.9.0 From 4c121fd40a4d300bfc2f38ca694378cec93bba11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jan 2026 08:21:25 +0100 Subject: [PATCH 265/269] Bump checkerFrameworkVersion from 3.52.1 to 3.53.0 (#167) Bumps `checkerFrameworkVersion` from 3.52.1 to 3.53.0. Updates `org.checkerframework:checker` from 3.52.1 to 3.53.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.52.1...checker-framework-3.53.0) Updates `org.checkerframework:checker-qual` from 3.52.1 to 3.53.0 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.52.1...checker-framework-3.53.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.53.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.checkerframework:checker-qual dependency-version: 3.53.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 10c6d6f9..1879de55 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.52.1 + 3.53.0 From 60beeeb4084810dd556b518d7f9374f8ee4fc8d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jan 2026 17:17:33 +0100 Subject: [PATCH 266/269] Bump org.junit.jupiter:junit-jupiter-engine from 6.0.1 to 6.0.2 (#166) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit-framework) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r6.0.1...r6.0.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 6.0.2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1879de55..02fc6b02 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ org.junit.jupiter junit-jupiter-engine - 6.0.1 + 6.0.2 test From 10b8e3d79a79132a67e4f21cd2dface27aa69527 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 17:17:40 +0100 Subject: [PATCH 267/269] Bump checkerFrameworkVersion from 3.53.0 to 3.53.1 (#169) Bumps `checkerFrameworkVersion` from 3.53.0 to 3.53.1. Updates `org.checkerframework:checker` from 3.53.0 to 3.53.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.53.0...checker-framework-3.53.1) Updates `org.checkerframework:checker-qual` from 3.53.0 to 3.53.1 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.53.0...checker-framework-3.53.1) --- updated-dependencies: - dependency-name: org.checkerframework:checker dependency-version: 3.53.1 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker-qual dependency-version: 3.53.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 02fc6b02..0bd39062 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 - 3.53.0 + 3.53.1 From d41bf6a0e1d4e6cda661caa1128a0ae5235585ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 15:58:47 +0100 Subject: [PATCH 268/269] Bump org.apache.maven.plugins:maven-compiler-plugin (#168) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.14.1 to 3.15.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.14.1...maven-compiler-plugin-3.15.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-version: 3.15.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0bd39062..d8a7e82a 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.1 + 3.15.0 11 11 From ecae7dff9477100c034fc5097823f2f7ca3aa806 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 11:45:25 +0100 Subject: [PATCH 269/269] Bump org.junit.jupiter:junit-jupiter-engine from 6.0.2 to 6.0.3 (#170) Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit-framework) from 6.0.2 to 6.0.3. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r6.0.2...r6.0.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 6.0.3 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d8a7e82a..4ecbe73c 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ org.junit.jupiter junit-jupiter-engine - 6.0.2 + 6.0.3 test