M Config.cs => Config.cs +6 -7
@@ 1,20 1,19 @@
using System.Runtime.InteropServices;
-using Exiled.API.Interfaces;
using Mamoru.Utils;
namespace Mamoru;
-public class Config : IConfig {
+public class Config {
public string Secret { get; set; } = Crypto.GenerateSecret();
- public string AuthEndpoint { get; set; } = "";
+ public string AuthEndpoint { get; set; } = "https://mamoru-auth.furry.coffee";
- public string ServerConfigPath { get; set; } = FileManager.GetAppFolder(serverConfig: true);
+ public string ServerConfigPath { get; set; } =
+ RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
+ ? $"/home/{Environment.UserName}/.config/SCP Secret Laboratory/config/"
+ : $@"C:\Users\{Environment.UserName}\AppData\Roaming\SCP Secret Laboratory\config\";
public string ExiledConfigPath { get; set; } =
RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
? $"/home/{Environment.UserName}/.config/EXILED/Configs/"
: $@"C:\Users\{Environment.UserName}\AppData\Roaming\EXILED\Configs\";
-
- public bool IsEnabled { get; set; } = true;
- public bool Debug { get; set; } = false;
}=
\ No newline at end of file
M Mamoru.cs => Mamoru.cs +18 -12
@@ 1,32 1,38 @@
-using Exiled.API.Features;
-using Mamoru.Managers;
+using Mamoru.Managers;
+using PluginAPI.Core;
+using PluginAPI.Core.Attributes;
+using PluginAPI.Enums;
namespace Mamoru;
-public class Mamoru : Plugin<Config> {
+public class Mamoru {
+ public static Mamoru? Instance { get; private set; }
+ public PluginHandler? Handler { get; private set; }
+ [PluginConfig] public Config Config;
+
public ConfigManager ConfigManager = null!;
public RoutesManager RoutesManager = null!;
public ConnectionsManager ConnectionsManager = null!;
-
- public static Mamoru Instance { get; } = new();
- public override string Name => "Mamoru";
- public override string Author => "furry";
+ [PluginPriority(LoadPriority.Low)]
+ [PluginEntryPoint("Mamoru", "1.0.0-alpha", "An uncomplicated moderation tool for SCP: SL.", "furry")]
+ public void LoadPlugin() {
+ Instance = this;
+ Handler = PluginHandler.Get(this);
- public override void OnEnabled() {
ConfigManager = new ConfigManager();
RoutesManager = new RoutesManager();
- ConnectionsManager = new ConnectionsManager();
+// ConnectionsManager = new ConnectionsManager();
Log.Info("Mamoru was enabled.");
- base.OnEnabled();
+ Log.Info(Instance.Config.ToString());
}
- public override void OnDisabled() {
+ [PluginUnload]
+ public void OnDisabled() {
RoutesManager.StopHttpServer();
ConnectionsManager.StopWebsocketServer();
Log.Info("Mamoru was disabled.");
- base.OnDisabled();
}
}=
\ No newline at end of file
M Mamoru.csproj => Mamoru.csproj +7 -1
@@ 9,7 9,7 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="EXILED" Version="9.0.0-beta.5" />
+ <PackageReference Include="Northwood.PluginAPI" Version="13.1.2" />
<PackageReference Include="Watson" Version="6.2.2" />
<PackageReference Include="WatsonWebsocket" Version="4.1.2" />
</ItemGroup>
@@ 18,4 18,10 @@
<Folder Include="Connections\" />
<Folder Include="Models.EXILED\"/>
</ItemGroup>
+
+ <ItemGroup>
+ <Reference Include="Assembly-CSharp">
+ <HintPath>..\..\..\.steam\steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
+ </Reference>
+ </ItemGroup>
</Project>
M Mamoru.sln.DotSettings.user => Mamoru.sln.DotSettings.user +7 -1
@@ 1,6 1,12 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+ <s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fnora_002F_002Esteam_002Fsteam_002Fsteamapps_002Fcommon_002FSCP_0020Secret_0020Laboratory_0020Dedicated_0020Server_002FSCPSL_005FData_002FManaged_002FAssembly_002DCSharp_002Edll/@EntryIndexedValue">True</s:Boolean>
+ <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APermissionsHandler_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe1b23ebe5ae54d29b01902bb36299308274e00_003F51_003F146fbb53_003FPermissionsHandler_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
+ <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APlayerPermissions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe1b23ebe5ae54d29b01902bb36299308274e00_003Fcf_003F6f634d89_003FPlayerPermissions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
+ <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APlayer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F163c477b167a499d9ae83e62d72d8a2e29c00_003F4e_003F3b2dff24_003FPlayer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
+ <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APluginUnload_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F163c477b167a499d9ae83e62d72d8a2e29c00_003F28_003Fa972e478_003FPluginUnload_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
+ <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AServer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F163c477b167a499d9ae83e62d72d8a2e29c00_003Ff6_003F47ab54d4_003FServer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
- <Assembly Path="/home/nora/.nuget/packages/exiled/9.0.0-beta.5/lib/net48/Exiled.API.dll" />
+ <Assembly Path="/home/nora/.steam/steam/steamapps/common/SCP Secret Laboratory Dedicated Server/SCPSL_Data/Managed/Assembly-CSharp.dll" />
</AssemblyExplorer></s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">/home/nora/.dotnet/sdk/9.0.100-preview.7.24407.12/MSBuild.dll</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/DotNetCliExePath/@EntryValue">/home/nora/.dotnet/dotnet</s:String>
M Managers/ConfigManager.cs => Managers/ConfigManager.cs +2 -2
@@ 1,5 1,5 @@
-using Exiled.API.Features;
using Mamoru.Models.DedicatedServer;
+using PluginAPI.Core;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
@@ 42,7 42,7 @@ public class ConfigManager {
private void LoadGameplayConfig() {
Log.Info("Loading config_gameplay...");
- var str = File.ReadAllText(Mamoru.Instance.Config.ServerConfigPath + "config_gameplay.txt");
+ var str = File.ReadAllText(Mamoru.Instance!.Config.ServerConfigPath + "config_gameplay.txt");
GameplayConfig = _deserializer.Deserialize<GameplayConfig>(str);
}
}=
\ No newline at end of file
M Managers/RoutesManager.cs => Managers/RoutesManager.cs +1 -1
@@ 1,9 1,9 @@
using System.Net;
using System.Reflection;
using System.Text.RegularExpressions;
-using Exiled.API.Features;
using Mamoru.Resources;
using Mamoru.Utils;
+using PluginAPI.Core;
using WatsonWebserver.Core;
using WatsonWebserver;
M Models.Mamoru/GetServerStatusResponse.cs => Models.Mamoru/GetServerStatusResponse.cs +6 -6
@@ 1,8 1,8 @@
namespace Mamoru.Models.Mamoru;
-public record GetServerStatusResponse(
- bool Auth,
- bool Webhooks,
- string ExiledVersion,
- string MamoruVersion
-);>
\ No newline at end of file
+public class GetServerStatusResponse {
+ public bool Auth { get; set; }
+ public bool Webhooks { get; set; }
+ public string PluginAPIVersion { get; set; }
+ public string MamoruVersion { get; set; }
+}<
\ No newline at end of file
M Models.Mamoru/ListPlayersResponse.cs => Models.Mamoru/ListPlayersResponse.cs +6 -6
@@ 1,8 1,8 @@
namespace Mamoru.Models.Mamoru;
-public record ListPlayersResponse(
- ushort Id,
- string? Steamid,
- string Name,
- bool RaAuthenticated
-);>
\ No newline at end of file
+public class ListPlayersResponse {
+ public int Id { get; set; }
+ public string UserId { get; set; }
+ public string Name { get; set; }
+ public bool RaAuthenticated { get; set; }
+}<
\ No newline at end of file
M Resources/MiscResource.cs => Resources/MiscResource.cs +7 -9
@@ 1,5 1,3 @@
-using System.Reflection;
-using Exiled.Loader;
using Mamoru.Models.Mamoru;
using Mamoru.Utils;
using WatsonWebserver.Core;
@@ 15,14 13,14 @@ public static class MiscResource {
[Route(HttpMethod.GET, "/.well-known/mamoru/status")]
public static async Task GetServerStatus(HttpContextBase ctx) {
- var status = new GetServerStatusResponse(
- true,
- true,
- Assembly.GetAssembly(typeof(Loader)).GetName().Version.ToString(),
- Assembly.GetExecutingAssembly().GetName().Version.ToString()
- );
+ var status = new GetServerStatusResponse {
+ Auth = true,
+ Webhooks = true,
+ MamoruVersion = Mamoru.Instance!.Handler!.PluginVersion,
+ PluginAPIVersion = PluginAPI.PluginApiVersion.VersionString
+ };
- ctx.Response.ContentType = "application/yaml";
+ ctx.Response.ContentType = "application/yaml";
await ctx.Response.Send(Serializers.YamlSerializer.Serialize(status));
}
}=
\ No newline at end of file
M Resources/PlayersResource.cs => Resources/PlayersResource.cs +9 -4
@@ 1,6 1,6 @@
-using Exiled.API.Features;
using Mamoru.Models.Mamoru;
using Mamoru.Utils;
+using PluginAPI.Core;
using WatsonWebserver.Core;
namespace Mamoru.Resources;
@@ 9,9 9,14 @@ public static class PlayersResource {
[Route(HttpMethod.GET, "/players/list")]
public static async Task ListPlayers(HttpContextBase ctx) {
List<ListPlayersResponse> players = [];
-
- Player.List.ToList().ForEach(player => {
- players.Add(new ListPlayersResponse((ushort)player.Id, player.UserId, player.Nickname, player.RemoteAdminAccess));
+
+ Player.GetPlayers().ForEach(player => {
+ players.Add(new ListPlayersResponse {
+ Id = player.PlayerId,
+ Name = player.Nickname,
+ RaAuthenticated = player.RemoteAdminAccess,
+ UserId = player.UserId
+ });
});
ctx.Response.ContentType = "application/yaml";