Skip to content

Commit

Permalink
1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
terminator-97 committed Apr 2, 2020
1 parent ceaa554 commit 85cf332
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 41 deletions.
12 changes: 1 addition & 11 deletions SCPUtils/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ namespace SCPUtils
{
public class Commands
{
private readonly Functions functionsInstance;
private readonly Utils pluginInstance;
string playerListString;



public Commands(Functions functionsInstance, Utils pluginInstance)
{
this.functionsInstance = functionsInstance;
this.pluginInstance = pluginInstance;
}


public void OnRaCommand(ref RACommandEvent ev)
Expand Down Expand Up @@ -93,6 +82,7 @@ public void OnRaCommand(ref RACommandEvent ev)
if (commandSender.CheckPermission("scputils.playerlist"))
{

var playerListString = "";
foreach (var databasePlayer in Database.LiteDatabase.GetCollection<Player>().FindAll())
{
playerListString += $"\n[{databasePlayer.Name} ({databasePlayer.Id}@{databasePlayer.Authentication})]\n\n Total SCP Suicides/Quits: [ {databasePlayer.ScpSuicideCount} ]\n Total SCP Suicides/Quits Kicks: [ {databasePlayer.TotalScpSuicideKicks} ]\n Total SCP Suicides/Quits Bans: [ {databasePlayer.TotalScpSuicideBans} ]\n Total Games played as SCP: [ {databasePlayer.TotalScpGamesPlayed} ]\n Total Suicides/Quits Percentage: [ {Math.Round(databasePlayer.SuicidePercentage, 2)}% ]\n";
Expand Down
35 changes: 5 additions & 30 deletions SCPUtils/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
namespace SCPUtils
{
public static class Database
{
//LiteDB
{
public static string databaseName = "SCPUtils";

public static LiteDatabase LiteDatabase { get; private set; }
public static string DatabaseDirectory => Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EXILED"), databaseName);
public static string DatabaseFullPath => Path.Combine(DatabaseDirectory, $"{databaseName}.db");
Expand Down Expand Up @@ -76,23 +74,19 @@ public static void AddPlayer(ReferenceHub player)


}
public class Utils : EXILED.Plugin
{

//Generic
public class Utils : Plugin
{
public static bool IsStarted { get; set; }
public static string pluginVersion = "1.2.3";
public static string pluginVersion = "1.2.4";
public override string getName { get; } = "SCPUtils";


public EventHandlers EventHandlers { get; private set; }
public Commands Commands { get; private set; }
public Functions Functions { get; private set; }
public Player Player { get; private set; }

internal ExiledVersion ExiledVersion { get; private set; } = new ExiledVersion() { Major = 1, Minor = 9, Patch = 10 };


//Configs
public bool enableSCPSuicideAutoWarn;
public bool enableRoundRestartCheck;
Expand All @@ -119,14 +113,9 @@ public class Utils : EXILED.Plugin
public float autoBanThreshold;
public float autoKickThreshold;






public override void OnEnable()
{
Commands = new Commands(Functions, this);
Commands = new Commands();
Functions = new Functions(this, Commands);
EventHandlers = new EventHandlers(Functions, this);
LoadEvents();
Expand All @@ -137,8 +126,6 @@ public override void OnEnable()
Log.Info($"{getName} {pluginVersion} Loaded!");
}



public override void OnDisable()
{
Events.RoundStartEvent -= EventHandlers.OnRoundStart;
Expand All @@ -156,16 +143,10 @@ public override void OnDisable()
Functions = null;
}



public override void OnReload()
{

}




public void LoadEvents()
{
Events.RoundStartEvent += EventHandlers.OnRoundStart;
Expand All @@ -177,7 +158,6 @@ public void LoadEvents()
Events.Scp079TriggerTeslaEvent += EventHandlers.On079Tesla;
Events.PlayerLeaveEvent += EventHandlers.OnPlayerLeave;
Events.PlayerSpawnEvent += EventHandlers.OnPlayerSpawn;

}

public void LoadCommands()
Expand Down Expand Up @@ -211,21 +191,16 @@ internal void LoadConfig()
SCP079TeslaEventWait = Config.GetInt("scputils_scp_079_tesla_event_wait", 2);
autoBanThreshold = Config.GetFloat("scputils_auto_ban_threshold", 30.5f);
autoKickThreshold = Config.GetFloat("scputils_auto_kick_threshold", 15.5f);

ConfigValidator();
}



public void ConfigValidator()
{
if (scpSuicideTollerance < 0) Log.Warn("Invalid config scputils_scp_suicide_tollerance!");
if (autoKickThreshold >= autoBanThreshold) Log.Warn("Invalid config scputils_auto_kick_threshold OR scputils_auto_ban_threshold!");
if (autoRestartTime < 0) Log.Warn("Invalid config scputils_auto_restart_time!");
if (SCP079TeslaEventWait < 0) Log.Warn("Invalid config scputils_scp_079_tesla_event_wait!");
if (Version.Parse($"{EventPlugin.Version.Major}.{EventPlugin.Version.Minor}.{EventPlugin.Version.Patch}") < Version.Parse($"{ExiledVersion.Major}.{ExiledVersion.Minor}.{ExiledVersion.Patch}")) Log.Warn($"You are running the plugin in an outdated EXILED version, you may try to use the plugin but it's advisable to update your EXILED version (Required version: {ExiledVersion.Major}.{ExiledVersion.Minor}.{ExiledVersion.Patch}), plugin developer won't offer support for incompatible EXILED versions!");

}

}
}

0 comments on commit 85cf332

Please sign in to comment.