From 15ff2fb1d63ddedfab7137fc771bf094caadda09 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 12 May 2023 15:39:51 +0100 Subject: [PATCH] Fixed registry locks --- .../main/java/com/willfp/eco/core/registry/Registry.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eco-api/src/main/java/com/willfp/eco/core/registry/Registry.java b/eco-api/src/main/java/com/willfp/eco/core/registry/Registry.java index e6ff3087..0ba56490 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/registry/Registry.java +++ b/eco-api/src/main/java/com/willfp/eco/core/registry/Registry.java @@ -149,6 +149,10 @@ public class Registry implements Iterable { * @param locker The locker. */ public void lock(@Nullable final Object locker) { + if (this.isLocked && this.locker != locker) { + throw new IllegalArgumentException("Registry is already locked with a different locker!"); + } + this.locker = locker; isLocked = true; } @@ -162,6 +166,8 @@ public class Registry implements Iterable { if (this.locker != locker) { throw new IllegalArgumentException("Cannot unlock registry!"); } + + this.locker = null; isLocked = false; }