From aa7b4abd742c49e41ed6cbd9c8e39fdb2feebdff Mon Sep 17 00:00:00 2001 From: UserR00T Date: Fri, 22 Mar 2019 21:20:44 +0100 Subject: [PATCH] Fixes some nullref issues, and empty report reasons --- .../Chat/Commands/Everyone/Report.cs | 4 + source/BP-Essentials/EssentialsChat.cs | 150 --- source/BP-Essentials/EssentialsCore.cs | 79 -- source/BP-Essentials/EssentialsMethods.cs | 493 ------- source/BP-Essentials/EssentialsVariables.cs | 1136 ----------------- .../Methods/API/DownloadAndWriteToFile.cs | 31 - .../BP-Essentials/Methods/API/DownloadFile.cs | 45 - .../Methods/API/FilterComments.cs | 32 - .../BP-Essentials/Methods/API/GetArgument.cs | 55 - .../Methods/API/GetPlaceHolders.cs | 72 -- .../BP-Essentials/Methods/API/GetShByStr.cs | 29 - .../Methods/API/HasPermission.cs | 32 - .../Methods/API/SendDiscordMessage.cs | 64 - .../Methods/Check/CheckAltAcc.cs | 37 - .../Methods/FileHandler/CheckFiles.cs | 1 + .../BP-Essentials/Methods/FileHandler/Kits.cs | 97 -- .../Methods/FileHandler/ReadFile.cs | 2 +- .../Methods/FileHandler/Warps.cs | 98 -- .../Methods/GameMethods/CleanupApartment.cs | 4 +- .../Methods/GameMethods/GetExtraCount.cs | 2 +- .../Methods/GameMethods/SetJob.cs | 4 +- .../Methods/GameMethods/UnRestrain.cs | 4 +- .../Methods/Utils/FillPlaceholders.cs | 33 - .../Methods/Utils/FunctionMenu.cs | 5 + .../Methods/Utils/GetPlaceHolders.cs | 72 -- .../Methods/Utils/SetTimeStamp.cs | 52 - .../Methods/misc/ErrorLogging.cs | 62 - .../BP-Essentials/Methods/misc/LogMessage.cs | 69 - source/BP-Essentials/Methods/misc/SaveNow.cs | 32 - .../Methods/misc/SavePeriodically.cs | 43 - .../Methods/misc/SetTimeStamp.cs | 52 - 31 files changed, 21 insertions(+), 2870 deletions(-) delete mode 100644 source/BP-Essentials/EssentialsChat.cs delete mode 100644 source/BP-Essentials/EssentialsCore.cs delete mode 100644 source/BP-Essentials/EssentialsMethods.cs delete mode 100644 source/BP-Essentials/EssentialsVariables.cs delete mode 100644 source/BP-Essentials/Methods/API/DownloadAndWriteToFile.cs delete mode 100644 source/BP-Essentials/Methods/API/DownloadFile.cs delete mode 100644 source/BP-Essentials/Methods/API/FilterComments.cs delete mode 100644 source/BP-Essentials/Methods/API/GetArgument.cs delete mode 100644 source/BP-Essentials/Methods/API/GetPlaceHolders.cs delete mode 100644 source/BP-Essentials/Methods/API/GetShByStr.cs delete mode 100644 source/BP-Essentials/Methods/API/HasPermission.cs delete mode 100644 source/BP-Essentials/Methods/API/SendDiscordMessage.cs delete mode 100644 source/BP-Essentials/Methods/Check/CheckAltAcc.cs delete mode 100644 source/BP-Essentials/Methods/FileHandler/Kits.cs delete mode 100644 source/BP-Essentials/Methods/FileHandler/Warps.cs delete mode 100644 source/BP-Essentials/Methods/Utils/FillPlaceholders.cs delete mode 100644 source/BP-Essentials/Methods/Utils/GetPlaceHolders.cs delete mode 100644 source/BP-Essentials/Methods/Utils/SetTimeStamp.cs delete mode 100644 source/BP-Essentials/Methods/misc/ErrorLogging.cs delete mode 100644 source/BP-Essentials/Methods/misc/LogMessage.cs delete mode 100644 source/BP-Essentials/Methods/misc/SaveNow.cs delete mode 100644 source/BP-Essentials/Methods/misc/SavePeriodically.cs delete mode 100644 source/BP-Essentials/Methods/misc/SetTimeStamp.cs diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs index 07b22ce7..e65cf138 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs @@ -41,7 +41,11 @@ public static void Run(SvPlayer player, string message) 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/EssentialsChat.cs b/source/BP-Essentials/EssentialsChat.cs deleted file mode 100644 index 8bef697f..00000000 --- a/source/BP-Essentials/EssentialsChat.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel.Design.Serialization; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using UnityEngine; -using static BP_Essentials.EssentialsMethodsPlugin; -using static BP_Essentials.EssentialsVariablesPlugin; -namespace BP_Essentials -{ - public class EssentialsChatPlugin : MonoBehaviour - { - #region Event: ChatMessage | Global - //Chat Events - [Hook("SvPlayer.SvGlobalChatMessage")] - public static bool SvGlobalChatMessage(SvPlayer player, ref string message) - { - try - { - var tempMessage = message; - if (MessagesAllowedPerSecond != -1 && MessagesAllowedPerSecond < 50) - { - if (playerList.TryGetValue(player.player.ID, out var currObj)) - { - if (currObj.messagesSent >= MessagesAllowedPerSecond) - { - Debug.Log($"{SetTimeStamp.Run()}[WARNING] {player.player.username} got kicked for spamming! {currObj.messagesSent}/s (max: {MessagesAllowedPerSecond}) messages sent."); - player.svManager.Kick(player.connection); - return true; - } - else - { - playerList[player.player.ID].messagesSent++; - if (!currObj.isCurrentlyAwaiting) - { - playerList[player.player.ID].isCurrentlyAwaiting = true; - Task.Factory.StartNew(async () => - { - await Task.Delay(1000); - if (playerList.ContainsKey(player.player.ID)) - { - playerList[player.player.ID].messagesSent = 0; - playerList[player.player.ID].isCurrentlyAwaiting = false; - } - }); - } - } - } - } - //Message Logging - if (!(MutePlayers.Contains(player.playerData.username))) - LogMessage.Run(player, message); - var command = GetArgument.Run(0, false, false, message); - if (message.StartsWith(CmdCommandCharacter)) - { - // CustomCommands - var customCommand = CustomCommands.FirstOrDefault(x => tempMessage.StartsWith(CmdCommandCharacter + x.Command)); - if (customCommand != null) - { - foreach (string line in customCommand.Response.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)) - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, GetPlaceHolders.Run(line, player)); - 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.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); - return true; - } - if (HasPermission.Run(player, cmd.commandGroup, true, player.player.job.jobIndex) && HasWantedLevel.Run(player, cmd.commandWantedAllowed) && IsCuffed.Run(player, cmd.commandHandcuffedAllowed)) - { - playerList.Where(x => x.Value.spyEnabled && x.Value.Shplayer.svPlayer != player).ToList().ForEach(x => x.Value.Shplayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"[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.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Unknown command. Type {CmdCommandCharacter}essentials cmds for more info."); - return true; - } - } - //Checks if the player is muted. - if (MutePlayers.Contains(player.playerData.username)) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, SelfIsMuted); - return true; - } - //Checks if the message contains a username that is AFK. - if (AfkPlayers.Any(message.Contains)) - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, PlayerIsAFK); - - var shplayer = player.player; - if (!playerList[shplayer.ID].chatEnabled) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Please enable your chat again by typing {CmdCommandCharacter}{CmdToggleChat}."); - return true; - } - if (playerList[shplayer.ID].staffChatEnabled) - { - SendChatMessageToAdmins.Run(FillPlaceholders.Run(shplayer, AdminChatMessage, message)); - return true; - } - foreach (var curr in Groups) - if (curr.Value.Users.Contains(player.playerData.username)) - { - SendChatMessage.Run(FillPlaceholders.Run(shplayer, curr.Value.Message, message)); - return true; - } - if (player.player.admin) - { - SendChatMessage.Run(FillPlaceholders.Run(shplayer, AdminMessage, message)); - return true; - } - SendChatMessage.Run(FillPlaceholders.Run(shplayer, PlayerMessage, message)); - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - return true; - } - #endregion - - #region Event: ChatMessage | Local - [Hook("SvPlayer.SvLocalChatMessage")] - public static bool SvLocalChatMessage(SvPlayer player, ref string message) - { - if (LocalChatMute && MutePlayers.Contains(player.playerData.username)) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, SelfIsMuted); - return true; - } - LogMessage.LocalMessage(player, message); - if (!ProximityChat) - return false; - player.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.GameMessage, $"[Local-Chat] {new Regex("(<)").Replace(player.player.username, "<")}: {new Regex("(<)").Replace(message, "<")}"); - return true; - } - #endregion - } -} \ No newline at end of file diff --git a/source/BP-Essentials/EssentialsCore.cs b/source/BP-Essentials/EssentialsCore.cs deleted file mode 100644 index b985ac11..00000000 --- a/source/BP-Essentials/EssentialsCore.cs +++ /dev/null @@ -1,79 +0,0 @@ -/* - - - BP:Essentials - - Created by UserR00T, DBK, and BP. - Currently only being worked on by UserR00T unfortunately. :( - - License: GPLv3. - - -*/ - - -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -namespace BP_Essentials -{ - public class EssentialsCorePlugin - { - - //Initialization - [Hook("SvManager.StartServer")] - public static void StartServer(SvManager svManager) - { - try - { - SvMan = svManager; - Kits.StartKitTimer(); - Reload.Run(true, null, true); - CheckAutoReloadFile.Run(AutoReloader); - if (EssentialsVariablesPlugin.Version != LocalVersion) - { - Debug.Log("[ERROR] Essentials - Versions do not match!"); - Debug.Log("[ERROR] Essentials - Essentials version: " + EssentialsVariablesPlugin.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(); - 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 - A file cannot be loaded in!"); - 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("-------------------------------------------------------------------------------"); - - } - if (Announcements.Length != 0) - { - Chat.Announce.Run(); - Debug.Log(SetTimeStamp.Run() + "[INFO] Announcer started successfully!"); - } - else - Debug.Log(SetTimeStamp.Run() + "[WARNING] No announcements found in the file!"); - } - } -} \ No newline at end of file diff --git a/source/BP-Essentials/EssentialsMethods.cs b/source/BP-Essentials/EssentialsMethods.cs deleted file mode 100644 index 54bba9ea..00000000 --- a/source/BP-Essentials/EssentialsMethods.cs +++ /dev/null @@ -1,493 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using System.Text.RegularExpressions; -using System.Collections.Generic; -using System.Text; -using System.Reflection; - -namespace BP_Essentials -{ - public class EssentialsMethodsPlugin : EssentialsCorePlugin - { - - [Hook("SvPlayer.SvSellApartment")] - public static bool SvSellApartment(SvPlayer player) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Are you sure you want to sell your apartment? Type '{CmdCommandCharacter}{CmdConfirm}' to confirm."); //softcode command - return true; - } - - [Hook("SvPlayer.Initialize")] - public static void Initialize(SvPlayer player) - { - var shPlayer = player.player; - if (!player.serverside) - { - new Thread(() => WriteIpToFile.Run(player)).Start(); - new Thread(() => CheckBanned.Run(player)).Start(); - new Thread(() => CheckAltAcc.Run(player)).Start(); - playerList.Add(shPlayer.ID, new _PlayerList { Shplayer = shPlayer }); - } - } - - [Hook("SvPlayer.Destroy")] - public static void Destroy(SvPlayer player) - { - foreach (KeyValuePair item in playerList) - if (item.Value.Shplayer.svPlayer == player && !item.Value.Shplayer.svPlayer.serverside) - { - Debug.Log(SetTimeStamp.Run() + "[INFO] [LEAVE] " + item.Value.Shplayer.username); - playerList.Remove(item.Key); - break; - } - } - - [Hook("SvPlayer.Damage")] - public static bool Damage(SvPlayer player, ref DamageIndex type, ref float amount, ref ShPlayer attacker, ref Collider collider) - { - return CheckGodMode.Run(player, amount); - } - - [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 ShTransport transport, ref ShPlayer enemy) - { - var shPlayer = player.player; - return EnableBlockSpawnBot == true && BlockedSpawnIds.Contains(shPlayer.spawnJobIndex); - } - - [Hook("ShRestraint.HitEffect")] - public static bool HitEffect(ShRestraint player, ref ShEntity hitTarget, ref ShPlayer source, ref Collider collider) - { - foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) - if (!shPlayer.svPlayer.serverside) - { - if (shPlayer != hitTarget) continue; - if (!GodListPlayers.Contains(shPlayer.username)) continue; - shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Being handcuffed Blocked!"); - return true; - } - return false; - } - - [Hook("SvPlayer.SvBan")] - public static bool SvBan(SvPlayer player, ref int otherID) - { - if (BlockBanButtonTabMenu) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"This button has been disabled. Please use the ban commands."); - return true; - } - foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) - if (shPlayer.ID == otherID) - if (!shPlayer.svPlayer.serverside && !shPlayer.svPlayer.serverside) - { - LogMessage.LogOther($"{SetTimeStamp.Run()}[INFO] {shPlayer.username} Got banned by {player.playerData.username}"); - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username}"); - SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username); - } - return false; - } - - [Hook("SvPlayer.SvStartVote")] - public static bool SvStartVote(SvPlayer player, ref byte voteIndex, ref int ID) - { - if (voteIndex == VoteIndex.Kick) - { - if (!VoteKickDisabled) - { - foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) - if (shPlayer.ID == ID) - foreach (var shIssuer in UnityEngine.Object.FindObjectsOfType()) - if (shIssuer.svPlayer == player) - { - if (player.svManager.vote != null || voteIndex >= shIssuer.manager.votes.Length || player.svManager.startedVote.Contains(shIssuer)) - return true; - player.svManager.startedVote.Add(shIssuer); - player.svManager.vote = shIssuer.manager.votes[voteIndex]; - if (player.svManager.vote.CheckVote(ID)) - { - player.Send(SvSendType.All, Channel.Reliable, 60, voteIndex, ID); - player.svManager.StartCoroutine(player.svManager.StartVote()); - Debug.Log($"{SetTimeStamp.Run()}[INFO] {player.playerData.username} Has issued a votekick against {shPlayer.username}"); - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} Has issued a vote kick against {shPlayer.username}"); - LatestVotePeople.Clear(); - } - else - player.svManager.vote = null; - } - } - else - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Vote kicking has been disabled on this server."); - return true; - } - else if (voteIndex == VoteIndex.Mission) - { - if (BlockMissions) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"All missions have been disabled on this server."); - return true; - } - } - return false; - } - - [Hook("SvPlayer.SvVoteYes", true)] - public static void SvVoteYes(SvPlayer player) - { - LatestVotePeople.Add(player.playerData.username); - } - - [Hook("SvPlayer.SvFunctionKey")] - public static bool SvFunctionKey(SvPlayer player, ref byte key) - { - try - { - if (key < 11) - { - foreach (KeyValuePair item in playerList) - { - if (item.Value.Shplayer.svPlayer == player) - { - ShPlayer shPlayer = item.Value.Shplayer; - - #region Report - if (item.Value.LastMenu == CurrentMenu.Report && key > 1 && key < 11) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Reported \"{item.Value.ReportedPlayer.username}\" With the reason \"{ReportReasons[key - 2]}\"."); - item.Value.reportedReason = ReportReasons[key - 2]; - item.Value.LastMenu = CurrentMenu.Main; - SendDiscordMessage.ReportMessage(item.Value.ReportedPlayer.username, player.player.username, ReportReasons[key - 2]); - ReportPlayer.Run(player.player.username, ReportReasons[key - 2], item.Value.ReportedPlayer); - return true; - } - #endregion - - switch (key) - { - case 1: - 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"); - else - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\n\nPress F11 To close this (G)UI"); - item.Value.LastMenu = CurrentMenu.Main; - break; - case 2: - if (item.Value.LastMenu == CurrentMenu.ServerInfo) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, File.ReadAllText("server_info.txt")); - item.Value.LastMenu = CurrentMenu.Main; - } - if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessMoneyMenu)) - { - 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"); - item.Value.LastMenu = CurrentMenu.GiveMoney; - } - else if (item.Value.LastMenu == CurrentMenu.GiveMoney) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - shPlayer.TransferMoney(DeltaInv.AddToMe, 1000, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 1.000 dollars."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 1.000 dollars through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - else if (item.Value.LastMenu == CurrentMenu.GiveItems) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - shPlayer.TransferItem(1, CommonIDs[0], 500, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 500 pistol ammo."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 500 pistol ammo through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - else if (item.Value.LastMenu == CurrentMenu.AdminReport && shPlayer.admin) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - if (IsOnline.Run(item.Value.ReportedPlayer)) - { - shPlayer.SetPosition(item.Value.ReportedPlayer.GetPosition()); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Teleported to \"{item.Value.ReportedPlayer.username}\"."); - } - else - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, "Player not online anymore."); - item.Value.ReportedPlayer = null; - item.Value.LastMenu = CurrentMenu.Main; - } - - break; - case 3: - if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessItemMenu)) - { - 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"); - item.Value.LastMenu = CurrentMenu.GiveItems; - } - else if (item.Value.LastMenu == CurrentMenu.GiveMoney) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - shPlayer.TransferMoney(DeltaInv.AddToMe, 10000, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 10.000 dollars."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 10.000 dollars through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - return true; - } - else if (item.Value.LastMenu == CurrentMenu.GiveItems) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - shPlayer.TransferItem(1, CommonIDs[1], 20, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 20 handcuffs."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 20 handcuffs through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - return true; - } - else if (item.Value.LastMenu == CurrentMenu.AdminReport && shPlayer.admin) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - item.Value.LastMenu = CurrentMenu.Main; - return true; - } - if (item.Value.LastMenu == CurrentMenu.Main) - { - 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"); - item.Value.LastMenu = CurrentMenu.ServerInfo; - } - else if (item.Value.LastMenu == CurrentMenu.ServerInfo) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - - var builder = new StringBuilder(); - builder.Append("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.Append(line + "\r\n"); - player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, builder.ToString()); - item.Value.LastMenu = CurrentMenu.Main; - } - - break; - case 4: - if (item.Value.LastMenu == CurrentMenu.GiveMoney) - { - item.Value.Shplayer.TransferMoney(DeltaInv.AddToMe, 100000, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 100.000 dollars."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 100.000 dollars through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - else if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessSetHPMenu)) - { - player.Heal(100); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You've been healed."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " healed himself through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - else if (item.Value.LastMenu == CurrentMenu.GiveItems) - { - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - shPlayer.TransferItem(1, CommonIDs[2], ClPacket.GameMessage, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 10 Taser ammo."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 10 taser ammo through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - break; - case 5: - if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessSetStatsMenu)) - { - player.UpdateStats(100F, 100F, 100F, 100F); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Maxed out stats for yourself."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Maxed out stats through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - else if (item.Value.LastMenu == CurrentMenu.GiveItems) - { - for (int i = 3; i < 7; i++) - shPlayer.TransferItem(1, CommonIDs[i], 1, true); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You have given yourself all licenses."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in all licenses through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - break; - case 6: - if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessCWMenu)) - { - shPlayer.ClearCrimes(); - player.Send(SvSendType.Self, Channel.Reliable, 33, shPlayer.ID); - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Cleared wanted level."); - Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Removed his wantedlevel through the functionUI"); - item.Value.LastMenu = CurrentMenu.Main; - } - - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - break; - case 10: - if (item.Value.LastMenu == CurrentMenu.Main) - { - var sb = new StringBuilder().Append("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"); - item.Value.LastMenu = CurrentMenu.Staff; - } - break; - default: - break; - } - } - } - return true; - } - foreach (KeyValuePair item in playerList) - if (item.Value.Shplayer.svPlayer == player) - item.Value.LastMenu = CurrentMenu.Main; - player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu); - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - return true; - } - - [Hook("SvPlayer.SvSuicide")] - public static bool SvSuicide(SvPlayer player) - { - var shPlayer = player.player; - if (BlockSuicide) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You cannot suicide on this server because the server owner disabled it."); - return true; - } - return false; - } - [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)) - if (!HasPermission.Run(player, WhitelistedJobs[shEmployer.job.jobIndex], false, shPlayer.job.jobIndex)) - { - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, MsgNoPermJob); - return true; - } - return false; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - return false; - } - } - [Hook("SvPlayer.SvAddCrime")] - public static bool SvAddCrime(SvPlayer player, ref byte crimeIndex, ref ShEntity victim) - { - try - { - if (GodModeLevel >= 1 && CheckGodMode.Run(player, null, "Blocked crime and losing EXP!")) - return true; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - return false; - } - [Hook("ShPlayer.TransferItem")] - public static bool TransferItem(ShPlayer player, ref byte deltaType, ref int itemIndex, ref int amount, ref bool dispatch) - { - try - { - if (player != null && BlockedItems.Count > 0 && BlockedItems.Contains(itemIndex)) - { - player.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, BlockedItemMessage); - return true; - } - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - return false; - } - - - [Hook("ShPlayer.RemoveItemsDeath")] - public static bool RemoveItemsDeath(ShPlayer player) - { - if (!blockLicenseRemoved) - return false; - foreach (InventoryItem inventoryItem in player.myItems.Values.ToArray()) - { - if (blockLicenseRemoved && inventoryItem.item.name.StartsWith("License")) - continue; - int extraCount = GetExtraCount.Run(player, inventoryItem); - if (extraCount > 0) - { - var shWearable = inventoryItem.item as ShWearable; - if (!shWearable || shWearable.illegal || player.curWearables[(int)shWearable.type].index != shWearable.index) - player.TransferItem(2, inventoryItem.item.index, extraCount, true); - } - } - if (blockLicenseRemoved) - player.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"This server disabled losing licenses on death."); - return true; - } - - [Hook("ShMovable.ShDie")] - public static void ShDie(ShMovable shMoveable) - { - shMoveable.CleanUp(); - shMoveable.ResetInputs(); - shMoveable.health = 0f; - if (shMoveable.manager.isServer) - if (!shMoveable.svEntity.respawnable) - shMoveable.Destroy(); - else - shMoveable.StartCoroutine(shMoveable.svMovable.RespawnDelay()); - } - [Hook("SvPlayer.SvPlaceInJail")] - public static void SvPlaceInJail(SvPlayer player, ref int criminalID) - { - var shPlayer = player.player; - if (shPlayer.manager.jail && shPlayer.job is Police) - { - var crimShPlayer = player.entity.manager.FindByID(criminalID); - if (!crimShPlayer) - return; - if (player.serverside || crimShPlayer.DistanceSqr(player.player.manager.jail) < 14400f) - { - var jailTime = 0f; - var Fine = 0; - foreach (var offense in crimShPlayer.offenses) - { - jailTime += offense.GetCrime().jailtime; - Fine += offense.GetCrime().fine; - } - SendToJail.Run(crimShPlayer, jailTime); - if (Fine > 0) - player.Reward(3, Fine); - if (ShowJailMessage) - player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{player.player.username} sent {crimShPlayer.username} to jail{(Fine > 0 ? $" for a fine of ${Fine}" : ".")}"); - return; - } - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Confirm criminal is cuffed and near jail"); - } - } - } -} \ No newline at end of file diff --git a/source/BP-Essentials/EssentialsVariables.cs b/source/BP-Essentials/EssentialsVariables.cs deleted file mode 100644 index a328e12d..00000000 --- a/source/BP-Essentials/EssentialsVariables.cs +++ /dev/null @@ -1,1136 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using UnityEngine; - -namespace BP_Essentials -{ - public class EssentialsVariablesPlugin : EssentialsCorePlugin - { - public const string Version = "2.6.1"; - public static bool isPreRelease; - - // Generic Constants - public const string FileDirectory = "Essentials/"; - - public static string LogDirectory = Path.Combine(FileDirectory, "logs/"); - public static string KitDirectory = Path.Combine(FileDirectory, "kits/"); - public static string WarpDirectory = Path.Combine(FileDirectory, "warps/"); - - public const string SettingsFile = FileDirectory + "essentials_settings.txt"; - public const string LanguageBlockFile = FileDirectory + "languageblock.txt"; - public const string ChatBlockFile = FileDirectory + "chatblock.txt"; - public const string AnnouncementsFile = FileDirectory + "announcements.txt"; - public const string IpListFile = FileDirectory + "ip_list.txt"; - public const string GodListFile = FileDirectory + "godlist.txt"; - public const string AfkListFile = FileDirectory + "afklist.txt"; - public const string MuteListFile = FileDirectory + "mutelist.txt"; - public const string ExceptionFile = FileDirectory + "exceptions.txt"; - public const string CustomCommandsFile = FileDirectory + "CustomCommands.txt"; - public const string CustomGroupsFile = FileDirectory + "CustomGroups.txt"; - public const string IdListItemsFile = FileDirectory + "ID_list-Items.txt"; - public const string IdListVehicleFile = FileDirectory + "ID_list-Vehicles.txt"; - - public const string AutoReloader = FileDirectory + "autoReloader.txt"; - - public const string AdminListFile = "admin_list.txt"; - public const string RulesFile = "server_info.txt"; - public const string BansFile = "ban_list.txt"; - public static readonly string LogFile = Path.Combine(LogDirectory, "all.txt"); - public static readonly string ChatLogFile = Path.Combine(LogDirectory, "chat.txt"); - public static readonly string CommandLogFile = Path.Combine(LogDirectory, "commands.txt"); - - // Bools - public static bool MsgUnknownCommand; - - public static bool ChatBlock; - public static bool LanguageBlock; - public static bool CheckAlt; - public static bool All; - public static bool Unmute; - public static bool MessageToLower; - public static bool EnableAtmCommand; - public static bool Confirmed; - public static bool? EnableBlockSpawnBot; - public static bool ShowDMGMessage; - public static bool VoteKickDisabled; - public static bool DownloadIdList; - public static bool EnableDiscordWebhook_Ban; - public static bool EnableDiscordWebhook_Report; - public static bool BlockBanButtonTabMenu; - public static bool CheckBannedEnabled; - public static bool blockLicenseRemoved; - public static bool ShowJailMessage; - public static bool BlockSuicide; - public static bool BlockMissions; - public static bool ProximityChat; - public static bool LocalChatMute; - - // Lists - public static List CustomCommands = new List(); - - public static List Responses = new List(); - public static List ChatBlockWords = new List(); - public static List LanguageBlockWords = new List(); - public static List AdminsListPlayers = new List(); - public static List GodListPlayers = new List(); - public static List AfkPlayers = new List(); - public static List MutePlayers = new List(); - public static List LatestVotePeople = new List(); - - public static List BlockedItems = new List(); - public static List listKits = new List(); - public static List listWarps = new List(); - - // Arrays - public static string[] Announcements; - - public static string[] Jobs = { - // default values - "Citizen", - "Criminal", - "Prisoner", - "Police", - "Paramedic", - "Firefighter", - "Gangster: Red", - "Gangster: Green", - "Gangster: Blue", - "Mayor", - "DeliveryDriver", - "TaxiDriver", - "Special Forces" - }; - - // Messages - public static string MsgSayPrefix; - - public static string MsgNoPerm; - public static string MsgNoPermJob; - public static string MsgDiscord; - public static string DisabledCommand; - public static string ArgRequired; - public static string PlayerIsAFK; - public static string SelfIsMuted; - public static string NotFoundOnline; - public static string NotFoundOnlineIdOnly; - public static string AdminSearchingInv; - public static string PlayerMessage; - public static string AdminMessage; - public static string AdminChatMessage; - public static string BlockedItemMessage; - public static string MsgNoWantedAllowed; - public static string MsgNoCuffedAllowed; - - public static string infoColor, errorColor, warningColor, argColor; - - // Strings - public static string Rules; - - public static string DisabledSpawnBots; - public static string LocalVersion; - public static string MsgSayColor; - public static string AccessMoneyMenu; - public static string AccessItemMenu; - public static string AccessCWMenu; - public static string AccessSetHPMenu; - public static string AccessSetStatsMenu; - public static string CmdCommandCharacter; - - // Commands, still a few needed for easy access - public static string CmdStaffChatExecutableBy; - public static string CmdConfirm; - public static string CmdToggleChat; - public static string CmdTpaaccept; - - - public static string DiscordWebhook_Ban; - public static string DiscordWebhook_Report; - public static string WipePassword; - // Ints - public const int SaveTime = 5 * 60; - - public static int AnnounceIndex; - public static int TimeBetweenAnnounce; - public static int[] BlockedSpawnIds; - public static int DebugLevel; - public static int GodModeLevel; - public static int MessagesAllowedPerSecond; - - // Misc. - public static string _msg; - - public static string username; - public static string TimestampFormat; - public const string CensoredText = "******"; - public const string PatternTemplate = @"\b({0})(s?)\b"; - public static Dictionary playerList = new Dictionary(); - public static Dictionary Groups = new Dictionary(); - public static Dictionary CommandList = new Dictionary(); - public static Dictionary WhitelistedJobs = new Dictionary(); - public static System.Timers.Timer _Timer = new System.Timers.Timer(); - public static SvManager SvMan; - - [Obsolete("Maps can be custom now, so should be removed in future update or manually added by server owners.")] - public static Dictionary PlaceDictionary = new Dictionary - { - { new[] { "1", "PoliceStation", "Police Station" }, new Vector3(-17.0F, 0.0F, 46.0F) }, - { new[] { "2", "FireStation", "Fire Station" }, new Vector3(173.0F, 0.0F, 237.0F)}, - { new[] { "3", "Hospital", "Ambulance Station" }, new Vector3(111.0F, 0.0F, 148.0F)}, - { new[] { "4", "GunShop", "Gun Shop", "ammunition" }, new Vector3(55.0F, 0.0F, 112.0F) }, - { new[] { "5", "ElectronicsShop", "Electronics Shop" }, new Vector3(567.0F, 0.0F, -92.0F) }, - { new[] { "6", "PawnShop", "Pawn Shop" }, new Vector3(448.0F, 0.0F, -203.0F) }, - { new[] { "7", "FastFoodShop", "Fast Food Shop" }, new Vector3(645.0F, 0.0F, -168.0F) }, - { new[] { "8", "CoffeeShop", "Coffee Shop" }, new Vector3(618.0F, 0.0F, 148.0F) }, - { new[] { "9", "ClothingShop", "Clothing Shop" }, new Vector3(595.0F, 0.0F, 81.0F) }, - { new[] { "10", "GreenGang", "Green St. Fam Boss" }, new Vector3(32.0F, 0.0F, -202.0F) }, - { new[] { "11", "BlueGang", "Borgata Blue Boss" }, new Vector3(504.0F, 0.0F, 23.0F) }, - { new[] { "12", "RedGang", "Rojo Loco Boss" }, new Vector3(521.0F, 0.0F, 199.0F) }, - { new[] { "13", "10k", "Large Apartment" }, new Vector3(2.0F, 0.0F, -92.0F) }, - { new[] { "14", "5k", "Medium Apartment" }, new Vector3(519.0F, 0.0F, -125.0F) }, - { new[] { "15", "1.2k", "Small Apartment" }, new Vector3(643.0F, 0.0F, -61.0F) }, - { new[] { "16", "DeliveryJob", "Delivery Job" }, new Vector3(64.0F, 0.0F, -92.0F) }, - { new[] { "17", "TaxiJob", "Taxi Job" }, new Vector3(-232.0F, 0.0F, 87.0F) }, - { new[] { "18", "TownHall", "Town Hall", "Mayor", "MayorOffice" }, new Vector3(127.0F, 0.0F, -56.0F) }, - { new[] { "19", "Bank" }, new Vector3(447.0F, 0.0F, -23.0F) }, - { new[] { "20", "DrugDealer", "Drug Dealer" }, new Vector3(288.0F, 0.0F, -236.0F) }, - { new[] { "21", "SpecOps", "Spec Ops Job", "MilitaryBase", "Military Base" }, new Vector3(654.0F, 0.0F, 278.0F) }, - { new[] { "22", "Bomb", "BombLocation", "Bomb Location" }, new Vector3(1010.0F, 0.0F, 401.0F) } - }; - - public static string[] ReportReasons = - { - // default values - "Random Vote Kick", - "Committing suicide/Disconnecting while arrested", - "Hacks/Exploits/Cheats", - "Pretending to be an admin", - "RDM as cop", - "RDA as cop", - "Bad username", - "Bullying, Harrasing, or Discriminating someone", - "Alternative account's (alts)" - }; - - public static int[] CommonIDs = - { - // need a better way of doing this - 493970259, // Pistol Ammo - -479434394, // Handcuffs - -906852676, // Taser Ammo - -700261193, //License Boating - 1695812550, //License Drivers - 499504400, //License Gun - 607710552 //License Pilots - }; - - #region ID LIST - public static int[] IDs_Vehicles = { -0, // you don't want to use ID 0 --161239262, //Apache1 -1869282968, //Apache2 -409849358, //Apache3 --1511445516, //SmallHelo1 -1021344334, //SmallHelo2 -1273449176, //SmallHelo3 --724826434, //Boat1 -1304778500, //Boat2 -985819026, //Boat3 -1510028342, //ArmyFuel1 --1022859892, //ArmyFuel2 --1274063590, //ArmyFuel3 --1389915498, //Car1 -875479852, //Car2 -1126822842, //Car3 -1629858698, //CarPizza --1372418684, //Hatchback1 -926669886, //Hatchback2 -1077734568, //Hatchback3 --1892890957, //Pickup1 -371562249, //Pickup2 -1629661087, //Pickup3 --1852539457, //SportsCar1 -144518149, //SportsCar2 -2140806291, //SportsCar3 --1840453330, //StairTruck -800352739, //SUV1 --1229113255, //SUV2 --1044772657, //SUV3 --4797188, //Taxi -1696421938, //TowTractor --701513985, //TroopCar1 -1327951685, //TroopCar2 -941744083, //TroopCar3 -748120166, //Van1 --1247921700, //Van2 --1030158006, //Van3 - }; - - - public static int[] IDs_Items = { -0, // you don't want to use ID 0 --2081117539, //FireExtinguisher --1490613521, //FireHose -1097271049, //Bandage -2048164192, //Defibrillator -1783530721, //Morphine --479434394, //Handcuffs -1411864780, //Axe -1953054383, //BatMetal -2082248681, //Baton -1021921521, //BatWood -162623668, //BrassKnuckles -304757094, //Chainsaw --1291023120, //Cleaver --900648623, //Crowbar -1613601012, //Drill --1312754449, //FireAxe -539449839, //FryPan1 --1188165547, //FryPan2 -1800940813, //GolfClub -2109002909, //AK47 -1968059740, //Colt --1975896234, //Glock -633001730, //M4 -794733957, //Mac --1384309123, //MachineGun -1875626018, //MP5SD -554920573, //Shotgun --162370066, //Sig -1053582733, //Springfield -2015188875, //Taser -238752591, //Winchester --648442112, //Hammer --1477501700, //Hands --484090981, //Kabar -2072098604, //Knife -1670374823, //Machete -1216282502, //MetalPipe --406179965, //Plank --65303750, //PlankSpiked -807974021, //Sledgehammer --1477281543, //Spade -1529145355, //Sword -1616058966, //Wrench -869043502, //AmmoMG -493970259, //AmmoPistol --872807194, //AmmoRifle -1086364132, //AmmoShotgun -168336396, //AmmoSMG --906852676, //AmmoTaser --1108084005, //Ashtray --242327999, //Binder1 -1753681915, //Binder2 -528498541, //Binder3 --2115720498, //Binder4 --261377924, //Bloodbag -540923433, //Bomb --1098973167, //Bong1 -662065579, //Bong2 -572982516, //Bonzai -319300906, //Book1 --1979616112, //Book2 --49921018, //Book3 -1667420581, //Book4 --1429135829, //BoomBox -1932783552, //Bucket1 --365248902, //Bucket2 --1656910100, //Bucket3 -1797559058, //Calculator -1018227507, //Camera --1309120383, //Candle1 -686897467, //Candle2 -1609959853, //Candle3 -1812188878, //CDCase -313689893, //CDHolder -981834931, //Chest -2053867013, //Chiller1 --480061505, //Chiller2 --1805261015, //Chiller3 -253737406, //Cigar1 --1776883708, //Cigar2 --518924142, //Cigar3 -2138393905, //Cigar4 -2028024241, //Cigarette1 --504864757, //Cigarette2 -220874293, //Clipboard -1469219949, //Coin1 --828647977, //Coin2 --1775946983, //ComputerCaseModern --1310377196, //ComputerCaseOffice --816841057, //ComputerCaseOld --1979328202, //ComputerDisplayModern -846906178, //ComputerDisplayOffice1 --1418489096, //ComputerDisplayOffice2 -708496214, //ComputerDisplayOld --237671921, //ComputerKeyboardModern --703241726, //ComputerKeyboardOffice --78488252, //ComputerKeyboardOld -532683176, //ComputerMouseModern --1179427236, //ComputerMouseOld --366810752, //Beer1 -1932245050, //Beer2 -70027436, //Beer3 -1202587699, //CoffeeCup1 --559457911, //CoffeeCup2 --1449105121, //CoffeeCup3 -935656636, //CoffeeCup4 --82690173, //CoffeeCupSmall --1953356567, //CupWater -1734556914, //EnergyCan1 --26579640, //EnergyCan2 --1495334556, //MilkBottle1 -1071010014, //MilkBottle2 -1414592914, //MilkCarton1 --849762264, //MilkCarton2 -312215426, //PaperBottle1 --1953147336, //PaperBottle2 --755725543, //PlasticCoffeeCup1 -1274927779, //PlasticCoffeeCup2 --1638525914, //SodaCan1 -123684252, //SodaCan2 -1884845322, //SodaCan3 -707466586, //SoftDrinkLarge1 --1289599776, //SoftDrinkLarge2 -1736080705, //SoftDrinkSmall -1877954167, //WaterBottle1 --152690739, //WaterBottle2 -19015101, //Wine1 --1741982713, //Wine2 --282311535, //Wine3 --846875713, //Cocaine --1617712860, //Heroin -236716975, //Meth -1314879085, //Moonshine -1809308527, //Weed --273508955, //Apple1 -1992016927, //Apple2 -1279649806, //AppleBig1 --716392012, //AppleBig2 --1572107998, //AppleBig3 -1009720449, //AppleBig4 -310612836, //AppleHalf1 --1953840418, //AppleHalf2 -1702175260, //Bacon -69690105, //Banana -1148264960, //BananaBunch1 --579308614, //BananaBunch2 -971070930, //BananaSmall -295609557, //BigMac --577045850, //BlueberryCream -375734610, //BunBottom --1068735117, //BunTop --397451461, //Burger --1489105393, //BurgerMeal -1793713626, //BurgerWrapped --2039755664, //Burrito -1463680763, //Cake1 --835408063, //Cake2 --1187799081, //Cake3 -399745542, //CakeSliceChocolate -1599774388, //CakeSliceVanilla1 --967586034, //CakeSliceVanilla2 --1089302024, //Carrot -407176456, //CarrotSliced --1245471453, //CarrotSmall --362654475, //Cheese -923427815, //Cheesecake -1201374976, //Chicken -1585611432, //ChickenLeg -1963643076, //ChickenLegSmall --1598837947, //ChickenMeal -74472777, //ChocolateBar1 --1653011213, //ChocolateBar2 --360825755, //ChocolateBar3 --897720728, //CinnamonRoll --1924350128, //Cookie --420017340, //CookieBig1 -2147375870, //CookieBig2 -1205979388, //Corn1 --555181754, //Corn2 --1321228377, //CreamRoll1 -674690589, //CreamRoll2 -1941924400, //CreamSlice --392093828, //CreamTube --1617094551, //Croissant --162406301, //Cucumber1 -1868083673, //Cucumber2 --1505527222, //CucumberSliced -664587976, //Cupcake1 --1097490574, //Cupcake2 --913133596, //Cupcake3 --649681443, //CupcakeSmall1 -1078981735, //CupcakeSmall2 -927515889, //CupcakeSmall3 --1389912314, //Donut1 -875482812, //Donut2 -1126825514, //Donut3 --582128759, //Donut4 --302939084, //DonutBig1 -1962464654, //DonutBig2 -1887084450, //Egg --34417183, //Fish1 -1694205019, //Fish2 -1176993064, //Fries -1775022893, //Gerkin --1928640708, //HamLeg --338274182, //HotDog --209488711, //IceBlock1 -1787438339, //IceBlock2 -495785365, //IceBlock3 --580117133, //IceCream1 -1147489481, //IceCream2 --1773123705, //IceCreamCone1 -257496637, //IceCreamCone2 -2019436203, //IceCreamCone3 -242189893, //IceCreamSundae -460359885, //Kiwi1 --2105943689, //Kiwi2 -1167664423, //KiwiSliced -404542308, //Leak --1883035562, //Lettuce -113691451, //Muffin1 --1613784447, //Muffin2 --389502441, //Muffin3 -516242109, //Mushroom --1363098368, //Mushrooms --938380499, //Onion -443135054, //Orange --587460087, //OrangeBig1 -1173701555, //OrangeBig2 --415825014, //Pancakes -1289297238, //Patty --150239810, //Pear1 -1845679108, //Pear2 -419816594, //Pear3 --467943479, //Pie1 -2098392691, //Pie2 -169205477, //Pie3 --1220321196, //Pineapple -236760427, //Pizza -26382251, //PizzaThin -1674766418, //Popcorn --1719549639, //Ribs -1129488573, //Salami --61088408, //SalamiSliced -1120707446, //Sandwich1 --607784244, //Sandwich2 --243156885, //Sausage1 -1753803217, //Sausage2 --378704046, //SausageBread -1973375733, //SausageRope -390308133, //ShishKebab --1795417320, //Shrimp --1378573660, //ShrimpTray --1515157115, //Steak1 -1018812479, //Steak2 -1270802601, //Steak3 --1178999815, //SteakSmall --800722565, //Sushi1 -1229758657, //Sushi2 -1045139543, //Sushi3 --1075600813, //Taco --1906967086, //TakeawayBag -1922778948, //Toast -733496620, //Tomato --374771862, //TomatoSlice --1233064414, //TomatoSlices --1626110389, //Turkey1 -102422513, //Turkey2 -1897785191, //Turkey3 --1566807776, //Waffle -811305019, //WaterMelon1 --1454188159, //WaterMelon2 -467765943, //MedicBox1 --2098668787, //MedicBox2 -1789815627, //DeskLamp -1324844400, //Cannabis --1626616456, //Coca --1605962214, //Ephedrin --719529300, //Ethanol -1374943456, //Opium --1343270306, //FlowerVase --351400709, //Folder -613358412, //FoodBowl1 --1115272458, //FoodBowl2 --897484192, //FoodBowl3 -1860288822, //FruitBowl -1699387113, //FuelCan --2070052131, //Armchair1 -496292711, //Armchair2 -1788077041, //Armchair3 -1202142496, //ArmchairBig -1331416699, //BarCounter -464889268, //BarStool --621624305, //BedDouble1 -1140561333, //BedDouble2 -888972579, //BedDouble3 --1908616205, //BedSingle1 -389382729, //BedSingle2 -1613935327, //BedSingle3 --820845019, //Bench1 -1444657055, //Bench2 -555517705, //Bench3 -1134099175, //BunkBed1 --627987619, //BunkBed2 --1316498584, //Cabinet1 -680428242, //Cabinet2 -1602859588, //Cabinet3 --1041422361, //Cabinet4 --1226172559, //Cabinet5 -1690463105, //Chair -419929706, //Chair1 --2146512944, //Chair2 --150339770, //Chair3 -1768778469, //Chair4 -510286451, //Chair5 --2023552055, //Chair6 --261866657, //Chair7 -1624975054, //Chair8 -400299608, //Chair9 --613832092, //ChairOffice --28765381, //ChairSwivel1 -1732264577, //ChairSwivel2 --2144444209, //ChestOld -11133431, //CopyMachine --907608641, //Couch1 -1357884421, //Couch2 -669555859, //Couch3 --1182004944, //Couch4 --829736538, //Couch5 -1468164124, //Couch6 -545609866, //Couch7 --1338358501, //Couch8 --952273523, //Couch9 -91428285, //CounterWood --423007494, //Desk1 -2143304512, //Desk2 --533773879, //DeskChair -772328317, //Dresser1 --1224631609, //Dresser2 --1073305007, //Dresser3 -1583497202, //Dresser4 -694488932, //Dresser5 --1335075106, //Dresser6 -647466325, //DresserMirror1 --1080107793, //DresserMirror2 --929436551, //DresserMirror3 -203711829, //DrumKit -1472642478, //Dryer --1391042892, //FootRest1 -874450702, //FootRest2 -1152478689, //HighChair -2047009475, //Keyboard --430574708, //Lamp1 -2136777270, //Lamp2 -140219040, //Lamp3 --1774254333, //Lamp4 --516409451, //Lamp5 -2016503343, //Lamp6 --1234597859, //Oven1 -794876327, //Oven2 -1483204913, //Oven3 -541897676, //BathMat1 --1186602378, //BathMat2 --1085122469, //BooksFew -1289059060, //BooksMany --1746943216, //Calendar --1493150307, //Certificate -2142933398, //Clock --1888650310, //Corkboard --141437809, //Cushion1 -1855489333, //Cushion2 -1908819108, //Flag --244484924, //FloorMat1 -1751393662, //FloorMat2 -144897887, //FullLengthMirror -848466005, //Guitar1 --1415855633, //Guitar2 --185936085, //GuitarElectric1 -1843627665, //GuitarElectric2 -451196423, //GuitarElectric3 -1235636787, //InsectFrame1 --793836663, //InsectFrame2 --1482149089, //InsectFrame3 --1053045356, //MatRubber -2075660469, //Placemat1 --491699953, //Placemat2 --1783205479, //Placemat3 -1014361465, //PlantVaseShort -977778144, //PlantVaseTall -762453193, //PlateDryer -1763200980, //Rug1 --267313554, //Rug2 --2028589320, //Rug3 -426949467, //Rug4 -366971451, //Saxophone -1274143987, //ToiletBrush --92602784, //ToyBear -1926903954, //ToyCat --672477378, //ToyChick -1839743559, //ToyDog --1397850393, //ToyLamb -551415405, //ToyPig -1706266935, //ToyRabbit -2046762882, //ToyTurtle --1356689746, //TrashCanSmall -1520699428, //WallArt1 --1012049506, //WallArt2 --1263900408, //WallArt3 -718208171, //WallArt4 --2013623785, //WallDeco1 -519297965, //WallDeco2 -1777658683, //WallDeco3 --141525352, //WallDeco4 --2137567730, //WallDeco5 -429793204, //WallDeco6 -1855532834, //WallDeco7 --31051085, //WallDeco8 --439271429, //RoomDivider -1936595972, //SafeSmall -1114775266, //Shelf1Big -1060332178, //Shelf1Medium --1933729649, //Shelf1Small --595780254, //Shelf1Thin -288187477, //Shelf1Tiny -1355264268, //Shelf2Big -249264143, //Shelf2Medium -170512929, //Shelf2Small --1679988814, //Shelf2Thin -1452088965, //Shelf2Tiny --1692189096, //ShelfMetal -2118980676, //ShelfOffice1 --414956034, //ShelfOffice2 --1874627224, //ShelfOffice3 -237494475, //ShelfOffice4 --1079661818, //ShopShelf1 -648870588, //ShopShelf2 --2037103436, //ShopTall --305205626, //Showcase --562139751, //CabinetFiling --51935546, //CabinetFlat -693498836, //Cabinets --667273670, //Case -1591617113, //ClockGrandfather --129617024, //CoffeeMachine -446585989, //Cupboards1 --2087252673, //Cupboards2 --191873623, //Cupboards3 --180008769, //Fridge --1930958485, //RecordPlayer --1367046112, //RecordShelf1 -932043162, //RecordShelf2 -1561328110, //RubbishBin1 --1006196652, //RubbishBin2 --1147890278, //SoundMonitor2 --1451178543, //Stereo -1009707106, //TrashBinHome -874269822, //WallShelf1 --1391125052, //WallShelf2 --615675499, //SimpleRecycle --1330575044, //SimpleTrash -580764704, //SoundMonitor1 --1205427253, //Stool -456730539, //Table1 --2110753263, //Table2 --180926841, //Table3 -1800655652, //Table4 -475325362, //Table5 -1416725174, //TableCoffee -499900372, //TableOffice1 --2067624338, //TableOffice2 --205144328, //TableOffice3 -1839278939, //TableOffice4 -447093709, //TableOffice5 -583490363, //TableShop1 --1144124799, //TableShop2 -14893190, //TableSmall1 --1712713412, //TableSmall2 --286449238, //TableSmall3 -1888072713, //TableSmall4 -126780575, //TableSmall5 --1635265243, //TableSmall6 --377428557, //TableSmall7 -2034235426, //TableSmall8 -781101585, //WallExtinguisher --424034282, //Wardrobe1 -2142278060, //Wardrobe2 --1646994167, //Washer -1546856892, //WaterCooler -1312283616, //Whiteboard --1506794359, //Game1 -1060730163, //Game2 --81513546, //GameConsole --390648404, //GamePad -1334811906, //Handbag1 --695808840, //Handbag2 --1585316818, //Handbag3 -1071999373, //Handbag4 -1222793499, //Handbag5 --773125983, //Handbag6 -119353383, //HealthPack -494261122, //Jam1 --2072214984, //Jam2 --209997138, //Jam3 -1830758157, //Jam4 -87407750, //Joystick --502195999, //Ketchup --1939907396, //KeyPrison --1127724957, //KitchenFork --567536648, //KitchenKnife -2095575396, //KitchenSpoon -1677000883, //Ladle --408071411, //Laptop --700261193, //LicenseBoating -1695812550, //LicenseDrivers -499504400, //LicenseGun -607710552, //LicensePilots --1092231192, //Lockpick --1252471357, //Longboard1 -743545977, //Longboard2 --896858339, //Magazines1 -1401050791, //Magazines2 -451290069, //Microwave --328781560, //MissileBig --2080560987, //MissileSmall -1981693152, //Money -1108257615, //Mugshot --1481382589, //Mustard -1822567310, //Necklace1 --173311436, //Necklace2 -1241849122, //NecklaceDisplay1 --754168680, //NecklaceDisplay2 --1542751218, //NecklaceDisplay3 -980412845, //NecklaceDisplay4 -1298716987, //NecklaceDisplay5 --731805567, //NecklaceDisplay6 -1142121509, //Newspaper -311999004, //Notepad --1881452782, //Paper --109265115, //PaperTray -561849375, //Pen --1915921987, //Pencil --1945929627, //PhoneOffice --1899151937, //PictureFrame -1285549208, //Pills1 --711541470, //Pills2 --3861386, //PlantSmall1 -1724663244, //PlantSmall2 -298546522, //PlantSmall3 --1884299015, //PlantSmall4 -1163839965, //PlateLong --835689360, //PlateSmall --1067629520, //Plunger -1123106929, //Printer --1500569022, //Register --961292868, //RegisterDigital --1714478603, //RegisterElectronic1 -13004879, //RegisterElectronic2 --1287877920, //RingGold --1125222960, //RingSilver -398080430, //RiotShield --921321944, //Rocket -1438178225, //RolledPaper -1642696866, //Scoop --49005880, //ScotchTape -1517652904, //Screwdriver1 --1015227886, //Screwdriver2 --1266947452, //Screwdriver3 --1561514462, //CannabisSeed -1343067718, //CocaSeed --1428095884, //OpiumSeed --1380688662, //Skateboard --318449686, //SoapDish -1719938366, //SoapDispenser --709313329, //SoundSystem -521180800, //Spanner -1706792829, //Spatula -1080318452, //Speaker1 --647165874, //Speaker2 --1368770344, //Speaker3 -513670350, //SportsBag1 --2020299404, //SportsBag2 --258761246, //SportsBag3 -935534676, //Stapler --4527003, //TableLamp -1338841008, //Tablet1 --691780086, //Tablet2 --1581025636, //Tablet3 --1678397020, //Toaster --1468082443, //ToolBox1 -829917007, //ToolBox2 -1181792217, //ToolBox3 -2115192440, //Toolkit -701212054, //TV1 --1329400788, //TV2 --943340358, //TV3 -1503744281, //TV4 -782655887, //TV5 --1213255627, //TV6 -203418146, //VaseSmall --918444274, //VCR -2046665206, //WalkieTalkie1 --520818612, //WalkieTalkie2 --1745633062, //WalkieTalkie3 --33192302, //WalkingStick -1578700508, //Watches Display 1 --955228314, //Watches Display 2 -1304259192, //Weight1 --726385726, //Weight2 --1733366847, //Basketball --1572858027, //Bazooka -161824251, //Flare -895677224, //Flashbang --1520575955, //Grenade --2004367746, //Smoke --552154137, //BackpackBrown --544534799, //BackpackCombat --1201692785, //BackpackPurple -334614070, //BackpackRed --409267593, //BackwardsCapBlue --762392333, //BackwardsCapGreen --1962854266, //BackwardsCapRed -360985946, //BeardBlack -973831052, //BeardBlond --250078426, //BeardBrown --1221739260, //BlouseBlue --904946077, //BlouseNavy --1694703303, //BlouseTeal --843762116, //CapBlue -1667534522, //CapChauffeur -113858252, //CapFlat -866805455, //CapGreen -753732225, //CapPizza --1557289298, //CapPolice --913660239, //CapRacer --904992899, //CapRed --951990666, //CapSheriff --1376032294, //FaceScarfDark -667274109, //FaceScarfLight --1067924423, //GangJacketBlue -1137541042, //GangJacketGreen -1251400951, //GangJacketRed --544630730, //GlovesDark -1076848752, //GlovesFingerlessDark -288052618, //GlovesFingerlessLight --390235841, //GlovesFingerlessMedium -956220633, //GlovesFingerlessWhite --1911875617, //GlovesLight --880225031, //GlovesMedical --215745530, //GlovesMedium --1478588788, //GlovesWhite --657754262, //GoateeBlack --146523716, //GoateeBlond -1012357398, //GoateeBrown --1849094355, //HardHatDark -69246628, //HardHatLight -880705339, //HardHatMedium -973238883, //HatBoonieDark --1779484338, //HatBoonieLight --544909805, //HatFedora --52820099, //HatFire --633509750, //HatHazard --1310874884, //HelmetCombat --766353867, //HelmetRiot --622606519, //JacketBusinessBlack --798800555, //JacketBusinessPurple -1953581485, //JacketBusinessRed -2065462452, //JacketFire --1867909606, //JacketFireBlack -1992507847, //JacketHippieBlue --1526906535, //JacketHippieBrown --1795298674, //JacketHippiePurple --623640896, //JacketHipsterBlue -1998765530, //JacketHipsterOrange -1753630114, //JacketHipsterPink --313637738, //JacketRacer --1574869922, //JacketVarsityBlue --1871056151, //JacketVarsityGreen --299146069, //JacketVarsityRed -112674745, //KevlarVest --1626497894, //NullArmor -673780802, //NullBack --1638932793, //NullBody -1089711634, //NullFace -2064679354, //NullFeet -1174688158, //NullHands --501996567, //NullHead --1191209217, //NullLegs -1645391131, //PantsBlue -730598986, //PantsBrown --1793758716, //PantsBrownPatched --1888685880, //PantsChauffeur -1998080865, //PantsCombat --312606938, //PantsConstructionBlue -134344360, //PantsConstructionOrange -1296190984, //PantsConstructionRed --443982957, //PantsDoctor --1527091616, //PantsFire -2025319866, //PantsFireBlack -2044418121, //PantsGray --1777372097, //PantsGreen --107652805, //PantsLightBlue -276408694, //PantsLightBrown -1066947391, //PantsLightPurple -1775808134, //PantsMerchant -595581678, //PantsParamedic -506851744, //PantsPolice --1175302500, //PantsPrisoner -1815065665, //PantsRacer --295837114, //PantsRiot -541389606, //PantsSheriff --757862723, //PunkTopBlue -1985284270, //PunkTopRed -996118564, //PunkTopWhite -1372071833, //ShirtBusinessBlue --476209925, //ShirtBusinessPink -781576011, //ShirtBusinessYellow --1755425193, //ShirtStripedBlue --376425089, //ShirtStripedGreen -1718551758, //ShirtStripedPurple --1161119954, //ShirtTouristOrange -1300919472, //ShirtTouristPurple -1997269705, //ShirtTouristYellow --2054702454, //ShoesBlack -1629197558, //ShoesBrown -837068077, //ShoesGray --471928380, //ShoesHipster -363817674, //ShortsBlue --634433073, //ShortsBrown -1803652245, //SkirtBlue -379826162, //SkirtNavy -1179701416, //SkirtTeal -1860177600, //SlacksBlue -1965685650, //SlacksGray --2029875776, //SlacksGreen --40633710, //SneakersBlue --800938321, //SneakersTeal --1868436119, //SneakersWhite -889404594, //SneakersYellow --300071980, //SuspendersBrown -1402878369, //SuspendersGreen -129955089, //SuspendersPurple --1369391530, //SuspendersShortPurple -1946500812, //SuspendersShortRed --1797185489, //SuspendersShortYellow --1691035721, //TeeApple --1779870671, //TeeLove --37255800, //TeePizza -1234346447, //TopChauffeur -388702693, //TopCombat -1258964252, //TopConstructionBlue -102550548, //TopConstructionOrange --1498475603, //TopConstructionRed --2051395305, //TopDoctor --1689248836, //TopMerchant --444494871, //TopParamedic -2114362148, //TopPolice -1266351014, //TopPrisoner --645285295, //TopRiot -602133489, //TopSafetyVest --890140811, //TopSheriff -}; - - #endregion ID LIST - } - public class Kits_Json - { - public class Kits_Item - { - public int Id { get; set; } - public int Amount { get; set; } - } - public class Kits_RootObj - { - public Kits_RootObj() { - Items = new List(); - CurrentlyInCooldown = new Dictionary(); - } - public string Name { get; set; } - public int Delay { get; set; } - public int Price { get; set; } - public string ExecutableBy { get; set; } - public bool Disabled { get; set; } - public List Items { get; set; } - public Dictionary CurrentlyInCooldown { get; set; } - } - } - public class Warps_Json - { - public class Position - { - public float X { get; set; } - public float Y { get; set; } - public float Z { 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 Warps_RootObj - { - public Warps_RootObj() - { - CurrentlyInCooldown = new Dictionary(); - } - public string Name { get; set; } - public int Delay { get; set; } - public int Price { get; set; } - public string ExecutableBy { get; set; } - public bool Disabled { get; set; } - public Position Position { get; set; } - public Rotation Rotation { get; set; } - public Dictionary CurrentlyInCooldown { get; set; } - } - } - public class _CommandList - { - public Action RunMethod; - public List commandCmds; - public bool commandDisabled; - public string commandGroup; - public string commandName; - public bool commandWantedAllowed; - public bool commandHandcuffedAllowed; - } - - public class _PlayerList - { - public ShPlayer Shplayer { get; set; } - public CurrentMenu LastMenu; - public ShPlayer ReportedPlayer { get; set; } - public string reportedReason; - public bool chatEnabled = true; - public bool staffChatEnabled; - public bool receiveStaffChat = true; - public bool spyEnabled; - public int messagesSent; - public bool isCurrentlyAwaiting; - public ShPlayer ReplyToUser { get; set; } - public ShPlayer TpaUser { get; set; } - } - - public class _Group - { - public string Name; - public string Message; - public List Users = new List(); - } - - public enum CurrentMenu - { - Main, - Help, - Staff, - GiveMoney, - GiveItems, - ServerInfo, - Report, - AdminReport - } -} \ No newline at end of file diff --git a/source/BP-Essentials/Methods/API/DownloadAndWriteToFile.cs b/source/BP-Essentials/Methods/API/DownloadAndWriteToFile.cs deleted file mode 100644 index 69ad5f2d..00000000 --- a/source/BP-Essentials/Methods/API/DownloadAndWriteToFile.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.IO; -using System.Net; -using System.Collections; - -namespace BP_Essentials -{ - class DownloadAndWriteToFile : EssentialsChatPlugin - { - public static void Run(string fileName, string websiteLink) - { - var output = DownloadFile.Run(websiteLink); - if (output != null) - File.WriteAllText(fileName, output); - } - public static void Run(string fileName, string websiteLink, Action callback) - { - SvMan.StartCoroutine(DownloadFile.Run(websiteLink, new Action((output) => { - if (output != null) - File.WriteAllText(fileName, output); - callback?.Invoke(output != null); - }))); - } - } -} diff --git a/source/BP-Essentials/Methods/API/DownloadFile.cs b/source/BP-Essentials/Methods/API/DownloadFile.cs deleted file mode 100644 index 6664b8d3..00000000 --- a/source/BP-Essentials/Methods/API/DownloadFile.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.IO; -using System.Net; -using System.Collections; - -namespace BP_Essentials -{ - class DownloadFile : EssentialsChatPlugin - { - // Redo method(s) - - public static string Run(string DownloadLink) - { - using (WebClient client = new WebClient()) - { - Stream stream = client.OpenRead(DownloadLink); - using (StreamReader reader = new StreamReader(stream)) - return reader.ReadToEnd(); - } - } - - - public static IEnumerator Run(string link, Action callback) - { - using (var www = new WWW(link)) - { - yield return www; - if (www.error != null) - { - Debug.Log($"{SetTimeStamp.Run()}[ERROR] {link} responded with HTTP error code: {www.error}!"); - callback?.Invoke(null); - yield break; - } - callback?.Invoke(www.text); - yield break; - } - } - } -} diff --git a/source/BP-Essentials/Methods/API/FilterComments.cs b/source/BP-Essentials/Methods/API/FilterComments.cs deleted file mode 100644 index 9308ee2c..00000000 --- a/source/BP-Essentials/Methods/API/FilterComments.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.Text.RegularExpressions; -using System.IO; - -namespace BP_Essentials -{ - class FilterComments : EssentialsChatPlugin - { - - public static string Run(string path) - { - string line; - using (StreamReader file = new StreamReader(path)) - { - var builder = new StringBuilder(); - // If anyone has a Regex that removes single comments (It should not remove https:// stuff etc because that contains // too) - // And Block comments /* */ (And the multiple line block comment) - while ((line = file.ReadLine()) != null) - if (!line.Trim().StartsWith("// ", StringComparison.Ordinal)) - builder.Append(line); - file.Close(); - return Regex.Replace(builder.ToString(), @"/\*(?:(?!\*/).)*\*/", String.Empty); - } - } - } -} diff --git a/source/BP-Essentials/Methods/API/GetArgument.cs b/source/BP-Essentials/Methods/API/GetArgument.cs deleted file mode 100644 index 1370e8d9..00000000 --- a/source/BP-Essentials/Methods/API/GetArgument.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.Text.RegularExpressions; - -namespace BP_Essentials -{ - class GetArgument : EssentialsCorePlugin - { - public static string Run(int nr, bool UseRegex, bool IncludeSpaces, string message) - { - try - { - if (UseRegex) - { - var args = Regex.Matches(message, @"[\""].+?[\""]|[^ ]+") - .Cast() - .Select(m => m.Value) - .ToList(); - return args[nr]; - } - else - { - if (IncludeSpaces) - { - message = message.Trim(); - if (nr == 0) - return message; - if (!message.Contains(" ")) - return ""; - var args = message.Split(' '); - if (nr > args.Length) - return ""; - return message.Substring(message.IndexOf(args[nr])).TrimEnd(); - } - else - { - var args = message.Trim().Split(' '); - if (nr > args.Length - 1) - return ""; - return args[nr]; - } - } - } - catch (Exception) - { - return ""; - } - } - } -} diff --git a/source/BP-Essentials/Methods/API/GetPlaceHolders.cs b/source/BP-Essentials/Methods/API/GetPlaceHolders.cs deleted file mode 100644 index 63658385..00000000 --- a/source/BP-Essentials/Methods/API/GetPlaceHolders.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; - -namespace BP_Essentials -{ - class GetPlaceHolders : EssentialsCorePlugin - { - public static string Run(string str, SvPlayer player) - { - try - { - var shPlayer = player.player; - var src = DateTime.Now; - var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); - var placeHolderText = str; - var minutes = hm.ToString("mm"); - var seconds = hm.ToString("ss"); - - if (str.Contains("{YYYY}")) - placeHolderText = placeHolderText.Replace("{YYYY}", hm.ToString("yyyy")); - if (str.Contains("{DD}")) - placeHolderText = placeHolderText.Replace("{DD}", hm.ToString("dd")); - if (str.Contains("{DDDD}")) - placeHolderText = placeHolderText.Replace("{DDDD}", hm.ToString("dddd")); - if (str.Contains("{MMMM}")) - placeHolderText = placeHolderText.Replace("{MMMM}", hm.ToString("MMMM")); - if (str.Contains("{MM}")) - placeHolderText = placeHolderText.Replace("{MM}", hm.ToString("MM")); - if (str.Contains("{H}")) - placeHolderText = placeHolderText.Replace("{H}", hm.ToString("HH")); - if (str.Contains("{h}")) - placeHolderText = placeHolderText.Replace("{h}", hm.ToString("hh")); - if (str.Contains("{M}") || str.Contains("{m}")) - placeHolderText = placeHolderText.Replace("{M}", minutes); - if (str.Contains("{S}") || str.Contains("{s}")) - placeHolderText = placeHolderText.Replace("{S}", seconds); - if (str.Contains("{T}")) - placeHolderText = placeHolderText.Replace("{T}", hm.ToString("tt")); - if (str.ToLower().Contains("{username}")) - placeHolderText = placeHolderText.Replace("{username}", player.playerData.username); - if (str.ToLower().Contains("{id}")) - placeHolderText = placeHolderText.Replace("{id}", $"{shPlayer.ID}"); - if (str.ToLower().Contains("{jobname}")) - placeHolderText = placeHolderText.Replace("{jobname}", Jobs[shPlayer.job.jobIndex]); - if (str.ToLower().Contains("{jobindex}")) - placeHolderText = placeHolderText.Replace("{jobindex}", $"{shPlayer.job.jobIndex}"); - - if (str.ToLower().Contains("{discordlink}")) - placeHolderText = placeHolderText.Replace("{discordlink}", MsgDiscord); - if (str.ToLower().Contains("{infocolor}")) - placeHolderText = placeHolderText.Replace("{infocolor}", infoColor); - if (str.ToLower().Contains("{warningcolor}")) - placeHolderText = placeHolderText.Replace("{warningcolor}", warningColor); - if (str.ToLower().Contains("{errorcolor}")) - placeHolderText = placeHolderText.Replace("{errorcolor}", errorColor); - if (str.ToLower().Contains("{argcolor}")) - placeHolderText = placeHolderText.Replace("{argcolor}", argColor); - return placeHolderText; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - return null; - } - } - } -} diff --git a/source/BP-Essentials/Methods/API/GetShByStr.cs b/source/BP-Essentials/Methods/API/GetShByStr.cs deleted file mode 100644 index 2a726256..00000000 --- a/source/BP-Essentials/Methods/API/GetShByStr.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; - -namespace BP_Essentials -{ - class GetShByStr : EssentialsCorePlugin - { - public static ShPlayer Run(string player, bool idOnly = false) - { - try - { - foreach (var shPlayer in SvMan.players.Values) - if ((shPlayer.ID.ToString() == player || shPlayer.username == player) && !idOnly || shPlayer.ID.ToString() == player && idOnly) - return shPlayer; - return null; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - return null; - } - } - } -} diff --git a/source/BP-Essentials/Methods/API/HasPermission.cs b/source/BP-Essentials/Methods/API/HasPermission.cs deleted file mode 100644 index d0b87efa..00000000 --- a/source/BP-Essentials/Methods/API/HasPermission.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; - -namespace BP_Essentials -{ - class HasPermission : EssentialsChatPlugin - { - public static bool Run(SvPlayer player, string ExeBy, bool ShowNoPermMessage = false, byte? jobIndex = null) - { - if (AdminsListPlayers.Contains(player.playerData.username) && ExeBy.Contains("admins") || ExeBy.Contains("everyone")) - return true; - string[] GroupsSplit = ExeBy.Split(','); - foreach (string name in GroupsSplit) - if (jobIndex != null) - { - if (Groups.Any(curr => $"group:{curr.Value.Name}".Equals(name.Trim()) && curr.Value.Users.Contains(player.playerData.username)) || name == $"jobindex:{jobIndex}") - return true; - } - else - if (Groups.Any(curr => $"group:{curr.Value.Name}".Equals(name.Trim()) && curr.Value.Users.Contains(player.playerData.username))) - return true; - if (ShowNoPermMessage) - player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{MsgNoPerm}"); - return false; - } - } -} diff --git a/source/BP-Essentials/Methods/API/SendDiscordMessage.cs b/source/BP-Essentials/Methods/API/SendDiscordMessage.cs deleted file mode 100644 index 7ee19433..00000000 --- a/source/BP-Essentials/Methods/API/SendDiscordMessage.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.IO; -using System.Threading.Tasks; -using System.Net; -using System.Collections; -using System.Threading; -using Newtonsoft.Json; - -namespace BP_Essentials -{ - class SendDiscordMessage : MonoBehaviour - { - public static void Run(string json, string link, bool enabled) - { - try - { - if (!enabled) - return; - if (DebugLevel >= 2) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Creating POST request to {link}"); - var formData = Encoding.UTF8.GetBytes(json); - var www = new WWW(link, formData); - SvMan.StartCoroutine(WaitForRequest(www)); - if (DebugLevel >= 2) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Post request sent!"); - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - public static void ReportMessage(string username, string issuer, string reason) - { - var fUsername = JsonConvert.ToString(username); - var fIssuer = JsonConvert.ToString(issuer); - var fReason = JsonConvert.ToString(reason); - Run(@"{ ""username"":""BP-Essentials Report Log"", ""avatar_url"":""https://i.imgur.com/ckuPXOH.jpg"", ""embeds"":[ {""title"":""New report AutoLogger"",""description"":""\u200B"",""color"":3837400,""timestamp"":""2018-06-23T12:26:09.635Z"",""footer"":{""text"":""BP-Essentials""},""fields"":[{""name"":""Username"",""value"":" + fUsername + @"},{""name"":""Issuer"",""value"":" + fIssuer + @"},{""name"":""Reason"",""value"":" + fReason + @"},{""name"":""Date (UTC)"",""value"":""" + DateTime.UtcNow + @"""}]}] }", DiscordWebhook_Report, EnableDiscordWebhook_Report); - } - public static void BanMessage(string username, string issuer) - { - BanMessage(username, issuer, "No reason provided. (Used tab menu)"); - } - public static void BanMessage(string username, string issuer, string banReason) - { - var fUsername = JsonConvert.ToString(username); - var fIssuer = JsonConvert.ToString(issuer); - var fReason = JsonConvert.ToString(banReason); - Run(@"{ ""username"":""BP-Essentials Ban Log"", ""avatar_url"":""https://i.imgur.com/ckuPXOH.jpg"", ""embeds"":[ {""title"":""New ban AutoLogger"",""description"":""\u200B"",""color"":3837400,""timestamp"":""2018-06-23T12:26:09.635Z"",""footer"":{""text"":""BP-Essentials""},""fields"":[{""name"":""Username"",""value"":" + fUsername + @"},{""name"":""Issuer"",""value"":" + fIssuer + @"},{""name"":""Reason"",""value"":" + fReason + @"},{""name"":""Date (UTC)"",""value"":""" + DateTime.UtcNow + @"""}]}] }", DiscordWebhook_Ban, EnableDiscordWebhook_Ban); - } - static IEnumerator WaitForRequest(WWW www) - { - yield return www; - if (DebugLevel >= 2) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Post request response received: {(www.error ?? $"[HTTP-ERROR] {www.text}")}"); - www.Dispose(); - } - } -} diff --git a/source/BP-Essentials/Methods/Check/CheckAltAcc.cs b/source/BP-Essentials/Methods/Check/CheckAltAcc.cs deleted file mode 100644 index b663f227..00000000 --- a/source/BP-Essentials/Methods/Check/CheckAltAcc.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.IO; -using System.Threading; - -namespace BP_Essentials -{ - class CheckAltAcc - { - public static void Run(SvPlayer player) - { - if (CheckAlt) - { - try - { - Thread.Sleep(3000); - if (!string.IsNullOrEmpty(player.playerData.username.Trim())) - if (!player.player.admin && File.ReadAllText(IpListFile).Contains(player.connection.IP)) - { - Debug.Log($"{SetTimeStamp.Run()}[WARNING] {player.player.username} Joined with a possible alt! IP: {player.connection.IP}"); - player.svManager.AddBanned(player.player); - player.svManager.Disconnect(player.connection); - } - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - } - } -} diff --git a/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs b/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs index 32e9be26..1f9d38b2 100644 --- a/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs +++ b/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs @@ -19,6 +19,7 @@ public static void Run() // 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); diff --git a/source/BP-Essentials/Methods/FileHandler/Kits.cs b/source/BP-Essentials/Methods/FileHandler/Kits.cs deleted file mode 100644 index e3959fe6..00000000 --- a/source/BP-Essentials/Methods/FileHandler/Kits.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; - -namespace BP_Essentials -{ - public class Kits - { - public static void LoadAllKits(bool firstLoad = false) - { - if (DebugLevel >= 1) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Loading kits.."); - listKits.Clear(); - foreach (string file in Directory.EnumerateFiles(KitDirectory, "*.json", SearchOption.AllDirectories)) - { - var obj = JsonConvert.DeserializeObject(FilterComments.Run(file)); - if (listKits.Any(x => x.Name == obj.Name)) - { - Debug.Log($"{SetTimeStamp.Run()}[ERROR] Cannot add kit {obj.Name} because it already exists in the list!"); - continue; - } - listKits.Add(obj); - if (firstLoad && obj.CurrentlyInCooldown != null) - foreach (var player in obj.CurrentlyInCooldown.ToList()) - SvMan.StartCoroutine(KitCooldown(player.Key, obj, player.Value)); - if (DebugLevel >= 1) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Loaded kit: {obj.Name}"); - } - if (DebugLevel >= 1) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Loaded in {listKits.Count} kit(s)."); - } - public static void CreateKit(SvPlayer player, string name, int delay, int price, string fileName) - { - var obj = new Kits_Json.Kits_RootObj - { - Name = name, - Delay = delay, - Price = price < 0 ? 0 : price, - Disabled = false, - ExecutableBy = "everyone" - }; - foreach (var item in player.player.myItems.Values) - obj.Items.Add(new Kits_Json.Kits_Item { Amount = item.count, Id = item.item.index }); - File.WriteAllText(fileName, JsonConvert.SerializeObject(obj, Formatting.Indented)); - listKits.Add(obj); - } - public static void DeleteKit(SvPlayer player, string fileName, string name) - { - File.Delete(fileName); - listKits = listKits.Where(x => x.Name != name).ToList(); - } - public static void StartKitTimer() - { - try - { - _Timer.Elapsed += (sender, e) => { - foreach (var kit in listKits) - { - var path = Path.Combine(KitDirectory, $"{kit.Name}.json"); - if (File.Exists(path)) - File.WriteAllText(path, JsonConvert.SerializeObject(kit, Formatting.Indented)); - } - }; - _Timer.Interval = 30 * 60 * 1000; // Save every 30 minutes - _Timer.Enabled = true; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - public static IEnumerator KitCooldown(string username, Kits_Json.Kits_RootObj kit, int PassedTime = 0) - { - if (!kit.CurrentlyInCooldown.ContainsKey(username)) - kit.CurrentlyInCooldown.Add(username, kit.Delay); - var path = Path.Combine(KitDirectory, $"{kit.Name}.json"); - File.WriteAllText(path, JsonConvert.SerializeObject(kit, Formatting.Indented)); - var passedTime = PassedTime; - while (passedTime <= kit.Delay) - { - ++passedTime; - --kit.CurrentlyInCooldown[username]; - yield return new WaitForSeconds(1); - } - if (kit.CurrentlyInCooldown.ContainsKey(username)) - kit.CurrentlyInCooldown.Remove(username); - if (File.Exists(path)) - File.WriteAllText(path, JsonConvert.SerializeObject(kit, Formatting.Indented)); - } - } -} diff --git a/source/BP-Essentials/Methods/FileHandler/ReadFile.cs b/source/BP-Essentials/Methods/FileHandler/ReadFile.cs index 1cc3dfa6..9ba7ca1d 100644 --- a/source/BP-Essentials/Methods/FileHandler/ReadFile.cs +++ b/source/BP-Essentials/Methods/FileHandler/ReadFile.cs @@ -180,7 +180,7 @@ public static void Run(string fileName) switch (fileName) { case SettingsFile: - __RootObject m = JsonConvert.DeserializeObject<__RootObject>(FilterComments.Run(SettingsFile)); + var m = JsonConvert.DeserializeObject<__RootObject>(FilterComments.Run(SettingsFile)); LocalVersion = m.General.Version; diff --git a/source/BP-Essentials/Methods/FileHandler/Warps.cs b/source/BP-Essentials/Methods/FileHandler/Warps.cs deleted file mode 100644 index 1aff3e76..00000000 --- a/source/BP-Essentials/Methods/FileHandler/Warps.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; - -namespace BP_Essentials -{ - // Almost a 1 : 1 copy of the Kits class.. oh well - public class Warps - { - public static void LoadAllWarps(bool firstLoad = false) - { - if (DebugLevel >= 1) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Loading warps.."); - listWarps.Clear(); - foreach (string file in Directory.EnumerateFiles(WarpDirectory, "*.json", SearchOption.AllDirectories)) - { - var obj = JsonConvert.DeserializeObject(FilterComments.Run(file)); - if (listWarps.Any(x => x.Name == obj.Name)) - { - Debug.Log($"{SetTimeStamp.Run()}[ERROR] Cannot add warp {obj.Name} because it already exists in the list!"); - continue; - } - listWarps.Add(obj); - if (firstLoad && obj.CurrentlyInCooldown != null) - foreach (var player in obj.CurrentlyInCooldown.ToList()) - SvMan.StartCoroutine(WarpCooldown(player.Key, obj, player.Value)); - if (DebugLevel >= 1) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Loaded warp: {obj.Name}"); - } - if (DebugLevel >= 1) - Debug.Log($"{SetTimeStamp.Run()}[INFO] Loaded in {listWarps.Count} warp(s)."); - } - public static void CreateWarp(SvPlayer player, string name, int delay, int price, string fileName) - { - var obj = new Warps_Json.Warps_RootObj - { - Name = name, - Delay = delay, - Price = price < 0 ? 0 : price, - Disabled = false, - ExecutableBy = "everyone", - Position = new Warps_Json.Position { X = player.player.GetPosition().x, Y = player.player.GetPosition().y, Z = player.player.GetPosition().z}, - Rotation = new Warps_Json.Rotation { X = player.player.GetRotation().x, Y = player.player.GetRotation().y, Z = player.player.GetRotation().z, W = player.player.GetRotation().w} - }; - File.WriteAllText(fileName, JsonConvert.SerializeObject(obj, Formatting.Indented)); - listWarps.Add(obj); - } - public static void DeleteWarp(SvPlayer player, string fileName, string name) - { - File.Delete(fileName); - listWarps = listWarps.Where(x => x.Name != name).ToList(); - } - public static void StartWarpTimer() - { - try - { - _Timer.Elapsed += (sender, e) => { - foreach (var warp in listWarps) - { - var path = Path.Combine(KitDirectory, $"{warp.Name}.json"); - if (File.Exists(path)) - File.WriteAllText(path, JsonConvert.SerializeObject(warp, Formatting.Indented)); - } - }; - _Timer.Interval = 30 * 60 * 1000; // Save every 30 minutes - _Timer.Enabled = true; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - public static IEnumerator WarpCooldown(string username, Warps_Json.Warps_RootObj warp, int PassedTime = 0) - { - if (!warp.CurrentlyInCooldown.ContainsKey(username)) - warp.CurrentlyInCooldown.Add(username, warp.Delay); - var path = Path.Combine(WarpDirectory, $"{warp.Name}.json"); - File.WriteAllText(path, JsonConvert.SerializeObject(warp, Formatting.Indented)); - var passedTime = PassedTime; - while (passedTime <= warp.Delay) - { - ++passedTime; - --warp.CurrentlyInCooldown[username]; - yield return new WaitForSeconds(1); - } - if (warp.CurrentlyInCooldown.ContainsKey(username)) - warp.CurrentlyInCooldown.Remove(username); - if (File.Exists(path)) - File.WriteAllText(path, JsonConvert.SerializeObject(warp, Formatting.Indented)); - } - } -} diff --git a/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs b/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs index 783a8372..01e586ec 100644 --- a/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs +++ b/source/BP-Essentials/Methods/GameMethods/CleanupApartment.cs @@ -9,12 +9,14 @@ namespace BP_Essentials { - class CleanupApartment : Variables + class CleanupApartment { public static void Run(ShPlayer shPlayer) { try { + 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/GetExtraCount.cs b/source/BP-Essentials/Methods/GameMethods/GetExtraCount.cs index 1f6d3e78..a838e211 100644 --- a/source/BP-Essentials/Methods/GameMethods/GetExtraCount.cs +++ b/source/BP-Essentials/Methods/GameMethods/GetExtraCount.cs @@ -9,7 +9,7 @@ namespace BP_Essentials { - class GetExtraCount : Variables + class GetExtraCount { public static int Run(ShPlayer player, InventoryItem myItem) { diff --git a/source/BP-Essentials/Methods/GameMethods/SetJob.cs b/source/BP-Essentials/Methods/GameMethods/SetJob.cs index 76d14b2a..45144e76 100644 --- a/source/BP-Essentials/Methods/GameMethods/SetJob.cs +++ b/source/BP-Essentials/Methods/GameMethods/SetJob.cs @@ -9,12 +9,14 @@ namespace BP_Essentials { - class SetJob : Variables + class SetJob { public static void Run(ShPlayer shPlayer, byte jobIndex, bool AddItems, bool CollectCost) { try { + 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 3539f938..335ea407 100644 --- a/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs +++ b/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs @@ -9,12 +9,14 @@ namespace BP_Essentials { - class UnRestrain : Variables + class UnRestrain { public static void Run(SvPlayer player) { try { + 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/FillPlaceholders.cs b/source/BP-Essentials/Methods/Utils/FillPlaceholders.cs deleted file mode 100644 index 239f3675..00000000 --- a/source/BP-Essentials/Methods/Utils/FillPlaceholders.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.IO; -using System.Threading; -using System.Text.RegularExpressions; - -namespace BP_Essentials -{ - class FillPlaceholders - { - public static string Run(ShPlayer shplayer, string message, string playerMessage) - { - try - { - return message.Replace("{username}", new Regex("(<)").Replace(shplayer.username, "<")) - .Replace("{id}", $"{shplayer.ID}") - .Replace("{jobindex}", $"{shplayer.job.jobIndex}") - .Replace("{jobname}", $"{Jobs[shplayer.job.jobIndex]}") - .Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(playerMessage), "<")); - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - return null; - } - } -} diff --git a/source/BP-Essentials/Methods/Utils/FunctionMenu.cs b/source/BP-Essentials/Methods/Utils/FunctionMenu.cs index c5f46129..4e6273fb 100644 --- a/source/BP-Essentials/Methods/Utils/FunctionMenu.cs +++ b/source/BP-Essentials/Methods/Utils/FunctionMenu.cs @@ -51,6 +51,11 @@ public static CurrentMenu ResetWindow(SvPlayer player) #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; diff --git a/source/BP-Essentials/Methods/Utils/GetPlaceHolders.cs b/source/BP-Essentials/Methods/Utils/GetPlaceHolders.cs deleted file mode 100644 index 63658385..00000000 --- a/source/BP-Essentials/Methods/Utils/GetPlaceHolders.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; - -namespace BP_Essentials -{ - class GetPlaceHolders : EssentialsCorePlugin - { - public static string Run(string str, SvPlayer player) - { - try - { - var shPlayer = player.player; - var src = DateTime.Now; - var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); - var placeHolderText = str; - var minutes = hm.ToString("mm"); - var seconds = hm.ToString("ss"); - - if (str.Contains("{YYYY}")) - placeHolderText = placeHolderText.Replace("{YYYY}", hm.ToString("yyyy")); - if (str.Contains("{DD}")) - placeHolderText = placeHolderText.Replace("{DD}", hm.ToString("dd")); - if (str.Contains("{DDDD}")) - placeHolderText = placeHolderText.Replace("{DDDD}", hm.ToString("dddd")); - if (str.Contains("{MMMM}")) - placeHolderText = placeHolderText.Replace("{MMMM}", hm.ToString("MMMM")); - if (str.Contains("{MM}")) - placeHolderText = placeHolderText.Replace("{MM}", hm.ToString("MM")); - if (str.Contains("{H}")) - placeHolderText = placeHolderText.Replace("{H}", hm.ToString("HH")); - if (str.Contains("{h}")) - placeHolderText = placeHolderText.Replace("{h}", hm.ToString("hh")); - if (str.Contains("{M}") || str.Contains("{m}")) - placeHolderText = placeHolderText.Replace("{M}", minutes); - if (str.Contains("{S}") || str.Contains("{s}")) - placeHolderText = placeHolderText.Replace("{S}", seconds); - if (str.Contains("{T}")) - placeHolderText = placeHolderText.Replace("{T}", hm.ToString("tt")); - if (str.ToLower().Contains("{username}")) - placeHolderText = placeHolderText.Replace("{username}", player.playerData.username); - if (str.ToLower().Contains("{id}")) - placeHolderText = placeHolderText.Replace("{id}", $"{shPlayer.ID}"); - if (str.ToLower().Contains("{jobname}")) - placeHolderText = placeHolderText.Replace("{jobname}", Jobs[shPlayer.job.jobIndex]); - if (str.ToLower().Contains("{jobindex}")) - placeHolderText = placeHolderText.Replace("{jobindex}", $"{shPlayer.job.jobIndex}"); - - if (str.ToLower().Contains("{discordlink}")) - placeHolderText = placeHolderText.Replace("{discordlink}", MsgDiscord); - if (str.ToLower().Contains("{infocolor}")) - placeHolderText = placeHolderText.Replace("{infocolor}", infoColor); - if (str.ToLower().Contains("{warningcolor}")) - placeHolderText = placeHolderText.Replace("{warningcolor}", warningColor); - if (str.ToLower().Contains("{errorcolor}")) - placeHolderText = placeHolderText.Replace("{errorcolor}", errorColor); - if (str.ToLower().Contains("{argcolor}")) - placeHolderText = placeHolderText.Replace("{argcolor}", argColor); - return placeHolderText; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - return null; - } - } - } -} diff --git a/source/BP-Essentials/Methods/Utils/SetTimeStamp.cs b/source/BP-Essentials/Methods/Utils/SetTimeStamp.cs deleted file mode 100644 index 7ac29cee..00000000 --- a/source/BP-Essentials/Methods/Utils/SetTimeStamp.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; - -namespace BP_Essentials -{ - class SetTimeStamp - { - public static string Run() - { - try - { - var src = DateTime.Now; - var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); - var placeHolderText = TimestampFormat; - var minutes = hm.ToString("mm"); - var seconds = hm.ToString("ss"); - - if (TimestampFormat.Contains("{YYYY}")) - placeHolderText = placeHolderText.Replace("{YYYY}", hm.ToString("yyyy")); - if (TimestampFormat.Contains("{DD}")) - placeHolderText = placeHolderText.Replace("{DD}", hm.ToString("dd")); - if (TimestampFormat.Contains("{DDDD}")) - placeHolderText = placeHolderText.Replace("{DDDD}", hm.ToString("dddd")); - if (TimestampFormat.Contains("{MMMM}")) - placeHolderText = placeHolderText.Replace("{MMMM}", hm.ToString("MMMM")); - if (TimestampFormat.Contains("{MM}")) - placeHolderText = placeHolderText.Replace("{MM}", hm.ToString("MM")); - if (TimestampFormat.Contains("{H}")) - placeHolderText = placeHolderText.Replace("{H}", hm.ToString("HH")); - if (TimestampFormat.Contains("{h}")) - placeHolderText = placeHolderText.Replace("{h}", hm.ToString("hh")); - if (TimestampFormat.Contains("{M}") || TimestampFormat.Contains("{m}")) - placeHolderText = placeHolderText.Replace("{M}", minutes); - if (TimestampFormat.Contains("{S}") || TimestampFormat.Contains("{s}")) - placeHolderText = placeHolderText.Replace("{S}", seconds.ToString()); - if (TimestampFormat.Contains("{T}")) - placeHolderText = placeHolderText.Replace("{T}", hm.ToString("t")); - placeHolderText = placeHolderText + " "; - return placeHolderText; - } - catch (Exception) - { - return "[Failed] "; - } - } - } -} diff --git a/source/BP-Essentials/Methods/misc/ErrorLogging.cs b/source/BP-Essentials/Methods/misc/ErrorLogging.cs deleted file mode 100644 index 29647546..00000000 --- a/source/BP-Essentials/Methods/misc/ErrorLogging.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.IO; -using System.Threading; -using System.Reflection; - -namespace BP_Essentials -{ - class ErrorLogging : EssentialsChatPlugin - { - public static void Run(Exception ex) - { - try - { - Thread.Sleep(20); - System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(ex, true); - var frame = st.GetFrame(st.FrameCount - 1); - Debug.Log("-------------------------------------------------------------------------------------------------------------------------------------------------------------"); - Debug.Log("[ERROR] - Exception!"); - Debug.Log(" "); - Debug.Log("--------------------------------------------------------------------"); - Debug.Log("Exception Frame: " + frame); - Debug.Log("Exception Method: " + frame.GetMethod()); - Debug.Log("Exception Line number: " + frame.GetFileLineNumber()); - Debug.Log("Exception Column number: " + frame.GetFileColumnNumber()); - Debug.Log("Exception File name: " + frame.GetFileName()); - Debug.Log("Exception Class name: " + ex.TargetSite.ReflectedType.Name); - Debug.Log("Exception Namespace: " + ex.TargetSite.ReflectedType.Namespace); - Debug.Log("--------------------------------------------------------------------"); - Debug.Log(" "); - Debug.Log(" "); - Debug.Log("[ERROR] Essentials - Error message: " + ex); - Debug.Log(" "); - Debug.Log(" "); - Debug.Log("[ERROR] Essentials - An exception occured, Check the Exceptions file for more info."); - Debug.Log("[ERROR] Essentials - Or check the error above 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("------------------------------------------------------------------------------------------------------------------------------------------------------------"); - - string content = - $"\nException START ---------------- Date: {DateTime.Now}\n" + - $"Error Message: {ex.Message}\n" + - $"Full error: {ex}\n" + - $"Exception Class name: {ex.TargetSite.ReflectedType.Name}\n" + - $"Exception Method: {frame.GetMethod()}\n" + - $"Exception STOP ---------------- Date: {DateTime.Now}"; - File.AppendAllText(ExceptionFile, content); - } - catch (Exception exx) - { - Debug.Log(" "); - Debug.Log("[ERROR] Essentials - Error inside ErrorLogging. " + exx); - Debug.Log(" "); - } - } - } -} diff --git a/source/BP-Essentials/Methods/misc/LogMessage.cs b/source/BP-Essentials/Methods/misc/LogMessage.cs deleted file mode 100644 index 7b4d806a..00000000 --- a/source/BP-Essentials/Methods/misc/LogMessage.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.IO; -using System.Threading; - -namespace BP_Essentials -{ - class LogMessage : EssentialsChatPlugin - { - public static void Run(SvPlayer player, string message) - { - try - { - var mssge = $"{SetTimeStamp.Run()}[{(message.StartsWith(CmdCommandCharacter) ? "COMMAND" : "MESSAGE")}] {player.playerData.username}: {message}"; - Debug.Log(mssge); - int tries = 0; - while (tries < 2) - try - { - if (!message.StartsWith(CmdCommandCharacter)) - File.AppendAllText(ChatLogFile, mssge + Environment.NewLine); - else - File.AppendAllText(CommandLogFile, mssge + Environment.NewLine); - File.AppendAllText(LogFile, mssge + Environment.NewLine); - break; - } - catch (IOException) - { - Thread.Sleep(50); - ++tries; - } - - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - public static void LogOther(string message) - { - try - { - Debug.Log(message); - int tries = 0; - while (tries < 2) - try - { - File.AppendAllText(LogFile, $"{message}{Environment.NewLine}"); - break; - } - catch (IOException) - { - Thread.Sleep(50); - ++tries; - } - - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - } -} diff --git a/source/BP-Essentials/Methods/misc/SaveNow.cs b/source/BP-Essentials/Methods/misc/SaveNow.cs deleted file mode 100644 index 43aa74c9..00000000 --- a/source/BP-Essentials/Methods/misc/SaveNow.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; - -namespace BP_Essentials -{ - class SaveNow : EssentialsChatPlugin - { - public static void Run() - { - try - { - Debug.Log(SetTimeStamp.Run() + "[INFO] Saving game.."); - foreach (var shPlayer in FindObjectsOfType()) - if (!shPlayer.svPlayer.IsServerside()) - { - if (shPlayer.GetPlaceIndex() >= 13) continue; - shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Saving game.. This can take up to 5 seconds."); - shPlayer.svPlayer.Save(); - } - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - } -} diff --git a/source/BP-Essentials/Methods/misc/SavePeriodically.cs b/source/BP-Essentials/Methods/misc/SavePeriodically.cs deleted file mode 100644 index eeb2b590..00000000 --- a/source/BP-Essentials/Methods/misc/SavePeriodically.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; -using System.Threading; -using System.Timers; - -namespace BP_Essentials -{ - class SavePeriodically : EssentialsChatPlugin - { - public static void Run(object man) - { - try - { - var svManager = (SvManager)man; - var Tmer = new System.Timers.Timer(); // TODO: Disposing the timer seems to break - Tmer.Elapsed += (sender, e) => OnTime(svManager); - Tmer.Interval = SaveTime * 1000; - Tmer.Enabled = true; - } - catch (Exception ex) - { - ErrorLogging.Run(ex); - } - } - static void OnTime(object onetMan) - { - var svManager = (SvManager)onetMan; - Debug.Log(SetTimeStamp.Run() + "[INFO] Saving game.."); - foreach (var shPlayer in svManager.players.Values) - if (!shPlayer.svPlayer.IsServerside()) - { - if (shPlayer.GetPlaceIndex() >= 13) continue; - shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Saving game.. This can take up to 5 seconds."); - shPlayer.svPlayer.Save(); - } - } - } -} \ No newline at end of file diff --git a/source/BP-Essentials/Methods/misc/SetTimeStamp.cs b/source/BP-Essentials/Methods/misc/SetTimeStamp.cs deleted file mode 100644 index 15c69ea0..00000000 --- a/source/BP-Essentials/Methods/misc/SetTimeStamp.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using static BP_Essentials.EssentialsVariablesPlugin; -using static BP_Essentials.EssentialsMethodsPlugin; - -namespace BP_Essentials -{ - class SetTimeStamp : EssentialsChatPlugin - { - public static string Run() - { - try - { - var src = DateTime.Now; - var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second); - var placeHolderText = TimestampFormat; - var minutes = hm.ToString("mm"); - var seconds = hm.ToString("ss"); - - if (TimestampFormat.Contains("{YYYY}")) - placeHolderText = placeHolderText.Replace("{YYYY}", hm.ToString("yyyy")); - if (TimestampFormat.Contains("{DD}")) - placeHolderText = placeHolderText.Replace("{DD}", hm.ToString("dd")); - if (TimestampFormat.Contains("{DDDD}")) - placeHolderText = placeHolderText.Replace("{DDDD}", hm.ToString("dddd")); - if (TimestampFormat.Contains("{MMMM}")) - placeHolderText = placeHolderText.Replace("{MMMM}", hm.ToString("MMMM")); - if (TimestampFormat.Contains("{MM}")) - placeHolderText = placeHolderText.Replace("{MM}", hm.ToString("MM")); - if (TimestampFormat.Contains("{H}")) - placeHolderText = placeHolderText.Replace("{H}", hm.ToString("HH")); - if (TimestampFormat.Contains("{h}")) - placeHolderText = placeHolderText.Replace("{h}", hm.ToString("hh")); - if (TimestampFormat.Contains("{M}") || TimestampFormat.Contains("{m}")) - placeHolderText = placeHolderText.Replace("{M}", minutes); - if (TimestampFormat.Contains("{S}") || TimestampFormat.Contains("{s}")) - placeHolderText = placeHolderText.Replace("{S}", seconds.ToString()); - if (TimestampFormat.Contains("{T}")) - placeHolderText = placeHolderText.Replace("{T}", hm.ToString("tt")); - placeHolderText = placeHolderText + " "; - return placeHolderText; - } - catch (Exception) - { - return "[Failed] "; - } - } - } -}