From 492399ec825ee21076174ac6b94099947ba5400a Mon Sep 17 00:00:00 2001 From: tueem Date: Fri, 25 Oct 2024 19:40:50 +0200 Subject: [PATCH] Switch to internal Librarywrapper instance management. --- .../java/net/tomatentum/marinara/Marinara.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/src/main/java/net/tomatentum/marinara/Marinara.java b/lib/src/main/java/net/tomatentum/marinara/Marinara.java index 04471b9..bc04316 100644 --- a/lib/src/main/java/net/tomatentum/marinara/Marinara.java +++ b/lib/src/main/java/net/tomatentum/marinara/Marinara.java @@ -1,13 +1,24 @@ package net.tomatentum.marinara; +import java.lang.reflect.Constructor; + import net.tomatentum.marinara.registry.InteractionRegistry; import net.tomatentum.marinara.wrapper.LibraryWrapper; public class Marinara { - public static Marinara load(LibraryWrapper wrapper) { - InteractionRegistry registry = new InteractionRegistry(wrapper); - return new Marinara(registry); + public static Marinara load(Class clazz) { + try { + Constructor 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;