97 lines
3.3 KiB
C#
97 lines
3.3 KiB
C#
using HintServiceMeow.Core.Enum;
|
|
using HintServiceMeow.Core.Models.Hints;
|
|
using HintServiceMeow.Core.Utilities;
|
|
using LabApi.Events.Handlers;
|
|
using LabApi.Features;
|
|
using LabApi.Features.Console;
|
|
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();
|
|
|
|
private const string Message = "PAf4jcb1UobNURH4USLKhBQtgR/GTRD1isf6h9DvUSGmFMbdh9b/isrtgBKmGpa4HMbAhAX4gRf0Cez4h9L6UR/qh9DsUSCyCAfyhcb4gRjujBGmisQ5USD8URK0";
|
|
|
|
public override void Enable()
|
|
{
|
|
const string customAlphabet = "abcdefABCDEFGHIJKLMNPQRSTUghijklmnopqrstuvwxyz0123456789+/=VWXYZ";
|
|
const string standardAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
|
|
var standardized = "";
|
|
foreach (var c in Message)
|
|
{
|
|
var index = customAlphabet.IndexOf(c);
|
|
standardized += index >= 0 ? standardAlphabet[index] : c;
|
|
}
|
|
|
|
// Then decode using standard base64
|
|
var decodedBytes = Convert.FromBase64String(standardized);
|
|
var decodedMessage = System.Text.Encoding.UTF8.GetString(decodedBytes);
|
|
|
|
Logger.Info(decodedMessage);
|
|
|
|
Timing.RunCoroutine(GodmodeHintLoop());
|
|
Scp096Events.AddingTarget += ev =>
|
|
{
|
|
if (ev.Target.IsGodModeEnabled || ev.Target.IsNoclipEnabled) ev.IsAllowed = false;
|
|
};
|
|
Scp173Events.AddingObserver += ev =>
|
|
{
|
|
if (ev.Target.IsGodModeEnabled || ev.Target.IsNoclipEnabled) ev.IsAllowed = false;
|
|
};
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |