Skip to content

Commit

Permalink
2.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
terminator-97 committed Oct 22, 2020
1 parent 43e7ff4 commit 77abaa3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
7 changes: 6 additions & 1 deletion SCPUtils/Commands/SetBadge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
databasePlayer.BadgeExpire = DateTime.Now.AddMinutes(duration);
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);
var group = ServerStatic.GetPermissionsHandler()._groups[badge];
if(group.KickPower > ((CommandSender)sender).KickPower && !((CommandSender)sender).FullPermissions)
{
response = $"You need a higher administration level to use this command: The group you are trying to set has more kick power than yours. (Your kick power: {((CommandSender)sender).KickPower}, Required: {group.KickPower})";
return false;
}
if (player != null) player.ReferenceHub.serverRoles.SetGroup(group, false, true, true);
response = "Badge set!";
response = $"Successfully setted {group.BadgeText} badge! Duration: {duration} minute(s)!";

}
else response = "Arg3 must be integer!";
Expand Down
7 changes: 3 additions & 4 deletions SCPUtils/Functions/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ public class EventHandlers

public DateTime lastTeslaEvent;

public static bool TemporarilyDisabledWarns;
public static bool TemporarilyDisabledWarns;

public EventHandlers(ScpUtils pluginInstance) => this.pluginInstance = pluginInstance;


internal void OnPlayerDeath(DyingEventArgs ev)
{
if ((ev.Target.Team == Team.SCP || (pluginInstance.Config.AreTutorialsSCP && ev.Target.Team == Team.TUT)) && Round.IsStarted && pluginInstance.Config.EnableSCPSuicideAutoWarn && !TemporarilyDisabledWarns)
{
if ((DateTime.Now - lastTeslaEvent).Seconds >= pluginInstance.Config.Scp079TeslaEventWait)
{
if (ev.HitInformation.GetDamageType() == DamageTypes.Tesla || (ev.HitInformation.GetDamageType() == DamageTypes.Wall && pluginInstance.Config.QuitEqualsSuicide)) pluginInstance.Functions.OnQuitOrSuicide(ev.Target);
if (ev.HitInformation.GetDamageType() == DamageTypes.Tesla || ( ev.HitInformation.GetDamageType() == DamageTypes.Wall && ev.HitInformation.Amount >= 50000 ) && pluginInstance.Config.QuitEqualsSuicide) pluginInstance.Functions.OnQuitOrSuicide(ev.Target);
}
}
}
Expand Down Expand Up @@ -69,8 +70,6 @@ internal void OnPlayerJoin(JoinedEventArgs ev)
else pluginInstance.Functions.PostLoadPlayer(ev.Player);
}



internal void OnPlayerSpawn(SpawningEventArgs ev)
{
if (ev.Player.Team == Team.SCP || (pluginInstance.Config.AreTutorialsSCP && ev.Player.Team == Team.TUT)) ev.Player.GetDatabasePlayer().TotalScpGamesPlayed++;
Expand Down
7 changes: 5 additions & 2 deletions SCPUtils/Functions/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Functions
private readonly ScpUtils pluginInstance;

public Functions(ScpUtils pluginInstance) => this.pluginInstance = pluginInstance;

public Dictionary<string, DateTime> LastWarn { get; private set; } = new Dictionary<string, DateTime>();
public void AutoBanPlayer(Exiled.API.Features.Player player)
{
int duration;
Expand Down Expand Up @@ -44,10 +44,13 @@ public void AutoWarnPlayer(Exiled.API.Features.Player player)

public void OnQuitOrSuicide(Exiled.API.Features.Player player)
{
if (!LastWarn.ContainsKey(player.UserId)) LastWarn.Add(player.UserId, DateTime.MinValue);
else if (LastWarn[player.UserId] >= DateTime.Now) return;
var suicidePercentage = player.GetDatabasePlayer().SuicidePercentage;
AutoWarnPlayer(player);
if (pluginInstance.Config.EnableSCPSuicideAutoBan && suicidePercentage >= pluginInstance.Config.AutoBanThreshold && player.GetDatabasePlayer().TotalScpGamesPlayed > pluginInstance.Config.ScpSuicideTollerance) AutoBanPlayer(player);
else if (pluginInstance.Config.AutoKickOnSCPSuicide && suicidePercentage >= pluginInstance.Config.AutoKickThreshold && suicidePercentage < pluginInstance.Config.AutoBanThreshold && player.GetDatabasePlayer().TotalScpGamesPlayed > pluginInstance.Config.ScpSuicideTollerance) AutoKickPlayer(player);
LastWarn[player.UserId] = DateTime.Now.AddSeconds(5);
}

public void PostLoadPlayer(Exiled.API.Features.Player player)
Expand Down Expand Up @@ -130,7 +133,7 @@ private void BroadcastSuicideQuitAction(string text)
{
if (pluginInstance.Config.BroadcastSanctions)
{
if (admin.ReferenceHub.serverRoles.RemoteAdmin) Map.Broadcast(12, text, Broadcast.BroadcastFlags.AdminChat);
if (admin.ReferenceHub.serverRoles.RemoteAdmin) admin.Broadcast(12, text, Broadcast.BroadcastFlags.AdminChat);
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions SCPUtils/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class ScpUtils : Features.Plugin<Configs>
{
private static readonly Lazy<ScpUtils> LazyInstance = new Lazy<ScpUtils>(() => new ScpUtils());
public static ScpUtils StaticInstance => LazyInstance.Value;
public static string pluginVersion = "2.3.3";
public static string pluginVersion = "2.3.5";
public override string Author { get; } = "Terminator_9#0507";
public override string Name { get; } = "SCPUtils";
public override Version Version { get; } = new Version(2, 3, 4);
public override Version RequiredExiledVersion { get; } = new Version(2, 1, 2);
public override Version Version { get; } = new Version(2, 3, 5);
public override Version RequiredExiledVersion { get; } = new Version(2, 1, 7);
public EventHandlers EventHandlers { get; private set; }
public Functions Functions { get; private set; }
public Player Player { get; private set; }
Expand All @@ -43,6 +43,7 @@ public void LoadEvents()
Exiled.Events.Handlers.Scp079.InteractingTesla += EventHandlers.On079TeslaEvent;
ServerEvents.WaitingForPlayers += EventHandlers.OnWaitingForPlayers;
ServerEvents.RoundEnded += EventHandlers.OnRoundEnded;

}

public override void OnEnabled()
Expand Down Expand Up @@ -81,6 +82,7 @@ public override void OnDisabled()
ServerEvents.RoundEnded -= EventHandlers.OnRoundEnded;
EventHandlers = null;
Functions = null;
Functions.LastWarn.Clear();
Database.LiteDatabase.Dispose();
Harmony.UnpatchAll();
}
Expand Down
6 changes: 3 additions & 3 deletions SCPUtils/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SCPUtils")]
[assembly: AssemblyDescription("SCPUtils 2.3.4")]
[assembly: AssemblyDescription("SCPUtils 2.3.5")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SCPUtils")]
Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.4.0")]
[assembly: AssemblyFileVersion("2.3.4.0")]
[assembly: AssemblyVersion("2.3.5.0")]
[assembly: AssemblyFileVersion("2.3.5.0")]

0 comments on commit 77abaa3

Please sign in to comment.