Check whether Citizens is loaded for Kill Mobs, fixes #267

This commit is contained in:
HappyPikachu 2018-02-07 13:10:42 -05:00
parent 87c0316ce7
commit e014697010

View File

@ -479,8 +479,8 @@ public class PlayerListener implements Listener {
}
/**
* Checks if damager is blacklisted
* Ensures damager is Player and not NPC
* Checks if damager is blacklisted.
* Ensures damager is Player and not NPC.
* Kills target mob/NPC if objective exists
*
* @param damager the attacking entity
@ -491,9 +491,8 @@ public class PlayerListener implements Listener {
if (plugin.checkQuester(damager.getUniqueId()) == true) {
return;
}
//Ensure damager is Player AND not an NPC
if (damager instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(damager)) {
//If target is an NPC...
if (damager instanceof Player) {
if (plugin.citizens != null) {
if (CitizensAPI.getNPCRegistry().isNPC(target)) {
Quester quester = plugin.getQuester(damager.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
@ -501,8 +500,9 @@ public class PlayerListener implements Listener {
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
}
}
//No? Must be a mob...
} else {
return;
}
}
Quester quester = plugin.getQuester(damager.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killMob")) {
@ -511,7 +511,6 @@ public class PlayerListener implements Listener {
}
}
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent evt) {