Fix a bug with challenge deletion.

If challenge has been left in a level, then system did not remove challenge from it and was kept as ghost challenge, preventing from completing level.
This commit is contained in:
BONNe 2019-11-03 22:45:24 +02:00
parent 9d45f08fb1
commit e3e3191e6c

View File

@ -1669,11 +1669,22 @@ public class ChallengesManager
{
if (this.challengeCacheData.containsKey(challenge.getUniqueId()))
{
// First remove challenge from its owner level.
if (!challenge.getLevel().equals(FREE))
{
ChallengeLevel level = this.getLevel(challenge.getLevel());
if (level != null)
{
this.removeChallengeFromLevel(challenge, level);
}
}
// Afterwards remove challenge from the database.
this.challengeCacheData.remove(challenge.getUniqueId());
this.challengeDatabase.deleteObject(challenge);
this.addon.getPlugin().getPlaceholdersManager().
unregisterPlaceholder("challenges_challenge_repetition_count_" + challenge.getUniqueId());
}
}