From 5d846c767090f6ac87807d3477c65054cf364f1c Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sat, 28 Mar 2020 15:10:02 -0400 Subject: [PATCH] Ensure Citizens is enabled when processing events, fixes #1146 --- .../convo/quests/prompts/MobsPrompt.java | 44 +++++++++---------- .../quests/listeners/NpcListener.java | 12 +++++ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java index 70973c22c..4f307a4ef 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java @@ -80,11 +80,11 @@ public class MobsPrompt extends QuestsEditorNumericPrompt { case 1: return ChatColor.YELLOW + Lang.get("stageEditorKillMobs"); case 2: - return ChatColor.YELLOW + Lang.get("stageEditorCatchFish"); + return ChatColor.YELLOW + Lang.get("stageEditorTameMobs"); case 3: - return ChatColor.YELLOW + Lang.get("stageEditorMilkCows"); + return ChatColor.YELLOW + Lang.get("stageEditorCatchFish"); case 4: - return ChatColor.YELLOW + Lang.get("stageEditorTameMobs"); + return ChatColor.YELLOW + Lang.get("stageEditorMilkCows"); case 5: return ChatColor.YELLOW + Lang.get("stageEditorShearSheep"); case 6: @@ -129,22 +129,6 @@ public class MobsPrompt extends QuestsEditorNumericPrompt { return text; } case 2: - if (context.getSessionData(pref + CK.S_FISH) == null) { - return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; - } else { - Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); - return ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") - + ChatColor.GRAY + ")\n"; - } - case 3: - if (context.getSessionData(pref + CK.S_COW_MILK) == null) { - return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; - } else { - Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK); - return ChatColor.GRAY + "(" + ChatColor.AQUA + cows + " " + Lang.get("stageEditorCows") - + ChatColor.GRAY + ")\n"; - } - case 4: if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { @@ -157,6 +141,22 @@ public class MobsPrompt extends QuestsEditorNumericPrompt { } return text; } + case 3: + if (context.getSessionData(pref + CK.S_FISH) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); + return ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") + + ChatColor.GRAY + ")\n"; + } + case 4: + if (context.getSessionData(pref + CK.S_COW_MILK) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK); + return ChatColor.GRAY + "(" + ChatColor.AQUA + cows + " " + Lang.get("stageEditorCows") + + ChatColor.GRAY + ")\n"; + } case 5: if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; @@ -198,11 +198,11 @@ public class MobsPrompt extends QuestsEditorNumericPrompt { case 1: return new MobListPrompt(); case 2: - return new FishPrompt(); + return new TameListPrompt(); case 3: - return new CowsPrompt(); + return new FishPrompt(); case 4: - return new TameListPrompt(); + return new CowsPrompt(); case 5: return new ShearListPrompt(); case 6: diff --git a/main/src/main/java/me/blackvein/quests/listeners/NpcListener.java b/main/src/main/java/me/blackvein/quests/listeners/NpcListener.java index a5c48a860..b804bf0ed 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/NpcListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/NpcListener.java @@ -56,6 +56,10 @@ public class NpcListener implements Listener { @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOWEST) public void onNPCRightClick(NPCRightClickEvent evt) { + if (plugin.getDependencies().getCitizens() == null) { + // Ensure that Citizens is linked (may not be if it loads after Quests) + return; + } if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) { evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID " + evt.getNPC().getId()); @@ -300,6 +304,10 @@ public class NpcListener implements Listener { @EventHandler public void onNPCLeftClick(NPCLeftClickEvent evt) { + if (plugin.getDependencies().getCitizens() == null) { + // Ensure that Citizens is linked (may not be if it loads after Quests) + return; + } if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) { evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + Lang.get("id") + " " + evt.getNPC().getId()); @@ -308,6 +316,10 @@ public class NpcListener implements Listener { @EventHandler public void onNPCDeath(NPCDeathEvent evt) { + if (plugin.getDependencies().getCitizens() == null) { + // Ensure that Citizens is linked (may not be if it loads after Quests) + return; + } if (evt.getNPC() == null || evt.getNPC().getEntity() == null || evt.getNPC().getEntity().getLastDamageCause() == null) { return;