From 6c0915544ed5b5eadc1e613fa893a79c015b0b29 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 16 Apr 2022 15:27:35 -0700 Subject: [PATCH] Require non-nulls. getInventory never returns null. --- .../bentobox/challenges/tasks/TryToComplete.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java b/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java index e0c2e4f..9ac4a42 100644 --- a/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java +++ b/src/main/java/world/bentobox/challenges/tasks/TryToComplete.java @@ -561,8 +561,8 @@ public class TryToComplete // cannot punish null or player who already was punished. continue; } - - switch (requirements.getStatistic().getType()) + + switch (Objects.requireNonNull(requirements.getStatistic()).getType()) { case UNTYPED -> { int statistic = player.getStatistic(requirements.getStatistic()); @@ -877,12 +877,7 @@ public class TryToComplete { int numInInventory; - if (this.user.getInventory() == null) - { - // Sanity check. User always has inventory at this point of code. - numInInventory = 0; - } - else if (this.getInventoryRequirements().getIgnoreMetaData().contains(required.getType())) + if (this.getInventoryRequirements().getIgnoreMetaData().contains(required.getType())) { numInInventory = Arrays.stream(this.user.getInventory().getContents()). filter(Objects::nonNull). @@ -1420,7 +1415,7 @@ public class TryToComplete return EMPTY_RESULT; } - switch (requirements.getStatistic().getType()) + switch (Objects.requireNonNull(requirements.getStatistic()).getType()) { case UNTYPED -> currentValue = this.manager.getStatisticData(this.user, this.world, requirements.getStatistic());