From 4877235ace0df60f2a64eb40a35ebf496f9362c3 Mon Sep 17 00:00:00 2001 From: Vankka Date: Mon, 1 Jan 2024 00:46:21 +0200 Subject: [PATCH] 1st party api improvements, gets rid of some asJDA usages --- .../com/discordsrv/api/DiscordSRVApi.java | 2 +- .../details/DiscordMemberCachePolicy.java | 2 +- .../entity/channel/DiscordThreadChannel.java | 36 ++++++++++++++++ .../entity/guild/DiscordGuildMember.java | 6 +++ .../interaction/DiscordInteractionHook.java | 6 ++- .../interaction/command/CommandOption.java | 4 +- .../interaction/command/DiscordCommand.java | 8 ++-- .../interaction/component/impl/Button.java | 2 +- .../interaction/component/impl/Modal.java | 2 +- .../component/impl/SelectMenu.java | 2 +- .../impl/SendableDiscordMessageImpl.java | 2 +- .../events/discord}/AbstractDiscordEvent.java | 2 +- .../events/discord}/DiscordEvent.java | 2 +- .../AbstractDeferrableInteractionEvent.java | 2 +- .../interaction/AbstractInteractionEvent.java | 4 +- .../DiscordModalInteractionEvent.java | 2 +- .../AbstractCommandInteractionEvent.java | 23 +++++++++-- .../command/CommandRegisterEvent.java | 2 +- .../DiscordChatInputInteractionEvent.java | 4 +- ...rdCommandAutoCompleteInteractionEvent.java | 10 ++++- ...DiscordMessageContextInteractionEvent.java | 4 +- .../DiscordUserContextInteractionEvent.java | 4 +- .../DiscordButtonInteractionEvent.java | 4 +- .../DiscordSelectMenuInteractionEvent.java | 5 +-- .../member/AbstractDiscordMemberEvent.java | 4 +- .../AbstractDiscordMemberRoleChangeEvent.java | 4 +- .../role/DiscordMemberRoleAddEvent.java | 2 +- .../role/DiscordMemberRoleRemoveEvent.java | 2 +- .../message/AbstractDiscordMessageEvent.java | 4 +- .../message/DiscordMessageDeleteEvent.java | 2 +- .../message/DiscordMessageReceiveEvent.java | 2 +- .../message/DiscordMessageUpdateEvent.java | 2 +- .../BukkitRequiredLinkingModule.java | 1 - .../discordsrv/bungee/BungeeDiscordSRV.java | 4 +- .../common/channel/ChannelConfigHelper.java | 4 +- .../combined/abstraction/CombinedCommand.java | 4 +- .../abstraction/DiscordCommandExecution.java | 4 +- .../command/discord/DiscordCommandModule.java | 2 +- .../commands/subcommand/ExecuteCommand.java | 41 ++++++++++--------- .../base/proxy/ProxyBaseChannelConfig.java | 2 +- .../base/server/ServerBaseChannelConfig.java | 2 +- .../common/console/SingleConsoleHandler.java | 2 +- .../common/console/entry/LogEntry.java | 4 -- .../discord/api/DiscordAPIEventModule.java | 30 ++++++++------ .../common/discord/api/DiscordAPIImpl.java | 13 +++--- .../discord/api/DiscordCommandRegistry.java | 4 +- .../channel/DiscordThreadChannelImpl.java | 30 ++++++++++++++ .../component/DiscordInteractionHookImpl.java | 13 +----- .../entity/guild/DiscordGuildMemberImpl.java | 5 +++ .../DiscordChatInputInteractionEventImpl.java | 39 ++++++++++++++++++ ...ordMessageContextInteractionEventImpl.java | 39 ++++++++++++++++++ ...iscordUserContextInteractionEventImpl.java | 39 ++++++++++++++++++ .../events/player}/PlayerConnectedEvent.java | 2 +- .../player}/PlayerDisconnectedEvent.java | 2 +- .../common/groupsync/GroupSyncModule.java | 6 +-- .../linking/impl/CachedLinkProvider.java | 2 +- .../discord/DiscordChatMessageModule.java | 6 +-- .../DiscordMessageMirroringModule.java | 4 +- .../game/AwardMessageModule.java | 2 +- .../result/ComponentResultStringifier.java | 2 +- .../provider/AbstractPlayerProvider.java | 4 +- .../player/provider/ServerPlayerProvider.java | 1 - .../common/update/UpdateChecker.java | 2 +- .../discordsrv/sponge/SpongeDiscordSRV.java | 4 +- .../velocity/VelocityDiscordSRV.java | 4 +- 65 files changed, 347 insertions(+), 138 deletions(-) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/AbstractDiscordEvent.java (97%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/DiscordEvent.java (96%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/AbstractDeferrableInteractionEvent.java (97%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/AbstractInteractionEvent.java (95%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/DiscordModalInteractionEvent.java (97%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/command/AbstractCommandInteractionEvent.java (69%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/command/CommandRegisterEvent.java (97%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/command/DiscordChatInputInteractionEvent.java (91%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java (87%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/command/DiscordMessageContextInteractionEvent.java (94%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/command/DiscordUserContextInteractionEvent.java (91%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/component/DiscordButtonInteractionEvent.java (92%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/interaction/component/DiscordSelectMenuInteractionEvent.java (92%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/member/AbstractDiscordMemberEvent.java (93%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/member/role/AbstractDiscordMemberRoleChangeEvent.java (93%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/member/role/DiscordMemberRoleAddEvent.java (96%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/member/role/DiscordMemberRoleRemoveEvent.java (96%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/message/AbstractDiscordMessageEvent.java (96%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/message/DiscordMessageDeleteEvent.java (96%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/message/DiscordMessageReceiveEvent.java (97%) rename api/src/main/java/com/discordsrv/api/{discord/events => event/events/discord}/message/DiscordMessageUpdateEvent.java (97%) create mode 100644 common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java create mode 100644 common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java create mode 100644 common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java rename common/src/main/java/com/discordsrv/common/{player/event => event/events/player}/PlayerConnectedEvent.java (96%) rename common/src/main/java/com/discordsrv/common/{player/event => event/events/player}/PlayerDisconnectedEvent.java (95%) diff --git a/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java b/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java index d5ae2c89..e5241b1c 100644 --- a/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java +++ b/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java @@ -27,8 +27,8 @@ import com.discordsrv.api.component.MinecraftComponentFactory; import com.discordsrv.api.discord.DiscordAPI; import com.discordsrv.api.discord.connection.details.DiscordConnectionDetails; import com.discordsrv.api.event.bus.EventBus; -import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.placeholder.PlaceholderService; +import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.api.player.IPlayerProvider; import com.discordsrv.api.profile.IProfileManager; diff --git a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java index 70992ad8..22d526be 100644 --- a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java +++ b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java @@ -38,7 +38,7 @@ public interface DiscordMemberCachePolicy { .map(api -> api.profileManager().getProfile(member.getUser().getId())) .map(IProfile::isLinked).orElse(false); DiscordMemberCachePolicy VOICE = member -> member.asJDA().getVoiceState() != null; - DiscordMemberCachePolicy OWNER = member -> member.asJDA().isOwner(); + DiscordMemberCachePolicy OWNER = DiscordGuildMember::isOwner; boolean isCached(DiscordGuildMember member); } diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java index 055fd8d8..792aa835 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java @@ -32,4 +32,40 @@ public interface DiscordThreadChannel extends DiscordGuildMessageChannel, JDAEnt @NotNull DiscordThreadContainer getParentChannel(); + /** + * Is this thread archived. + * @return {@code true} if the thread is archived + */ + boolean isArchived(); + + /** + * Is this thread locked from replies by non-moderators. + * @return {@code true} if the thread is locked + */ + boolean isLocked(); + + /** + * Is the self user (bot) joined in this thread. + * @return {@code true} if the self user is current a part of this thread + */ + boolean isJoined(); + + /** + * Is this thread invitable, meaning non-moderators can invite non-moderators to the thread. + * @return {@code true} if the thread is invitable + */ + boolean isInvitable(); + + /** + * Is the self user (bot) the owner of this thread. + * @return {@code true} if the self user is the owner of this thread + */ + boolean isOwnedBySelfUser(); + + /** + * Is this thread public, meaning anybody can read and join it if they can see its parent channel. + * @return {@code true} if this thread is public + */ + boolean isPublic(); + } diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java index bf6fd051..e1d427be 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java @@ -58,6 +58,12 @@ public interface DiscordGuildMember extends JDAEntity, Mentionable { @NotNull DiscordGuild getGuild(); + /** + * If this Discord server member is the owner of the Discord server. + * @return {@code true} if this member is the server owner + */ + boolean isOwner(); + /** * Gets the nickname of the Discord server member. * @return the nickname server member diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java index c46eaa28..c49d289a 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java @@ -39,8 +39,10 @@ public interface DiscordInteractionHook extends JDAEntity { CompletableFuture replyLater(boolean ephemeral); CompletableFuture editOriginal(SendableDiscordMessage message); - CompletableFuture reply(SendableDiscordMessage message); - CompletableFuture replyEphemeral(SendableDiscordMessage message); + CompletableFuture reply(SendableDiscordMessage message, boolean ephemeral); + default CompletableFuture reply(SendableDiscordMessage message) { + return reply(message, false); + } CompletableFuture replyModal(Modal modal); } diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java index 1d3c1a2d..ccf20287 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java @@ -229,11 +229,11 @@ public class CommandOption implements JDAEntity { } /** - * Sets if this option is auto completed. See {@link com.discordsrv.api.discord.events.interaction.command.DiscordCommandAutoCompleteInteractionEvent}. + * Sets if this option is auto completed. See {@link com.discordsrv.api.event.events.discord.interaction.command.DiscordCommandAutoCompleteInteractionEvent}. * * @param autoComplete is this choice auto completing * @return this builder, useful for chaining - * @see com.discordsrv.api.discord.events.interaction.command.DiscordCommandAutoCompleteInteractionEvent + * @see com.discordsrv.api.event.events.discord.interaction.command.DiscordCommandAutoCompleteInteractionEvent */ @NotNull public Builder setAutoComplete(boolean autoComplete) { diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java index 40d850e7..56b00574 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java @@ -25,7 +25,7 @@ package com.discordsrv.api.discord.entity.interaction.command; import com.discordsrv.api.discord.entity.JDAEntity; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; -import com.discordsrv.api.discord.events.interaction.command.*; +import com.discordsrv.api.event.events.discord.interaction.command.*; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; import net.dv8tion.jda.api.interactions.commands.build.*; @@ -52,7 +52,7 @@ public class DiscordCommand implements JDAEntity { * @param name the name of the command, 1-32 characters alphanumeric and dashes * @param description the description of the command * @return a new chat input command builder - * @see com.discordsrv.api.discord.events.interaction.command.DiscordChatInputInteractionEvent + * @see com.discordsrv.api.event.events.discord.interaction.command.DiscordChatInputInteractionEvent */ public static ChatInputBuilder chatInput( ComponentIdentifier id, @@ -71,7 +71,7 @@ public class DiscordCommand implements JDAEntity { * @param id a unique identifier for this interaction, used to check if a given event was for this interaction * @param name the name of the command, 1-32 characters * @return a new command builder - * @see com.discordsrv.api.discord.events.interaction.command.DiscordUserContextInteractionEvent + * @see com.discordsrv.api.event.events.discord.interaction.command.DiscordUserContextInteractionEvent */ public static Builder user( ComponentIdentifier id, @@ -86,7 +86,7 @@ public class DiscordCommand implements JDAEntity { * @param id a unique identifier for this interaction, used to check if a given event was for this interaction * @param name the name of the command, 1-32 characters * @return a new command builder - * @see com.discordsrv.api.discord.events.interaction.command.DiscordMessageContextInteractionEvent + * @see com.discordsrv.api.event.events.discord.interaction.command.DiscordMessageContextInteractionEvent */ public static Builder message( ComponentIdentifier id, diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java index f4ad1f36..dbc0fb71 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java @@ -38,7 +38,7 @@ import java.util.UUID; * A Discord button. * @see #builder(ComponentIdentifier, Style) * @see #urlBuilder(String) - * @see com.discordsrv.api.discord.events.interaction.component.DiscordButtonInteractionEvent + * @see com.discordsrv.api.event.events.discord.interaction.component.DiscordButtonInteractionEvent */ public class Button implements MessageComponent { diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java index 57f5d2ce..a43fc777 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java @@ -37,7 +37,7 @@ import java.util.stream.Collectors; /** * A Discord modal. * @see #builder(ComponentIdentifier, String) - * @see com.discordsrv.api.discord.events.interaction.DiscordModalInteractionEvent + * @see com.discordsrv.api.event.events.discord.interaction.DiscordModalInteractionEvent */ public class Modal implements JDAEntity { diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java index ff0c4234..3ddca623 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java @@ -38,7 +38,7 @@ import java.util.List; /** * A Discord selection menu. * @see #builder(ComponentIdentifier) - * @see com.discordsrv.api.discord.events.interaction.component.DiscordSelectMenuInteractionEvent + * @see com.discordsrv.api.event.events.discord.interaction.component.DiscordSelectMenuInteractionEvent */ // TODO: newest changes public class SelectMenu implements MessageComponent { diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java b/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java index c3926d8c..08f56b08 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java @@ -29,9 +29,9 @@ import com.discordsrv.api.discord.entity.message.AllowedMention; import com.discordsrv.api.discord.entity.message.DiscordMessageEmbed; import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; import com.discordsrv.api.discord.util.DiscordFormattingUtil; -import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.placeholder.FormattedText; import com.discordsrv.api.placeholder.PlaceholderService; +import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.placeholder.util.Placeholders; import net.dv8tion.jda.api.entities.MessageEmbed; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/AbstractDiscordEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/AbstractDiscordEvent.java similarity index 97% rename from api/src/main/java/com/discordsrv/api/discord/events/AbstractDiscordEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/AbstractDiscordEvent.java index 2b81cec9..0441b131 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/AbstractDiscordEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/AbstractDiscordEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events; +package com.discordsrv.api.event.events.discord; import net.dv8tion.jda.api.events.GenericEvent; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/DiscordEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/DiscordEvent.java similarity index 96% rename from api/src/main/java/com/discordsrv/api/discord/events/DiscordEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/DiscordEvent.java index 37b52c40..5071ccf0 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/DiscordEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/DiscordEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events; +package com.discordsrv.api.event.events.discord; import com.discordsrv.api.discord.entity.JDAEntity; import com.discordsrv.api.event.events.Event; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/AbstractDeferrableInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java similarity index 97% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/AbstractDeferrableInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java index 47f8a0a3..0febdaf6 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/AbstractDeferrableInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction; +package com.discordsrv.api.event.events.discord.interaction; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/AbstractInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java similarity index 95% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/AbstractInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java index aa602665..8d84bf22 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/AbstractInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java @@ -21,14 +21,14 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction; +package com.discordsrv.api.event.events.discord.interaction; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuild; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; -import com.discordsrv.api.discord.events.AbstractDiscordEvent; +import com.discordsrv.api.event.events.discord.AbstractDiscordEvent; import net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/DiscordModalInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java similarity index 97% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/DiscordModalInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java index 271fd9dc..04ec14fe 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/DiscordModalInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction; +package com.discordsrv.api.event.events.discord.interaction; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/AbstractCommandInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java similarity index 69% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/command/AbstractCommandInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java index 4604392c..1a9e3d3d 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/AbstractCommandInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java @@ -21,17 +21,22 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.command; +package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; -import com.discordsrv.api.discord.events.interaction.AbstractDeferrableInteractionEvent; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; +import com.discordsrv.api.event.events.discord.interaction.AbstractDeferrableInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionMapping; +import org.jetbrains.annotations.Nullable; -public class AbstractCommandInteractionEvent +import java.util.concurrent.CompletableFuture; + +public abstract class AbstractCommandInteractionEvent extends AbstractDeferrableInteractionEvent { public AbstractCommandInteractionEvent( @@ -44,4 +49,16 @@ public class AbstractCommandInteractionEvent reply(SendableDiscordMessage message, boolean ephemeral); + + public CompletableFuture reply(SendableDiscordMessage message) { + return reply(message, false); + } + + @Nullable + public String getOption(String name) { + OptionMapping mapping = jdaEvent.getOption(name); + return mapping != null ? mapping.getAsString() : null; + } } diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/CommandRegisterEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java similarity index 97% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/command/CommandRegisterEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java index 35141392..e5d6c3bc 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/CommandRegisterEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.command; +package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; import com.discordsrv.api.event.events.Event; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordChatInputInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java similarity index 91% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordChatInputInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java index ecf1059e..61a1dc9a 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordChatInputInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.command; +package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; @@ -30,7 +30,7 @@ import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -public class DiscordChatInputInteractionEvent extends AbstractCommandInteractionEvent { +public abstract class DiscordChatInputInteractionEvent extends AbstractCommandInteractionEvent { public DiscordChatInputInteractionEvent( SlashCommandInteractionEvent jdaEvent, diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java similarity index 87% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java index d4376b2b..f70f965a 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java @@ -21,14 +21,15 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.command; +package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; -import com.discordsrv.api.discord.events.interaction.AbstractInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.AbstractInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionMapping; import java.util.LinkedHashMap; import java.util.Map; @@ -47,6 +48,11 @@ public class DiscordCommandAutoCompleteInteractionEvent extends AbstractInteract super(jdaEvent, identifier, user, member, channel); } + public String getOption(String name) { + OptionMapping mapping = jdaEvent.getOption(name); + return mapping != null ? mapping.getAsString() : null; + } + public void addChoice(String name, String value) { this.choices.put(name, value); } diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordMessageContextInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java similarity index 94% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordMessageContextInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java index 881e4a8e..2758808e 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordMessageContextInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.command; +package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; @@ -30,7 +30,7 @@ import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent; -public class DiscordMessageContextInteractionEvent +public abstract class DiscordMessageContextInteractionEvent extends AbstractCommandInteractionEvent { public DiscordMessageContextInteractionEvent( diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordUserContextInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java similarity index 91% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordUserContextInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java index 285a9252..5a7a8e4f 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/command/DiscordUserContextInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.command; +package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; @@ -30,7 +30,7 @@ import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent; -public class DiscordUserContextInteractionEvent extends AbstractCommandInteractionEvent { +public abstract class DiscordUserContextInteractionEvent extends AbstractCommandInteractionEvent { public DiscordUserContextInteractionEvent( UserContextInteractionEvent jdaEvent, diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/component/DiscordButtonInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java similarity index 92% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/component/DiscordButtonInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java index d8d54aed..b75176b1 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/component/DiscordButtonInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java @@ -21,14 +21,14 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.component; +package com.discordsrv.api.event.events.discord.interaction.component; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; -import com.discordsrv.api.discord.events.interaction.AbstractDeferrableInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.AbstractDeferrableInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; public class DiscordButtonInteractionEvent extends AbstractDeferrableInteractionEvent { diff --git a/api/src/main/java/com/discordsrv/api/discord/events/interaction/component/DiscordSelectMenuInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java similarity index 92% rename from api/src/main/java/com/discordsrv/api/discord/events/interaction/component/DiscordSelectMenuInteractionEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java index 743a823f..942956e7 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/interaction/component/DiscordSelectMenuInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java @@ -21,17 +21,16 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.interaction.component; +package com.discordsrv.api.event.events.discord.interaction.component; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; -import com.discordsrv.api.discord.events.interaction.AbstractDeferrableInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.AbstractDeferrableInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.GenericSelectMenuInteractionEvent; -// TODO: newest changes public class DiscordSelectMenuInteractionEvent extends AbstractDeferrableInteractionEvent> { public DiscordSelectMenuInteractionEvent( diff --git a/api/src/main/java/com/discordsrv/api/discord/events/member/AbstractDiscordMemberEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java similarity index 93% rename from api/src/main/java/com/discordsrv/api/discord/events/member/AbstractDiscordMemberEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java index d8e51ffa..8331aa06 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/member/AbstractDiscordMemberEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java @@ -21,10 +21,10 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.member; +package com.discordsrv.api.event.events.discord.member; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; -import com.discordsrv.api.discord.events.AbstractDiscordEvent; +import com.discordsrv.api.event.events.discord.AbstractDiscordEvent; import net.dv8tion.jda.api.events.guild.member.GenericGuildMemberEvent; public abstract class AbstractDiscordMemberEvent extends AbstractDiscordEvent { diff --git a/api/src/main/java/com/discordsrv/api/discord/events/member/role/AbstractDiscordMemberRoleChangeEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java similarity index 93% rename from api/src/main/java/com/discordsrv/api/discord/events/member/role/AbstractDiscordMemberRoleChangeEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java index e2654d14..4d9f95f3 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/member/role/AbstractDiscordMemberRoleChangeEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java @@ -21,11 +21,11 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.member.role; +package com.discordsrv.api.event.events.discord.member.role; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.guild.DiscordRole; -import com.discordsrv.api.discord.events.member.AbstractDiscordMemberEvent; +import com.discordsrv.api.event.events.discord.member.AbstractDiscordMemberEvent; import net.dv8tion.jda.api.events.guild.member.GenericGuildMemberEvent; import java.util.List; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/member/role/DiscordMemberRoleAddEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java similarity index 96% rename from api/src/main/java/com/discordsrv/api/discord/events/member/role/DiscordMemberRoleAddEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java index 96821c6d..76eefc27 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/member/role/DiscordMemberRoleAddEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.member.role; +package com.discordsrv.api.event.events.discord.member.role; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.guild.DiscordRole; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/member/role/DiscordMemberRoleRemoveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java similarity index 96% rename from api/src/main/java/com/discordsrv/api/discord/events/member/role/DiscordMemberRoleRemoveEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java index 6b52bb80..748f2318 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/member/role/DiscordMemberRoleRemoveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.member.role; +package com.discordsrv.api.event.events.discord.member.role; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.guild.DiscordRole; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/message/AbstractDiscordMessageEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/AbstractDiscordMessageEvent.java similarity index 96% rename from api/src/main/java/com/discordsrv/api/discord/events/message/AbstractDiscordMessageEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/message/AbstractDiscordMessageEvent.java index 6a425466..1aed976e 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/message/AbstractDiscordMessageEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/AbstractDiscordMessageEvent.java @@ -21,13 +21,13 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.message; +package com.discordsrv.api.event.events.discord.message; import com.discordsrv.api.discord.entity.channel.DiscordDMChannel; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.channel.DiscordTextChannel; import com.discordsrv.api.discord.entity.channel.DiscordThreadChannel; -import com.discordsrv.api.discord.events.AbstractDiscordEvent; +import com.discordsrv.api.event.events.discord.AbstractDiscordEvent; import net.dv8tion.jda.api.events.message.GenericMessageEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageDeleteEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageDeleteEvent.java similarity index 96% rename from api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageDeleteEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageDeleteEvent.java index ab67e360..f16ee650 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageDeleteEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageDeleteEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.message; +package com.discordsrv.api.event.events.discord.message; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import net.dv8tion.jda.api.events.message.MessageDeleteEvent; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageReceiveEvent.java similarity index 97% rename from api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageReceiveEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageReceiveEvent.java index 1c0f6a76..e783ef66 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageReceiveEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.message; +package com.discordsrv.api.event.events.discord.message; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; diff --git a/api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageUpdateEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java similarity index 97% rename from api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageUpdateEvent.java rename to api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java index 27a3ecd6..0118c50d 100644 --- a/api/src/main/java/com/discordsrv/api/discord/events/message/DiscordMessageUpdateEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java @@ -21,7 +21,7 @@ * SOFTWARE. */ -package com.discordsrv.api.discord.events.message; +package com.discordsrv.api.event.events.discord.message; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java b/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java index 154e4c6a..f03d0bcb 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java @@ -20,7 +20,6 @@ package com.discordsrv.bukkit.requiredlinking; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.config.main.BukkitRequiredLinkingConfig; -import com.discordsrv.common.config.main.linking.RequirementsConfig; import com.discordsrv.common.linking.requirelinking.ServerRequireLinkingModule; import org.bukkit.event.Listener; diff --git a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java index 3c0d43f1..7e016c46 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java +++ b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java @@ -24,11 +24,11 @@ import com.discordsrv.bungee.player.BungeePlayerProvider; import com.discordsrv.bungee.plugin.BungeePluginManager; import com.discordsrv.common.ProxyDiscordSRV; import com.discordsrv.common.command.game.handler.ICommandHandler; +import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; +import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.configurate.manager.MessagesConfigManager; import com.discordsrv.common.config.connection.ConnectionConfig; import com.discordsrv.common.config.main.MainConfig; -import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; -import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.messages.MessagesConfig; import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.plugin.PluginManager; diff --git a/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java b/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java index f8b20870..a47fe86e 100644 --- a/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java +++ b/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java @@ -24,12 +24,12 @@ import com.discordsrv.api.discord.entity.channel.DiscordTextChannel; import com.discordsrv.api.discord.entity.channel.DiscordThreadChannel; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.channels.base.ChannelConfig; import com.discordsrv.common.config.main.channels.base.IChannelConfig; -import com.discordsrv.common.config.main.generic.ThreadConfig; import com.discordsrv.common.config.main.generic.DestinationConfig; -import com.discordsrv.common.config.configurate.manager.MainConfigManager; +import com.discordsrv.common.config.main.generic.ThreadConfig; import com.github.benmanes.caffeine.cache.CacheLoader; import com.github.benmanes.caffeine.cache.LoadingCache; import org.apache.commons.lang3.tuple.Pair; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java index c0779646..ef8abaa3 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java @@ -1,8 +1,8 @@ package com.discordsrv.common.command.combined.abstraction; import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; -import com.discordsrv.api.discord.events.interaction.command.DiscordChatInputInteractionEvent; -import com.discordsrv.api.discord.events.interaction.command.DiscordCommandAutoCompleteInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordChatInputInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordCommandAutoCompleteInteractionEvent; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.command.game.abstraction.GameCommandArguments; import com.discordsrv.common.command.game.abstraction.GameCommandExecutor; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java index 7a733131..cbeb75fa 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java @@ -1,7 +1,7 @@ package com.discordsrv.common.command.combined.abstraction; -import com.discordsrv.api.discord.events.interaction.command.DiscordChatInputInteractionEvent; -import com.discordsrv.api.discord.events.interaction.command.DiscordCommandAutoCompleteInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordChatInputInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordCommandAutoCompleteInteractionEvent; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.messages.MessagesConfig; import net.dv8tion.jda.api.entities.User; diff --git a/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java b/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java index 84b57ffa..a876cea6 100644 --- a/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java +++ b/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java @@ -1,7 +1,7 @@ package com.discordsrv.common.command.discord; -import com.discordsrv.api.discord.events.interaction.command.CommandRegisterEvent; import com.discordsrv.api.event.bus.Subscribe; +import com.discordsrv.api.event.events.discord.interaction.command.CommandRegisterEvent; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.command.discord.commands.DiscordSRVDiscordCommand; import com.discordsrv.common.module.type.AbstractModule; diff --git a/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java b/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java index d03aec85..04b1c4fc 100644 --- a/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java @@ -2,11 +2,13 @@ package com.discordsrv.common.command.discord.commands.subcommand; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; +import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.command.CommandOption; import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; -import com.discordsrv.api.discord.events.interaction.command.DiscordChatInputInteractionEvent; -import com.discordsrv.api.discord.events.interaction.command.DiscordCommandAutoCompleteInteractionEvent; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordChatInputInteractionEvent; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordCommandAutoCompleteInteractionEvent; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.command.game.GameCommandExecutionHelper; import com.discordsrv.common.config.main.DiscordCommandConfig; @@ -14,8 +16,6 @@ import com.discordsrv.common.config.main.generic.GameCommandExecutionConditionCo import com.discordsrv.common.logging.Logger; import com.discordsrv.common.logging.NamedLogger; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.interactions.InteractionHook; -import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.kyori.adventure.text.Component; import java.time.Duration; @@ -72,25 +72,28 @@ public class ExecuteCommand implements Consumer new ExecutionContext(discordSRV, ih, config.outputMode, ephemeral).run(event.getUser(), command)); + event.reply(SendableDiscordMessage.builder().setContent("Executing command `" + command + "`").build()) + .whenComplete((ih, t) -> { + if (t != null) { + return; + } + new ExecutionContext(discordSRV, ih, config.outputMode, ephemeral).run(event.getUser(), command); + }); } @Override @@ -105,14 +108,12 @@ public class ExecuteCommand implements Consumer parts = new ArrayList<>(Arrays.asList(command.split(" "))); - List suggestions = getSuggestions(parts); if (suggestions == null) { return; @@ -177,7 +178,7 @@ public class ExecuteCommand implements Consumer future; @@ -185,7 +186,7 @@ public class ExecuteCommand implements Consumer Message.MAX_CONTENT_LENGTH) { - hook.sendMessage(prefix + joiner + suffix).setEphemeral(ephemeral).queue(); + hook.reply(SendableDiscordMessage.builder().setContent(prefix + joiner + suffix).build(), ephemeral); joiner = new StringJoiner(delimiter); } @@ -249,7 +250,7 @@ public class ExecuteCommand implements Consumer { return; } - DiscordMessageContextInteractionEvent interactionEvent = new DiscordMessageContextInteractionEvent( + DiscordMessageContextInteractionEvent interactionEvent = new DiscordMessageContextInteractionEventImpl( + discordSRV, (MessageContextInteractionEvent) event, command.getId(), user, @@ -202,7 +206,8 @@ public class DiscordAPIEventModule extends AbstractModule { return; } - DiscordUserContextInteractionEvent interactionEvent = new DiscordUserContextInteractionEvent( + DiscordUserContextInteractionEvent interactionEvent = new DiscordUserContextInteractionEventImpl( + discordSRV, (UserContextInteractionEvent) event, command.getId(), user, @@ -228,7 +233,8 @@ public class DiscordAPIEventModule extends AbstractModule { ((SlashCommandInteractionEvent) event).getSubcommandName() ); - DiscordChatInputInteractionEvent interactionEvent = new DiscordChatInputInteractionEvent( + DiscordChatInputInteractionEvent interactionEvent = new DiscordChatInputInteractionEventImpl( + discordSRV, (SlashCommandInteractionEvent) event, command.getId(), user, diff --git a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java index 25e40576..04cdb967 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java @@ -33,8 +33,8 @@ import com.discordsrv.api.discord.exception.RestErrorResponseException; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.channels.base.IChannelConfig; -import com.discordsrv.common.config.main.generic.ThreadConfig; import com.discordsrv.common.config.main.generic.DestinationConfig; +import com.discordsrv.common.config.main.generic.ThreadConfig; import com.discordsrv.common.discord.api.entity.DiscordUserImpl; import com.discordsrv.common.discord.api.entity.channel.*; import com.discordsrv.common.discord.api.entity.guild.DiscordCustomEmojiImpl; @@ -139,10 +139,9 @@ public class DiscordAPIImpl implements DiscordAPI { // Check if a thread by the same name is still active DiscordThreadChannel thread = findThread(threadConfig, channel.getActiveThreads()); if (thread != null) { - ThreadChannel jdaChannel = thread.asJDA(); - if (!jdaChannel.isArchived()) { + if (!thread.isArchived()) { synchronized (channels) { - channels.add(getThreadChannel(jdaChannel)); + channels.add(thread); } continue; } @@ -253,10 +252,10 @@ public class DiscordAPIImpl implements DiscordAPI { CompletableFuture future ) { if (thread != null) { - ThreadChannel channel = thread.asJDA(); - if (channel.isLocked() || channel.isArchived()) { + if (thread.isLocked() || thread.isArchived()) { try { - channel.getManager() + thread.asJDA() + .getManager() .setArchived(false) .reason("DiscordSRV Auto Unarchive") .queue(v -> future.complete(thread), future::completeExceptionally); diff --git a/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java b/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java index 31961fd7..f7f6314f 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java @@ -19,9 +19,9 @@ package com.discordsrv.common.discord.api; import com.discordsrv.api.discord.entity.JDAEntity; -import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; import com.discordsrv.api.discord.entity.interaction.command.CommandType; -import com.discordsrv.api.discord.events.interaction.command.CommandRegisterEvent; +import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; +import com.discordsrv.api.event.events.discord.interaction.command.CommandRegisterEvent; import com.discordsrv.common.DiscordSRV; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java index dcb2cadc..6fcc6bc0 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java @@ -81,6 +81,36 @@ public class DiscordThreadChannelImpl extends AbstractDiscordGuildMessageChannel return threadContainer; } + @Override + public boolean isArchived() { + return channel.isArchived(); + } + + @Override + public boolean isLocked() { + return channel.isLocked(); + } + + @Override + public boolean isJoined() { + return channel.isJoined(); + } + + @Override + public boolean isInvitable() { + return channel.isInvitable(); + } + + @Override + public boolean isOwnedBySelfUser() { + return channel.isOwner(); + } + + @Override + public boolean isPublic() { + return channel.isPublic(); + } + @Override public String toString() { return "Thread:" + getName() + "(" + Long.toUnsignedString(getId()) + " in " + threadContainer + ")"; diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java index bddb3a38..1abf5c10 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java @@ -72,20 +72,11 @@ public class DiscordInteractionHookImpl implements DiscordInteractionHook { } @Override - public CompletableFuture reply(SendableDiscordMessage message) { + public CompletableFuture reply(SendableDiscordMessage message, boolean ephemeral) { if (!(hook instanceof IReplyCallback)) { throw new IllegalStateException("This interaction cannot be replied to"); } - return ((IReplyCallback) hook).reply(SendableDiscordMessageUtil.toJDASend(message)).submit() - .thenApply(hook -> new DiscordInteractionHookImpl(discordSRV, hook)); - } - - @Override - public CompletableFuture replyEphemeral(SendableDiscordMessage message) { - if (!(hook instanceof IReplyCallback)) { - throw new IllegalStateException("This interaction cannot be replied to"); - } - return ((IReplyCallback) hook).reply(SendableDiscordMessageUtil.toJDASend(message)).setEphemeral(true).submit() + return ((IReplyCallback) hook).reply(SendableDiscordMessageUtil.toJDASend(message)).setEphemeral(ephemeral).submit() .thenApply(hook -> new DiscordInteractionHookImpl(discordSRV, hook)); } diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java index 9efb03e3..e14e2973 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java @@ -74,6 +74,11 @@ public class DiscordGuildMemberImpl implements DiscordGuildMember { return guild; } + @Override + public boolean isOwner() { + return member.isOwner(); + } + @Override public @Nullable String getNickname() { return member.getNickname(); diff --git a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java new file mode 100644 index 00000000..694d7177 --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java @@ -0,0 +1,39 @@ +package com.discordsrv.common.event.events.discord.interaction.command; + +import com.discordsrv.api.discord.entity.DiscordUser; +import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; +import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; +import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; +import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordChatInputInteractionEvent; +import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.discord.api.entity.component.DiscordInteractionHookImpl; +import com.discordsrv.common.discord.api.entity.message.util.SendableDiscordMessageUtil; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; + +import java.util.concurrent.CompletableFuture; + +public class DiscordChatInputInteractionEventImpl extends DiscordChatInputInteractionEvent { + + private final DiscordSRV discordSRV; + + public DiscordChatInputInteractionEventImpl( + DiscordSRV discordSRV, + SlashCommandInteractionEvent jdaEvent, + ComponentIdentifier identifier, + DiscordUser user, + DiscordGuildMember member, + DiscordMessageChannel channel, DiscordInteractionHook interaction) { + super(jdaEvent, identifier, user, member, channel, interaction); + this.discordSRV = discordSRV; + } + + @Override + public CompletableFuture reply(SendableDiscordMessage message, boolean ephemeral) { + return discordSRV.discordAPI().mapExceptions( + () -> jdaEvent.reply(SendableDiscordMessageUtil.toJDASend(message)).setEphemeral(ephemeral).submit() + .thenApply(ih -> new DiscordInteractionHookImpl(discordSRV, ih)) + ); + } +} diff --git a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java new file mode 100644 index 00000000..1a0c21db --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java @@ -0,0 +1,39 @@ +package com.discordsrv.common.event.events.discord.interaction.command; + +import com.discordsrv.api.discord.entity.DiscordUser; +import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; +import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; +import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; +import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordMessageContextInteractionEvent; +import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.discord.api.entity.component.DiscordInteractionHookImpl; +import com.discordsrv.common.discord.api.entity.message.util.SendableDiscordMessageUtil; +import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent; + +import java.util.concurrent.CompletableFuture; + +public class DiscordMessageContextInteractionEventImpl extends DiscordMessageContextInteractionEvent { + + private final DiscordSRV discordSRV; + + public DiscordMessageContextInteractionEventImpl( + DiscordSRV discordSRV, + MessageContextInteractionEvent jdaEvent, + ComponentIdentifier identifier, + DiscordUser user, + DiscordGuildMember member, + DiscordMessageChannel channel, DiscordInteractionHook interaction) { + super(jdaEvent, identifier, user, member, channel, interaction); + this.discordSRV = discordSRV; + } + + @Override + public CompletableFuture reply(SendableDiscordMessage message, boolean ephemeral) { + return discordSRV.discordAPI().mapExceptions( + () -> jdaEvent.reply(SendableDiscordMessageUtil.toJDASend(message)).setEphemeral(ephemeral).submit() + .thenApply(ih -> new DiscordInteractionHookImpl(discordSRV, ih)) + ); + } +} diff --git a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java new file mode 100644 index 00000000..408eb262 --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java @@ -0,0 +1,39 @@ +package com.discordsrv.common.event.events.discord.interaction.command; + +import com.discordsrv.api.discord.entity.DiscordUser; +import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; +import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; +import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; +import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; +import com.discordsrv.api.event.events.discord.interaction.command.DiscordUserContextInteractionEvent; +import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.discord.api.entity.component.DiscordInteractionHookImpl; +import com.discordsrv.common.discord.api.entity.message.util.SendableDiscordMessageUtil; +import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent; + +import java.util.concurrent.CompletableFuture; + +public class DiscordUserContextInteractionEventImpl extends DiscordUserContextInteractionEvent { + + private final DiscordSRV discordSRV; + + public DiscordUserContextInteractionEventImpl( + DiscordSRV discordSRV, + UserContextInteractionEvent jdaEvent, + ComponentIdentifier identifier, + DiscordUser user, + DiscordGuildMember member, + DiscordMessageChannel channel, DiscordInteractionHook interaction) { + super(jdaEvent, identifier, user, member, channel, interaction); + this.discordSRV = discordSRV; + } + + @Override + public CompletableFuture reply(SendableDiscordMessage message, boolean ephemeral) { + return discordSRV.discordAPI().mapExceptions( + () -> jdaEvent.reply(SendableDiscordMessageUtil.toJDASend(message)).setEphemeral(ephemeral).submit() + .thenApply(ih -> new DiscordInteractionHookImpl(discordSRV, ih)) + ); + } +} diff --git a/common/src/main/java/com/discordsrv/common/player/event/PlayerConnectedEvent.java b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerConnectedEvent.java similarity index 96% rename from common/src/main/java/com/discordsrv/common/player/event/PlayerConnectedEvent.java rename to common/src/main/java/com/discordsrv/common/event/events/player/PlayerConnectedEvent.java index 824336f8..c953a7b8 100644 --- a/common/src/main/java/com/discordsrv/common/player/event/PlayerConnectedEvent.java +++ b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerConnectedEvent.java @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package com.discordsrv.common.player.event; +package com.discordsrv.common.event.events.player; import com.discordsrv.api.event.events.Event; import com.discordsrv.common.player.IPlayer; diff --git a/common/src/main/java/com/discordsrv/common/player/event/PlayerDisconnectedEvent.java b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerDisconnectedEvent.java similarity index 95% rename from common/src/main/java/com/discordsrv/common/player/event/PlayerDisconnectedEvent.java rename to common/src/main/java/com/discordsrv/common/event/events/player/PlayerDisconnectedEvent.java index be1f12c0..3f3d7408 100644 --- a/common/src/main/java/com/discordsrv/common/player/event/PlayerDisconnectedEvent.java +++ b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerDisconnectedEvent.java @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package com.discordsrv.common.player.event; +package com.discordsrv.common.event.events.player; import com.discordsrv.api.event.events.Event; import com.discordsrv.common.player.IPlayer; diff --git a/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java b/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java index 7acfb081..6efe775d 100644 --- a/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java +++ b/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java @@ -20,14 +20,15 @@ package com.discordsrv.common.groupsync; import com.discordsrv.api.DiscordSRVApi; import com.discordsrv.api.discord.entity.guild.DiscordRole; -import com.discordsrv.api.discord.events.member.role.DiscordMemberRoleAddEvent; -import com.discordsrv.api.discord.events.member.role.DiscordMemberRoleRemoveEvent; import com.discordsrv.api.event.bus.Subscribe; +import com.discordsrv.api.event.events.discord.member.role.DiscordMemberRoleAddEvent; +import com.discordsrv.api.event.events.discord.member.role.DiscordMemberRoleRemoveEvent; import com.discordsrv.api.module.type.PermissionDataProvider; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.main.GroupSyncConfig; import com.discordsrv.common.debug.DebugGenerateEvent; import com.discordsrv.common.debug.file.TextDebugFile; +import com.discordsrv.common.event.events.player.PlayerConnectedEvent; import com.discordsrv.common.future.util.CompletableFutureUtil; import com.discordsrv.common.groupsync.enums.GroupSyncCause; import com.discordsrv.common.groupsync.enums.GroupSyncDirection; @@ -36,7 +37,6 @@ import com.discordsrv.common.groupsync.enums.GroupSyncSide; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.AbstractModule; import com.discordsrv.common.player.IPlayer; -import com.discordsrv.common.player.event.PlayerConnectedEvent; import com.discordsrv.common.profile.Profile; import com.github.benmanes.caffeine.cache.Cache; import org.apache.commons.lang3.StringUtils; diff --git a/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java b/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java index ebd2091a..58631911 100644 --- a/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java +++ b/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java @@ -20,8 +20,8 @@ package com.discordsrv.common.linking.impl; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.event.events.player.PlayerConnectedEvent; import com.discordsrv.common.linking.LinkProvider; -import com.discordsrv.common.player.event.PlayerConnectedEvent; import com.github.benmanes.caffeine.cache.AsyncCacheLoader; import com.github.benmanes.caffeine.cache.AsyncLoadingCache; import com.github.benmanes.caffeine.cache.Cache; diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java index b935fa22..a55a0c45 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java @@ -27,10 +27,10 @@ import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuild; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; -import com.discordsrv.api.discord.events.message.DiscordMessageDeleteEvent; -import com.discordsrv.api.discord.events.message.DiscordMessageReceiveEvent; -import com.discordsrv.api.discord.events.message.DiscordMessageUpdateEvent; import com.discordsrv.api.event.bus.Subscribe; +import com.discordsrv.api.event.events.discord.message.DiscordMessageDeleteEvent; +import com.discordsrv.api.event.events.discord.message.DiscordMessageReceiveEvent; +import com.discordsrv.api.event.events.discord.message.DiscordMessageUpdateEvent; import com.discordsrv.api.event.events.message.forward.discord.DiscordChatMessageForwardedEvent; import com.discordsrv.api.event.events.message.process.discord.DiscordChatMessageProcessEvent; import com.discordsrv.api.event.events.message.receive.discord.DiscordChatMessageReceiveEvent; diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java index 20714f23..3188b841 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java @@ -29,9 +29,9 @@ import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.message.DiscordMessageEmbed; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; -import com.discordsrv.api.discord.events.message.DiscordMessageDeleteEvent; -import com.discordsrv.api.discord.events.message.DiscordMessageUpdateEvent; import com.discordsrv.api.event.bus.Subscribe; +import com.discordsrv.api.event.events.discord.message.DiscordMessageDeleteEvent; +import com.discordsrv.api.event.events.discord.message.DiscordMessageUpdateEvent; import com.discordsrv.api.event.events.message.forward.game.AbstractGameMessageForwardedEvent; import com.discordsrv.api.event.events.message.receive.discord.DiscordChatMessageReceiveEvent; import com.discordsrv.api.placeholder.PlainPlaceholderFormat; diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java index 8237cd6f..fff0b851 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java @@ -28,9 +28,9 @@ import com.discordsrv.api.event.events.message.receive.game.AwardMessageReceiveE import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; -import com.discordsrv.common.config.main.channels.server.AwardMessageConfig; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.channels.base.server.ServerBaseChannelConfig; +import com.discordsrv.common.config.main.channels.server.AwardMessageConfig; import com.github.benmanes.caffeine.cache.Cache; import net.kyori.adventure.text.Component; diff --git a/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java b/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java index 83793b1d..ab22e524 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java @@ -19,8 +19,8 @@ package com.discordsrv.common.placeholder.result; import com.discordsrv.api.component.MinecraftComponent; -import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.placeholder.FormattedText; +import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.placeholder.mapper.PlaceholderResultMapper; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; diff --git a/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java b/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java index 43538d06..fbe34486 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java @@ -19,12 +19,12 @@ package com.discordsrv.common.player.provider; import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.event.events.player.PlayerConnectedEvent; +import com.discordsrv.common.event.events.player.PlayerDisconnectedEvent; import com.discordsrv.common.http.util.HttpUtil; import com.discordsrv.common.player.IOfflinePlayer; import com.discordsrv.common.player.IPlayer; import com.discordsrv.common.player.OfflinePlayer; -import com.discordsrv.common.player.event.PlayerConnectedEvent; -import com.discordsrv.common.player.event.PlayerDisconnectedEvent; import com.discordsrv.common.player.provider.model.GameProfileResponse; import com.discordsrv.common.player.provider.model.SkinInfo; import com.discordsrv.common.player.provider.model.Textures; diff --git a/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java b/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java index e42e4159..fd41928a 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java @@ -21,7 +21,6 @@ package com.discordsrv.common.player.provider; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.player.IOfflinePlayer; import com.discordsrv.common.player.IPlayer; -import com.discordsrv.common.player.provider.AbstractPlayerProvider; import java.util.UUID; import java.util.concurrent.CompletableFuture; diff --git a/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java b/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java index 3cc5008e..93bed953 100644 --- a/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java +++ b/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java @@ -23,12 +23,12 @@ import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.connection.ConnectionConfig; import com.discordsrv.common.config.connection.UpdateConfig; import com.discordsrv.common.debug.data.VersionInfo; +import com.discordsrv.common.event.events.player.PlayerConnectedEvent; import com.discordsrv.common.exception.MessageException; import com.discordsrv.common.http.util.HttpUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.permission.Permission; import com.discordsrv.common.player.IPlayer; -import com.discordsrv.common.player.event.PlayerConnectedEvent; import com.discordsrv.common.update.github.GitHubCompareResponse; import com.discordsrv.common.update.github.GithubRelease; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java b/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java index 2e579737..a1c24740 100644 --- a/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java +++ b/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java @@ -21,11 +21,11 @@ package com.discordsrv.sponge; import com.discordsrv.api.DiscordSRVApi; import com.discordsrv.common.ServerDiscordSRV; import com.discordsrv.common.command.game.handler.ICommandHandler; +import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; +import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.configurate.manager.MessagesConfigManager; import com.discordsrv.common.config.connection.ConnectionConfig; import com.discordsrv.common.config.main.MainConfig; -import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; -import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.messages.MessagesConfig; import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.plugin.PluginManager; diff --git a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java index 957b2bfa..e646437d 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java +++ b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java @@ -20,11 +20,11 @@ package com.discordsrv.velocity; import com.discordsrv.common.ProxyDiscordSRV; import com.discordsrv.common.command.game.handler.ICommandHandler; +import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; +import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.configurate.manager.MessagesConfigManager; import com.discordsrv.common.config.connection.ConnectionConfig; import com.discordsrv.common.config.main.MainConfig; -import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; -import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.messages.MessagesConfig; import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.plugin.PluginManager;