Skip to content

Commit

Permalink
Fixes #269
Browse files Browse the repository at this point in the history
Disable waiver amount message for last challenge level.
  • Loading branch information
BONNe committed Sep 24, 2021
1 parent aa0336d commit 644c7d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,21 @@ public ChallengeLevel getLatestUnlockedLevel(User user, World world)
}


/**
* Returns if the given level is last leve in given world.
*
* @param level the level
* @param world the world
* @return the boolean
*/
public boolean isLastLevel(ChallengeLevel level, World world)
{
List<ChallengeLevel> levels = this.getLevels(world);

return levels.get(levels.size() - 1) == level;
}


// ---------------------------------------------------------------------
// Section: Challenges related methods
// ---------------------------------------------------------------------
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/world/bentobox/challenges/panel/CommonPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,9 @@ protected List<String> generateLevelDescription(ChallengeLevel level)
// Get status in single string
String status = "";
// Get requirements in single string
String waiver = this.user.getTranslationOrNothing(reference + "waiver",
"[number]", String.valueOf(level.getWaiverAmount()));
String waiver = this.manager.isLastLevel(level, this.world) ? "" :
this.user.getTranslationOrNothing(reference + "waiver",
"[number]", String.valueOf(level.getWaiverAmount()));
// Get rewards in single string
String rewards = this.generateReward(level);

Expand Down Expand Up @@ -851,9 +852,11 @@ protected List<String> generateLevelDescription(LevelStatus levelStatus, User us
// Get status in single string
String status = this.generateLevelStatus(levelStatus);
// Get requirements in single string
String waiver = !levelStatus.isUnlocked() || levelStatus.isComplete() ? "" :
this.user.getTranslationOrNothing(reference + "waiver",
"[number]", String.valueOf(level.getWaiverAmount()));
String waiver = this.manager.isLastLevel(level, this.world) ||
!levelStatus.isUnlocked() ||
levelStatus.isComplete() ?
"" : this.user.getTranslationOrNothing(reference + "waiver",
"[number]", String.valueOf(level.getWaiverAmount()));
// Get rewards in single string
String rewards = !levelStatus.isUnlocked() ? "" : this.generateReward(level);

Expand Down

0 comments on commit 644c7d6

Please sign in to comment.