mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-25 03:55:10 +01:00
parent
dd8834f1df
commit
e85b687e36
@ -388,6 +388,24 @@ public class ChallengesAddon extends Addon {
|
||||
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
|
||||
return level != null ? level.getUniqueId() : "";
|
||||
});
|
||||
|
||||
// Completed challenge count in latest level
|
||||
this.getPlugin().getPlaceholdersManager().registerPlaceholder(gameModeAddon,
|
||||
addonName + "_latest_level_completed_count",
|
||||
user -> {
|
||||
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
|
||||
return String.valueOf(level != null ?
|
||||
this.challengesManager.getLevelCompletedChallengeCount(user, world, level) : 0);
|
||||
});
|
||||
|
||||
// Uncompleted challenge count in latest level
|
||||
this.getPlugin().getPlaceholdersManager().registerPlaceholder(gameModeAddon,
|
||||
addonName + "_latest_level_uncompleted_count",
|
||||
user -> {
|
||||
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
|
||||
return String.valueOf(level != null ?
|
||||
level.getChallenges().size() - this.challengesManager.getLevelCompletedChallengeCount(user, world, level) : 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -1786,6 +1786,21 @@ public class ChallengesManager
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns completed challenge count in given level.
|
||||
* @param user User which should be checked
|
||||
* @param world World where challenges are operating
|
||||
* @param level Level which challenges must be checked.
|
||||
* @return Number of completed challenges in given level.
|
||||
*/
|
||||
public long getLevelCompletedChallengeCount(User user, World world, ChallengeLevel level)
|
||||
{
|
||||
return this.getLevelChallenges(level).stream().
|
||||
filter(challenge -> this.getChallengeTimes(user, world, challenge) > 0).
|
||||
count();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Level related methods
|
||||
// ---------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user