Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
Config reload command.
Browse files Browse the repository at this point in the history
  • Loading branch information
joker-119 committed Jan 29, 2020
1 parent 97958a9 commit ca35b92
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
33 changes: 28 additions & 5 deletions AdminTools/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using EXILED;
using GameCore;
using MEC;
using Mirror;
using UnityEngine;
Expand Down Expand Up @@ -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<Scp049PlayerScript>().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<Scp049PlayerScript>().plyCam.transform.forward * 2, gameObject.transform.rotation.eulerAngles, new Vector3(x,y,z));
ev.Sender.RAMessage($"Ahh, yes. Enslaved game code.");
return;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -673,6 +695,7 @@ public void SpawnWorkbench(Vector3 position, Vector3 rotation, Vector3 size)

NetworkServer.Spawn(bench);
bench.GetComponent<WorkStation>().Networkposition = offset;
bench.AddComponent<WorkStationUpgrader>();
}

public void SpawnItem(ItemType type, Vector3 pos, Vector3 rot)
Expand Down
12 changes: 8 additions & 4 deletions AdminTools/Patches/Scp049HumanSpeech.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CharacterClassManager>();

if (ccm.CurClass == RoleType.Scp049 || ccm.CurClass.Is939())
__instance.MimicAs939 = value;

return true;
}
}
}
4 changes: 4 additions & 0 deletions AdminTools/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using EXILED;
using Harmony;

namespace AdminTools
{
Expand All @@ -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()
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit ca35b92

Please sign in to comment.