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; }