From ae384c433d5f80dda05b09a03698086c270be86f Mon Sep 17 00:00:00 2001 From: BONNe Date: Fri, 26 Apr 2019 23:45:34 +0300 Subject: [PATCH] Fix crashing build. --- .../challenges/ChallengesManager.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/ChallengesManager.java b/src/main/java/world/bentobox/challenges/ChallengesManager.java index 8df185b..a61382c 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesManager.java +++ b/src/main/java/world/bentobox/challenges/ChallengesManager.java @@ -137,6 +137,23 @@ public class ChallengesManager } + /** + * Reload database. This method keeps cache memory. + */ + public void reload() + { + this.addon.getLogger().info("Reloading challenges..."); + + this.challengeDatabase = new Database<>(addon, Challenge.class); + this.levelDatabase = new Database<>(addon, ChallengeLevel.class); + this.playersDatabase = new Database<>(addon, ChallengesPlayerData.class); + + this.challengeDatabase.loadObjects().forEach(this::loadChallenge); + this.levelDatabase.loadObjects().forEach(this::loadLevel); + this.playersDatabase.loadObjects().forEach(this::loadPlayerData); + } + + /** * Load challenge silently. Used when loading. * @@ -386,7 +403,7 @@ public class ChallengesManager * This method saves given challenge object to database. * @param challenge object that must be saved */ - private void saveChallenge(Challenge challenge) + public void saveChallenge(Challenge challenge) { this.challengeDatabase.saveObject(challenge); } @@ -405,7 +422,7 @@ public class ChallengesManager * This method saves given level into database. * @param level object that must be saved */ - private void saveLevel(ChallengeLevel level) + public void saveLevel(ChallengeLevel level) { this.levelDatabase.saveObject(level); }