Skip to content

Commit

Permalink
3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
terminator-97 committed Sep 1, 2021
1 parent f58070a commit 6a9c4b5
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 124 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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 />
**Each server must have it's own database, you cannot use one database on multiple servers!**<br /><br />
**You must add LiteDB.dll into Plugins/dependencies folder or plugin won't work**<br /><br />
**Minimum requirements: Exiled version: 3.0.0.alpha76 and LiteDB 5.0.9**
**Minimum requirements: Exiled version: 3.0.0.alpha77 and LiteDB 5.0.9**


### Configs:
Expand Down Expand Up @@ -67,6 +67,8 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex
| scputils_player_unwarn | <userid / id> <warn id> | scputils.unwarn | Removes a specific warning from a user |
| scputils_player_broadcast | <userid / id> <broadcast/hint> <text> | scputils.broadcast | Send an hint or broadcast to a specific player |
| scputils_broadcast | <broadcast/hint> <text> | scputils.broadcast | Send an hint or broadcast to all players |
| scputils_set_round_ban | <id / userid> <amount> | scputils.roundban | Sets the number of round ban to one player |
| scputils_dupeip | < id / userid > | scputils.dupeip | Check if player has another account on same IP |

**Console commands**

Expand Down
4 changes: 0 additions & 4 deletions SCPUtils/Commands/Convert.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using CommandSystem;
using Exiled.API.Features;
using Exiled.Permissions.Extensions;
using LiteDB;
using System;
using System.Collections.Generic;
using System.Text;

//Command is here in case if you need convert playtime of all players inside database, you must edit the code for your needs. (example: if you change time format in the vps), this this is a DIY, to recompile the plugin you need publicized assembly c# and you must allow unsafe code.
//Before doing anything make a copy of your database
Expand Down
10 changes: 4 additions & 6 deletions SCPUtils/Commands/Dupeip.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using CommandSystem;
using Exiled.Permissions.Extensions;
using System;
using System.Linq;
using System.Text;
using CommandSystem;
using Exiled.API.Features;
using Exiled.Permissions.Extensions;
using UnityEngine;

namespace SCPUtils.Commands
{
Expand Down Expand Up @@ -44,7 +42,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
message.AppendLine();
message.Append(
$"Player: <color=yellow>{ips.Name} ({ips.Id}{ips.Authentication})</color>\nFirst Join: <color=yellow>{ips.FirstJoin}</color>\nIsRestricted: <color=yellow>{ips.IsRestricted()}</color>\nIsBanned: <color=yellow>{ips.IsBanned()}</color>\nTotal played as SCP: <color=yellow>{ips.TotalScpGamesPlayed}</color>\nTotal suicide: <color=yellow>{ips.ScpSuicideCount}</color>")
$"Player: <color=yellow>{ips.Name} ({ips.Id}{ips.Authentication})</color>\nFirst Join: <color=yellow>{ips.FirstJoin}</color>\nLast seen: <color=yellow>{ips.LastSeen}</color>\nIsRestricted: <color=yellow>{ips.IsRestricted()}</color>\nIsBanned: <color=yellow>{ips.IsBanned()}</color>\nTotal played as SCP: <color=yellow>{ips.TotalScpGamesPlayed}</color>\nTotal suicide: <color=yellow>{ips.ScpSuicideCount}</color>\nRound(s) ban left: <color=yellow>{ips.RoundBanLeft}</color>")
.AppendLine();

}
Expand Down
4 changes: 2 additions & 2 deletions SCPUtils/Commands/HideBadge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
else
{
Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId);
player.BadgeHidden = true;
player.BadgeHidden = true;
player.GetDatabasePlayer().HideBadge = true;
response = "<color=green>Your badge has been hidden!</color>";
response = "<color=green>Your badge has been hidden!</color>";
return true;
}
}
Expand Down
30 changes: 15 additions & 15 deletions SCPUtils/Commands/PlaySessions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
}

