From 11ebb3fdea4dd39167134edf13e48c4707f5a7f4 Mon Sep 17 00:00:00 2001 From: tueem Date: Sat, 26 Oct 2024 00:43:05 +0200 Subject: [PATCH] rename to make more sense --- ...a => ExecutableSlashCommandDefinition.java} | 10 +++++----- ...nition.java => SlashCommandDefinition.java} | 18 +++++++++--------- .../methods/CommandInteractionMethod.java | 10 +++++----- .../marinara/registry/InteractionRegistry.java | 14 +++++++------- .../marinara/wrapper/LibraryWrapper.java | 8 ++++---- 5 files changed, 30 insertions(+), 30 deletions(-) rename lib/src/main/java/net/tomatentum/marinara/interaction/commands/{ExecutableCommandDefinition.java => ExecutableSlashCommandDefinition.java} (82%) rename lib/src/main/java/net/tomatentum/marinara/interaction/commands/{ApplicationCommandDefinition.java => SlashCommandDefinition.java} (76%) diff --git a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableCommandDefinition.java b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableSlashCommandDefinition.java similarity index 82% rename from lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableCommandDefinition.java rename to lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableSlashCommandDefinition.java index ac240c6..3a85463 100644 --- a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableCommandDefinition.java +++ b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableSlashCommandDefinition.java @@ -4,7 +4,7 @@ import net.tomatentum.marinara.interaction.commands.annotation.ApplicationComman import net.tomatentum.marinara.interaction.commands.annotation.CommandOption; import net.tomatentum.marinara.interaction.commands.annotation.SubCommand; -public record ExecutableCommandDefinition( +public record ExecutableSlashCommandDefinition( ApplicationCommand applicationCommand, SubCommand subCommand, String[] subCommandGroups, @@ -12,9 +12,9 @@ public record ExecutableCommandDefinition( @Override public final boolean equals(Object o) { - if (!(o instanceof ExecutableCommandDefinition)) + if (!(o instanceof ExecutableSlashCommandDefinition)) return false; - ExecutableCommandDefinition other = (ExecutableCommandDefinition) o; + ExecutableSlashCommandDefinition other = (ExecutableSlashCommandDefinition) o; return other.applicationCommand.name().equals(this.applicationCommand.name()) && other.subCommandGroups.equals(this.subCommandGroups) && other.subCommand.equals(this.subCommand); @@ -38,11 +38,11 @@ public record ExecutableCommandDefinition( this.subCommandGroupNames = new String[0]; } - public ExecutableCommandDefinition build() { + public ExecutableSlashCommandDefinition build() { if (applicationCommand == null) throw new IllegalArgumentException("applicationCommandName cant be null"); - return new ExecutableCommandDefinition(applicationCommand, subCommand, subCommandGroupNames, subCommand != null ? subCommand.options() : applicationCommand.options()); + return new ExecutableSlashCommandDefinition(applicationCommand, subCommand, subCommandGroupNames, subCommand != null ? subCommand.options() : applicationCommand.options()); } public void setApplicationCommand(ApplicationCommand applicationCommand) { diff --git a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ApplicationCommandDefinition.java b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/SlashCommandDefinition.java similarity index 76% rename from lib/src/main/java/net/tomatentum/marinara/interaction/commands/ApplicationCommandDefinition.java rename to lib/src/main/java/net/tomatentum/marinara/interaction/commands/SlashCommandDefinition.java index ea1627f..9f8b189 100644 --- a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ApplicationCommandDefinition.java +++ b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/SlashCommandDefinition.java @@ -6,18 +6,18 @@ import java.util.List; import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand; -public class ApplicationCommandDefinition { - private List executableDefinitons; +public class SlashCommandDefinition { + private List executableDefinitons; private ApplicationCommand applicationCommand; private int subCommandGroupCount = -1; private boolean isRootCommand = false; - public ApplicationCommandDefinition(ApplicationCommand applicationCommand) { + public SlashCommandDefinition(ApplicationCommand applicationCommand) { this.executableDefinitons = new ArrayList<>(); this.applicationCommand = applicationCommand; } - public ApplicationCommandDefinition addExecutableCommand(ExecutableCommandDefinition def) { + public SlashCommandDefinition addExecutableCommand(ExecutableSlashCommandDefinition def) { if (this.subCommandGroupCount == -1) this.subCommandGroupCount = def.subCommandGroups().length; if (def.subCommandGroups().length != subCommandGroupCount) @@ -46,14 +46,14 @@ public class ApplicationCommandDefinition { return applicationCommand; } - public ExecutableCommandDefinition[] getExecutableDefinitons() { - return executableDefinitons.toArray(new ExecutableCommandDefinition[0]); + public ExecutableSlashCommandDefinition[] getExecutableDefinitons() { + return executableDefinitons.toArray(new ExecutableSlashCommandDefinition[0]); } - public ExecutableCommandDefinition[] getUniqueExecutableDefinitions() { - HashSet set = new HashSet<>(); + public ExecutableSlashCommandDefinition[] getUniqueExecutableDefinitions() { + HashSet set = new HashSet<>(); executableDefinitons.forEach(set::add); - return set.toArray(new ExecutableCommandDefinition[0]); + return set.toArray(new ExecutableSlashCommandDefinition[0]); } public int getSubCommandGroupCount() { return subCommandGroupCount; diff --git a/lib/src/main/java/net/tomatentum/marinara/interaction/methods/CommandInteractionMethod.java b/lib/src/main/java/net/tomatentum/marinara/interaction/methods/CommandInteractionMethod.java index 283efc0..d0a13a5 100644 --- a/lib/src/main/java/net/tomatentum/marinara/interaction/methods/CommandInteractionMethod.java +++ b/lib/src/main/java/net/tomatentum/marinara/interaction/methods/CommandInteractionMethod.java @@ -4,7 +4,7 @@ import java.lang.reflect.Method; import net.tomatentum.marinara.interaction.InteractionHandler; import net.tomatentum.marinara.interaction.InteractionType; -import net.tomatentum.marinara.interaction.commands.ExecutableCommandDefinition; +import net.tomatentum.marinara.interaction.commands.ExecutableSlashCommandDefinition; import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand; import net.tomatentum.marinara.interaction.commands.annotation.SubCommand; import net.tomatentum.marinara.interaction.commands.annotation.SubCommandGroup; @@ -13,7 +13,7 @@ import net.tomatentum.marinara.wrapper.LibraryWrapper; public class CommandInteractionMethod extends InteractionMethod { - private ExecutableCommandDefinition commandDefinition; + private ExecutableSlashCommandDefinition commandDefinition; CommandInteractionMethod(Method method, InteractionHandler handler, LibraryWrapper wrapper) { super(method, handler, wrapper); @@ -27,7 +27,7 @@ public class CommandInteractionMethod extends InteractionMethod { @Override public boolean canRun(Object context) { - ExecutableCommandDefinition other = wrapper.getCommandDefinition(context); + ExecutableSlashCommandDefinition other = wrapper.getCommandDefinition(context); return commandDefinition.equals(other); } @@ -36,7 +36,7 @@ public class CommandInteractionMethod extends InteractionMethod { return InteractionType.COMMAND; } - public ExecutableCommandDefinition getCommandDefinition() { + public ExecutableSlashCommandDefinition getCommandDefinition() { return commandDefinition; } @@ -44,7 +44,7 @@ public class CommandInteractionMethod extends InteractionMethod { ReflectionUtil.checkValidCommandMethod(method); ApplicationCommand cmd = ReflectionUtil.getAnnotation(method, ApplicationCommand.class); - ExecutableCommandDefinition.Builder builder = new ExecutableCommandDefinition.Builder(); + ExecutableSlashCommandDefinition.Builder builder = new ExecutableSlashCommandDefinition.Builder(); builder.setApplicationCommand(cmd); if (ReflectionUtil.isAnnotationPresent(method, SubCommandGroup.class)) { diff --git a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java index 2d47510..3d9037f 100644 --- a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java +++ b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java @@ -7,8 +7,8 @@ import java.util.Optional; import net.tomatentum.marinara.interaction.InteractionHandler; import net.tomatentum.marinara.interaction.InteractionType; -import net.tomatentum.marinara.interaction.commands.ApplicationCommandDefinition; -import net.tomatentum.marinara.interaction.commands.ExecutableCommandDefinition; +import net.tomatentum.marinara.interaction.commands.SlashCommandDefinition; +import net.tomatentum.marinara.interaction.commands.ExecutableSlashCommandDefinition; import net.tomatentum.marinara.interaction.methods.CommandInteractionMethod; import net.tomatentum.marinara.interaction.methods.InteractionMethod; import net.tomatentum.marinara.wrapper.LibraryWrapper; @@ -29,23 +29,23 @@ public class InteractionRegistry { } public void registerCommands() { - List defs = new ArrayList<>(); - List execDefs = interactionMethods.stream() + List defs = new ArrayList<>(); + List execDefs = interactionMethods.stream() .filter((x) -> x.getClass().isAssignableFrom(CommandInteractionMethod.class)) .map((x) -> ((CommandInteractionMethod)x).getCommandDefinition()) .toList(); execDefs.forEach((def) -> { - Optional appDef = defs.stream() + Optional appDef = defs.stream() .filter((x) -> x.getApplicationCommand().equals(def.applicationCommand())) .findFirst(); if (appDef.isPresent()) appDef.get().addExecutableCommand(def); else - defs.add(new ApplicationCommandDefinition(def.applicationCommand()).addExecutableCommand(def)); + defs.add(new SlashCommandDefinition(def.applicationCommand()).addExecutableCommand(def)); }); - wrapper.registerApplicationCommands(defs.toArray(new ApplicationCommandDefinition[0])); + wrapper.registerSlashCommands(defs.toArray(new SlashCommandDefinition[0])); } public void handle(Object context) { diff --git a/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java index cd3c5d3..3e10702 100644 --- a/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java +++ b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -import net.tomatentum.marinara.interaction.commands.ApplicationCommandDefinition; -import net.tomatentum.marinara.interaction.commands.ExecutableCommandDefinition; +import net.tomatentum.marinara.interaction.commands.SlashCommandDefinition; +import net.tomatentum.marinara.interaction.commands.ExecutableSlashCommandDefinition; import net.tomatentum.marinara.interaction.commands.option.OptionType; import net.tomatentum.marinara.interaction.InteractionType; @@ -17,7 +17,7 @@ public abstract class LibraryWrapper { interactionSubscriber = new ArrayList<>(); } - public abstract void registerApplicationCommands(ApplicationCommandDefinition[] defs); + public abstract void registerSlashCommands(SlashCommandDefinition[] defs); public void handleInteraction(Object context) { interactionSubscriber.forEach((o) -> o.accept(context)); @@ -32,5 +32,5 @@ public abstract class LibraryWrapper { public abstract InteractionType getInteractionType(Class clazz); public abstract Object convertCommandOption(Object context, OptionType type, String optionName); - public abstract ExecutableCommandDefinition getCommandDefinition(Object context); + public abstract ExecutableSlashCommandDefinition getCommandDefinition(Object context); } \ No newline at end of file