fix mod api
This commit is contained in:
@@ -2,5 +2,5 @@
|
|||||||
<PluginManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<PluginManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<Name>LuckPerms.Loader</Name>
|
<Name>LuckPerms.Loader</Name>
|
||||||
<Guid>7E4B3CC8-64FA-416E-8910-AACDF2DA5E2C</Guid>
|
<Guid>7E4B3CC8-64FA-416E-8910-AACDF2DA5E2C</Guid>
|
||||||
<Version>v5.4.106.2</Version>
|
<Version>v5.4.106.3</Version>
|
||||||
</PluginManifest>
|
</PluginManifest>
|
@@ -4,7 +4,7 @@ using me.lucko.luckperms.common.config.generic.key;
|
|||||||
|
|
||||||
namespace LuckPerms.Torch.Extensions;
|
namespace LuckPerms.Torch.Extensions;
|
||||||
|
|
||||||
public static class KeyedConfigurationExtensions
|
internal static class KeyedConfigurationExtensions
|
||||||
{
|
{
|
||||||
public static bool GetBoolean(this KeyedConfiguration config, ConfigKey key, bool defaultValue = default)
|
public static bool GetBoolean(this KeyedConfiguration config, ConfigKey key, bool defaultValue = default)
|
||||||
{
|
{
|
||||||
|
15
LuckPerms.Torch/Extensions/MultiplayerManagerExtensions.cs
Normal file
15
LuckPerms.Torch/Extensions/MultiplayerManagerExtensions.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using java.util;
|
||||||
|
using Torch.API;
|
||||||
|
using Torch.API.Managers;
|
||||||
|
using Torch.Server.Managers;
|
||||||
|
|
||||||
|
namespace LuckPerms.Torch.Extensions;
|
||||||
|
|
||||||
|
public static class MultiplayerManagerExtensions
|
||||||
|
{
|
||||||
|
public static IPlayer GetPlayer(this IMultiplayerManagerServer manager, ulong steamId) =>
|
||||||
|
((MultiplayerManagerDedicated)manager).Players[steamId];
|
||||||
|
|
||||||
|
public static IPlayer GetPlayer(this IMultiplayerManagerServer manager, UUID uuid) =>
|
||||||
|
((MultiplayerManagerDedicated)manager).Players[uuid.GetSteamId()];
|
||||||
|
}
|
@@ -5,7 +5,7 @@ using Torch.Utils;
|
|||||||
|
|
||||||
namespace LuckPerms.Torch.Extensions;
|
namespace LuckPerms.Torch.Extensions;
|
||||||
|
|
||||||
public static class StreamExtensions
|
internal static class StreamExtensions
|
||||||
{
|
{
|
||||||
public static InputStream GetInputStream(this Stream stream)
|
public static InputStream GetInputStream(this Stream stream)
|
||||||
{
|
{
|
||||||
|
@@ -4,6 +4,8 @@ using System.Linq;
|
|||||||
using ikvm.extensions;
|
using ikvm.extensions;
|
||||||
using ikvm.runtime;
|
using ikvm.runtime;
|
||||||
using java.lang;
|
using java.lang;
|
||||||
|
using LuckPerms.Torch.Extensions;
|
||||||
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using VRage.Scripting;
|
using VRage.Scripting;
|
||||||
|
|
||||||
@@ -18,7 +20,8 @@ public class ModApiManager : IManager
|
|||||||
|
|
||||||
MyScriptCompiler.Static.AddReferencedAssemblies(
|
MyScriptCompiler.Static.AddReferencedAssemblies(
|
||||||
typeof(net.luckperms.api.LuckPerms).Assembly.Location, // net.luckperms.api.dll
|
typeof(net.luckperms.api.LuckPerms).Assembly.Location, // net.luckperms.api.dll
|
||||||
typeof(java.lang.Boolean).Assembly.Location // IKVM.Java.dll
|
typeof(java.lang.Boolean).Assembly.Location, // IKVM.Java.dll
|
||||||
|
typeof(ModApiManager).Assembly.Location // LuckPerms.Torch.dll
|
||||||
);
|
);
|
||||||
|
|
||||||
using var whitelist = MyScriptCompiler.Static.Whitelist.OpenBatch();
|
using var whitelist = MyScriptCompiler.Static.Whitelist.OpenBatch();
|
||||||
@@ -27,7 +30,8 @@ public class ModApiManager : IManager
|
|||||||
whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(java.util.function.Consumer), typeof(java.util.UUID), typeof(java.time.Instant), typeof(java.time.temporal.Temporal));
|
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),
|
whitelist.AllowTypes(MyWhitelistTarget.ModApi, typeof(java.lang.Boolean), typeof(java.lang.Enum),
|
||||||
typeof(AutoCloseable), typeof(java.util.concurrent.TimeUnit),
|
typeof(AutoCloseable), typeof(java.util.concurrent.TimeUnit),
|
||||||
typeof(java.util.concurrent.CompletableFuture));
|
typeof(java.util.concurrent.CompletableFuture),
|
||||||
|
typeof(java.util.concurrent.Executor));
|
||||||
whitelist.AllowMembers(MyWhitelistTarget.ModApi,
|
whitelist.AllowMembers(MyWhitelistTarget.ModApi,
|
||||||
typeof(Class).GetMethod("op_Implicit", new[] { typeof(Type) }),
|
typeof(Class).GetMethod("op_Implicit", new[] { typeof(Type) }),
|
||||||
typeof(Class).GetMethod(nameof(Class.getName)),
|
typeof(Class).GetMethod(nameof(Class.getName)),
|
||||||
@@ -38,6 +42,11 @@ public class ModApiManager : IManager
|
|||||||
typeof(Util).GetMethod(nameof(Util.getRuntimeTypeFromClass)),
|
typeof(Util).GetMethod(nameof(Util.getRuntimeTypeFromClass)),
|
||||||
typeof(ExtensionMethods).GetMethod(nameof(ExtensionMethods.getClass), new []{ typeof(object) }),
|
typeof(ExtensionMethods).GetMethod(nameof(ExtensionMethods.getClass), new []{ typeof(object) }),
|
||||||
typeof(java.lang.Object).GetMethod(nameof(java.lang.Object.getClass)));
|
typeof(java.lang.Object).GetMethod(nameof(java.lang.Object.getClass)));
|
||||||
|
|
||||||
|
whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(UuidExtensions));
|
||||||
|
whitelist.AllowTypes(MyWhitelistTarget.ModApi, typeof(TorchApi), typeof(IDependencyProvider), typeof(IManager),
|
||||||
|
typeof(DependencyProviderExtensions), typeof(IMultiplayerManagerServer), typeof(IMultiplayerManagerBase),
|
||||||
|
typeof(IPlayer), typeof(ConnectionState));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Detach()
|
public void Detach()
|
||||||
|
12
LuckPerms.Torch/ModApi/TorchApi.cs
Normal file
12
LuckPerms.Torch/ModApi/TorchApi.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Torch;
|
||||||
|
using Torch.API.Managers;
|
||||||
|
|
||||||
|
namespace LuckPerms.Torch.ModApi;
|
||||||
|
|
||||||
|
public static class TorchApi
|
||||||
|
{
|
||||||
|
public static IDependencyProvider Managers =>
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
TorchBase.Instance.CurrentSession?.Managers ?? TorchBase.Instance.Managers;
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
}
|
@@ -2,5 +2,5 @@
|
|||||||
<PluginManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<PluginManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<Name>LuckPerms.Torch</Name>
|
<Name>LuckPerms.Torch</Name>
|
||||||
<Guid>7E4B3CC8-64FA-416E-8910-AACDF2DA5E2C</Guid>
|
<Guid>7E4B3CC8-64FA-416E-8910-AACDF2DA5E2C</Guid>
|
||||||
<Version>v5.4.106.2</Version>
|
<Version>v5.4.106.3</Version>
|
||||||
</PluginManifest>
|
</PluginManifest>
|
Reference in New Issue
Block a user