various thingies
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using HintServiceMeow.Core.Enum;
|
||||
using HintServiceMeow.Core.Models.Hints;
|
||||
using HintServiceMeow.Core.Utilities;
|
||||
using LabApi.Features;
|
||||
using LabApi.Loader.Features.Plugins;
|
||||
using LabApi.Features.Wrappers;
|
||||
using MEC;
|
||||
|
||||
namespace ModInfo
|
||||
{
|
||||
public class ModInfo : Plugin
|
||||
{
|
||||
public override string Name => "ModInfo";
|
||||
public override string Author => "Code002Lover";
|
||||
public override Version Version { get; } = new(1, 0, 0);
|
||||
public override string Description => "Shows some extra info for moderators";
|
||||
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
|
||||
|
||||
private readonly Dictionary<Player, Hint> _spectatorHints = new();
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
Timing.RunCoroutine(GodmodeHintLoop());
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator<float> GodmodeHintLoop()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
yield return Timing.WaitForSeconds(1);
|
||||
UpdateHints();
|
||||
}
|
||||
// ReSharper disable once IteratorNeverReturns
|
||||
}
|
||||
|
||||
private void UpdateHints()
|
||||
{
|
||||
foreach (var player in Player.ReadyList) UpdateHint(player);
|
||||
}
|
||||
|
||||
private void UpdateHint(Player player)
|
||||
{
|
||||
var hint = _spectatorHints.TryGetValue(player, out var hintValue) ? hintValue : AddPlayerHint(player);
|
||||
hint.Hide = !player.IsGodModeEnabled;
|
||||
}
|
||||
|
||||
private Hint AddPlayerHint(Player player)
|
||||
{
|
||||
var hint = new Hint
|
||||
{
|
||||
Text = "<size=40><color=#50C878>GODMODE</color></size>",
|
||||
Alignment = HintAlignment.Left,
|
||||
YCoordinate = 800,
|
||||
Hide = true
|
||||
};
|
||||
|
||||
var playerDisplay = PlayerDisplay.Get(player);
|
||||
playerDisplay.AddHint(hint);
|
||||
|
||||
_spectatorHints[player] = hint;
|
||||
return hint;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user