Compare commits

..

3 Commits

7 changed files with 21 additions and 16 deletions

@ -20,12 +20,6 @@ dependencies {
testImplementation(libs.junit.jupiter) testImplementation(libs.junit.jupiter)
testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// This dependency is exported to consumers, that is to say found on their compile classpath.
api(libs.commons.math3)
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation(libs.guava)
implementation(libs.log4j) implementation(libs.log4j)
} }

@ -1,13 +1,24 @@
package net.tomatentum.marinara; package net.tomatentum.marinara;
import java.lang.reflect.Constructor;
import net.tomatentum.marinara.registry.InteractionRegistry; import net.tomatentum.marinara.registry.InteractionRegistry;
import net.tomatentum.marinara.wrapper.LibraryWrapper; import net.tomatentum.marinara.wrapper.LibraryWrapper;
public class Marinara { public class Marinara {
public static Marinara load(LibraryWrapper wrapper) { public static <T extends LibraryWrapper> Marinara load(Class<T> clazz) {
InteractionRegistry registry = new InteractionRegistry(wrapper); try {
return new Marinara(registry); Constructor<T> ctor = clazz.getConstructor();
ctor.setAccessible(true);
T wrapper = ctor.newInstance();
InteractionRegistry registry = new InteractionRegistry(wrapper);
return new Marinara(registry);
}catch (Exception ex) {
System.err.println(ex);
System.exit(100);
return null;
}
} }
private InteractionRegistry registry; private InteractionRegistry registry;

@ -1,4 +0,0 @@
package net.tomatentum.marinara.handler;
public interface InteractionHandler {
}

@ -0,0 +1,4 @@
package net.tomatentum.marinara.interaction;
public interface InteractionHandler {
}

@ -2,13 +2,13 @@ package net.tomatentum.marinara.interaction.methods;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import net.tomatentum.marinara.interaction.InteractionHandler;
import net.tomatentum.marinara.interaction.InteractionType; import net.tomatentum.marinara.interaction.InteractionType;
import net.tomatentum.marinara.interaction.commands.ExecutableCommandDefinition; import net.tomatentum.marinara.interaction.commands.ExecutableCommandDefinition;
import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand; import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommand; import net.tomatentum.marinara.interaction.commands.annotation.SubCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommandGroup; import net.tomatentum.marinara.interaction.commands.annotation.SubCommandGroup;
import net.tomatentum.marinara.util.ReflectionUtil; import net.tomatentum.marinara.util.ReflectionUtil;
import net.tomatentum.marinara.handler.InteractionHandler;
import net.tomatentum.marinara.wrapper.LibraryWrapper; import net.tomatentum.marinara.wrapper.LibraryWrapper;
public class CommandInteractionMethod extends InteractionMethod { public class CommandInteractionMethod extends InteractionMethod {

@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import net.tomatentum.marinara.handler.InteractionHandler; import net.tomatentum.marinara.interaction.InteractionHandler;
import net.tomatentum.marinara.interaction.InteractionType; import net.tomatentum.marinara.interaction.InteractionType;
import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand; import net.tomatentum.marinara.interaction.commands.annotation.ApplicationCommand;
import net.tomatentum.marinara.interaction.commands.annotation.SubCommand; import net.tomatentum.marinara.interaction.commands.annotation.SubCommand;

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import net.tomatentum.marinara.handler.InteractionHandler; import net.tomatentum.marinara.interaction.InteractionHandler;
import net.tomatentum.marinara.interaction.InteractionType; import net.tomatentum.marinara.interaction.InteractionType;
import net.tomatentum.marinara.interaction.commands.ApplicationCommandDefinition; import net.tomatentum.marinara.interaction.commands.ApplicationCommandDefinition;
import net.tomatentum.marinara.interaction.commands.ExecutableCommandDefinition; import net.tomatentum.marinara.interaction.commands.ExecutableCommandDefinition;