Skip to content
Permalink
Browse files

Add held item material name targets

Careful, it's case sensitive!
  • Loading branch information...
mcmonkey4eva committed Mar 27, 2016
1 parent 3c6c714 commit adb17c5a88335434dae3d8bc39202025b4160b00
@@ -50,11 +50,10 @@ Created by mcmonkey4eva on behalf of the Citizens and Denizen teams.
- Mounting:
- Ride a horse or whatever other NPC
- maybe support this in base Citizens rather than Sentinel?
- Targets:
- Items (EG, "Sword" or "Diamond_Sword") being held: `helditem:ITEM_MATERIAL_NAME` (Regex!)
- Commands:
- `/sentinel stats`
- `/sentinel fightback`
- maybe `/sentinel targets` separate from `info`
- Other:
- old Sentry saves importer?

@@ -91,6 +91,9 @@ else if (info[0].equalsIgnoreCase("npc")) {
else if (info[0].equalsIgnoreCase("entityname")) {
names = sentinel.entityNameTargets;
}
else if (info[0].equalsIgnoreCase("helditem")) {
names = sentinel.heldItemTargets;
}
try {
if ("Sentinel".matches(info[1])) {
ignoreMe++;
@@ -117,7 +120,7 @@ else if (info[0].equalsIgnoreCase("entityname")) {
valid.append(poss.name()).append(", ");
}
sender.sendMessage(prefixGood + "Valid targets: " + valid.substring(0, valid.length() - 2));
sender.sendMessage(prefixGood + "Also allowed: player:NAME(REGEX), npc:NAME(REGEX), entityname:NAME(REGEX)");
sender.sendMessage(prefixGood + "Also allowed: player:NAME(REGEX), npc:NAME(REGEX), entityname:NAME(REGEX), helditem:MATERIALNAME(REGEX)");
}
else {
if (sentinel.targets.add(target)) {
@@ -144,6 +147,9 @@ else if (info[0].equalsIgnoreCase("npc")) {
else if (info[0].equalsIgnoreCase("entityname")) {
names = sentinel.entityNameTargets;
}
else if (info[0].equalsIgnoreCase("helditem")) {
names = sentinel.heldItemTargets;
}
try {
if ("Sentinel".matches(info[1])) {
ignoreMe++;
@@ -164,7 +170,7 @@ else if (info[0].equalsIgnoreCase("entityname")) {
}
}
sender.sendMessage(prefixBad + "Invalid target!");
sender.sendMessage(prefixGood + "See '/sentinel addtarget' to view valid targets!");
sender.sendMessage(prefixGood + "See '/sentinel addtarget help' to view valid targets!");
}
else {
if (sentinel.targets.remove(target)) {
@@ -191,6 +197,9 @@ else if (info[0].equalsIgnoreCase("npc")) {
else if (info[0].equalsIgnoreCase("entityname")) {
names = sentinel.entityNameIgnores;
}
else if (info[0].equalsIgnoreCase("helditem")) {
names = sentinel.heldItemIgnores;
}
try {
if ("Sentinel".matches(info[1])) {
ignoreMe++;
@@ -212,7 +221,7 @@ else if (info[0].equalsIgnoreCase("entityname")) {
}
}
sender.sendMessage(prefixBad + "Invalid ignore target!");
sender.sendMessage(prefixGood + "See '/sentinel addtarget' to view valid targets!");
sender.sendMessage(prefixGood + "See '/sentinel addtarget help' to view valid targets!");
}
else {
if (sentinel.ignores.add(target)) {
@@ -239,6 +248,9 @@ else if (info[0].equalsIgnoreCase("npc")) {
else if (info[0].equalsIgnoreCase("entityname")) {
names = sentinel.entityNameIgnores;
}
else if (info[0].equalsIgnoreCase("helditem")) {
names = sentinel.heldItemIgnores;
}
try {
if ("Sentinel".matches(info[1])) {
ignoreMe++;
@@ -259,7 +271,7 @@ else if (info[0].equalsIgnoreCase("entityname")) {
}
}
sender.sendMessage(prefixBad + "Invalid ignore target!");
sender.sendMessage(prefixGood + "See '/sentinel addtarget' to view valid targets!");
sender.sendMessage(prefixGood + "See '/sentinel addtarget help' to view valid targets!");
}
else {
if (sentinel.ignores.remove(target)) {
@@ -368,10 +380,12 @@ else if (arg0.equals("info") && sender.hasPermission("sentinel.info")) {
sender.sendMessage(prefixGood + "Player Name Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.playerNameTargets));
sender.sendMessage(prefixGood + "NPC Name Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.npcNameTargets));
sender.sendMessage(prefixGood + "Entity Name Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.entityNameTargets));
sender.sendMessage(prefixGood + "Held Item Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.heldItemTargets));
sender.sendMessage(prefixGood + "Ignored Targets: " + ChatColor.AQUA + getTargetString(sentinel.ignores));
sender.sendMessage(prefixGood + "Ignored Player Name Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.playerNameIgnores));
sender.sendMessage(prefixGood + "Ignored NPC Name Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.npcNameIgnores));
sender.sendMessage(prefixGood + "Ignored Entity Name Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.entityNameIgnores));
sender.sendMessage(prefixGood + "Ignored Held Item Targets: " + ChatColor.AQUA + getNameTargetString(sentinel.heldItemIgnores));
sender.sendMessage(prefixGood + "Damage: " + ChatColor.AQUA + sentinel.damage);
sender.sendMessage(prefixGood + "Armor: " + ChatColor.AQUA + sentinel.armor);
sender.sendMessage(prefixGood + "Health: " + ChatColor.AQUA +
@@ -71,6 +71,12 @@ public SentinelTrait() {
@Persist("entityNameIgnores")
public List<String> entityNameIgnores = new ArrayList<String>();

@Persist("heldItemTargets")
public List<String> heldItemTargets = new ArrayList<String>();

@Persist("heldItemIgnores")
public List<String> heldItemIgnores = new ArrayList<String>();

@Persist("range")
public double range = 20;

@@ -421,6 +427,10 @@ else if (isRegexTargeted(entity.getCustomName() == null ? entity.getType().name(
return true;
}
}
if (entity.getEquipment() != null && entity.getEquipment().getItemInMainHand() != null
&& isRegexTargeted(entity.getEquipment().getItemInMainHand().getType().name(), heldItemIgnores)) {
return true;
}
return false;
}

@@ -446,6 +456,10 @@ else if (isRegexTargeted(entity.getCustomName() == null ? entity.getType().name(
return true;
}
}
if (entity.getEquipment() != null && entity.getEquipment().getItemInMainHand() != null
&& isRegexTargeted(entity.getEquipment().getItemInMainHand().getType().name(), heldItemTargets)) {
return true;
}
return false;
}

0 comments on commit adb17c5

Please sign in to comment.
You can’t perform that action at this time.