Ensure Citizens is enabled when processing events, fixes #1146

This commit is contained in:
PikaMug 2020-03-28 15:10:02 -04:00
parent cf4a1a7303
commit 5d846c7670
2 changed files with 34 additions and 22 deletions

View File

@ -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");
case 3:
return ChatColor.YELLOW + Lang.get("stageEditorMilkCows");
case 4:
return ChatColor.YELLOW + Lang.get("stageEditorTameMobs");
case 3:
return ChatColor.YELLOW + Lang.get("stageEditorCatchFish");
case 4:
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();
case 3:
return new CowsPrompt();
case 4:
return new TameListPrompt();
case 3:
return new FishPrompt();
case 4:
return new CowsPrompt();
case 5:
return new ShearListPrompt();
case 6:

View File

@ -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;