Skip to content

Commit

Permalink
Fixes a bug with -1 repeat-times
Browse files Browse the repository at this point in the history
There was a bug that prevented the challenge to be completed if negative numbers were set in the "max-repeats" value.
  • Loading branch information
BONNe committed Mar 22, 2022
1 parent 48c47f0 commit e96e2c7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/java/world/bentobox/challenges/tasks/TryToComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ private int getAvailableCompletionTimes(int vantedTimes)
// Challenge is not repeatable
vantedTimes = 1;
}
else if (this.challenge.getMaxTimes() != 0)
else if (this.challenge.getMaxTimes() > 0)
{
// Challenge has limitations
long availableTimes = this.challenge.getMaxTimes() - this.manager.getChallengeTimes(this.user, this.world, this.challenge);
Expand Down Expand Up @@ -858,6 +858,11 @@ private void showError(final String cmd)
*/
private ChallengeResult checkInventory(int maxTimes)
{
if (maxTimes <= 0)
{
return EMPTY_RESULT;
}

// Run through inventory
List<ItemStack> requiredItems;

Expand Down Expand Up @@ -1000,6 +1005,11 @@ else if (this.getInventoryRequirements().getIgnoreMetaData().contains(required.g
*/
private ChallengeResult checkSurrounding(int factor)
{
if (factor <= 0)
{
return EMPTY_RESULT;
}

// Init location in player position.
BoundingBox boundingBox = this.user.getPlayer().getBoundingBox().clone();

Expand Down Expand Up @@ -1316,6 +1326,11 @@ private void removeEntities(Queue<Entity> entityQueue, int factor)
*/
private ChallengeResult checkOthers(int factor)
{
if (factor <= 0)
{
return EMPTY_RESULT;
}

OtherRequirements requirements = this.getOtherRequirements();

if (!this.addon.isLevelProvided() && requirements.getRequiredIslandLevel() != 0)
Expand Down Expand Up @@ -1390,6 +1405,11 @@ else if (this.addon.isLevelProvided() &&
*/
private ChallengeResult checkStatistic(int factor)
{
if (factor <= 0)
{
return EMPTY_RESULT;
}

StatisticRequirements requirements = this.challenge.getRequirements();

int currentValue;
Expand Down

0 comments on commit e96e2c7

Please sign in to comment.