Skip to content

Commit

Permalink
Merge pull request #111 from BPEssentials/DeleteEvent
Browse files Browse the repository at this point in the history
Create OnTryDelete.cs
  • Loading branch information
PLASMAchicken authored Aug 10, 2024
2 parents 21abe6a + 121a6ea commit 8069cc7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/BPEssentials/Events/OnTryDelete.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
2 changes: 2 additions & 0 deletions src/BPEssentials/ExtensionMethods/PlayerWarns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8069cc7

Please sign in to comment.