62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
using LabApi.Events.Handlers;
|
|
using LabApi.Features;
|
|
using LabApi.Features.Console;
|
|
using LabApi.Loader;
|
|
|
|
namespace GamblingCoin;
|
|
|
|
public class Plugin : LabApi.Loader.Features.Plugins.Plugin
|
|
{
|
|
public static Plugin Singleton;
|
|
private GamblingCoinEventHandler _eventHandler;
|
|
public GamblingCoinChancesConfig ConfigChances;
|
|
|
|
public GamblingCoinGameplayConfig ConfigGameplay;
|
|
public GamblingCoinMessages ConfigMessages;
|
|
public override string Name => "GamblingCoin";
|
|
public override string Author => "Code002Lover";
|
|
public override Version Version { get; } = new(1, 0, 0);
|
|
public override string Description => "Gamble your life away";
|
|
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
|
|
|
|
public override void LoadConfigs()
|
|
{
|
|
base.LoadConfigs();
|
|
|
|
ConfigGameplay = this.LoadConfig<GamblingCoinGameplayConfig>("gameplay.yml");
|
|
ConfigMessages = this.LoadConfig<GamblingCoinMessages>("messages.yml");
|
|
ConfigChances = this.LoadConfig<GamblingCoinChancesConfig>("chances.yml");
|
|
}
|
|
|
|
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);
|
|
|
|
Singleton = this;
|
|
_eventHandler = new GamblingCoinEventHandler();
|
|
PlayerEvents.FlippedCoin += _eventHandler.OnFlippedCoin;
|
|
}
|
|
|
|
public override void Disable()
|
|
{
|
|
Logger.Debug("unloading...");
|
|
Singleton = null;
|
|
PlayerEvents.FlippedCoin -= _eventHandler.OnFlippedCoin;
|
|
}
|
|
} |