From deed1ced7156aec23d7bc48b2c6c7b4d552cfe26 Mon Sep 17 00:00:00 2001 From: UserR00T Date: Sun, 24 Mar 2019 10:46:31 +0100 Subject: [PATCH] Resolved tab spacing issues --- source/BP-Essentials/Chat/Announce.cs | 86 ++-- .../Chat/Commands/Admin/Arrest.cs | 34 +- .../BP-Essentials/Chat/Commands/Admin/Back.cs | 28 +- .../BP-Essentials/Chat/Commands/Admin/Ban.cs | 44 +- .../Chat/Commands/Admin/CheckAlts.cs | 90 ++-- .../Chat/Commands/Admin/Clear.cs | 44 +- .../Chat/Commands/Admin/ClearWanted.cs | 30 +- .../Chat/Commands/Admin/CreateKit.cs | 20 +- .../Chat/Commands/Admin/CreateWarp.cs | 36 +- .../Chat/Commands/Admin/DebugCommands.cs | 220 ++++----- .../Chat/Commands/Admin/FakeJoin.cs | 20 +- .../Chat/Commands/Admin/FakeLeave.cs | 20 +- .../BP-Essentials/Chat/Commands/Admin/Feed.cs | 20 +- .../BP-Essentials/Chat/Commands/Admin/Free.cs | 34 +- .../BP-Essentials/Chat/Commands/Admin/Give.cs | 52 +-- .../Chat/Commands/Admin/GodMode.cs | 54 +-- .../BP-Essentials/Chat/Commands/Admin/Heal.cs | 20 +- .../BP-Essentials/Chat/Commands/Admin/Info.cs | 62 +-- .../BP-Essentials/Chat/Commands/Admin/Kill.cs | 34 +- .../Chat/Commands/Admin/Knockout.cs | 34 +- .../Chat/Commands/Admin/LatestVoteResults.cs | 20 +- .../Chat/Commands/Admin/Launch.cs | 30 +- .../Chat/Commands/Admin/Money.cs | 64 +-- .../BP-Essentials/Chat/Commands/Admin/Mute.cs | 58 +-- .../Chat/Commands/Admin/Promote.cs | 44 +- .../Chat/Commands/Admin/RepairVehicle.cs | 28 +- .../Chat/Commands/Admin/Restrain.cs | 42 +- .../BP-Essentials/Chat/Commands/Admin/Say.cs | 26 +- .../Chat/Commands/Admin/Search.cs | 62 +-- .../BP-Essentials/Chat/Commands/Admin/Slap.cs | 40 +- .../BP-Essentials/Chat/Commands/Admin/Snap.cs | 22 +- .../Chat/Commands/Admin/SpawnVehicle.cs | 70 +-- .../Chat/Commands/Admin/Strip.cs | 64 +-- .../BP-Essentials/Chat/Commands/Admin/Sudo.cs | 42 +- .../Chat/Commands/Admin/ToggleStaffChat.cs | 40 +- .../BP-Essentials/Chat/Commands/Admin/Tp.cs | 40 +- .../Chat/Commands/Admin/TpHere.cs | 38 +- .../Chat/Commands/Admin/TpJob.cs | 42 +- .../Chat/Commands/Admin/TpLocation.cs | 4 +- .../Chat/Commands/Admin/TpToApartment.cs | 8 +- .../BP-Essentials/Chat/Commands/Admin/Wipe.cs | 6 +- .../Chat/Commands/Admin/_SetJob.cs | 74 +-- .../Chat/Commands/Everyone/ClearChat.cs | 42 +- .../Chat/Commands/Everyone/Confirm.cs | 5 + .../Chat/Commands/Everyone/Essentials.cs | 54 +-- .../Chat/Commands/Everyone/GetKit.cs | 2 +- .../Chat/Commands/Everyone/GoToWarp.cs | 2 +- .../Chat/Commands/Everyone/Home.cs | 2 +- .../Chat/Commands/Everyone/Me.cs | 26 +- .../Chat/Commands/Everyone/OnlinePlayers.cs | 8 +- .../Chat/Commands/Everyone/Pay.cs | 86 ++-- .../Chat/Commands/Everyone/ReplyUser.cs | 4 +- .../Chat/Commands/Everyone/Report.cs | 82 ++-- .../Chat/Commands/Everyone/ToggleChat.cs | 4 +- .../Chat/Commands/Everyone/TpaUser.cs | 10 +- source/BP-Essentials/Chat/LangAndChatBlock.cs | 2 +- source/BP-Essentials/Core.cs | 108 ++--- source/BP-Essentials/ExtensionMethods.cs | 72 +-- source/BP-Essentials/HookChat.cs | 100 ++-- source/BP-Essentials/HookMethods.cs | 344 +++++++------- .../Methods/Check/CheckBanned.cs | 30 +- .../FileHandler/CheckAutoReloadFile.cs | 10 +- .../Methods/FileHandler/CheckFiles.cs | 12 +- .../FileHandler/ExpandableFileHandler.cs | 232 +++++----- .../Methods/FileHandler/KitsHandler.cs | 48 +- .../Methods/FileHandler/ReadFile.cs | 298 ++++++------ .../Methods/FileHandler/ReadFileStream.cs | 12 +- .../Methods/FileHandler/ReadGroups.cs | 18 +- .../Methods/FileHandler/RegisterCommands.cs | 2 +- .../Methods/FileHandler/WarpsHandler.cs | 68 +-- .../Methods/GameMethods/CleanupApartment.cs | 4 +- .../Methods/GameMethods/SetJob.cs | 4 +- .../Methods/GameMethods/UnRestrain.cs | 4 +- .../Methods/Utils/FunctionMenu.cs | 434 +++++++++--------- .../BP-Essentials/Methods/Utils/HandleSpam.cs | 66 +-- .../BP-Essentials/Methods/Utils/IsJailed.cs | 4 +- .../Methods/Utils/MultiDictionary.cs | 40 +- .../Methods/Utils/PlaceholderParser.cs | 144 +++--- source/BP-Essentials/Methods/misc/Reload.cs | 50 +- .../BP-Essentials/Properties/AssemblyInfo.cs | 2 +- source/BP-Essentials/Variables.cs | 118 ++--- 81 files changed, 2202 insertions(+), 2197 deletions(-) diff --git a/source/BP-Essentials/Chat/Announce.cs b/source/BP-Essentials/Chat/Announce.cs index 6d38158b..cc4a9908 100644 --- a/source/BP-Essentials/Chat/Announce.cs +++ b/source/BP-Essentials/Chat/Announce.cs @@ -10,37 +10,37 @@ namespace BP_Essentials { public class Announcer - { - public System.Timers.Timer Timer { get; private set; } - public List Announcements { get; set; } = new List(); - public double Interval - { - get => Timer.Interval; - set - { - Timer.Enabled = false; - Timer.Interval = value * 1000; - Timer.Enabled = true; - } - } - public Announcer(List announcements) : this() - { - Announcements = announcements; - } - public Announcer() + { + public System.Timers.Timer Timer { get; private set; } + public List Announcements { get; set; } = new List(); + public double Interval + { + get => Timer.Interval; + set + { + Timer.Enabled = false; + Timer.Interval = value * 1000; + Timer.Enabled = true; + } + } + public Announcer(List announcements) : this() + { + Announcements = announcements; + } + public Announcer() { try { - Timer = new System.Timers.Timer(); + Timer = new System.Timers.Timer(); - Timer.Elapsed += (sender, e) => OnTime(); - if (TimeBetweenAnnounce == 0) - { - Timer.Enabled = false; - return; - } - Timer.Interval = TimeBetweenAnnounce * 1000; - Timer.Enabled = true; + Timer.Elapsed += (sender, e) => OnTime(); + if (TimeBetweenAnnounce == 0) + { + Timer.Enabled = false; + return; + } + Timer.Interval = TimeBetweenAnnounce * 1000; + Timer.Enabled = true; } catch (Exception ex) { @@ -48,21 +48,21 @@ public Announcer() } } - void OnTime() - { - if (Announcements == null || Announcements.Count == 0) - return; - if (++AnnounceIndex > Announcements.Count - 1) - AnnounceIndex = 0; - if (string.IsNullOrWhiteSpace(Announcements[AnnounceIndex])) - return; - var lines = Announcements[AnnounceIndex].Split(new[] { "\r\n", "\r", "\n", "\\r\\n", "\\r", "\\n" }, StringSplitOptions.None); - foreach (var player in SvMan.players) - { - foreach (var line in lines) - player.Value.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, line); - } - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Announcement made..."); - } + void OnTime() + { + if (Announcements == null || Announcements.Count == 0) + return; + if (++AnnounceIndex > Announcements.Count - 1) + AnnounceIndex = 0; + if (string.IsNullOrWhiteSpace(Announcements[AnnounceIndex])) + return; + var lines = Announcements[AnnounceIndex].Split(new[] { "\r\n", "\r", "\n", "\\r\\n", "\\r", "\\n" }, StringSplitOptions.None); + foreach (var player in SvMan.players) + { + foreach (var line in lines) + player.Value.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, line); + } + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Announcement made..."); + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs b/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs index 86a5aa5a..083844ab 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs @@ -9,22 +9,22 @@ namespace BP_Essentials.Commands { class Arrest { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var shPlayer = GetShByStr.Run(arg1); - if (shPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed); - player.SendChatMessage($"Arrested {shPlayer.username}."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var shPlayer = GetShByStr.Run(arg1); + if (shPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed); + player.SendChatMessage($"Arrested {shPlayer.username}."); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Back.cs b/source/BP-Essentials/Chat/Commands/Admin/Back.cs index f2ae094b..e104371d 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Back.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Back.cs @@ -8,18 +8,18 @@ namespace BP_Essentials.Commands { - class Back - { - public static void Run(SvPlayer player, string message) - { - var lastLocation = PlayerList[player.player.ID].LastLocation; - if (!lastLocation.HasPositionSet()) - { - player.SendChatMessage($"There is no location to teleport to."); - return; - } - player.ResetAndSavePosition(lastLocation.Position, lastLocation.Rotation, lastLocation.PlaceIndex); - player.SendChatMessage($"You've been teleported to your last known location."); - } - } + class Back + { + public static void Run(SvPlayer player, string message) + { + var lastLocation = PlayerList[player.player.ID].LastLocation; + if (!lastLocation.HasPositionSet()) + { + player.SendChatMessage($"There is no location to teleport to."); + return; + } + player.ResetAndSavePosition(lastLocation.Position, lastLocation.Rotation, lastLocation.PlaceIndex); + player.SendChatMessage($"You've been teleported to your last known location."); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Ban.cs b/source/BP-Essentials/Chat/Commands/Admin/Ban.cs index d7435a86..240650bd 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Ban.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Ban.cs @@ -3,27 +3,27 @@ namespace BP_Essentials.Commands { public class Ban { - public static void Run(SvPlayer player, string message) - { - var arg1 = GetArgument.Run(1, false, false, message); - var arg2 = GetArgument.Run(2, false, true, message); - if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2)) - { - player.SendChatMessage(ArgRequired); - return; - } - var shPlayer = GetShByStr.Run(arg1, true); - if (shPlayer == null) - { - player.SendChatMessage(NotFoundOnlineIdOnly); - return; - } - LogMessage.LogOther($"{PlaceholderParser.ParseTimeStamp()} [INFO] {shPlayer.username} Got banned by {player.playerData.username} (Reason: {arg2}"); - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username} (Reason: {arg2})"); - SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username, arg2); - player.SendChatMessage($"Banned {shPlayer.username}. (Reason: {arg2})"); - player.svManager.AddBanned(shPlayer); - player.svManager.Disconnect(shPlayer.svPlayer.connection, DisconnectTypes.Banned); - } + public static void Run(SvPlayer player, string message) + { + var arg1 = GetArgument.Run(1, false, false, message); + var arg2 = GetArgument.Run(2, false, true, message); + if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2)) + { + player.SendChatMessage(ArgRequired); + return; + } + var shPlayer = GetShByStr.Run(arg1, true); + if (shPlayer == null) + { + player.SendChatMessage(NotFoundOnlineIdOnly); + return; + } + LogMessage.LogOther($"{PlaceholderParser.ParseTimeStamp()} [INFO] {shPlayer.username} Got banned by {player.playerData.username} (Reason: {arg2}"); + player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username} (Reason: {arg2})"); + SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username, arg2); + player.SendChatMessage($"Banned {shPlayer.username}. (Reason: {arg2})"); + player.svManager.AddBanned(shPlayer); + player.svManager.Disconnect(shPlayer.svPlayer.connection, DisconnectTypes.Banned); + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs b/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs index 8d92292e..4703e085 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs @@ -11,50 +11,50 @@ namespace BP_Essentials.Commands { class CheckAlts { - public static void Run(SvPlayer player, string message) - { - var arg1 = GetArgument.Run(1, false, false, message); - var found = 0; - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(GetArgument.Run(0, false, false, message) + "[IP/IGN] [Arg2] Eg " + GetArgument.Run(0, false, false, message) + " ip 127.0.0.1"); - return; - } - var arg2 = GetArgument.Run(2, false, true, message); - if (arg1.Equals("ip", StringComparison.InvariantCultureIgnoreCase)) - { - var content = "Possible accounts using the IP " + arg2 + ":\r\n\r\n"; - var builder = new StringBuilder(); - builder.Append(content); - foreach (var line in File.ReadAllLines(IpListFile)) - { - if (line.EndsWith(arg2, StringComparison.CurrentCulture)) - { - ++found; - builder.Append(line.Replace(": " + arg2, string.Empty) + "\r\n"); - } - } - content = builder.ToString(); - content += "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n"; - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content); - } - else if (arg1.Equals("ign", StringComparison.InvariantCultureIgnoreCase) || (arg1.Equals(nameof(player), StringComparison.InvariantCultureIgnoreCase))) - { - var content = "Possible logins on the account " + arg2 + " using the following IP's:\r\n\r\n"; - var builder = new StringBuilder(); - builder.Append(content); - foreach (var line in File.ReadAllLines(IpListFile)) - { - if (line.StartsWith(arg2 + ": ", StringComparison.CurrentCulture)) - { - ++found; - builder.Append(line.Replace(arg2 + ": ", string.Empty) + "\r\n"); - } - } - content = builder.ToString(); - content = content + "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n"; - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content); - } - } + public static void Run(SvPlayer player, string message) + { + var arg1 = GetArgument.Run(1, false, false, message); + var found = 0; + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(GetArgument.Run(0, false, false, message) + "[IP/IGN] [Arg2] Eg " + GetArgument.Run(0, false, false, message) + " ip 127.0.0.1"); + return; + } + var arg2 = GetArgument.Run(2, false, true, message); + if (arg1.Equals("ip", StringComparison.InvariantCultureIgnoreCase)) + { + var content = "Possible accounts using the IP " + arg2 + ":\r\n\r\n"; + var builder = new StringBuilder(); + builder.Append(content); + foreach (var line in File.ReadAllLines(IpListFile)) + { + if (line.EndsWith(arg2, StringComparison.CurrentCulture)) + { + ++found; + builder.Append(line.Replace(": " + arg2, string.Empty) + "\r\n"); + } + } + content = builder.ToString(); + content += "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n"; + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content); + } + else if (arg1.Equals("ign", StringComparison.InvariantCultureIgnoreCase) || (arg1.Equals(nameof(player), StringComparison.InvariantCultureIgnoreCase))) + { + var content = "Possible logins on the account " + arg2 + " using the following IP's:\r\n\r\n"; + var builder = new StringBuilder(); + builder.Append(content); + foreach (var line in File.ReadAllLines(IpListFile)) + { + if (line.StartsWith(arg2 + ": ", StringComparison.CurrentCulture)) + { + ++found; + builder.Append(line.Replace(arg2 + ": ", string.Empty) + "\r\n"); + } + } + content = builder.ToString(); + content = content + "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n"; + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content); + } + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Clear.cs b/source/BP-Essentials/Chat/Commands/Admin/Clear.cs index 4be433f0..d30a4764 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Clear.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Clear.cs @@ -5,27 +5,27 @@ namespace BP_Essentials.Commands { public class Clear { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var shPlayer = GetShByStr.Run(arg1); - if (shPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - var tempList = new List(); - foreach (var item in shPlayer.myItems.Values) - tempList.Add(item); - for (int i = 0; i < tempList.Count; i++) - shPlayer.TransferItem(2, tempList[i].item.index, shPlayer.MyItemCount(tempList[i].item.index), true); - player.SendChatMessage($"You cleared the inventory of {shPlayer.username}."); - shPlayer.svPlayer.SendChatMessage($"Your inventory has been cleared by {player.playerData.username}."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var shPlayer = GetShByStr.Run(arg1); + if (shPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + var tempList = new List(); + foreach (var item in shPlayer.myItems.Values) + tempList.Add(item); + for (int i = 0; i < tempList.Count; i++) + shPlayer.TransferItem(2, tempList[i].item.index, shPlayer.MyItemCount(tempList[i].item.index), true); + player.SendChatMessage($"You cleared the inventory of {shPlayer.username}."); + shPlayer.svPlayer.SendChatMessage($"Your inventory has been cleared by {player.playerData.username}."); + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs b/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs index 79006c34..d2cacd19 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs @@ -10,20 +10,20 @@ namespace BP_Essentials.Commands { class ClearWanted { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - arg1 = player.player.username; - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.ClearCrimes(); - currPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ClearCrimes, currPlayer.ID); - player.SendChatMessage($"Cleared crimes of '{currPlayer.username}'."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + arg1 = player.player.username; + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.ClearCrimes(); + currPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ClearCrimes, currPlayer.ID); + player.SendChatMessage($"Cleared crimes of '{currPlayer.username}'."); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs b/source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs index de365c11..9e51c524 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs @@ -35,16 +35,16 @@ public static void Run(SvPlayer player, string message) player.SendChatMessage($"A kit already exists with that name."); return; } - var obj = new KitsHandler.JsonModel - { - Delay = arg1i, - Price = arg2i < 0 ? 0 : arg2i, - Name = arg3, - ExecutableBy = "everyone" - }; - foreach (var item in player.player.myItems.Values) - obj.Items.Add(new KitsHandler.Kits_Item { Amount = item.count, Id = item.item.index }); - Variables.KitsHandler.CreateNew(obj, arg3); + var obj = new KitsHandler.JsonModel + { + Delay = arg1i, + Price = arg2i < 0 ? 0 : arg2i, + Name = arg3, + ExecutableBy = "everyone" + }; + foreach (var item in player.player.myItems.Values) + obj.Items.Add(new KitsHandler.Kits_Item { Amount = item.count, Id = item.item.index }); + Variables.KitsHandler.CreateNew(obj, arg3); player.SendChatMessage($"Kit created. Please edit {file} to add ExecuteableBy."); } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/CreateWarp.cs b/source/BP-Essentials/Chat/Commands/Admin/CreateWarp.cs index 722c25a1..2a53db20 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/CreateWarp.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/CreateWarp.cs @@ -12,9 +12,9 @@ public class CreateWarp public static void Run(SvPlayer player, string message) { var arg1 = GetArgument.Run(1, false, false, message); // (int)DelayInSeconds - var arg2 = GetArgument.Run(2, false, false, message); // (int)Price - var arg3 = GetArgument.Run(3, false, true, message); // (string)KitName - if (string.IsNullOrEmpty(arg1.Trim()) || string.IsNullOrEmpty(arg2.Trim()) || string.IsNullOrEmpty(arg3.Trim())) + var arg2 = GetArgument.Run(2, false, false, message); // (int)Price + var arg3 = GetArgument.Run(3, false, true, message); // (string)KitName + if (string.IsNullOrEmpty(arg1.Trim()) || string.IsNullOrEmpty(arg2.Trim()) || string.IsNullOrEmpty(arg3.Trim())) { player.SendChatMessage(ArgRequired); return; @@ -29,27 +29,27 @@ public static void Run(SvPlayer player, string message) player.SendChatMessage($"The delay must be a positive number (0 to disable)"); return; } - if (player.InApartment()) - { - player.SendChatMessage($"You cannot set a warp inside any apartment, as they are not fixed places."); - return; - } + if (player.InApartment()) + { + player.SendChatMessage($"You cannot set a warp inside any apartment, as they are not fixed places."); + return; + } var file = Path.Combine(WarpDirectory, $"{arg3}.json"); if (File.Exists(file)) { player.SendChatMessage($"A warp already exists with that name."); return; } - var obj = new WarpHandler.JsonModel - { - Delay = arg1i, - Price = arg2i < 0 ? 0 : arg2i, - Name = arg3, - ExecutableBy = "everyone", - Position = new WarpHandler.Position { X = player.player.GetPosition().x, Y = player.player.GetPosition().y, Z = player.player.GetPosition().z, PlaceIndex = player.player.GetPlaceIndex() }, - Rotation = new WarpHandler.Rotation { X = player.player.GetRotation().x, Y = player.player.GetRotation().y, Z = player.player.GetRotation().z, W = player.player.GetRotation().w } - }; - Variables.WarpHandler.CreateNew(obj, arg3); + var obj = new WarpHandler.JsonModel + { + Delay = arg1i, + Price = arg2i < 0 ? 0 : arg2i, + Name = arg3, + ExecutableBy = "everyone", + Position = new WarpHandler.Position { X = player.player.GetPosition().x, Y = player.player.GetPosition().y, Z = player.player.GetPosition().z, PlaceIndex = player.player.GetPlaceIndex() }, + Rotation = new WarpHandler.Rotation { X = player.player.GetRotation().x, Y = player.player.GetRotation().y, Z = player.player.GetRotation().z, W = player.player.GetRotation().w } + }; + Variables.WarpHandler.CreateNew(obj, arg3); player.SendChatMessage($"Warp created. Please edit {file} to add ExecuteableBy."); } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs b/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs index 30ee805a..3865c999 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs @@ -16,123 +16,123 @@ public static void Run(SvPlayer player, string message) var shPlayer = player.player; string arg = GetArgument.Run(1, false, false, message).Trim().ToLower(); - switch (arg) - { - case "location": - case "getlocation": - player.SendChatMessage("Your location: " + shPlayer.GetPosition()); - break; - case "getplayerhash": - case "gethash": - { - string arg2 = GetArgument.Run(2, false, true, message); - if (string.IsNullOrEmpty(arg2)) - { + switch (arg) + { + case "location": + case "getlocation": + player.SendChatMessage("Your location: " + shPlayer.GetPosition()); + break; + case "getplayerhash": + case "gethash": + { + string arg2 = GetArgument.Run(2, false, true, message); + if (string.IsNullOrEmpty(arg2)) + { - player.SendChatMessage("Invalid arguments. /debug get(player)hash [username]"); - return; - } - player.SendChatMessage("Hash of " + arg2 + " : " + Animator.StringToHash(arg2)); - break; - } + player.SendChatMessage("Invalid arguments. /debug get(player)hash [username]"); + return; + } + player.SendChatMessage("Hash of " + arg2 + " : " + Animator.StringToHash(arg2)); + break; + } - case "spaceindex": - case "getspaceindex": - { - string arg2 = GetArgument.Run(2, false, true, message); - if (string.IsNullOrEmpty(arg2)) - { - player.SendChatMessage("Your SpaceIndex: " + shPlayer.GetPlaceIndex()); - return; - } - var argshPlayer = GetShByStr.Run(arg2); - if (argshPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - player.SendChatMessage("SpaceIndex of '" + argshPlayer.svPlayer.playerData.username + "': " + argshPlayer.GetPlaceIndex()); - break; - } + case "spaceindex": + case "getspaceindex": + { + string arg2 = GetArgument.Run(2, false, true, message); + if (string.IsNullOrEmpty(arg2)) + { + player.SendChatMessage("Your SpaceIndex: " + shPlayer.GetPlaceIndex()); + return; + } + var argshPlayer = GetShByStr.Run(arg2); + if (argshPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + player.SendChatMessage("SpaceIndex of '" + argshPlayer.svPlayer.playerData.username + "': " + argshPlayer.GetPlaceIndex()); + break; + } - case "createidlist": - { - string arg2 = GetArgument.Run(2, false, true, message); - if (string.IsNullOrEmpty(arg2)) - { - player.SendChatMessage("Please select idlist type: /debug createidlist item/vehicle/skinid"); - return; - } - arg2 = arg2.Trim().ToLower(); - if (arg2 != "item" && arg2 != "vehicle" && arg2 != "skinid") - { - player.SendChatMessage("Please select idlist type: /debug createidlist item/vehicle/skinid (Invalid value given as second arument)"); - return; - } - player.SendChatMessage("Creating ID list.. please wait"); - var location = $"{FileDirectory}IDLists/{arg2}/IDLIST_{DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss")}.txt"; - if (!Directory.Exists($"{FileDirectory}IDLists/{arg2}")) - Directory.CreateDirectory($"{FileDirectory}IDLists/{arg2}"); - var sb = new StringBuilder(); - int currIndex = 0; - sb.Append("{\"items\": ["); - if (arg2 == "skinid") - { - for (int i = 0; i < shPlayer.manager.skinPrefabs.Length; i++) - { - sb.Append($"{{\"name\": \"{shPlayer.manager.skinPrefabs[i].name}\",\"id\": {currIndex},\"gameid\": {Animator.StringToHash(shPlayer.manager.skinPrefabs[i].name)}}},\n"); - ++currIndex; - } - } - else - { - var itemsAdded = new List(); - foreach (var entity in Builder.pb_Scene.instance.entityCollection) - { - if (entity == null) - continue; - if (((arg2 == "item" && entity is ShItem) || (arg2 == "vehicle" && entity is ShTransport && !(entity is ShParachute))) && !itemsAdded.Contains(entity.index)) - { - sb.Append($"{{\"name\": \"{entity.name.Replace("(Clone)", "")}\",\"id\": {++currIndex},\"gameid\": {entity.index}}},\n"); - itemsAdded.Add(entity.index); - } - } - } - File.WriteAllText(location, $"{sb.Remove(sb.Length - 2, 1)}]}}"); + case "createidlist": + { + string arg2 = GetArgument.Run(2, false, true, message); + if (string.IsNullOrEmpty(arg2)) + { + player.SendChatMessage("Please select idlist type: /debug createidlist item/vehicle/skinid"); + return; + } + arg2 = arg2.Trim().ToLower(); + if (arg2 != "item" && arg2 != "vehicle" && arg2 != "skinid") + { + player.SendChatMessage("Please select idlist type: /debug createidlist item/vehicle/skinid (Invalid value given as second arument)"); + return; + } + player.SendChatMessage("Creating ID list.. please wait"); + var location = $"{FileDirectory}IDLists/{arg2}/IDLIST_{DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss")}.txt"; + if (!Directory.Exists($"{FileDirectory}IDLists/{arg2}")) + Directory.CreateDirectory($"{FileDirectory}IDLists/{arg2}"); + var sb = new StringBuilder(); + int currIndex = 0; + sb.Append("{\"items\": ["); + if (arg2 == "skinid") + { + for (int i = 0; i < shPlayer.manager.skinPrefabs.Length; i++) + { + sb.Append($"{{\"name\": \"{shPlayer.manager.skinPrefabs[i].name}\",\"id\": {currIndex},\"gameid\": {Animator.StringToHash(shPlayer.manager.skinPrefabs[i].name)}}},\n"); + ++currIndex; + } + } + else + { + var itemsAdded = new List(); + foreach (var entity in Builder.pb_Scene.instance.entityCollection) + { + if (entity == null) + continue; + if (((arg2 == "item" && entity is ShItem) || (arg2 == "vehicle" && entity is ShTransport && !(entity is ShParachute))) && !itemsAdded.Contains(entity.index)) + { + sb.Append($"{{\"name\": \"{entity.name.Replace("(Clone)", "")}\",\"id\": {++currIndex},\"gameid\": {entity.index}}},\n"); + itemsAdded.Add(entity.index); + } + } + } + File.WriteAllText(location, $"{sb.Remove(sb.Length - 2, 1)}]}}"); - player.SendChatMessage($"Success! ID List has been saved in {location}. ({currIndex} entries.)"); - break; - } + player.SendChatMessage($"Success! ID List has been saved in {location}. ({currIndex} entries.)"); + break; + } - case "jobarray": - player.SendChatMessage($"Jobs array: (Length: {Jobs.Length}) {string.Join(", ", Jobs)}"); - break; - case "tpall": - { - foreach (var currPlayer in UnityEngine.Object.FindObjectsOfType()) - currPlayer.ResetAndSavePosition(shPlayer.GetPosition(), shPlayer.GetRotation(), shPlayer.GetPlaceIndex()); - break; - } + case "jobarray": + player.SendChatMessage($"Jobs array: (Length: {Jobs.Length}) {string.Join(", ", Jobs)}"); + break; + case "tpall": + { + foreach (var currPlayer in UnityEngine.Object.FindObjectsOfType()) + currPlayer.ResetAndSavePosition(shPlayer.GetPosition(), shPlayer.GetRotation(), shPlayer.GetPlaceIndex()); + break; + } - case "addcrimes": - player.SvAddCrime(CrimeIndex.Murder, null); - break; + case "addcrimes": + player.SvAddCrime(CrimeIndex.Murder, null); + break; - case "disconnecttest": - player.Send(SvSendType.AllOthers, Channel.Unsequenced, ClPacket.DestroyEntity, player.player.ID); - break; - case "setmaxapartmententities": - player.entity.manager.apartmentLimit = 300; - player.SendChatMessage("success"); - break; - case "getmaxapartmententities": - player.SendChatMessage($"Max entities: {player.entity.manager.apartmentLimit}"); - break; - default: - player.SendChatMessage("/debug location/getplayerhash/getspaceindex/createidlist/jobarray"); - break; - } - } + case "disconnecttest": + player.Send(SvSendType.AllOthers, Channel.Unsequenced, ClPacket.DestroyEntity, player.player.ID); + break; + case "setmaxapartmententities": + player.entity.manager.apartmentLimit = 300; + player.SendChatMessage("success"); + break; + case "getmaxapartmententities": + player.SendChatMessage($"Max entities: {player.entity.manager.apartmentLimit}"); + break; + default: + player.SendChatMessage("/debug location/getplayerhash/getspaceindex/createidlist/jobarray"); + break; + } + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs b/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs index 52f0e84f..1777ddd7 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs @@ -10,15 +10,15 @@ namespace BP_Essentials.Commands { class FakeJoin { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, arg1 + " connected"); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, arg1 + " connected"); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs b/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs index e28768fa..8c1678ca 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs @@ -10,15 +10,15 @@ namespace BP_Essentials.Commands { class FakeLeave { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, arg1 + " disconnected"); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, arg1 + " disconnected"); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Feed.cs b/source/BP-Essentials/Chat/Commands/Admin/Feed.cs index 803890d7..e7666d04 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Feed.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Feed.cs @@ -13,16 +13,16 @@ class Feed public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - arg1 = player.player.username; - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.RestoreStats(); - player.SendChatMessage($"Maxed stats for {currPlayer.username}."); + if (string.IsNullOrEmpty(arg1)) + arg1 = player.player.username; + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.RestoreStats(); + player.SendChatMessage($"Maxed stats for {currPlayer.username}."); } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/Free.cs b/source/BP-Essentials/Chat/Commands/Admin/Free.cs index 0cb6ec80..88344479 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Free.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Free.cs @@ -10,22 +10,22 @@ namespace BP_Essentials.Commands { class Free { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - UnRestrain.Run(currPlayer.svPlayer); - player.SendChatMessage($"Freed {currPlayer.username}."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + UnRestrain.Run(currPlayer.svPlayer); + player.SendChatMessage($"Freed {currPlayer.username}."); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Give.cs b/source/BP-Essentials/Chat/Commands/Admin/Give.cs index 37ad3da7..351143b5 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Give.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Give.cs @@ -10,31 +10,31 @@ namespace BP_Essentials.Commands { class Give { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, false, message); - string arg2 = GetArgument.Run(2, false, false, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - if (string.IsNullOrWhiteSpace(arg2)) - arg2 = "1"; - bool parsedSuccessfully = int.TryParse(arg1, out int arg1int); - parsedSuccessfully = int.TryParse(arg2, out int arg2int); - if (!parsedSuccessfully) - { - player.SendChatMessage(NotValidArg); - return; - } - if (arg1int < 0 || arg1int > IDs_Items.Length) - { - player.SendChatMessage($"Error: The ID must be between 1 and {IDs_Items.Length}."); - return; - } - player.player.TransferItem(DeltaInv.AddToMe, IDs_Items[arg1int - 1], arg2int, true); - player.SendChatMessage($"Giving you item ID: {arg1}"); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, false, message); + string arg2 = GetArgument.Run(2, false, false, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + if (string.IsNullOrWhiteSpace(arg2)) + arg2 = "1"; + bool parsedSuccessfully = int.TryParse(arg1, out int arg1int); + parsedSuccessfully = int.TryParse(arg2, out int arg2int); + if (!parsedSuccessfully) + { + player.SendChatMessage(NotValidArg); + return; + } + if (arg1int < 0 || arg1int > IDs_Items.Length) + { + player.SendChatMessage($"Error: The ID must be between 1 and {IDs_Items.Length}."); + return; + } + player.player.TransferItem(DeltaInv.AddToMe, IDs_Items[arg1int - 1], arg2int, true); + player.SendChatMessage($"Giving you item ID: {arg1}"); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs b/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs index a5c6fd05..7bbfd5bb 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs @@ -6,31 +6,31 @@ namespace BP_Essentials.Commands { - public class GodMode - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - arg1 = player.player.username; - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - ReadFile.Run(GodListFile); - var msg = $"Godmode {{0}} for '{arg1}'."; - if (GodListPlayers.Contains(currPlayer.username)) - { - RemoveStringFromFile.Run(GodListFile, currPlayer.username); - ReadFile.Run(GodListFile); - player.SendChatMessage(string.Format(msg, "disabled")); - return; - } - File.AppendAllText(GodListFile, currPlayer.username + Environment.NewLine); - GodListPlayers.Add(currPlayer.username); - player.SendChatMessage(string.Format(msg, "enabled")); - } - } + public class GodMode + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + arg1 = player.player.username; + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + ReadFile.Run(GodListFile); + var msg = $"Godmode {{0}} for '{arg1}'."; + if (GodListPlayers.Contains(currPlayer.username)) + { + RemoveStringFromFile.Run(GodListFile, currPlayer.username); + ReadFile.Run(GodListFile); + player.SendChatMessage(string.Format(msg, "disabled")); + return; + } + File.AppendAllText(GodListFile, currPlayer.username + Environment.NewLine); + GodListPlayers.Add(currPlayer.username); + player.SendChatMessage(string.Format(msg, "enabled")); + } + } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/Heal.cs b/source/BP-Essentials/Chat/Commands/Admin/Heal.cs index 6ebcc7fe..c2d915d3 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Heal.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Heal.cs @@ -13,16 +13,16 @@ class Heal public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - arg1 = player.player.username; - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.svPlayer.Heal(100); - player.SendChatMessage($"Healed {currPlayer.username}."); + if (string.IsNullOrEmpty(arg1)) + arg1 = player.player.username; + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.svPlayer.Heal(100); + player.SendChatMessage($"Healed {currPlayer.username}."); } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Info.cs b/source/BP-Essentials/Chat/Commands/Admin/Info.cs index 0346a609..a71b7ba5 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Info.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Info.cs @@ -10,36 +10,36 @@ namespace BP_Essentials.Commands { class Info { - public static void Run(SvPlayer player, string message) - { - var arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - string[] contentarray = { - "Username: " + currPlayer.username, - "", - "", - "Job: " + Jobs[currPlayer.job.jobIndex], - "Health: " + Math.Floor(currPlayer.health), - "OwnsApartment: " + (bool)currPlayer.ownedApartment, - "Position: " + currPlayer.GetPosition().ToString(), - "WantedLevel: " + currPlayer.wantedLevel, - "IsAdmin: " + currPlayer.admin, - "BankBalance: " + currPlayer.svPlayer.bankBalance, - "ChatEnabled: " + PlayerList[currPlayer.ID].ChatEnabled, - "IP: " + currPlayer.svPlayer.connection.IP - }; - var content = string.Join("\r\n", contentarray); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content); - } + public static void Run(SvPlayer player, string message) + { + var arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + string[] contentarray = { + "Username: " + currPlayer.username, + "", + "", + "Job: " + Jobs[currPlayer.job.jobIndex], + "Health: " + Math.Floor(currPlayer.health), + "OwnsApartment: " + (bool)currPlayer.ownedApartment, + "Position: " + currPlayer.GetPosition().ToString(), + "WantedLevel: " + currPlayer.wantedLevel, + "IsAdmin: " + currPlayer.admin, + "BankBalance: " + currPlayer.svPlayer.bankBalance, + "ChatEnabled: " + PlayerList[currPlayer.ID].ChatEnabled, + "IP: " + currPlayer.svPlayer.connection.IP + }; + var content = string.Join("\r\n", contentarray); + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Kill.cs b/source/BP-Essentials/Chat/Commands/Admin/Kill.cs index f5fffd03..78b8ef05 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Kill.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Kill.cs @@ -10,22 +10,22 @@ namespace BP_Essentials.Commands { class Kill { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.svPlayer.SvSuicide(); - player.SendChatMessage($"Killed {currPlayer.username}."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.svPlayer.SvSuicide(); + player.SendChatMessage($"Killed {currPlayer.username}."); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs b/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs index 069577fe..907c2bb3 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs @@ -10,22 +10,22 @@ namespace BP_Essentials.Commands { class Knockout { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.svPlayer.SvForceStance(StanceIndex.KnockedOut); - player.SendChatMessage($"Knocked out {currPlayer.username}."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.svPlayer.SvForceStance(StanceIndex.KnockedOut); + player.SendChatMessage($"Knocked out {currPlayer.username}."); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs b/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs index 8dde3216..7cede372 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs @@ -10,15 +10,15 @@ namespace BP_Essentials.Commands { class LatestVoteResults { - public static void Run(SvPlayer player, string message) - { - if (!LatestVotePeople.Any()) - { - player.SendChatMessage($"The list seems empty."); - return; - } - string content = string.Join("\r\n", LatestVotePeople); - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.ServerInfo, "\r\nPlayers that voted 'yes' on the latest votekick: \r\n\r\n" + content); - } + public static void Run(SvPlayer player, string message) + { + if (!LatestVotePeople.Any()) + { + player.SendChatMessage($"The list seems empty."); + return; + } + string content = string.Join("\r\n", LatestVotePeople); + player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.ServerInfo, "\r\nPlayers that voted 'yes' on the latest votekick: \r\n\r\n" + content); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Launch.cs b/source/BP-Essentials/Chat/Commands/Admin/Launch.cs index 6d285037..48f9f730 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Launch.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Launch.cs @@ -12,21 +12,21 @@ class Launch { public static void Run(SvPlayer player, string message) { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.svPlayer.SvForce(new Vector3(0f, 6500f, 0f)); - currPlayer.svPlayer.SendChatMessage($"Off you go!"); - player.SendChatMessage($"You've launched {currPlayer.username} into space!"); + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.svPlayer.SvForce(new Vector3(0f, 6500f, 0f)); + currPlayer.svPlayer.SendChatMessage($"Off you go!"); + player.SendChatMessage($"You've launched {currPlayer.username} into space!"); } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Money.cs b/source/BP-Essentials/Chat/Commands/Admin/Money.cs index d8ce7a33..3730d886 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Money.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Money.cs @@ -8,36 +8,36 @@ namespace BP_Essentials.Commands { - class Money - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - string arg2 = message.Split(' ').Last().Trim(); - string correctSyntax = $"{GetArgument.Run(0, false, false, message)} [Player] [Amount] (Incorrect or missing argument(s).)"; - if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2)) - { - player.SendChatMessage(correctSyntax); - return; - } - int lastIndex = arg1.LastIndexOf(" ", StringComparison.CurrentCulture); - if (lastIndex != -1) - arg1 = arg1.Remove(lastIndex).Trim(); - bool parsedSuccessfully = int.TryParse(arg2, out var arg2int); - if (!parsedSuccessfully) - { - player.SendChatMessage(correctSyntax); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.TransferMoney(DeltaInv.AddToMe, arg2int, true); - player.SendChatMessage($"Successfully gave {currPlayer.username} {arg2int}$"); - currPlayer.svPlayer.SendChatMessage($"{player.player.username} gave you {arg2int}$!"); - } - } + class Money + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + string arg2 = message.Split(' ').Last().Trim(); + string correctSyntax = $"{GetArgument.Run(0, false, false, message)} [Player] [Amount] (Incorrect or missing argument(s).)"; + if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2)) + { + player.SendChatMessage(correctSyntax); + return; + } + int lastIndex = arg1.LastIndexOf(" ", StringComparison.CurrentCulture); + if (lastIndex != -1) + arg1 = arg1.Remove(lastIndex).Trim(); + bool parsedSuccessfully = int.TryParse(arg2, out var arg2int); + if (!parsedSuccessfully) + { + player.SendChatMessage(correctSyntax); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.TransferMoney(DeltaInv.AddToMe, arg2int, true); + player.SendChatMessage($"Successfully gave {currPlayer.username} {arg2int}$"); + currPlayer.svPlayer.SendChatMessage($"{player.player.username} gave you {arg2int}$!"); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Mute.cs b/source/BP-Essentials/Chat/Commands/Admin/Mute.cs index b1d80a8c..f7bd3f35 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Mute.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Mute.cs @@ -9,33 +9,33 @@ namespace BP_Essentials.Commands { - class Mute - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - ReadFile.Run(MuteListFile); - if (!MutePlayers.Contains(currPlayer.username)) - { - MutePlayers.Add(currPlayer.username); - File.AppendAllText(MuteListFile, currPlayer.username + Environment.NewLine); - player.SendChatMessage($"Muted {currPlayer.username}."); - return; - } - RemoveStringFromFile.Run(MuteListFile, currPlayer.username); - ReadFile.Run(MuteListFile); - player.SendChatMessage($"Unmuted {currPlayer.username}."); - } - } + class Mute + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + ReadFile.Run(MuteListFile); + if (!MutePlayers.Contains(currPlayer.username)) + { + MutePlayers.Add(currPlayer.username); + File.AppendAllText(MuteListFile, currPlayer.username + Environment.NewLine); + player.SendChatMessage($"Muted {currPlayer.username}."); + return; + } + RemoveStringFromFile.Run(MuteListFile, currPlayer.username); + ReadFile.Run(MuteListFile); + player.SendChatMessage($"Unmuted {currPlayer.username}."); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Promote.cs b/source/BP-Essentials/Chat/Commands/Admin/Promote.cs index 5ef8e0f0..bf4da6d0 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Promote.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Promote.cs @@ -5,27 +5,27 @@ namespace BP_Essentials.Commands { public class Promote { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - if (currPlayer.rank >= 2) - { - player.SendChatMessage($"{currPlayer.username} Already has the highest rank!"); - return; - } - currPlayer.svPlayer.Reward(currPlayer.maxExperience - currPlayer.experience + 1, 0); - player.SendChatMessage($"Promoted {currPlayer.username} to rank {currPlayer.rank + 1}."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + if (currPlayer.rank >= 2) + { + player.SendChatMessage($"{currPlayer.username} Already has the highest rank!"); + return; + } + currPlayer.svPlayer.Reward(currPlayer.maxExperience - currPlayer.experience + 1, 0); + player.SendChatMessage($"Promoted {currPlayer.username} to rank {currPlayer.rank + 1}."); + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/RepairVehicle.cs b/source/BP-Essentials/Chat/Commands/Admin/RepairVehicle.cs index 5d481465..bf9ee412 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/RepairVehicle.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/RepairVehicle.cs @@ -8,18 +8,18 @@ namespace BP_Essentials.Commands { - class RepairVehicle - { - public static void Run(SvPlayer player, string message) - { - var vehicle = player.player.curMount as ShTransport; - if (!player.player.curMount || vehicle == null) - { - player.SendChatMessage($"You must be in a vehicle to execute this command."); - return; - } - vehicle.RestoreStats(); - player.SendChatMessage($"Your vehicle has been repaired."); - } - } + class RepairVehicle + { + public static void Run(SvPlayer player, string message) + { + var vehicle = player.player.curMount as ShTransport; + if (!player.player.curMount || vehicle == null) + { + player.SendChatMessage($"You must be in a vehicle to execute this command."); + return; + } + vehicle.RestoreStats(); + player.SendChatMessage($"Your vehicle has been repaired."); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs b/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs index 438bca2f..9fd13729 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs @@ -10,26 +10,26 @@ namespace BP_Essentials.Commands { class Restrain { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - currPlayer.svPlayer.Restrain(currPlayer.manager.handcuffed); - var shRetained = currPlayer.curEquipable as ShRestrained; - currPlayer.svPlayer.SvSetEquipable(shRetained.otherRestrained.index); - if (!currPlayer.svPlayer.serverside) - currPlayer.svPlayer.SendChatMessage("You've been restrained"); - player.SendChatMessage($"Restrained {currPlayer.username}."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + currPlayer.svPlayer.Restrain(currPlayer.manager.handcuffed); + var shRetained = currPlayer.curEquipable as ShRestrained; + currPlayer.svPlayer.SvSetEquipable(shRetained.otherRestrained.index); + if (!currPlayer.svPlayer.serverside) + currPlayer.svPlayer.SendChatMessage("You've been restrained"); + player.SendChatMessage($"Restrained {currPlayer.username}."); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Say.cs b/source/BP-Essentials/Chat/Commands/Admin/Say.cs index cb1e8b1f..4228a382 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Say.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Say.cs @@ -9,17 +9,17 @@ namespace BP_Essentials.Commands { - class Say - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{MsgSayPrefix} {player.playerData.username}: {arg1.FilterString()}"); - } - } + class Say + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{MsgSayPrefix} {player.playerData.username}: {arg1.FilterString()}"); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Search.cs b/source/BP-Essentials/Chat/Commands/Admin/Search.cs index ce7b9437..f7451ac0 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Search.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Search.cs @@ -12,37 +12,37 @@ class Search { public static void Run(SvPlayer player, string message) { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - if (currPlayer == player.player) - { - player.SendChatMessage($"You cannot search yourself."); - return; - } - if (currPlayer.IsDead()) - { - player.SendChatMessage($"You cannot search this player because he or she is dead."); - return; - } - if (currPlayer.otherEntity) - currPlayer.svPlayer.SvStopInventory(true); - currPlayer.viewers.Add(player.player); - player.player.otherEntity = currPlayer; - player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.Searching, player.player.otherEntity.ID, player.player.otherEntity.SerializeMyItems()); - if (!currPlayer.svPlayer.serverside && currPlayer.viewers.Count == 1) - currPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowSearchedInventory, new object[] { }); - player.SendChatMessage($"Viewing inventory of {currPlayer.username}"); - currPlayer.svPlayer.SendChatMessage(AdminSearchingInv); + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + if (currPlayer == player.player) + { + player.SendChatMessage($"You cannot search yourself."); + return; + } + if (currPlayer.IsDead()) + { + player.SendChatMessage($"You cannot search this player because he or she is dead."); + return; + } + if (currPlayer.otherEntity) + currPlayer.svPlayer.SvStopInventory(true); + currPlayer.viewers.Add(player.player); + player.player.otherEntity = currPlayer; + player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.Searching, player.player.otherEntity.ID, player.player.otherEntity.SerializeMyItems()); + if (!currPlayer.svPlayer.serverside && currPlayer.viewers.Count == 1) + currPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowSearchedInventory, new object[] { }); + player.SendChatMessage($"Viewing inventory of {currPlayer.username}"); + currPlayer.svPlayer.SendChatMessage(AdminSearchingInv); } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Slap.cs b/source/BP-Essentials/Chat/Commands/Admin/Slap.cs index 1f335070..aee9f283 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Slap.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Slap.cs @@ -10,25 +10,25 @@ namespace BP_Essentials.Commands { class Slap { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - int amount = new System.Random().Next(4, 15); - currPlayer.svPlayer.Damage(DamageIndex.Null, amount, null, null); - currPlayer.svPlayer.SvForce(new Vector3(500f, 0f, 500f)); - currPlayer.svPlayer.SendChatMessage($"You got slapped by {player.player.username}! [-{amount} HP]"); - player.SendChatMessage($"You've slapped {currPlayer.username}. [-{amount} HP]"); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + int amount = new System.Random().Next(4, 15); + currPlayer.svPlayer.Damage(DamageIndex.Null, amount, null, null); + currPlayer.svPlayer.SvForce(new Vector3(500f, 0f, 500f)); + currPlayer.svPlayer.SendChatMessage($"You got slapped by {player.player.username}! [-{amount} HP]"); + player.SendChatMessage($"You've slapped {currPlayer.username}. [-{amount} HP]"); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Snap.cs b/source/BP-Essentials/Chat/Commands/Admin/Snap.cs index ec82e64b..bdd13ed4 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Snap.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Snap.cs @@ -8,15 +8,15 @@ namespace BP_Essentials.Commands { - // lol - class Snap - { - public static void Run(SvPlayer player, string message) - { - var playersToBePwned = (new System.Random().NextDouble() >= 0.5 ? PlayerList.Take(PlayerList.Count / 2) : PlayerList.Skip(PlayerList.Count / 2)).Select(x => x.Value.ShPlayer).ToList(); - for (int i = 0; i < playersToBePwned.Count; i++) - playersToBePwned[i].svPlayer.SvSuicide(); - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"Perfectly balanced, as all things should be."); - } - } + // lol + class Snap + { + public static void Run(SvPlayer player, string message) + { + var playersToBePwned = (new System.Random().NextDouble() >= 0.5 ? PlayerList.Take(PlayerList.Count / 2) : PlayerList.Skip(PlayerList.Count / 2)).Select(x => x.Value.ShPlayer).ToList(); + for (int i = 0; i < playersToBePwned.Count; i++) + playersToBePwned[i].svPlayer.SvSuicide(); + player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"Perfectly balanced, as all things should be."); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/SpawnVehicle.cs b/source/BP-Essentials/Chat/Commands/Admin/SpawnVehicle.cs index aa4d36fb..384f572b 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/SpawnVehicle.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/SpawnVehicle.cs @@ -8,39 +8,39 @@ namespace BP_Essentials.Commands { - class SpawnVehicle - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - bool parsedSuccessfully = int.TryParse(arg1, out int arg1int); - if (!parsedSuccessfully) - { - player.SendChatMessage(NotValidArg); - return; - } - if (arg1int < 0 || arg1int > IDs_Vehicles.Length) - { - player.SendChatMessage($"Error: The ID must be between 1 and {IDs_Vehicles.Length}."); - return; - } - var shPlayer = player.player; - var pos = shPlayer.GetPosition(); - if (!player.player.IsOutside()) - { - player.SendChatMessage($"Cannot spawn inside a building."); - return; - } - if (arg1.Length > 4) - SvMan.AddNewEntity(ShManager.GetEntity(arg1int), shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 10F, pos.z), shPlayer.GetRotation(), false); - else - SvMan.AddNewEntity(ShManager.GetEntity(IDs_Vehicles[arg1int - 1]), shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 7F, pos.z), shPlayer.GetRotation(), false); - player.SendChatMessage($"Spawning in vehicle with the ID: {arg1}"); - } - } + class SpawnVehicle + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + bool parsedSuccessfully = int.TryParse(arg1, out int arg1int); + if (!parsedSuccessfully) + { + player.SendChatMessage(NotValidArg); + return; + } + if (arg1int < 0 || arg1int > IDs_Vehicles.Length) + { + player.SendChatMessage($"Error: The ID must be between 1 and {IDs_Vehicles.Length}."); + return; + } + var shPlayer = player.player; + var pos = shPlayer.GetPosition(); + if (!player.player.IsOutside()) + { + player.SendChatMessage($"Cannot spawn inside a building."); + return; + } + if (arg1.Length > 4) + SvMan.AddNewEntity(ShManager.GetEntity(arg1int), shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 10F, pos.z), shPlayer.GetRotation(), false); + else + SvMan.AddNewEntity(ShManager.GetEntity(IDs_Vehicles[arg1int - 1]), shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 7F, pos.z), shPlayer.GetRotation(), false); + player.SendChatMessage($"Spawning in vehicle with the ID: {arg1}"); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Strip.cs b/source/BP-Essentials/Chat/Commands/Admin/Strip.cs index 383701be..c0925023 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Strip.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Strip.cs @@ -8,36 +8,36 @@ namespace BP_Essentials.Commands { - class Strip - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - // To be improved - currPlayer.svPlayer.SvSetWearable(-1626497894); //NullArmor - currPlayer.svPlayer.SvSetWearable(673780802); //NullBack - currPlayer.svPlayer.SvSetWearable(-1638932793); //NullBody - currPlayer.svPlayer.SvSetWearable(1089711634); //NullFace - currPlayer.svPlayer.SvSetWearable(2064679354); //NullFeet - currPlayer.svPlayer.SvSetWearable(1174688158); //NullHands - currPlayer.svPlayer.SvSetWearable(-501996567); //NullHead - currPlayer.svPlayer.SvSetWearable(-1191209217); //NullLegs - foreach (var item in currPlayer.myItems.Values.ToList()) - if (item.item.GetType() == typeof(ShWearable)) - currPlayer.TransferItem(DeltaInv.RemoveFromMe, item.item.index, currPlayer.MyItemCount(item.item.index), true); - currPlayer.svPlayer.SendChatMessage($"{player.playerData.username} Removed your clothes."); - player.SendChatMessage($"Removed {currPlayer.username}'s clothes."); - } - } + class Strip + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + // To be improved + currPlayer.svPlayer.SvSetWearable(-1626497894); //NullArmor + currPlayer.svPlayer.SvSetWearable(673780802); //NullBack + currPlayer.svPlayer.SvSetWearable(-1638932793); //NullBody + currPlayer.svPlayer.SvSetWearable(1089711634); //NullFace + currPlayer.svPlayer.SvSetWearable(2064679354); //NullFeet + currPlayer.svPlayer.SvSetWearable(1174688158); //NullHands + currPlayer.svPlayer.SvSetWearable(-501996567); //NullHead + currPlayer.svPlayer.SvSetWearable(-1191209217); //NullLegs + foreach (var item in currPlayer.myItems.Values.ToList()) + if (item.item.GetType() == typeof(ShWearable)) + currPlayer.TransferItem(DeltaInv.RemoveFromMe, item.item.index, currPlayer.MyItemCount(item.item.index), true); + currPlayer.svPlayer.SendChatMessage($"{player.playerData.username} Removed your clothes."); + player.SendChatMessage($"Removed {currPlayer.username}'s clothes."); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Sudo.cs b/source/BP-Essentials/Chat/Commands/Admin/Sudo.cs index 280a914d..a2009082 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Sudo.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Sudo.cs @@ -8,25 +8,25 @@ namespace BP_Essentials.Commands { - class Sudo - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, false, message); - string arg2 = GetArgument.Run(2, false, true, message); - if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2)) - { - player.SendChatMessage(ArgRequired); - return; - } - var shPlayer = GetShByStr.Run(arg1, true); - if (shPlayer == null) - { - player.SendChatMessage(NotFoundOnlineIdOnly); - return; - } - shPlayer.svPlayer.SvGlobalChatMessage(arg2); - player.SendChatMessage($"You sudo'ed {shPlayer.username} to type {arg2} in the global chat."); - } - } + class Sudo + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, false, message); + string arg2 = GetArgument.Run(2, false, true, message); + if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2)) + { + player.SendChatMessage(ArgRequired); + return; + } + var shPlayer = GetShByStr.Run(arg1, true); + if (shPlayer == null) + { + player.SendChatMessage(NotFoundOnlineIdOnly); + return; + } + shPlayer.svPlayer.SvGlobalChatMessage(arg2); + player.SendChatMessage($"You sudo'ed {shPlayer.username} to type {arg2} in the global chat."); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs b/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs index 819b19ae..dc874c45 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs @@ -11,25 +11,25 @@ namespace BP_Essentials.Commands { class ToggleStaffChat { - public static void Run(SvPlayer player, string message) - { - var arg1 = GetArgument.Run(1, false, true, message); - var shplayer = player.player; - if (string.IsNullOrEmpty(arg1)) - { - if (PlayerList[shplayer.ID].StaffChatEnabled) - { - PlayerList[shplayer.ID].StaffChatEnabled = false; - player.SendChatMessage($"Staff chat disabled."); - } - else - { - PlayerList[shplayer.ID].StaffChatEnabled = true; - player.SendChatMessage($"Staff chat enabled."); - } - return; - } - SendChatMessageToAdmins.Run(PlaceholderParser.ParseUserMessage(player.player, AdminChatMessage, arg1)); - } + public static void Run(SvPlayer player, string message) + { + var arg1 = GetArgument.Run(1, false, true, message); + var shplayer = player.player; + if (string.IsNullOrEmpty(arg1)) + { + if (PlayerList[shplayer.ID].StaffChatEnabled) + { + PlayerList[shplayer.ID].StaffChatEnabled = false; + player.SendChatMessage($"Staff chat disabled."); + } + else + { + PlayerList[shplayer.ID].StaffChatEnabled = true; + player.SendChatMessage($"Staff chat enabled."); + } + return; + } + SendChatMessageToAdmins.Run(PlaceholderParser.ParseUserMessage(player.player, AdminChatMessage, arg1)); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/Tp.cs b/source/BP-Essentials/Chat/Commands/Admin/Tp.cs index 3401919c..7e50bed8 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Tp.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Tp.cs @@ -4,24 +4,24 @@ namespace BP_Essentials.Commands { - public class Tp - { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var shPlayer = GetShByStr.Run(arg1); - if (shPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - player.ResetAndSavePosition(shPlayer.GetPosition(), shPlayer.GetRotation(), shPlayer.GetPlaceIndex()); - player.SendChatMessage($"Teleported to {shPlayer.username}."); - } - } + public class Tp + { + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var shPlayer = GetShByStr.Run(arg1); + if (shPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + player.ResetAndSavePosition(shPlayer.GetPosition(), shPlayer.GetRotation(), shPlayer.GetPlaceIndex()); + player.SendChatMessage($"Teleported to {shPlayer.username}."); + } + } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs b/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs index f81c67c8..1e592163 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs @@ -6,24 +6,24 @@ namespace BP_Essentials.Commands { public class TpHere { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var shPlayer = GetShByStr.Run(arg1); - var shPlayer1 = player.player; - if (shPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - shPlayer.svPlayer.ResetAndSavePosition(shPlayer1.GetPosition(), shPlayer1.GetRotation(), shPlayer1.GetPlaceIndex()); - shPlayer.svPlayer.SendChatMessage($"{shPlayer1.username} Teleported you to him."); - player.SendChatMessage($"Teleported {shPlayer.username} To you."); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var shPlayer = GetShByStr.Run(arg1); + var shPlayer1 = player.player; + if (shPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + shPlayer.svPlayer.ResetAndSavePosition(shPlayer1.GetPosition(), shPlayer1.GetRotation(), shPlayer1.GetPlaceIndex()); + shPlayer.svPlayer.SendChatMessage($"{shPlayer1.username} Teleported you to him."); + player.SendChatMessage($"Teleported {shPlayer.username} To you."); + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpJob.cs b/source/BP-Essentials/Chat/Commands/Admin/TpJob.cs index cb3c193e..dc8a888f 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/TpJob.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/TpJob.cs @@ -7,25 +7,25 @@ namespace BP_Essentials.Commands { - class TpJob - { - public static void Run(SvPlayer player, string message) - { - var arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrWhiteSpace(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - var bosses = UnityEngine.Object.FindObjectsOfType().Where(x => x.boss || x.svPlayer.serverside); - var boss = bosses.FirstOrDefault(x => x.ID.ToString() == arg1 || x.username == arg1 || x.username.StartsWith(arg1, StringComparison.CurrentCultureIgnoreCase) || x.job.info.jobName == arg1.ToLower() || x.job.info.jobName.StartsWith(arg1, StringComparison.CurrentCultureIgnoreCase)); - if (boss == default(ShPlayer)) - { - player.SendChatMessage(NotFoundOnline); - return; - } - player.ResetAndSavePosition(boss.svPlayer); - player.SendChatMessage($"Teleported to {boss.username} ({boss.job.info.jobName})"); - } - } + class TpJob + { + public static void Run(SvPlayer player, string message) + { + var arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrWhiteSpace(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + var bosses = UnityEngine.Object.FindObjectsOfType().Where(x => x.boss || x.svPlayer.serverside); + var boss = bosses.FirstOrDefault(x => x.ID.ToString() == arg1 || x.username == arg1 || x.username.StartsWith(arg1, StringComparison.CurrentCultureIgnoreCase) || x.job.info.jobName == arg1.ToLower() || x.job.info.jobName.StartsWith(arg1, StringComparison.CurrentCultureIgnoreCase)); + if (boss == default(ShPlayer)) + { + player.SendChatMessage(NotFoundOnline); + return; + } + player.ResetAndSavePosition(boss.svPlayer); + player.SendChatMessage($"Teleported to {boss.username} ({boss.job.info.jobName})"); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpLocation.cs b/source/BP-Essentials/Chat/Commands/Admin/TpLocation.cs index 22fdec84..4fefc3e4 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/TpLocation.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/TpLocation.cs @@ -7,8 +7,8 @@ namespace BP_Essentials.Commands { - [Obsolete] - public class TpLocation + [Obsolete] + public class TpLocation { [Obsolete] public static void Run(SvPlayer player, string message) diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs b/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs index 54be5f41..87ae8d0f 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs @@ -4,11 +4,11 @@ namespace BP_Essentials.Commands { - [Obsolete] - public class TpToApartment + [Obsolete] + public class TpToApartment { - [Obsolete] - public static void Run(SvPlayer player, string message) + [Obsolete] + public static void Run(SvPlayer player, string message) { var arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) diff --git a/source/BP-Essentials/Chat/Commands/Admin/Wipe.cs b/source/BP-Essentials/Chat/Commands/Admin/Wipe.cs index 8a5d4322..23f97714 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Wipe.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Wipe.cs @@ -32,9 +32,9 @@ public static void Run(SvPlayer player, string message) foreach (var currPlayer in PlayerList.Values.ToList()) player.svManager.Disconnect(currPlayer.ShPlayer.svPlayer.connection, DisconnectTypes.Problem); Thread.Sleep(500); - var files = Directory.GetFiles(Path.Combine(Application.persistentDataPath, "PlayerData/"), "*.json").Where(item => item.EndsWith(".json", StringComparison.CurrentCulture)); - foreach (var file in files.ToList()) - File.Delete(file); + var files = Directory.GetFiles(Path.Combine(Application.persistentDataPath, "PlayerData/"), "*.json").Where(item => item.EndsWith(".json", StringComparison.CurrentCulture)); + foreach (var file in files.ToList()) + File.Delete(file); Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] All user data deleted!"); } } diff --git a/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs b/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs index 53c41310..aab6fb62 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs @@ -11,42 +11,42 @@ namespace BP_Essentials.Commands { class _SetJob : SvPlayer { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, false, message); - string arg2 = GetArgument.Run(2, false, true, message); - byte arg1Parsed = 10; - string msg = $"Set {{0}}'s Job to {{1}}."; - if (string.IsNullOrEmpty(arg2)) - arg2 = player.player.username; - if (string.IsNullOrEmpty(arg1)) - { - player.SendChatMessage(NotValidArg); - return; - } - bool parsedCorrectly = true; - if (Jobs.Contains(arg1)) - arg1Parsed = Convert.ToByte((Array.IndexOf(Jobs, arg1))); - else - parsedCorrectly = byte.TryParse(arg1, out arg1Parsed); - if (!parsedCorrectly) - { - player.SendChatMessage(NotValidArg); - return; - } - if (arg1Parsed > Jobs.Length || arg1Parsed < 0) - { - player.SendChatMessage($"Error: The value must be between 0 and {Jobs.Length}."); - return; - } - var currPlayer = GetShByStr.Run(arg2); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - player.SendChatMessage(string.Format(msg, currPlayer.username, Jobs[arg1Parsed])); - SetJob.Run(currPlayer, arg1Parsed, true, false); - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, false, message); + string arg2 = GetArgument.Run(2, false, true, message); + byte arg1Parsed = 10; + string msg = $"Set {{0}}'s Job to {{1}}."; + if (string.IsNullOrEmpty(arg2)) + arg2 = player.player.username; + if (string.IsNullOrEmpty(arg1)) + { + player.SendChatMessage(NotValidArg); + return; + } + bool parsedCorrectly = true; + if (Jobs.Contains(arg1)) + arg1Parsed = Convert.ToByte((Array.IndexOf(Jobs, arg1))); + else + parsedCorrectly = byte.TryParse(arg1, out arg1Parsed); + if (!parsedCorrectly) + { + player.SendChatMessage(NotValidArg); + return; + } + if (arg1Parsed > Jobs.Length || arg1Parsed < 0) + { + player.SendChatMessage($"Error: The value must be between 0 and {Jobs.Length}."); + return; + } + var currPlayer = GetShByStr.Run(arg2); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + player.SendChatMessage(string.Format(msg, currPlayer.username, Jobs[arg1Parsed])); + SetJob.Run(currPlayer, arg1Parsed, true, false); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs b/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs index c85c4dea..f54e374c 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs @@ -5,26 +5,26 @@ namespace BP_Essentials.Commands { public class ClearChat { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, false, message); - if (arg1 == "all" || arg1 == "everyone") - { - if (!player.player.admin) - { - player.Send(SvSendType.Self, Channel.Unsequenced, 10, MsgNoPerm); - return; - } - for (var i = 0; i < 6; i++) - player.Send(SvSendType.All, Channel.Unsequenced, 10, " "); - player.Send(SvSendType.All, Channel.Unsequenced, 10, $"{player.playerData.username} Cleared the chat for everyone."); - } - else - { - for (var i = 0; i < 6; i++) - player.Send(SvSendType.Self, Channel.Unsequenced, 10, " "); - player.Send(SvSendType.Self, Channel.Unsequenced, 10, $"Cleared the chat for yourself."); - } - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, false, message); + if (arg1 == "all" || arg1 == "everyone") + { + if (!player.player.admin) + { + player.Send(SvSendType.Self, Channel.Unsequenced, 10, MsgNoPerm); + return; + } + for (var i = 0; i < 6; i++) + player.Send(SvSendType.All, Channel.Unsequenced, 10, " "); + player.Send(SvSendType.All, Channel.Unsequenced, 10, $"{player.playerData.username} Cleared the chat for everyone."); + } + else + { + for (var i = 0; i < 6; i++) + player.Send(SvSendType.Self, Channel.Unsequenced, 10, " "); + player.Send(SvSendType.Self, Channel.Unsequenced, 10, $"Cleared the chat for yourself."); + } + } } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs b/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs index 6c5bbb28..a2dcdcf3 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs @@ -18,6 +18,11 @@ public static void Run(SvPlayer player, string message) player.SendChatMessage($"You don't have a apartment to sell!"); return; } + if (shPlayer.InOwnApartment()) + { + player.SendChatMessage($"You cannot sell your apartment while you're in it."); + return; + } player.SendChatMessage($"Selling apartment..."); SellApartment(shPlayer); } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs b/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs index a167bc2e..201c8188 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs @@ -5,32 +5,32 @@ public class Essentials { public static void Run(SvPlayer player, string message) { string arg = GetArgument.Run(1, false, false, message).Trim().ToLower(); - switch (arg) - { - case "ver": - case "version": - player.SendChatMessage("Version: " + Variables.Version); - break; - case "help": - player.SendChatMessage("Subcommands for /essentials:"); - player.SendChatMessage(" - help : Shows this menu."); - player.SendChatMessage(" - info : Shows infomation about the developer."); - player.SendChatMessage(" - ver/version : Shows version number."); - player.SendChatMessage(" - cmd/command : Gives a link to the website of BP-Essentials."); - break; - case "cmd": - case "cmds": - case "command": - case "commands": - player.SendChatMessage("Up to date help can be found at https://goo.gl/Rwhtjs"); - break; - case "info": - default: - player.SendChatMessage("Essentials Created by UserR00T & DeathByKorea & BP."); - player.SendChatMessage("Version " + Variables.Version); - player.SendChatMessage("Type '/essentials help' for more info. "); - break; - } - } + switch (arg) + { + case "ver": + case "version": + player.SendChatMessage("Version: " + Variables.Version); + break; + case "help": + player.SendChatMessage("Subcommands for /essentials:"); + player.SendChatMessage(" - help : Shows this menu."); + player.SendChatMessage(" - info : Shows infomation about the developer."); + player.SendChatMessage(" - ver/version : Shows version number."); + player.SendChatMessage(" - cmd/command : Gives a link to the website of BP-Essentials."); + break; + case "cmd": + case "cmds": + case "command": + case "commands": + player.SendChatMessage("Up to date help can be found at https://goo.gl/Rwhtjs"); + break; + case "info": + default: + player.SendChatMessage("Essentials Created by UserR00T & DeathByKorea & BP."); + player.SendChatMessage("Version " + Variables.Version); + player.SendChatMessage("Type '/essentials help' for more info. "); + break; + } + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs b/source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs index ef22271c..f3411b68 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs @@ -57,6 +57,6 @@ public static void Run(SvPlayer player, string message) SvMan.StartCoroutine(Variables.KitsHandler.StartCooldown(player.player.username, obj)); player.SendChatMessage($"You've been given the kit {arg1}.{(obj.Delay > 0 ? $" You can get this kit again in {obj.Delay} seconds." : "")}"); - } + } } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/GoToWarp.cs b/source/BP-Essentials/Chat/Commands/Everyone/GoToWarp.cs index 429a5349..1b9ec9bb 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/GoToWarp.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/GoToWarp.cs @@ -52,7 +52,7 @@ public static void Run(SvPlayer player, string message) player.ResetAndSavePosition(new Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z), new Quaternion(obj.Rotation.X, obj.Rotation.Y, obj.Rotation.Z, obj.Rotation.W), obj.Position.PlaceIndex); if (obj.Delay > 0) SvMan.StartCoroutine(Variables.WarpHandler.StartCooldown(player.player.username, obj)); - player.SendChatMessage($"You've been teleported to the warp named {arg1}.{(obj.Delay > 0 ? $" You can teleport to this warp again in {obj.Delay} seconds." : "")}"); + player.SendChatMessage($"You've been teleported to the warp named {arg1}.{(obj.Delay > 0 ? $" You can teleport to this warp again in {obj.Delay} seconds." : "")}"); } } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Home.cs b/source/BP-Essentials/Chat/Commands/Everyone/Home.cs index 037df59b..ba0309f9 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Home.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Home.cs @@ -13,7 +13,7 @@ public static void Run(SvPlayer player, string message) player.SendChatMessage($"You don't have a apartment to teleport to!"); return; } - player.ResetAndSavePosition(shPlayer.ownedApartment.svDoor.transform.position, shPlayer.ownedApartment.svDoor.transform.rotation, 0); + player.ResetAndSavePosition(shPlayer.ownedApartment.svDoor.transform.position, shPlayer.ownedApartment.svDoor.transform.rotation, 0); player.SendChatMessage($"Teleported to your apartment."); } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Me.cs b/source/BP-Essentials/Chat/Commands/Everyone/Me.cs index 3b0d85f2..51feded2 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Me.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Me.cs @@ -7,17 +7,17 @@ namespace BP_Essentials.Commands { - class Me - { - public static void Run(SvPlayer player, string message) - { - var arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrWhiteSpace(arg1)) - { - player.SendChatMessage(ArgRequired); - return; - } - player.Send(LocalChatMe ? SvSendType.Local : SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, PlaceholderParser.ParseUserMessage(player.player, MeMessage, arg1)); - } - } + class Me + { + public static void Run(SvPlayer player, string message) + { + var arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrWhiteSpace(arg1)) + { + player.SendChatMessage(ArgRequired); + return; + } + player.Send(LocalChatMe ? SvSendType.Local : SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, PlaceholderParser.ParseUserMessage(player.player, MeMessage, arg1)); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs b/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs index 6b8b96f4..0610dd0e 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs @@ -10,9 +10,9 @@ namespace BP_Essentials.Commands { class OnlinePlayers { - public static void Run(SvPlayer player, string message) - { - player.SendChatMessage($"There are/is {PlayerList.Count} player(s) online"); - } + public static void Run(SvPlayer player, string message) + { + player.SendChatMessage($"There are/is {PlayerList.Count} player(s) online"); + } } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs b/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs index d9a82144..4994f813 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs @@ -5,48 +5,48 @@ namespace BP_Essentials.Commands { - public class Pay - { - public static void Run(SvPlayer player, string message) - { - string correctSyntax = $"{GetArgument.Run(0, false, false, message)} [Player] [Amount] (Incorrect or missing argument(s).)"; - string arg1 = GetArgument.Run(1, false, true, message); - string arg2 = message.Split(' ').Last().Trim(); - if (string.IsNullOrEmpty(GetArgument.Run(1, false, false, message)) || string.IsNullOrEmpty(arg2)) - { - player.SendChatMessage(correctSyntax); - return; - } - int lastIndex = arg1.LastIndexOf(" ", StringComparison.CurrentCulture); - if (lastIndex != -1) - arg1 = arg1.Remove(lastIndex).Trim(); - var parsedSuccessfully = int.TryParse(arg2, out int arg2Int); - if (!parsedSuccessfully) - { - player.SendChatMessage(correctSyntax); - return; - } - if (arg2Int <= 0) - { - player.SendChatMessage($"Cannot transfer 0$ or less."); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } + public class Pay + { + public static void Run(SvPlayer player, string message) + { + string correctSyntax = $"{GetArgument.Run(0, false, false, message)} [Player] [Amount] (Incorrect or missing argument(s).)"; + string arg1 = GetArgument.Run(1, false, true, message); + string arg2 = message.Split(' ').Last().Trim(); + if (string.IsNullOrEmpty(GetArgument.Run(1, false, false, message)) || string.IsNullOrEmpty(arg2)) + { + player.SendChatMessage(correctSyntax); + return; + } + int lastIndex = arg1.LastIndexOf(" ", StringComparison.CurrentCulture); + if (lastIndex != -1) + arg1 = arg1.Remove(lastIndex).Trim(); + var parsedSuccessfully = int.TryParse(arg2, out int arg2Int); + if (!parsedSuccessfully) + { + player.SendChatMessage(correctSyntax); + return; + } + if (arg2Int <= 0) + { + player.SendChatMessage($"Cannot transfer 0$ or less."); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } - if (player.player.MyMoneyCount() < arg2Int) - { - player.SendChatMessage($"Cannot transfer money, do you have {arg2Int}$ in your inventory?"); - return; - } - player.player.TransferMoney(DeltaInv.RemoveFromMe, arg2Int, true); - currPlayer.TransferMoney(DeltaInv.AddToMe, arg2Int, true); - player.SendChatMessage($"Successfully transfered {arg2Int}$ to {currPlayer.username}!"); - currPlayer.svPlayer.SendChatMessage($"{player.player.username} gave you {arg2Int}$!"); - } - } + if (player.player.MyMoneyCount() < arg2Int) + { + player.SendChatMessage($"Cannot transfer money, do you have {arg2Int}$ in your inventory?"); + return; + } + player.player.TransferMoney(DeltaInv.RemoveFromMe, arg2Int, true); + currPlayer.TransferMoney(DeltaInv.AddToMe, arg2Int, true); + player.SendChatMessage($"Successfully transfered {arg2Int}$ to {currPlayer.username}!"); + currPlayer.svPlayer.SendChatMessage($"{player.player.username} gave you {arg2Int}$!"); + } + } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/ReplyUser.cs b/source/BP-Essentials/Chat/Commands/Everyone/ReplyUser.cs index 45fe75df..b6163d6f 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/ReplyUser.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/ReplyUser.cs @@ -24,8 +24,8 @@ public static void Run(SvPlayer player, string message) player.SendChatMessage(ArgRequired); return; } - PlayerList[replyUser.ID].ReplyToUser = player.player; - player.SendChatMessage($"[PM] {replyUser.username} > {arg1}"); + PlayerList[replyUser.ID].ReplyToUser = player.player; + player.SendChatMessage($"[PM] {replyUser.username} > {arg1}"); replyUser.svPlayer.SendChatMessage($"[PM] {player.player.username} < {arg1}"); } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs index e65cf138..c20d67e5 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs @@ -9,46 +9,46 @@ namespace BP_Essentials.Commands { class Report { - public static void Run(SvPlayer player, string message) - { - string arg1 = GetArgument.Run(1, false, true, message); - if (string.IsNullOrEmpty(arg1)) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Missing argument! Correct syntax: {GetArgument.Run(0, false, false, message)} [player]"); - return; - } - var currPlayer = GetShByStr.Run(arg1); - if (currPlayer == null) - { - player.SendChatMessage(NotFoundOnline); - return; - } - if (currPlayer == player.player) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report yourself, dummy."); - return; - } - if (player.player.admin) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report as admin."); - return; - } - if (currPlayer.admin) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report an admin."); - return; - } - var builder = new StringBuilder(); - builder.Append("Reporting " + arg1 + "\nReason:\n\n"); - for (int i = 0; i < ReportReasons.Length; i++) - { - if (string.IsNullOrWhiteSpace(ReportReasons[i])) - continue; - builder.Append("F" + (i + 2) + ": " + ReportReasons[i] + "\n"); - } - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, builder + "\nPress F11 To close this (G)UI"); - PlayerList[player.player.ID].LastMenu = CurrentMenu.Report; - PlayerList[player.player.ID].ReportedPlayer = currPlayer; - } + public static void Run(SvPlayer player, string message) + { + string arg1 = GetArgument.Run(1, false, true, message); + if (string.IsNullOrEmpty(arg1)) + { + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Missing argument! Correct syntax: {GetArgument.Run(0, false, false, message)} [player]"); + return; + } + var currPlayer = GetShByStr.Run(arg1); + if (currPlayer == null) + { + player.SendChatMessage(NotFoundOnline); + return; + } + if (currPlayer == player.player) + { + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report yourself, dummy."); + return; + } + if (player.player.admin) + { + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report as admin."); + return; + } + if (currPlayer.admin) + { + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report an admin."); + return; + } + var builder = new StringBuilder(); + builder.Append("Reporting " + arg1 + "\nReason:\n\n"); + for (int i = 0; i < ReportReasons.Length; i++) + { + if (string.IsNullOrWhiteSpace(ReportReasons[i])) + continue; + builder.Append("F" + (i + 2) + ": " + ReportReasons[i] + "\n"); + } + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, builder + "\nPress F11 To close this (G)UI"); + PlayerList[player.player.ID].LastMenu = CurrentMenu.Report; + PlayerList[player.player.ID].ReportedPlayer = currPlayer; + } } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs b/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs index fe33853e..8d24cff6 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs @@ -12,8 +12,8 @@ class ToggleChat { public static void Run(SvPlayer player, string message) { - PlayerList[player.player.ID].ChatEnabled = !PlayerList[player.player.ID].ChatEnabled; - player.SendChatMessage($"Chat {(PlayerList[player.player.ID].ChatEnabled ? "enabled" : "disabled")}."); + PlayerList[player.player.ID].ChatEnabled = !PlayerList[player.player.ID].ChatEnabled; + player.SendChatMessage($"Chat {(PlayerList[player.player.ID].ChatEnabled ? "enabled" : "disabled")}."); } } } diff --git a/source/BP-Essentials/Chat/Commands/Everyone/TpaUser.cs b/source/BP-Essentials/Chat/Commands/Everyone/TpaUser.cs index dbbeaed9..e9367cb7 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/TpaUser.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/TpaUser.cs @@ -24,11 +24,11 @@ public static void Run(SvPlayer player, string message) player.SendChatMessage(NotFoundOnline); return; } - if (shPlayer == player.player) - { - player.SendChatMessage($"You cannot teleport to yourself."); - return; - } + if (shPlayer == player.player) + { + player.SendChatMessage($"You cannot teleport to yourself."); + return; + } PlayerList[shPlayer.ID].TpaUser = player.player; player.SendChatMessage($"Sent a TPA request to {shPlayer.username}."); shPlayer.svPlayer.SendChatMessage($"{player.player.username} sent you a tpa request. Type {CmdCommandCharacter}{CmdTpaaccept} to accept it."); diff --git a/source/BP-Essentials/Chat/LangAndChatBlock.cs b/source/BP-Essentials/Chat/LangAndChatBlock.cs index 53af6037..cb46783a 100644 --- a/source/BP-Essentials/Chat/LangAndChatBlock.cs +++ b/source/BP-Essentials/Chat/LangAndChatBlock.cs @@ -13,7 +13,7 @@ class LangAndChatBlock { public static string Run(string message) { - // todo + // todo try { if (ChatBlock) diff --git a/source/BP-Essentials/Core.cs b/source/BP-Essentials/Core.cs index c47288f9..f4a8f46d 100644 --- a/source/BP-Essentials/Core.cs +++ b/source/BP-Essentials/Core.cs @@ -24,61 +24,61 @@ namespace BP_Essentials public class Core { - //Initialization - [Hook("SvManager.StartServer")] - public static void StartServer(SvManager svManager) - { - Debug.Log("[INFO] Essentials - Starting up.."); - try - { - SvMan = svManager; - Methods.Utils.FunctionMenu.RegisterMenus(); - Reload.Run(true, null, true); - CheckAutoReloadFile.Run(AutoReloader); - if (Variables.Version != LocalVersion) - { - Debug.Log("[ERROR] Essentials - Versions do not match!"); - Debug.Log("[ERROR] Essentials - Essentials assembly version: " + Variables.Version); - Debug.Log("[ERROR] Essentials - Settings file version: " + LocalVersion); - Debug.Log(""); - Debug.Log(""); - Debug.Log("[ERROR] Essentials - Recreating settings file!"); - string date = DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss"); - if (File.Exists(SettingsFile + "." + date + ".OLD")) - File.Delete(SettingsFile + "." + date + ".OLD"); - File.Move(SettingsFile, $"{SettingsFile}.{date}.OLD"); - Reload.Run(true); - } - Save.StartSaveTimer(); - Variables.WarpHandler = new WarpHandler(); - Variables.WarpHandler.LoadAll(true); - Variables.KitsHandler = new KitsHandler(); - Variables.KitsHandler.LoadAll(true); - Debug.Log("-------------------------------------------------------------------------------"); - Debug.Log($"[INFO] Essentials - Version: {LocalVersion} {(IsPreRelease ? "[PRE-RELEASE] " : "")}Loaded in successfully!"); - Debug.Log("-------------------------------------------------------------------------------"); - } - catch (Exception ex) - { - Debug.Log("-------------------------------------------------------------------------------"); - Debug.Log(" "); - Debug.Log("[ERROR] Essentials - Whoopsie doopsie, something went wrong."); - Debug.Log("[ERROR] Essentials - Please check the error below for more info,"); - Debug.Log("[ERROR] Essentials - And it would be highly appreciated if you would send the error to the developers of this plugin!"); - Debug.Log(" "); - Debug.Log(ex); - Debug.Log(ex.ToString()); - Debug.Log("-------------------------------------------------------------------------------"); + //Initialization + [Hook("SvManager.StartServer")] + public static void StartServer(SvManager svManager) + { + Debug.Log("[INFO] Essentials - Starting up.."); + try + { + SvMan = svManager; + Methods.Utils.FunctionMenu.RegisterMenus(); + Reload.Run(true, null, true); + CheckAutoReloadFile.Run(AutoReloader); + if (Variables.Version != LocalVersion) + { + Debug.Log("[ERROR] Essentials - Versions do not match!"); + Debug.Log("[ERROR] Essentials - Essentials assembly version: " + Variables.Version); + Debug.Log("[ERROR] Essentials - Settings file version: " + LocalVersion); + Debug.Log(""); + Debug.Log(""); + Debug.Log("[ERROR] Essentials - Recreating settings file!"); + string date = DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss"); + if (File.Exists(SettingsFile + "." + date + ".OLD")) + File.Delete(SettingsFile + "." + date + ".OLD"); + File.Move(SettingsFile, $"{SettingsFile}.{date}.OLD"); + Reload.Run(true); + } + Save.StartSaveTimer(); + Variables.WarpHandler = new WarpHandler(); + Variables.WarpHandler.LoadAll(true); + Variables.KitsHandler = new KitsHandler(); + Variables.KitsHandler.LoadAll(true); + Debug.Log("-------------------------------------------------------------------------------"); + Debug.Log($"[INFO] Essentials - Version: {LocalVersion} {(IsPreRelease ? "[PRE-RELEASE] " : "")}Loaded in successfully!"); + Debug.Log("-------------------------------------------------------------------------------"); + } + catch (Exception ex) + { + Debug.Log("-------------------------------------------------------------------------------"); + Debug.Log(" "); + Debug.Log("[ERROR] Essentials - Whoopsie doopsie, something went wrong."); + Debug.Log("[ERROR] Essentials - Please check the error below for more info,"); + Debug.Log("[ERROR] Essentials - And it would be highly appreciated if you would send the error to the developers of this plugin!"); + Debug.Log(" "); + Debug.Log(ex); + Debug.Log(ex.ToString()); + Debug.Log("-------------------------------------------------------------------------------"); - } - Debug.Log("[INFO] Essentials - Ready."); + } + Debug.Log("[INFO] Essentials - Ready."); - if (Variables.Announcer.Announcements.Count == 0) - { - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] No announcements found in the file!"); - return; - } - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Announcer started successfully!"); - } + if (Variables.Announcer.Announcements.Count == 0) + { + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] No announcements found in the file!"); + return; + } + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Announcer started successfully!"); + } } } \ No newline at end of file diff --git a/source/BP-Essentials/ExtensionMethods.cs b/source/BP-Essentials/ExtensionMethods.cs index 4aafc9f5..c50bdbbc 100644 --- a/source/BP-Essentials/ExtensionMethods.cs +++ b/source/BP-Essentials/ExtensionMethods.cs @@ -9,46 +9,46 @@ namespace BP_Essentials { - public static class ExtensionMethods - { - public static void SavePosition(this SvPlayer player) - { - player.SavePosition(player.player.GetPosition(), player.player.GetRotation(), player.player.GetPlaceIndex()); - } - public static void SavePosition(this SvPlayer player, Vector3 position, Quaternion rotation, int index) - { - if (!PlayerList.TryGetValue(player.player.ID, out var playerValue)) - return; - playerValue.LastLocation.Update(position, rotation, index); - } - public static void ResetAndSavePosition(this SvPlayer player, Vector3 position, Quaternion rotation, int index) - { - player.SavePosition(); - player.SvReset(position, rotation, index); - } - public static void ResetAndSavePosition(this SvPlayer player, SvPlayer targetPlayer) - { - player.SavePosition(); - player.SvReset(targetPlayer.player.GetPosition(), targetPlayer.player.GetRotation(), targetPlayer.player.GetPlaceIndex()); - } + public static class ExtensionMethods + { + public static void SavePosition(this SvPlayer player) + { + player.SavePosition(player.player.GetPosition(), player.player.GetRotation(), player.player.GetPlaceIndex()); + } + public static void SavePosition(this SvPlayer player, Vector3 position, Quaternion rotation, int index) + { + if (!PlayerList.TryGetValue(player.player.ID, out var playerValue)) + return; + playerValue.LastLocation.Update(position, rotation, index); + } + public static void ResetAndSavePosition(this SvPlayer player, Vector3 position, Quaternion rotation, int index) + { + player.SavePosition(); + player.SvReset(position, rotation, index); + } + public static void ResetAndSavePosition(this SvPlayer player, SvPlayer targetPlayer) + { + player.SavePosition(); + player.SvReset(targetPlayer.player.GetPosition(), targetPlayer.player.GetRotation(), targetPlayer.player.GetPlaceIndex()); + } public static void SendChatMessage(this ShPlayer player, string message) => player.svPlayer.SendChatMessage(message); - public static void SendChatMessage(this SvPlayer player, string message) => player.SendGameMessage(SvSendType.Self, message); - public static void SendChatMessageToAll(this SvPlayer player, string message) => player.SendGameMessage(SvSendType.All, message); - public static void SendGameMessage(this SvPlayer player, SvSendType type, string message) => player.Send(type, Channel.Unsequenced, ClPacket.GameMessage, message); + public static void SendChatMessage(this SvPlayer player, string message) => player.SendGameMessage(SvSendType.Self, message); + public static void SendChatMessageToAll(this SvPlayer player, string message) => player.SendGameMessage(SvSendType.All, message); + public static void SendGameMessage(this SvPlayer player, SvSendType type, string message) => player.Send(type, Channel.Unsequenced, ClPacket.GameMessage, message); - public static bool WillDieByDamage(this SvPlayer player, float damage) => (player.player.health - damage) <= 0; + public static bool WillDieByDamage(this SvPlayer player, float damage) => (player.player.health - damage) <= 0; - public static string FilterString(this string str) => new Regex("(<)").Replace(str, "<"); + public static string FilterString(this string str) => new Regex("(<)").Replace(str, "<"); - public static void CloseFunctionMenu(this SvPlayer player) => player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.CloseFunctionMenu); - public static void CloseAndResetFunctionMenu(this SvPlayer player) - { - player.CloseFunctionMenu(); - if (PlayerList.TryGetValue(player.player.ID, out var playerListItem)) - return; - playerListItem.LastMenu = CurrentMenu.None; - } + public static void CloseFunctionMenu(this SvPlayer player) => player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.CloseFunctionMenu); + public static void CloseAndResetFunctionMenu(this SvPlayer player) + { + player.CloseFunctionMenu(); + if (PlayerList.TryGetValue(player.player.ID, out var playerListItem)) + return; + playerListItem.LastMenu = CurrentMenu.None; + } - } + } } diff --git a/source/BP-Essentials/HookChat.cs b/source/BP-Essentials/HookChat.cs index 527a51b5..ab7d1f41 100644 --- a/source/BP-Essentials/HookChat.cs +++ b/source/BP-Essentials/HookChat.cs @@ -21,15 +21,15 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) try { var tempMessage = message; - if (HandleSpam.Run(player, tempMessage)) - return true; + if (HandleSpam.Run(player, tempMessage)) + return true; //Message Logging if (!MutePlayers.Contains(player.playerData.username)) LogMessage.Run(player, message); if (message.StartsWith(CmdCommandCharacter, StringComparison.CurrentCulture)) - if (OnCommand(player, ref message)) - return true; + if (OnCommand(player, ref message)) + return true; //Checks if the player is muted. if (MutePlayers.Contains(player.playerData.username)) @@ -71,54 +71,54 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) } return true; } - #endregion + #endregion - #region Event OnCommand | Global - public static bool OnCommand(SvPlayer player, ref string message) - { - var tempMessage = message; - var command = GetArgument.Run(0, false, false, message); - // CustomCommands - var customCommand = CustomCommands.FirstOrDefault(x => tempMessage.StartsWith(CmdCommandCharacter + x.Command, StringComparison.CurrentCulture)); - if (customCommand != null) - { - foreach (string line in customCommand.Response.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)) - player.SendChatMessage(PlaceholderParser.ParseUserMessage(player.player, line, message)); - PlayerList.Where(x => x.Value.SpyEnabled && x.Value.ShPlayer.svPlayer != player).ToList().ForEach(x => x.Value.ShPlayer.svPlayer.SendChatMessage($"[SPYCHAT] {player.playerData.username}: {tempMessage}")); - return true; - } - // Go through all registered commands and check if the command that the user entered matches - foreach (var cmd in CommandList.Values) - if (cmd.commandCmds.Contains(command)) - { - if (cmd.commandDisabled) - { - player.SendChatMessage(DisabledCommand); - return true; - } - if (HasPermission.Run(player, cmd.commandGroup, true, player.player.job.jobIndex) - && HasWantedLevel.Run(player, cmd.commandWantedAllowed) - && IsCuffed.Run(player, cmd.commandHandcuffedAllowed) - && IsJailed.Run(player, cmd.commandWhileJailedAllowed)) - { - PlayerList.Where(x => x.Value.SpyEnabled && x.Value.ShPlayer.svPlayer != player).ToList().ForEach(x => x.Value.ShPlayer.svPlayer.SendChatMessage($"[SPYCHAT] {player.playerData.username}: {tempMessage}")); - cmd.RunMethod.Invoke(player, message); - } - return true; - } - if (AfkPlayers.Contains(player.playerData.username)) - Commands.Afk.Run(player, message); - if (MsgUnknownCommand) - { - player.SendChatMessage($"Unknown command. Type {CmdCommandCharacter}essentials cmds for more info."); - return true; - } - return false; - } - #endregion + #region Event OnCommand | Global + public static bool OnCommand(SvPlayer player, ref string message) + { + var tempMessage = message; + var command = GetArgument.Run(0, false, false, message); + // CustomCommands + var customCommand = CustomCommands.FirstOrDefault(x => tempMessage.StartsWith(CmdCommandCharacter + x.Command, StringComparison.CurrentCulture)); + if (customCommand != null) + { + foreach (string line in customCommand.Response.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)) + player.SendChatMessage(PlaceholderParser.ParseUserMessage(player.player, line, message)); + PlayerList.Where(x => x.Value.SpyEnabled && x.Value.ShPlayer.svPlayer != player).ToList().ForEach(x => x.Value.ShPlayer.svPlayer.SendChatMessage($"[SPYCHAT] {player.playerData.username}: {tempMessage}")); + return true; + } + // Go through all registered commands and check if the command that the user entered matches + foreach (var cmd in CommandList.Values) + if (cmd.commandCmds.Contains(command)) + { + if (cmd.commandDisabled) + { + player.SendChatMessage(DisabledCommand); + return true; + } + if (HasPermission.Run(player, cmd.commandGroup, true, player.player.job.jobIndex) + && HasWantedLevel.Run(player, cmd.commandWantedAllowed) + && IsCuffed.Run(player, cmd.commandHandcuffedAllowed) + && IsJailed.Run(player, cmd.commandWhileJailedAllowed)) + { + PlayerList.Where(x => x.Value.SpyEnabled && x.Value.ShPlayer.svPlayer != player).ToList().ForEach(x => x.Value.ShPlayer.svPlayer.SendChatMessage($"[SPYCHAT] {player.playerData.username}: {tempMessage}")); + cmd.RunMethod.Invoke(player, message); + } + return true; + } + if (AfkPlayers.Contains(player.playerData.username)) + Commands.Afk.Run(player, message); + if (MsgUnknownCommand) + { + player.SendChatMessage($"Unknown command. Type {CmdCommandCharacter}essentials cmds for more info."); + return true; + } + return false; + } + #endregion - #region Event: ChatMessage | Local - [Hook("SvPlayer.SvLocalChatMessage")] + #region Event: ChatMessage | Local + [Hook("SvPlayer.SvLocalChatMessage")] public static bool SvLocalChatMessage(SvPlayer player, ref string message) { if (LocalChatMute && MutePlayers.Contains(player.playerData.username)) diff --git a/source/BP-Essentials/HookMethods.cs b/source/BP-Essentials/HookMethods.cs index 9ef55634..0d5fda69 100644 --- a/source/BP-Essentials/HookMethods.cs +++ b/source/BP-Essentials/HookMethods.cs @@ -14,126 +14,126 @@ namespace BP_Essentials { public class HookMethods : Core { - [Hook("SvPlayer.SvSellApartment")] + [Hook("SvPlayer.SvSellApartment")] public static bool SvSellApartment(SvPlayer player) { player.SendChatMessage($"Are you sure you want to sell your apartment? Type '{CmdCommandCharacter}{CmdConfirm}' to confirm."); //softcode command return true; } - [Hook("SvEntity.Initialize", true)] - public static void Initialize(SvEntity player) - { - if (player.serverside) - return; - var svPlayer = player as SvPlayer; - if (svPlayer == null) - return; - PlayerList.Add(svPlayer.player.ID, new PlayerListItem(svPlayer.player)); - Task.Run(() => - { - WriteIpToFile.Run(svPlayer); - CheckBanned.Run(svPlayer); - }); - } + [Hook("SvEntity.Initialize", true)] + public static void Initialize(SvEntity player) + { + if (player.serverside) + return; + var svPlayer = player as SvPlayer; + if (svPlayer == null) + return; + PlayerList.Add(svPlayer.player.ID, new PlayerListItem(svPlayer.player)); + Task.Run(() => + { + WriteIpToFile.Run(svPlayer); + CheckBanned.Run(svPlayer); + }); + } - [Hook("SvPlayer.Destroy")] - public static void Destroy(SvPlayer player) - { - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] [LEAVE] {player.player.username}"); - if (!PlayerList.ContainsKey(player.player.ID)) - return; - PlayerList.Remove(player.player.ID); - } + [Hook("SvPlayer.Destroy")] + public static void Destroy(SvPlayer player) + { + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] [LEAVE] {player.player.username}"); + if (!PlayerList.ContainsKey(player.player.ID)) + return; + PlayerList.Remove(player.player.ID); + } - [Hook("SvPlayer.Damage")] - public static bool Damage(SvPlayer player, ref DamageIndex type, ref float amount, ref ShPlayer attacker, ref Collider collider) - { - if (CheckGodMode.Run(player, amount)) - return true; - if (player.WillDieByDamage(amount)) - OnDeath(player, ref type, ref amount, ref attacker, ref collider); - return false; - } - public static void OnDeath(SvPlayer player, ref DamageIndex type, ref float amount, ref ShPlayer attacker, ref Collider collider) - { - player.SavePosition(); - } + [Hook("SvPlayer.Damage")] + public static bool Damage(SvPlayer player, ref DamageIndex type, ref float amount, ref ShPlayer attacker, ref Collider collider) + { + if (CheckGodMode.Run(player, amount)) + return true; + if (player.WillDieByDamage(amount)) + OnDeath(player, ref type, ref amount, ref attacker, ref collider); + return false; + } + public static void OnDeath(SvPlayer player, ref DamageIndex type, ref float amount, ref ShPlayer attacker, ref Collider collider) + { + player.SavePosition(); + } [Hook("SvPlayer.SpawnBot")] public static bool SpawnBot(SvPlayer player, ref Vector3 position, ref Quaternion rotation, ref Place place, ref Waypoint node, ref ShPlayer spawner, ref ShEntity mount, ref ShPlayer enemy) - { + { return EnableBlockSpawnBot == true && BlockedSpawnIds.Contains(player.player.spawnJobIndex); } - [Hook("ShRestraint.HitEffect")] - public static bool HitEffect(ShRestraint player, ref ShEntity hitTarget, ref ShPlayer source, ref Collider collider) - { - if (!PlayerList.TryGetValue(hitTarget.ID, out var hitPlayer)) - return false; - if (!GodListPlayers.Contains(hitPlayer.ShPlayer.username)) - return false; - hitPlayer.ShPlayer.svPlayer.SendChatMessage("Being handcuffed Blocked!"); - return true; - } + [Hook("ShRestraint.HitEffect")] + public static bool HitEffect(ShRestraint player, ref ShEntity hitTarget, ref ShPlayer source, ref Collider collider) + { + if (!PlayerList.TryGetValue(hitTarget.ID, out var hitPlayer)) + return false; + if (!GodListPlayers.Contains(hitPlayer.ShPlayer.username)) + return false; + hitPlayer.ShPlayer.svPlayer.SendChatMessage("Being handcuffed Blocked!"); + return true; + } - [Hook("SvPlayer.SvBan")] - public static bool SvBan(SvPlayer player, ref int otherID) - { - if (player.player.admin) - return true; - if (BlockBanButtonTabMenu) - { - player.SendChatMessage($"This button has been disabled. Please use the ban commands. ID: {otherID}"); - return true; - } - var targetPlayer = player.entity.manager.FindByID(otherID); - if (!targetPlayer || targetPlayer.svPlayer.serverside) - { - player.SendChatMessage("Cannot ban NPC"); - return true; - } - LogMessage.LogOther($"{PlaceholderParser.ParseTimeStamp()} [INFO] {targetPlayer.username} Got banned by {player.playerData.username}"); - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{targetPlayer.username} Just got banned by {player.player.username}"); - SendDiscordMessage.BanMessage(targetPlayer.username, player.playerData.username); - player.svManager.AddBanned(targetPlayer); - player.svManager.Disconnect(targetPlayer.svPlayer.connection, DisconnectTypes.Banned); - return true; - } + [Hook("SvPlayer.SvBan")] + public static bool SvBan(SvPlayer player, ref int otherID) + { + if (player.player.admin) + return true; + if (BlockBanButtonTabMenu) + { + player.SendChatMessage($"This button has been disabled. Please use the ban commands. ID: {otherID}"); + return true; + } + var targetPlayer = player.entity.manager.FindByID(otherID); + if (!targetPlayer || targetPlayer.svPlayer.serverside) + { + player.SendChatMessage("Cannot ban NPC"); + return true; + } + LogMessage.LogOther($"{PlaceholderParser.ParseTimeStamp()} [INFO] {targetPlayer.username} Got banned by {player.playerData.username}"); + player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{targetPlayer.username} Just got banned by {player.player.username}"); + SendDiscordMessage.BanMessage(targetPlayer.username, player.playerData.username); + player.svManager.AddBanned(targetPlayer); + player.svManager.Disconnect(targetPlayer.svPlayer.connection, DisconnectTypes.Banned); + return true; + } [Hook("SvPlayer.SvStartVote")] public static bool SvStartVote(SvPlayer player, ref byte voteIndex, ref int ID) { - switch (voteIndex) - { - case VoteIndex.Mission: - if (!BlockMissions) - return false; - player.SendChatMessage($"All missions have been disabled on this server."); - return true; - case VoteIndex.Kick: - if (VoteKickDisabled) - { - player.SendChatMessage($"Vote kicking has been disabled on this server."); - return true; - } - if (!PlayerList.TryGetValue(ID, out var shPlayer)) - return true; - if (player.svManager.vote != null || voteIndex >= player.player.manager.votes.Length || player.svManager.startedVote.OverLimit(player.player)) - return true; - player.svManager.startedVote.Add(player.player); - player.svManager.vote = player.player.manager.votes[voteIndex]; - if (!player.svManager.vote.CheckVote(ID)) - player.svManager.vote = null; - player.Send(SvSendType.All, Channel.Reliable, 60, voteIndex, ID); - player.svManager.StartCoroutine(player.svManager.StartVote()); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.playerData.username} Has issued a votekick against {player.player.username}"); - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} Has issued a vote kick against {shPlayer.ShPlayer.username}"); - LatestVotePeople.Clear(); - return true; - default: - return false; - } + switch (voteIndex) + { + case VoteIndex.Mission: + if (!BlockMissions) + return false; + player.SendChatMessage($"All missions have been disabled on this server."); + return true; + case VoteIndex.Kick: + if (VoteKickDisabled) + { + player.SendChatMessage($"Vote kicking has been disabled on this server."); + return true; + } + if (!PlayerList.TryGetValue(ID, out var shPlayer)) + return true; + if (player.svManager.vote != null || voteIndex >= player.player.manager.votes.Length || player.svManager.startedVote.OverLimit(player.player)) + return true; + player.svManager.startedVote.Add(player.player); + player.svManager.vote = player.player.manager.votes[voteIndex]; + if (!player.svManager.vote.CheckVote(ID)) + player.svManager.vote = null; + player.Send(SvSendType.All, Channel.Reliable, 60, voteIndex, ID); + player.svManager.StartCoroutine(player.svManager.StartVote()); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.playerData.username} Has issued a votekick against {player.player.username}"); + player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} Has issued a vote kick against {shPlayer.ShPlayer.username}"); + LatestVotePeople.Clear(); + return true; + default: + return false; + } } [Hook("SvPlayer.SvVoteYes", true)] @@ -145,52 +145,52 @@ public static void SvVoteYes(SvPlayer player) [Hook("SvPlayer.SvFunctionKey")] public static bool SvFunctionKey(SvPlayer player, ref byte key) { - var lastMenu = PlayerList[player.player.ID].LastMenu; - if (lastMenu == CurrentMenu.Report && key > 1 && key < 11) - { - PlayerList[player.player.ID].LastMenu = Methods.Utils.FunctionMenu.ReportMenu(player, key); - return true; - } - if (key == 11) - { - player.CloseFunctionMenu(); - PlayerList[player.player.ID].LastMenu = CurrentMenu.None; - return true; - } - if (!FunctionMenuKeys.TryGetValue(key, lastMenu, out var method)) - return true; - PlayerList[player.player.ID].LastMenu = method.Invoke(player); + var lastMenu = PlayerList[player.player.ID].LastMenu; + if (lastMenu == CurrentMenu.Report && key > 1 && key < 11) + { + PlayerList[player.player.ID].LastMenu = Methods.Utils.FunctionMenu.ReportMenu(player, key); + return true; + } + if (key == 11) + { + player.CloseFunctionMenu(); + PlayerList[player.player.ID].LastMenu = CurrentMenu.None; + return true; + } + if (!FunctionMenuKeys.TryGetValue(key, lastMenu, out var method)) + return true; + PlayerList[player.player.ID].LastMenu = method.Invoke(player); return true; } - [Hook("SvPlayer.SvSuicide")] - public static bool SvSuicide(SvPlayer player) - { - var shPlayer = player.player; - if (!BlockSuicide) - return false; - player.SendChatMessage($"You cannot suicide on this server because the server owner disabled it."); - return true; - } + [Hook("SvPlayer.SvSuicide")] + public static bool SvSuicide(SvPlayer player) + { + var shPlayer = player.player; + if (!BlockSuicide) + return false; + player.SendChatMessage($"You cannot suicide on this server because the server owner disabled it."); + return true; + } [Hook("SvPlayer.SvGetJob")] public static bool SvGetJob(SvPlayer player, ref int employerID) { - try - { - var shPlayer = player.player; - var shEmployer = shPlayer.manager.FindByID(employerID); - if (!WhitelistedJobs.ContainsKey(shEmployer.job.jobIndex)) - return false; - if (HasPermission.Run(player, WhitelistedJobs[shEmployer.job.jobIndex], false, shPlayer.job.jobIndex)) - return false; - player.SendChatMessage(MsgNoPermJob); - return true; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - return false; - } + try + { + var shPlayer = player.player; + var shEmployer = shPlayer.manager.FindByID(employerID); + if (!WhitelistedJobs.ContainsKey(shEmployer.job.jobIndex)) + return false; + if (HasPermission.Run(player, WhitelistedJobs[shEmployer.job.jobIndex], false, shPlayer.job.jobIndex)) + return false; + player.SendChatMessage(MsgNoPermJob); + return true; + } + catch (Exception ex) + { + ErrorLogging.Run(ex); + return false; + } } [Hook("SvPlayer.SvAddCrime")] public static bool SvAddCrime(SvPlayer player, ref byte crimeIndex, ref ShEntity victim) @@ -256,7 +256,7 @@ public static bool SvPlaceInJail(SvPlayer player, ref int criminalID) if (!crimShPlayer) return true; if ((player.serverside || crimShPlayer.DistanceSqr(player.player.manager.jail) < 14400f) && - crimShPlayer.IsRestrained() && !crimShPlayer.IsDead() && !(crimShPlayer.job is Prisoner)) + crimShPlayer.IsRestrained() && !crimShPlayer.IsDead() && !(crimShPlayer.job is Prisoner)) { var jailTime = 0f; var fine = 0; @@ -274,35 +274,35 @@ public static bool SvPlaceInJail(SvPlayer player, ref int criminalID) } player.SendChatMessage("Confirm criminal is cuffed and near jail"); } - return true; + return true; + } + [Hook("SvPlayer.SvTimescale")] + public static bool SvTimescale(SvPlayer player, ref float timescale) + { + if (!player.player.admin) + return true; + if (TimescaleDisabled) + { + player.SendChatMessage($"You cannot set the timescale because the server owner disabled this."); + return true; + } + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} set the timescale to {timescale}"); + return false; + } + /* + [Hook("ShFurniture.HitCheck")] + public static void HitCheck(ShFurniture shFurniture, ref RaycastHit hit) + { + if (!shFurniture.player.InOwnApartment()) + { + if (shFurniture.player.IsClientMain()) + { + shFurniture.manager.clManager.ShowGameMessage("Must place in your apartment lol sike"); + } + //return false; + } + //return shFurniture.HitCheck(ref hit); } - [Hook("SvPlayer.SvTimescale")] - public static bool SvTimescale(SvPlayer player, ref float timescale) - { - if (!player.player.admin) - return true; - if (TimescaleDisabled) - { - player.SendChatMessage($"You cannot set the timescale because the server owner disabled this."); - return true; - } - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} set the timescale to {timescale}"); - return false; - } - /* - [Hook("ShFurniture.HitCheck")] - public static void HitCheck(ShFurniture shFurniture, ref RaycastHit hit) - { - if (!shFurniture.player.InOwnApartment()) - { - if (shFurniture.player.IsClientMain()) - { - shFurniture.manager.clManager.ShowGameMessage("Must place in your apartment lol sike"); - } - //return false; - } - //return shFurniture.HitCheck(ref hit); - } - */ - } + */ + } } \ No newline at end of file diff --git a/source/BP-Essentials/Methods/Check/CheckBanned.cs b/source/BP-Essentials/Methods/Check/CheckBanned.cs index 4c795445..d8c3c90d 100644 --- a/source/BP-Essentials/Methods/Check/CheckBanned.cs +++ b/source/BP-Essentials/Methods/Check/CheckBanned.cs @@ -16,21 +16,21 @@ public static void Run(SvPlayer player) { if (CheckBannedEnabled) { - try - { - if (player.player.admin || string.IsNullOrEmpty(player.connection.IP.Trim())) - return; - foreach (var line in File.ReadAllLines(BansFile)) - if (string.IsNullOrEmpty(line) || !line.StartsWith("# " + player.player.username, StringComparison.CurrentCulture)) - continue; - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] {player.player.username} Joined while banned! IP: {player.connection.IP}"); - player.svManager.AddBanned(player.player); - player.svManager.Disconnect(player.connection, DisconnectTypes.Banned); - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } + try + { + if (player.player.admin || string.IsNullOrEmpty(player.connection.IP.Trim())) + return; + foreach (var line in File.ReadAllLines(BansFile)) + if (string.IsNullOrEmpty(line) || !line.StartsWith("# " + player.player.username, StringComparison.CurrentCulture)) + continue; + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] {player.player.username} Joined while banned! IP: {player.connection.IP}"); + player.svManager.AddBanned(player.player); + player.svManager.Disconnect(player.connection, DisconnectTypes.Banned); + } + catch (Exception ex) + { + ErrorLogging.Run(ex); + } } } } diff --git a/source/BP-Essentials/Methods/FileHandler/CheckAutoReloadFile.cs b/source/BP-Essentials/Methods/FileHandler/CheckAutoReloadFile.cs index d9980aa0..2f0e0052 100644 --- a/source/BP-Essentials/Methods/FileHandler/CheckAutoReloadFile.cs +++ b/source/BP-Essentials/Methods/FileHandler/CheckAutoReloadFile.cs @@ -22,11 +22,11 @@ public static void Run(string file) EnableRaisingEvents = true }; watcher.Changed += (sender, e) => - { - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Found a change in file {file}, reloading all files..."); - Debug.Log(" "); - Reload.Run(true); - }; + { + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Found a change in file {file}, reloading all files..."); + Debug.Log(" "); + Reload.Run(true); + }; } catch (Exception ex) { diff --git a/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs b/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs index 1f9d38b2..ffcf0f18 100644 --- a/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs +++ b/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs @@ -15,12 +15,12 @@ public static void Run() { try { - // this really needs some improvement - // I don't know when I added that comment but seriously I should really redo this method.. whenever I have time - // Every time I have to change something in this file it reminds me again that I should change this somehow.. I just don't know how. - // lol yup still here.. fuck. - // shrugs - if (!Directory.Exists(FileDirectory)) + // this really needs some improvement + // I don't know when I added that comment but seriously I should really redo this method.. whenever I have time + // Every time I have to change something in this file it reminds me again that I should change this somehow.. I just don't know how. + // lol yup still here.. fuck. + // shrugs + if (!Directory.Exists(FileDirectory)) { Directory.CreateDirectory(FileDirectory); Debug.Log(FileDirectory + " Does not exist! Creating one."); diff --git a/source/BP-Essentials/Methods/FileHandler/ExpandableFileHandler.cs b/source/BP-Essentials/Methods/FileHandler/ExpandableFileHandler.cs index 02f22ee8..3dab679e 100644 --- a/source/BP-Essentials/Methods/FileHandler/ExpandableFileHandler.cs +++ b/source/BP-Essentials/Methods/FileHandler/ExpandableFileHandler.cs @@ -11,122 +11,122 @@ namespace BP_Essentials.Methods.FileHandler { - public interface IExpandableFile - { - string Name { get; set; } - string ExecutableBy { get; set; } - bool Disabled { get; set; } - } - public interface IExpandableFileDelayable - { - int Delay { get; set; } - Dictionary CurrentlyInCooldown { get; set; } - } - public interface IExpandableFileHasPrice - { - int Price { get; set; } - } - public abstract class ExpandableFileHandler where JsonType : class, IExpandableFile, new() - { - protected ExpandableFileHandler() - { - if (IsInitialized) - return; - StartTimer(); - IsInitialized = true; - } - public string FileExtension { get; set; } = "json"; - public string FilesDirectory { get; set; } - public bool IsInitialized { get; private set; } - public List List { get; private set; } = new List(); - public string Name { get; set; } - public System.Timers.Timer Timer { get; private set; } = new System.Timers.Timer(); + public interface IExpandableFile + { + string Name { get; set; } + string ExecutableBy { get; set; } + bool Disabled { get; set; } + } + public interface IExpandableFileDelayable + { + int Delay { get; set; } + Dictionary CurrentlyInCooldown { get; set; } + } + public interface IExpandableFileHasPrice + { + int Price { get; set; } + } + public abstract class ExpandableFileHandler where JsonType : class, IExpandableFile, new() + { + protected ExpandableFileHandler() + { + if (IsInitialized) + return; + StartTimer(); + IsInitialized = true; + } + public string FileExtension { get; set; } = "json"; + public string FilesDirectory { get; set; } + public bool IsInitialized { get; private set; } + public List List { get; private set; } = new List(); + public string Name { get; set; } + public System.Timers.Timer Timer { get; private set; } = new System.Timers.Timer(); - public virtual void CreateNew(JsonType obj, string fileName) - { - var filePath = Path.Combine(FilesDirectory, $"{fileName}.{FileExtension}"); - File.WriteAllText(filePath, JsonConvert.SerializeObject(obj, Formatting.Indented)); - List.Add(obj); - } - public virtual void DeleteExisting(string fileName, string name = null) - { - var filePath = Path.Combine(FileDirectory, $"{fileName}.{FileExtension}"); - File.Delete(filePath); - List = List.Where(x => x.Name != (name ?? fileName)).ToList(); - } - public virtual void LoadAll(bool initCooldown = false) - { - if (DebugLevel >= 1) - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loading {Name}s.."); - List.Clear(); - foreach (string file in Directory.EnumerateFiles(FilesDirectory, $"*.{FileExtension}", SearchOption.AllDirectories)) - { - var obj = JsonConvert.DeserializeObject(FilterComments.Run(file)); - if (List.Any(x => x.Name == obj.Name)) - { - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [ERROR] Cannot add {Name} {obj.Name} because it already exists in the list!"); - continue; - } - List.Add(obj); - if (initCooldown) - SetupDelayable(obj); - if (DebugLevel >= 1) - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loaded {Name}: {obj.Name}"); - } - if (DebugLevel >= 1) - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loaded in {List.Count} {Name}(s)."); - } - public virtual IEnumerator StartCooldown(string username, JsonType obj, int _passedTime = 0) - { - if (!(obj is IExpandableFileDelayable objDelayable)) - yield break; - if (!objDelayable.CurrentlyInCooldown.ContainsKey(username)) - objDelayable.CurrentlyInCooldown.Add(username, objDelayable.Delay); - var path = Path.Combine(WarpDirectory, $"{obj.Name}.json"); - var passedTime = _passedTime; - while (passedTime < objDelayable.Delay) - { - ++passedTime; - --objDelayable.CurrentlyInCooldown[username]; - yield return new WaitForSecondsRealtime(1); - } - if (objDelayable.CurrentlyInCooldown.ContainsKey(username)) - objDelayable.CurrentlyInCooldown.Remove(username); - if (File.Exists(path)) - File.WriteAllText(path, JsonConvert.SerializeObject(obj, Formatting.Indented)); - } + public virtual void CreateNew(JsonType obj, string fileName) + { + var filePath = Path.Combine(FilesDirectory, $"{fileName}.{FileExtension}"); + File.WriteAllText(filePath, JsonConvert.SerializeObject(obj, Formatting.Indented)); + List.Add(obj); + } + public virtual void DeleteExisting(string fileName, string name = null) + { + var filePath = Path.Combine(FileDirectory, $"{fileName}.{FileExtension}"); + File.Delete(filePath); + List = List.Where(x => x.Name != (name ?? fileName)).ToList(); + } + public virtual void LoadAll(bool initCooldown = false) + { + if (DebugLevel >= 1) + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loading {Name}s.."); + List.Clear(); + foreach (string file in Directory.EnumerateFiles(FilesDirectory, $"*.{FileExtension}", SearchOption.AllDirectories)) + { + var obj = JsonConvert.DeserializeObject(FilterComments.Run(file)); + if (List.Any(x => x.Name == obj.Name)) + { + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [ERROR] Cannot add {Name} {obj.Name} because it already exists in the list!"); + continue; + } + List.Add(obj); + if (initCooldown) + SetupDelayable(obj); + if (DebugLevel >= 1) + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loaded {Name}: {obj.Name}"); + } + if (DebugLevel >= 1) + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loaded in {List.Count} {Name}(s)."); + } + public virtual IEnumerator StartCooldown(string username, JsonType obj, int _passedTime = 0) + { + if (!(obj is IExpandableFileDelayable objDelayable)) + yield break; + if (!objDelayable.CurrentlyInCooldown.ContainsKey(username)) + objDelayable.CurrentlyInCooldown.Add(username, objDelayable.Delay); + var path = Path.Combine(WarpDirectory, $"{obj.Name}.json"); + var passedTime = _passedTime; + while (passedTime < objDelayable.Delay) + { + ++passedTime; + --objDelayable.CurrentlyInCooldown[username]; + yield return new WaitForSecondsRealtime(1); + } + if (objDelayable.CurrentlyInCooldown.ContainsKey(username)) + objDelayable.CurrentlyInCooldown.Remove(username); + if (File.Exists(path)) + File.WriteAllText(path, JsonConvert.SerializeObject(obj, Formatting.Indented)); + } - void SetupDelayable(JsonType obj) - { - if (!(obj is IExpandableFileDelayable objDelayable)) - return; - foreach (var player in objDelayable.CurrentlyInCooldown.ToList()) - { - if (player.Value <= 0) - continue; - SvMan.StartCoroutine(StartCooldown(player.Key, obj, player.Value)); - } - } - void StartTimer() - { - try - { - Timer.Elapsed += (sender, e) => - { - foreach (var item in List) - { - var path = Path.Combine(FilesDirectory, $"{item.Name}.json"); - if (File.Exists(path)) - File.WriteAllText(path, JsonConvert.SerializeObject(item, Formatting.Indented)); - } - }; - Timer.Interval = 10 * 60 * 1000; // Save every 10 minutes - Timer.Enabled = true; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - } + void SetupDelayable(JsonType obj) + { + if (!(obj is IExpandableFileDelayable objDelayable)) + return; + foreach (var player in objDelayable.CurrentlyInCooldown.ToList()) + { + if (player.Value <= 0) + continue; + SvMan.StartCoroutine(StartCooldown(player.Key, obj, player.Value)); + } + } + void StartTimer() + { + try + { + Timer.Elapsed += (sender, e) => + { + foreach (var item in List) + { + var path = Path.Combine(FilesDirectory, $"{item.Name}.json"); + if (File.Exists(path)) + File.WriteAllText(path, JsonConvert.SerializeObject(item, Formatting.Indented)); + } + }; + Timer.Interval = 10 * 60 * 1000; // Save every 10 minutes + Timer.Enabled = true; + } + catch (Exception ex) + { + ErrorLogging.Run(ex); + } + } + } } diff --git a/source/BP-Essentials/Methods/FileHandler/KitsHandler.cs b/source/BP-Essentials/Methods/FileHandler/KitsHandler.cs index f2b36e00..5ecf94a6 100644 --- a/source/BP-Essentials/Methods/FileHandler/KitsHandler.cs +++ b/source/BP-Essentials/Methods/FileHandler/KitsHandler.cs @@ -11,28 +11,28 @@ namespace BP_Essentials { - public class KitsHandler : ExpandableFileHandler - { - public KitsHandler() - { - Name = "kit"; - FileExtension = "json"; - FilesDirectory = KitDirectory; - } - public class JsonModel : IExpandableFile, IExpandableFileDelayable, IExpandableFileHasPrice - { - public string Name { get; set; } - public string ExecutableBy { get; set; } - public bool Disabled { get; set; } - public int Price { get; set; } - public int Delay { get; set; } - public List Items { get; set; } = new List(); - public Dictionary CurrentlyInCooldown { get; set; } = new Dictionary(); - } - public class Kits_Item - { - public int Id { get; set; } - public int Amount { get; set; } - } - } + public class KitsHandler : ExpandableFileHandler + { + public KitsHandler() + { + Name = "kit"; + FileExtension = "json"; + FilesDirectory = KitDirectory; + } + public class JsonModel : IExpandableFile, IExpandableFileDelayable, IExpandableFileHasPrice + { + public string Name { get; set; } + public string ExecutableBy { get; set; } + public bool Disabled { get; set; } + public int Price { get; set; } + public int Delay { get; set; } + public List Items { get; set; } = new List(); + public Dictionary CurrentlyInCooldown { get; set; } = new Dictionary(); + } + public class Kits_Item + { + public int Id { get; set; } + public int Amount { get; set; } + } + } } diff --git a/source/BP-Essentials/Methods/FileHandler/ReadFile.cs b/source/BP-Essentials/Methods/FileHandler/ReadFile.cs index 9ba7ca1d..50dc465e 100644 --- a/source/BP-Essentials/Methods/FileHandler/ReadFile.cs +++ b/source/BP-Essentials/Methods/FileHandler/ReadFile.cs @@ -35,31 +35,31 @@ public class _General public bool BlockBanButtonTabMenu { get; set; } public bool BlockLicenseRemoved { get; set; } public int MessagesAllowedPerSecond { get; set; } - public int TimeBetweenDelay { get; set; } - public string WipePassword { get; set; } + public int TimeBetweenDelay { get; set; } + public string WipePassword { get; set; } } - [Serializable] - public class _Messages - { - public string NoPerm { get; set; } - public string DisabledCommand { get; set; } - public string MsgSayPrefix { get; set; } - public string DiscordLink { get; set; } - public string PlayerIsAFK { get; set; } - public string SelfIsMuted { get; set; } - public string ArgRequired { get; set; } - public string NotFoundOnline { get; set; } - public string NotFoundOnlineIdOnly { get; set; } - public string AdminSearchingInv { get; set; } - public string PlayerMessage { get; set; } - public string AdminMessage { get; set; } - public string AdminChatMessage { get; set; } - public string MsgNoPermJob { get; set; } - public string BlockedItem { get; set; } - public string MsgNoWantedAllowed { get; set; } - public string MsgNoCuffedAllowed { get; set; } - public string MsgNoJailAllowed { get; set; } - public string MeMessage { get; set; } + [Serializable] + public class _Messages + { + public string NoPerm { get; set; } + public string DisabledCommand { get; set; } + public string MsgSayPrefix { get; set; } + public string DiscordLink { get; set; } + public string PlayerIsAFK { get; set; } + public string SelfIsMuted { get; set; } + public string ArgRequired { get; set; } + public string NotFoundOnline { get; set; } + public string NotFoundOnlineIdOnly { get; set; } + public string AdminSearchingInv { get; set; } + public string PlayerMessage { get; set; } + public string AdminMessage { get; set; } + public string AdminChatMessage { get; set; } + public string MsgNoPermJob { get; set; } + public string BlockedItem { get; set; } + public string MsgNoWantedAllowed { get; set; } + public string MsgNoCuffedAllowed { get; set; } + public string MsgNoJailAllowed { get; set; } + public string MeMessage { get; set; } } [Serializable] public class MessageColors @@ -123,9 +123,9 @@ public class _Misc public bool BlockMissions { get; set; } public bool ProximityChat { get; set; } public bool LocalChatMute { get; set; } - public bool LocalChatMe { get; set; } - public bool TimescaleDisabled { get; set; } - } + public bool LocalChatMe { get; set; } + public bool TimescaleDisabled { get; set; } + } [Serializable] public class WhitelistedJob { @@ -141,8 +141,8 @@ public class _Command public bool? Disabled { get; set; } public bool? AllowWithCrimes { get; set; } public bool? AllowWhileCuffed { get; set; } - public bool? AllowWhileJailed { get; set; } - } + public bool? AllowWhileJailed { get; set; } + } [Serializable] public class __RootObject { @@ -177,137 +177,137 @@ public static void Run(string fileName) try { IdListObject idlist; - switch (fileName) - { - case SettingsFile: - var m = JsonConvert.DeserializeObject<__RootObject>(FilterComments.Run(SettingsFile)); + switch (fileName) + { + case SettingsFile: + var m = JsonConvert.DeserializeObject<__RootObject>(FilterComments.Run(SettingsFile)); - LocalVersion = m.General.Version; - CmdCommandCharacter = m.General.CommandCharacter; - DownloadIdList = m.General.DownloadIDList; - TimestampFormat = m.General.TimestapFormat; - MsgSayColor = m.General.MsgSayColor; - MsgUnknownCommand = m.General.DisplayUnknownCommandMessage; - VoteKickDisabled = m.General.VoteKickDisabled; - ShowDMGMessage = m.General.ShowDMGMessage; - DebugLevel = m.General.DebugLevel; - EnableDiscordWebhook_Ban = m.General.EnableDiscordWebhook_Ban; - if (EnableDiscordWebhook_Ban && string.IsNullOrEmpty(m.General.DiscordWebhook_Ban.Trim())) - { - Debug.Log("[ERROR] Discord webhook_Ban is empty but EnableDiscordWebhook_Ban is true! Disabling webhook_Ban."); - EnableDiscordWebhook_Ban = false; - } - else - DiscordWebhook_Ban = m.General.DiscordWebhook_Ban; - EnableDiscordWebhook_Report = m.General.EnableDiscordWebhook_Report; - if (EnableDiscordWebhook_Report && string.IsNullOrEmpty(m.General.DiscordWebhook_Report.Trim())) - { - Debug.Log("[ERROR] Discord webhook_Report is empty but EnableDiscordWebhook_Report is true! Disabling webhook_Report."); - EnableDiscordWebhook_Report = false; - } - else - DiscordWebhook_Report = m.General.DiscordWebhook_Report; - BlockBanButtonTabMenu = m.General.BlockBanButtonTabMenu; - blockLicenseRemoved = m.General.BlockLicenseRemoved; - MessagesAllowedPerSecond = m.General.MessagesAllowedPerSecond; - TimeBetweenDelay = m.General.TimeBetweenDelay; - WipePassword = m.General.WipePassword; + LocalVersion = m.General.Version; + CmdCommandCharacter = m.General.CommandCharacter; + DownloadIdList = m.General.DownloadIDList; + TimestampFormat = m.General.TimestapFormat; + MsgSayColor = m.General.MsgSayColor; + MsgUnknownCommand = m.General.DisplayUnknownCommandMessage; + VoteKickDisabled = m.General.VoteKickDisabled; + ShowDMGMessage = m.General.ShowDMGMessage; + DebugLevel = m.General.DebugLevel; + EnableDiscordWebhook_Ban = m.General.EnableDiscordWebhook_Ban; + if (EnableDiscordWebhook_Ban && string.IsNullOrEmpty(m.General.DiscordWebhook_Ban.Trim())) + { + Debug.Log("[ERROR] Discord webhook_Ban is empty but EnableDiscordWebhook_Ban is true! Disabling webhook_Ban."); + EnableDiscordWebhook_Ban = false; + } + else + DiscordWebhook_Ban = m.General.DiscordWebhook_Ban; + EnableDiscordWebhook_Report = m.General.EnableDiscordWebhook_Report; + if (EnableDiscordWebhook_Report && string.IsNullOrEmpty(m.General.DiscordWebhook_Report.Trim())) + { + Debug.Log("[ERROR] Discord webhook_Report is empty but EnableDiscordWebhook_Report is true! Disabling webhook_Report."); + EnableDiscordWebhook_Report = false; + } + else + DiscordWebhook_Report = m.General.DiscordWebhook_Report; + BlockBanButtonTabMenu = m.General.BlockBanButtonTabMenu; + blockLicenseRemoved = m.General.BlockLicenseRemoved; + MessagesAllowedPerSecond = m.General.MessagesAllowedPerSecond; + TimeBetweenDelay = m.General.TimeBetweenDelay; + WipePassword = m.General.WipePassword; - infoColor = m.MessageColors.Info; - errorColor = m.MessageColors.Error; - warningColor = m.MessageColors.Warning; - argColor = m.MessageColors.Arg; + infoColor = m.MessageColors.Info; + errorColor = m.MessageColors.Error; + warningColor = m.MessageColors.Warning; + argColor = m.MessageColors.Arg; - MsgNoPerm = m.Messages.NoPerm; - MsgDiscord = m.Messages.DiscordLink; - MsgSayPrefix = m.Messages.MsgSayPrefix; - DisabledCommand = $"{m.Messages.DisabledCommand}"; - PlayerIsAFK = $"{m.Messages.PlayerIsAFK}"; - SelfIsMuted = $"{m.Messages.SelfIsMuted}"; - ArgRequired = $"{m.Messages.ArgRequired}"; - NotFoundOnline = $"{m.Messages.NotFoundOnline}"; - NotFoundOnlineIdOnly = $"{m.Messages.NotFoundOnlineIdOnly}"; - AdminSearchingInv = $"{m.Messages.AdminSearchingInv}"; - PlayerMessage = m.Messages.PlayerMessage; - AdminMessage = m.Messages.AdminMessage; - AdminChatMessage = m.Messages.AdminChatMessage; - MsgNoPermJob = $"{m.Messages.MsgNoPermJob}"; - BlockedItemMessage = $"{m.Messages.BlockedItem}"; - MsgNoWantedAllowed = $"{m.Messages.MsgNoWantedAllowed}"; - MsgNoCuffedAllowed = $"{m.Messages.MsgNoCuffedAllowed}"; - MsgNoJailAllowed = $"{m.Messages.MsgNoJailAllowed}"; - MeMessage = m.Messages.MeMessage; + MsgNoPerm = m.Messages.NoPerm; + MsgDiscord = m.Messages.DiscordLink; + MsgSayPrefix = m.Messages.MsgSayPrefix; + DisabledCommand = $"{m.Messages.DisabledCommand}"; + PlayerIsAFK = $"{m.Messages.PlayerIsAFK}"; + SelfIsMuted = $"{m.Messages.SelfIsMuted}"; + ArgRequired = $"{m.Messages.ArgRequired}"; + NotFoundOnline = $"{m.Messages.NotFoundOnline}"; + NotFoundOnlineIdOnly = $"{m.Messages.NotFoundOnlineIdOnly}"; + AdminSearchingInv = $"{m.Messages.AdminSearchingInv}"; + PlayerMessage = m.Messages.PlayerMessage; + AdminMessage = m.Messages.AdminMessage; + AdminChatMessage = m.Messages.AdminChatMessage; + MsgNoPermJob = $"{m.Messages.MsgNoPermJob}"; + BlockedItemMessage = $"{m.Messages.BlockedItem}"; + MsgNoWantedAllowed = $"{m.Messages.MsgNoWantedAllowed}"; + MsgNoCuffedAllowed = $"{m.Messages.MsgNoCuffedAllowed}"; + MsgNoJailAllowed = $"{m.Messages.MsgNoJailAllowed}"; + MeMessage = m.Messages.MeMessage; - AccessMoneyMenu = m.FunctionUI.AccessMoneyMenu; - AccessItemMenu = m.FunctionUI.AccessItemMenu; - AccessSetHPMenu = m.FunctionUI.AccessSetHPMenu; - AccessSetStatsMenu = m.FunctionUI.AccessSetStatsMenu; - AccessCWMenu = m.FunctionUI.AccessCWMenu; + AccessMoneyMenu = m.FunctionUI.AccessMoneyMenu; + AccessItemMenu = m.FunctionUI.AccessItemMenu; + AccessSetHPMenu = m.FunctionUI.AccessSetHPMenu; + AccessSetStatsMenu = m.FunctionUI.AccessSetStatsMenu; + AccessCWMenu = m.FunctionUI.AccessCWMenu; - ReportReasons = new string[] { m.ReportOptions.F2, m.ReportOptions.F3, m.ReportOptions.F4, m.ReportOptions.F5, m.ReportOptions.F6, m.ReportOptions.F7, m.ReportOptions.F8, m.ReportOptions.F9, m.ReportOptions.F10 }; + ReportReasons = new string[] { m.ReportOptions.F2, m.ReportOptions.F3, m.ReportOptions.F4, m.ReportOptions.F5, m.ReportOptions.F6, m.ReportOptions.F7, m.ReportOptions.F8, m.ReportOptions.F9, m.ReportOptions.F10 }; - // Softcode this someday - Jobs = new string[] { m.JobIndexArray.Citizen, m.JobIndexArray.Criminal, m.JobIndexArray.Prisoner, m.JobIndexArray.Police, m.JobIndexArray.Paramedic, m.JobIndexArray.Firefighter, m.JobIndexArray.Rojo_Loco, m.JobIndexArray.Green_St_Fam, m.JobIndexArray.Borgata_Blue, m.JobIndexArray.Mayor, m.JobIndexArray.DeliveryDriver, m.JobIndexArray.TaxiDriver, m.JobIndexArray.SpecOps }; + // Softcode this someday + Jobs = new string[] { m.JobIndexArray.Citizen, m.JobIndexArray.Criminal, m.JobIndexArray.Prisoner, m.JobIndexArray.Police, m.JobIndexArray.Paramedic, m.JobIndexArray.Firefighter, m.JobIndexArray.Rojo_Loco, m.JobIndexArray.Green_St_Fam, m.JobIndexArray.Borgata_Blue, m.JobIndexArray.Mayor, m.JobIndexArray.DeliveryDriver, m.JobIndexArray.TaxiDriver, m.JobIndexArray.SpecOps }; - BlockedItems = m.BlockedItems; + BlockedItems = m.BlockedItems; - EnableBlockSpawnBot = m.Misc.EnableBlockSpawnBot; - LanguageBlock = m.Misc.EnableLanguageBlock; - ChatBlock = m.Misc.EnableChatBlock; - CheckBannedEnabled = m.Misc.CheckBannedEnabled; - TimeBetweenAnnounce = m.Misc.TimeBetweenAnnounce; - Variables.Announcer.Interval = TimeBetweenAnnounce; - TimescaleDisabled = m.Misc.TimescaleDisabled; + EnableBlockSpawnBot = m.Misc.EnableBlockSpawnBot; + LanguageBlock = m.Misc.EnableLanguageBlock; + ChatBlock = m.Misc.EnableChatBlock; + CheckBannedEnabled = m.Misc.CheckBannedEnabled; + TimeBetweenAnnounce = m.Misc.TimeBetweenAnnounce; + Variables.Announcer.Interval = TimeBetweenAnnounce; + TimescaleDisabled = m.Misc.TimescaleDisabled; - if (m.Misc.EnableBlockSpawnBot) - BlockedSpawnIds = m.Misc.BlockSpawnBot.Split(',').Select(int.Parse).ToArray(); - GodModeLevel = m.Misc.GodModeLevel; - ShowJailMessage = m.Misc.ShowJailMessage; - BlockSuicide = m.Misc.BlockSuicide; - BlockMissions = m.Misc.BlockMissions; - ProximityChat = m.Misc.ProximityChat; - LocalChatMute = m.Misc.LocalChatMute; - LocalChatMe = m.Misc.LocalChatMe; + if (m.Misc.EnableBlockSpawnBot) + BlockedSpawnIds = m.Misc.BlockSpawnBot.Split(',').Select(int.Parse).ToArray(); + GodModeLevel = m.Misc.GodModeLevel; + ShowJailMessage = m.Misc.ShowJailMessage; + BlockSuicide = m.Misc.BlockSuicide; + BlockMissions = m.Misc.BlockMissions; + ProximityChat = m.Misc.ProximityChat; + LocalChatMute = m.Misc.LocalChatMute; + LocalChatMe = m.Misc.LocalChatMe; - foreach (var currJob in m.WhitelistedJobs) - { - if (WhitelistedJobs.ContainsKey(currJob.JobIndex)) - { - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] WhitelistedJobs already contains a item with the key '{currJob.JobIndex}'! (Did you make two objects with the same JobIndex?)"); - continue; - } - WhitelistedJobs.Add(currJob.JobIndex, currJob.Whitelisted); - } - RegisterCommands.Run(m.Commands); - break; - case IdListItemsFile: - idlist = JsonConvert.DeserializeObject(FilterComments.Run(IdListItemsFile)); - IDs_Items = idlist.items.Select(x => x.gameid).ToArray(); - break; - case IdListVehicleFile: - idlist = JsonConvert.DeserializeObject(FilterComments.Run(IdListVehicleFile)); - IDs_Vehicles = idlist.items.Select(x => x.gameid).ToArray(); - break; - case AnnouncementsFile: - Variables.Announcer.Announcements = File.ReadAllLines(fileName).ToList(); - break; - case RulesFile: - Rules = File.ReadAllText(fileName); - break; - case GodListFile: - GodListPlayers = File.ReadAllLines(fileName).ToList(); - break; - case AfkListFile: - AfkPlayers = File.ReadAllLines(fileName).ToList(); - break; - case MuteListFile: - MutePlayers = File.ReadAllLines(fileName).ToList(); - break; - default: - break; - } - } + foreach (var currJob in m.WhitelistedJobs) + { + if (WhitelistedJobs.ContainsKey(currJob.JobIndex)) + { + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] WhitelistedJobs already contains a item with the key '{currJob.JobIndex}'! (Did you make two objects with the same JobIndex?)"); + continue; + } + WhitelistedJobs.Add(currJob.JobIndex, currJob.Whitelisted); + } + RegisterCommands.Run(m.Commands); + break; + case IdListItemsFile: + idlist = JsonConvert.DeserializeObject(FilterComments.Run(IdListItemsFile)); + IDs_Items = idlist.items.Select(x => x.gameid).ToArray(); + break; + case IdListVehicleFile: + idlist = JsonConvert.DeserializeObject(FilterComments.Run(IdListVehicleFile)); + IDs_Vehicles = idlist.items.Select(x => x.gameid).ToArray(); + break; + case AnnouncementsFile: + Variables.Announcer.Announcements = File.ReadAllLines(fileName).ToList(); + break; + case RulesFile: + Rules = File.ReadAllText(fileName); + break; + case GodListFile: + GodListPlayers = File.ReadAllLines(fileName).ToList(); + break; + case AfkListFile: + AfkPlayers = File.ReadAllLines(fileName).ToList(); + break; + case MuteListFile: + MutePlayers = File.ReadAllLines(fileName).ToList(); + break; + default: + break; + } + } catch (Exception ex) { ErrorLogging.Run(ex); diff --git a/source/BP-Essentials/Methods/FileHandler/ReadFileStream.cs b/source/BP-Essentials/Methods/FileHandler/ReadFileStream.cs index 4abf80c2..554dcc33 100644 --- a/source/BP-Essentials/Methods/FileHandler/ReadFileStream.cs +++ b/source/BP-Essentials/Methods/FileHandler/ReadFileStream.cs @@ -16,12 +16,12 @@ public static void Run(string fileName, List output) try { output.Clear(); - foreach (var line in File.ReadAllLines(fileName)) - { - if (line.StartsWith("#", StringComparison.CurrentCulture)) - continue; - output.Add(line); - } + foreach (var line in File.ReadAllLines(fileName)) + { + if (line.StartsWith("#", StringComparison.CurrentCulture)) + continue; + output.Add(line); + } } catch (Exception ex) { diff --git a/source/BP-Essentials/Methods/FileHandler/ReadGroups.cs b/source/BP-Essentials/Methods/FileHandler/ReadGroups.cs index d52b7843..8b2edcdb 100644 --- a/source/BP-Essentials/Methods/FileHandler/ReadGroups.cs +++ b/source/BP-Essentials/Methods/FileHandler/ReadGroups.cs @@ -28,15 +28,15 @@ public static void Run() { Groups.Clear(); _RootObject m = JsonConvert.DeserializeObject<_RootObject>(FilterComments.Run(CustomGroupsFile)); - foreach (var group in m.Groups) - { - if (Groups.ContainsKey(group.Name)) - { - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [ERROR] Cannot add group {group.Name} To dictionary because it already exists!"); - continue; - } - Groups.Add(group.Name, new _Group { Message = group.Message, Name = group.Name, Users = group.Usernames }); - } + foreach (var group in m.Groups) + { + if (Groups.ContainsKey(group.Name)) + { + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [ERROR] Cannot add group {group.Name} To dictionary because it already exists!"); + continue; + } + Groups.Add(group.Name, new _Group { Message = group.Message, Name = group.Name, Users = group.Usernames }); + } } catch (Exception ex) { diff --git a/source/BP-Essentials/Methods/FileHandler/RegisterCommands.cs b/source/BP-Essentials/Methods/FileHandler/RegisterCommands.cs index efa3dff0..1504aafb 100644 --- a/source/BP-Essentials/Methods/FileHandler/RegisterCommands.cs +++ b/source/BP-Essentials/Methods/FileHandler/RegisterCommands.cs @@ -48,7 +48,7 @@ public static void Run(List<_Command> cmdlist) commandDisabled = command.Disabled ?? false, commandWantedAllowed = command.AllowWithCrimes ?? true, commandHandcuffedAllowed = command.AllowWhileCuffed ?? true, - commandWhileJailedAllowed = command.AllowWhileJailed ?? true + commandWhileJailedAllowed = command.AllowWhileJailed ?? true }); } Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Registered commands! ({CommandList.Count} commands loaded in.)"); diff --git a/source/BP-Essentials/Methods/FileHandler/WarpsHandler.cs b/source/BP-Essentials/Methods/FileHandler/WarpsHandler.cs index f3360862..22fc7b61 100644 --- a/source/BP-Essentials/Methods/FileHandler/WarpsHandler.cs +++ b/source/BP-Essentials/Methods/FileHandler/WarpsHandler.cs @@ -11,40 +11,40 @@ namespace BP_Essentials { - public class WarpHandler : ExpandableFileHandler - { - public WarpHandler() - { - Name = "warp"; - FileExtension = "json"; - FilesDirectory = WarpDirectory; - } - public class JsonModel : IExpandableFile, IExpandableFileDelayable, IExpandableFileHasPrice - { - public string Name { get; set; } - public string ExecutableBy { get; set; } - public bool Disabled { get; set; } - public int Price { get; set; } - public int Delay { get; set; } - public Dictionary CurrentlyInCooldown { get; set; } = new Dictionary(); + public class WarpHandler : ExpandableFileHandler + { + public WarpHandler() + { + Name = "warp"; + FileExtension = "json"; + FilesDirectory = WarpDirectory; + } + public class JsonModel : IExpandableFile, IExpandableFileDelayable, IExpandableFileHasPrice + { + public string Name { get; set; } + public string ExecutableBy { get; set; } + public bool Disabled { get; set; } + public int Price { get; set; } + public int Delay { get; set; } + public Dictionary CurrentlyInCooldown { get; set; } = new Dictionary(); - public Position Position { get; set; } - public Rotation Rotation { get; set; } - } - public class Position - { - public float X { get; set; } - public float Y { get; set; } - public float Z { get; set; } - public int PlaceIndex { get; set; } - } + public Position Position { get; set; } + public Rotation Rotation { get; set; } + } + public class Position + { + public float X { get; set; } + public float Y { get; set; } + public float Z { get; set; } + public int PlaceIndex { get; set; } + } - public class Rotation - { - public float X { get; set; } - public float Y { get; set; } - public float Z { get; set; } - public float W { get; set; } - } - } + public class Rotation + { + public float X { get; set; } + public float Y { get; set; } + public float Z { get; set; } + public float W { get; set; } + } + } } diff --git a/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs b/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs index 01e586ec..e76e7719 100644 --- a/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs +++ b/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs @@ -15,8 +15,8 @@ public static void Run(ShPlayer shPlayer) { try { - if (shPlayer == null) - return; + if (shPlayer == null) + return; typeof(SvPlayer).GetMethod(nameof(CleanupApartment), BindingFlags.NonPublic | BindingFlags.Instance).Invoke(shPlayer.svPlayer, new object[] { }); } catch (Exception ex) diff --git a/source/BP-Essentials/Methods/GameMethods/SetJob.cs b/source/BP-Essentials/Methods/GameMethods/SetJob.cs index 45144e76..ad8b763b 100644 --- a/source/BP-Essentials/Methods/GameMethods/SetJob.cs +++ b/source/BP-Essentials/Methods/GameMethods/SetJob.cs @@ -15,8 +15,8 @@ public static void Run(ShPlayer shPlayer, byte jobIndex, bool AddItems, bool Col { try { - if (shPlayer == null) - return; + if (shPlayer == null) + return; typeof(SvPlayer).GetMethod("SvTrySetJob", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(shPlayer.svPlayer, new object[] { jobIndex, AddItems, CollectCost }); } catch (Exception ex) diff --git a/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs b/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs index 335ea407..87b9e032 100644 --- a/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs +++ b/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs @@ -15,8 +15,8 @@ public static void Run(SvPlayer player) { try { - if (player == null) - return; + if (player == null) + return; typeof(SvPlayer).GetMethod(nameof(UnRestrain), BindingFlags.NonPublic | BindingFlags.Instance).Invoke(player, new object[] { }); } catch (Exception ex) diff --git a/source/BP-Essentials/Methods/Utils/FunctionMenu.cs b/source/BP-Essentials/Methods/Utils/FunctionMenu.cs index 4e6273fb..a5295975 100644 --- a/source/BP-Essentials/Methods/Utils/FunctionMenu.cs +++ b/source/BP-Essentials/Methods/Utils/FunctionMenu.cs @@ -9,235 +9,235 @@ namespace BP_Essentials.Methods.Utils { - public static class FunctionMenu - { - public static void RegisterMenus() - { - FunctionMenuKeys = new MultiDictionary> - { - [1, CurrentMenu.None] = MainMenu, + public static class FunctionMenu + { + public static void RegisterMenus() + { + FunctionMenuKeys = new MultiDictionary> + { + [1, CurrentMenu.None] = MainMenu, - [2, CurrentMenu.ServerInfo] = ServerInfo, - [2, CurrentMenu.Staff] = GiveMoneyMenu, - [2, CurrentMenu.GiveMoney] = Give1kMoney, - [2, CurrentMenu.GiveItems] = GivePistolAmmo, - [2, CurrentMenu.AdminReport] = AdminReportWindowTeleport, + [2, CurrentMenu.ServerInfo] = ServerInfo, + [2, CurrentMenu.Staff] = GiveMoneyMenu, + [2, CurrentMenu.GiveMoney] = Give1kMoney, + [2, CurrentMenu.GiveItems] = GivePistolAmmo, + [2, CurrentMenu.AdminReport] = AdminReportWindowTeleport, - [3, CurrentMenu.Main] = ServerInfoMenu, - [3, CurrentMenu.ServerInfo] = ServerAdmins, - [3, CurrentMenu.Staff] = GiveItemsMenu, - [3, CurrentMenu.GiveMoney] = Give10kMoney, - [3, CurrentMenu.GiveItems] = Give20Handcuffs, - [3, CurrentMenu.AdminReport] = ResetWindow, + [3, CurrentMenu.Main] = ServerInfoMenu, + [3, CurrentMenu.ServerInfo] = ServerAdmins, + [3, CurrentMenu.Staff] = GiveItemsMenu, + [3, CurrentMenu.GiveMoney] = Give10kMoney, + [3, CurrentMenu.GiveItems] = Give20Handcuffs, + [3, CurrentMenu.AdminReport] = ResetWindow, - [4, CurrentMenu.GiveMoney] = Give100kMoney, - [4, CurrentMenu.GiveItems] = Give10TaserAmmo, - [4, CurrentMenu.Staff] = Heal, + [4, CurrentMenu.GiveMoney] = Give100kMoney, + [4, CurrentMenu.GiveItems] = Give10TaserAmmo, + [4, CurrentMenu.Staff] = Heal, - [5, CurrentMenu.GiveItems] = GiveAllLicenses, - [5, CurrentMenu.Staff] = Feed, + [5, CurrentMenu.GiveItems] = GiveAllLicenses, + [5, CurrentMenu.Staff] = Feed, - [6, CurrentMenu.Staff] = ClearWanted, + [6, CurrentMenu.Staff] = ClearWanted, - [10, CurrentMenu.Main] = StaffMenu - }; - } - public static CurrentMenu ResetWindow(SvPlayer player) - { - player.CloseFunctionMenu(); - return CurrentMenu.None; - } + [10, CurrentMenu.Main] = StaffMenu + }; + } + public static CurrentMenu ResetWindow(SvPlayer player) + { + player.CloseFunctionMenu(); + return CurrentMenu.None; + } - #region Key | Any - public static CurrentMenu ReportMenu(SvPlayer player, byte key) - { - if (string.IsNullOrWhiteSpace(ReportReasons[key - 2])) - { - player.SendChatMessage($"This report reason is empty."); - return CurrentMenu.Report; - } - player.CloseFunctionMenu(); - if (!PlayerList.TryGetValue(player.player.ID, out var playerListItem)) - return CurrentMenu.None; - player.SendChatMessage($"Reported \"{playerListItem.ReportedPlayer.username}\" With the reason \"{ReportReasons[key - 2]}\"."); - playerListItem.ReportedReason = ReportReasons[key - 2]; - SendDiscordMessage.ReportMessage(playerListItem.ReportedPlayer.username, player.player.username, ReportReasons[key - 2]); - ReportPlayer.Run(player.player.username, ReportReasons[key - 2], playerListItem.ReportedPlayer); - return CurrentMenu.None; - } - #endregion + #region Key | Any + public static CurrentMenu ReportMenu(SvPlayer player, byte key) + { + if (string.IsNullOrWhiteSpace(ReportReasons[key - 2])) + { + player.SendChatMessage($"This report reason is empty."); + return CurrentMenu.Report; + } + player.CloseFunctionMenu(); + if (!PlayerList.TryGetValue(player.player.ID, out var playerListItem)) + return CurrentMenu.None; + player.SendChatMessage($"Reported \"{playerListItem.ReportedPlayer.username}\" With the reason \"{ReportReasons[key - 2]}\"."); + playerListItem.ReportedReason = ReportReasons[key - 2]; + SendDiscordMessage.ReportMessage(playerListItem.ReportedPlayer.username, player.player.username, ReportReasons[key - 2]); + ReportPlayer.Run(player.player.username, ReportReasons[key - 2], playerListItem.ReportedPlayer); + return CurrentMenu.None; + } + #endregion - #region Key | 1 - public static CurrentMenu MainMenu(SvPlayer player) - { - if (HasPermission.Run(player, AccessMoneyMenu) || HasPermission.Run(player, AccessItemMenu) || HasPermission.Run(player, AccessSetHPMenu) || HasPermission.Run(player, AccessSetStatsMenu) || HasPermission.Run(player, AccessCWMenu)) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\nF10: Extras menu\n\nPress F11 To close this (G)UI"); - return CurrentMenu.Main; - } - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\n\nPress F11 To close this (G)UI"); - return CurrentMenu.Main; - } - #endregion + #region Key | 1 + public static CurrentMenu MainMenu(SvPlayer player) + { + if (HasPermission.Run(player, AccessMoneyMenu) || HasPermission.Run(player, AccessItemMenu) || HasPermission.Run(player, AccessSetHPMenu) || HasPermission.Run(player, AccessSetStatsMenu) || HasPermission.Run(player, AccessCWMenu)) + { + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\nF10: Extras menu\n\nPress F11 To close this (G)UI"); + return CurrentMenu.Main; + } + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\n\nPress F11 To close this (G)UI"); + return CurrentMenu.Main; + } + #endregion - #region Key | 2 - public static CurrentMenu ServerInfo(SvPlayer player) - { - player.CloseFunctionMenu(); - player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, File.ReadAllText("server_info.txt")); - return CurrentMenu.None; - } - public static CurrentMenu GiveMoneyMenu(SvPlayer player) - { - if (!HasPermission.Run(player, AccessMoneyMenu)) - return CurrentMenu.None; - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Money menu:\n\nF2: Give 1.000 dollars (1k)\nF3: Give 10.000 dollars (10k)\nF4: Give 100.000 dollars (100k)\n\nPress F11 To close this (G)UI"); - return CurrentMenu.GiveMoney; - } - public static CurrentMenu Give1kMoney(SvPlayer player) - { - player.player.TransferMoney(DeltaInv.AddToMe, 1000, true); - player.SendChatMessage($"You have given yourself 1.000 dollars."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 1.000 dollars through the functionUI"); - return CurrentMenu.GiveMoney; - } - public static CurrentMenu GivePistolAmmo(SvPlayer player) - { - player.player.TransferItem(DeltaInv.AddToMe, CommonIDs[0], 500, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 500 pistol ammo."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 500 pistol ammo through the functionUI"); - return CurrentMenu.GiveItems; - } - public static CurrentMenu AdminReportWindowTeleport(SvPlayer player) - { - player.CloseFunctionMenu(); - if (!PlayerList.TryGetValue(player.player.ID, out var playerItem)) - return CurrentMenu.None; - playerItem.ReportedPlayer = null; - if (!IsOnline.Run(playerItem.ReportedPlayer)) - { - player.SendChatMessage("Player not online anymore."); - return CurrentMenu.None; - } - player.ResetAndSavePosition(playerItem.ReportedPlayer.GetPosition(), playerItem.ReportedPlayer.GetRotation(), playerItem.ReportedPlayer.GetPlaceIndex()); - player.SendChatMessage($"Teleported to \"{playerItem.ReportedPlayer.username}\"."); - return CurrentMenu.None; - } - #endregion + #region Key | 2 + public static CurrentMenu ServerInfo(SvPlayer player) + { + player.CloseFunctionMenu(); + player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, File.ReadAllText("server_info.txt")); + return CurrentMenu.None; + } + public static CurrentMenu GiveMoneyMenu(SvPlayer player) + { + if (!HasPermission.Run(player, AccessMoneyMenu)) + return CurrentMenu.None; + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Money menu:\n\nF2: Give 1.000 dollars (1k)\nF3: Give 10.000 dollars (10k)\nF4: Give 100.000 dollars (100k)\n\nPress F11 To close this (G)UI"); + return CurrentMenu.GiveMoney; + } + public static CurrentMenu Give1kMoney(SvPlayer player) + { + player.player.TransferMoney(DeltaInv.AddToMe, 1000, true); + player.SendChatMessage($"You have given yourself 1.000 dollars."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 1.000 dollars through the functionUI"); + return CurrentMenu.GiveMoney; + } + public static CurrentMenu GivePistolAmmo(SvPlayer player) + { + player.player.TransferItem(DeltaInv.AddToMe, CommonIDs[0], 500, true); + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 500 pistol ammo."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 500 pistol ammo through the functionUI"); + return CurrentMenu.GiveItems; + } + public static CurrentMenu AdminReportWindowTeleport(SvPlayer player) + { + player.CloseFunctionMenu(); + if (!PlayerList.TryGetValue(player.player.ID, out var playerItem)) + return CurrentMenu.None; + playerItem.ReportedPlayer = null; + if (!IsOnline.Run(playerItem.ReportedPlayer)) + { + player.SendChatMessage("Player not online anymore."); + return CurrentMenu.None; + } + player.ResetAndSavePosition(playerItem.ReportedPlayer.GetPosition(), playerItem.ReportedPlayer.GetRotation(), playerItem.ReportedPlayer.GetPlaceIndex()); + player.SendChatMessage($"Teleported to \"{playerItem.ReportedPlayer.username}\"."); + return CurrentMenu.None; + } + #endregion - #region Key | 3 - public static CurrentMenu GiveItemsMenu(SvPlayer player) - { - if (!HasPermission.Run(player, AccessItemMenu)) - return CurrentMenu.None; - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Items menu:\n\nF2: Give 500 Pistol Ammo\nF3: Give 20 Handcuffs\nF4: Give 10 Taser ammo\nF5: Give all Licenses\n\nPress F11 To close this (G)UI"); - return CurrentMenu.GiveItems; - } - public static CurrentMenu Give10kMoney(SvPlayer player) - { - player.player.TransferMoney(DeltaInv.AddToMe, 10000, true); - player.SendChatMessage($"You have given yourself 10.000 dollars."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 10.000 dollars through the functionUI"); - return CurrentMenu.GiveMoney; - } - public static CurrentMenu Give20Handcuffs(SvPlayer player) - { - player.player.TransferItem(1, CommonIDs[1], 20, true); - player.SendChatMessage($"You have given yourself 20 handcuffs."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 20 handcuffs through the functionUI"); - return CurrentMenu.GiveItems; - } - public static CurrentMenu ServerInfoMenu(SvPlayer player) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Server info menu:\n\nF2: Show rules\nF3: Show admins\n\nPress F11 To close this (G)UI"); - return CurrentMenu.ServerInfo; - } - public static CurrentMenu ServerAdmins(SvPlayer player) - { - player.CloseFunctionMenu(); - var builder = new StringBuilder("All admins on this server:\n\n"); - foreach (var line in File.ReadAllLines("admin_list.txt")) - if (line.Trim() != null && !line.Trim().StartsWith("#", StringComparison.OrdinalIgnoreCase)) - builder.AppendLine(line); - player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, builder.ToString()); - return CurrentMenu.None; - } - #endregion + #region Key | 3 + public static CurrentMenu GiveItemsMenu(SvPlayer player) + { + if (!HasPermission.Run(player, AccessItemMenu)) + return CurrentMenu.None; + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Items menu:\n\nF2: Give 500 Pistol Ammo\nF3: Give 20 Handcuffs\nF4: Give 10 Taser ammo\nF5: Give all Licenses\n\nPress F11 To close this (G)UI"); + return CurrentMenu.GiveItems; + } + public static CurrentMenu Give10kMoney(SvPlayer player) + { + player.player.TransferMoney(DeltaInv.AddToMe, 10000, true); + player.SendChatMessage($"You have given yourself 10.000 dollars."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 10.000 dollars through the functionUI"); + return CurrentMenu.GiveMoney; + } + public static CurrentMenu Give20Handcuffs(SvPlayer player) + { + player.player.TransferItem(1, CommonIDs[1], 20, true); + player.SendChatMessage($"You have given yourself 20 handcuffs."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 20 handcuffs through the functionUI"); + return CurrentMenu.GiveItems; + } + public static CurrentMenu ServerInfoMenu(SvPlayer player) + { + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Server info menu:\n\nF2: Show rules\nF3: Show admins\n\nPress F11 To close this (G)UI"); + return CurrentMenu.ServerInfo; + } + public static CurrentMenu ServerAdmins(SvPlayer player) + { + player.CloseFunctionMenu(); + var builder = new StringBuilder("All admins on this server:\n\n"); + foreach (var line in File.ReadAllLines("admin_list.txt")) + if (line.Trim() != null && !line.Trim().StartsWith("#", StringComparison.OrdinalIgnoreCase)) + builder.AppendLine(line); + player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, builder.ToString()); + return CurrentMenu.None; + } + #endregion - #region Key | 4 - public static CurrentMenu Give100kMoney(SvPlayer player) - { - player.player.TransferMoney(DeltaInv.AddToMe, 100000, true); - player.SendChatMessage($"You have given yourself 100.000 dollars."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 100.000 dollars through the functionUI"); - return CurrentMenu.GiveMoney; - } - public static CurrentMenu Heal(SvPlayer player) - { - if (!HasPermission.Run(player, AccessSetHPMenu)) - return CurrentMenu.None; - player.Heal(100); - player.SendChatMessage($"You've been healed."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} healed himself through the functionUI"); - return CurrentMenu.Staff; - } - public static CurrentMenu Give10TaserAmmo(SvPlayer player) - { - player.player.TransferItem(1, CommonIDs[2], 10, true); - player.SendChatMessage($"You have given yourself 10 Taser ammo."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 10 taser ammo through the functionUI"); - return CurrentMenu.GiveItems; - } - #endregion + #region Key | 4 + public static CurrentMenu Give100kMoney(SvPlayer player) + { + player.player.TransferMoney(DeltaInv.AddToMe, 100000, true); + player.SendChatMessage($"You have given yourself 100.000 dollars."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 100.000 dollars through the functionUI"); + return CurrentMenu.GiveMoney; + } + public static CurrentMenu Heal(SvPlayer player) + { + if (!HasPermission.Run(player, AccessSetHPMenu)) + return CurrentMenu.None; + player.Heal(100); + player.SendChatMessage($"You've been healed."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} healed himself through the functionUI"); + return CurrentMenu.Staff; + } + public static CurrentMenu Give10TaserAmmo(SvPlayer player) + { + player.player.TransferItem(1, CommonIDs[2], 10, true); + player.SendChatMessage($"You have given yourself 10 Taser ammo."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in 10 taser ammo through the functionUI"); + return CurrentMenu.GiveItems; + } + #endregion - #region Key | 5 - public static CurrentMenu Feed(SvPlayer player) - { - if (!HasPermission.Run(player, AccessSetStatsMenu)) - return CurrentMenu.None; - player.UpdateStats(100F, 100F, 100F, 100F); - player.SendChatMessage($"Maxed out stats for yourself."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Maxed out stats through the functionUI"); - return CurrentMenu.Staff; - } - public static CurrentMenu GiveAllLicenses(SvPlayer player) - { - for (int i = 3; i < 7; i++) - player.player.TransferItem(DeltaInv.AddToMe, CommonIDs[i], 1, true); - player.SendChatMessage($"You have given yourself all licenses."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in all licenses through the functionUI"); - return CurrentMenu.GiveItems; - } - #endregion + #region Key | 5 + public static CurrentMenu Feed(SvPlayer player) + { + if (!HasPermission.Run(player, AccessSetStatsMenu)) + return CurrentMenu.None; + player.UpdateStats(100F, 100F, 100F, 100F); + player.SendChatMessage($"Maxed out stats for yourself."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Maxed out stats through the functionUI"); + return CurrentMenu.Staff; + } + public static CurrentMenu GiveAllLicenses(SvPlayer player) + { + for (int i = 3; i < 7; i++) + player.player.TransferItem(DeltaInv.AddToMe, CommonIDs[i], 1, true); + player.SendChatMessage($"You have given yourself all licenses."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Spawned in all licenses through the functionUI"); + return CurrentMenu.GiveItems; + } + #endregion - #region Key | 6 - public static CurrentMenu ClearWanted(SvPlayer player) - { - player.player.ClearCrimes(); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ClearCrimes, player.player.ID); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Cleared wanted level."); - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Removed his wantedlevel through the functionUI"); - return CurrentMenu.Staff; - } - #endregion + #region Key | 6 + public static CurrentMenu ClearWanted(SvPlayer player) + { + player.player.ClearCrimes(); + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ClearCrimes, player.player.ID); + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Cleared wanted level."); + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] {player.player.username} Removed his wantedlevel through the functionUI"); + return CurrentMenu.Staff; + } + #endregion - #region Key | 10 - public static CurrentMenu StaffMenu(SvPlayer player) - { - var sb = new StringBuilder("Staff menu:\n\n"); - if (HasPermission.Run(player, AccessMoneyMenu)) - sb.Append("F2: Give Money\n"); - if (HasPermission.Run(player, AccessItemMenu)) - sb.Append("F3: Give Items\n"); - if (HasPermission.Run(player, AccessSetHPMenu)) - sb.Append("F4: Set HP to full\n"); - if (HasPermission.Run(player, AccessSetStatsMenu)) - sb.Append("F5: Set Stats to full\n"); - if (HasPermission.Run(player, AccessCWMenu)) - sb.Append("F6: Clear wanted level\n\n"); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, $"{sb}Press F11 To close this (G)UI"); - return CurrentMenu.Staff; - } - #endregion - } + #region Key | 10 + public static CurrentMenu StaffMenu(SvPlayer player) + { + var sb = new StringBuilder("Staff menu:\n\n"); + if (HasPermission.Run(player, AccessMoneyMenu)) + sb.Append("F2: Give Money\n"); + if (HasPermission.Run(player, AccessItemMenu)) + sb.Append("F3: Give Items\n"); + if (HasPermission.Run(player, AccessSetHPMenu)) + sb.Append("F4: Set HP to full\n"); + if (HasPermission.Run(player, AccessSetStatsMenu)) + sb.Append("F5: Set Stats to full\n"); + if (HasPermission.Run(player, AccessCWMenu)) + sb.Append("F6: Clear wanted level\n\n"); + player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, $"{sb}Press F11 To close this (G)UI"); + return CurrentMenu.Staff; + } + #endregion + } } diff --git a/source/BP-Essentials/Methods/Utils/HandleSpam.cs b/source/BP-Essentials/Methods/Utils/HandleSpam.cs index 63f897c9..ee6bd8eb 100644 --- a/source/BP-Essentials/Methods/Utils/HandleSpam.cs +++ b/source/BP-Essentials/Methods/Utils/HandleSpam.cs @@ -8,37 +8,37 @@ namespace BP_Essentials { - class HandleSpam - { - public static bool Run(SvPlayer player, string message) - { - if (MessagesAllowedPerSecond != -1 && MessagesAllowedPerSecond < 50) - { - if (PlayerList.TryGetValue(player.player.ID, out var currObj)) - { - if (currObj.MessagesSent >= MessagesAllowedPerSecond) - { - Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] {player.player.username} got kicked for spamming! {currObj.MessagesSent}/s (max: {MessagesAllowedPerSecond}) messages sent."); - player.svManager.Kick(player.connection); - return true; - } - PlayerList[player.player.ID].MessagesSent++; - if (!currObj.IsCurrentlyAwaiting) - { - PlayerList[player.player.ID].IsCurrentlyAwaiting = true; - Task.Factory.StartNew(async () => - { - await Task.Delay(TimeBetweenDelay); - if (PlayerList.ContainsKey(player.player.ID)) - { - PlayerList[player.player.ID].MessagesSent = 0; - PlayerList[player.player.ID].IsCurrentlyAwaiting = false; - } - }); - } - } - } - return false; - } - } + class HandleSpam + { + public static bool Run(SvPlayer player, string message) + { + if (MessagesAllowedPerSecond != -1 && MessagesAllowedPerSecond < 50) + { + if (PlayerList.TryGetValue(player.player.ID, out var currObj)) + { + if (currObj.MessagesSent >= MessagesAllowedPerSecond) + { + Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] {player.player.username} got kicked for spamming! {currObj.MessagesSent}/s (max: {MessagesAllowedPerSecond}) messages sent."); + player.svManager.Kick(player.connection); + return true; + } + PlayerList[player.player.ID].MessagesSent++; + if (!currObj.IsCurrentlyAwaiting) + { + PlayerList[player.player.ID].IsCurrentlyAwaiting = true; + Task.Factory.StartNew(async () => + { + await Task.Delay(TimeBetweenDelay); + if (PlayerList.ContainsKey(player.player.ID)) + { + PlayerList[player.player.ID].MessagesSent = 0; + PlayerList[player.player.ID].IsCurrentlyAwaiting = false; + } + }); + } + } + } + return false; + } + } } diff --git a/source/BP-Essentials/Methods/Utils/IsJailed.cs b/source/BP-Essentials/Methods/Utils/IsJailed.cs index 483b28dd..6bc0aff5 100644 --- a/source/BP-Essentials/Methods/Utils/IsJailed.cs +++ b/source/BP-Essentials/Methods/Utils/IsJailed.cs @@ -9,11 +9,11 @@ namespace BP_Essentials { class IsJailed - { + { public static bool Run(SvPlayer player, bool allow = true) { if (allow || !(player.player.job is Prisoner)) - return true; + return true; player.SendChatMessage($"{MsgNoJailAllowed}"); return false; } diff --git a/source/BP-Essentials/Methods/Utils/MultiDictionary.cs b/source/BP-Essentials/Methods/Utils/MultiDictionary.cs index 94b32c69..9e4fea6e 100644 --- a/source/BP-Essentials/Methods/Utils/MultiDictionary.cs +++ b/source/BP-Essentials/Methods/Utils/MultiDictionary.cs @@ -6,25 +6,25 @@ namespace BP_Essentials.Methods.Utils { - public class MultiDictionary : Dictionary, TValue>, IDictionary, TValue> - { - public TValue this[TKey1 key1, TKey2 key2] - { - get { return base[Tuple.Create(key1, key2)]; } - set { base[Tuple.Create(key1, key2)] = value; } - } - public bool TryGetValue(TKey1 key1, TKey2 key2, out TValue value) - { - return base.TryGetValue(Tuple.Create(key1, key2), out value); - } - public void Add(TKey1 key1, TKey2 key2, TValue value) - { - base.Add(Tuple.Create(key1, key2), value); - } + public class MultiDictionary : Dictionary, TValue>, IDictionary, TValue> + { + public TValue this[TKey1 key1, TKey2 key2] + { + get { return base[Tuple.Create(key1, key2)]; } + set { base[Tuple.Create(key1, key2)] = value; } + } + public bool TryGetValue(TKey1 key1, TKey2 key2, out TValue value) + { + return base.TryGetValue(Tuple.Create(key1, key2), out value); + } + public void Add(TKey1 key1, TKey2 key2, TValue value) + { + base.Add(Tuple.Create(key1, key2), value); + } - public bool ContainsKey(TKey1 key1, TKey2 key2) - { - return base.ContainsKey(Tuple.Create(key1, key2)); - } - } + public bool ContainsKey(TKey1 key1, TKey2 key2) + { + return base.ContainsKey(Tuple.Create(key1, key2)); + } + } } diff --git a/source/BP-Essentials/Methods/Utils/PlaceholderParser.cs b/source/BP-Essentials/Methods/Utils/PlaceholderParser.cs index 2e3a958f..fae59fc6 100644 --- a/source/BP-Essentials/Methods/Utils/PlaceholderParser.cs +++ b/source/BP-Essentials/Methods/Utils/PlaceholderParser.cs @@ -9,76 +9,76 @@ namespace BP_Essentials { - public static class PlaceholderParser - { - public static string ParseString(string str) - { - var src = DateTime.Now; - var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); - var minutes = hm.ToString("mm"); - var seconds = hm.ToString("ss"); - return str - .Replace("{YYYY}", hm.ToString("yyyy")) - .Replace("{DD}", hm.ToString("dd")) - .Replace("{DDDD}", hm.ToString("dddd")) - .Replace("{MMMM}", hm.ToString("MMMM")) - .Replace("{MM}", hm.ToString("MM")) - .Replace("{H}", hm.ToString("HH")) - .Replace("{h}", hm.ToString("hh")) - .Replace("{M}", minutes) - .Replace("{S}", seconds) - .Replace("{T}", hm.ToString("t")); - } - public static string ParseTimeStamp() => ParseTimeStamp(TimestampFormat); - public static string ParseTimeStamp(string Timestamp) - { - try - { - return ParseString(Timestamp); - } - catch (Exception) - { - return "[Failed] "; - } - } - public static string ParseUserMessage(ShPlayer shplayer, string message, string playerMessage) - { - try - { - var src = DateTime.Now; - var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); - var minutes = hm.ToString("mm"); - var seconds = hm.ToString("ss"); - // Improve this mess - return message - .Replace("{YYYY}", hm.ToString("yyyy")) - .Replace("{DD}", hm.ToString("dd")) - .Replace("{DDDD}", hm.ToString("dddd")) - .Replace("{MMMM}", hm.ToString("MMMM")) - .Replace("{MM}", hm.ToString("MM")) - .Replace("{H}", hm.ToString("HH")) - .Replace("{h}", hm.ToString("hh")) - .Replace("{M}", minutes) - .Replace("{S}", seconds) - .Replace("{T}", hm.ToString("tt")) - .Replace("{username}", new Regex("(<)").Replace(shplayer.username, "<")) - .Replace("{id}", $"{shplayer.ID}") - .Replace("{jobname}", Jobs[shplayer.job.jobIndex]) - .Replace("{jobnameofficial}", shplayer.job.info.jobName) - .Replace("{jobindex}", $"{shplayer.job.jobIndex}") - .Replace("{jobcolor}", $"#{ColorUtility.ToHtmlStringRGB(shplayer.job.info.jobColor)}") - .Replace("{discordlink}", MsgDiscord) - .Replace("{infocolor}", infoColor) - .Replace("{warningcolor}", warningColor) - .Replace("{errorcolor}", errorColor) - .Replace("{argcolor}", argColor) - .Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(playerMessage), "<")); - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - return null; - } - } + public static class PlaceholderParser + { + public static string ParseString(string str) + { + var src = DateTime.Now; + var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); + var minutes = hm.ToString("mm"); + var seconds = hm.ToString("ss"); + return str + .Replace("{YYYY}", hm.ToString("yyyy")) + .Replace("{DD}", hm.ToString("dd")) + .Replace("{DDDD}", hm.ToString("dddd")) + .Replace("{MMMM}", hm.ToString("MMMM")) + .Replace("{MM}", hm.ToString("MM")) + .Replace("{H}", hm.ToString("HH")) + .Replace("{h}", hm.ToString("hh")) + .Replace("{M}", minutes) + .Replace("{S}", seconds) + .Replace("{T}", hm.ToString("t")); + } + public static string ParseTimeStamp() => ParseTimeStamp(TimestampFormat); + public static string ParseTimeStamp(string Timestamp) + { + try + { + return ParseString(Timestamp); + } + catch (Exception) + { + return "[Failed] "; + } + } + public static string ParseUserMessage(ShPlayer shplayer, string message, string playerMessage) + { + try + { + var src = DateTime.Now; + var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); + var minutes = hm.ToString("mm"); + var seconds = hm.ToString("ss"); + // Improve this mess + return message + .Replace("{YYYY}", hm.ToString("yyyy")) + .Replace("{DD}", hm.ToString("dd")) + .Replace("{DDDD}", hm.ToString("dddd")) + .Replace("{MMMM}", hm.ToString("MMMM")) + .Replace("{MM}", hm.ToString("MM")) + .Replace("{H}", hm.ToString("HH")) + .Replace("{h}", hm.ToString("hh")) + .Replace("{M}", minutes) + .Replace("{S}", seconds) + .Replace("{T}", hm.ToString("tt")) + .Replace("{username}", new Regex("(<)").Replace(shplayer.username, "<")) + .Replace("{id}", $"{shplayer.ID}") + .Replace("{jobname}", Jobs[shplayer.job.jobIndex]) + .Replace("{jobnameofficial}", shplayer.job.info.jobName) + .Replace("{jobindex}", $"{shplayer.job.jobIndex}") + .Replace("{jobcolor}", $"#{ColorUtility.ToHtmlStringRGB(shplayer.job.info.jobColor)}") + .Replace("{discordlink}", MsgDiscord) + .Replace("{infocolor}", infoColor) + .Replace("{warningcolor}", warningColor) + .Replace("{errorcolor}", errorColor) + .Replace("{argcolor}", argColor) + .Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(playerMessage), "<")); + } + catch (Exception ex) + { + ErrorLogging.Run(ex); + } + return null; + } + } } diff --git a/source/BP-Essentials/Methods/misc/Reload.cs b/source/BP-Essentials/Methods/misc/Reload.cs index 59c31e4f..fece8574 100644 --- a/source/BP-Essentials/Methods/misc/Reload.cs +++ b/source/BP-Essentials/Methods/misc/Reload.cs @@ -15,31 +15,31 @@ public static void Run(bool silentExecution, SvPlayer player = null, bool IsFirs { try { - if (!silentExecution && player != null) - player.SendChatMessage("[WAIT] Reloading all files.."); - CheckFiles.Run(); - ReadFile.Run(SettingsFile); - ReadStream.Run(LanguageBlockFile, LanguageBlockWords); - ReadStream.Run(ChatBlockFile, ChatBlockWords); - ReadStream.Run(AdminListFile, AdminsListPlayers); - ReadCustomCommands.Run(); - ReadGroups.Run(); - LanguageBlockWords = LanguageBlockWords.ConvertAll(d => d.ToLower()); - ChatBlockWords = ChatBlockWords.ConvertAll(d => d.ToLower()); - if (DownloadIdList && player == null) // do not download every time a player /reloads - GetIdList.Run(false); - else - { - ReadFile.Run(IdListItemsFile); - ReadFile.Run(IdListVehicleFile); - } - ReadFile.Run(AnnouncementsFile); - ReadFile.Run(GodListFile); - ReadFile.Run(MuteListFile); - ReadFile.Run(AfkListFile); - ReadFile.Run(RulesFile); - if (!silentExecution && player != null) - player.SendChatMessage("[OK] Critical config files reloaded"); + if (!silentExecution && player != null) + player.SendChatMessage("[WAIT] Reloading all files.."); + CheckFiles.Run(); + ReadFile.Run(SettingsFile); + ReadStream.Run(LanguageBlockFile, LanguageBlockWords); + ReadStream.Run(ChatBlockFile, ChatBlockWords); + ReadStream.Run(AdminListFile, AdminsListPlayers); + ReadCustomCommands.Run(); + ReadGroups.Run(); + LanguageBlockWords = LanguageBlockWords.ConvertAll(d => d.ToLower()); + ChatBlockWords = ChatBlockWords.ConvertAll(d => d.ToLower()); + if (DownloadIdList && player == null) // do not download every time a player /reloads + GetIdList.Run(false); + else + { + ReadFile.Run(IdListItemsFile); + ReadFile.Run(IdListVehicleFile); + } + ReadFile.Run(AnnouncementsFile); + ReadFile.Run(GodListFile); + ReadFile.Run(MuteListFile); + ReadFile.Run(AfkListFile); + ReadFile.Run(RulesFile); + if (!silentExecution && player != null) + player.SendChatMessage("[OK] Critical config files reloaded"); } catch (Exception ex) { diff --git a/source/BP-Essentials/Properties/AssemblyInfo.cs b/source/BP-Essentials/Properties/AssemblyInfo.cs index 51051ca7..ab5e9228 100644 --- a/source/BP-Essentials/Properties/AssemblyInfo.cs +++ b/source/BP-Essentials/Properties/AssemblyInfo.cs @@ -15,4 +15,4 @@ // Change BPE Version here -[assembly: AssemblyFileVersion("2.6.3")] +[assembly: AssemblyFileVersion("2.6.4")] diff --git a/source/BP-Essentials/Variables.cs b/source/BP-Essentials/Variables.cs index 49dec741..86e3381d 100644 --- a/source/BP-Essentials/Variables.cs +++ b/source/BP-Essentials/Variables.cs @@ -9,8 +9,8 @@ namespace BP_Essentials { public class Variables : Core { - public static string Version { get; private set; } = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; - public static bool IsPreRelease => Version.Contains("pre"); + public static string Version { get; private set; } = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; + public static bool IsPreRelease => Version.Contains("pre"); // Generic Constants public const string FileDirectory = "Essentials/"; @@ -42,13 +42,13 @@ public class Variables : Core public static readonly string ChatLogFile = Path.Combine(LogDirectory, "chat.txt"); public static readonly string CommandLogFile = Path.Combine(LogDirectory, "commands.txt"); - // Singletons - public static WarpHandler WarpHandler { get; set; } - public static KitsHandler KitsHandler { get; set; } - public static Announcer Announcer { get; set; } = new Announcer(); + // Singletons + public static WarpHandler WarpHandler { get; set; } + public static KitsHandler KitsHandler { get; set; } + public static Announcer Announcer { get; set; } = new Announcer(); - // Bools - public static bool MsgUnknownCommand; + // Bools + public static bool MsgUnknownCommand; public static bool ChatBlock; public static bool LanguageBlock; @@ -71,11 +71,11 @@ public class Variables : Core public static bool BlockMissions; public static bool ProximityChat; public static bool LocalChatMute; - public static bool LocalChatMe; - public static bool TimescaleDisabled; + public static bool LocalChatMe; + public static bool TimescaleDisabled; - // Lists - public static List CustomCommands = new List(); + // Lists + public static List CustomCommands = new List(); public static List Responses = new List(); public static List ChatBlockWords = new List(); @@ -88,16 +88,16 @@ public class Variables : Core public static List BlockedItems = new List(); - // Dictionary - public static Dictionary PlayerList { get; set; } = new Dictionary(); - public static Dictionary Groups { get; set; } = new Dictionary(); - public static Dictionary CommandList { get; set; } = new Dictionary(); - public static Dictionary WhitelistedJobs { get; set; } = new Dictionary(); + // Dictionary + public static Dictionary PlayerList { get; set; } = new Dictionary(); + public static Dictionary Groups { get; set; } = new Dictionary(); + public static Dictionary CommandList { get; set; } = new Dictionary(); + public static Dictionary WhitelistedJobs { get; set; } = new Dictionary(); - // MultiDictonary - public static Methods.Utils.MultiDictionary> FunctionMenuKeys { get; set; } = new Methods.Utils.MultiDictionary>(); + // MultiDictonary + public static Methods.Utils.MultiDictionary> FunctionMenuKeys { get; set; } = new Methods.Utils.MultiDictionary>(); - // Arrays + // Arrays public static string[] Jobs = { // default values "Citizen", @@ -134,10 +134,10 @@ public class Variables : Core public static string BlockedItemMessage; public static string MsgNoWantedAllowed; public static string MsgNoCuffedAllowed; - public static string MsgNoJailAllowed; - public static string MeMessage; + public static string MsgNoJailAllowed; + public static string MeMessage; - public static string infoColor, errorColor, warningColor, argColor; + public static string infoColor, errorColor, warningColor, argColor; // Strings public static string Rules; @@ -163,9 +163,9 @@ public class Variables : Core public static string DiscordWebhook_Report; public static string WipePassword; - public static string NotValidArg = $"Error: Is that a valid number you provided as argument?"; - // Ints - public const int SaveTime = 5 * 60; + public static string NotValidArg = $"Error: Is that a valid number you provided as argument?"; + // Ints + public const int SaveTime = 5 * 60; public static int AnnounceIndex; public static int TimeBetweenAnnounce; @@ -173,7 +173,7 @@ public class Variables : Core public static int DebugLevel; public static int GodModeLevel; public static int MessagesAllowedPerSecond; - public static int TimeBetweenDelay; + public static int TimeBetweenDelay; // Misc. public static string _msg; @@ -237,33 +237,33 @@ public class Variables : Core 499504400, //License Gun 607710552 //License Pilots }; - public static int[] IDs_Vehicles; + public static int[] IDs_Vehicles; public static int[] IDs_Items; } - public class LastLocation - { - public Vector3 Position { get; private set; } - public Quaternion Rotation { get; private set; } - public int PlaceIndex { get; private set; } - public void Update(Vector3 position, Quaternion rotation, int index) - { - Position = position; - Rotation = rotation; - PlaceIndex = index; - } - public bool HasPositionSet() - { - return Position != default(Vector3) && Rotation != default(Quaternion); - } - public LastLocation(Vector3 position, Quaternion rotation, int index) - { - Update(position, rotation, index); - } - public LastLocation() - { - - } - } + public class LastLocation + { + public Vector3 Position { get; private set; } + public Quaternion Rotation { get; private set; } + public int PlaceIndex { get; private set; } + public void Update(Vector3 position, Quaternion rotation, int index) + { + Position = position; + Rotation = rotation; + PlaceIndex = index; + } + public bool HasPositionSet() + { + return Position != default(Vector3) && Rotation != default(Quaternion); + } + public LastLocation(Vector3 position, Quaternion rotation, int index) + { + Update(position, rotation, index); + } + public LastLocation() + { + + } + } public class _CommandList { public Action RunMethod; @@ -273,15 +273,15 @@ public class _CommandList public string commandName; public bool commandWantedAllowed; public bool commandHandcuffedAllowed; - public bool commandWhileJailedAllowed; + public bool commandWhileJailedAllowed; } public class PlayerListItem { - public PlayerListItem(ShPlayer player) - { - ShPlayer = player; - } + public PlayerListItem(ShPlayer player) + { + ShPlayer = player; + } public ShPlayer ShPlayer { get; set; } public CurrentMenu LastMenu { get; set; } public ShPlayer ReportedPlayer { get; set; } @@ -294,7 +294,7 @@ public PlayerListItem(ShPlayer player) public bool IsCurrentlyAwaiting { get; set; } public ShPlayer ReplyToUser { get; set; } public ShPlayer TpaUser { get; set; } - public LastLocation LastLocation { get; set; } = new LastLocation(); + public LastLocation LastLocation { get; set; } = new LastLocation(); } public class _Group @@ -306,7 +306,7 @@ public class _Group public enum CurrentMenu { - None, + None, Main, Help, Staff,