using LabApi.Loader.Features.Plugins; using LabApi.Features; using LabApi.Events.Handlers; using LabApi.Events.Arguments.PlayerEvents; using LabApi.Features.Console; using MEC; namespace VisibleSpectators; /// /// Main entry point for the VisibleSpectators plugin. /// public class Plugin : Plugin { private SpectatorManager _spectatorManager; public override string Name => "VisibleSpectators"; public override string Author => "Code002Lover"; public override Version Version { get; } = new(1, 0, 0); public override string Description => "See your spectators"; public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion); 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); _spectatorManager = new SpectatorManager(Config); PlayerEvents.ChangedSpectator += _spectatorManager.OnSpectate; PlayerEvents.Joined += _spectatorManager.OnJoin; Timing.RunCoroutine(_spectatorManager.KeepUpdatingSpectators()); } public override void Disable() { Logger.Debug("unloading..."); PlayerEvents.Joined -= _spectatorManager.OnJoin; PlayerEvents.ChangedSpectator -= _spectatorManager.OnSpectate; _spectatorManager = null; } }