mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 07:05:51 +01:00
Check for Citizens prior to player death, fixes #886
This commit is contained in:
parent
b1a42e4426
commit
1e29ad1436
@ -3280,11 +3280,22 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if player can use Quests
|
||||||
|
*
|
||||||
|
* @param uuid the entity UUID to be checked
|
||||||
|
* @return {@code true} if entity is a Player that has permission
|
||||||
|
*/
|
||||||
|
public boolean canUseQuests(UUID uuid) {
|
||||||
|
return !checkQuester(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if player CANNOT use Quests
|
* Checks if player CANNOT use Quests
|
||||||
*
|
*
|
||||||
* @param uuid the entity UUID to be checked
|
* @param uuid the entity UUID to be checked
|
||||||
* @return {@code true} if entity has no permission or is not a player
|
* @return {@code true} if entity has no permission or is not a player
|
||||||
|
* @deprecated Use #canUseQuests
|
||||||
*/
|
*/
|
||||||
public boolean checkQuester(UUID uuid) {
|
public boolean checkQuester(UUID uuid) {
|
||||||
if (!(Bukkit.getPlayer(uuid) instanceof Player)) {
|
if (!(Bukkit.getPlayer(uuid) instanceof Player)) {
|
||||||
|
@ -703,7 +703,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if damager is blacklisted. Ensures damager is Player and not NPC. Kills target Player if objective exists
|
* Checks if damager is blacklisted. Ensures damager and target are Player and not NPC. Kills target Player if objective exists
|
||||||
*
|
*
|
||||||
* @param damager the attacking entity
|
* @param damager the attacking entity
|
||||||
* @param target the entity being attacked
|
* @param target the entity being attacked
|
||||||
@ -713,10 +713,12 @@ public class PlayerListener implements Listener {
|
|||||||
if (plugin.checkQuester(damager.getUniqueId()) == true) {
|
if (plugin.checkQuester(damager.getUniqueId()) == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Ensure damager is player AND not an NPC
|
if (damager instanceof Player && target instanceof Player) {
|
||||||
if (damager instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(damager)) {
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
//If target is player AND not an NPC...
|
if (CitizensAPI.getNPCRegistry().isNPC(damager) && CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||||
if (target instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(target)) {
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
Quester quester = plugin.getQuester(damager.getUniqueId());
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||||
if (quester.containsObjective(quest, "killPlayer")) {
|
if (quester.containsObjective(quest, "killPlayer")) {
|
||||||
@ -725,7 +727,6 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerFish(PlayerFishEvent evt) {
|
public void onPlayerFish(PlayerFishEvent evt) {
|
||||||
|
Loading…
Reference in New Issue
Block a user