Skip to content

Commit

Permalink
Fixes #222
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Jul 9, 2020
1 parent 445e5a0 commit 15655b8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/world/bentobox/challenges/ChallengesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,20 @@ private void resetChallenge(@NonNull String storageDataID, @NonNull String chall
private void resetAllChallenges(@NonNull String storageDataID, @NonNull String gameMode)
{
this.addPlayerData(storageDataID);
this.playerCacheData.get(storageDataID).reset(gameMode);

if (this.playerCacheData.containsKey(storageDataID))
{
// There may be a rare situation when player data cannot be loaded. Just avoid
// error.
this.playerCacheData.get(storageDataID).reset(gameMode);
}
else
{
// If object cannot be loaded remove it completely.
this.playersDatabase.deleteID(storageDataID);
this.addon.logError("Database object was not loaded. It is removed completely. Object Id: " + storageDataID);
}

// Save
this.savePlayerData(storageDataID);
}
Expand Down Expand Up @@ -1399,7 +1412,7 @@ public void resetAllChallenges(User user, World world)
* @param world - World where challenges must be reset.
* @param adminID - admin iD
*/
public void resetAllChallenges(UUID userID, World world, UUID adminID)
public void resetAllChallenges(@NonNull UUID userID, World world, @Nullable UUID adminID)
{
String storageID = this.getDataUniqueID(userID, Util.getWorld(world));

Expand Down

0 comments on commit 15655b8

Please sign in to comment.