diff --git a/LuckPerms.Loader/manifest.xml b/LuckPerms.Loader/manifest.xml
index dc273fa..1634d75 100644
--- a/LuckPerms.Loader/manifest.xml
+++ b/LuckPerms.Loader/manifest.xml
@@ -2,5 +2,5 @@
LuckPerms.Loader
7E4B3CC8-64FA-416E-8910-AACDF2DA5E2C
- v5.4.106
+ v5.4.106.1
\ No newline at end of file
diff --git a/LuckPerms.Torch/Impl/LpTorchPlugin.cs b/LuckPerms.Torch/Impl/LpTorchPlugin.cs
index 9b6b78e..b0a549c 100644
--- a/LuckPerms.Torch/Impl/LpTorchPlugin.cs
+++ b/LuckPerms.Torch/Impl/LpTorchPlugin.cs
@@ -6,6 +6,7 @@ using LuckPerms.Torch.Extensions;
using LuckPerms.Torch.Impl.Calculator;
using LuckPerms.Torch.Impl.Listeners;
using LuckPerms.Torch.Impl.Messaging;
+using LuckPerms.Torch.ModApi;
using LuckPerms.Torch.PlatformHooks;
using me.lucko.luckperms.common.api;
using me.lucko.luckperms.common.calculator;
@@ -71,6 +72,7 @@ public class LpTorchPlugin(LuckPermsBootstrap bootstrap, ITorchBase torch) : Abs
_trackManager = new(this);
_connectionListener = new(this);
torch.Managers.GetManager().AddFactory(_ => _connectionListener);
+ torch.Managers.GetManager().AddFactory(_ => new ModApiManager());
}
protected override CalculatorFactory provideCalculatorFactory() => new LpCalculatorFactory(this);
diff --git a/LuckPerms.Torch/ModApi/ModApiManager.cs b/LuckPerms.Torch/ModApi/ModApiManager.cs
new file mode 100644
index 0000000..9f9e6f2
--- /dev/null
+++ b/LuckPerms.Torch/ModApi/ModApiManager.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using ikvm.extensions;
+using ikvm.runtime;
+using java.lang;
+using Torch.API.Managers;
+using VRage.Scripting;
+
+namespace LuckPerms.Torch.ModApi;
+
+public class ModApiManager : IManager
+{
+ public void Attach()
+ {
+ // TODO make and reference platform helpers (uuid extensions, delegate converters etc)
+ MyScriptCompiler.Static.AddConditionalCompilationSymbols("LUCKPERMS_API");
+
+ MyScriptCompiler.Static.AddReferencedAssemblies(
+ typeof(net.luckperms.api.LuckPerms).Assembly.Location, // net.luckperms.api.dll
+ typeof(java.lang.Boolean).Assembly.Location // IKVM.Java.dll
+ );
+
+ using var whitelist = MyScriptCompiler.Static.Whitelist.OpenBatch();
+
+ whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(net.luckperms.api.LuckPerms).Assembly.GetTypes().Distinct(TypeNamespaceComparer.Instance).ToArray());
+ whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(java.util.function.Consumer), typeof(java.util.UUID), typeof(java.time.Instant), typeof(java.time.temporal.Temporal));
+ whitelist.AllowTypes(MyWhitelistTarget.ModApi, typeof(java.lang.Boolean), typeof(java.lang.Enum),
+ typeof(AutoCloseable), typeof(java.util.concurrent.TimeUnit),
+ typeof(java.util.concurrent.CompletableFuture));
+ whitelist.AllowMembers(MyWhitelistTarget.ModApi,
+ typeof(Class).GetMethod("op_Implicit", new[] { typeof(Type) }),
+ typeof(Class).GetMethod(nameof(Class.getName)),
+ typeof(Class).GetMethod(nameof(Class.getTypeName)),
+ typeof(Util).GetMethod(nameof(Util.getClassFromObject)),
+ typeof(Util).GetMethod(nameof(Util.getFriendlyClassFromType)),
+ typeof(Util).GetMethod(nameof(Util.getInstanceTypeFromClass)),
+ typeof(Util).GetMethod(nameof(Util.getRuntimeTypeFromClass)),
+ typeof(ExtensionMethods).GetMethod(nameof(ExtensionMethods.getClass), new []{ typeof(object) }),
+ typeof(java.lang.Object).GetMethod(nameof(java.lang.Object.getClass)));
+ }
+
+ public void Detach()
+ {
+ }
+
+ private sealed class TypeNamespaceComparer : IEqualityComparer
+ {
+ public static readonly IEqualityComparer Instance = new TypeNamespaceComparer();
+
+ public bool Equals(Type x, Type y)
+ {
+ if (ReferenceEquals(x, y)) return true;
+ if (ReferenceEquals(x, null)) return false;
+ if (ReferenceEquals(y, null)) return false;
+ if (x.GetType() != y.GetType()) return false;
+ return x.Namespace == y.Namespace;
+ }
+
+ public int GetHashCode(Type obj)
+ {
+ return obj.Namespace != null ? obj.Namespace.GetHashCode() : 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/LuckPerms.Torch/manifest.xml b/LuckPerms.Torch/manifest.xml
index fbdecf1..677ec9f 100644
--- a/LuckPerms.Torch/manifest.xml
+++ b/LuckPerms.Torch/manifest.xml
@@ -2,5 +2,5 @@
LuckPerms.Torch
7E4B3CC8-64FA-416E-8910-AACDF2DA5E2C
- v5.4.106
+ v5.4.106.1
\ No newline at end of file