Fix H2 for fabric

This commit is contained in:
IxPrumxI 2025-01-13 01:21:28 +03:00
parent 78d355491c
commit 2ec29d1d56

View File

@ -22,6 +22,7 @@ import com.discordsrv.common.DiscordSRV;
import com.discordsrv.common.config.connection.StorageConfig;
import com.discordsrv.common.core.storage.impl.sql.SQLStorage;
import com.discordsrv.common.exception.StorageException;
import com.discordsrv.common.util.ReflectionUtil;
import dev.vankka.dependencydownload.classloader.IsolatedClassLoader;
import java.io.IOException;
@ -51,7 +52,13 @@ public class H2Storage extends SQLStorage {
StorageConfig storageConfig = discordSRV.connectionConfig().storage;
try {
Class<?> clazz = classLoader.loadClass("org.h2.jdbc.JdbcConnection");
Class<?> clazz;
if(ReflectionUtil.classExists("net.fabricmc.loader.api.FabricLoader")) {
clazz = getClass().getClassLoader().loadClass("org.h2.jdbc.JdbcConnection");
} else {
clazz = classLoader.loadClass("org.h2.jdbc.JdbcConnection");
}
Constructor<?> constructor = clazz.getConstructor(
String.class, // url
Properties.class, // info