aboutsummaryrefslogtreecommitdiffstats
path: root/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java
diff options
context:
space:
mode:
authorfatpigsarefat <fatpigsarefat@outlook.com>2018-04-22 17:04:25 +0100
committerfatpigsarefat <fatpigsarefat@outlook.com>2018-04-22 17:04:25 +0100
commitb8fd9ba3ee94c36fd5c4cb5e663fb535871aa2f0 (patch)
tree1835c547992ecbadbbb93f414b30d253533c69ec /src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java
parent43ea3f3571c7c7f4bf2d178aebe80f5de6831803 (diff)
Changed from using lists to map
Diffstat (limited to 'src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java')
-rw-r--r--src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java b/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java
index c4fe87b2..c6ec335d 100644
--- a/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java
+++ b/src/me/fatpigsarefat/quests/player/questprogressfile/QuestProgress.java
@@ -1,12 +1,10 @@
package me.fatpigsarefat.quests.player.questprogressfile;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
public class QuestProgress {
- private List<TaskProgress> taskProgress = new ArrayList<>();
+ private Map<String, TaskProgress> taskProgress = new HashMap<>();
private String questid;
private boolean started;
private boolean completed;
@@ -74,20 +72,15 @@ public class QuestProgress {
}
public void addTaskProgress(TaskProgress taskProgress) {
- this.taskProgress.add(taskProgress);
+ this.taskProgress.put(taskProgress.getTaskId(), taskProgress);
}
- public List<TaskProgress> getTaskProgress() {
- return taskProgress;
+ public Collection<TaskProgress> getTaskProgress() {
+ return taskProgress.values();
}
public TaskProgress getTaskProgress(String taskId) {
- for (TaskProgress taskProgress : this.taskProgress) {
- if (taskProgress.getTaskId().equals(taskId)) {
- return taskProgress;
- }
- }
- return null;
+ return taskProgress.getOrDefault(taskId, null);
}
public boolean isWorthSaving() {