Guard against nothing in ThingGroupPicker.
This commit filters the result list of a ThingGroupPicker by a non-null predicate to avoid null values in the resulting ThingGroup instance. Since null values represent `nothing`, and we don't usually announce it when players earn a `nothing` reward, it makes sense that they wouldn't bubble up and somehow "manifest" in groups of things either. Fixes #691
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.garbagemule.MobArena.things;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ThingGroupPicker implements ThingPicker {
|
||||
@@ -15,6 +16,7 @@ public class ThingGroupPicker implements ThingPicker {
|
||||
public Thing pick() {
|
||||
List<Thing> things = pickers.stream()
|
||||
.map(ThingPicker::pick)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new ThingGroup(things);
|
||||
|
||||
Reference in New Issue
Block a user