tueem 991d1c047b
All checks were successful
github-mirror / push-github (push) Successful in 1m45s
Build / Gradle-Build (push) Successful in 37s
Test / Gradle-Test (push) Successful in 46s
feat(core): add InteractionProcessors and InteractionExecutors and improve Autocomplete Interaction
2025-04-06 00:04:17 +02:00

64 lines
2.3 KiB
Java

package net.tomatentum.marinara;
import org.slf4j.Logger;
import net.tomatentum.marinara.interaction.InteractionType;
import net.tomatentum.marinara.interaction.processor.AutocompleteInteractionProcessor;
import net.tomatentum.marinara.interaction.processor.DirectInteractionProcessor;
import net.tomatentum.marinara.reflection.ReflectedMethodFactory;
import net.tomatentum.marinara.reflection.ReflectedMethodFactoryImpl;
import net.tomatentum.marinara.registry.InteractionCheckRegistry;
import net.tomatentum.marinara.registry.InteractionExecutor;
import net.tomatentum.marinara.registry.InteractionRegistry;
import net.tomatentum.marinara.registry.ProcessorInteractionExecutor;
import net.tomatentum.marinara.util.LoggerUtil;
import net.tomatentum.marinara.wrapper.LibraryWrapper;
public class Marinara {
private Logger logger = LoggerUtil.getLogger(getClass());
public static Marinara load(LibraryWrapper wrapper) {
return new Marinara(wrapper);
}
private LibraryWrapper wrapper;
private ReflectedMethodFactory reflectedMethodFactory;
private InteractionRegistry registry;
private InteractionCheckRegistry checkRegistry;
private InteractionExecutor interactionExecutor;
private Marinara(LibraryWrapper wrapper) {
this.wrapper = wrapper;
this.reflectedMethodFactory = new ReflectedMethodFactoryImpl(this);
this.registry = new InteractionRegistry(this);
this.checkRegistry = new InteractionCheckRegistry();
this.interactionExecutor = new ProcessorInteractionExecutor(wrapper.createIdentifierProvider(), this)
.addProcessor(new DirectInteractionProcessor(InteractionType.COMMAND, InteractionType.BUTTON))
.addProcessor(new AutocompleteInteractionProcessor());
wrapper.subscribeInteractions(this.interactionExecutor::handle);
logger.info("Marinara loaded successfully!");
}
public LibraryWrapper getWrapper() {
return this.wrapper;
}
public InteractionRegistry getRegistry() {
return this.registry;
}
public InteractionCheckRegistry getCheckRegistry() {
return this.checkRegistry;
}
public ReflectedMethodFactory getReflectedMethodFactory() {
return this.reflectedMethodFactory;
}
public InteractionExecutor getInteractionExecutor() {
return interactionExecutor;
}
}