Skip to content

Commit

Permalink
Don't target oneself, able to target NPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 27, 2016
1 parent 60bb240 commit 4a9a1ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -53,8 +53,8 @@ Created by mcmonkey4eva on behalf of the Citizens and Denizen teams.
- Targets:
- Player by name: `player:NAME`
- NPC by name: `npc:NAME`
- NPCs in general: `npcs`
- Items (EG, "Sword" or "Diamond_Sword") being held: `helditem:ITEM_MATERIAL_NAME`
- The NPC's owner (For easy ignoring, default ignore status!) `OWNER`
- Commands:
- `/sentinel stats`

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/mcmonkey/sentinel/SentinelTarget.java
Expand Up @@ -5,6 +5,7 @@
import java.util.HashSet;

public enum SentinelTarget {
NPCS(new EntityType[] {}, "NPC"),
PASSIVE_MOB(new EntityType[] {
EntityType.PIG, EntityType.OCELOT, EntityType.COW, EntityType.RABBIT, EntityType.SHEEP, EntityType.CHICKEN, EntityType.MUSHROOM_COW,
EntityType.HORSE, EntityType.IRON_GOLEM, EntityType.SQUID, EntityType.VILLAGER, EntityType.WOLF, EntityType.SNOWMAN},
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/mcmonkey/sentinel/SentinelTrait.java
Expand Up @@ -365,6 +365,12 @@ public boolean usesPotion() {
}

public boolean shouldTarget(LivingEntity entity) {
if (entity.getUniqueId().equals(getLivingEntity().getUniqueId())) {
return false;
}
if (entity.hasMetadata("NPC")) {
return targets.contains(SentinelTarget.NPCS);
}
return isTargeted(entity) && !isIgnored(entity);
}

Expand Down

0 comments on commit 4a9a1ac

Please sign in to comment.