diff --git a/api/src/main/java/com/bivashy/auth/api/database/DatabaseConnectionProvider.java b/api/src/main/java/com/bivashy/auth/api/database/DatabaseConnectionProvider.java index 34bf11c7..25126bfd 100644 --- a/api/src/main/java/com/bivashy/auth/api/database/DatabaseConnectionProvider.java +++ b/api/src/main/java/com/bivashy/auth/api/database/DatabaseConnectionProvider.java @@ -11,7 +11,7 @@ public enum DatabaseConnectionProvider { public String getConnectionUrl(LegacyStorageDataSettings settings) { return "jdbc:mysql://" + settings.getHost() + ":" + settings.getPort() + "/" + settings.getDatabase(); } - }, SQLITE("https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.36.0.3/sqlite-jdbc-3.36.0.3.jar") { + }, SQLITE("https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.45.1.0/sqlite-jdbc-3.45.1.0.jar") { @Override public String getConnectionUrl(LegacyStorageDataSettings settings) { return "jdbc:sqlite:" + AuthPlugin.instance().getFolder().getAbsolutePath() + File.separator + "auth.db"; diff --git a/core/src/main/java/me/mastercapexd/auth/BaseAuthPlugin.java b/core/src/main/java/me/mastercapexd/auth/BaseAuthPlugin.java index 6c336b93..5e5d7d68 100644 --- a/core/src/main/java/me/mastercapexd/auth/BaseAuthPlugin.java +++ b/core/src/main/java/me/mastercapexd/auth/BaseAuthPlugin.java @@ -216,6 +216,10 @@ private void initializeDiscord() { eventBus.register(new DiscordLinkRoleModifierListener()); new DiscordCommandRegistry(); + }).exceptionally(throwable -> { + throwable.printStackTrace(); + // TODO: Replace with proper logging + return null; }); } diff --git a/core/src/main/java/me/mastercapexd/auth/discord/command/DiscordCommandRegistry.java b/core/src/main/java/me/mastercapexd/auth/discord/command/DiscordCommandRegistry.java index fc6288f7..2d9fd6b9 100644 --- a/core/src/main/java/me/mastercapexd/auth/discord/command/DiscordCommandRegistry.java +++ b/core/src/main/java/me/mastercapexd/auth/discord/command/DiscordCommandRegistry.java @@ -1,10 +1,7 @@ package me.mastercapexd.auth.discord.command; -import java.util.Collections; - import com.bivashy.auth.api.AuthPlugin; -import me.mastercapexd.auth.discord.command.annotation.RenameTo; import me.mastercapexd.auth.discord.listener.JDACommandListener; import me.mastercapexd.auth.hooks.DiscordHook; import me.mastercapexd.auth.link.LinkCommandActorWrapper; @@ -13,15 +10,13 @@ import me.mastercapexd.auth.messenger.commands.MessengerCommandRegistry; import me.mastercapexd.auth.shared.commands.DiscordLinkCommand; import me.mastercapexd.auth.shared.commands.MessengerLinkCommandTemplate; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import revxrsal.commands.annotation.dynamic.Annotations; import revxrsal.commands.command.CommandActor; import revxrsal.commands.exception.CommandErrorException; import revxrsal.commands.jda.JDAActor; import revxrsal.commands.jda.JDACommandHandler; -import revxrsal.commands.jda.annotation.OptionData; public class DiscordCommandRegistry extends MessengerCommandRegistry { + private static final AuthPlugin PLUGIN = AuthPlugin.instance(); private static final DiscordHook DISCORD_HOOK = PLUGIN.getHook(DiscordHook.class); private static final JDACommandHandler COMMAND_HANDLER = JDACommandHandler.create(DISCORD_HOOK.getJDA(), ""); @@ -30,8 +25,6 @@ public DiscordCommandRegistry() { super(COMMAND_HANDLER, DiscordLinkType.getInstance()); COMMAND_HANDLER.disableStackTraceSanitizing(); COMMAND_HANDLER.registerContextResolver(LinkCommandActorWrapper.class, context -> new DiscordCommandActorWrapper(context.actor())); - COMMAND_HANDLER.registerAnnotationReplacer(RenameTo.class, (element, parameter) -> Collections.singletonList( - Annotations.create(OptionData.class, "value", OptionType.valueOf(parameter.type()), "name", parameter.value()))); COMMAND_HANDLER.registerCondition((actor, command, arguments) -> { DiscordCommandActorWrapper actorWrapper = actor.as(DiscordCommandActorWrapper.class); @@ -67,4 +60,5 @@ protected LinkCommandActorWrapper wrapActor(CommandActor actor) { protected MessengerLinkCommandTemplate createLinkCommand() { return new DiscordLinkCommand(DiscordLinkType.getInstance().getLinkMessages()); } + } diff --git a/core/src/main/java/me/mastercapexd/auth/discord/command/annotation/RenameTo.java b/core/src/main/java/me/mastercapexd/auth/discord/command/annotation/RenameTo.java deleted file mode 100644 index 5314a3c5..00000000 --- a/core/src/main/java/me/mastercapexd/auth/discord/command/annotation/RenameTo.java +++ /dev/null @@ -1,18 +0,0 @@ -package me.mastercapexd.auth.discord.command.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Required and used in discord module. Used when we need to change {@link revxrsal.commands.annotation.Flag} or {@link revxrsal.commands.annotation.Named} - * name to another. - */ -@Target(ElementType.PARAMETER) -@Retention(RetentionPolicy.RUNTIME) -public @interface RenameTo { - String value(); - - String type(); -} diff --git a/core/src/main/java/me/mastercapexd/auth/discord/listener/JDACommandListener.java b/core/src/main/java/me/mastercapexd/auth/discord/listener/JDACommandListener.java index 86dbb402..3c4a5ab2 100644 --- a/core/src/main/java/me/mastercapexd/auth/discord/listener/JDACommandListener.java +++ b/core/src/main/java/me/mastercapexd/auth/discord/listener/JDACommandListener.java @@ -37,6 +37,7 @@ import revxrsal.commands.jda.core.actor.BaseJDASlashCommandActor; public class JDACommandListener implements EventListener { + private static final DiscordLinkType DISCORD_LINK_TYPE = DiscordLinkType.getInstance(); private final JDACommandHandler handler; private final Function wrapper; @@ -50,7 +51,7 @@ private void dispatch(JDAActor actor, ArgumentStack arguments) { LinkCommandActorWrapper actorWrapper = wrapper.apply(actor); try { handler.dispatch(actorWrapper, arguments); - } catch(Throwable t) { + } catch (Throwable t) { handler.getExceptionHandler().handleException(t, actorWrapper); } } @@ -90,7 +91,7 @@ private void onAutocompleteEvent(CommandAutoCompleteInteractionEvent event) { return new Choice(suggestion, Long.parseLong(suggestion)); return new Choice(suggestion, suggestion); }).collect(Collectors.toList())).queue(); - } catch(Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } @@ -105,7 +106,7 @@ private void onButtonEvent(ButtonInteractionEvent event) { try { ArgumentStack arguments = ArgumentStack.parse(content); dispatch(actor, arguments); - } catch(Throwable t) { + } catch (Throwable t) { handler.getExceptionHandler().handleException(t, actor); } } @@ -113,7 +114,8 @@ private void onButtonEvent(ButtonInteractionEvent event) { private void onSlashCommandEvent(SlashCommandInteractionEvent event) { parseSlashCommandEvent(event).ifPresent(arguments -> { JDAActor actor = new BaseJDASlashCommandActor(event, handler); - event.deferReply(true).queue(); + if (!event.getInteraction().isAcknowledged() && !event.getHook().isExpired()) + event.deferReply(true).queue(); dispatch(actor, arguments); }); } @@ -190,5 +192,6 @@ private void appendOptionMapping(Collection arguments, OptionMapping opt arguments.add(optionMapping.getAsString()); } } + } diff --git a/core/src/main/java/me/mastercapexd/auth/management/BaseLibraryManagement.java b/core/src/main/java/me/mastercapexd/auth/management/BaseLibraryManagement.java index e25e7c64..2e1cb01d 100644 --- a/core/src/main/java/me/mastercapexd/auth/management/BaseLibraryManagement.java +++ b/core/src/main/java/me/mastercapexd/auth/management/BaseLibraryManagement.java @@ -10,7 +10,7 @@ public class BaseLibraryManagement implements LibraryManagement { - private static final String JDA_VERSION = "5.0.0-beta.18"; + private static final String JDA_VERSION = "5.0.0-beta.20"; public static final Library JDA_LIBRARY = Library.builder() .groupId("net{}dv8tion") .artifactId("JDA") diff --git a/core/src/main/java/me/mastercapexd/auth/messenger/commands/AccountsListCommand.java b/core/src/main/java/me/mastercapexd/auth/messenger/commands/AccountsListCommand.java index 2e65572b..4faede2e 100644 --- a/core/src/main/java/me/mastercapexd/auth/messenger/commands/AccountsListCommand.java +++ b/core/src/main/java/me/mastercapexd/auth/messenger/commands/AccountsListCommand.java @@ -13,7 +13,6 @@ import com.bivashy.messenger.common.button.ButtonColor; import com.bivashy.messenger.common.keyboard.Keyboard; -import me.mastercapexd.auth.discord.command.annotation.RenameTo; import me.mastercapexd.auth.link.LinkCommandActorWrapper; import me.mastercapexd.auth.messenger.commands.annotation.CommandKey; import me.mastercapexd.auth.shared.commands.annotation.CommandCooldown; @@ -21,6 +20,7 @@ import revxrsal.commands.annotation.DefaultFor; import revxrsal.commands.annotation.Dependency; import revxrsal.commands.annotation.Flag; +import revxrsal.commands.annotation.Named; import revxrsal.commands.orphan.OrphanCommand; @CommandKey(AccountsListCommand.CONFIGURATION_KEY) @@ -35,7 +35,7 @@ public class AccountsListCommand implements OrphanCommand { @DefaultFor("~") @CommandCooldown(CommandCooldown.DEFAULT_VALUE) public void onAccountsMenu(LinkCommandActorWrapper actorWrapper, LinkType linkType, @Flag("page") @Default("1") Integer page, - @RenameTo(value = "size", type = "NUMBER") @Flag("pageSize") @Default("5") Integer accountsPerPage, + @Flag("pageSize") @Named("size") @Default("5") Integer accountsPerPage, @Flag("type") @Default("my") AccountListType type) { if (!linkType.getSettings().isAdministrator(actorWrapper.userId()) && type.isAdministratorOnly) { actorWrapper.reply(linkType.getLinkMessages().getMessage("not-enough-permission")); diff --git a/core/src/main/resources/configurations/config.yml b/core/src/main/resources/configurations/config.yml index 97bcf334..d07b1d1c 100644 --- a/core/src/main/resources/configurations/config.yml +++ b/core/src/main/resources/configurations/config.yml @@ -31,7 +31,7 @@ data: # # # Ссылка для скачивания драйвера. # # MySQL 8.0.31: https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.0.31/mysql-connector-j-8.0.31.jar -# # SQLite 3.36.0.3: https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.36.0.3/sqlite-jdbc-3.36.0.3.jar +# # SQLite 3.45.1.0: https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.45.1.0/sqlite-jdbc-3.45.1.0.jar # # PostgreSQL 42.4.0: https://repo1.maven.org/maven2/org/postgresql/postgresql/42.5.1/postgresql-42.5.1.jar # # MariaDB 3.0.6: https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/3.0.8/mariadb-java-client-3.0.8.jar # download-url: 'https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.36.0.3/sqlite-jdbc-3.36.0.3.jar' diff --git a/pom.xml b/pom.xml index 821d7d12..91c998e9 100644 --- a/pom.xml +++ b/pom.xml @@ -32,10 +32,10 @@ 1.5.0 - 3.5.2 + 3.5.3 - 4.15.0 + 4.16.0 4.15.0 4.3.2 4.3.2 @@ -51,7 +51,7 @@ 1.0.0 6.9.1 - 5.0.0-beta.19 + 5.0.0-beta.20 0.4.2 1.20-R0.1