mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-26 12:35:24 +01:00
Fix NPE when opening ChallengesGUI (#116).
Add code that removes challenges level from all its challenges, if level is deleted. Add protection code that shows admins that something is not correct if challenge level is not in database.
This commit is contained in:
parent
dd56842dca
commit
6c10fcdca9
@ -1462,6 +1462,20 @@ public class ChallengesManager
|
|||||||
if (this.levelCacheData.containsKey(challengeLevel.getUniqueId()))
|
if (this.levelCacheData.containsKey(challengeLevel.getUniqueId()))
|
||||||
{
|
{
|
||||||
this.levelCacheData.remove(challengeLevel.getUniqueId());
|
this.levelCacheData.remove(challengeLevel.getUniqueId());
|
||||||
|
|
||||||
|
// Remove challenge level from challenges object.
|
||||||
|
if (!challengeLevel.getChallenges().isEmpty())
|
||||||
|
{
|
||||||
|
challengeLevel.getChallenges().forEach(challengeID -> {
|
||||||
|
Challenge challenge = this.getChallenge(challengeID);
|
||||||
|
|
||||||
|
if (challenge != null)
|
||||||
|
{
|
||||||
|
challenge.setLevel(ChallengesManager.FREE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.levelDatabase.deleteObject(challengeLevel);
|
this.levelDatabase.deleteObject(challengeLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,9 +297,20 @@ public abstract class CommonGUI
|
|||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'l':
|
case 'l':
|
||||||
|
{
|
||||||
|
ChallengeLevel level = manager.getLevel(challenge);
|
||||||
|
|
||||||
|
if (level == null)
|
||||||
|
{
|
||||||
|
result.add(this.user.getTranslation("challenges.errors.missing-level",
|
||||||
|
"[level]", challenge.getLevel()));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
result.add(this.user.getTranslation("challenges.gui.challenge-description.level",
|
result.add(this.user.getTranslation("challenges.gui.challenge-description.level",
|
||||||
"[level]", manager.getLevel(challenge).getFriendlyName()));
|
"[level]", level.getFriendlyName()));
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -359,12 +359,13 @@ public class TryToComplete
|
|||||||
// Mark as complete
|
// Mark as complete
|
||||||
this.manager.setChallengeComplete(this.user, this.world, this.challenge, result.getFactor());
|
this.manager.setChallengeComplete(this.user, this.world, this.challenge, result.getFactor());
|
||||||
|
|
||||||
// Check level completion.
|
// Check level completion for non-free challenges
|
||||||
if (!result.wasCompleted())
|
if (!result.wasCompleted() &&
|
||||||
|
!this.challenge.getLevel().equals(ChallengesManager.FREE))
|
||||||
{
|
{
|
||||||
ChallengeLevel level = this.manager.getLevel(this.challenge);
|
ChallengeLevel level = this.manager.getLevel(this.challenge);
|
||||||
|
|
||||||
if (!this.manager.isLevelCompleted(this.user, this.world, level))
|
if (level != null && !this.manager.isLevelCompleted(this.user, this.world, level))
|
||||||
{
|
{
|
||||||
if (this.manager.validateLevelCompletion(this.user, this.world, level))
|
if (this.manager.validateLevelCompletion(this.user, this.world, level))
|
||||||
{
|
{
|
||||||
|
@ -364,6 +364,7 @@ challenges:
|
|||||||
defaults-file-exist: '&cdefault.json already exists. Use overwrite mode to replace it!'
|
defaults-file-exist: '&cdefault.json already exists. Use overwrite mode to replace it!'
|
||||||
defaults-file-error: '&cThere was an error while creating default.json file! Check console!'
|
defaults-file-error: '&cThere was an error while creating default.json file! Check console!'
|
||||||
no-challenges: '&cChallenges are not implemented in current world!'
|
no-challenges: '&cChallenges are not implemented in current world!'
|
||||||
|
missing-level: '&cChallenge Level [level] is not defined in database. It may case some errors!'
|
||||||
protection:
|
protection:
|
||||||
flags:
|
flags:
|
||||||
CHALLENGES_ISLAND_PROTECTION:
|
CHALLENGES_ISLAND_PROTECTION:
|
||||||
|
Loading…
Reference in New Issue
Block a user