From 6f51f3ab07e8ef59e425766fd02bebeafab8f3bc Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 21 Jan 2025 22:28:46 +0100 Subject: [PATCH 01/42] No error for build --- EXILED/Exiled.API/Exiled.API.csproj | 2 +- .../Extensions/UserGroupExtensions.cs | 4 +- EXILED/Exiled.API/Features/Camera.cs | 4 +- .../CustomStats/CustomHumeShieldStat.cs | 6 +-- .../Features/Doors/CheckpointDoor.cs | 16 +++--- .../Features/Hazards/TemporaryHazard.cs | 4 +- EXILED/Exiled.API/Features/Paths.cs | 3 +- EXILED/Exiled.API/Features/Player.cs | 52 +++++++++++-------- EXILED/Exiled.API/Features/Scp914.cs | 8 +-- EXILED/Exiled.API/Features/Server.cs | 6 +-- EXILED/Exiled.API/Features/Warhead.cs | 2 +- .../Exiled.CreditTags.csproj | 4 +- .../Exiled.CustomItems.csproj | 2 +- .../Exiled.CustomRoles.csproj | 2 +- EXILED/Exiled.Events/Commands/Config/Merge.cs | 2 +- EXILED/Exiled.Events/Commands/Config/Split.cs | 2 +- .../DeactivatingWorkstationEventArgs.cs | 2 +- .../Player/PreAuthenticatingEventArgs.cs | 1 - .../Player/SendingValidCommandEventArgs.cs | 2 +- .../Player/SentValidCommandEventArgs.cs | 2 +- EXILED/Exiled.Events/Events.cs | 6 +-- EXILED/Exiled.Events/Exiled.Events.csproj | 2 +- EXILED/Exiled.Events/Handlers/Player.cs | 4 -- .../Events/Cassie/SendingCassieMessage.cs | 2 +- .../Events/Player/EscapingAndEscaped.cs | 38 -------------- .../Events/Player/InteractingGenerator.cs | 13 +++-- .../Events/Player/ProcessDisarmMessage.cs | 6 +-- .../Events/Player/ReservedSlotPatch.cs | 5 +- .../Patches/Events/Player/TogglingRadio.cs | 4 +- .../Player/UsingAndCancellingItemUse.cs | 4 +- .../Patches/Events/Scp079/ChangingCamera.cs | 1 - .../Patches/Events/Scp173/BeingObserved.cs | 9 ++-- .../Events/Scp330/InteractingScp330.cs | 5 +- .../Patches/Fixes/NWFixDetonationTimer.cs | 2 +- .../Patches/Generic/OfflineModeIds.cs | 9 ++-- .../Patches/Generic/ServerNamePatch.cs | 2 +- EXILED/Exiled.Example/Exiled.Example.csproj | 2 +- EXILED/Exiled.Loader/AutoUpdateFiles.cs | 5 ++ EXILED/Exiled.Loader/AutoUpdateFiles.tt | 5 ++ EXILED/Exiled.Loader/ConfigManager.cs | 2 +- EXILED/Exiled.Loader/Exiled.Loader.csproj | 2 +- EXILED/Exiled.Loader/Loader.cs | 2 +- EXILED/Exiled.Loader/LoaderPlugin.cs | 51 ++++++++++++++---- EXILED/Exiled.Loader/Updater.cs | 4 +- .../Exiled.Permissions.csproj | 2 +- .../Extensions/Permissions.cs | 4 +- EXILED/docs/docs.csproj | 2 +- 47 files changed, 153 insertions(+), 166 deletions(-) diff --git a/EXILED/Exiled.API/Exiled.API.csproj b/EXILED/Exiled.API/Exiled.API.csproj index 961b44e98d..c8737a790c 100644 --- a/EXILED/Exiled.API/Exiled.API.csproj +++ b/EXILED/Exiled.API/Exiled.API.csproj @@ -27,10 +27,10 @@ + - diff --git a/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs b/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs index 7b9138618c..41b8523433 100644 --- a/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs +++ b/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs @@ -37,7 +37,7 @@ public static bool EqualsTo(this UserGroup @this, UserGroup other) /// /// The . /// The key of that group, or if not found. - public static string GetKey(this UserGroup @this) => Server.PermissionsHandler._groups + public static string GetKey(this UserGroup @this) => Server.PermissionsHandler.Groups .FirstOrDefault(pair => pair.Value.EqualsTo(@this)).Key; /// @@ -47,7 +47,7 @@ public static string GetKey(this UserGroup @this) => Server.PermissionsHandler._ /// The value of that group, or if not found. public static UserGroup GetValue(string groupName) { - ServerStatic.GetPermissionsHandler().GetAllGroups().TryGetValue(groupName, out UserGroup userGroup); + ServerStatic.PermissionsHandler.GetAllGroups().TryGetValue(groupName, out UserGroup userGroup); return userGroup; } } diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index 6c72485739..d852933ddc 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -216,8 +216,8 @@ internal Camera(Scp079Camera camera079) /// public Quaternion Rotation { - get => Base._cameraAnchor.rotation; - set => Base._cameraAnchor.rotation = value; + get => Base.CameraAnchor.rotation; + set => Base.CameraAnchor.rotation = value; } /// diff --git a/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs b/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs index 78c4cd807d..fbc65ad88d 100644 --- a/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs +++ b/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) ExMod Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -45,7 +45,7 @@ public override void Update() if (!NetworkServer.active) return; - if (_valueDirty) + if (ValueDirty) { new SyncedStatMessages.StatMessage() { @@ -53,7 +53,7 @@ public override void Update() SyncedValue = CurValue, }.SendToHubsConditionally(CanReceive); _lastSent = CurValue; - _valueDirty = false; + ValueDirty = false; } if (ShieldRegeneration == 0) diff --git a/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs b/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs index 837bd5ff72..06c4f756db 100644 --- a/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs +++ b/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs @@ -44,8 +44,8 @@ internal CheckpointDoor(Interactables.Interobjects.CheckpointDoor door, List public Interactables.Interobjects.CheckpointDoor.CheckpointSequenceStage CurrentStage { - get => Base._currentSequence; - set => Base._currentSequence = value; + get => Base.CurrentSequence; + set => Base.CurrentSequence = value; } /// @@ -53,8 +53,8 @@ public Interactables.Interobjects.CheckpointDoor.CheckpointSequenceStage Current /// public float MainTimer { - get => Base._mainTimer; - set => Base._mainTimer = value; + get => Base.MainTimer; + set => Base.MainTimer = value; } /// @@ -62,8 +62,8 @@ public float MainTimer /// public float WaitTime { - get => Base._waitTime; - set => Base._waitTime = value; + get => Base.WaitTime; + set => Base.WaitTime = value; } /// @@ -71,8 +71,8 @@ public float WaitTime /// public float WarningTime { - get => Base._warningTime; - set => Base._warningTime = value; + get => Base.WarningTime; + set => Base.WarningTime = value; } /// diff --git a/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs b/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs index 0e701a8093..c9dfecb650 100644 --- a/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs +++ b/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs @@ -56,8 +56,8 @@ public bool IsDestroyed /// public float Duration { - get => Base._elapsed; - set => Base._elapsed = value; + get => Base.Elapsed; + set => Base.Elapsed = value; } /// diff --git a/EXILED/Exiled.API/Features/Paths.cs b/EXILED/Exiled.API/Features/Paths.cs index 153d8e0bf6..b80b88dbd4 100644 --- a/EXILED/Exiled.API/Features/Paths.cs +++ b/EXILED/Exiled.API/Features/Paths.cs @@ -106,7 +106,8 @@ public static void Reload(string rootDirectory = null) Dependencies = Path.Combine(Plugins, "dependencies"); Configs = Path.Combine(Exiled, "Configs"); IndividualConfigs = Path.Combine(Configs, "Plugins"); - LoaderConfig = PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.MainConfigPath; + + // LoaderConfig = LabApi.Loader.PluginLoader.EnabledPlugins.FirstOrDefault(x => x.Name == "Exiled Loader")?; // TODO Config = Path.Combine(Configs, $"{Server.Port}-config.yml"); BackupConfig = Path.Combine(Configs, $"{Server.Port}-config.yml.old"); IndividualTranslations = Path.Combine(Configs, "Translations"); diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index ada3c952af..454cb88d18 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -53,7 +53,6 @@ namespace Exiled.API.Features using PlayerRoles.Spectating; using PlayerRoles.Voice; using PlayerStatsSystem; - using PluginAPI.Core; using RelativePositioning; using RemoteAdmin; using Respawning.NamingRules; @@ -422,7 +421,7 @@ public float InfoViewRange /// /// /// - public bool HasReservedSlot => ReservedSlot.HasReservedSlot(UserId, out _); + public bool HasReservedSlot => ReservedSlot.HasReservedSlot(UserId); /// /// Gets a value indicating whether the player is in whitelist. @@ -509,7 +508,7 @@ public Player Cuffer public virtual Vector3 Position { get => Transform.position; - set => ReferenceHub.TryOverridePosition(value, Vector3.zero); + set => ReferenceHub.TryOverridePosition(value); } /// @@ -529,7 +528,7 @@ public RelativePosition RelativePosition public Quaternion Rotation { get => Transform.rotation; - set => ReferenceHub.TryOverridePosition(Position, value.eulerAngles); + set => ReferenceHub.TryOverrideRotation(value.eulerAngles); } /// @@ -1014,8 +1013,8 @@ public float Stamina /// public string GroupName { - get => ServerStatic.PermissionsHandler._members.TryGetValue(UserId, out string groupName) ? groupName : null; - set => ServerStatic.PermissionsHandler._members[UserId] = value; + get => ServerStatic.PermissionsHandler.Members.TryGetValue(UserId, out string groupName) ? groupName : null; + set => ServerStatic.PermissionsHandler.Members[UserId] = value; } /// @@ -1182,11 +1181,18 @@ public bool IsSpawnProtected internal static ConditionalWeakTable UnverifiedPlayers { get; } = new(); /// - /// Converts NwPluginAPI player to EXILED player. + /// Converts LabApi player to EXILED player. /// - /// The NwPluginAPI player. + /// The LabApi player. /// EXILED player. - public static implicit operator Player(PluginAPI.Core.Player player) => Get(player); + public static implicit operator Player(LabApi.Features.Wrappers.Player player) => Get(player); + + /// + /// Converts LabApi player to EXILED player. + /// + /// The LabApi player. + /// EXILED player. + public static implicit operator LabApi.Features.Wrappers.Player(Player player) => LabApi.Features.Wrappers.Player.Get(player.ReferenceHub); /// /// Gets a filtered by side. Can be empty. @@ -1377,11 +1383,11 @@ public static Player Get(string args) } /// - /// Gets the from NwPluginAPI class. + /// Gets the from LabApi class. /// - /// The class. + /// The class. /// A or if not found. - public static Player Get(PluginAPI.Core.Player apiPlayer) => Get(apiPlayer.ReferenceHub); + public static Player Get(LabApi.Features.Wrappers.Player apiPlayer) => Get(apiPlayer.ReferenceHub); /// /// Try-get a player given a . @@ -1464,12 +1470,12 @@ public static Player Get(string args) public static bool TryGet(string args, out Player player) => (player = Get(args)) is not null; /// - /// Try-get the from NwPluginAPI class. + /// Try-get the from LabApi class. /// - /// The class. + /// The class. /// The player found or if not found. /// A boolean indicating whether a player was found. - public static bool TryGet(PluginAPI.Core.Player apiPlayer, out Player player) => (player = Get(apiPlayer)) is not null; + public static bool TryGet(LabApi.Features.Wrappers.Player apiPlayer, out Player player) => (player = Get(apiPlayer)) is not null; /// /// Try-get player by . @@ -1508,10 +1514,10 @@ public static bool AddReservedSlot(string userId, bool isPermanent) { if (isPermanent) { - if (ReservedSlots.HasReservedSlot(userId)) + if (LabApi.Features.Wrappers.ReservedSlots.HasReservedSlot(userId)) return false; - ReservedSlots.Add(userId); + LabApi.Features.Wrappers.ReservedSlots.Add(userId); return true; } @@ -1532,7 +1538,7 @@ public static bool AddToWhitelist(string userId, bool isPermanent) if (WhiteList.IsOnWhitelist(userId)) return false; - Whitelist.Add(userId); + LabApi.Features.Wrappers.Whitelist.Add(userId); return true; } @@ -1824,7 +1830,7 @@ public bool TryGetItem(ushort serial, out Item item) /// The group to be set. public void SetRank(string name, UserGroup group) { - if (ServerStatic.GetPermissionsHandler()._groups.TryGetValue(name, out UserGroup userGroup)) + if (ServerStatic.PermissionsHandler.Groups.TryGetValue(name, out UserGroup userGroup)) { userGroup.BadgeColor = group.BadgeColor; userGroup.BadgeText = name; @@ -1835,15 +1841,15 @@ public void SetRank(string name, UserGroup group) } else { - ServerStatic.GetPermissionsHandler()._groups.Add(name, group); + ServerStatic.PermissionsHandler.Groups.Add(name, group); ReferenceHub.serverRoles.SetGroup(group, false, false); } - if (ServerStatic.GetPermissionsHandler()._members.ContainsKey(UserId)) - ServerStatic.GetPermissionsHandler()._members[UserId] = name; + if (ServerStatic.PermissionsHandler.Members.ContainsKey(UserId)) + ServerStatic.PermissionsHandler.Members[UserId] = name; else - ServerStatic.GetPermissionsHandler()._members.Add(UserId, name); + ServerStatic.PermissionsHandler.Members.Add(UserId, name); } /// diff --git a/EXILED/Exiled.API/Features/Scp914.cs b/EXILED/Exiled.API/Features/Scp914.cs index 57ee9d366c..7d9ea65818 100644 --- a/EXILED/Exiled.API/Features/Scp914.cs +++ b/EXILED/Exiled.API/Features/Scp914.cs @@ -40,8 +40,8 @@ public static Scp914KnobSetting KnobStatus /// public static Scp914Mode ConfigMode { - get => Scp914Controller._configMode.Value; - set => Scp914Controller._configMode.Value = value; + get => Scp914Controller.ConfigMode.Value; + set => Scp914Controller.ConfigMode.Value = value; } /// @@ -72,7 +72,7 @@ public static Scp914Mode ConfigMode /// /// Gets a value indicating whether SCP-914 is active and currently processing items. /// - public static bool IsWorking => Scp914Controller._isUpgrading; + public static bool IsWorking => Scp914Controller.IsUpgrading; /// /// Gets a value indicating all of the GameObjects currently present inside SCP-914's intake chamber. @@ -92,7 +92,7 @@ public static Scp914Mode ConfigMode /// /// Gets the list with which SCP-914 has. /// - public static IReadOnlyCollection Doors => Scp914Controller._doors.Select(Door.Get).ToList(); + public static IReadOnlyCollection Doors => Scp914Controller.Doors.Select(Door.Get).ToList(); /// /// Filters all GameObjects inside SCP-914's intake chamber into players and items. diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs index c79d0c4c1d..c9a7e40212 100644 --- a/EXILED/Exiled.API/Features/Server.cs +++ b/EXILED/Exiled.API/Features/Server.cs @@ -60,11 +60,11 @@ public static class Server /// public static string Name { - get => ServerConsole._serverName; + get => ServerConsole.ServerName; set { - ServerConsole._serverName = value; - ServerConsole.singleton.RefreshServerName(); + ServerConsole.ServerName = value; + ServerConsole.Singleton.RefreshServerName(); } } diff --git a/EXILED/Exiled.API/Features/Warhead.cs b/EXILED/Exiled.API/Features/Warhead.cs index 687b4fb035..7ff16a9e93 100644 --- a/EXILED/Exiled.API/Features/Warhead.cs +++ b/EXILED/Exiled.API/Features/Warhead.cs @@ -168,7 +168,7 @@ public static int Kills public static void CloseBlastDoors() { foreach (BlastDoor door in BlastDoors) - door.SetClosed(false, true); + door.SetDoorState(false, true); } /// diff --git a/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj b/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj index 9382489fb3..a169d69155 100644 --- a/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj +++ b/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj @@ -27,13 +27,13 @@ + - - + diff --git a/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj b/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj index 703a8a7c77..6d45708c17 100644 --- a/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj +++ b/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj @@ -28,9 +28,9 @@ + - diff --git a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj index d569aacb2c..78b2030580 100644 --- a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj +++ b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj @@ -29,9 +29,9 @@ + - diff --git a/EXILED/Exiled.Events/Commands/Config/Merge.cs b/EXILED/Exiled.Events/Commands/Config/Merge.cs index b9916ede64..d1463b49b7 100644 --- a/EXILED/Exiled.Events/Commands/Config/Merge.cs +++ b/EXILED/Exiled.Events/Commands/Config/Merge.cs @@ -49,8 +49,8 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s SortedDictionary configs = ConfigManager.LoadSorted(ConfigManager.Read()); LoaderPlugin.Config.ConfigType = ConfigType.Default; bool haveBeenSaved = ConfigManager.Save(configs); - PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); + // LabApi.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); response = $"Configs have been merged successfully! Feel free to remove the directory in the following path:\n\"{Paths.IndividualConfigs}\""; return haveBeenSaved; } diff --git a/EXILED/Exiled.Events/Commands/Config/Split.cs b/EXILED/Exiled.Events/Commands/Config/Split.cs index 9fad9c3e16..fee85f0616 100644 --- a/EXILED/Exiled.Events/Commands/Config/Split.cs +++ b/EXILED/Exiled.Events/Commands/Config/Split.cs @@ -49,8 +49,8 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s SortedDictionary configs = ConfigManager.LoadSorted(ConfigManager.Read()); LoaderPlugin.Config.ConfigType = ConfigType.Separated; bool haveBeenSaved = ConfigManager.Save(configs); - PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); + // PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); response = $"Configs have been merged successfully! Feel free to remove the file in the following path:\n\"{Paths.Config}\""; return haveBeenSaved; } diff --git a/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs index 48b7164d83..20ce6f84d0 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs @@ -31,7 +31,7 @@ public class DeactivatingWorkstationEventArgs : IPlayerEvent, IDeniableEvent /// public DeactivatingWorkstationEventArgs(WorkstationController controller, bool isAllowed = true) { - Player = Player.Get(controller._knownUser); + Player = Player.Get(controller.KnownUser); WorkstationController = controller; IsAllowed = isAllowed; } diff --git a/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs index f2af6a8300..3c127ca02e 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs @@ -13,7 +13,6 @@ namespace Exiled.Events.EventArgs.Player using LiteNetLib; using LiteNetLib.Utils; - using PluginAPI.Events; #pragma warning disable SA1600 //TODO: #pragma warning disable SA1309 diff --git a/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs index a3fa2d5310..1ea8a6df71 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs @@ -11,7 +11,7 @@ namespace Exiled.Events.EventArgs.Player using Exiled.API.Features; using Exiled.API.Features.Pickups; using Exiled.Events.EventArgs.Interfaces; - using PluginAPI.Enums; + using LabApi.Features.Enums; using RemoteAdmin; /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs index 0fb7778a16..1c96ff88f9 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs @@ -11,7 +11,7 @@ namespace Exiled.Events.EventArgs.Player using Exiled.API.Features; using Exiled.API.Features.Pickups; using Exiled.Events.EventArgs.Interfaces; - using PluginAPI.Enums; + using LabApi.Features.Enums; using RemoteAdmin; /// diff --git a/EXILED/Exiled.Events/Events.cs b/EXILED/Exiled.Events/Events.cs index 1572f76942..d61f55163f 100644 --- a/EXILED/Exiled.Events/Events.cs +++ b/EXILED/Exiled.Events/Events.cs @@ -20,7 +20,7 @@ namespace Exiled.Events using InventorySystem.Items.Usables; using PlayerRoles.Ragdolls; using PlayerRoles.RoleAssign; - using PluginAPI.Events; + using Respawning; using UnityEngine.SceneManagement; using UserSettings.ServerSpecific; @@ -85,8 +85,6 @@ public override void OnEnabled() ServerConsole.ReloadServerName(); ServerSpecificSettingsSync.ServerOnSettingValueReceived += SettingBase.OnSettingUpdated; - - EventManager.RegisterEvents(this); } /// @@ -120,8 +118,6 @@ public override void OnDisabled() ItemPickupBase.OnPickupDestroyed -= Handlers.Internal.PickupEvent.OnRemovedPickup; ServerSpecificSettingsSync.ServerOnSettingValueReceived -= SettingBase.OnSettingUpdated; - - EventManager.UnregisterEvents(this); } /// diff --git a/EXILED/Exiled.Events/Exiled.Events.csproj b/EXILED/Exiled.Events/Exiled.Events.csproj index aa7f9ff4bf..620625057d 100644 --- a/EXILED/Exiled.Events/Exiled.Events.csproj +++ b/EXILED/Exiled.Events/Exiled.Events.csproj @@ -26,10 +26,10 @@ + - diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs index 0e2770f7e2..44c585fad2 100644 --- a/EXILED/Exiled.Events/Handlers/Player.cs +++ b/EXILED/Exiled.Events/Handlers/Player.cs @@ -17,10 +17,6 @@ namespace Exiled.Events.Handlers using Exiled.Events.Features; - using PluginAPI.Core.Attributes; - using PluginAPI.Enums; - using PluginAPI.Events; - /// /// Player related events. /// diff --git a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs index 1bdacfd8f2..d70de49fb1 100644 --- a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs +++ b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs @@ -22,7 +22,7 @@ namespace Exiled.Events.Patches.Events.Cassie using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Cassie), nameof(Cassie.SendingCassieMessage))] diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs index c078ac2dcb..100271a913 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs @@ -117,42 +117,4 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } - - /// - /// Patches for . - /// Replaces last returned to . - /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Escaping))] - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Escaped))] - [HarmonyPatch(typeof(Escape), nameof(Escape.ServerGetScenario))] - internal static class GetScenario - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - LocalBuilder fpcRole = generator.DeclareLocal(typeof(FpcStandardRoleBase)); - - // replace HumanRole to FpcStandardRoleBase - newInstructions.Find(x => x.opcode == OpCodes.Isinst).operand = typeof(FpcStandardRoleBase); - - // after this index all invalid exit are considered Custom - int customExit = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Ldarg_0); - for (int i = 0; i < newInstructions.Count; i++) - { - OpCode opcode = newInstructions[i].opcode; - if (opcode == OpCodes.Stloc_0) - newInstructions[i] = new CodeInstruction(OpCodes.Stloc_S, fpcRole.LocalIndex).WithLabels(newInstructions[i].labels); - else if (opcode == OpCodes.Ldloc_0) - newInstructions[i] = new CodeInstruction(OpCodes.Ldloc_S, fpcRole.LocalIndex).WithLabels(newInstructions[i].labels); - else if (opcode == OpCodes.Ldc_I4_0 && i > customExit) - newInstructions[i].opcode = OpCodes.Ldc_I4_5; - } - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Player/InteractingGenerator.cs b/EXILED/Exiled.Events/Patches/Events/Player/InteractingGenerator.cs index b82994b2dd..4eeb8de400 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/InteractingGenerator.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/InteractingGenerator.cs @@ -22,8 +22,6 @@ namespace Exiled.Events.Patches.Events.Player using MapGeneration.Distributors; - using PluginAPI.Events; - using static HarmonyLib.AccessTools; /// @@ -68,7 +66,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(PlayerCloseGeneratorEvent))[0]) + offset; + index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerClosingGeneratorEventArgs))[0]) + offset; // if (this.HasFlag(_flags, GeneratorFlags.Open)) // { @@ -169,9 +167,9 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(PlayerUnlockGeneratorEvent))[0]) + offset; - + // TODO: + // offset = -2; + // int index2 = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(null))[0]) + offset; newInstructions.InsertRange( index, new[] @@ -179,7 +177,8 @@ private static IEnumerable Transpiler(IEnumerable @@ -42,7 +40,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(PlayerRemoveHandcuffsEvent))[0]) + offset; + instruction => instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerCuffingEventArgs))[0]) + offset; newInstructions.InsertRange( index, @@ -98,7 +96,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(PlayerHandcuffEvent))[0]) + offset; + instruction => instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerCuffingEventArgs))[0]) + offset; newInstructions.InsertRange( index, diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs b/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs index 29544e21ce..23bc710daf 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs @@ -17,12 +17,11 @@ namespace Exiled.Events.Patches.Events.Player using Handlers; using HarmonyLib; - using PluginAPI.Events; using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Player), nameof(Player.ReservedSlot))] @@ -106,7 +105,7 @@ private static IEnumerable Transpiler(IEnumerable @@ -38,7 +36,7 @@ private static IEnumerable Transpiler(IEnumerable match = instruction => instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(PlayerRadioToggleEvent))[0]; + Predicate match = instruction => instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerTogglingRadioEventArgs))[0]; int offset = -4; int index = newInstructions.FindIndex(match) + offset; diff --git a/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs b/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs index 3fa2bd67fd..94d0ace9a7 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs @@ -20,8 +20,6 @@ namespace Exiled.Events.Patches.Events.Player using InventorySystem.Items.Usables; - using PluginAPI.Events; - using static HarmonyLib.AccessTools; /// @@ -84,7 +82,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(PlayerCancelUsingItemEvent))[0]) + offset; + index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerCancellingUsingItemEventArgs))[0]) + offset; newInstructions.InsertRange( index, diff --git a/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs b/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs index 19b170c1bf..10f07126f8 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs @@ -21,7 +21,6 @@ namespace Exiled.Events.Patches.Events.Scp079 using PlayerRoles.PlayableScps.Scp079; using PlayerRoles.PlayableScps.Scp079.Cameras; using PlayerRoles.Subroutines; - using PluginAPI.Events; using static HarmonyLib.AccessTools; diff --git a/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs b/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs index c690f20e2b..095c374d83 100755 --- a/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs @@ -18,7 +18,6 @@ namespace Exiled.Events.Patches.Events.Scp173 using HarmonyLib; using PlayerRoles.PlayableScps.Scp173; using PlayerRoles.Subroutines; - using PluginAPI.Events; using static HarmonyLib.AccessTools; @@ -37,11 +36,9 @@ private static IEnumerable Transpiler(IEnumerable m.Name == nameof(EventManager.ExecuteEvent) - && !m.IsGenericMethod); - int index = newInstructions.FindLastIndex(i => i.Calls(scp173ExecuteEvent)) + offset; + + // MethodInfo scp173ExecuteEvent = typeof(EventManager).GetMethods(BindingFlags.Public | BindingFlags.Static).FirstOrDefault(m => m.Name == nameof(EventManager.ExecuteEvent)&& !m.IsGenericMethod); + int index = 0 + offset; // newInstructions.FindLastIndex(i => i.Calls(scp173ExecuteEvent)) + offset; newInstructions.InsertRange( index, diff --git a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index 6971695c96..15ed8f01b1 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -22,7 +22,6 @@ namespace Exiled.Events.Patches.Events.Scp330 using Interactables.Interobjects; using InventorySystem; using InventorySystem.Items.Usables.Scp330; - using PluginAPI.Events; using static HarmonyLib.AccessTools; @@ -106,7 +105,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(PropertyGetter(typeof(PlayerInteractScp330Event), nameof(PlayerInteractScp330Event.PlaySound)))) + offset; + instruction => instruction.Calls(PropertyGetter(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerInteractingScp330EventArgs), nameof(LabApi.Events.Arguments.PlayerEvents.PlayerInteractingScp330EventArgs.PlaySound)))) + offset; newInstructions.InsertRange( index, new[] @@ -132,7 +131,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(PropertyGetter(typeof(PlayerInteractScp330Event), nameof(PlayerInteractScp330Event.AllowPunishment)))) + offset; + instruction => instruction.Calls(PropertyGetter(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerInteractingScp330EventArgs), nameof(LabApi.Events.Arguments.PlayerEvents.PlayerInteractingScp330EventArgs.AllowPunishment)))) + offset; // remove `uses >= 2` check, to override that by ev.ShouldSever newInstructions.RemoveRange(index, 3); diff --git a/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs b/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs index 0eeafc3c0e..4d19d4954d 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs @@ -23,7 +23,7 @@ internal class NWFixDetonationTimer private static void Postfix() { AlphaWarheadSyncInfo networkInfo = default; - networkInfo.ScenarioId = (byte)Array.IndexOf(AlphaWarheadController.Singleton._startScenarios, AlphaWarheadController.Singleton._startScenarios.OrderBy(d => Math.Abs(d.TimeToDetonate - ConfigFile.ServerConfig.GetByte("warhead_tminus_start_duration", 90))).First()); + networkInfo.ScenarioId = (byte)Array.IndexOf(AlphaWarheadController.Singleton.StartScenarios, AlphaWarheadController.Singleton.StartScenarios.OrderBy(d => Math.Abs(d.TimeToDetonate - ConfigFile.ServerConfig.GetByte("warhead_tminus_start_duration", 90))).First()); AlphaWarheadController.Singleton.NetworkInfo = networkInfo; return; diff --git a/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs b/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs index 1fc013cde3..c47a550d01 100644 --- a/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs +++ b/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs @@ -14,8 +14,6 @@ namespace Exiled.Events.Patches.Generic using API.Features.Pools; using CentralAuth; using HarmonyLib; - using PluginAPI.Core.Interfaces; - using PluginAPI.Events; using static HarmonyLib.AccessTools; @@ -48,8 +46,9 @@ private static IEnumerable Transpiler(IEnumerable $"{userId}@offline"; } + /* /// - /// Patches to add the player's UserId to the dictionary. + /// Patches to add the player's UserId to the dictionary. /// [HarmonyPatch(typeof(PlayerAuthenticationManager), nameof(PlayerAuthenticationManager.Start))] internal static class OfflineModePlayerIds @@ -70,7 +69,7 @@ private static IEnumerable Transpiler(IEnumerable), nameof(Dictionary.ContainsKey))), @@ -160,5 +159,5 @@ private static void ExecuteNwEvent(ReferenceHub hub) { EventManager.ExecuteEvent(new PlayerJoinedEvent(hub)); } - } + }*/ } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Generic/ServerNamePatch.cs b/EXILED/Exiled.Events/Patches/Generic/ServerNamePatch.cs index 39726b846e..35c160b845 100644 --- a/EXILED/Exiled.Events/Patches/Generic/ServerNamePatch.cs +++ b/EXILED/Exiled.Events/Patches/Generic/ServerNamePatch.cs @@ -22,7 +22,7 @@ private static void Postfix() if (!Instance.Config.IsNameTrackingEnabled) return; - ServerConsole._serverName += $"Exiled {Instance.Version.ToString(3)}"; + ServerConsole.ServerName += $"Exiled {Instance.Version.ToString(3)}"; } } } \ No newline at end of file diff --git a/EXILED/Exiled.Example/Exiled.Example.csproj b/EXILED/Exiled.Example/Exiled.Example.csproj index 9ad073fe0f..ce8f908c20 100644 --- a/EXILED/Exiled.Example/Exiled.Example.csproj +++ b/EXILED/Exiled.Example/Exiled.Example.csproj @@ -25,9 +25,9 @@ + - diff --git a/EXILED/Exiled.Loader/AutoUpdateFiles.cs b/EXILED/Exiled.Loader/AutoUpdateFiles.cs index c04a1d00e3..4f12ca7484 100644 --- a/EXILED/Exiled.Loader/AutoUpdateFiles.cs +++ b/EXILED/Exiled.Loader/AutoUpdateFiles.cs @@ -18,5 +18,10 @@ public static class AutoUpdateFiles /// Gets which SCP: SL version generated Exiled. /// public static readonly Version RequiredSCPSLVersion = new(14, 0, 0, 2); + + /// + /// Gets which Lab API version generated Exiled. + /// + public static readonly Version RequiredLabAPIVersion = new(0, 0, 0, 0); } } \ No newline at end of file diff --git a/EXILED/Exiled.Loader/AutoUpdateFiles.tt b/EXILED/Exiled.Loader/AutoUpdateFiles.tt index 07176b7f8f..8f9d44e5ce 100644 --- a/EXILED/Exiled.Loader/AutoUpdateFiles.tt +++ b/EXILED/Exiled.Loader/AutoUpdateFiles.tt @@ -18,5 +18,10 @@ namespace Exiled.Loader /// Gets which SCP: SL version generated Exiled. /// public static readonly Version RequiredSCPSLVersion = new(<#=GameCore.Version.Major#>, <#=GameCore.Version.Minor#>, 0, <#=GameCore.Version.Revision#>); + + /// + /// Gets which Lab API version generated Exiled. + /// + public static readonly Version RequiredSCPSLVersion = new(<#=GameCore.Version.Major#>, <#=GameCore.Version.Minor#>, 0, <#=GameCore.Version.Revision#>); } } \ No newline at end of file diff --git a/EXILED/Exiled.Loader/ConfigManager.cs b/EXILED/Exiled.Loader/ConfigManager.cs index 3a59afedf0..e925517be9 100644 --- a/EXILED/Exiled.Loader/ConfigManager.cs +++ b/EXILED/Exiled.Loader/ConfigManager.cs @@ -273,7 +273,7 @@ public static void ReloadRemoteAdmin() ServerStatic.SharedGroupsConfig = GameCore.ConfigSharing.Paths[4] is null ? null : new YamlConfig(GameCore.ConfigSharing.Paths[4] + "shared_groups.txt"); ServerStatic.SharedGroupsMembersConfig = GameCore.ConfigSharing.Paths[5] is null ? null : new YamlConfig(GameCore.ConfigSharing.Paths[5] + "shared_groups_members.txt"); ServerStatic.PermissionsHandler = new PermissionsHandler(ref ServerStatic.RolesConfig, ref ServerStatic.SharedGroupsConfig, ref ServerStatic.SharedGroupsMembersConfig); - ServerStatic.GetPermissionsHandler().RefreshPermissions(); + ServerStatic.PermissionsHandler.RefreshPermissions(); foreach (Player player in Player.List) { diff --git a/EXILED/Exiled.Loader/Exiled.Loader.csproj b/EXILED/Exiled.Loader/Exiled.Loader.csproj index fc19e5aea6..55b587ef44 100644 --- a/EXILED/Exiled.Loader/Exiled.Loader.csproj +++ b/EXILED/Exiled.Loader/Exiled.Loader.csproj @@ -25,8 +25,8 @@ + - diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 2c3ce68de9..7c2194d09f 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -46,7 +46,7 @@ public Loader() Log.Warn("You are running a public beta build. It is not compatible with another version of the game."); #endif - Log.SendRaw($"Exiled.API - Version {PluginAPI.Loader.AssemblyLoader.Dependencies.FirstOrDefault(x => x.GetName().Name == "Exiled.API").GetCustomAttribute().InformationalVersion}", ConsoleColor.DarkRed); + Log.SendRaw($"Exiled.API - Version {LabApi.Loader.PluginLoader.Dependencies.FirstOrDefault(x => x.GetName().Name == "Exiled.API").GetCustomAttribute().InformationalVersion}", ConsoleColor.DarkRed); Log.SendRaw($"{Assembly.GetExecutingAssembly().GetName().Name} - Version {Assembly.GetExecutingAssembly().GetCustomAttribute().InformationalVersion}", ConsoleColor.DarkRed); if (MultiAdminFeatures.MultiAdminUsed) diff --git a/EXILED/Exiled.Loader/LoaderPlugin.cs b/EXILED/Exiled.Loader/LoaderPlugin.cs index 349da02566..e11777db8a 100644 --- a/EXILED/Exiled.Loader/LoaderPlugin.cs +++ b/EXILED/Exiled.Loader/LoaderPlugin.cs @@ -11,32 +11,55 @@ namespace Exiled.Loader using System.IO; using System.Reflection; - using MEC; + using LabApi.Loader.Features.Plugins; - using PluginAPI.Core.Attributes; + using MEC; using Log = API.Features.Log; using Paths = API.Features.Paths; /// - /// The Northwood PluginAPI Plugin class for the EXILED Loader. + /// The Northwood LabAPI Plugin class for the EXILED Loader. /// - public class LoaderPlugin + public class LoaderPlugin : Plugin { #pragma warning disable SA1401 /// /// The config for the EXILED Loader. /// - [PluginConfig] - public static Config Config; + public static new Config Config; #pragma warning restore SA1401 /// - /// Called by PluginAPI when the plugin is enabled. + /// Gets the Name of the EXILED Loader. + /// + public override string Name => "Exiled Loader"; + + /// + /// Gets the Description of the EXILED Loader. + /// + public override string Description => "Loads the EXILED Plugin Framework."; + + /// + /// Gets the Author of the EXILED Loader. + /// + public override string Author => "ExMod-Team"; + + /// + /// Gets the RequiredApiVersion of the EXILED Loader. /// - [PluginEntryPoint("Exiled Loader", null, "Loads the EXILED Plugin Framework.", "ExMod-Team")] - [PluginPriority(byte.MinValue)] - public void Enable() + public override Version RequiredApiVersion => AutoUpdateFiles.RequiredLabAPIVersion; + + /// + /// Gets the Exiled Version. + /// + public override Version Version { get; } = new Version(0, 0, 0); +#pragma warning restore SA1401 + + /// + /// Called by LabAPI when the plugin is enabled. + /// + public override void Enable() { if (Config == null) { @@ -63,5 +86,13 @@ public void Enable() Timing.RunCoroutine(new Loader().Run()); } + + /// + /// Called by LabAPI when the plugin is Disable. + /// + public override void Disable() + { + // Plugin will not be disable + } } } \ No newline at end of file diff --git a/EXILED/Exiled.Loader/Updater.cs b/EXILED/Exiled.Loader/Updater.cs index 448adfd6c2..2aef897a61 100644 --- a/EXILED/Exiled.Loader/Updater.cs +++ b/EXILED/Exiled.Loader/Updater.cs @@ -69,7 +69,7 @@ where name.StartsWith("Exiled.", StringComparison.OrdinalIgnoreCase) && name != Assembly.GetExecutingAssembly().GetName().Name select new ExiledLib(a); - private string Folder => File.Exists($"{PluginAPI.Helpers.Paths.GlobalPlugins.Plugins}/Exiled.Loader.dll") ? "global" : Server.Port.ToString(); + private string Folder => File.Exists($"{LabApi.Loader.Features.Paths.PathManager.Plugins}/Exiled.Loader.dll") ? "global" : Server.Port.ToString(); private string InstallerName { @@ -116,7 +116,7 @@ internal void CheckUpdate() try { using HttpClient client = CreateHttpClient(); - if (Busy = FindUpdate(client, !PluginAPI.Loader.AssemblyLoader.Dependencies.Exists(x => x.GetName().Name == "Exiled.API"), out NewVersion newVersion)) + if (Busy = FindUpdate(client, !LabApi.Loader.PluginLoader.Dependencies.Any(x => x.GetName().Name == "Exiled.API"), out NewVersion newVersion)) Update(client, newVersion); } catch (Exception e) diff --git a/EXILED/Exiled.Permissions/Exiled.Permissions.csproj b/EXILED/Exiled.Permissions/Exiled.Permissions.csproj index 3c130764f8..7057fc5d5d 100644 --- a/EXILED/Exiled.Permissions/Exiled.Permissions.csproj +++ b/EXILED/Exiled.Permissions/Exiled.Permissions.csproj @@ -23,10 +23,10 @@ + - diff --git a/EXILED/Exiled.Permissions/Extensions/Permissions.cs b/EXILED/Exiled.Permissions/Extensions/Permissions.cs index b03271b4be..56823e3feb 100644 --- a/EXILED/Exiled.Permissions/Extensions/Permissions.cs +++ b/EXILED/Exiled.Permissions/Extensions/Permissions.cs @@ -105,7 +105,7 @@ public static void Reload() { try { - if (string.Equals(group.Key, "user", StringComparison.OrdinalIgnoreCase) || ServerStatic.PermissionsHandler._groups.ContainsKey(group.Key)) + if (string.Equals(group.Key, "user", StringComparison.OrdinalIgnoreCase) || ServerStatic.PermissionsHandler.Groups.ContainsKey(group.Key)) { deserializedPerms.Add(group.Key, Deserializer.Deserialize(Serializer.Serialize(group.Value))); } @@ -207,7 +207,7 @@ public static bool CheckPermission(this Player player, string permission) Log.Debug($"UserID: {player.UserId} | PlayerId: {player.Id}"); Log.Debug($"Permission string: {permission}"); - string plyGroupKey = player.Group is not null ? ServerStatic.GetPermissionsHandler()._groups.FirstOrDefault(g => g.Value.EqualsTo(player.Group)).Key : null; + string plyGroupKey = player.Group is not null ? ServerStatic.PermissionsHandler.Groups.FirstOrDefault(g => g.Value.EqualsTo(player.Group)).Key : null; Log.Debug($"GroupKey: {plyGroupKey ?? "(null)"}"); if (plyGroupKey is null || !Groups.TryGetValue(plyGroupKey, out Group group)) diff --git a/EXILED/docs/docs.csproj b/EXILED/docs/docs.csproj index d8e9026b98..f315b6977d 100644 --- a/EXILED/docs/docs.csproj +++ b/EXILED/docs/docs.csproj @@ -35,7 +35,7 @@ - + From cf4c725f27a7095c47506d3106e85b73b3cb7989 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 21 Jan 2025 23:36:10 +0100 Subject: [PATCH 02/42] Fix Exiled --- EXILED/Exiled.API/Features/Paths.cs | 5 +++-- .../Patches/Events/Player/TogglingNoClip.cs | 2 +- .../Exiled.Events/Patches/Events/Server/RoundEnd.cs | 12 ++++++++---- .../Patches/Fixes/Scp3114FriendlyFireFix.cs | 2 +- EXILED/Exiled.Loader/LoaderPlugin.cs | 2 ++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/EXILED/Exiled.API/Features/Paths.cs b/EXILED/Exiled.API/Features/Paths.cs index b80b88dbd4..8d99b1a996 100644 --- a/EXILED/Exiled.API/Features/Paths.cs +++ b/EXILED/Exiled.API/Features/Paths.cs @@ -11,6 +11,8 @@ namespace Exiled.API.Features using System.IO; using System.Linq; + using LabApi.Loader; + /// /// A set of useful paths. /// @@ -106,8 +108,7 @@ public static void Reload(string rootDirectory = null) Dependencies = Path.Combine(Plugins, "dependencies"); Configs = Path.Combine(Exiled, "Configs"); IndividualConfigs = Path.Combine(Configs, "Plugins"); - - // LoaderConfig = LabApi.Loader.PluginLoader.EnabledPlugins.FirstOrDefault(x => x.Name == "Exiled Loader")?; // TODO + LoaderConfig = LabApi.Loader.PluginLoader.EnabledPlugins.FirstOrDefault(x => x.Name == "Exiled Loader")?.GetConfigPath("Exiled Loader"); Config = Path.Combine(Configs, $"{Server.Port}-config.yml"); BackupConfig = Path.Combine(Configs, $"{Server.Port}-config.yml.old"); IndividualTranslations = Path.Combine(Configs, "Translations"); diff --git a/EXILED/Exiled.Events/Patches/Events/Player/TogglingNoClip.cs b/EXILED/Exiled.Events/Patches/Events/Player/TogglingNoClip.cs index c5a6a3a9fe..190e45bf80 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/TogglingNoClip.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/TogglingNoClip.cs @@ -44,7 +44,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - const string LeadingTeam = "5__9"; + const string LeadingTeam = "5__4"; const string NewList = "5__3"; int offset = -1; @@ -66,7 +66,7 @@ private static IEnumerable Transpiler(IEnumerable), nameof(HashSet.Contains))), new(OpCodes.Brtrue_S, jmp), }); @@ -112,7 +112,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable - [HarmonyPatch(typeof(Scp2176Projectile), nameof(Scp2176Projectile.ServerShatter))] + // [HarmonyPatch(typeof(Scp2176Projectile), nameof(Scp2176Projectile.ServerShatter))] internal class Scp3114FriendlyFireFix { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/EXILED/Exiled.Loader/LoaderPlugin.cs b/EXILED/Exiled.Loader/LoaderPlugin.cs index e11777db8a..e41e2ac914 100644 --- a/EXILED/Exiled.Loader/LoaderPlugin.cs +++ b/EXILED/Exiled.Loader/LoaderPlugin.cs @@ -61,6 +61,8 @@ public class LoaderPlugin : Plugin /// public override void Enable() { + Config = base.Config; + if (Config == null) { Log.Error("Detected null config, EXILED will not be loaded."); From 187b2298c30051fd36cd0b7e71040dd5a4c11f52 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 01:52:10 +0100 Subject: [PATCH 03/42] Fix RoundEnding --- .../EventArgs/Server/EndingRoundEventArgs.cs | 12 +++++----- .../Patches/Events/Server/RoundEnd.cs | 24 ++++--------------- EXILED/Exiled.Loader/LoaderPlugin.cs | 7 +++++- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs index 216676772b..7ed1dcbb58 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs @@ -24,17 +24,13 @@ public class EndingRoundEventArgs : IDeniableEvent /// /// /// - /// - /// - /// /// /// /// - public EndingRoundEventArgs(LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassList classList, bool isForceEnded, bool isAllowed) + public EndingRoundEventArgs(LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassList classList, bool isAllowed) { LeadingTeam = leadingTeam; ClassList = classList; - IsForceEnded = isForceEnded; IsAllowed = isAllowed; } @@ -51,7 +47,11 @@ public EndingRoundEventArgs(LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassL /// /// Gets or sets a value indicating whether the round is ended by API call. /// - public bool IsForceEnded { get; set; } + public bool IsForceEnded + { + get => RoundSummary.singleton._roundEnded; + set => RoundSummary.singleton._roundEnded = value; + } /// /// Gets or sets a value indicating whether the round is going to finish or not. diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs index d61e6ca4bd..efcc7a5c82 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -87,12 +87,12 @@ private static IEnumerable Transpiler(IEnumerable x.LoadsField(Field(typeof(RoundSummary), nameof(RoundSummary._roundEnded)))) + offset; + index = newInstructions.FindLastIndex(x => x.operand is LocalBuilder { LocalIndex: 10 }) + offset; newInstructions.InsertRange(index, leadingTeamLogic); // recorect the index because of the LeadingTeamLogic that got moved offset = -1; - index = newInstructions.FindIndex(x => x.LoadsField(Field(typeof(RoundSummary), nameof(RoundSummary._roundEnded)))) + offset; + index = newInstructions.FindLastIndex(x => x.operand is LocalBuilder { LocalIndex: 10 }) + offset; LocalBuilder evEndingRound = generator.DeclareLocal(typeof(EndingRoundEventArgs)); newInstructions.InsertRange( @@ -107,17 +107,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable /// Gets the Exiled Version. /// public override Version Version { get; } = new Version(0, 0, 0); -#pragma warning restore SA1401 + + /// + /// Gets the Exiled Priority load. + /// + public override LoadPriority Priority { get; } = (LoadPriority)byte.MaxValue; /// /// Called by LabAPI when the plugin is enabled. From e20b517018eac928db1276acce2f8f5f3fc07b00 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 02:07:55 +0100 Subject: [PATCH 04/42] Now is fucking separated by default --- EXILED/Exiled.Loader/Config.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Loader/Config.cs b/EXILED/Exiled.Loader/Config.cs index a6941cc54b..6e07979ef2 100644 --- a/EXILED/Exiled.Loader/Config.cs +++ b/EXILED/Exiled.Loader/Config.cs @@ -57,7 +57,7 @@ public sealed class Config : IConfig /// Gets or sets the config files distribution type. /// [Description("The config files distribution type (Default, Separated)")] - public ConfigType ConfigType { get; set; } = ConfigType.Default; + public ConfigType ConfigType { get; set; } = ConfigType.Separated; /// /// Gets or sets the quotes wrapper type. From 1554ee4e159b29440a687943e0958fc1f637f8a9 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 09:56:30 +0100 Subject: [PATCH 05/42] CustomSubtitles --- .../EventArgs/Cassie/SendingCassieMessageEventArgs.cs | 10 +++++++++- .../Patches/Events/Cassie/SendingCassieMessage.cs | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs index e39a463c23..dd92ca4eb3 100644 --- a/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs @@ -26,8 +26,11 @@ public class SendingCassieMessageEventArgs : IDeniableEvent /// /// /// + /// + /// + /// /// Indicates whether the event can be executed. - public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise, bool isAllowed = true) + public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise, string customSubtitles, bool isAllowed = true) { Words = words; MakeHold = makeHold; @@ -40,6 +43,11 @@ public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise /// public string Words { get; set; } + /// + /// Gets or sets the message. + /// + public string CustomSubtitles { get; set; } + /// /// Gets or sets a value indicating whether the message should be held. /// diff --git a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs index d70de49fb1..8666f0e0f5 100644 --- a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs +++ b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs @@ -35,13 +35,13 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 22 Jan 2025 10:02:43 +0100 Subject: [PATCH 06/42] Missing IsCustomAnnouncement --- .../Cassie/SendingCassieMessageEventArgs.cs | 14 ++++++++++++-- .../Patches/Events/Cassie/SendingCassieMessage.cs | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs index dd92ca4eb3..a8b986c171 100644 --- a/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs @@ -26,15 +26,20 @@ public class SendingCassieMessageEventArgs : IDeniableEvent /// /// /// + /// + /// + /// /// /// /// /// Indicates whether the event can be executed. - public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise, string customSubtitles, bool isAllowed = true) + public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise, bool customAnnouncement, string customSubtitles, bool isAllowed = true) { Words = words; + CustomSubtitles = customSubtitles; MakeHold = makeHold; MakeNoise = makeNoise; + IsCustomAnnouncement = customAnnouncement; IsAllowed = isAllowed; } @@ -44,7 +49,7 @@ public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise public string Words { get; set; } /// - /// Gets or sets the message. + /// Gets or sets the message subtitles. /// public string CustomSubtitles { get; set; } @@ -62,5 +67,10 @@ public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise /// Gets or sets a value indicating whether the message can be sent. /// public bool IsAllowed { get; set; } + + /// + /// Gets or sets a value indicating whether the message can be sent. + /// + public bool IsCustomAnnouncement { get; set; } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs index 8666f0e0f5..2c138e305e 100644 --- a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs +++ b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs @@ -52,6 +52,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 22 Jan 2025 10:32:18 +0100 Subject: [PATCH 07/42] Fix 3 patch & removal of CustomHealthStat --- .../Exiled.API/Features/CustomHealthStat.cs | 26 -------------- .../CustomStats/CustomHumeShieldStat.cs | 8 ----- EXILED/Exiled.API/Features/Player.cs | 8 ++--- .../Player/UsingRadioBatteryEventArgs.cs | 7 ++-- .../Events/Player/UsingRadioBattery.cs | 36 ++++++------------- .../Patches/Events/Server/Reporting.cs | 10 +++--- 6 files changed, 21 insertions(+), 74 deletions(-) delete mode 100644 EXILED/Exiled.API/Features/CustomHealthStat.cs diff --git a/EXILED/Exiled.API/Features/CustomHealthStat.cs b/EXILED/Exiled.API/Features/CustomHealthStat.cs deleted file mode 100644 index 57f6d31c20..0000000000 --- a/EXILED/Exiled.API/Features/CustomHealthStat.cs +++ /dev/null @@ -1,26 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.API.Features -{ - using PlayerStatsSystem; - - /// - /// A custom version of which allows the player's max amount of health to be changed. - /// TODO: Move to Features.CustomStats. - /// - public class CustomHealthStat : HealthStat - { - /// - public override float MaxValue => CustomMaxValue == default ? base.MaxValue : CustomMaxValue; - - /// - /// Gets or sets the maximum amount of health the player will have. - /// - public float CustomMaxValue { get; set; } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs b/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs index fbc65ad88d..b6eca23585 100644 --- a/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs +++ b/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs @@ -18,19 +18,11 @@ namespace Exiled.API.Features.CustomStats /// public class CustomHumeShieldStat : HumeShieldStat { - /// - public override float MaxValue => CustomMaxValue == -1 ? base.MaxValue : CustomMaxValue; - /// /// Gets or sets the multiplier for gaining HumeShield. /// public float ShieldRegenerationMultiplier { get; set; } = 1; - /// - /// Gets or sets the maximum amount of HumeShield the player can have. - /// - public float CustomMaxValue { get; set; } = -1; - private float ShieldRegeneration => TryGetHsModule(out HumeShieldModuleBase controller) ? controller.HsRegeneration * ShieldRegenerationMultiplier : 0; /// diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 454cb88d18..df2ab96604 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -95,7 +95,7 @@ public class Player : TypeCastObject, IEntity, IWorldSpace private readonly HashSet componentsInChildren = new(); private ReferenceHub referenceHub; - private CustomHealthStat healthStat; + private HealthStat healthStat; private CustomHumeShieldStat humeShieldStat; private Role role; @@ -177,7 +177,7 @@ private set Inventory = value.inventory; CameraTransform = value.PlayerCameraReference; - value.playerStats._dictionarizedTypes[typeof(HealthStat)] = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HealthStat))] = healthStat = new CustomHealthStat { Hub = value }; + healthStat = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HealthStat))] as HealthStat; value.playerStats._dictionarizedTypes[typeof(HumeShieldStat)] = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HumeShieldStat))] = humeShieldStat = new CustomHumeShieldStat { Hub = value }; } } @@ -882,7 +882,7 @@ public float Health public float MaxHealth { get => healthStat.MaxValue; - set => healthStat.CustomMaxValue = value; + set => healthStat.MaxValue = value; } /// @@ -938,7 +938,7 @@ public float HumeShield public float MaxHumeShield { get => humeShieldStat.MaxValue; - set => humeShieldStat.CustomMaxValue = value; + set => humeShieldStat.MaxValue = value; } /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs index ae1995da47..3b3af1c73f 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs @@ -25,19 +25,16 @@ public class UsingRadioBatteryEventArgs : IPlayerEvent, IDeniableEvent, IItemEve /// /// /// - /// - /// - /// /// /// /// /// /// /// - public UsingRadioBatteryEventArgs(RadioItem radio, Player player, float drain, bool isAllowed = true) + public UsingRadioBatteryEventArgs(RadioItem radio, float drain, bool isAllowed = true) { Radio = Item.Get(radio); - Player = player; + Player = Radio.Owner; Drain = drain; IsAllowed = isAllowed; } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/UsingRadioBattery.cs b/EXILED/Exiled.Events/Patches/Events/Player/UsingRadioBattery.cs index cf9895ff9e..1baf62c851 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/UsingRadioBattery.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/UsingRadioBattery.cs @@ -33,62 +33,46 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - Label returnLabel = newInstructions[newInstructions.Count - 1].labels[0]; - Label continueLabel = generator.DefineLabel(); + Label returnLabel = generator.DefineLabel(); LocalBuilder ev = generator.DeclareLocal(typeof(UsingRadioBatteryEventArgs)); - LocalBuilder player = generator.DeclareLocal(typeof(Player)); const int offset = 1; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_0) + offset; - - newInstructions[index].WithLabels(continueLabel); + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_1) + offset; newInstructions.InsertRange( index, new CodeInstruction[] { - // if (Player.Get(base.Owner) is not Player player) - // continue; - new(OpCodes.Ldarg_0), - new(OpCodes.Call, PropertyGetter(typeof(RadioItem), nameof(RadioItem.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, player.LocalIndex), - new(OpCodes.Brfalse_S, continueLabel), - // this new(OpCodes.Ldarg_0), - // player - new(OpCodes.Ldloc_S, player.LocalIndex), - // num - new(OpCodes.Ldloc_0), + new(OpCodes.Ldloc_1), // true new(OpCodes.Ldc_I4_1), - // UsingRadioBatteryEventArgs ev = new(RadioItem, Player, float, bool); + // UsingRadioBatteryEventArgs ev = new(RadioItem, ReferenceHub, float, bool); new(OpCodes.Newobj, GetDeclaredConstructors(typeof(UsingRadioBatteryEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), - new(OpCodes.Stloc_S, ev.LocalIndex), // Handlers.Player.OnUsingRadioBattery(ev); new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnUsingRadioBattery))), + // num = ev.Drain; + new(OpCodes.Callvirt, PropertyGetter(typeof(UsingRadioBatteryEventArgs), nameof(UsingRadioBatteryEventArgs.Drain))), + new(OpCodes.Stloc_1), + // if (!ev.IsAllowed) // return; new(OpCodes.Callvirt, PropertyGetter(typeof(UsingRadioBatteryEventArgs), nameof(UsingRadioBatteryEventArgs.IsAllowed))), new(OpCodes.Brfalse_S, returnLabel), - - // num = ev.Drain; - new(OpCodes.Ldloc_S, ev.LocalIndex), - new(OpCodes.Callvirt, PropertyGetter(typeof(UsingRadioBatteryEventArgs), nameof(UsingRadioBatteryEventArgs.Drain))), - new(OpCodes.Stloc_0), }); + newInstructions[newInstructions.Count - 1].labels.Add(returnLabel); + for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; diff --git a/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs b/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs index 99ff8006da..d5150c2c81 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs @@ -48,10 +48,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.StoresField(Field(typeof(CheaterReport), nameof(CheaterReport._lastReport)))) + offset; + instruction => instruction.operand == (object)"[REPORTING] Invalid report signature.") + offset; newInstructions.InsertRange( index, From b9da17f8063735de94b2b63a94ffbf71bc61013e Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 12:00:44 +0100 Subject: [PATCH 08/42] Fix UsingAndCancellingItemUse --- .../Events/Player/UsingAndCancellingItemUse.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs b/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs index 94d0ace9a7..ead102f44a 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs @@ -13,12 +13,14 @@ namespace Exiled.Events.Patches.Events.Player using API.Features; using API.Features.Pools; + using CustomPlayerEffects; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Player; using HarmonyLib; using InventorySystem.Items.Usables; + using Utils.Networking; using static HarmonyLib.AccessTools; @@ -43,16 +45,16 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(UsableItemsController), nameof(UsableItemsController.GetCooldown)))) + offset; + instruction => instruction.Calls(Method(typeof(UsableItemModifierEffectExtensions), nameof(UsableItemModifierEffectExtensions.GetSpeedMultiplier)))) + offset; newInstructions.InsertRange( index, new CodeInstruction[] { // Player.Get(referenceHub) - new(OpCodes.Ldloc_0), + new CodeInstruction(OpCodes.Ldloc_0).MoveLabelsFrom(newInstructions[index]), new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // usableItem @@ -81,7 +83,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerCancellingUsingItemEventArgs))[0]) + offset; newInstructions.InsertRange( @@ -112,8 +114,9 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(NetworkUtils), nameof(NetworkUtils.SendToAuthenticated)))) + offset; newInstructions.InsertRange( index, From a4ba5f7bff86dfcab84ff420838a10db333bb5a7 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 12:13:03 +0100 Subject: [PATCH 09/42] Fix TogglingFlashlight --- .../Events/Player/TogglingFlashlight.cs | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs b/EXILED/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs index 0fdf7c8c22..91f8aa87ad 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs @@ -34,8 +34,8 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_2) + offset; newInstructions.InsertRange( index, @@ -47,32 +47,20 @@ private static IEnumerable Transpiler(IEnumerable i.LoadsField(Field(typeof(FlashlightNetworkHandler.FlashlightMessage), nameof(FlashlightNetworkHandler.FlashlightMessage.NewState)))) + offset; - newInstructions.RemoveRange(index, 2); - newInstructions.InsertRange(index, new CodeInstruction[] - { - new(OpCodes.Ldloc_S, ev.LocalIndex), - new(OpCodes.Callvirt, PropertyGetter(typeof(TogglingFlashlightEventArgs), nameof(TogglingFlashlightEventArgs.NewState))), + // flag = ev.NewState + new(OpCodes.Call, PropertyGetter(typeof(TogglingFlashlightEventArgs), nameof(TogglingFlashlightEventArgs.NewState))), + new(OpCodes.Stloc_2), }); - } for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; From e5d10214bcdcb98dd916dca5cb61343ab213635c Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 12:16:17 +0100 Subject: [PATCH 10/42] La Flemme ? --- .../Patches/Events/Player/SendingValidRACommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs b/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs index 5e051c8b49..c6fb9bb034 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs @@ -28,9 +28,9 @@ namespace Exiled.Events.Patches.Events.Player /// Adds the and /// the events. /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] - [HarmonyPatch(typeof(CommandProcessor), nameof(CommandProcessor.ProcessQuery))] + // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] + // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] + // [HarmonyPatch(typeof(CommandProcessor), nameof(CommandProcessor.ProcessQuery))] TODO internal static class SendingValidRACommand { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) From 8945d11c664955279f0a2942c1c29cc7c2836b87 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 12:23:19 +0100 Subject: [PATCH 11/42] La flemme 2 --- .../Patches/Events/Player/SendingValidGameConsoleCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/SendingValidGameConsoleCommand.cs b/EXILED/Exiled.Events/Patches/Events/Player/SendingValidGameConsoleCommand.cs index a8a4d7027c..4a307fc1ca 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/SendingValidGameConsoleCommand.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/SendingValidGameConsoleCommand.cs @@ -28,9 +28,9 @@ namespace Exiled.Events.Patches.Events.Player /// Adds the and /// the events. /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] - [HarmonyPatch(typeof(QueryProcessor), nameof(QueryProcessor.ProcessGameConsoleQuery))] + // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] + // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] + // [HarmonyPatch(typeof(QueryProcessor), nameof(QueryProcessor.ProcessGameConsoleQuery))] // TODO internal static class SendingValidGameConsoleCommand { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) From 34d4fdd37e6e6ec5202bbca790ea29fa56ca3c12 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 14:00:40 +0100 Subject: [PATCH 12/42] Fix ReservedSlotPatch --- .../Player/ReservedSlotsCheckEventArgs.cs | 42 ++++++++-- .../Events/Player/ReservedSlotPatch.cs | 83 +++++-------------- 2 files changed, 56 insertions(+), 69 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs index 47861a038c..d571f1e451 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs @@ -13,21 +13,24 @@ namespace Exiled.Events.EventArgs.Player /// /// Contains all information when checking if a player has a reserved slot. /// - public class ReservedSlotsCheckEventArgs : IExiledEvent + public class ReservedSlotsCheckEventArgs : IExiledEvent, IDeniableEvent { + private ReservedSlotEventResult reservedSlotEventResult = ReservedSlotEventResult.UseBaseGameSystem; + /// /// Initializes a new instance of the class. /// - /// - /// - /// /// /// /// - public ReservedSlotsCheckEventArgs(string userId, bool hasReservedSlot) + /// + /// + /// + public ReservedSlotsCheckEventArgs(bool hasReservedSlot, string userId) { UserId = userId; HasReservedSlot = hasReservedSlot; + IsAllowed = hasReservedSlot; } /// @@ -40,9 +43,36 @@ public ReservedSlotsCheckEventArgs(string userId, bool hasReservedSlot) /// public bool HasReservedSlot { get; } + /// + /// Gets or sets a value indicating whether the player is allowed to connect. + /// + public bool IsAllowed { get; set; } + /// /// Gets or sets the event result. /// - public ReservedSlotEventResult Result { get; set; } = ReservedSlotEventResult.UseBaseGameSystem; + public ReservedSlotEventResult Result + { + get => reservedSlotEventResult; + set + { + switch (reservedSlotEventResult) + { + case ReservedSlotEventResult.CanUseReservedSlots or ReservedSlotEventResult.UseBaseGameSystem: + IsAllowed = HasReservedSlot; + break; + case ReservedSlotEventResult.AllowConnectionUnconditionally: + IsAllowed = true; + break; + case ReservedSlotEventResult.CannotUseReservedSlots: + IsAllowed = false; + break; + default: + return; + } + + reservedSlotEventResult = value; + } + } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs b/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs index 23bc710daf..68c3c315bc 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ReservedSlotPatch.cs @@ -31,81 +31,38 @@ internal static class ReservedSlotPatch private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - Label baseGame = generator.DefineLabel(); - Label conditional = generator.DefineLabel(); - Label continueLabel = generator.DefineLabel(); - Label skipLabel = generator.DefineLabel(); - LocalBuilder ev = generator.DeclareLocal(typeof(ReservedSlotsCheckEventArgs)); - int offset = -2; - int index = newInstructions.FindIndex(i => i.opcode == OpCodes.Newobj) + offset; + Label callExiledEvent = generator.DefineLabel(); - newInstructions[index].WithLabels(baseGame); - - newInstructions.InsertRange( - index, - new[] + for (int i = 0; i < newInstructions.Count; i++) + { + if (newInstructions[i].opcode == OpCodes.Ret) { - // ReservedSlotCheckEventArgs ev = new(userid, flag); - new(OpCodes.Ldarg_0), - new(OpCodes.Ldloc_0), - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ReservedSlotsCheckEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Stloc, ev.LocalIndex), - - // Handlers.Player.OnReservedSlot(ev); - new(OpCodes.Call, Method(typeof(Player), nameof(Player.OnReservedSlot))), + newInstructions[i] = new(OpCodes.Br, callExiledEvent); + } + } - // if (ev.Result == ReservedSlotEventResult.UseBaseGameSystem) - // goto baseGame; - new(OpCodes.Ldloc_S, ev), - new(OpCodes.Callvirt, PropertyGetter(typeof(ReservedSlotsCheckEventArgs), nameof(ReservedSlotsCheckEventArgs.Result))), - new(OpCodes.Ldc_I4_0), - new(OpCodes.Beq_S, baseGame), + newInstructions.InsertRange(newInstructions.Count - 1, new[] + { + // flag is already loaded + new CodeInstruction(OpCodes.Ldarg_0).WithLabels(callExiledEvent), - // if (ev.Result == ReservedSlotEventResult.AllowConnectionUnconditionally) - // { - // bypass = true; - // return true; - // } - new(OpCodes.Ldloc_S, ev), - new(OpCodes.Callvirt, PropertyGetter(typeof(ReservedSlotsCheckEventArgs), nameof(ReservedSlotsCheckEventArgs.Result))), - new(OpCodes.Ldc_I4_3), - new(OpCodes.Bne_Un_S, conditional), - new(OpCodes.Ldarg_0), - new(OpCodes.Ldc_I4_1), - new(OpCodes.Call, Method(typeof(ReservedSlotPatch), nameof(CallNwEvent))), - new(OpCodes.Ldarg_1), - new(OpCodes.Ldc_I4_1), - new(OpCodes.Stind_I1), - new(OpCodes.Ldc_I4_1), - new(OpCodes.Ret), + // ReservedSlotCheckEventArgs ev = new(flag, userid); + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ReservedSlotsCheckEventArgs))[0]), + new(OpCodes.Dup), - // if (ev.Result == ReservedSlotEventResult.CannotUseReservedSlots) - // { - // bypass = false; - // return false; - // } - new CodeInstruction(OpCodes.Ldloc_S, ev).WithLabels(conditional), - new(OpCodes.Callvirt, PropertyGetter(typeof(ReservedSlotsCheckEventArgs), nameof(ReservedSlotsCheckEventArgs.Result))), - new(OpCodes.Ldc_I4_2), - new(OpCodes.Bne_Un_S, continueLabel), - new(OpCodes.Ldc_I4_1), - new(OpCodes.Br_S, skipLabel), + // Handlers.Player.OnReservedSlot(ev); + new(OpCodes.Call, Method(typeof(Player), nameof(Player.OnReservedSlot))), - new CodeInstruction(OpCodes.Ldc_I4_1).WithLabels(continueLabel), - new CodeInstruction(OpCodes.Stloc_0).WithLabels(skipLabel), - }); + // return ev.IsAllowed + new(OpCodes.Callvirt, PropertyGetter(typeof(ReservedSlotsCheckEventArgs), nameof(ReservedSlotsCheckEventArgs.IsAllowed))), + new(OpCodes.Ret), + }); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; ListPool.Pool.Return(newInstructions); } - - private static void CallNwEvent(string userId, bool hasReservedSlot) - { - // EventManager.ExecuteEvent(new PlayerCheckReservedSlotEvent(userId, hasReservedSlot)); - } } } \ No newline at end of file From a7ae2cbb258e8661e8aa4a6ae30c57241044778b Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 14:04:48 +0100 Subject: [PATCH 13/42] Fix PickingUpItem(PickingUpAmmo) --- .../Player/PickingUpItemEventArgs.cs | 6 +++--- .../Patches/Events/Player/PickingUp330.cs | 7 +++---- .../Patches/Events/Player/PickingUpAmmo.cs | 20 +++++++++---------- .../Patches/Events/Player/PickingUpArmor.cs | 7 +++---- .../Patches/Events/Player/PickingUpItem.cs | 5 ++--- .../Patches/Events/Player/PickingUpScp244.cs | 5 ++--- 6 files changed, 22 insertions(+), 28 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs index 90493c03c5..f71781e3b7 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs @@ -21,7 +21,7 @@ public class PickingUpItemEventArgs : IPlayerEvent, IPickupEvent, IDeniableEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -30,10 +30,10 @@ public class PickingUpItemEventArgs : IPlayerEvent, IPickupEvent, IDeniableEvent /// /// /// - public PickingUpItemEventArgs(Player player, ItemPickupBase pickup, bool isAllowed = true) + public PickingUpItemEventArgs(ReferenceHub referenceHub, ItemPickupBase pickup, bool isAllowed = true) { IsAllowed = isAllowed; - Player = player; + Player = Player.Get(referenceHub); Pickup = Pickup.Get(pickup); } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/PickingUp330.cs b/EXILED/Exiled.Events/Patches/Events/Player/PickingUp330.cs index a6a618cd79..b4ad99a32a 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/PickingUp330.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/PickingUp330.cs @@ -48,9 +48,8 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Brfalse) + offset; - + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_2) + offset; newInstructions[index].labels.Add(continueLabel); newInstructions.InsertRange( index, new CodeInstruction[] { - // Player.Get(this.Hub) + // this.Hub new(OpCodes.Ldarg_0), new(OpCodes.Ldfld, Field(typeof(AmmoSearchCompletor), nameof(AmmoSearchCompletor.Hub))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // this.TargetPickup new(OpCodes.Ldarg_0), @@ -54,15 +52,15 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 22 Jan 2025 14:10:25 +0100 Subject: [PATCH 14/42] Fix Hurt event --- .../EventArgs/Player/HurtEventArgs.cs | 8 +++---- .../Patches/Events/Player/Hurting.cs | 24 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs index 1b97b4a946..8fd0eab99b 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs @@ -23,7 +23,7 @@ public class HurtEventArgs : IAttackerEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -32,11 +32,11 @@ public class HurtEventArgs : IAttackerEvent /// /// /// - public HurtEventArgs(Player target, DamageHandlerBase damageHandler, DamageHandlerBase.HandlerOutput handlerOutput) + public HurtEventArgs(ReferenceHub referenceHub, DamageHandlerBase damageHandler, DamageHandlerBase.HandlerOutput handlerOutput) { - DamageHandler = new CustomDamageHandler(target, damageHandler); + Player = Player.Get(referenceHub); + DamageHandler = new CustomDamageHandler(Player, damageHandler); Attacker = DamageHandler.BaseIs(out CustomAttackerHandler attackerDamageHandler) ? attackerDamageHandler.Attacker : null; - Player = target; HandlerOutput = handlerOutput; } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs b/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs index 11e3e2a96c..1a5e4093f6 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs @@ -38,8 +38,6 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - LocalBuilder player = generator.DeclareLocal(typeof(Player)); - Label jump = generator.DefineLabel(); int offset = 1; int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; @@ -48,15 +46,14 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 22 Jan 2025 14:27:19 +0100 Subject: [PATCH 15/42] Fix FlippingCoin & EscapingPocketDimension --- .../EventArgs/Player/FlippingCoinEventArgs.cs | 6 +-- .../Events/Player/EscapingPocketDimension.cs | 37 +++++++++---------- .../Patches/Events/Player/FlippingCoin.cs | 11 +++--- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs index 369a443868..954d2f39e8 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs @@ -20,7 +20,7 @@ public class FlippingCoinEventArgs : IPlayerEvent, IDeniableEvent, IItemEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -29,9 +29,9 @@ public class FlippingCoinEventArgs : IPlayerEvent, IDeniableEvent, IItemEvent /// /// /// - public FlippingCoinEventArgs(Player player, Coin coin, bool isTails) + public FlippingCoinEventArgs(ReferenceHub referenceHub, Coin coin, bool isTails) { - Player = player; + Player = Player.Get(referenceHub); Item = Item.Get(coin); IsTails = isTails; } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs index e69b577385..84c5a8a81d 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs @@ -8,6 +8,7 @@ namespace Exiled.Events.Patches.Events.Player { using System.Collections.Generic; + using System.Reflection; using System.Reflection.Emit; using API.Features; @@ -29,7 +30,7 @@ namespace Exiled.Events.Patches.Events.Player /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.EscapingPocketDimension))] - [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.OnTriggerEnter))] + [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.Exit))] internal static class EscapingPocketDimension { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -40,21 +41,14 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(FirstPersonMovementModule), nameof(FirstPersonMovementModule.ServerOverridePosition)))) + offset; - - // Replaces "ServerOverridePosition" with our logic - newInstructions.RemoveRange(index, 6); - + int offset = 1; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ret) + offset; newInstructions.InsertRange( index, new[] { - // Player.Get(referenceHub) - new CodeInstruction(OpCodes.Ldloc_1).WithLabels((Label)newInstructions[index + labelOffset].operand), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + // referenceHub + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), // Scp106PocketExitFinder.GetBestExitPosition(fpcRole) new(OpCodes.Ldloc_2), @@ -73,15 +67,20 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(FirstPersonMovementModule), nameof(FirstPersonMovementModule.ServerOverridePosition)))) + offset; + + // Replaces "fpcRole.FpcModule.ServerOverridePosition(Scp106PocketExitFinder.GetBestExitPosition(fpcRole))" + // with "fpcRole.FpcModule.ServerOverridePosition(ev.TeleportPosition)" + newInstructions.RemoveRange(index, 2); + newInstructions.InsertRange(index, new CodeInstruction[] + { + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(EscapingPocketDimensionEventArgs), nameof(EscapingPocketDimensionEventArgs.TeleportPosition))), + }); newInstructions[newInstructions.Count - 1].WithLabels(ret); for (int z = 0; z < newInstructions.Count; z++) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs b/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs index 71e9711a7f..4ec1ce8c9f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs @@ -38,25 +38,24 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Brtrue_S) + offset; + int offset = 1; + int index = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Stloc_0) + offset; newInstructions.InsertRange( index, new[] { - // Player.Get(ReferenceHub) + // this.Owner new CodeInstruction(OpCodes.Ldarg_0), new(OpCodes.Callvirt, PropertyGetter(typeof(ItemBase), nameof(ItemBase.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // this new CodeInstruction(OpCodes.Ldarg_0), // isTails - new(OpCodes.Ldloc_1), + new(OpCodes.Ldloc_0), - // FlippingCoinEventArgs ev = new(Player, bool) + // FlippingCoinEventArgs ev = new(ReferenceHub, bool) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(FlippingCoinEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), From 15703b1dcb5e9e94180ad4f18ddba0c4ff630f98 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 14:47:40 +0100 Subject: [PATCH 16/42] Fix FailingEscapePocketDimension --- .../FailingEscapePocketDimensionEventArgs.cs | 9 +++--- .../Events/Player/EscapingPocketDimension.cs | 4 +-- .../Player/FailingEscapePocketDimension.cs | 29 ++++--------------- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs index 247e62cbe7..9d398abdda 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs @@ -7,6 +7,8 @@ namespace Exiled.Events.EventArgs.Player { + using System; + using API.Features; using Interfaces; @@ -22,22 +24,19 @@ public class FailingEscapePocketDimensionEventArgs : IPlayerEvent, IDeniableEven /// /// /// - /// - /// - /// /// /// /// - public FailingEscapePocketDimensionEventArgs(Player player, PocketDimensionTeleport teleporter, bool isAllowed = true) + public FailingEscapePocketDimensionEventArgs(Player player, bool isAllowed = true) { Player = player; - Teleporter = teleporter; IsAllowed = isAllowed; } /// /// Gets the PocketDimensionTeleport the player walked into. /// + [Obsolete("can't be used")] public PocketDimensionTeleport Teleporter { get; } /// diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs index 84c5a8a81d..6c6408b36f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Events.Player using static HarmonyLib.AccessTools; /// - /// Patches the method. + /// Patches the method. /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.EscapingPocketDimension))] @@ -51,7 +51,7 @@ private static IEnumerable Transpiler(IEnumerable - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.FailingEscapePocketDimension))] - [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.OnTriggerEnter))] + [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.Kill))] internal static class FailingEscapePocketDimension { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -35,34 +35,17 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; - newInstructions.InsertRange( - index, + 0, new[] { - new CodeInstruction(OpCodes.Ldloc_1).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, player.LocalIndex), - new(OpCodes.Brfalse, returnLabel), - - // player - new CodeInstruction(OpCodes.Ldloc_S, player.LocalIndex), - - // this - new(OpCodes.Ldarg_0), + // referenceHub + new CodeInstruction(OpCodes.Ldarg_0), // true new(OpCodes.Ldc_I4_1), - // FailingEscapePocketDimensionEventArgs ev = new(Player, PocketDimensionTeleport, bool) + // FailingEscapePocketDimensionEventArgs ev = new(ReferenceHub, bool) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(FailingEscapePocketDimensionEventArgs))[0]), new(OpCodes.Dup), From 3c4ec86e72a5213b433f8010742ef6f98a62f5fb Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 14:47:54 +0100 Subject: [PATCH 17/42] EscapingAndEscaped fix patch --- .../API/EventArgs/OwnerEscapingEventArgs.cs | 2 +- .../EventArgs/Player/EscapingEventArgs.cs | 6 ++--- .../Events/Player/EscapingAndEscaped.cs | 22 +++++++++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs b/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs index 2fc89ef333..54f478d7ce 100644 --- a/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs +++ b/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs @@ -30,7 +30,7 @@ public class OwnerEscapingEventArgs : EscapingEventArgs /// /// The instance. public OwnerEscapingEventArgs(Item item, EscapingEventArgs ev) - : base(ev.Player, ev.NewRole, ev.EscapeScenario) + : base(ev.Player.ReferenceHub, ev.NewRole, ev.EscapeScenario) { Item = item; } diff --git a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs index a10eea6922..756873bc56 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs @@ -25,7 +25,7 @@ public class EscapingEventArgs : IPlayerEvent, IDeniableEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -34,9 +34,9 @@ public class EscapingEventArgs : IPlayerEvent, IDeniableEvent /// /// /// - public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escapeScenario) + public EscapingEventArgs(ReferenceHub referenceHub, RoleTypeId newRole, EscapeScenario escapeScenario) { - Player = player; + Player = Player.Get(referenceHub); NewRole = newRole; EscapeScenario = escapeScenario; IsAllowed = escapeScenario is not EscapeScenario.CustomEscape; diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs index 100271a913..72bade7906 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs @@ -41,24 +41,23 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; newInstructions.InsertRange( index, new[] { - // Player.Get(hub) + // hub new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // roleTypeId - new(OpCodes.Ldloc_0), + new(OpCodes.Ldloc_1), // escapeScenario - new(OpCodes.Ldloc_1), + new(OpCodes.Ldloc_2), - // EscapingEventArgs ev = new(Player, RoleTypeId, EscapeScenario, SpawnableTeamType, float) + // EscapingEventArgs ev = new(Player, RoleTypeId, EscapeScenario) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(EscapingEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), @@ -75,7 +74,12 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 22 Jan 2025 15:05:44 +0100 Subject: [PATCH 18/42] Fix UpgradingPlayer patch --- .../Patches/Events/Scp914/UpgradingPlayer.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs index 18394fda42..394fd8815b 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs @@ -16,6 +16,7 @@ namespace Exiled.Events.Patches.Events.Scp914 using Exiled.Events.EventArgs.Scp914; using global::Scp914; using HarmonyLib; + using Mono.Cecil.Cil; using PlayerRoles.FirstPersonControl; using UnityEngine; @@ -41,9 +42,8 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(FpcExtensionMethods), nameof(FpcExtensionMethods.TryOverridePosition)))) + offset; + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_0) + offset; newInstructions.InsertRange( index, @@ -106,18 +106,13 @@ private static IEnumerable Transpiler(IEnumerable instruction.LoadsField(Field(typeof(Scp914Upgrader), nameof(Scp914Upgrader.OnInventoryItemUpgraded)))); - - Label continueLabel = generator.DefineLabel(); - - // Find iterator jump by going -3 from leave_s - int continueIndex = newInstructions.FindIndex(index, instruction => instruction.opcode == OpCodes.Leave_S) - 3; - - newInstructions[continueIndex].labels.Add(continueLabel); + offset = 1; + index = newInstructions.FindIndex(x => x.Calls(PropertyGetter(typeof(LabApi.Events.Arguments.Scp914Events.Scp914ProcessingInventoryItemEventArgs), nameof(LabApi.Events.Arguments.Scp914Events.Scp914ProcessingInventoryItemEventArgs.IsAllowed)))) + offset; + Label continueLabel = (Label)newInstructions[index].operand; LocalBuilder ev2 = generator.DeclareLocal(typeof(UpgradingInventoryItemEventArgs)); + offset = 1; + index = newInstructions.FindIndex(x => x.opcode == OpCodes.Stloc_S && x.operand is LocalBuilder { LocalIndex: 10 }) + offset; newInstructions.InsertRange( index, @@ -132,7 +127,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 22 Jan 2025 15:19:54 +0100 Subject: [PATCH 19/42] Fix BeingObserved --- .../Patches/Events/Scp173/BeingObserved.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs b/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs index 095c374d83..8bb058bf7c 100755 --- a/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs @@ -35,14 +35,10 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Brtrue_S) + offset; - // MethodInfo scp173ExecuteEvent = typeof(EventManager).GetMethods(BindingFlags.Public | BindingFlags.Static).FirstOrDefault(m => m.Name == nameof(EventManager.ExecuteEvent)&& !m.IsGenericMethod); - int index = 0 + offset; // newInstructions.FindLastIndex(i => i.Calls(scp173ExecuteEvent)) + offset; - - newInstructions.InsertRange( - index, - new CodeInstruction[] + newInstructions.InsertRange(index, new CodeInstruction[] { // Player.Get(target) new(OpCodes.Ldarg_1), From d74aa3bba648b942a32783b9b36363b114ef0140 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 15:24:31 +0100 Subject: [PATCH 20/42] Fix PlacingTantrum --- .../Patches/Events/Scp173/PlacingTantrum.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp173/PlacingTantrum.cs b/EXILED/Exiled.Events/Patches/Events/Scp173/PlacingTantrum.cs index 76934c3ff7..9da814466b 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp173/PlacingTantrum.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp173/PlacingTantrum.cs @@ -35,21 +35,13 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - Label returnLabel = newInstructions[newInstructions.Count - 1].labels[0]; + Label returnLabel = generator.DefineLabel(); LocalBuilder ev = generator.DeclareLocal(typeof(PlacingTantrumEventArgs)); - const int offset = -2; + int offset = -2; int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newobj) + offset; - // PlacingTantrumEventArgs ev = new(this, Player, gameObject, cooldown, true); - // - // Handlers.Player.OnPlacingTantrum(ev); - // - // if (!ev.IsAllowed) - // return; - // - // cooldown = ev.Cooldown; newInstructions.InsertRange( index, new CodeInstruction[] @@ -84,6 +76,8 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 22 Jan 2025 15:28:55 +0100 Subject: [PATCH 21/42] Fix FinishingRecall --- EXILED/Exiled.Events/Patches/Events/Scp049/FinishingRecall.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp049/FinishingRecall.cs b/EXILED/Exiled.Events/Patches/Events/Scp049/FinishingRecall.cs index eacd1e1684..6ea1385c8c 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp049/FinishingRecall.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp049/FinishingRecall.cs @@ -34,8 +34,8 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - const int offset = -5; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newobj) + offset; + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_0) + offset; Label returnLabel = generator.DefineLabel(); From d768ee1d0fc940f1049c63c33f3e347885747643 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 15:44:55 +0100 Subject: [PATCH 22/42] ChangingCamera (Not working) --- .../Patches/Events/Scp079/ChangingCamera.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs b/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs index 10f07126f8..0580e4f858 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs @@ -38,8 +38,8 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - int offset = -2; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldloca_S) + offset; + int offset = 6; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ldc_I4_S && x.operand == (object)(sbyte)Scp079HudTranslation.SignalLost) + offset; Label returnLabel = generator.DefineLabel(); @@ -55,14 +55,14 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Brtrue_S) + offset; + offset = -1; + index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ldc_I4_S && x.operand == (object)(sbyte)Scp079HudTranslation.SignalLost) + offset; newInstructions[index].labels.Add(returnLabel); for (int z = 0; z < newInstructions.Count; z++) From fa0fce307cade7da744f578a50b5883b7d81eec1 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 17:02:35 +0100 Subject: [PATCH 23/42] putting again the event than i was lazzy to fix --- .../Events/Player/DamagingShootingTarget.cs | 2 +- .../Events/Player/InteractingGenerator.cs | 16 +++++----------- .../Player/SendingValidGameConsoleCommand.cs | 6 +++--- .../Events/Player/SendingValidRACommand.cs | 6 +++--- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/DamagingShootingTarget.cs b/EXILED/Exiled.Events/Patches/Events/Player/DamagingShootingTarget.cs index 582a3770ae..2687d9b0e7 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/DamagingShootingTarget.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/DamagingShootingTarget.cs @@ -54,7 +54,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj && (ConstructorInfo)instruction.operand == GetDeclaredConstructors(typeof(null))[0]) + offset; + offset = -3; + int index2 = newInstructions.FindLastIndex(x => x.operand == (object)Field(typeof(Scp079Generator), nameof(Scp079Generator._unlockCooldownTime))) + offset; newInstructions.InsertRange( index, new[] { - // isAllowed var set - new(OpCodes.Ldc_I4_0), - new(OpCodes.Br_S, skip2), - - // new CodeInstruction(OpCodes.Ldc_I4_1).MoveLabelsFrom(newInstructions[index2]), TODO: - new CodeInstruction(OpCodes.Stloc_S, isAllowedUnlocking.LocalIndex).WithLabels(skip2), + // save the value of IsAllowed + new(OpCodes.Stloc_S, isAllowedUnlocking.LocalIndex), // player - new(OpCodes.Ldloc_S, player.LocalIndex), + new CodeInstruction(OpCodes.Ldloc_S, player.LocalIndex).MoveLabelsFrom(newInstructions[index]), // this new(OpCodes.Ldarg_0), @@ -200,7 +195,6 @@ private static IEnumerable Transpiler(IEnumerable and /// the events. /// - // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] - // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] - // [HarmonyPatch(typeof(QueryProcessor), nameof(QueryProcessor.ProcessGameConsoleQuery))] // TODO + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] + [HarmonyPatch(typeof(QueryProcessor), nameof(QueryProcessor.ProcessGameConsoleQuery))] internal static class SendingValidGameConsoleCommand { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs b/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs index c6fb9bb034..5e051c8b49 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/SendingValidRACommand.cs @@ -28,9 +28,9 @@ namespace Exiled.Events.Patches.Events.Player /// Adds the and /// the events. /// - // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] - // [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] - // [HarmonyPatch(typeof(CommandProcessor), nameof(CommandProcessor.ProcessQuery))] TODO + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SendingValidCommand))] + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.SentValidCommand))] + [HarmonyPatch(typeof(CommandProcessor), nameof(CommandProcessor.ProcessQuery))] internal static class SendingValidRACommand { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) From 1fe7d022356325fa018dac06e15979451d2dd3aa Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 22 Jan 2025 18:26:31 +0100 Subject: [PATCH 24/42] Rework InteractingDoor Patch missing removing the Prefix part lol & SkillIssueFix --- .../Patches/Events/Player/InteractingDoor.cs | 136 +++++++----------- 1 file changed, 54 insertions(+), 82 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs b/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs index 417b03b859..44274e5572 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs @@ -7,6 +7,12 @@ namespace Exiled.Events.Patches.Events.Player { +#pragma warning disable SA1313 +#pragma warning disable SA1005 +#pragma warning disable SA1515 +#pragma warning disable SA1513 +#pragma warning disable SA1512 + using System.Collections.Generic; using System.Reflection.Emit; @@ -14,10 +20,13 @@ namespace Exiled.Events.Patches.Events.Player using Exiled.API.Features.Pools; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Player; - using HarmonyLib; using Interactables.Interobjects.DoorUtils; + using LabApi.Events.Arguments.PlayerEvents; + using LabApi.Events.Handlers; + using PlayerRoles; + using UnityEngine; using static HarmonyLib.AccessTools; @@ -33,90 +42,53 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); + Label retLabel = generator.DefineLabel(); LocalBuilder ev = generator.DeclareLocal(typeof(InteractingDoorEventArgs)); - List public static readonly Version RequiredSCPSLVersion = new(<#=GameCore.Version.Major#>, <#=GameCore.Version.Minor#>, 0, <#=GameCore.Version.Revision#>); - - /// - /// Gets which Lab API version generated Exiled. - /// - public static readonly Version RequiredSCPSLVersion = new(<#=GameCore.Version.Major#>, <#=GameCore.Version.Minor#>, 0, <#=GameCore.Version.Revision#>); } } \ No newline at end of file diff --git a/EXILED/Exiled.Loader/LoaderPlugin.cs b/EXILED/Exiled.Loader/LoaderPlugin.cs index f0f26cca12..5aeb53d7ec 100644 --- a/EXILED/Exiled.Loader/LoaderPlugin.cs +++ b/EXILED/Exiled.Loader/LoaderPlugin.cs @@ -49,12 +49,12 @@ public class LoaderPlugin : Plugin /// /// Gets the RequiredApiVersion of the EXILED Loader. /// - public override Version RequiredApiVersion => AutoUpdateFiles.RequiredLabAPIVersion; + public override Version RequiredApiVersion { get; } = Assembly.GetAssembly(typeof(LabApi.Loader.PluginLoader)).GetReferencedAssemblies()[0].Version; // TODO Not finish /// /// Gets the Exiled Version. /// - public override Version Version { get; } = new Version(0, 0, 0); + public override Version Version => Exiled.Loader.Loader.Version; /// /// Gets the Exiled Priority load. From f7788a675ed4aa4d2d9271ee685644c1d5d7782e Mon Sep 17 00:00:00 2001 From: Yamato Date: Mon, 27 Jan 2025 21:13:13 +0100 Subject: [PATCH 33/42] InteractingDoor swap CanInteract & IsAllowed back to normal --- .../Patches/Events/Player/InteractingDoor.cs | 8 ++++---- EXILED/Exiled.Loader/LoaderPlugin.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs b/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs index 9d9c1b98eb..3e4c2230c9 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs @@ -62,13 +62,13 @@ private static IEnumerable Transpiler(IEnumerable /// /// Gets the Exiled Version. /// - public override Version Version => Exiled.Loader.Loader.Version; + public override Version Version => Loader.Version; /// /// Gets the Exiled Priority load. From 3993cfe4cddb7a8d2c058770c6522df780dafccc Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 28 Jan 2025 01:42:34 +0100 Subject: [PATCH 34/42] Player::Gravity --- EXILED/Exiled.API/Features/Player.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index df2ab96604..f5b1106d79 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -1069,6 +1069,15 @@ public string RankName set => ReferenceHub.serverRoles.SetText(value); } + /// + /// Gets or sets the player's gravity. + /// + public Vector3 Gravity + { + get => FpcGravityController.AllSyncedGravities.TryGetValue(ReferenceHub, out Vector3 value) ? value : FpcGravityController.DefaultGravity; + set => FpcGravityController.AllSyncedGravities[ReferenceHub] = value; + } + /// /// Gets the global badge of the player. Value will be if the player does not have a global badge. /// From 36d94b4d4f1695adac89dd99e44da9cacdca58c8 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 28 Jan 2025 15:01:47 +0100 Subject: [PATCH 35/42] Gravity in wrong place --- EXILED/Exiled.API/Features/Player.cs | 9 --------- EXILED/Exiled.API/Features/Roles/FpcRole.cs | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index f5b1106d79..df2ab96604 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -1069,15 +1069,6 @@ public string RankName set => ReferenceHub.serverRoles.SetText(value); } - /// - /// Gets or sets the player's gravity. - /// - public Vector3 Gravity - { - get => FpcGravityController.AllSyncedGravities.TryGetValue(ReferenceHub, out Vector3 value) ? value : FpcGravityController.DefaultGravity; - set => FpcGravityController.AllSyncedGravities[ReferenceHub] = value; - } - /// /// Gets the global badge of the player. Value will be if the player does not have a global badge. /// diff --git a/EXILED/Exiled.API/Features/Roles/FpcRole.cs b/EXILED/Exiled.API/Features/Roles/FpcRole.cs index 20998d57da..2a80b0b7f7 100644 --- a/EXILED/Exiled.API/Features/Roles/FpcRole.cs +++ b/EXILED/Exiled.API/Features/Roles/FpcRole.cs @@ -72,6 +72,15 @@ public RelativePosition ClientRelativePosition set => FirstPersonController.FpcModule.Motor.ReceivedPosition = value; } + /// + /// Gets or sets the player's gravity. + /// + public Vector3 Gravity + { + get => FirstPersonController.FpcModule.Motor.GravityController.Gravity; + set => FirstPersonController.FpcModule.Motor.GravityController.Gravity = value; + } + /// /// Gets or sets a value indicating whether if the player should get damage. /// From 88fa6af8e0fbbbcbf026e9532d47c6cb7b02519a Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 28 Jan 2025 15:02:01 +0100 Subject: [PATCH 36/42] IHumeShieldRole for Human --- EXILED/Exiled.API/Features/Roles/HumanRole.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.API/Features/Roles/HumanRole.cs b/EXILED/Exiled.API/Features/Roles/HumanRole.cs index 4ed3398c27..a1ee23aeee 100644 --- a/EXILED/Exiled.API/Features/Roles/HumanRole.cs +++ b/EXILED/Exiled.API/Features/Roles/HumanRole.cs @@ -10,7 +10,7 @@ namespace Exiled.API.Features.Roles using Mirror; using PlayerRoles; - + using PlayerRoles.PlayableScps.HumeShield; using Respawning; using Respawning.NamingRules; @@ -19,7 +19,7 @@ namespace Exiled.API.Features.Roles /// /// Defines a role that represents a human class. /// - public class HumanRole : FpcRole + public class HumanRole : FpcRole, IHumeShieldRole { /// /// Initializes a new instance of the class. @@ -29,6 +29,7 @@ internal HumanRole(HumanGameRole baseRole) : base(baseRole) { Base = baseRole; + HumeShieldModule = baseRole.HumeShieldModule; } /// @@ -58,6 +59,9 @@ public byte UnitNameId /// public new HumanGameRole Base { get; } + /// + public HumeShieldModuleBase HumeShieldModule { get; } + /// /// Gets the armor efficacy based on a specific and the armor the is wearing. /// From d23c75f0c2b9616497fa9f2cab3ba34c891b2e7f Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 28 Jan 2025 15:02:23 +0100 Subject: [PATCH 37/42] Fix BlastDoors & add OpenBlastDoor --- EXILED/Exiled.API/Features/Warhead.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/EXILED/Exiled.API/Features/Warhead.cs b/EXILED/Exiled.API/Features/Warhead.cs index 7ff16a9e93..2857cd61c9 100644 --- a/EXILED/Exiled.API/Features/Warhead.cs +++ b/EXILED/Exiled.API/Features/Warhead.cs @@ -166,6 +166,15 @@ public static int Kills /// Closes the surface blast doors. /// public static void CloseBlastDoors() + { + foreach (BlastDoor door in BlastDoors) + door.SetDoorState(true, false); + } + + /// + /// Open the surface blast doors. + /// + public static void OpenBlastDoors() { foreach (BlastDoor door in BlastDoors) door.SetDoorState(false, true); From b6f6ef7807a6ef82efcff042fc32724c41a28091 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 28 Jan 2025 15:02:53 +0100 Subject: [PATCH 38/42] Fix SpawningRagdoll Scale & missing argument when modify --- .../Player/SpawningRagdollEventArgs.cs | 18 ++++++++----- .../Patches/Events/Player/SpawningRagdoll.cs | 26 ------------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs index e12dc914a1..933b62dfb4 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs @@ -8,7 +8,6 @@ namespace Exiled.Events.EventArgs.Player { using API.Features; - using Interfaces; using PlayerRoles; @@ -16,6 +15,7 @@ namespace Exiled.Events.EventArgs.Player using PlayerStatsSystem; using UnityEngine; + using YamlDotNet.Core.Tokens; /// /// Contains all information before spawning a player ragdoll. @@ -45,7 +45,7 @@ public SpawningRagdollEventArgs(RagdollData info, bool isAllowed = true) public Vector3 Position { get => Info.StartPosition; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, value, Rotation); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, value, Rotation, Scale, Nickname, CreationTime); } /// @@ -54,13 +54,17 @@ public Vector3 Position public Quaternion Rotation { get => Info.StartRotation; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Position, value); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, value, Scale, Nickname, CreationTime); } /// /// Gets or sets the ragdoll's scale. /// - public Vector3 Scale { get; set; } + public Vector3 Scale + { + get => Info.Scale; + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, Rotation, value, Nickname, CreationTime); + } /// /// Gets or sets the ragdoll's . @@ -68,7 +72,7 @@ public Quaternion Rotation public RoleTypeId Role { get => Info.RoleType; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, value, Position, Rotation, Nickname, CreationTime); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, value, Position, Rotation, Scale, Nickname, CreationTime); } /// @@ -82,7 +86,7 @@ public RoleTypeId Role public string Nickname { get => Info.Nickname; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, Rotation, value, CreationTime); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, Rotation, Scale, value, CreationTime); } /// @@ -96,7 +100,7 @@ public string Nickname public DamageHandlerBase DamageHandlerBase { get => Info.Handler; - set => Info = new RagdollData(Player.ReferenceHub, value, Role, Position, Rotation, Nickname, CreationTime); + set => Info = new RagdollData(Player.ReferenceHub, value, Role, Position, Rotation, Scale, Nickname, CreationTime); } /// diff --git a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs index d38f915959..d5c1c33573 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs @@ -72,32 +72,6 @@ private static IEnumerable Transpiler(IEnumerable Date: Tue, 28 Jan 2025 15:03:05 +0100 Subject: [PATCH 39/42] Now fix in LabAPI only --- .../Patches/Fixes/FixNWDisarmCommand.cs | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 EXILED/Exiled.Events/Patches/Fixes/FixNWDisarmCommand.cs diff --git a/EXILED/Exiled.Events/Patches/Fixes/FixNWDisarmCommand.cs b/EXILED/Exiled.Events/Patches/Fixes/FixNWDisarmCommand.cs deleted file mode 100644 index a56149d10a..0000000000 --- a/EXILED/Exiled.Events/Patches/Fixes/FixNWDisarmCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Fixes -{ - using System; - using System.Collections.Generic; - using System.Reflection.Emit; - - using Achievements.Handlers; - - using API.Features.Pools; - using HarmonyLib; - - /// - /// Patches the delegate. - /// Fix https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/528. - /// - [HarmonyPatch(typeof(JustResourcesHandler), nameof(JustResourcesHandler.HandleDisarmed), new Type[] { typeof(ReferenceHub), typeof(ReferenceHub), })] - internal class FixNWDisarmCommand - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - Label retLabel = generator.DefineLabel(); - - newInstructions.InsertRange(0, new CodeInstruction[] - { - new(OpCodes.Ldarg_1), - new(OpCodes.Brfalse_S, retLabel), - new(OpCodes.Ldarg_2), - new(OpCodes.Brfalse_S, retLabel), - }); - - newInstructions[newInstructions.Count - 1].labels.Add(retLabel); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} From c15bcc2fb65a2eebecd6bb1842572d52918f1fae Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 28 Jan 2025 15:13:02 +0100 Subject: [PATCH 40/42] we will keep the funny Ragdoll scale --- .../Player/SpawningRagdollEventArgs.cs | 7 ++++- .../Patches/Events/Player/SpawningRagdoll.cs | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs index 933b62dfb4..a925a3b8bf 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs @@ -58,7 +58,7 @@ public Quaternion Rotation } /// - /// Gets or sets the ragdoll's scale. + /// Gets or sets the ragdoll's scale with RagdollData. /// public Vector3 Scale { @@ -66,6 +66,11 @@ public Vector3 Scale set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, Rotation, value, Nickname, CreationTime); } + /// + /// Gets or sets the ragdoll's scale with GameObject. + /// + public Vector3 RagdollScale { get; set; } + /// /// Gets or sets the ragdoll's . /// diff --git a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs index d5c1c33573..21c44aa091 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs @@ -72,6 +72,32 @@ private static IEnumerable Transpiler(IEnumerable Date: Tue, 11 Feb 2025 18:58:57 +0100 Subject: [PATCH 41/42] Fix Merge & Split Command --- EXILED/Exiled.Events/Commands/Config/Merge.cs | 2 +- EXILED/Exiled.Events/Commands/Config/Split.cs | 2 +- EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs | 2 +- EXILED/Exiled.Loader/LoaderPlugin.cs | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Events/Commands/Config/Merge.cs b/EXILED/Exiled.Events/Commands/Config/Merge.cs index d1463b49b7..c6cf79042d 100644 --- a/EXILED/Exiled.Events/Commands/Config/Merge.cs +++ b/EXILED/Exiled.Events/Commands/Config/Merge.cs @@ -50,7 +50,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s LoaderPlugin.Config.ConfigType = ConfigType.Default; bool haveBeenSaved = ConfigManager.Save(configs); - // LabApi.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); + LoaderPlugin.Instance.SaveConfig(); response = $"Configs have been merged successfully! Feel free to remove the directory in the following path:\n\"{Paths.IndividualConfigs}\""; return haveBeenSaved; } diff --git a/EXILED/Exiled.Events/Commands/Config/Split.cs b/EXILED/Exiled.Events/Commands/Config/Split.cs index fee85f0616..34816af579 100644 --- a/EXILED/Exiled.Events/Commands/Config/Split.cs +++ b/EXILED/Exiled.Events/Commands/Config/Split.cs @@ -50,7 +50,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s LoaderPlugin.Config.ConfigType = ConfigType.Separated; bool haveBeenSaved = ConfigManager.Save(configs); - // PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); + LoaderPlugin.Instance.SaveConfig(); response = $"Configs have been merged successfully! Feel free to remove the file in the following path:\n\"{Paths.Config}\""; return haveBeenSaved; } diff --git a/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs b/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs index c47a550d01..9649cf2740 100644 --- a/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs +++ b/EXILED/Exiled.Events/Patches/Generic/OfflineModeIds.cs @@ -46,7 +46,7 @@ private static IEnumerable Transpiler(IEnumerable $"{userId}@offline"; } - /* + /* // TODO: Fix for labAPI online mode disabled /// /// Patches to add the player's UserId to the dictionary. /// diff --git a/EXILED/Exiled.Loader/LoaderPlugin.cs b/EXILED/Exiled.Loader/LoaderPlugin.cs index db75752028..b2f5215ccd 100644 --- a/EXILED/Exiled.Loader/LoaderPlugin.cs +++ b/EXILED/Exiled.Loader/LoaderPlugin.cs @@ -29,6 +29,11 @@ public class LoaderPlugin : Plugin /// The config for the EXILED Loader. /// public static new Config Config; + + /// + /// The config for the EXILED Loader. + /// + public static LoaderPlugin Instance; #pragma warning restore SA1401 /// @@ -66,6 +71,7 @@ public class LoaderPlugin : Plugin /// public override void Enable() { + Instance = this; Config = base.Config; if (Config == null) From 6a362ac62727ceba925b1061d7fbf137f911cba4 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 11 Feb 2025 19:43:01 +0100 Subject: [PATCH 42/42] new workflow for LabAPI --- .github/workflows/labapi.yml | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/labapi.yml diff --git a/.github/workflows/labapi.yml b/.github/workflows/labapi.yml new file mode 100644 index 0000000000..889c33f8d6 --- /dev/null +++ b/.github/workflows/labapi.yml @@ -0,0 +1,74 @@ +name: Exiled Dev CI + +on: + push: + branches: + - LabAPI + pull_request: + branches: + - LabAPI + workflow_dispatch: + +defaults: + run: + working-directory: ./EXILED + +env: + EXILED_REFERENCES_URL: https://exmod-team.github.io/SL-References/LabAPI.zip + EXILED_REFERENCES_PATH: ${{ github.workspace }}/EXILED/References + EXILED_DLL_ARCHIVER_URL: https://github.com/ExMod-Team/EXILED-DLL-Archiver/releases/latest/download/EXILED-DLL-Archiver.exe + +jobs: + + build: + + runs-on: windows-latest + # Prevent double running for push & pull_request events from the main repo + if: github.event_name != 'push' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + + steps: + + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v4.0.1 + + - name: Setup Nuget + uses: nuget/setup-nuget@v2 + + - uses: actions/checkout@v4.1.7 + + - name: Get references + shell: pwsh + run: | + Invoke-WebRequest -Uri ${{ env.EXILED_REFERENCES_URL }} -OutFile ${{ github.workspace }}/EXILED/References.zip + Expand-Archive -Path References.zip -DestinationPath ${{ env.EXILED_REFERENCES_PATH }} + + - name: Build + env: + EXILED_REFERENCES: ${{ env.EXILED_REFERENCES_PATH }} + shell: pwsh + run: | + ./build.ps1 -BuildNuGet + $File = (Get-ChildItem -Path . -Include 'ExMod.Exiled.*.nupkg' -Recurse).Name + Out-File -FilePath ${{ github.env }} -InputObject "PackageFile=$File" -Encoding utf-8 -Append + + - name: Upload nuget package + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PackageFile }} + path: EXILED/${{ env.PackageFile }} + + - name: Get references + shell: pwsh + run: | + Invoke-WebRequest -Uri ${{ env.EXILED_DLL_ARCHIVER_URL }} -OutFile ${{ github.workspace }}/EXILED/EXILED-DLL-Archiver.exe + + - name: Packaging results as tar.gz + shell: pwsh + run: ./packaging.ps1 + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Build Result + path: EXILED/bin/Release/Exiled.tar.gz +