Skip to content

Commit 8069cc7

Browse files
Merge pull request #111 from BPEssentials/DeleteEvent
Create OnTryDelete.cs
2 parents 21abe6a + 121a6ea commit 8069cc7

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Text.RegularExpressions;
2+
using BrokeProtocol.API;
3+
using BrokeProtocol.LiteDB;
4+
using BrokeProtocol.Managers;
5+
using BrokeProtocol.Utility;
6+
7+
namespace BPEssentials.Events
8+
{
9+
public class OnDelete : IScript
10+
{
11+
[Target(GameSourceEvent.ManagerTryDelete, ExecutionMode.PreEvent)]
12+
public bool OnTryDelete(ConnectData connectionData)
13+
{
14+
if (SvManager.Instance.TryGetUserData(connectionData.username, out User user) && Core.Instance.Settings.General.DisableAccountOverwrite)
15+
{
16+
SvManager.Instance.RegisterFail(connectionData.connection, "This name has already been registered and this server has disabled overwriting accounts!");
17+
return false;
18+
}
19+
20+
return true;
21+
}
22+
}
23+
}

src/BPEssentials/ExtensionMethods/PlayerWarns.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public SerializableWarn(string issuer, string reason, DateTimeOffset dateTime)
3030
Date = dateTime;
3131
}
3232

33+
public SerializableWarn() { }
34+
3335
public string ToString(ShPlayer player)
3436
{
3537
User issuer = SvManager.Instance.database.Users.FindById(IssueraccountID);

0 commit comments

Comments
 (0)