diff --git a/core/src/main/java/com/riiablo/cvar/CvarManager.java b/core/src/main/java/com/riiablo/cvar/CvarManager.java index 30bb3072..c13e5251 100644 --- a/core/src/main/java/com/riiablo/cvar/CvarManager.java +++ b/core/src/main/java/com/riiablo/cvar/CvarManager.java @@ -43,7 +43,10 @@ public class CvarManager implements Cvar.StateListener, Iterable { if (cvar == null) return false; String alias = cvar.ALIAS.toLowerCase(); Cvar queriedCvar = CVARS.get(alias); - return Objects.equals(queriedCvar, cvar) && CVARS.remove(alias) != null; + boolean removed = Objects.equals(queriedCvar, cvar) + && CVARS.remove(alias) != null; + if (removed) queriedCvar.removeStateListener(this); + return removed; } @SuppressWarnings("unchecked")