Skip to content

Commit

Permalink
2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
terminator-97 committed Aug 27, 2020
1 parent 5dac7ef commit 00ee4f0
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 12 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This is the list of SCPUtils features with a brief description, i recomend to re

**Database will get created inside Exiled/SCPUtils folder.**<br /><br />
**You must add LiteDB.dll into Plugins/dependencies folder or plugin won't work**<br /><br />
**Minimum requirements: Exiled version: 2.0.10 and LiteDB 5.0.8**
**Minimum requirements: Exiled version: 2.1.2 and LiteDB 5.0.8**

### Configs:

Expand All @@ -46,7 +46,10 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex
| scputils_unwhitelist_asn | <id / userid> | scputils.whitelist | Removes player to ASN whitelist |
| scputils_staff_list | - | scputils.stafflist | Show both local staff and global staff present in game |
| scputils_enable_suicide_warns | - | scputils.warnmanagement | Enabled previously disabled suicide / quits warns |
| scputils_disable_suicide_warns | - | scputils.warnmanagement | Disable suicides / quits warns for the rest of the round |
| scputils_disable_suicide_warns | - | scputils.warnmanagement | Disable suicides / quits warns for the rest of the round |
| scputils_global_edit | <Total SCP Games to remove> <Suicides/Quits to remove> <Kicks to remove> <Bans to remove> | scputils.globaledit | Globally edits player stats (removes total scp games/suicides/kicks/bans) |
| scputils_player_edit | <id / userid> <Total SCP Games> <Suicides/Quits> <Kicks> <Bans>| scputils.playeredit | Edits player stats (total scp games/suicides/kicks/bans) by setting them to specified amount |
| scputils_player_delete | <userid / id> | scputils.playerdelete | Deletes a player from db, action is irreversible, do this when player is not in server. |

**Console commands**

Expand Down Expand Up @@ -98,7 +101,8 @@ To edit your configs you must go into EXILED folder and edit port-config.yml fil
- scputils_speak.scp049
owner:
permissions:
- '*'
- scputils.*
- scputils_speak.*
admin:
inheritance: []
permissions:
Expand Down
60 changes: 60 additions & 0 deletions SCPUtils/Commands/GlobalEdit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using CommandSystem;
using UnityEngine;

namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
class GlobalEdit : ICommand
{

public string Command { get; } = "scputils_global_edit";

public string[] Aliases { get; } = new[] { "gedit" };

public string Description { get; } = "Remove specified amount of scp games / warns / kick / bans from each player present in DB!";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.globaledit") && !((CommandSender)sender).FullPermissions)
{
response = "<color=red>You need a higher administration level to use this command!</color>";
return false;
}
else
{
if (arguments.Count < 4)
{
response = $"<color=yellow>Usage: {Command} <SCPGames to remove> <Suicides to remove> <Kicks to remove> <Bans to remove></color>";
return false;
}
}

if (int.TryParse(arguments.Array[1].ToString(), out int scpGamesToRemove) && int.TryParse(arguments.Array[2].ToString(), out int suicidesToRemove) && int.TryParse(arguments.Array[3].ToString(), out int kicksToRemove) && int.TryParse(arguments.Array[4].ToString(), out int bansToRemove))
{
foreach (var databasePlayer in Database.LiteDatabase.GetCollection<Player>().Find(x => x.ScpSuicideCount >= 1))
{
if (databasePlayer.TotalScpGamesPlayed >= scpGamesToRemove) databasePlayer.TotalScpGamesPlayed -= scpGamesToRemove;
else databasePlayer.TotalScpGamesPlayed = 0;
if (databasePlayer.ScpSuicideCount >= suicidesToRemove) databasePlayer.ScpSuicideCount -= suicidesToRemove;
else databasePlayer.ScpSuicideCount = 0;
if (databasePlayer.TotalScpSuicideKicks >= kicksToRemove) databasePlayer.TotalScpSuicideKicks -= kicksToRemove;
else databasePlayer.TotalScpSuicideKicks = 0;
if (databasePlayer.TotalScpSuicideBans >= bansToRemove) databasePlayer.TotalScpSuicideBans -= bansToRemove;
else databasePlayer.TotalScpSuicideBans = 0;
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);
}
}

else
{
response = $"One or more arguments are not an integer, Command usage example: {Command} 4 2 1 3";
return false;
}

response = $"Success, the following edits have been made globally: Removed: {scpGamesToRemove} SCP Game(s), {suicidesToRemove} Suicide(s), {kicksToRemove} Kick(s), {bansToRemove} Ban(s) to each player!";
return true;
}
}
}
2 changes: 1 addition & 1 deletion SCPUtils/Commands/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
text = $"<color=#1BBC9B>User commands:</color> \n" +
"<color=#1BBC9B>.scputils_info, .scputils_change_nickname, .scputils_change_color, .scputils_show_badge, .scputils_hide_badge, .scputils_my_info</color>";
if (CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.help") && ((CommandSender)sender).FullPermissions) text += "\n<color=#FFD700>Administration commands (Remote Admin): </color>\n" +
"<color=#FFD700>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</color>";
"<color=#FFD700>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</color>";
response = text;
return true;
}
Expand Down
51 changes: 51 additions & 0 deletions SCPUtils/Commands/PlayerDelete.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using CommandSystem;

namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
public class PlayerDelete : ICommand
{

public string Command { get; } = "scputils_player_delete";

public string[] Aliases { get; } = new[] { "pdelete" };

public string Description { get; } = "Delete a player (and all the player data) from the database, action is irreversible!";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{

if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playerdelete") && !((CommandSender)sender).FullPermissions)
{
response = "<color=red> You need a higher administration level to use this command!</color>";
return false;
}
else if (arguments.Count < 1)
{
response = $"<color=red>Usage: {Command} <player name/id> (You will delete the player from the database)</color>";
return false;
}
else
{
var target = arguments.Array[1].ToString();

var databasePlayer = target.GetDatabasePlayer();

if (databasePlayer == null)
{
response = "<color=yellow>Player not found on Database or Player is loading data!</color>";
return false;
}

databasePlayer.Reset();
Database.LiteDatabase.GetCollection<Player>().Delete(databasePlayer.Id);
response = $"{target} has been deleted from the database!";

return true;
}
}
}
}

65 changes: 65 additions & 0 deletions SCPUtils/Commands/PlayerEdit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using CommandSystem;

namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
public class PlayerEdit : ICommand
{

public string Command { get; } = "scputils_player_edit";

public string[] Aliases { get; } = new[] { "pedit" };

public string Description { get; } = "Edits the specified player data!";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{

if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playeredit") && !((CommandSender)sender).FullPermissions)
{
response = "<color=red> You need a higher administration level to use this command!</color>";
return false;
}
else if (arguments.Count < 5)
{
response = $"<color=red>Usage: {Command} <player name/id> <Total SCPGames played> <Total suicides/quits as SCP> <Total kicks> <Total bans></color>";
return false;
}
else
{
var target = arguments.Array[1].ToString();

var databasePlayer = target.GetDatabasePlayer();

if (databasePlayer == null)
{
response = "<color=yellow>Player not found on Database or Player is loading data!</color>";
return false;
}


if (int.TryParse(arguments.Array[2].ToString(), out int totalSCPGames) && int.TryParse(arguments.Array[3].ToString(), out int totalSCPSuicides) && int.TryParse(arguments.Array[4].ToString(), out int totalSCPKicks) && int.TryParse(arguments.Array[5].ToString(), out int totalSCPBans))
{

databasePlayer.TotalScpGamesPlayed = totalSCPGames;
databasePlayer.ScpSuicideCount = totalSCPSuicides;
databasePlayer.TotalScpSuicideKicks = totalSCPKicks;
databasePlayer.TotalScpSuicideBans = totalSCPBans;
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);
}

else
{
response = $"One or more arguments are not an integer, Command usage example: {Command} 76561198347253445@steam 25 3 0 1";
return false;
}

response = $"Success, {target} has been edited as follows: Total SCP Games Played: {totalSCPGames}, Total Suicides/Quits: {totalSCPSuicides}, Total Kicks: {totalSCPKicks}, Total Bans: {totalSCPBans}";
return true;
}
}
}
}

2 changes: 1 addition & 1 deletion SCPUtils/Commands/PlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s

if (databasePlayer == null)
{
response = $"<color=yellow>Player not found on Database or Player is loading data! ({target})</color>";
response = $"<color=yellow>Player not found on Database or Player is loading data!</color>";
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion SCPUtils/Commands/StaffList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
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";
}
if (string.IsNullOrEmpty(text)) text = "No staff online!";
if (text.Equals("Online Staff List:\n")) text = "No staff online!";
response = text;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion SCPUtils/Functions/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class EventHandlers
{
private readonly ScpUtils pluginInstance;

public DateTime lastTeslaEvent;
public DateTime lastTeslaEvent;

public static bool TemporarilyDisabledWarns;

Expand Down
4 changes: 2 additions & 2 deletions SCPUtils/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ 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.2";
public static string pluginVersion = "2.3.3";
public override string Author { get; } = "Terminator_9#0507";
public override string Name { get; } = "SCPUtils";
public override Version Version { get; } = new Version(2, 3, 2);
public override Version Version { get; } = new Version(2, 3, 3);
public override Version RequiredExiledVersion { get; } = new Version(2, 1, 2);
public EventHandlers EventHandlers { get; private set; }
public Functions Functions { get; private set; }
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.2")]
[assembly: AssemblyDescription("SCPUtils 2.3.3")]
[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.2.0")]
[assembly: AssemblyFileVersion("2.3.2.0")]
[assembly: AssemblyVersion("2.3.3.0")]
[assembly: AssemblyFileVersion("2.3.3.0")]
3 changes: 3 additions & 0 deletions SCPUtils/SCPUtils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@
<ItemGroup>
<Compile Include="Commands\AsnUnwhitelist.cs" />
<Compile Include="Commands\AsnWhitelist.cs" />
<Compile Include="Commands\PlayerDelete.cs" />
<Compile Include="Commands\DisableSuicideWarn.cs" />
<Compile Include="Commands\EnableSuicideWarn.cs" />
<Compile Include="Commands\GlobalEdit.cs" />
<Compile Include="Commands\PlayerEdit.cs" />
<Compile Include="Commands\PlayerReset.cs" />
<Compile Include="Commands\PlayerResetPreferences.cs" />
<Compile Include="Commands\PlayTime.cs" />
Expand Down

0 comments on commit 00ee4f0

Please sign in to comment.