if (arguments.Count < 2)
{
response = $"<color=yellow>Usage: {Command} <player name/id> <number of previous sessions to print(0 prints the last one)> </color>";
return false;
}
else
{
target = arguments.Array[1].ToString();
}
{
response = $"<color=yellow>Usage: {Command} <player name/id> <number of previous sessions to print(0 prints the last one)> </color>";
return false;
}
else
{
target = arguments.Array[1].ToString();
}

int.TryParse(arguments.Array[2], out range);

int.TryParse(arguments.Array[2], out range);


Player databasePlayer = target.GetDatabasePlayer();

if (databasePlayer == null)
Expand All @@ -63,15 +63,15 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
}
StringBuilder message = new StringBuilder($"[{databasePlayer.Name} ({databasePlayer.Id}@{databasePlayer.Authentication})]");
message.AppendLine();


for (int i = 0; i <= range; i++)
{
if(databasePlayer.PlaytimeSessionsLog.Count()-i-1>=0)
if (databasePlayer.PlaytimeSessionsLog.Count() - i - 1 >= 0)
{
var session = databasePlayer.PlaytimeSessionsLog.ElementAt(databasePlayer.PlaytimeSessionsLog.Count()-i-1);
message.AppendLine($"Session Start: [ {session.Key} ] - Session End: [ { session.Value} ] - Duration: [ {(session.Value-session.Key).ToString(@"hh\:mm\:ss")} ]");
}
var session = databasePlayer.PlaytimeSessionsLog.ElementAt(databasePlayer.PlaytimeSessionsLog.Count() - i - 1);
message.AppendLine($"Session Start: [ {session.Key} ] - Session End: [ { session.Value} ] - Duration: [ {(session.Value - session.Key).ToString(@"hh\:mm\:ss")} ]");
}
else
{
message.Append($"Limit reached! No more data about this player.");
Expand Down
1 change: 0 additions & 1 deletion SCPUtils/Commands/PlayerBroadcast.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CommandSystem;
using Exiled.Permissions.Extensions;
using System;
using Exiled.API.Features;

namespace SCPUtils.Commands
{
Expand Down
4 changes: 4 additions & 0 deletions SCPUtils/Commands/PlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
text += $"\n<color=red>User account is currently restricted</color>\nReason: [ {databasePlayer.Restricted.Values.Last()} ]\nExpire: [ {databasePlayer.Restricted.Keys.Last()} ]";
}

if (databasePlayer.RoundBanLeft >= 1)
{
text += $"\n<color=red>User account is currently SCP-Banned:</color>\nRound(s) left: [ {databasePlayer.RoundBanLeft} ]";
}
response = text;

return true;
Expand Down
4 changes: 2 additions & 2 deletions SCPUtils/Commands/SetBadge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
BadgeSetEvent args = new BadgeSetEvent();
args.Player = player;
args.NewBadgeName = badge;
args.NewBadgeName = badge;


if (ServerStatic.PermissionsHandler._members.ContainsKey(player.UserId))
{
Expand Down
61 changes: 61 additions & 0 deletions SCPUtils/Commands/SetRoundBan.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using CommandSystem;
using Exiled.Permissions.Extensions;
using System;
using System.Collections.Generic;

namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
internal class SetRoundBan : ICommand
{
public string Command { get; } = "scputils_set_round_ban";

public string[] Aliases { get; } = new[] { "srb", "roundban", "su_srb", "su_roundban" };

public string Description { get; } = "Sets the number of round ban to one player";

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

if (!sender.CheckPermission("scputils.roundban"))
{
response = "<color=red> You need a higher administration level to use this command!</color>";
return false;


}

if (arguments.Count < 2)
{
response = $"<color=yellow>Usage: {Command} <player name/id> <Round bans to set> </color>";
return false;
}
else target = arguments.Array[1].ToString();


Player databasePlayer = target.GetDatabasePlayer();

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

if (int.TryParse(arguments.Array[2].ToString(), out int rounds))
{
databasePlayer.RoundBanLeft = rounds;
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);
response = "Success!";
return true;
}

else
{
response = "Number of rounds must be an integer!";
return false;
}
}
}
}
4 changes: 2 additions & 2 deletions SCPUtils/Commands/ShowBadge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
else
{
Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId);
player.BadgeHidden = false;
player.GetDatabasePlayer().HideBadge = false;
player.BadgeHidden = false;
player.GetDatabasePlayer().HideBadge = false;
response = "<color=green>Your badge has been shown!</color>";
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion SCPUtils/Commands/ShowWarn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
message.AppendLine($"Class: {databasePlayer.SuicideScp[databasePlayer.SuicideScp.Count - 1]}");
message.AppendLine($"Punishment: {databasePlayer.SuicidePunishment[databasePlayer.SuicidePunishment.Count - 1]}");
message.AppendLine($"Staffer: {databasePlayer.LogStaffer[databasePlayer.LogStaffer.Count - 1]}");
if(databasePlayer.SuicidePunishment[databasePlayer.SuicidePunishment.Count - 1] == "Ban") message.AppendLine($"Expire: {databasePlayer.Expire[databasePlayer.Expire.Count - 1]}");
if (databasePlayer.SuicidePunishment[databasePlayer.SuicidePunishment.Count - 1] == "Ban") message.AppendLine($"Expire: {databasePlayer.Expire[databasePlayer.Expire.Count - 1]}");
if (databasePlayer.SuicidePunishment[databasePlayer.SuicidePunishment.Count - 1] == "Round-Ban") message.AppendLine($"Round(s) ban: {databasePlayer.RoundsBan[databasePlayer.RoundsBan.Count - 1]}");
message.AppendLine($"Expire: {databasePlayer.Expire[databasePlayer.Expire.Count - 1]}");
message.AppendLine($"User Notified: {databasePlayer.UserNotified[databasePlayer.UserNotified.Count - 1]}");
message.AppendLine();
Expand Down
3 changes: 2 additions & 1 deletion SCPUtils/Commands/ShowWarns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
message.AppendLine($"Class: {databasePlayer.SuicideScp[currentindex]}");
message.AppendLine($"Punishment: {databasePlayer.SuicidePunishment[currentindex]}");
message.AppendLine($"Staffer: {databasePlayer.LogStaffer[currentindex]}");
if(databasePlayer.SuicidePunishment[currentindex] == "Ban") message.AppendLine($"Expire: {databasePlayer.Expire[currentindex]}");
if (databasePlayer.SuicidePunishment[currentindex] == "Ban") message.AppendLine($"Expire: {databasePlayer.Expire[currentindex]}");
if (databasePlayer.SuicidePunishment[currentindex] == "Round-Ban") message.AppendLine($"Round(s) ban: {databasePlayer.RoundsBan[currentindex]}");
message.AppendLine($"User Notified: {databasePlayer.UserNotified[currentindex]}");
message.AppendLine();
currentindex++;
Expand Down
21 changes: 17 additions & 4 deletions SCPUtils/Commands/Unwarn.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using CommandSystem;
using Exiled.Permissions.Extensions;
using System;
using Log = Exiled.API.Features.Log;

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

Expand All @@ -22,7 +20,8 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
string target;
if (!sender.CheckPermission("scputils.unwarn"))
{
target = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId).ToString().Split(new string[] { " " }, StringSplitOptions.None)[2];
response = "You need a higher administration level to use this command!";
return false;
}
else
{
Expand Down Expand Up @@ -85,7 +84,21 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
BanHandler.RemoveBan($"{databasePlayer.Id}@{databasePlayer.Authentication}", BanHandler.BanType.UserId);
BanHandler.RemoveBan(databasePlayer.Ip, BanHandler.BanType.IP);
}
}
break;
case "Round-Ban":
databasePlayer.ScpSuicideCount--;
databasePlayer.TotalScpSuicideBans--;
databasePlayer.SuicidePunishment[id] = "REMOVED";
databasePlayer.LogStaffer[id] = sender.LogName;
databasePlayer.UserNotified[id] = true;

databasePlayer.RoundBanLeft -= databasePlayer.RoundsBan[id];
if (databasePlayer.RoundBanLeft < 0) databasePlayer.RoundBanLeft = 0;


Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);

break;
case "REMOVED":
message = "This sanction has already been removed!";
Expand Down
Loading

0 comments on commit 6a9c4b5

Please sign in to comment.