From ca35b922602a3cdad23ccec45214e2279a6067f8 Mon Sep 17 00:00:00 2001 From: galaxy119 Date: Wed, 29 Jan 2020 15:05:17 -0800 Subject: [PATCH] Config reload command. --- AdminTools/EventHandlers.cs | 33 +++++++++++++++++++++---- AdminTools/Patches/Scp049HumanSpeech.cs | 12 ++++++--- AdminTools/Plugin.cs | 4 +++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/AdminTools/EventHandlers.cs b/AdminTools/EventHandlers.cs index 871fd4a..be6fabe 100644 --- a/AdminTools/EventHandlers.cs +++ b/AdminTools/EventHandlers.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using EXILED; +using GameCore; using MEC; using Mirror; using UnityEngine; @@ -551,27 +552,36 @@ public void OnCommand(ref RACommandEvent ev) if (args.Length < 5) { ev.Sender.RAMessage("Invalid number of arguments.", false); + return; } if (!float.TryParse(args[2], out float x)) { - ev.Sender.RAMessage($"Invalid x size: {args[1]}", false); + ev.Sender.RAMessage($"Invalid x size: {args[2]}", false); return; } if (!float.TryParse(args[3], out float y)) { - ev.Sender.RAMessage($"Invalid y size: {args[2]}", false); + ev.Sender.RAMessage($"Invalid y size: {args[3]}", false); return; } if (!float.TryParse(args[4], out float z)) { - ev.Sender.RAMessage($"Invalid z size: {args[3]}", false); + ev.Sender.RAMessage($"Invalid z size: {args[4]}", false); + return; + } + + ReferenceHub player = Plugin.GetPlayer(args[1]); + if (player == null) + { + ev.Sender.RAMessage($"Player not found: {args[1]}", false); return; } - - SpawnWorkbench(sender.gameObject.transform.position + sender.gameObject.GetComponent().plyCam.transform.forward * 2, sender.gameObject.transform.rotation.eulerAngles, new Vector3(x,y,z)); + + GameObject gameObject; + SpawnWorkbench(player.gameObject.transform.position + (gameObject = player.gameObject).GetComponent().plyCam.transform.forward * 2, gameObject.transform.rotation.eulerAngles, new Vector3(x,y,z)); ev.Sender.RAMessage($"Ahh, yes. Enslaved game code."); return; } @@ -640,6 +650,18 @@ public void OnCommand(ref RACommandEvent ev) Timing.RunCoroutine(SpawnBodies(player, role, count)); return; } + case "config": + { + if (args[1].ToLower() == "reload") + { + ev.Allow = false; + ServerStatic.PermissionsHandler.RefreshPermissions(); + ConfigFile.ReloadGameConfigs(); + ev.Sender.RAMessage($"Config files reloaded."); + } + + return; + } } } catch (Exception e) @@ -673,6 +695,7 @@ public void SpawnWorkbench(Vector3 position, Vector3 rotation, Vector3 size) NetworkServer.Spawn(bench); bench.GetComponent().Networkposition = offset; + bench.AddComponent(); } public void SpawnItem(ItemType type, Vector3 pos, Vector3 rot) diff --git a/AdminTools/Patches/Scp049HumanSpeech.cs b/AdminTools/Patches/Scp049HumanSpeech.cs index 4f9bd00..d2004e0 100644 --- a/AdminTools/Patches/Scp049HumanSpeech.cs +++ b/AdminTools/Patches/Scp049HumanSpeech.cs @@ -4,15 +4,19 @@ namespace AdminTools.Patches { [HarmonyPatch(typeof(DissonanceUserSetup), nameof(DissonanceUserSetup.CallCmdAltIsActive))] - public class Scp049HumanSpeech + public class Scp049Speak { - public static void Prefix(DissonanceUserSetup __instance, bool value) + public static bool Prefix(DissonanceUserSetup __instance, bool value) { - if (!Plugin.Scp049Speak) - return; + if (!Plugin.Scp049Speak) + return true; + CharacterClassManager ccm = __instance.gameObject.GetComponent(); + if (ccm.CurClass == RoleType.Scp049 || ccm.CurClass.Is939()) __instance.MimicAs939 = value; + + return true; } } } \ No newline at end of file diff --git a/AdminTools/Plugin.cs b/AdminTools/Plugin.cs index 73a2dd8..795e6b3 100644 --- a/AdminTools/Plugin.cs +++ b/AdminTools/Plugin.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using EXILED; +using Harmony; namespace AdminTools { @@ -13,6 +14,7 @@ public class Plugin : EXILED.Plugin public string HiddenTagsFilePath; public bool GodTuts; public static bool Scp049Speak; + public static int PatchCounter; public override void OnEnable() { @@ -44,6 +46,8 @@ public override void OnEnable() Events.RoundEndEvent += EventHandlers.OnRoundEnd; Events.TriggerTeslaEvent += EventHandlers.OnTriggerTesla; Events.SetClassEvent += EventHandlers.OnSetClass; + HarmonyInstance instance = HarmonyInstance.Create($"com.joker.admintools.{PatchCounter}"); + instance.PatchAll(); } catch (Exception e) {