From 9c4c5b7d86a818bf4f67eed56316a640751c94d2 Mon Sep 17 00:00:00 2001 From: BONNe1704 Date: Wed, 23 Jan 2019 18:01:19 +0200 Subject: [PATCH] Fix issue when Levels were not loaded with world name in unique ID. Fix crash that appears after renaming Level to Other challenge type. --- .../challenges/ChallengesImportManager.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/ChallengesImportManager.java b/src/main/java/world/bentobox/challenges/ChallengesImportManager.java index 8040590..c16ab32 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesImportManager.java +++ b/src/main/java/world/bentobox/challenges/ChallengesImportManager.java @@ -83,7 +83,7 @@ public class ChallengesImportManager for (String level : lvs) { ChallengeLevel challengeLevel = new ChallengeLevel(); challengeLevel.setFriendlyName(level); - challengeLevel.setUniqueId(level); + challengeLevel.setUniqueId(Util.getWorld(world).getName() + "_" + level); challengeLevel.setOrder(order++); challengeLevel.setWorld(Util.getWorld(world).getName()); challengeLevel.setWaiverAmount(chal.getInt("challenges.waiveramount")); @@ -120,7 +120,17 @@ public class ChallengesImportManager newChallenge.setFriendlyName(details.getString("friendlyname", challenge)); newChallenge.setDescription(GuiUtils.stringSplit(details.getString("description", ""))); newChallenge.setIcon(ItemParser.parse(details.getString("icon") + ":1")); - newChallenge.setChallengeType(Challenge.ChallengeType.valueOf(details.getString("type","INVENTORY").toUpperCase())); + + if (details.getString("type").equalsIgnoreCase("level")) + { + // Fix for older version config + newChallenge.setChallengeType(Challenge.ChallengeType.OTHER); + } + else + { + newChallenge.setChallengeType(Challenge.ChallengeType.valueOf(details.getString("type","INVENTORY").toUpperCase())); + } + newChallenge.setTakeItems(details.getBoolean("takeItems",true)); newChallenge.setRewardText(details.getString("rewardText", "")); newChallenge.setRewardCommands(details.getStringList("rewardcommands"));