mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 13:36:06 +01:00
Merge branch 'develop' of https://github.com/BentoBoxWorld/Challenges.git into develop
This commit is contained in:
commit
30783112b1
@ -21,6 +21,7 @@ import world.bentobox.challenges.commands.ChallengesUserCommand;
|
||||
import world.bentobox.challenges.commands.admin.Challenges;
|
||||
import world.bentobox.challenges.commands.admin.ChallengesAdminCommand;
|
||||
import world.bentobox.challenges.config.Settings;
|
||||
import world.bentobox.challenges.database.object.ChallengeLevel;
|
||||
import world.bentobox.challenges.handlers.ChallengeDataRequestHandler;
|
||||
import world.bentobox.challenges.handlers.ChallengeListRequestHandler;
|
||||
import world.bentobox.challenges.handlers.CompletedChallengesRequestHandler;
|
||||
@ -361,6 +362,22 @@ public class ChallengesAddon extends Addon {
|
||||
gameMode + "_challenge_locked_level_count",
|
||||
user -> String.valueOf(this.challengesManager.getLevelCount(world) -
|
||||
this.challengesManager.getUnlockedLevelCount(user, world)));
|
||||
|
||||
// Latest challenge level name placeholder
|
||||
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
|
||||
gameMode + "_challenge_latest_level_name",
|
||||
user -> {
|
||||
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
|
||||
return level != null ? level.getFriendlyName() : "";
|
||||
});
|
||||
|
||||
// Latest challenge level id placeholder
|
||||
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
|
||||
gameMode + "_challenge_latest_level_id",
|
||||
user -> {
|
||||
ChallengeLevel level = this.challengesManager.getLatestUnlockedLevel(user, world);
|
||||
return level != null ? level.getUniqueId() : "";
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -1514,6 +1514,27 @@ public class ChallengesManager
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns latest ChallengeLevel object that is unlocked.
|
||||
* @param user user who latest unlocked level must be returned.
|
||||
* @param world World where level operates.
|
||||
* @return ChallengeLevel for latest unlocked level.
|
||||
*/
|
||||
@Nullable
|
||||
public ChallengeLevel getLatestUnlockedLevel(User user, World world)
|
||||
{
|
||||
LevelStatus lastStatus = null;
|
||||
|
||||
for (Iterator<LevelStatus> statusIterator = this.getAllChallengeLevelStatus(user, world).iterator();
|
||||
statusIterator.hasNext() && (lastStatus == null || !lastStatus.isUnlocked());)
|
||||
{
|
||||
lastStatus = statusIterator.next();
|
||||
}
|
||||
|
||||
return lastStatus != null ? lastStatus.getLevel() : null;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Challenges related methods
|
||||
// ---------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user