Skip to content

Commit

Permalink
Merge branch 'main' into fix/153-sql-drivers-are-not-relocated
Browse files Browse the repository at this point in the history
  • Loading branch information
bivashy committed Apr 3, 2024
2 parents d4f7b05 + 1dc63ef commit 176c660
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/me/mastercapexd/auth/BaseAuthPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ private void initializeDiscord() {

eventBus.register(new DiscordLinkRoleModifierListener());
new DiscordCommandRegistry();
}).exceptionally(throwable -> {
throwable.printStackTrace();
// TODO: Replace with proper logging
return null;
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(), "");
Expand All @@ -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);
Expand Down Expand Up @@ -67,4 +60,5 @@ protected LinkCommandActorWrapper wrapActor(CommandActor actor) {
protected MessengerLinkCommandTemplate createLinkCommand() {
return new DiscordLinkCommand(DiscordLinkType.getInstance().getLinkMessages());
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<JDAActor, LinkCommandActorWrapper> wrapper;
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -105,15 +106,16 @@ 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);
}
}

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);
});
}
Expand Down Expand Up @@ -190,5 +192,6 @@ private void appendOptionMapping(Collection<String> arguments, OptionMapping opt
arguments.add(optionMapping.getAsString());
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
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;
import revxrsal.commands.annotation.Default;
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)
Expand All @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/configurations/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

<!-- TOTP -->
<totp-auth.version>1.5.0</totp-auth.version>
<zxing-qr-generator.version>3.5.2</zxing-qr-generator.version>
<zxing-qr-generator.version>3.5.3</zxing-qr-generator.version>

<!-- Adventure -->
<minimessage.version>4.15.0</minimessage.version>
<minimessage.version>4.16.0</minimessage.version>
<adventure-serializer.version>4.15.0</adventure-serializer.version>
<adventure-platform.version>4.3.2</adventure-platform.version>
<adventure-bungee.version>4.3.2</adventure-bungee.version>
Expand All @@ -51,7 +51,7 @@
<lamp-telegram.version>1.0.0</lamp-telegram.version>

<telegram-api.version>6.9.1</telegram-api.version>
<jda.version>5.0.0-beta.19</jda.version>
<jda.version>5.0.0-beta.20</jda.version>
<vk-api.version>0.4.2</vk-api.version>

<bungeecord.version>1.20-R0.1</bungeecord.version>
Expand Down

0 comments on commit 176c660

Please sign in to comment.