Skip to content

Commit

Permalink
Require non-nulls.
Browse files Browse the repository at this point in the history
getInventory never returns null.
  • Loading branch information
tastybento committed Apr 16, 2022
1 parent 37d2039 commit 6c09155
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/main/java/world/bentobox/challenges/tasks/TryToComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ else if (removeAmount >= statistic)
// 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());
Expand Down Expand Up @@ -877,12 +877,7 @@ private ChallengeResult checkInventory(int maxTimes)
{
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).
Expand Down Expand Up @@ -1420,7 +1415,7 @@ private ChallengeResult checkStatistic(int factor)
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());
Expand Down

0 comments on commit 6c09155

Please sign in to comment.