Fixes a bug with `-1` repeat-times

There was a bug that prevented the challenge to be completed if negative numbers were set in the "max-repeats" value.
This commit is contained in:
BONNe 2022-03-22 12:41:27 +02:00 committed by GitHub
parent 48c47f086d
commit e96e2c7e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 1 deletions

View File

@ -771,7 +771,7 @@ public class TryToComplete
// 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);
@ -858,6 +858,11 @@ public class TryToComplete
*/
private ChallengeResult checkInventory(int maxTimes)
{
if (maxTimes <= 0)
{
return EMPTY_RESULT;
}
// Run through inventory
List<ItemStack> requiredItems;
@ -1000,6 +1005,11 @@ public class TryToComplete
*/
private ChallengeResult checkSurrounding(int factor)
{
if (factor <= 0)
{
return EMPTY_RESULT;
}
// Init location in player position.
BoundingBox boundingBox = this.user.getPlayer().getBoundingBox().clone();
@ -1316,6 +1326,11 @@ public class TryToComplete
*/
private ChallengeResult checkOthers(int factor)
{
if (factor <= 0)
{
return EMPTY_RESULT;
}
OtherRequirements requirements = this.getOtherRequirements();
if (!this.addon.isLevelProvided() && requirements.getRequiredIslandLevel() != 0)
@ -1390,6 +1405,11 @@ public class TryToComplete
*/
private ChallengeResult checkStatistic(int factor)
{
if (factor <= 0)
{
return EMPTY_RESULT;
}
StatisticRequirements requirements = this.challenge.getRequirements();
int currentValue;