From 7cbbd6396b15ef174133318ed255a6966565aab8 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sat, 12 Dec 2020 23:37:12 -0500 Subject: [PATCH] Throw error if requirement quest name is unknown, fixes #1502 --- .../main/java/me/blackvein/quests/Quests.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index d4defb0f6..31bc779b8 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -1796,7 +1796,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener final String name2 = config.getString("quests." + id + ".name"); if (name2.equalsIgnoreCase(name) || ChatColor.stripColor(name2).equalsIgnoreCase(ChatColor.stripColor(name))) { - temp.add(getQuest(name)); + if (getQuest(name) != null) { + temp.add(getQuest(name)); + } else { + throw new QuestFormatException("Requirement quest-blocks has unknown quest name " + + failedQuest, questKey); + } done = true; break; } @@ -1827,7 +1832,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener final String name2 = config.getString("quests." + id + ".name"); if (name2.equalsIgnoreCase(name) || ChatColor.stripColor(name2).equalsIgnoreCase(ChatColor.stripColor(name))) { - temp.add(getQuest(name)); + if (getQuest(name) != null) { + temp.add(getQuest(name)); + } else { + throw new QuestFormatException("Requirement quests has unknown quest name " + + failedQuest, questKey); + } done = true; break; } @@ -1840,7 +1850,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } reqs.setNeededQuests(temp); if (failed) { - throw new QuestFormatException("Requirement quests has invalid quest name " + failedQuest, questKey); + throw new QuestFormatException("Requirement quests has invalid quest name " + + failedQuest, questKey); } } else { throw new QuestFormatException("Requirement quests is not a list of quest names", questKey);