mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-13 06:07:36 +01:00
No null in Collection/MapGameRule; resolves #993
This commit is contained in:
parent
3be40cc20a
commit
c956344176
@ -72,7 +72,7 @@ public class CollectionGameRule<T, V extends Collection<T>> extends GameRule<V>
|
||||
Object value = config.get(getKey());
|
||||
if (reader != null) {
|
||||
V v = reader.read(api, value);
|
||||
container.setState(this, v);
|
||||
setStateWithoutNull(container, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -82,10 +82,17 @@ public class CollectionGameRule<T, V extends Collection<T>> extends GameRule<V>
|
||||
} catch (ClassCastException exception) {
|
||||
return null;
|
||||
}
|
||||
container.setState(this, v);
|
||||
setStateWithoutNull(container, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
private void setStateWithoutNull(GameRuleContainer container, V v) {
|
||||
while (v != null && v.contains(null)) {
|
||||
v.remove(null);
|
||||
}
|
||||
container.setState(this, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void merge(GameRuleContainer overriding, GameRuleContainer subsidiary, GameRuleContainer writeTo) {
|
||||
V writeToState = writeTo.getState(this);
|
||||
|
@ -68,6 +68,7 @@ public class MapGameRule<TK, TV, V extends Map<TK, TV>> extends GameRule<V> {
|
||||
if (v == null) {
|
||||
return null;
|
||||
}
|
||||
v.remove(null); // Do not allow null values
|
||||
container.setState(this, v);
|
||||
return v;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user