added platform abstraction layer

This commit is contained in:
tueem 2024-10-13 14:27:04 +02:00
parent fff20c8dab
commit 55bfeee2d0
Signed by: tueem
GPG Key ID: 65C8667EC17A88FB
2 changed files with 45 additions and 0 deletions

@ -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);
}

@ -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<Consumer<Object>> 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<Object> consumer) {
interactionSubscriber.add(consumer);
}
public void unsubscribeInteractions(Consumer<Object> consumer) {
interactionSubscriber.remove(consumer);
}
public abstract InteractionType getInteractionType(Class<?> clazz);
public abstract OptionType getOptionType(Class<?> clazz);
public abstract LibraryConverter getConverter();
}