Skip to content

Commit

Permalink
Sentinel 1.3.2: Sneaky update!
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 29, 2017
1 parent f002e13 commit b555aec
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>org.mcmonkey</groupId>
<artifactId>sentinel</artifactId>
<packaging>jar</packaging>
<version>1.3.1</version>
<version>1.3.2</version>
<name>Sentinel</name>
<description>Combat NPCs for Spigot</description>

Expand Down Expand Up @@ -115,6 +115,16 @@
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>

<url>https://github.com/mcmonkey4eva/Sentinel</url>
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/org/mcmonkey/sentinel/SentinelTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1460,6 +1461,9 @@ public boolean isRegexTargeted(String name, List<String> 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);
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -1753,13 +1772,19 @@ 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...");
}
}
}
}
else if (chasing == null && npc.getNavigator().getEntityTarget() != null) {
npc.getNavigator().cancelNavigation();
}
}

private final static double MAX_DIST = 100000000;
Expand Down

0 comments on commit b555aec

Please sign in to comment.