-
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
94a5c79
commit 59eede6
Showing
23 changed files
with
481 additions
and
82 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
string target; | ||
string reason; | ||
if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.moderatecommands") && !((CommandSender)sender).FullPermissions) | ||
{ | ||
response = "<color=red> You need a higher administration level to use this command!</color>"; | ||
return false; | ||
} | ||
|
||
else if (arguments.Count < 3) | ||
{ | ||
response = $"Usage: {Command} <player name / id> <Minutes, 0 = permanent> <Reason>"; | ||
return false; | ||
} | ||
target = arguments.Array[1].ToString(); | ||
|
||
var player = Exiled.API.Features.Player.Get(target); | ||
var databasePlayer = target.GetDatabasePlayer(); | ||
|
||
if (databasePlayer == null) | ||
{ | ||
response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; | ||
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<Player>().Update(databasePlayer); | ||
response = $"Player suspended!"; | ||
|
||
} | ||
else response = "Duration must be integer!"; | ||
|
||
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,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<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
string target; | ||
if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.moderatecommands") && !((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 = $"Usage: {Command} <player name/id>"; | ||
return false; | ||
} | ||
|
||
|
||
else target = arguments.Array[1].ToString(); | ||
|
||
var player = Exiled.API.Features.Player.Get(target); | ||
var databasePlayer = target.GetDatabasePlayer(); | ||
|
||
if (databasePlayer == null) | ||
{ | ||
response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; | ||
return false; | ||
} | ||
|
||
else if (!databasePlayer.IsRestricted()) | ||
{ | ||
response = "Player is not suspended!"; | ||
return false; | ||
} | ||
|
||
databasePlayer.Restricted.Remove(databasePlayer.Restricted.Keys.Last()); | ||
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer); | ||
response = "Player unsuspended!"; | ||
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,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<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
string target; | ||
if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.keep") && !((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=yellow>Usage: {Command} <player name/id></color>"; | ||
return false; | ||
} | ||
else 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 (databasePlayer.KeepPreferences == false) | ||
{ | ||
databasePlayer.KeepPreferences = true; | ||
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer); | ||
response = "Success, keep mode has been enabled!"; | ||
} | ||
else | ||
{ | ||
databasePlayer.KeepPreferences = false; | ||
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer); | ||
response = "Success, keep mode has been disabled!"; | ||
} | ||
|
||
|
||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.