Switch to MEC

This commit is contained in:
code002lover 2025-06-05 01:19:33 +02:00
parent 3e51b1a6c8
commit d3dbd1ec9d
4 changed files with 10 additions and 17 deletions

View File

@ -6,11 +6,11 @@ using LabApi.Events.Handlers;
using LabApi.Features; using LabApi.Features;
using LabApi.Features.Console; using LabApi.Features.Console;
using LabApi.Features.Wrappers; using LabApi.Features.Wrappers;
using MEC;
using PlayerRoles; using PlayerRoles;
using PlayerRoles.PlayableScps.Scp079; using PlayerRoles.PlayableScps.Scp079;
using PlayerRoles.PlayableScps.Scp096; using PlayerRoles.PlayableScps.Scp096;
using PlayerRoles.PlayableScps.Scp3114; using PlayerRoles.PlayableScps.Scp3114;
using Timer = System.Timers.Timer;
namespace SCPTeamHint; namespace SCPTeamHint;
@ -19,7 +19,6 @@ public class Plugin : LabApi.Loader.Features.Plugins.Plugin
private readonly object _hintsLock = new(); private readonly object _hintsLock = new();
private readonly Dictionary<Player, Hint> _spectatorHints = new(); private readonly Dictionary<Player, Hint> _spectatorHints = new();
private Timer _timer;
public override string Name => "SCPTeamHint"; public override string Name => "SCPTeamHint";
public override string Author => "HoherGeist, Code002Lover"; public override string Author => "HoherGeist, Code002Lover";
public override Version Version { get; } = new(1, 0, 0); public override Version Version { get; } = new(1, 0, 0);
@ -32,18 +31,13 @@ public class Plugin : LabApi.Loader.Features.Plugins.Plugin
PlayerEvents.Joined += OnJoin; PlayerEvents.Joined += OnJoin;
PlayerEvents.Left += OnLeft; PlayerEvents.Left += OnLeft;
_timer = new Timer(1000); Timing.CallContinuously(1, UpdateHints);
_timer.Elapsed += (_, _) => UpdateHints();
_timer.Start();
} }
public override void Disable() public override void Disable()
{ {
PlayerEvents.Joined -= OnJoin; PlayerEvents.Joined -= OnJoin;
PlayerEvents.Left -= OnLeft; PlayerEvents.Left -= OnLeft;
_timer?.Stop();
_timer?.Dispose();
_timer = null;
} }
private void UpdateHints() private void UpdateHints()

View File

@ -29,6 +29,9 @@
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>..\dependencies\Assembly-CSharp.dll</HintPath> <HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\dependencies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="HintServiceMeow"> <Reference Include="HintServiceMeow">
<HintPath>..\dependencies\HintServiceMeow-LabAPI.dll</HintPath> <HintPath>..\dependencies\HintServiceMeow-LabAPI.dll</HintPath>
</Reference> </Reference>

View File

@ -7,8 +7,8 @@ using LabApi.Features;
using LabApi.Features.Console; using LabApi.Features.Console;
using LabApi.Features.Wrappers; using LabApi.Features.Wrappers;
using LabApi.Loader.Features.Plugins; using LabApi.Loader.Features.Plugins;
using MEC;
using PlayerRoles; using PlayerRoles;
using Timer = System.Timers.Timer;
namespace VisibleSpectators; namespace VisibleSpectators;
@ -51,7 +51,6 @@ public class Plugin : Plugin<SpectatorConfig>
}; };
private readonly Dictionary<Player, Hint> _spectatorHints = new(); private readonly Dictionary<Player, Hint> _spectatorHints = new();
private Timer _timer;
public override string Name => "VisibleSpectators"; public override string Name => "VisibleSpectators";
public override string Author => "Code002Lover"; public override string Author => "Code002Lover";
public override Version Version { get; } = new(1, 0, 0); public override Version Version { get; } = new(1, 0, 0);
@ -68,19 +67,13 @@ public class Plugin : Plugin<SpectatorConfig>
PlayerEvents.ChangedSpectator += OnSpectate; PlayerEvents.ChangedSpectator += OnSpectate;
PlayerEvents.Joined += OnJoin; PlayerEvents.Joined += OnJoin;
_timer = new Timer(1000); Timing.CallContinuously(1, UpdateSpectators);
_timer.Elapsed += (_, _) => UpdateSpectators();
_timer.Start();
} }
public override void Disable() public override void Disable()
{ {
Logger.Debug("unloading..."); Logger.Debug("unloading...");
_timer.Stop();
_timer.Dispose();
_timer = null;
PlayerEvents.Joined -= OnJoin; PlayerEvents.Joined -= OnJoin;
PlayerEvents.ChangedSpectator -= OnSpectate; PlayerEvents.ChangedSpectator -= OnSpectate;

View File

@ -23,6 +23,9 @@
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath> <HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\dependencies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="HintServiceMeow"> <Reference Include="HintServiceMeow">
<HintPath>..\dependencies\HintServiceMeow-LabAPI.dll</HintPath> <HintPath>..\dependencies\HintServiceMeow-LabAPI.dll</HintPath>
</Reference> </Reference>