Skip to content
Permalink
Browse files

Add /sentinel safeshot

Protect your friends!
  • Loading branch information...
mcmonkey4eva committed Mar 30, 2016
1 parent 1731630 commit ff86adc784ca03f4ee89413bddacab5ba3968201
@@ -440,6 +440,16 @@ else if (arg0.equals("needammo") && sender.hasPermission("sentinel.needammo")) {
}
return true;
}
else if (arg0.equals("safeshot") && sender.hasPermission("sentinel.safeshot")) {
sentinel.safeShot = !sentinel.safeShot;
if (sentinel.safeShot) {
sender.sendMessage(prefixGood + "NPC now is a safe shot!");
}
else {
sender.sendMessage(prefixGood + "NPC is no longer a safe shot!");
}
return true;
}
else if (arg0.equals("chaseclose") && sender.hasPermission("sentinel.chase")) {
sentinel.closeChase = !sentinel.closeChase;
if (sentinel.closeChase) {
@@ -507,6 +517,7 @@ else if (arg0.equals("info") && sender.hasPermission("sentinel.info")) {
sender.sendMessage(prefixGood + "Fightback Enabled: " + ChatColor.AQUA + sentinel.fightback);
sender.sendMessage(prefixGood + "Ranged Chasing Enabled: " + ChatColor.AQUA + sentinel.rangedChase);
sender.sendMessage(prefixGood + "Close-Quarters Chasing Enabled: " + ChatColor.AQUA + sentinel.closeChase);
sender.sendMessage(prefixGood + "Safe-Shot Enabled: " + ChatColor.AQUA + sentinel.safeShot);
return true;
}
else if (arg0.equals("stats") && sender.hasPermission("sentinel.info")) {
@@ -534,11 +545,12 @@ else if (arg0.equals("stats") && sender.hasPermission("sentinel.info")) {
if (sender.hasPermission("sentinel.health")) sender.sendMessage(prefixGood + "/sentinel health HEALTH - Sets the NPC's health level.");
if (sender.hasPermission("sentinel.attackrate")) sender.sendMessage(prefixGood + "/sentinel attackrate RATE - Changes the rate at which the NPC attacks, in ticks.");
if (sender.hasPermission("sentinel.healrate")) sender.sendMessage(prefixGood + "/sentinel healrate RATE - Changes the rate at which the NPC heals, in ticks.");
if (sender.hasPermission("sentinel.healrate")) sender.sendMessage(prefixGood + "/sentinel respawntime TIME - Changes the time it takes for the NPC to respawn, in ticks.");
if (sender.hasPermission("sentinel.respawntime")) sender.sendMessage(prefixGood + "/sentinel respawntime TIME - Changes the time it takes for the NPC to respawn, in ticks.");
if (sender.hasPermission("sentinel.guard")) sender.sendMessage(prefixGood + "/sentinel guard [PLAYERNAME] - Makes the NPC guard a specific player. Don't specify a player to stop guarding.");
if (sender.hasPermission("sentinel.invincible")) sender.sendMessage(prefixGood + "/sentinel invincible - Toggles whether the NPC is invincible.");
if (sender.hasPermission("sentinel.fightback")) sender.sendMessage(prefixGood + "/sentinel fightback - Toggles whether the NPC will fight back.");
if (sender.hasPermission("sentinel.needammo")) sender.sendMessage(prefixGood + "/sentinel needammo - Toggles whether the NPC will need ammo.");
if (sender.hasPermission("sentinel.safeshot")) sender.sendMessage(prefixGood + "/sentinel safeshot - Toggles whether the NPC will avoid damaging non-targets.");
if (sender.hasPermission("sentinel.chase")) sender.sendMessage(prefixGood + "/sentinel chaseclose - Toggles whether the NPC will chase while in 'close quarters' fights.");
if (sender.hasPermission("sentinel.chase")) sender.sendMessage(prefixGood + "/sentinel chaseranged - Toggles whether the NPC will chase while in ranged fights.");
if (sender.hasPermission("sentinel.info")) sender.sendMessage(prefixGood + "/sentinel info - Shows info on the current NPC.");
@@ -137,6 +137,9 @@ public SentinelTrait() {
@Persist("needsAmmo")
public boolean needsAmmo = false;

@Persist("safeShot")
public boolean safeShot = true;

@Persist("respawnTime")
public long respawnTime = 100;

@@ -201,6 +204,10 @@ else if (event.getDamager() instanceof Projectile) {
return;
}
if (event.getDamager().getUniqueId().equals(getLivingEntity().getUniqueId())) {
if (safeShot && !shouldTarget((LivingEntity) event.getEntity())) {
event.setCancelled(true);
return;
}
stats_damageGiven += event.getFinalDamage();
return;
}
@@ -211,7 +218,12 @@ else if (event.getDamager() instanceof Projectile) {
if (source instanceof LivingEntity) {
e = (LivingEntity) source;
if (e.getUniqueId().equals(getLivingEntity().getUniqueId())) {
if (safeShot && !shouldTarget((LivingEntity) event.getEntity())) {
event.setCancelled(true);
return;
}
stats_damageGiven += event.getFinalDamage();
return;
}
}
}
@@ -240,6 +252,8 @@ public void onAttach() {
}
setInvincible(config.getBoolean("sentinel defaults.invincible", false));
fightback = config.getBoolean("sentinel defaults.fightback", true);
needsAmmo = config.getBoolean("sentinel defaults.needs ammo", false);
safeShot = config.getBoolean("sentinel defaults.safe shot", true);
ignores.add(SentinelTarget.OWNER);
}

@@ -22,6 +22,8 @@ sentinel defaults:
fightback: true
# Whether this NPC needs ammo to fight with.
needs ammo: false
# Whether the NPC will avoiding damaging non-targets.
safe shot: true
# Default respawn time, in ticks.
respawn time: 100

@@ -47,6 +47,8 @@ permissions:
sentinel.fightback: true
# /sentinel needammo
sentinel.needammo: true
# /sentinel safeshot
sentinel.safeshot: true
# /sentinel chaseclose, chaseranged
sentinel.chase: true
# /sentinel info, /sentinel targets, /sentinel stats

0 comments on commit ff86adc

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