Skip to content

Commit

Permalink
wee little update
Browse files Browse the repository at this point in the history
  • Loading branch information
Parkeymon committed Oct 30, 2024
1 parent db7cbd0 commit 962fa1e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
6 changes: 6 additions & 0 deletions RemoteKeycard/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ public class Config : IConfig
[Description("Toggle on/off exceptions/errors in console. (Enable this before reporting ANY bugs)")]
public bool ShowExceptions { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether this plugin is enabled.
/// </summary>
public bool IsEnabled { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether debug messages should be shown.
/// </summary>
public bool Debug { get; set; } = false;
}
26 changes: 13 additions & 13 deletions RemoteKeycard/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

public class EventHandlers
{
private readonly Config config;
private readonly Config _config;

/// <summary>
/// Initializes a new instance of the <see cref="EventHandlers" /> class.
/// </summary>
/// <param name="config">The <see cref="Config" /> settings that will be used.</param>
public EventHandlers(Config config)
{
this.config = config;
this._config = config;
}

/// <summary>
Expand Down Expand Up @@ -47,7 +47,7 @@ private void OnDoorInteract(InteractingDoorEventArgs ev)
Log.Debug("Door Interact Event");
try
{
if (!config.AffectDoors)
if (!_config.AffectDoors)
return;

Log.Debug(
Expand All @@ -59,7 +59,7 @@ private void OnDoorInteract(InteractingDoorEventArgs ev)
}
catch (Exception e)
{
if (config.ShowExceptions)
if (_config.ShowExceptions)
Log.Warn($"{nameof(OnDoorInteract)}: {e.Message}\n{e.StackTrace}");
}
}
Expand All @@ -69,7 +69,7 @@ private void OnWarheadUnlock(ActivatingWarheadPanelEventArgs ev)
Log.Debug("Warhead Unlock Event");
try
{
if (!config.AffectWarheadPanel)
if (!_config.AffectWarheadPanel)
return;

Log.Debug(
Expand All @@ -80,7 +80,7 @@ private void OnWarheadUnlock(ActivatingWarheadPanelEventArgs ev)
}
catch (Exception e)
{
if (config.ShowExceptions)
if (_config.ShowExceptions)
Log.Warn($"{nameof(OnWarheadUnlock)}: {e.Message}\n{e.StackTrace}");
}
}
Expand All @@ -90,7 +90,7 @@ private void OnGeneratorUnlock(UnlockingGeneratorEventArgs ev)
Log.Debug("Generator Unlock Event");
try
{
if (!config.AffectGenerators)
if (!_config.AffectGenerators)
return;

Log.Debug(
Expand All @@ -101,7 +101,7 @@ private void OnGeneratorUnlock(UnlockingGeneratorEventArgs ev)
}
catch (Exception e)
{
if (config.ShowExceptions)
if (_config.ShowExceptions)
Log.Warn($"{nameof(OnGeneratorUnlock)}: {e.Message}\n{e.StackTrace}");
}
}
Expand All @@ -111,19 +111,19 @@ private void OnLockerInteract(InteractingLockerEventArgs ev)
Log.Debug("Locker Interact Event");
try
{
if (!config.AffectScpLockers)
if (!_config.AffectScpLockers)
return;

Log.Debug(
$"Allowed: {ev.IsAllowed}, Permission?: {ev.Player.HasKeycardPermission(ev.Chamber.RequiredPermissions, true)}");
$"Allowed: {ev.IsAllowed}, Permission?: {ev.Player.HasKeycardPermission(ev.InteractingChamber.Base.RequiredPermissions, true)}");

if (!ev.IsAllowed && ev.Chamber != null &&
ev.Player.HasKeycardPermission(ev.Chamber.RequiredPermissions, true))
if (!ev.IsAllowed && ev.InteractingChamber != null &&
ev.Player.HasKeycardPermission(ev.InteractingChamber.Base.RequiredPermissions, true))
ev.IsAllowed = true;
}
catch (Exception e)
{
if (config.ShowExceptions)
if (_config.ShowExceptions)
Log.Warn($"{nameof(OnLockerInteract)}: {e.Message}\n{e.StackTrace}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion RemoteKeycard/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static bool HasKeycardPermission(
KeycardPermissions permissions,
bool requiresAllPermissions = false)
{
if (Plugin.Instance.Config.AmnesiaMatters && player.IsEffectActive<AmnesiaVision>())
if (Plugin.Instance != null && Plugin.Instance.Config.AmnesiaMatters && player.IsEffectActive<AmnesiaVision>())
return false;

return requiresAllPermissions
Expand Down
4 changes: 2 additions & 2 deletions RemoteKeycard/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace RemoteKeycard;
#nullable enable
namespace RemoteKeycard;

using System;
using Exiled.API.Features;
using Players = Exiled.Events.Handlers.Player;

public class Plugin : Plugin<Config>
{
Expand Down
8 changes: 4 additions & 4 deletions RemoteKeycard/RemoteKeycard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
<DebugType>none</DebugType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EXILED" Version="8.4.2" />
</ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp-firstpass" HintPath="$(EXILED_References)\Assembly-CSharp-firstpass.dll" Private="false" />
<Reference Include="Assembly-CSharp" HintPath="$(EXILED_References)\Assembly-CSharp-Publicized.dll" Private="false" />
Expand All @@ -29,4 +25,8 @@
<Reference Include="UnityEngine.CoreModule" HintPath="$(EXILED_References)\UnityEngine.CoreModule.dll" Private="false" />
<Reference Include="Mirror" HintPath="$(EXILED_References)\Mirror.dll" Private="false" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ExMod.Exiled" Version="8.13.1" />
</ItemGroup>
</Project>

0 comments on commit 962fa1e

Please sign in to comment.