Skip to content

Commit

Permalink
Fixes bug with levels in challanges.yml is ''
Browse files Browse the repository at this point in the history
#473
  • Loading branch information
tastybento committed Jan 23, 2017
1 parent 061e183 commit b1b721b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/com/wasteofplastic/askyblock/Players.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@ public void save() {
// Save the challenges
playerInfo.set("challenges",null);
for (String challenge : challengeList.keySet()) {
//plugin.getLogger().info("DEBUG: " + challenge + " --> " + challengeList.get(challenge));
playerInfo.set("challenges.status." + challenge.replace(".","[dot]"), challengeList.get(challenge));
if (!challenge.isEmpty())
playerInfo.set("challenges.status." + challenge.replace(".","[dot]"), challengeList.get(challenge));
}
for (String challenge : challengeListTimes.keySet()) {
playerInfo.set("challenges.times." + challenge.replace(".","[dot]"), challengeListTimes.get(challenge));
if (!challenge.isEmpty())
playerInfo.set("challenges.times." + challenge.replace(".","[dot]"), challengeListTimes.get(challenge));
}
// Check what the global limit is
if (Settings.resetLimit < this.resetsLeft) {
Expand Down Expand Up @@ -366,7 +367,7 @@ public HashMap<String, Boolean> getChallengeStatus() {
* @param challenge
*/
public void completeChallenge(final String challenge) {
// plugin.getLogger().info("DEBUG: Complete challenge");
//plugin.getLogger().info("DEBUG: Complete challenge");
challengeList.put(challenge.toLowerCase(), true);
// Count how many times the challenge has been done
int times = 0;
Expand Down Expand Up @@ -558,6 +559,7 @@ public void resetAllChallenges() {
* @param challenge
*/
public void resetChallenge(final String challenge) {
//plugin.getLogger().info("DEBUG: reset challenge");
challengeList.put(challenge, false);
challengeListTimes.put(challenge, 0);
}
Expand Down
7 changes: 6 additions & 1 deletion src/com/wasteofplastic/askyblock/commands/Challenges.java
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,12 @@ public void reloadChallengeConfig() {
challengeFile.setDefaults(defConfig);
}*/
Settings.challengeList = getChallengeConfig().getConfigurationSection("challenges.challengeList").getKeys(false);
Settings.challengeLevels = Arrays.asList(getChallengeConfig().getString("challenges.levels","").split(" "));
// This code below handles the edge case where the levels is set to ''
if (getChallengeConfig().getString("challenges.levels","").isEmpty()) {
Settings.challengeLevels = new ArrayList<String>();
} else {
Settings.challengeLevels = Arrays.asList(getChallengeConfig().getString("challenges.levels","").split(" "));
}
Settings.freeLevels = Arrays.asList(getChallengeConfig().getString("challenges.freelevels","").split(" "));
Settings.waiverAmount = getChallengeConfig().getInt("challenges.waiveramount", 1);
if (Settings.waiverAmount < 0) {
Expand Down

0 comments on commit b1b721b

Please sign in to comment.