diff options
| author | fatpigsarefat <fatpigsarefat@outlook.com> | 2018-05-06 12:26:27 +0100 |
|---|---|---|
| committer | fatpigsarefat <fatpigsarefat@outlook.com> | 2018-05-06 12:26:27 +0100 |
| commit | 83db4a24abcc8dce6888247ca151d6c05b30a8c1 (patch) | |
| tree | c80503572c891cc32548a0039607ba810c644211 | |
| parent | c3561041cecfb014e46b4b345200bb698795bbfe (diff) | |
Fix for NullPointerException when a task is added after the quest has already been initialized before.
| -rw-r--r-- | src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java b/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java index 8824f920..97e0b517 100644 --- a/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java +++ b/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java @@ -1,6 +1,9 @@ package me.fatpigsarefat.quests.player.questprogressfile; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; public class QuestProgress { @@ -35,8 +38,8 @@ public class QuestProgress { return completed; } - public void setStarted(boolean started) { - this.started = started; + public void setCompleted(boolean completed) { + this.completed = completed; this.modified = true; } @@ -44,8 +47,8 @@ public class QuestProgress { return started; } - public void setCompleted(boolean completed) { - this.completed = completed; + public void setStarted(boolean started) { + this.started = started; this.modified = true; } @@ -80,7 +83,17 @@ public class QuestProgress { } public TaskProgress getTaskProgress(String taskId) { - return taskProgress.getOrDefault(taskId, null); + TaskProgress tP = taskProgress.getOrDefault(taskId, null); + if (tP == null) { + repairTaskProgress(taskId); + tP = taskProgress.getOrDefault(taskId, null); + } + return tP; + } + + public void repairTaskProgress(String taskid) { + TaskProgress taskProgress = new TaskProgress(taskid, null, player, false); + this.addTaskProgress(taskProgress); } public boolean isWorthSaving() { |
