From 55bfeee2d0193cf9ee44ff8d3641c8394a9cf53d Mon Sep 17 00:00:00 2001 From: tueem Date: Sun, 13 Oct 2024 14:27:04 +0200 Subject: [PATCH] added platform abstraction layer --- .../marinara/wrapper/LibraryConverter.java | 9 +++++ .../marinara/wrapper/LibraryWrapper.java | 36 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryConverter.java create mode 100644 lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java diff --git a/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryConverter.java b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryConverter.java new file mode 100644 index 0000000..405eec2 --- /dev/null +++ b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryConverter.java @@ -0,0 +1,9 @@ +package net.tomatentum.marinara.wrapper; + +public interface LibraryConverter { + public Object toAttachment(Object context, String option); + public Object toChannel(Object context, String option); + public Object toMentionable(Object context, String option); + public Object toRole(Object context, String option); + public Object toUser(Object context, String option); +} diff --git a/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java new file mode 100644 index 0000000..3a9825e --- /dev/null +++ b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java @@ -0,0 +1,36 @@ +package net.tomatentum.marinara.wrapper; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +import net.tomatentum.marinara.command.option.OptionType; +import net.tomatentum.marinara.interaction.InteractionType; + +public abstract class LibraryWrapper { + + private List> interactionSubscriber; + + protected LibraryWrapper() { + interactionSubscriber = new ArrayList<>(); + } + + public abstract void registerGlobalCommand(); + public abstract void registerServerCommand(); + + public void handleInteraction(Object context) { + interactionSubscriber.forEach((o) -> o.accept(context)); + } + + public void subscribeInteractions(Consumer consumer) { + interactionSubscriber.add(consumer); + } + public void unsubscribeInteractions(Consumer consumer) { + interactionSubscriber.remove(consumer); + } + + public abstract InteractionType getInteractionType(Class clazz); + public abstract OptionType getOptionType(Class clazz); + public abstract LibraryConverter getConverter(); + +}