-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dac7ef
commit 00ee4f0
Showing
11 changed files
with
195 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters