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

View File

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