Fixed CvarManager cleanup

Fixed an issue where removing a Cvar from a CvarManager was not removing its state listener
This commit is contained in:
Collin Smith 2021-04-25 01:47:57 -07:00
parent bb5351646f
commit e550bdab55

View File

@ -43,7 +43,10 @@ public class CvarManager implements Cvar.StateListener, Iterable<Cvar> {
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")