rename to make more sense x2

This commit is contained in:
tueem 2024-10-26 00:56:27 +02:00
parent 11ebb3fdea
commit f4a6bf937d
No known key found for this signature in database
GPG Key ID: 819A0F7C36B9CF07
10 changed files with 29 additions and 30 deletions

@ -1,14 +1,14 @@
package net.tomatentum.marinara.interaction.commands;
import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand;
import net.tomatentum.marinara.interaction.commands.annotation.CommandOption;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommandOption;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommand;
public record ExecutableSlashCommandDefinition(
ApplicationCommand applicationCommand,
SlashCommand applicationCommand,
SubCommand subCommand,
String[] subCommandGroups,
CommandOption[] options) {
SlashCommandOption[] options) {
@Override
public final boolean equals(Object o) {
@ -30,7 +30,7 @@ public record ExecutableSlashCommandDefinition(
}
public static class Builder {
private ApplicationCommand applicationCommand;
private SlashCommand applicationCommand;
private SubCommand subCommand;
private String[] subCommandGroupNames;
@ -45,7 +45,7 @@ public record ExecutableSlashCommandDefinition(
return new ExecutableSlashCommandDefinition(applicationCommand, subCommand, subCommandGroupNames, subCommand != null ? subCommand.options() : applicationCommand.options());
}
public void setApplicationCommand(ApplicationCommand applicationCommand) {
public void setApplicationCommand(SlashCommand applicationCommand) {
this.applicationCommand = applicationCommand;
}
@ -57,7 +57,7 @@ public record ExecutableSlashCommandDefinition(
this.subCommandGroupNames = subCommandGroupNames;
}
public ApplicationCommand getApplicationCommand() {
public SlashCommand getApplicationCommand() {
return applicationCommand;
}

@ -4,15 +4,15 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
public class SlashCommandDefinition {
private List<ExecutableSlashCommandDefinition> executableDefinitons;
private ApplicationCommand applicationCommand;
private SlashCommand applicationCommand;
private int subCommandGroupCount = -1;
private boolean isRootCommand = false;
public SlashCommandDefinition(ApplicationCommand applicationCommand) {
public SlashCommandDefinition(SlashCommand applicationCommand) {
this.executableDefinitons = new ArrayList<>();
this.applicationCommand = applicationCommand;
}
@ -42,7 +42,7 @@ public class SlashCommandDefinition {
return this;
}
public ApplicationCommand getApplicationCommand() {
public SlashCommand getApplicationCommand() {
return applicationCommand;
}

@ -7,10 +7,9 @@ import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ApplicationCommand {
public @interface SlashCommand {
public String name();
public String description() default "";
public String[] aliases() default {};
public CommandOption[] options() default {};
public SlashCommandOption[] options() default {};
public long[] serverIds() default {};
}

@ -5,13 +5,13 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.tomatentum.marinara.interaction.commands.option.OptionType;
import net.tomatentum.marinara.interaction.commands.option.SlashCommandOptionType;
@Target({ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandOption {
public @interface SlashCommandOption {
public String name();
public String description() default "";
public OptionType type() default OptionType.STRING;
public SlashCommandOptionType type() default SlashCommandOptionType.STRING;
public boolean required() default false;
}

@ -10,5 +10,5 @@ import java.lang.annotation.Target;
public @interface SubCommand {
public String name();
public String description() default "";
public CommandOption[] options() default {};
public SlashCommandOption[] options() default {};
}

@ -1,6 +1,6 @@
package net.tomatentum.marinara.interaction.commands.option;
public enum OptionType {
public enum SlashCommandOptionType {
ATTACHMENT,
BOOLEAN,
CHANNEL,

@ -5,7 +5,7 @@ import java.lang.reflect.Method;
import net.tomatentum.marinara.interaction.InteractionHandler;
import net.tomatentum.marinara.interaction.InteractionType;
import net.tomatentum.marinara.interaction.commands.ExecutableSlashCommandDefinition;
import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommandGroup;
import net.tomatentum.marinara.util.ReflectionUtil;
@ -43,7 +43,7 @@ public class CommandInteractionMethod extends InteractionMethod {
private void parseMethod() {
ReflectionUtil.checkValidCommandMethod(method);
ApplicationCommand cmd = ReflectionUtil.getAnnotation(method, ApplicationCommand.class);
SlashCommand cmd = ReflectionUtil.getAnnotation(method, SlashCommand.class);
ExecutableSlashCommandDefinition.Builder builder = new ExecutableSlashCommandDefinition.Builder();
builder.setApplicationCommand(cmd);

@ -8,14 +8,14 @@ import java.util.List;
import net.tomatentum.marinara.interaction.InteractionHandler;
import net.tomatentum.marinara.interaction.InteractionType;
import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommand;
import net.tomatentum.marinara.wrapper.LibraryWrapper;
public abstract class InteractionMethod {
public static InteractionMethod create(Method method, InteractionHandler handler, LibraryWrapper wrapper) {
if (method.isAnnotationPresent(ApplicationCommand.class) || method.isAnnotationPresent(SubCommand.class))
if (method.isAnnotationPresent(SlashCommand.class) || method.isAnnotationPresent(SubCommand.class))
return new CommandInteractionMethod(method, handler, wrapper);
return null;

@ -3,7 +3,7 @@ package net.tomatentum.marinara.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommand;
public final class ReflectionUtil {
@ -22,16 +22,16 @@ public final class ReflectionUtil {
}
public static void checkValidCommandMethod(Method method) {
if (method.isAnnotationPresent(ApplicationCommand.class) &&
method.getDeclaringClass().isAnnotationPresent(ApplicationCommand.class)) {
if (method.isAnnotationPresent(SlashCommand.class) &&
method.getDeclaringClass().isAnnotationPresent(SlashCommand.class)) {
throw new RuntimeException(method.getName() + ": Can't have ApplicationCommand Annotation on Class and Method");
}
if (!isAnnotationPresent(method, ApplicationCommand.class))
if (!isAnnotationPresent(method, SlashCommand.class))
throw new RuntimeException(method.getName() + ": Missing ApplicationCommand Annotation on either Class or Method");
if (!(method.isAnnotationPresent(SubCommand.class) &&
isAnnotationPresent(method, ApplicationCommand.class))) {
isAnnotationPresent(method, SlashCommand.class))) {
throw new RuntimeException(method.getName() + ": Missing ApplicationCommand Annotation on either Method or Class");
}
}

@ -6,7 +6,7 @@ import java.util.function.Consumer;
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.commands.option.SlashCommandOptionType;
import net.tomatentum.marinara.interaction.InteractionType;
public abstract class LibraryWrapper {
@ -31,6 +31,6 @@ public abstract class LibraryWrapper {
}
public abstract InteractionType getInteractionType(Class<?> clazz);
public abstract Object convertCommandOption(Object context, OptionType type, String optionName);
public abstract Object convertCommandOption(Object context, SlashCommandOptionType type, String optionName);
public abstract ExecutableSlashCommandDefinition getCommandDefinition(Object context);
}