Use custom Pair Record instead of library Pair

java-rewrite
Hammy 3 years ago
parent 5932ba6b1f
commit 6cd4dd6c4d

@ -4,9 +4,9 @@ import io.micronaut.inject.ExecutableMethod;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import java.util.Map;
import me.goudham.domain.Pair;
import net.dv8tion.jda.api.events.Event;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.internal.utils.tuple.Pair;
@Singleton
public class SlashCommandHandler implements CommandHandler {
@ -23,8 +23,8 @@ public class SlashCommandHandler implements CommandHandler {
String commandPath = slashCommandEvent.getCommandPath();
Pair<Object, ExecutableMethod<Object, Object>> slashCommandPair = commandMap.get(commandPath);
Object slashCommandBean = slashCommandPair.getLeft();
ExecutableMethod<Object, Object> slashCommandMethod = slashCommandPair.getRight();
Object slashCommandBean = slashCommandPair.left();
ExecutableMethod<Object, Object> slashCommandMethod = slashCommandPair.right();
slashCommandMethod.invoke(slashCommandBean, slashCommandEvent);
}

@ -22,14 +22,13 @@ import me.goudham.command.annotation.Option;
import me.goudham.command.annotation.SlashCommand;
import me.goudham.command.annotation.SubCommand;
import me.goudham.command.annotation.SubCommandGroup;
import me.goudham.domain.Pair;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData;
import net.dv8tion.jda.internal.utils.tuple.ImmutablePair;
import net.dv8tion.jda.internal.utils.tuple.Pair;
@Singleton
public class SlashCommandLoader implements CommandLoader {
@ -275,6 +274,6 @@ public class SlashCommandLoader implements CommandLoader {
nsme.printStackTrace();
}
commandMap.put(commandPath, new ImmutablePair<>(beanInstance, executableMethod));
commandMap.put(commandPath, new Pair<>(beanInstance, executableMethod));
}
}

@ -12,6 +12,7 @@ import java.util.List;
import java.util.Map;
import javax.security.auth.login.LoginException;
import me.goudham.command.CommandHandler;
import me.goudham.domain.Pair;
import me.goudham.listener.OnReadyListener;
import me.goudham.listener.SlashCommandListener;
import net.dv8tion.jda.api.JDA;
@ -20,7 +21,6 @@ import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;
import net.dv8tion.jda.internal.utils.tuple.Pair;
@Factory
@Introspected

Loading…
Cancel
Save