This commit is contained in:
zznty
2023-11-20 19:36:35 +07:00
parent 3e09ef63fb
commit e1ca099dd9
14 changed files with 45 additions and 15 deletions

View File

@@ -2,13 +2,13 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata> <metadata>
<id>LuckPerms.Torch.Api</id> <id>LuckPerms.Torch.Api</id>
<version>5.4</version> <version>5.4.1</version>
<authors>LuckPerms.Torch.Api</authors> <authors>LuckPerms.Torch.Api</authors>
<description>Package Description</description> <description>Package Description</description>
<dependencies> <dependencies>
<group targetFramework=".NETFramework4.8"> <group targetFramework=".NETFramework4.8">
<dependency id="Torch.Loader" version="1.0.0" /> <dependency id="Torch.Loader" version="1.0.0" />
<dependency id="LuckPerms.Torch.Utils" version="1.0.0" /> <dependency id="LuckPerms.Torch.Utils" version="1.0.1" />
<dependency id="IKVM.Maven.Sdk" version="1.6.1" /> <dependency id="IKVM.Maven.Sdk" version="1.6.1" />
</group> </group>
</dependencies> </dependencies>

View File

@@ -0,0 +1,14 @@
using net.luckperms.api.query;
using net.luckperms.api.util;
using Torch.API;
namespace LuckPerms.Torch.Api;
public interface ILpPlayerModel : IPlayer
{
Tristate HasPermission(string permission);
Tristate HasPermission(string permission, QueryOptions queryOptions);
string? GetOption(string key);
string? GetOption(string key, QueryOptions queryOptions);
}

View File

@@ -0,0 +1,8 @@
using Torch.API.Managers;
namespace LuckPerms.Torch.Api.Managers;
public interface ILuckPermsPlatformManager : IManager
{
net.luckperms.api.LuckPerms Api { get; }
}

View File

@@ -2,10 +2,11 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net48</TargetFramework> <TargetFramework>net48</TargetFramework>
<RootNamespace>LuckPerms.Torch</RootNamespace>
<LangVersion>12</LangVersion> <LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>1.0.0</Version> <Version>1.0.1</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@@ -21,7 +22,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="IKVM" Version="8.7.1" /> <PackageReference Include="IKVM" Version="8.7.1" />
<PackageReference Include="torch.server.referenceassemblies" Version="1.3.1.260-master" PrivateAssets="all" IncludeAssets="compile" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -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.Api;
using LuckPerms.Torch.Api.Managers;
using LuckPerms.Torch.Extensions; using LuckPerms.Torch.Extensions;
using LuckPerms.Torch.Utils.Extensions; using LuckPerms.Torch.Utils.Extensions;
using Torch.API; using Torch.API;
@@ -22,7 +24,7 @@ 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 typeof(ILuckPermsPlatformManager).Assembly.Location, // LuckPerms.Torch.Utils.dll
typeof(ITorchBase).Assembly.Location // Torch.API.dll typeof(ITorchBase).Assembly.Location // Torch.API.dll
); );
@@ -48,7 +50,7 @@ public class ModApiManager : IManager
whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(UuidExtensions)); whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(UuidExtensions));
whitelist.AllowTypes(MyWhitelistTarget.ModApi, typeof(TorchApi), typeof(IDependencyProvider), typeof(IManager), whitelist.AllowTypes(MyWhitelistTarget.ModApi, typeof(TorchApi), typeof(IDependencyProvider), typeof(IManager),
typeof(DependencyProviderExtensions), typeof(IMultiplayerManagerServer), typeof(IMultiplayerManagerBase), typeof(DependencyProviderExtensions), typeof(IMultiplayerManagerServer), typeof(IMultiplayerManagerBase),
typeof(IPlayer), typeof(ConnectionState)); typeof(IPlayer), typeof(ConnectionState), typeof(ILpPlayerModel));
} }
public void Detach() public void Detach()

View File

@@ -1,4 +1,5 @@
using LuckPerms.Torch.Impl; using LuckPerms.Torch.Api;
using LuckPerms.Torch.Impl;
using me.lucko.luckperms.common.context.manager; using me.lucko.luckperms.common.context.manager;
using me.lucko.luckperms.common.model; using me.lucko.luckperms.common.model;
using me.lucko.luckperms.common.verbose.@event; using me.lucko.luckperms.common.verbose.@event;
@@ -8,7 +9,7 @@ using Torch.ViewModels;
namespace LuckPerms.Torch.PlatformApi; namespace LuckPerms.Torch.PlatformApi;
public class LpPlayerModel(ulong steamId, string? name = null) : PlayerViewModel(steamId, name) public class LpPlayerModel(ulong steamId, string? name = null) : PlayerViewModel(steamId, name), ILpPlayerModel
{ {
public QueryOptionsCache? QueryOptionsCache { get; private set; } public QueryOptionsCache? QueryOptionsCache { get; private set; }
public User? LpUser { get; private set; } public User? LpUser { get; private set; }

View File

@@ -1,19 +1,22 @@
using System.IO; using System;
using System.IO;
using java.lang; using java.lang;
using LuckPerms.Torch.Api.Managers;
using LuckPerms.Torch.Impl; using LuckPerms.Torch.Impl;
using NLog; using NLog;
using Torch; using Torch;
using Torch.API; using Torch.API;
using Torch.API.Managers;
using Exception = System.Exception; using Exception = System.Exception;
namespace LuckPerms.Torch.PlatformApi; namespace LuckPerms.Torch.PlatformApi;
public class LuckPermsPlatformManager : IManager public class LuckPermsPlatformManager : ILuckPermsPlatformManager
{ {
private readonly ILogger _log = LogManager.GetCurrentClassLogger(); private readonly ILogger _log = LogManager.GetCurrentClassLogger();
private readonly LpTorchBootstrap _bootstrap; private readonly LpTorchBootstrap _bootstrap;
public net.luckperms.api.LuckPerms Api => _bootstrap.EnableLatch.getCount() == 0 ? _bootstrap.Plugin.getApiProvider() : throw new InvalidOperationException("Api is not initialized");
public LuckPermsPlatformManager(TorchPluginBase plugin, ITorchServer server, ILogger log) public LuckPermsPlatformManager(TorchPluginBase plugin, ITorchServer server, ILogger log)
{ {
_bootstrap = new(server, plugin, log, Path.Combine(plugin.StoragePath, "luckperms")); _bootstrap = new(server, plugin, log, Path.Combine(plugin.StoragePath, "luckperms"));

View File

@@ -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.5</Version> <Version>v5.4.106.6</Version>
</PluginManifest> </PluginManifest>