From e550bdab55848b7738c977f062681f74b793ab66 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sun, 25 Apr 2021 01:47:57 -0700 Subject: [PATCH] Fixed CvarManager cleanup Fixed an issue where removing a Cvar from a CvarManager was not removing its state listener --- core/src/main/java/com/riiablo/cvar/CvarManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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")