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:
Andreas Troelsen
2021-08-07 01:36:35 +02:00
parent 286071871f
commit 823be96b4e
2 changed files with 5 additions and 0 deletions
@@ -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);