Skip to content

Commit 4cc345a

Browse files
fix: remove temp code locks when plugin is unloaded
1 parent 815b448 commit 4cc345a

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/AutoCode.cs

+19-11
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,8 @@ protected override void LoadDefaultConfig() {
4141

4242
void OnServerSave()
4343
{
44+
RemoveAllTempCodeLocks();
4445
data.Save();
45-
46-
// Remove all temp code locks - we don't want to save them.
47-
foreach (TempCodeLockInfo codeLockInfo in tempCodeLocks.Values)
48-
{
49-
if (!codeLockInfo.CodeLock.IsDestroyed)
50-
{
51-
codeLockInfo.CodeLock.Kill();
52-
}
53-
}
54-
tempCodeLocks.Clear();
55-
UnsubscribeFromUnneedHooks();
5646
}
5747

5848
void OnServerShutdown()
@@ -62,6 +52,7 @@ void OnServerShutdown()
6252

6353
void Unload()
6454
{
55+
RemoveAllTempCodeLocks();
6556
data.Save();
6657
}
6758

@@ -487,6 +478,23 @@ private void DestoryTempCodeLock(BasePlayer player)
487478
UnsubscribeFromUnneedHooks();
488479
}
489480

481+
/// <summary>
482+
/// Remove all the temporary code locks.
483+
/// </summary>
484+
private void RemoveAllTempCodeLocks()
485+
{
486+
// Remove all temp code locks - we don't want to save them.
487+
foreach (TempCodeLockInfo codeLockInfo in tempCodeLocks.Values)
488+
{
489+
if (!codeLockInfo.CodeLock.IsDestroyed)
490+
{
491+
codeLockInfo.CodeLock.Kill();
492+
}
493+
}
494+
tempCodeLocks.Clear();
495+
UnsubscribeFromUnneedHooks();
496+
}
497+
490498
/// <summary>
491499
/// Unsubscribe from things that there is not point currently being subscribed to.
492500
/// </summary>

0 commit comments

Comments
 (0)