From 9593b6419697c7e5935df5b62a8049556cb73507 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 04:17:18 +0000 Subject: [PATCH 01/16] build(deps): bump org.jetbrains:annotations from 24.0.1 to 24.1.0 Bumps [org.jetbrains:annotations](https://github.com/JetBrains/java-annotations) from 24.0.1 to 24.1.0. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](https://github.com/JetBrains/java-annotations/compare/24.0.1...24.1.0) --- updated-dependencies: - dependency-name: org.jetbrains:annotations 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 7ef1bda5..56d936ff 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ org.jetbrains annotations - 24.0.1 + 24.1.0 compile From 6ae9ceba51c5877dc8db6f0055dab3a2d2ddf95f Mon Sep 17 00:00:00 2001 From: IoyoCode Date: Sat, 18 Nov 2023 19:54:54 +0000 Subject: [PATCH 02/16] fix(gateway): fixed the "heartbeat thread stopped" spam --- .../java/com/seailz/discordjar/gateway/heartbeat/HeartLogic.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/seailz/discordjar/gateway/heartbeat/HeartLogic.java b/src/main/java/com/seailz/discordjar/gateway/heartbeat/HeartLogic.java index 9760dc22..5ccaa60d 100644 --- a/src/main/java/com/seailz/discordjar/gateway/heartbeat/HeartLogic.java +++ b/src/main/java/com/seailz/discordjar/gateway/heartbeat/HeartLogic.java @@ -68,7 +68,6 @@ public void start() { Thread thread = new Thread(() -> { while (true) { if (!running) { - System.out.println("Heartbeat thread stopped."); try { Thread.sleep(1000); } catch (InterruptedException e) { From 27540294e7ac96f1f0c42dde01265c778b86a392 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 04:21:55 +0000 Subject: [PATCH 03/16] build(deps): bump org.springframework.boot:spring-boot-starter-websocket Bumps [org.springframework.boot:spring-boot-starter-websocket](https://github.com/spring-projects/spring-boot) from 3.1.5 to 3.2.0. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.1.5...v3.2.0) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-websocket 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 56d936ff..9576fc96 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.boot spring-boot-starter-websocket - 3.1.5 + 3.2.0 From 5344577922b75cb411f53876c73f91944b57b96d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 04:57:48 +0000 Subject: [PATCH 04/16] build(deps): bump org.jsoup:jsoup from 1.16.2 to 1.17.1 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.16.2 to 1.17.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.16.2...jsoup-1.17.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup 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 9576fc96..4554a618 100644 --- a/pom.xml +++ b/pom.xml @@ -129,7 +129,7 @@ org.jsoup jsoup - 1.16.2 + 1.17.1 com.squareup.okhttp3 From 4aa4af9d7a270bd361401db82a5cdff5bd73d737 Mon Sep 17 00:00:00 2001 From: IoyoCode Date: Sat, 9 Dec 2023 17:49:17 +0000 Subject: [PATCH 05/16] feat(event dispatcher): added a new field to the EventMethod.java class, EventMethod#requireCustomId which has the same effect as the old RequireCustomId.java annotation. Also deprecated RequireCustomId.java in favour of the new field. This change has been made because the old annotation had performance issues, as the annotation was checked at every event dispatch, and reflection takes time to run. Instead, the new field is checked when the event is registered to improve performance. --- .../discordjar/events/EventDispatcher.java | 23 +++++++++++++-- .../events/annotation/EventMethod.java | 28 ++++++++++++++++--- .../utils/annotation/RequireCustomId.java | 4 +++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/seailz/discordjar/events/EventDispatcher.java b/src/main/java/com/seailz/discordjar/events/EventDispatcher.java index 2cc51adf..7045b9ae 100644 --- a/src/main/java/com/seailz/discordjar/events/EventDispatcher.java +++ b/src/main/java/com/seailz/discordjar/events/EventDispatcher.java @@ -30,10 +30,12 @@ public class EventDispatcher { private static class ListenerMethodPair { final DiscordListener listener; final Method method; + final String customId; - ListenerMethodPair(DiscordListener listener, Method method) { + ListenerMethodPair(DiscordListener listener, Method method, String customId) { this.listener = listener; this.method = method; + this.customId = customId; } } @@ -53,7 +55,12 @@ public void addListener(DiscordListener... listeners) { for (Method method : listener.getClass().getMethods()) { if (method.isAnnotationPresent(EventMethod.class)) { Class eventType = (Class) method.getParameterTypes()[0]; - listenersByEventType.computeIfAbsent(eventType, k -> new ArrayList<>()).add(new ListenerMethodPair(listener, method)); + EventMethod eventMethod = method.getAnnotation(EventMethod.class); + + String customId = null; + if (eventMethod.requireCustomId() != null && !eventMethod.requireCustomId().equals("")) customId = eventMethod.requireCustomId(); + + listenersByEventType.computeIfAbsent(eventType, k -> new ArrayList<>()).add(new ListenerMethodPair(listener, method, customId)); } } } @@ -90,6 +97,18 @@ public void dispatchEvent(Event event, Class type, DiscordJar d } } + if (listenerMethodPair.customId != null) { + if (event instanceof CustomIdable) { + if (((CustomIdable) event).getCustomId() == null) { + continue; + } + + if (!((CustomIdable) event).getCustomId().matches(listenerMethodPair.customId)) { + continue; + } + } + } + method.setAccessible(true); DiscordJarThreadAllocator.requestThread(() -> { try { diff --git a/src/main/java/com/seailz/discordjar/events/annotation/EventMethod.java b/src/main/java/com/seailz/discordjar/events/annotation/EventMethod.java index dc991aec..c4d89fe1 100644 --- a/src/main/java/com/seailz/discordjar/events/annotation/EventMethod.java +++ b/src/main/java/com/seailz/discordjar/events/annotation/EventMethod.java @@ -6,10 +6,8 @@ import java.lang.annotation.Target; /** - * This annotation is used to mark methods that should be called when an event is fired. - * If a listener method isn't marked with this annotation, it will not be called. - * - * THIS ANNOTATION IS NO LONGER REQUIRED. It exists purely for backwards compatibility. + * This annotation is used to mark methods that should be called when an event is fired. + *
If a listener method isn't marked with this annotation, it will not be called. * * @author Seailz * @see com.seailz.discordjar.events.DiscordListener @@ -19,4 +17,26 @@ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface EventMethod { + + + /** + * If this field is set, then the event will only run if the customid of the event == the value of this field. + *
Example: + *
+ * + *
@EventMethod(requireCustomId="my_custom_id) + *
public void onModalInteractionEvent(@NotNull ModalInteractionEvent event) { + *
// This will only run if the custom id of the event is "my_custom_id" + *
event.reply("The custom ID is my_custom_id!").run(); + *
} + *
+ *

+ * It's also a regex, so you can do things like this: @RequireCustomId("my_custom_id|my_custom_id2") which will match both "my_custom_id" and "my_custom_id2" , + * or @RequireCustomId("my_custom_id-.*") which will match any custom id that starts with "my_custom_id-". + *

+ * @author Seailz + * @since 1.0 + */ + String requireCustomId() default ""; + } diff --git a/src/main/java/com/seailz/discordjar/utils/annotation/RequireCustomId.java b/src/main/java/com/seailz/discordjar/utils/annotation/RequireCustomId.java index fefdbefd..41c55072 100644 --- a/src/main/java/com/seailz/discordjar/utils/annotation/RequireCustomId.java +++ b/src/main/java/com/seailz/discordjar/utils/annotation/RequireCustomId.java @@ -1,5 +1,7 @@ package com.seailz.discordjar.utils.annotation; +import com.seailz.discordjar.events.annotation.EventMethod; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -23,9 +25,11 @@ *

* Using this annotation, however, will cause some performance loss, so use it sparingly or if time is not a concern. * @author Seailz + * @deprecated Use the {@link EventMethod#requireCustomId()} field instead. * @since 1.0 */ @Retention(RetentionPolicy.RUNTIME) +@Deprecated(since = "1.0") @Target({java.lang.annotation.ElementType.METHOD}) public @interface RequireCustomId { String value(); From b2332ed244e613794ae554d3c08360e8b2cdd2e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 04:44:55 +0000 Subject: [PATCH 06/16] build(deps): bump org.apache.maven.plugins:maven-compiler-plugin 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] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4554a618..b05e95dd 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.0 ${java.version} ${java.version} From 7bb750c3a81b842bb38d2910d0eeb66842dd5946 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Dec 2023 04:31:31 +0000 Subject: [PATCH 07/16] build(deps): bump org.springframework.boot:spring-boot-starter-websocket Bumps [org.springframework.boot:spring-boot-starter-websocket](https://github.com/spring-projects/spring-boot) from 3.2.0 to 3.2.1. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.0...v3.2.1) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-websocket 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 b05e95dd..57f1eda2 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.boot spring-boot-starter-websocket - 3.2.0 + 3.2.1 From 319de2442bc92be0b2db96425fae9ddaa7596cbd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 04:44:40 +0000 Subject: [PATCH 08/16] build(deps): bump org.apache.maven.plugins:maven-compiler-plugin 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] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 57f1eda2..3aa89e87 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.0 + 3.12.1 ${java.version} ${java.version} From 36a7cfb0b84cd22ba092b9b8c6da29d13e23f652 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Dec 2023 04:40:33 +0000 Subject: [PATCH 09/16] build(deps): bump org.jsoup:jsoup from 1.17.1 to 1.17.2 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.17.1 to 1.17.2. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.17.1...jsoup-1.17.2) --- updated-dependencies: - dependency-name: org.jsoup:jsoup 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 3aa89e87..3f75dda8 100644 --- a/pom.xml +++ b/pom.xml @@ -129,7 +129,7 @@ org.jsoup jsoup - 1.17.1 + 1.17.2 com.squareup.okhttp3 From d8f0a0126ec5cd50f67420d447e68f09126490ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 04:15:44 +0000 Subject: [PATCH 10/16] build(deps): bump joda-time:joda-time from 2.12.5 to 2.12.6 Bumps [joda-time:joda-time](https://github.com/JodaOrg/joda-time) from 2.12.5 to 2.12.6. - [Release notes](https://github.com/JodaOrg/joda-time/releases) - [Changelog](https://github.com/JodaOrg/joda-time/blob/main/RELEASE-NOTES.txt) - [Commits](https://github.com/JodaOrg/joda-time/compare/v2.12.5...v2.12.6) --- updated-dependencies: - dependency-name: joda-time:joda-time 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 3f75dda8..7744baf8 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,7 @@ joda-time joda-time - 2.12.5 + 2.12.6 com.github.codahale From 5de407db02c48a6d8a8ba399f3268f8edb9820f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 04:25:37 +0000 Subject: [PATCH 11/16] build(deps): bump joda-time:joda-time from 2.12.6 to 2.12.7 Bumps [joda-time:joda-time](https://github.com/JodaOrg/joda-time) from 2.12.6 to 2.12.7. - [Release notes](https://github.com/JodaOrg/joda-time/releases) - [Changelog](https://github.com/JodaOrg/joda-time/blob/main/RELEASE-NOTES.txt) - [Commits](https://github.com/JodaOrg/joda-time/compare/v2.12.6...v2.12.7) --- updated-dependencies: - dependency-name: joda-time:joda-time 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 7744baf8..2c74471b 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,7 @@ joda-time joda-time - 2.12.6 + 2.12.7 com.github.codahale From c8477b45d78bd11430bae7430797fc6dc78d1c06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 04:09:46 +0000 Subject: [PATCH 12/16] build(deps): bump org.json:json from 20231013 to 20240205 Bumps [org.json:json](https://github.com/douglascrockford/JSON-java) from 20231013 to 20240205. - [Release notes](https://github.com/douglascrockford/JSON-java/releases) - [Changelog](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md) - [Commits](https://github.com/douglascrockford/JSON-java/commits) --- updated-dependencies: - dependency-name: org.json:json dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2c74471b..24469090 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ org.json json - 20231013 + 20240205 com.google.code.gson From 4d6f2b228946b522c708ff8727203fe28ea39536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 04:08:07 +0000 Subject: [PATCH 13/16] build(deps): bump commons-codec:commons-codec from 1.16.0 to 1.16.1 Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.16.0 to 1.16.1. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.16.0...rel/commons-codec-1.16.1) --- updated-dependencies: - dependency-name: commons-codec:commons-codec 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 24469090..0d996e1c 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ commons-codec commons-codec - 1.16.0 + 1.16.1 From b14259effb114c137ba05812a77d98c54bb076c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 04:41:58 +0000 Subject: [PATCH 14/16] build(deps): bump org.apache.maven.plugins:maven-shade-plugin Bumps [org.apache.maven.plugins:maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.5.1 to 3.5.2. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.5.1...maven-shade-plugin-3.5.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-shade-plugin 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 24469090..a6efe28b 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.5.1 + 3.5.2 package From d04ca4fafb0bd5b873966492cc93e60b7a11d375 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 04:25:44 +0000 Subject: [PATCH 15/16] build(deps): bump org.springframework.boot:spring-boot-starter-websocket Bumps [org.springframework.boot:spring-boot-starter-websocket](https://github.com/spring-projects/spring-boot) from 3.2.1 to 3.2.3. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.1...v3.2.3) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-websocket 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 24469090..beddda92 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ org.springframework.boot spring-boot-starter-websocket - 3.2.1 + 3.2.3 From 118f5c06c91aede7fcc818ebd759ab3520c9dfe0 Mon Sep 17 00:00:00 2001 From: IoyoCode Date: Sat, 24 Feb 2024 17:11:00 +0000 Subject: [PATCH 16/16] removed 404 message --- .../java/com/seailz/discordjar/utils/rest/DiscordRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/seailz/discordjar/utils/rest/DiscordRequest.java b/src/main/java/com/seailz/discordjar/utils/rest/DiscordRequest.java index 1d0b672e..c7aadb17 100644 --- a/src/main/java/com/seailz/discordjar/utils/rest/DiscordRequest.java +++ b/src/main/java/com/seailz/discordjar/utils/rest/DiscordRequest.java @@ -352,8 +352,8 @@ private DiscordResponse invoke(String contentType, boolean auth) throws Unhandle } } catch (JSONException ignored) { } - Logger.getLogger("DiscordJar") - .warning("[REST] 404: " + message); +// Logger.getLogger("DiscordJar") +// .warning("[REST] 404: " + message); return new DiscordResponse(404, null, null, null); }