mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +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());
|
Object value = config.get(getKey());
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
V v = reader.read(api, value);
|
V v = reader.read(api, value);
|
||||||
container.setState(this, v);
|
setStateWithoutNull(container, v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,10 +82,17 @@ public class CollectionGameRule<T, V extends Collection<T>> extends GameRule<V>
|
|||||||
} catch (ClassCastException exception) {
|
} catch (ClassCastException exception) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
container.setState(this, v);
|
setStateWithoutNull(container, v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setStateWithoutNull(GameRuleContainer container, V v) {
|
||||||
|
while (v != null && v.contains(null)) {
|
||||||
|
v.remove(null);
|
||||||
|
}
|
||||||
|
container.setState(this, v);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void merge(GameRuleContainer overriding, GameRuleContainer subsidiary, GameRuleContainer writeTo) {
|
public void merge(GameRuleContainer overriding, GameRuleContainer subsidiary, GameRuleContainer writeTo) {
|
||||||
V writeToState = writeTo.getState(this);
|
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) {
|
if (v == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
v.remove(null); // Do not allow null values
|
||||||
container.setState(this, v);
|
container.setState(this, v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user