From 823be96b4e0d260a0ffa57794ce0e18b13856baf Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Sat, 7 Aug 2021 01:20:27 +0200 Subject: [PATCH] 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 --- changelog.md | 3 +++ .../java/com/garbagemule/MobArena/things/ThingGroupPicker.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 4b45ed6..454c40d 100644 --- a/changelog.md +++ b/changelog.md @@ -20,6 +20,9 @@ These changes will (most likely) be included in the next version. - MobArena now targets the Minecraft 1.17 version of the Spigot API (but still works on 1.13-1.16). This should make it easier to tackle feature requests and bug reports related to modern Minecraft. - The regex pattern for the player list command is now less greedy, so it will only match on `/ma players`, `/ma playerlist`, and `/ma player-list`. The previous pattern matched on anything that starts with `player`, which rendered the `/ma player-stats` command in MobArenaStats impossible to invoke. +### Fixed +- Reward groups with `nothing` in them no longer cause errors when earned/granted. + ## [0.106] - 2021-05-09 ### Added - It is now possible to write custom formulas for wave growth in Default Wave, swarm amounts in Swarm Waves, and boss health in Boss Waves, allowing for much more control and fine-tuning. The formulas support various session-related variables as well as various mathematical operators and functions. Formulas can be predefined as macros in the new `formulas.yml` file. Check the wiki for details. diff --git a/src/main/java/com/garbagemule/MobArena/things/ThingGroupPicker.java b/src/main/java/com/garbagemule/MobArena/things/ThingGroupPicker.java index ad548a2..8506b1c 100644 --- a/src/main/java/com/garbagemule/MobArena/things/ThingGroupPicker.java +++ b/src/main/java/com/garbagemule/MobArena/things/ThingGroupPicker.java @@ -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 things = pickers.stream() .map(ThingPicker::pick) + .filter(Objects::nonNull) .collect(Collectors.toList()); return new ThingGroup(things);