1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-02 07:23:29 +01:00

Fix NPE when getting quest

This commit is contained in:
montlikadani 2020-03-03 19:47:53 +01:00
parent ab3ea2e77d
commit f8d9862a8b
3 changed files with 12 additions and 3 deletions

View File

@ -446,10 +446,15 @@ public class Job {
} }
public Quest getQuest(String name) { public Quest getQuest(String name) {
if (name == null || name.trim().isEmpty()) {
return null;
}
for (Quest one : quests) { for (Quest one : quests) {
if (one.getConfigName().equalsIgnoreCase(name)) if (one.getConfigName().equalsIgnoreCase(name))
return one; return one;
} }
return null; return null;
} }

View File

@ -12,8 +12,8 @@ import com.gamingmesh.jobs.Jobs;
public class Quest { public class Quest {
private String configName; private String configName = "";
private String questName; private String questName = "";
private Job job; private Job job;
private Long validUntil = 0L; private Long validUntil = 0L;

View File

@ -11,17 +11,21 @@ import com.gamingmesh.jobs.Jobs;
public class QuestProgression { public class QuestProgression {
private Quest quest; private Quest quest;
private long validUntil; private long validUntil;
private boolean givenReward = false; private boolean givenReward = false;
private HashMap<QuestObjective, Integer> done = new HashMap<>(); private HashMap<QuestObjective, Integer> done = new HashMap<>();
public QuestProgression(Quest quest) { public QuestProgression(Quest quest) {
this.quest = quest; this.quest = quest;
validUntil = quest.getValidUntil(); validUntil = quest.getValidUntil();
} }
public Quest getQuest() { public Quest getQuest() {
return quest == null ? null : quest.getJob().getQuest(quest.getConfigName()); Quest q = quest == null ? null : (quest.getJob() == null ? null : quest.getJob().getQuest(quest.getConfigName()));
return q;
} }
public void setQuest(Quest quest) { public void setQuest(Quest quest) {