diff --git a/pom.xml b/pom.xml index 50e8e2f..3c509f7 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.mcmonkey sentinel jar - 1.3.1 + 1.3.2 Sentinel Combat NPCs for Spigot @@ -115,6 +115,16 @@ + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + https://github.com/mcmonkey4eva/Sentinel diff --git a/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java b/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java index 2f321b9..8f17375 100644 --- a/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java +++ b/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java @@ -30,6 +30,7 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.scheduler.BukkitRunnable; @@ -1460,6 +1461,9 @@ public boolean isRegexTargeted(String name, List regexes) { } public boolean isIgnored(LivingEntity entity) { + if (entity.hasPotionEffect(PotionEffectType.INVISIBILITY)) { + return true; + } if (entity.hasMetadata("NPC")) { return ignores.contains(SentinelTarget.NPCS.name()) || isRegexTargeted(CitizensAPI.getNPCRegistry().getNPC(entity).getName(), npcNameIgnores); @@ -1520,6 +1524,9 @@ && isRegexTargeted(entity.getEquipment().getItemInHand().getType().name(), heldI } public boolean isTargeted(LivingEntity entity) { + if (entity.hasPotionEffect(PotionEffectType.INVISIBILITY)) { + return false; + } SentinelCurrentTarget target = new SentinelCurrentTarget(); target.targetID = entity.getUniqueId(); if (entity.getUniqueId().equals(getLivingEntity().getUniqueId())) { @@ -1636,6 +1643,10 @@ private void updateTargets() { currentTargets.remove(uuid); continue; } + if (e instanceof LivingEntity && ((LivingEntity) e).hasPotionEffect(PotionEffectType.INVISIBILITY)) { + currentTargets.remove(uuid); + continue; + } if (e.isDead()) { currentTargets.remove(uuid); continue; @@ -1654,6 +1665,14 @@ private void updateTargets() { } } } + if (chasing != null) { + SentinelCurrentTarget cte = new SentinelCurrentTarget(); + cte.targetID = chasing.getUniqueId(); + if (!currentTargets.contains(cte)) { + chasing = null; + npc.getNavigator().cancelNavigation(); + } + } } int cleverTicks = 0; @@ -1753,6 +1772,9 @@ else if(chasing != null && chasing.isValid()) { chased = false; } else { + if (npc.getNavigator().getEntityTarget() != null) { + npc.getNavigator().cancelNavigation(); + } if (SentinelPlugin.debugMe) { if (near != null && near.distanceSquared(getLivingEntity().getLocation()) > 3 * 3) { SentinelPlugin.instance.getLogger().info("Sentinel: I'll just stand here and hope they come out..."); @@ -1760,6 +1782,9 @@ else if(chasing != null && chasing.isValid()) { } } } + else if (chasing == null && npc.getNavigator().getEntityTarget() != null) { + npc.getNavigator().cancelNavigation(); + } } private final static double MAX_DIST = 100000000;