From 59eede61278cd50ace6c2caf96b7f5d7a9291e20 Mon Sep 17 00:00:00 2001
From: Terminator_97 <50580453+francesco132@users.noreply.github.com>
Date: Sun, 3 Jan 2021 16:44:53 +0100
Subject: [PATCH] 2.4.0
---
README.md | 11 ++--
SCPUtils/Commands/Help.cs | 4 +-
SCPUtils/Commands/PlayTime.cs | 38 ++++++++++----
SCPUtils/Commands/PlayerInfo.cs | 38 ++++++++------
SCPUtils/Commands/PlayerList.cs | 11 ++--
SCPUtils/Commands/PlayerRestrict.cs | 64 ++++++++++++++++++++++
SCPUtils/Commands/PlayerUnrestrict.cs | 58 ++++++++++++++++++++
SCPUtils/Commands/PreferencePersist.cs | 61 +++++++++++++++++++++
SCPUtils/Commands/RevokeBadge.cs | 1 -
SCPUtils/Commands/SetBadge.cs | 22 +++++---
SCPUtils/Commands/SetColor.cs | 9 +++-
SCPUtils/Commands/SetName.cs | 5 ++
SCPUtils/Commands/ShowCommandBan.cs | 73 ++++++++++++++++++++++++++
SCPUtils/Commands/StaffList.cs | 2 +-
SCPUtils/Configs.cs | 8 +++
SCPUtils/Database/Database.cs | 7 ++-
SCPUtils/Database/Player.cs | 23 ++++++--
SCPUtils/Functions/EventHandlers.cs | 13 +++--
SCPUtils/Functions/Functions.cs | 61 +++++++++++++++++----
SCPUtils/Plugin.cs | 10 ++--
SCPUtils/SCPUtils.csproj | 32 ++++++-----
SCPUtils/app.config | 11 ++++
SCPUtils/packages.config | 1 +
23 files changed, 481 insertions(+), 82 deletions(-)
create mode 100644 SCPUtils/Commands/PlayerRestrict.cs
create mode 100644 SCPUtils/Commands/PlayerUnrestrict.cs
create mode 100644 SCPUtils/Commands/PreferencePersist.cs
create mode 100644 SCPUtils/Commands/ShowCommandBan.cs
create mode 100644 SCPUtils/app.config
diff --git a/README.md b/README.md
index 7c0e1a4..9986c09 100644
--- a/README.md
+++ b/README.md
@@ -22,17 +22,17 @@ This is the list of SCPUtils features with a brief description, i recomend to re
**Database will get created inside Exiled/SCPUtils folder.**
**You must add LiteDB.dll into Plugins/dependencies folder or plugin won't work**
-**Minimum requirements: Exiled version: 2.1.8 and LiteDB 5.0.9**
+**Minimum requirements: Exiled version: 2.1.22 and LiteDB 5.0.9**
### Configs:
You can see settings and edit them inside Exiled/port-config.yml file(example Exiled/7777-config.yml)
-**Admin commands**
+**Admin commands and Game console commands**
| Admin Commands | Args | Permission | Description |
| ------------- | ------------- | ------------- | ------------- |
-| scputils_help | none | none | Show plugin info |
+| scputils_help | none | scputils.help | Show plugin info |
| scputils_player_info | player / id / userid | scputils.playerinfo | Show player info |
| scputils_player_list | minimun percentage | scputils.playerlist | List all players with a percetage equal or higher of quits/suicides |
| scputils_player_reset | player / id / userid | scputils.playerreset | Reset warns,suicides,bans,kick and games played stats |
@@ -50,6 +50,10 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex
| scputils_global_edit | | scputils.globaledit | Globally edits player stats (removes total scp games/suicides/kicks/bans) |
| scputils_player_edit | | scputils.playeredit | Edits player stats (total scp games/suicides/kicks/bans) by setting them to specified amount |
| scputils_player_delete | | scputils.playerdelete | Deletes a player from db, action is irreversible, do this when player is not in server. |
+| scputils_preference_persist | | scputils.keep | If disabled by config players that lose the permission to change name,color,hide badge will have that setting resetted, by using this command you allow the player to use their preference even without permissions |
+| scputils_player_restrict | | scputils.moderatecommands | | You can a specific player from change name and color feature |
+| scputils_player_unrestrict | | scputils.moderatecommands | Unban a previously command banned player |
+| scputils_show_command_bans | | scputils.moderatecommands | Show command ban history of a specific player |
**Console commands**
@@ -62,6 +66,7 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex
| scputils_show_badge | none | scputils.badgevisibility | Permanently show your badge |
| scputils_hide_badge | none | scputils.badgevisibility | Permanently hide your badge |
| scputils_my_info | none | none | Show your preferences and temporarily badges info |
+| scputils_play_time | none | none | Show your own playtime with a max range of 120 days |
**Speak permissions**
diff --git a/SCPUtils/Commands/Help.cs b/SCPUtils/Commands/Help.cs
index 56dd192..ecb1fc5 100644
--- a/SCPUtils/Commands/Help.cs
+++ b/SCPUtils/Commands/Help.cs
@@ -18,9 +18,9 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
{
string text = "";
text = $"User commands: \n" +
- ".scputils_info, .scputils_change_nickname, .scputils_change_color, .scputils_show_badge, .scputils_hide_badge, .scputils_my_info";
+ ".scputils_info, .scputils_change_nickname, .scputils_change_color, .scputils_show_badge, .scputils_hide_badge, .scputils_my_info, .scputils_play_time";
if (CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.help") || ((CommandSender)sender).FullPermissions) text += "\nAdministration commands (Remote Admin): \n" +
- "scputils_player_info, scputils_player_list, scputils_player_reset_preferences, scputils_player_reset, scputils_set_color, scputils_set_name, scputils_set_badge, scputils_revoke_badge, scputils_play_time, scputils_whitelist_asn, scputils_unwhitelist_asn, scputils_enable_suicide_warns, scputils_disable_suicide_warns, scputils_global_edit, scputils_player_edit, scputils_player_delete";
+ "scputils_player_info, scputils_player_list, scputils_player_reset_preferences, scputils_player_reset, scputils_set_color, scputils_set_name, scputils_set_badge, scputils_revoke_badge, scputils_play_time, scputils_whitelist_asn, scputils_unwhitelist_asn, scputils_enable_suicide_warns, scputils_disable_suicide_warns, scputils_global_edit, scputils_player_edit, scputils_player_delete, scputils_player_restrict, scputils_player_unrestrict, scputils_show_command_bans, scputils_preference_persist";
response = text;
return true;
}
diff --git a/SCPUtils/Commands/PlayTime.cs b/SCPUtils/Commands/PlayTime.cs
index aa24231..79e5901 100644
--- a/SCPUtils/Commands/PlayTime.cs
+++ b/SCPUtils/Commands/PlayTime.cs
@@ -1,11 +1,14 @@
using System;
using System.Linq;
+using System.Text;
using CommandSystem;
+using Log = Exiled.API.Features.Log;
namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
+ [CommandHandler(typeof(ClientCommandHandler))]
class PlayTime : ICommand
{
@@ -18,10 +21,24 @@ class PlayTime : ICommand
public bool Execute(ArraySegment arguments, ICommandSender sender, out string response)
{
string target;
- if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playtime") && !((CommandSender)sender).FullPermissions)
+ int range;
+ if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playerinfo") && !((CommandSender)sender).FullPermissions)
{
- response = " You need a higher administration level to use this command!";
- return false;
+ target = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId).ToString().Split(new string[] { " " }, StringSplitOptions.None)[2];
+
+ if (arguments.Count < 1)
+ {
+ response = $"Usage: {Command} ";
+ return false;
+ }
+
+ else int.TryParse(arguments.Array[1], out range);
+
+ if (range > 120)
+ {
+ response = "You can specify a range of max 120 days!";
+ return false;
+ }
}
else
{
@@ -31,6 +48,9 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
return false;
}
else target = arguments.Array[1].ToString();
+
+ int.TryParse(arguments.Array[2], out range);
+
}
var databasePlayer = target.GetDatabasePlayer();
@@ -41,8 +61,6 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
}
- int.TryParse(arguments.Array[2], out int range);
-
if (range < 0)
{
response = "You have to specify a positive number!";
@@ -54,15 +72,17 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
response = "Player not found on Database or Player is loading data!";
return false;
}
- string message = $"\n[{databasePlayer.Name} ({databasePlayer.Id}@{databasePlayer.Authentication})]\n\n" +
- $"Total Playtime: [ { new TimeSpan(0, 0, databasePlayer.PlayTimeRecords.Values.Sum()).ToString() } ]\n";
+ StringBuilder message = new StringBuilder($"[{databasePlayer.Name} ({databasePlayer.Id}@{databasePlayer.Authentication})");
+ message.AppendLine();
+ message.Append($"Total Playtime: [ { new TimeSpan(0, 0, databasePlayer.PlayTimeRecords.Values.Sum()).ToString() } ]");
for (int i = 0; i <= range; i++)
{
+ message.AppendLine();
DateTime.TryParse((DateTime.Now.Date.AddDays(-i)).ToString(), out DateTime date);
- if (databasePlayer.PlayTimeRecords.ContainsKey(date.Date.ToShortDateString())) message += $"{date.Date.ToShortDateString()} Playtime: [ { new TimeSpan(0, 0, databasePlayer.PlayTimeRecords[date.Date.ToShortDateString()]).ToString() } ]\n";
- else message += $"{date.Date.ToShortDateString()} Playtime: [ No activity ]\n";
+ if (databasePlayer.PlayTimeRecords.ContainsKey(date.Date.ToShortDateString())) message.Append($"{date.Date.ToShortDateString()} Playtime: [ { new TimeSpan(0, 0, databasePlayer.PlayTimeRecords[date.Date.ToShortDateString()]).ToString() } ]");
+ else message.Append($"{date.Date.ToShortDateString()} Playtime: [ No activity ]");
}
response = $"{message}";
diff --git a/SCPUtils/Commands/PlayerInfo.cs b/SCPUtils/Commands/PlayerInfo.cs
index d8502d8..f3a7815 100644
--- a/SCPUtils/Commands/PlayerInfo.cs
+++ b/SCPUtils/Commands/PlayerInfo.cs
@@ -37,21 +37,29 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
return false;
}
- response = $"\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" +
- $"First Join: [ {databasePlayer.FirstJoin} ]\n" +
- $"Last Seen: [ {databasePlayer.LastSeen} ]\n" +
- $"Custom Color: [ {databasePlayer.ColorPreference} ]\n" +
- $"Custom Name: [ {databasePlayer.CustomNickName} ]\n" +
- $"Temporarily Badge: [ {databasePlayer.BadgeName} ]\n" +
- $"Badge Expire: [ {databasePlayer.BadgeExpire} ]\n" +
- $"Hide Badge: [ {databasePlayer.HideBadge} ]\n" +
- $"Asn Whitelisted: [ {databasePlayer.ASNWhitelisted} ]\n" +
- $"Total Playtime: [ { new TimeSpan(0, 0, databasePlayer.PlayTimeRecords.Values.Sum()).ToString() } ]";
+
+
+ string text = $"\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" +
+ $"First Join: [ {databasePlayer.FirstJoin} ]\n" +
+ $"Last Seen: [ {databasePlayer.LastSeen} ]\n" +
+ $"Custom Color: [ {databasePlayer.ColorPreference} ]\n" +
+ $"Custom Name: [ {databasePlayer.CustomNickName} ]\n" +
+ $"Temporarily Badge: [ {databasePlayer.BadgeName} ]\n" +
+ $"Badge Expire: [ {databasePlayer.BadgeExpire} ]\n" +
+ $"Previous Badge: [ {databasePlayer.PreviousBadge} ]\n" +
+ $"Hide Badge: [ {databasePlayer.HideBadge} ]\n" +
+ $"Asn Whitelisted: [ {databasePlayer.ASNWhitelisted} ]\n" +
+ $"Keep Flag: [ {databasePlayer.KeepPreferences} ]\n" +
+ $"Total Playtime: [ { new TimeSpan(0, 0, databasePlayer.PlayTimeRecords.Values.Sum()).ToString() } ]";
+
+ if (databasePlayer.IsRestricted()) text += $"\nUser account is currently restricted\nReason: [ {databasePlayer.Restricted.Values.Last()} ]\nExpire: [ {databasePlayer.Restricted.Keys.Last()} ]";
+
+ response = text;
return true;
}
diff --git a/SCPUtils/Commands/PlayerList.cs b/SCPUtils/Commands/PlayerList.cs
index d4aa417..4842064 100644
--- a/SCPUtils/Commands/PlayerList.cs
+++ b/SCPUtils/Commands/PlayerList.cs
@@ -1,4 +1,5 @@
using System;
+using System.Text;
using CommandSystem;
namespace SCPUtils.Commands
@@ -29,16 +30,16 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
return false;
}
}
- var playerListString = "[Quits/Suicides Percentage]\n";
-
+ StringBuilder playerListString = new StringBuilder("[Quits/Suicides Percentage]");
+ playerListString.AppendLine();
if (int.TryParse(arguments.Array[1].ToString(), out int minpercentage))
{
foreach (var databasePlayer in Database.LiteDatabase.GetCollection().Find(x => x.SuicidePercentage >= minpercentage))
{
- playerListString += $"\n{databasePlayer.Name} ({databasePlayer.Id}@{databasePlayer.Authentication}) -[ {Math.Round(databasePlayer.SuicidePercentage, 2)}% ]";
+ playerListString.AppendLine();
+ playerListString.Append($"{databasePlayer.Name} ({databasePlayer.Id}@{databasePlayer.Authentication}) -[ {Math.Round(databasePlayer.SuicidePercentage, 2)}% ]");
}
- if (playerListString == "[Quits/Suicides as SCP]\n") response = "No results found";
- else response = $"{playerListString}";
+ response = $"{playerListString}";
}
else
diff --git a/SCPUtils/Commands/PlayerRestrict.cs b/SCPUtils/Commands/PlayerRestrict.cs
new file mode 100644
index 0000000..a9163c8
--- /dev/null
+++ b/SCPUtils/Commands/PlayerRestrict.cs
@@ -0,0 +1,64 @@
+using System;
+using CommandSystem;
+
+namespace SCPUtils.Commands
+{
+ [CommandHandler(typeof(RemoteAdminCommandHandler))]
+ [CommandHandler(typeof(GameConsoleCommandHandler))]
+ class PlayerRestrict : ICommand
+ {
+
+ public string Command { get; } = "scputils_player_restrict";
+
+ public string[] Aliases { get; } = new[] { "restrict", "susp" };
+
+ public string Description { get; } = "This command restrict a player from using change name and set color commands!";
+
+ public bool Execute(ArraySegment arguments, ICommandSender sender, out string response)
+ {
+ string target;
+ string reason;
+ if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.moderatecommands") && !((CommandSender)sender).FullPermissions)
+ {
+ response = " You need a higher administration level to use this command!";
+ return false;
+ }
+
+ else if (arguments.Count < 3)
+ {
+ response = $"Usage: {Command} ";
+ return false;
+ }
+ target = arguments.Array[1].ToString();
+
+ var player = Exiled.API.Features.Player.Get(target);
+ var databasePlayer = target.GetDatabasePlayer();
+
+ if (databasePlayer == null)
+ {
+ response = "Player not found on Database or Player is loading data!";
+ return false;
+ }
+
+ else if (databasePlayer.IsRestricted())
+ {
+ response = "Player is already suspended!";
+ return false;
+ }
+
+
+ else if (int.TryParse(arguments.Array[2], out int minutes))
+ {
+ reason = string.Join(" ", arguments.Array, 3, arguments.Array.Length - 3);
+ databasePlayer.Restricted.Add(DateTime.Now.AddMinutes(minutes), reason);
+ if (minutes == 0) databasePlayer.Restricted.Add(DateTime.Now.AddDays(20000), reason);
+ Database.LiteDatabase.GetCollection().Update(databasePlayer);
+ response = $"Player suspended!";
+
+ }
+ else response = "Duration must be integer!";
+
+ return true;
+ }
+ }
+}
diff --git a/SCPUtils/Commands/PlayerUnrestrict.cs b/SCPUtils/Commands/PlayerUnrestrict.cs
new file mode 100644
index 0000000..fd7f373
--- /dev/null
+++ b/SCPUtils/Commands/PlayerUnrestrict.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Linq;
+using CommandSystem;
+
+
+namespace SCPUtils.Commands
+{
+ [CommandHandler(typeof(RemoteAdminCommandHandler))]
+ [CommandHandler(typeof(GameConsoleCommandHandler))]
+ public class PlayerUnrestrict : ICommand
+ {
+ public string Command { get; } = "scputils_player_unrestrict";
+
+ public string[] Aliases { get; } = new[] { "unrestrict", "unsusp" };
+
+ public string Description { get; } = "Removes a restriction from a player!";
+
+ public bool Execute(ArraySegment arguments, ICommandSender sender, out string response)
+ {
+ string target;
+ if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.moderatecommands") && !((CommandSender)sender).FullPermissions)
+ {
+ response = " You need a higher administration level to use this command!";
+ return false;
+ }
+
+ else if (arguments.Count < 1)
+ {
+ response = $"Usage: {Command} ";
+ return false;
+ }
+
+
+ else target = arguments.Array[1].ToString();
+
+ var player = Exiled.API.Features.Player.Get(target);
+ var databasePlayer = target.GetDatabasePlayer();
+
+ if (databasePlayer == null)
+ {
+ response = "Player not found on Database or Player is loading data!";
+ return false;
+ }
+
+ else if (!databasePlayer.IsRestricted())
+ {
+ response = "Player is not suspended!";
+ return false;
+ }
+
+ databasePlayer.Restricted.Remove(databasePlayer.Restricted.Keys.Last());
+ Database.LiteDatabase.GetCollection().Update(databasePlayer);
+ response = "Player unsuspended!";
+ return true;
+
+ }
+ }
+}
diff --git a/SCPUtils/Commands/PreferencePersist.cs b/SCPUtils/Commands/PreferencePersist.cs
new file mode 100644
index 0000000..c217399
--- /dev/null
+++ b/SCPUtils/Commands/PreferencePersist.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Linq;
+using CommandSystem;
+
+namespace SCPUtils.Commands
+{
+ [CommandHandler(typeof(RemoteAdminCommandHandler))]
+ [CommandHandler(typeof(GameConsoleCommandHandler))]
+ [CommandHandler(typeof(ClientCommandHandler))]
+ class PreferencePersist : ICommand
+ {
+
+ public string Command { get; } = "scputils_preference_persist";
+
+ public string[] Aliases { get; } = new[] { "pp" };
+
+ public string Description { get; } = "Use this to keep player badge and color even if he doesn't have access to that permission!";
+
+ public bool Execute(ArraySegment arguments, ICommandSender sender, out string response)
+ {
+ string target;
+ if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.keep") && !((CommandSender)sender).FullPermissions)
+ {
+ response = " You need a higher administration level to use this command!";
+ return false;
+ }
+ else
+ {
+ if (arguments.Count < 1)
+ {
+ response = $"Usage: {Command} ";
+ return false;
+ }
+ else target = arguments.Array[1].ToString();
+ }
+ var databasePlayer = target.GetDatabasePlayer();
+
+ if (databasePlayer == null)
+ {
+ response = $"Player not found on Database or Player is loading data!";
+ return false;
+ }
+
+ if (databasePlayer.KeepPreferences == false)
+ {
+ databasePlayer.KeepPreferences = true;
+ Database.LiteDatabase.GetCollection().Update(databasePlayer);
+ response = "Success, keep mode has been enabled!";
+ }
+ else
+ {
+ databasePlayer.KeepPreferences = false;
+ Database.LiteDatabase.GetCollection().Update(databasePlayer);
+ response = "Success, keep mode has been disabled!";
+ }
+
+
+ return true;
+ }
+ }
+}
diff --git a/SCPUtils/Commands/RevokeBadge.cs b/SCPUtils/Commands/RevokeBadge.cs
index fdd53e0..15c3aad 100644
--- a/SCPUtils/Commands/RevokeBadge.cs
+++ b/SCPUtils/Commands/RevokeBadge.cs
@@ -40,7 +40,6 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
return false;
}
- databasePlayer.BadgeName = "";
databasePlayer.BadgeExpire = DateTime.MinValue;
Database.LiteDatabase.GetCollection().Update(databasePlayer);
if (player != null) player.BadgeHidden = false;
diff --git a/SCPUtils/Commands/SetBadge.cs b/SCPUtils/Commands/SetBadge.cs
index 0c3f1c0..bec89cc 100644
--- a/SCPUtils/Commands/SetBadge.cs
+++ b/SCPUtils/Commands/SetBadge.cs
@@ -1,11 +1,12 @@
using System;
using CommandSystem;
+using Log = Exiled.API.Features.Log;
namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
- class SeetBadge : ICommand
+ class SetBadge : ICommand
{
public string Command { get; } = "scputils_set_badge";
@@ -50,17 +51,26 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
else if (int.TryParse(arguments.Array[3], out int duration))
{
+ var group = ServerStatic.GetPermissionsHandler()._groups[badge];
+ if (player != null)
+ {
+ if (string.IsNullOrEmpty(databasePlayer.PreviousBadge) && player.Group != null) databasePlayer.PreviousBadge = player.Group.BadgeText;
+ if (ServerStatic.PermissionsHandler._members.ContainsKey(player.UserId)) ServerStatic.PermissionsHandler._members.Remove(player.UserId);
+ player.ReferenceHub.serverRoles.SetGroup(group, false, true, true);
+ ServerStatic.PermissionsHandler._members.Add(player.UserId, badge);
+ }
+
databasePlayer.BadgeName = badge;
databasePlayer.BadgeExpire = DateTime.Now.AddMinutes(duration);
- Database.LiteDatabase.GetCollection().Update(databasePlayer);
- var group = ServerStatic.GetPermissionsHandler()._groups[badge];
- if(group.KickPower > ((CommandSender)sender).KickPower && !((CommandSender)sender).FullPermissions)
+
+ 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 = $"Successfully setted {group.BadgeText} badge! Duration: {duration} minute(s)!";
+ Database.LiteDatabase.GetCollection().Update(databasePlayer);
+ response = $"Successfully set {group.BadgeText} badge! Duration: {duration} minute(s)!";
+
}
else response = "Arg3 must be integer!";
diff --git a/SCPUtils/Commands/SetColor.cs b/SCPUtils/Commands/SetColor.cs
index a9d9a68..9257273 100644
--- a/SCPUtils/Commands/SetColor.cs
+++ b/SCPUtils/Commands/SetColor.cs
@@ -49,7 +49,14 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
{
target = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId).ToString().Split(new string[] { " " }, StringSplitOptions.None)[2];
color = arguments.Array[1].ToString().ToLower();
- if (!validColors.Contains(color) && !color.Equals("none"))
+
+ if (target.GetDatabasePlayer().IsRestricted())
+ {
+ response = "You are banned from executing this command!";
+ return false;
+ }
+
+ else if (!validColors.Contains(color) && !color.Equals("none"))
{
response = "Invalid color, type color in console to see valid SCP colors";
return false;
diff --git a/SCPUtils/Commands/SetName.cs b/SCPUtils/Commands/SetName.cs
index 0d3fc87..a31d56e 100644
--- a/SCPUtils/Commands/SetName.cs
+++ b/SCPUtils/Commands/SetName.cs
@@ -45,6 +45,11 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
else
{
target = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId).UserId;
+ if (target.GetDatabasePlayer().IsRestricted())
+ {
+ response = "You are banned from executing this command!";
+ return false;
+ }
nickname = string.Join(" ", arguments.Array, 1, arguments.Array.Length - 1);
bool allowChange = true;
foreach (var playerList in Exiled.API.Features.Player.List)
diff --git a/SCPUtils/Commands/ShowCommandBan.cs b/SCPUtils/Commands/ShowCommandBan.cs
new file mode 100644
index 0000000..7079226
--- /dev/null
+++ b/SCPUtils/Commands/ShowCommandBan.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Linq;
+using CommandSystem;
+using Log = Exiled.API.Features.Log;
+
+namespace SCPUtils.Commands
+{
+ [CommandHandler(typeof(RemoteAdminCommandHandler))]
+ [CommandHandler(typeof(GameConsoleCommandHandler))]
+ class ShowCommandBans : ICommand
+ {
+
+ public string Command { get; } = "scputils_show_command_bans";
+
+ public string[] Aliases { get; } = new[] { "scb" };
+
+ public string Description { get; } = "You can see detailed informations about playtime";
+
+ public bool Execute(ArraySegment arguments, ICommandSender sender, out string response)
+ {
+ string target;
+ if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.moderatecommands") && !((CommandSender)sender).FullPermissions)
+ {
+ response = " You need a higher administration level to use this command!";
+ return false;
+ }
+ else
+ {
+ if (arguments.Count < 1)
+ {
+ response = $"Usage: {Command} ";
+ return false;
+ }
+ else target = arguments.Array[1].ToString();
+ }
+ var databasePlayer = target.GetDatabasePlayer();
+
+ if (databasePlayer == null)
+ {
+ response = "Player not found on Database or Player is loading data!";
+ return false;
+ }
+
+ if (databasePlayer == null)
+ {
+ response = "Player not found on Database or Player is loading data!";
+ return false;
+ }
+ string message = $"\n[{databasePlayer.Name} ({databasePlayer.Id}@{databasePlayer.Authentication})]\n\n" +
+ $"Total Command restrictions: [ { databasePlayer.Restricted.Count } ]\n";
+
+
+ if (databasePlayer.IsRestricted()) message += $"*** Active Restrictions: ***\n\n" +
+ $"Reason: [ {databasePlayer.Restricted.Values.Last()} ]\n" +
+ $"Expire: [ {databasePlayer.Restricted.Keys.Last()} ]\n";
+
+ if (databasePlayer.Restricted.Count >= 1)
+ {
+ message += $"\n*** Restrictions History: ***\n\n";
+ foreach (var a in databasePlayer.Restricted)
+ {
+ message += $"Reason: [ {a.Value} ]\n";
+ message += $"Expire: [ {a.Key} ]\n\n";
+ }
+ }
+ else message += "No restrictions!";
+
+ response = $"{message}";
+
+ return true;
+ }
+ }
+}
diff --git a/SCPUtils/Commands/StaffList.cs b/SCPUtils/Commands/StaffList.cs
index 9ef20fe..0add4b0 100644
--- a/SCPUtils/Commands/StaffList.cs
+++ b/SCPUtils/Commands/StaffList.cs
@@ -24,7 +24,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s
foreach (var player in Exiled.API.Features.Player.List)
{
if (player.ReferenceHub.serverRoles.RaEverywhere || player.ReferenceHub.serverRoles.Staff) text += $"(SCP:SL Staff) Player: {player.Nickname} {player.UserId} Global badge: {player.GlobalBadge}\n";
- else if (player.ReferenceHub.serverRoles.RemoteAdmin) text += $"Player: {player.Nickname} {player.UserId} Rank: {player.GroupName}\n";
+ else if (player.ReferenceHub.serverRoles.RemoteAdmin) text += $"Player: {player.Nickname} {player.UserId} Rank: {player.Group.BadgeText}\n";
}
if (text.Equals("Online Staff List:\n")) text = "No staff online!";
response = text;
diff --git a/SCPUtils/Configs.cs b/SCPUtils/Configs.cs
index 5afff52..e012adc 100644
--- a/SCPUtils/Configs.cs
+++ b/SCPUtils/Configs.cs
@@ -50,6 +50,14 @@ public class Configs : IConfig
[Description("Broadcast in admin chat auto warns for quitting or suicide as SCP")]
public bool BroadcastWarns { get; private set; } = false;
+ [Description("Should the nickname gets resetted if the user when joins doesn't have the permission to execute the command? You can bypass it using scputils_preference_persist command")]
+ public bool KeepNameWithoutPermission { get; private set; } = false;
+
+ [Description("Should the color gets resetted if the user when joins doesn't have the permission to execute the command? You can bypass it using scputils_preference_persist command")]
+ public bool KeepColorWithoutPermission { get; private set; } = false;
+
+ [Description("Should the badge visibility gets resetted if the user when joins doesn't have the permission to execute the command? You can bypass it using scputils_preference_persist command")]
+ public bool KeepBadgeVisibilityWithoutPermission { get; private set; } = false;
[Description("Autowarn message for suiciding as SCP")]
public string SuicideWarnMessage { get; private set; } = "WARN:\nAs per server rules SCP's suicide is an offence, doing it too much will result in a ban!";
diff --git a/SCPUtils/Database/Database.cs b/SCPUtils/Database/Database.cs
index 82ed242..f05e135 100644
--- a/SCPUtils/Database/Database.cs
+++ b/SCPUtils/Database/Database.cs
@@ -69,11 +69,14 @@ public void AddPlayer(Exiled.API.Features.Player player)
CustomNickName = "",
BadgeName = "",
BadgeExpire = DateTime.MinValue,
+ PreviousBadge = "",
HideBadge = false,
PlayTimeRecords = null,
- ASNWhitelisted = false
+ ASNWhitelisted = false,
+ Restricted = null,
+ KeepPreferences = false
});
- Log.Info("Trying to add ID: " + player.UserId.Split('@')[0] + " Discriminator: " + player.UserId.Split('@')[1] + " to Database");
+ // Log.Info("Trying to add ID: " + player.UserId.Split('@')[0] + " Discriminator: " + player.UserId.Split('@')[1] + " to Database");
}
catch (Exception ex)
{
diff --git a/SCPUtils/Database/Player.cs b/SCPUtils/Database/Player.cs
index e2b00b6..3d6e8ec 100644
--- a/SCPUtils/Database/Player.cs
+++ b/SCPUtils/Database/Player.cs
@@ -1,4 +1,5 @@
-using System;
+using LiteDB;
+using System;
using System.Collections.Generic;
using Log = Exiled.API.Features.Log;
@@ -20,14 +21,13 @@ public class Player
public bool HideBadge { get; set; }
public string BadgeName { get; set; }
public DateTime BadgeExpire { get; set; }
+ public string PreviousBadge { get; set; }
public Dictionary PlayTimeRecords { get; set; } = new Dictionary();
-
public bool ASNWhitelisted { get; set; }
-
+ public Dictionary Restricted { get; set; } = new Dictionary();
+ public bool KeepPreferences { get; set; }
public float SuicidePercentage => (float)ScpSuicideCount == 0 ? 0 : ((float)ScpSuicideCount / (float)TotalScpGamesPlayed) * 100;
-
-
public void SetCurrentDayPlayTime()
{
if (!PlayTimeRecords.ContainsKey(DateTime.Now.Date.ToShortDateString())) PlayTimeRecords.Add(DateTime.Now.Date.ToShortDateString(), 0);
@@ -44,6 +44,9 @@ public void Reset()
CustomNickName = "";
HideBadge = false;
BadgeName = "";
+ PreviousBadge = "";
+ KeepPreferences = false;
+ PlayTimeRecords.Clear();
}
public void ResetPreferences()
@@ -51,6 +54,16 @@ public void ResetPreferences()
ColorPreference = "";
CustomNickName = "";
HideBadge = false;
+ KeepPreferences = false;
+ }
+
+ public bool IsRestricted()
+ {
+ foreach (var a in Restricted)
+ {
+ if (a.Key >= DateTime.Now) return true;
+ }
+ return false;
}
}
diff --git a/SCPUtils/Functions/EventHandlers.cs b/SCPUtils/Functions/EventHandlers.cs
index a414527..6d86dcd 100644
--- a/SCPUtils/Functions/EventHandlers.cs
+++ b/SCPUtils/Functions/EventHandlers.cs
@@ -15,10 +15,10 @@ 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)
{
@@ -26,7 +26,7 @@ internal void OnPlayerDeath(DyingEventArgs ev)
{
if ((DateTime.Now - lastTeslaEvent).Seconds >= pluginInstance.Config.Scp079TeslaEventWait)
{
- if (ev.HitInformation.GetDamageType() == DamageTypes.Tesla || ( ev.HitInformation.GetDamageType() == DamageTypes.Wall && ev.HitInformation.Amount >= 50000 ) && pluginInstance.Config.QuitEqualsSuicide) pluginInstance.Functions.OnQuitOrSuicide(ev.Target);
+ if (ev.HitInformation.GetDamageType() == DamageTypes.Tesla || (ev.HitInformation.GetDamageType() == DamageTypes.Wall && ev.HitInformation.Amount >= 50000) || (ev.HitInformation.GetDamageType() == DamageTypes.Grenade && ev.Killer == ev.Target) && pluginInstance.Config.QuitEqualsSuicide) pluginInstance.Functions.OnQuitOrSuicide(ev.Target);
}
}
}
@@ -49,12 +49,16 @@ internal void OnPlayerHurt(HurtingEventArgs ev)
}
}
+ internal void Tafazzi(BanningEventArgs ev)
+ {
+ throw new NotImplementedException();
+ }
internal void OnPlayerJoin(JoinedEventArgs ev)
{
if (!Database.LiteDatabase.GetCollection().Exists(player => player.Id == DatabasePlayer.GetRawUserId(ev.Player)))
{
- Log.Info(ev.Player.Nickname + " is not present on DB!");
+ Log.Info(ev.Player.Nickname + " is not present on DB, creating account!");
pluginInstance.DatabasePlayerData.AddPlayer(ev.Player);
}
@@ -65,7 +69,6 @@ internal void OnPlayerJoin(JoinedEventArgs ev)
databasePlayer.Name = ev.Player.Nickname;
if (databasePlayer.FirstJoin == DateTime.MinValue) databasePlayer.FirstJoin = DateTime.Now;
if (pluginInstance.Config.WelcomeEnabled) ev.Player.Broadcast(pluginInstance.Config.WelcomeMessageDuration, pluginInstance.Config.WelcomeMessage, Broadcast.BroadcastFlags.Normal);
- if (!string.IsNullOrEmpty(databasePlayer.CustomNickName) && databasePlayer.CustomNickName != "None") ev.Player.DisplayNickname = databasePlayer.CustomNickName;
if (pluginInstance.Functions.CheckAsnPlayer(ev.Player)) ev.Player.Kick($"Auto-Kick: {pluginInstance.Config.AsnKickMessage}", "SCPUtils");
else pluginInstance.Functions.PostLoadPlayer(ev.Player);
}
diff --git a/SCPUtils/Functions/Functions.cs b/SCPUtils/Functions/Functions.cs
index 4169236..8c38df2 100644
--- a/SCPUtils/Functions/Functions.cs
+++ b/SCPUtils/Functions/Functions.cs
@@ -50,7 +50,7 @@ public void OnQuitOrSuicide(Exiled.API.Features.Player player)
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);
+ LastWarn[player.UserId] = DateTime.Now.AddSeconds(5);
}
public void PostLoadPlayer(Exiled.API.Features.Player player)
@@ -58,6 +58,7 @@ public void PostLoadPlayer(Exiled.API.Features.Player player)
var databasePlayer = player.GetDatabasePlayer();
+
if (!string.IsNullOrEmpty(databasePlayer.BadgeName))
{
Timing.CallDelayed(1f, () =>
@@ -65,30 +66,63 @@ public void PostLoadPlayer(Exiled.API.Features.Player player)
if (databasePlayer.BadgeExpire >= DateTime.Now)
{
var group = ServerStatic.GetPermissionsHandler()._groups[databasePlayer.BadgeName];
+ if (string.IsNullOrEmpty(databasePlayer.PreviousBadge) && player.Group != null && group.BadgeText != player.Group.BadgeText) databasePlayer.PreviousBadge = player.Group.BadgeText;
player.ReferenceHub.serverRoles.SetGroup(group, false, true, true);
+ if (ServerStatic.PermissionsHandler._members.ContainsKey(player.UserId)) ServerStatic.PermissionsHandler._members.Remove(player.UserId);
+ ServerStatic.PermissionsHandler._members.Add(player.UserId, databasePlayer.BadgeName);
}
else
{
databasePlayer.BadgeName = "";
- databasePlayer.ResetPreferences();
+
+ if (!string.IsNullOrEmpty(databasePlayer.PreviousBadge))
+ {
+ var group = ServerStatic.GetPermissionsHandler()._groups[databasePlayer.PreviousBadge];
+ player.ReferenceHub.serverRoles.SetGroup(group, false, true, true);
+ ServerStatic.PermissionsHandler._members.Add(player.UserId, databasePlayer.PreviousBadge);
+ }
+ databasePlayer.PreviousBadge = "";
+ if (!databasePlayer.KeepPreferences) databasePlayer.ResetPreferences();
+
}
});
}
if (!string.IsNullOrEmpty(databasePlayer.ColorPreference) && databasePlayer.ColorPreference != "None")
{
- Timing.CallDelayed(1.15f, () =>
+ if (player.CheckPermission("scputils.changecolor") || player.CheckPermission("scputils.playersetcolor") || databasePlayer.KeepPreferences || pluginInstance.Config.KeepColorWithoutPermission)
{
- player.RankColor = databasePlayer.ColorPreference;
- });
+ Timing.CallDelayed(1.15f, () =>
+ {
+ player.RankColor = databasePlayer.ColorPreference;
+ });
+ }
+ else databasePlayer.ColorPreference = "";
}
if (databasePlayer.HideBadge == true)
{
- Timing.CallDelayed(1.25f, () =>
+ if (player.CheckPermission("scputils.badgevisibility") || databasePlayer.KeepPreferences || pluginInstance.Config.KeepBadgeVisibilityWithoutPermission)
{
- player.BadgeHidden = true;
- });
+ Timing.CallDelayed(1.25f, () =>
+ {
+ player.BadgeHidden = true;
+ });
+ }
+ else databasePlayer.HideBadge = false;
+ }
+
+
+ if (!string.IsNullOrEmpty(databasePlayer.CustomNickName) && databasePlayer.CustomNickName != "None")
+ {
+ if (player.CheckPermission("scputils.changenickname") || player.CheckPermission("scputils.playersetname") || databasePlayer.KeepPreferences || pluginInstance.Config.KeepNameWithoutPermission)
+ {
+ Timing.CallDelayed(1.35f, () =>
+ {
+ player.DisplayNickname = databasePlayer.CustomNickName;
+ });
+ }
+ else databasePlayer.CustomNickName = "";
}
if (pluginInstance.Config.AutoKickBannedNames && pluginInstance.Functions.CheckNickname(player.Nickname) && !player.CheckPermission("scputils.bypassnickrestriction"))
@@ -120,10 +154,17 @@ public void SaveData(Exiled.API.Features.Player player)
{
if (pluginInstance.Config.EnableSCPSuicideAutoWarn && pluginInstance.Config.QuitEqualsSuicide) pluginInstance.Functions.OnQuitOrSuicide(player);
}
- player.GetDatabasePlayer().SetCurrentDayPlayTime();
+ var databasePlayer = player.GetDatabasePlayer();
+ databasePlayer.SetCurrentDayPlayTime();
+
+ if (!string.IsNullOrEmpty(databasePlayer.BadgeName))
+ {
+ if (ServerStatic.PermissionsHandler._members.ContainsKey(player.UserId)) ServerStatic.PermissionsHandler._members.Remove(player.UserId);
+ }
+
Database.LiteDatabase.GetCollection().Update(Database.PlayerData[player]);
Database.PlayerData.Remove(player);
- Log.Debug($"Saving data of {player.Nickname}");
+ // Log.Debug($"Saving data of {player.Nickname}");
}
}
diff --git a/SCPUtils/Plugin.cs b/SCPUtils/Plugin.cs
index 7fb5e63..b5da44f 100644
--- a/SCPUtils/Plugin.cs
+++ b/SCPUtils/Plugin.cs
@@ -14,11 +14,11 @@ public class ScpUtils : Features.Plugin
{
private static readonly Lazy LazyInstance = new Lazy(() => new ScpUtils());
public static ScpUtils StaticInstance => LazyInstance.Value;
- public static string pluginVersion = "2.3.6";
- public override string Author { get; } = "Terminator_9#0507";
+ public static string pluginVersion = "2.4.0";
+ public override string Author { get; } = "Terminator_97#0507";
public override string Name { get; } = "SCPUtils";
- public override Version Version { get; } = new Version(2, 3, 6);
- public override Version RequiredExiledVersion { get; } = new Version(2, 1, 8);
+ public override Version Version { get; } = new Version(2, 4, 0);
+ public override Version RequiredExiledVersion { get; } = new Version(2, 1, 22);
public EventHandlers EventHandlers { get; private set; }
public Functions Functions { get; private set; }
public Player Player { get; private set; }
@@ -43,7 +43,7 @@ public void LoadEvents()
Exiled.Events.Handlers.Scp079.InteractingTesla += EventHandlers.On079TeslaEvent;
ServerEvents.WaitingForPlayers += EventHandlers.OnWaitingForPlayers;
ServerEvents.RoundEnded += EventHandlers.OnRoundEnded;
-
+
}
public override void OnEnabled()
diff --git a/SCPUtils/SCPUtils.csproj b/SCPUtils/SCPUtils.csproj
index 92f1e7c..ed33593 100644
--- a/SCPUtils/SCPUtils.csproj
+++ b/SCPUtils/SCPUtils.csproj
@@ -35,7 +35,7 @@
False
- ..\..\..\..\..\release\Exiled\EXILED\Plugins\dependencies\0Harmony.dll
+ ..\..\..\..\..\NewExiled\Exiled\EXILED\Plugins\dependencies\0Harmony.dll
False
@@ -49,21 +49,24 @@
False
..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\CommandSystem.Core.dll
-
+
False
..\..\..\..\..\NewExiled\Exiled\EXILED\Plugins\dependencies\Exiled.API.dll
-
- False
- ..\..\..\..\..\NewExiled\Exiled\EXILED\Plugins\Exiled.Events.dll
+
+ ..\packages\EXILED.2.1.22\lib\net472\Exiled.Bootstrap.dll
-
- False
- ..\..\..\..\..\NewExiled\Exiled\EXILED\Exiled.Loader.dll
+
+ ..\packages\EXILED.2.1.22\lib\net472\Exiled.Events.dll
-
- False
- ..\..\..\..\..\NewExiled\Exiled\EXILED\Plugins\Exiled.Permissions.dll
+
+ ..\packages\EXILED.2.1.22\lib\net472\Exiled.Loader.dll
+
+
+ ..\packages\EXILED.2.1.22\lib\net472\Exiled.Permissions.dll
+
+
+ ..\packages\EXILED.2.1.22\lib\net472\Exiled.Updater.dll
..\packages\LiteDB.5.0.9\lib\net45\LiteDB.dll
@@ -87,12 +90,15 @@
False
- ..\..\..\..\..\release\Exiled\EXILED\Plugins\dependencies\YamlDotNet.dll
+ ..\..\..\..\..\NewExiled\Exiled\EXILED\Plugins\dependencies\YamlDotNet.dll
+
+
+
@@ -105,6 +111,7 @@
+
@@ -130,6 +137,7 @@
+
SettingsSingleFileGenerator
diff --git a/SCPUtils/app.config b/SCPUtils/app.config
new file mode 100644
index 0000000..f0f1284
--- /dev/null
+++ b/SCPUtils/app.config
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SCPUtils/packages.config b/SCPUtils/packages.config
index b20a045..f9d85db 100644
--- a/SCPUtils/packages.config
+++ b/SCPUtils/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file