diff --git a/src/BPEssentials/Events/OnTryDelete.cs b/src/BPEssentials/Events/OnTryDelete.cs new file mode 100644 index 0000000..0c0a0f1 --- /dev/null +++ b/src/BPEssentials/Events/OnTryDelete.cs @@ -0,0 +1,23 @@ +using System.Text.RegularExpressions; +using BrokeProtocol.API; +using BrokeProtocol.LiteDB; +using BrokeProtocol.Managers; +using BrokeProtocol.Utility; + +namespace BPEssentials.Events +{ + public class OnDelete : IScript + { + [Target(GameSourceEvent.ManagerTryDelete, ExecutionMode.PreEvent)] + public bool OnTryDelete(ConnectData connectionData) + { + if (SvManager.Instance.TryGetUserData(connectionData.username, out User user) && Core.Instance.Settings.General.DisableAccountOverwrite) + { + SvManager.Instance.RegisterFail(connectionData.connection, "This name has already been registered and this server has disabled overwriting accounts!"); + return false; + } + + return true; + } + } +} diff --git a/src/BPEssentials/ExtensionMethods/PlayerWarns.cs b/src/BPEssentials/ExtensionMethods/PlayerWarns.cs index 6b35134..265373d 100644 --- a/src/BPEssentials/ExtensionMethods/PlayerWarns.cs +++ b/src/BPEssentials/ExtensionMethods/PlayerWarns.cs @@ -30,6 +30,8 @@ public SerializableWarn(string issuer, string reason, DateTimeOffset dateTime) Date = dateTime; } + public SerializableWarn() { } + public string ToString(ShPlayer player) { User issuer = SvManager.Instance.database.Users.FindById(IssueraccountID);