Skip to content
Permalink
Browse files

add protected option, fixes #97

  • Loading branch information...
mcmonkey4eva committed Nov 26, 2016
1 parent 653558c commit 44c446697f9d474887e048efcdef6dbb1f8cf403
@@ -70,7 +70,7 @@ public void onEnable() {
instance = this;
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SentinelTrait.class).withName("sentinel"));
saveDefaultConfig();
if (getConfig().getInt("config version", 0) != 6) {
if (getConfig().getInt("config version", 0) != 7) {
getLogger().warning("Outdated Sentinel config - please delete it to regenerate it!");
}
BukkitRunnable postLoad = new BukkitRunnable() {
@@ -283,6 +283,10 @@ public void whenAttacksHappened(EntityDamageByEntityEvent event) {
return;
}
boolean isMe = event.getEntity().getUniqueId().equals(getLivingEntity().getUniqueId());
if (sentinelProtected && isMe && event.getDamager() instanceof LivingEntity && isIgnored((LivingEntity) event.getDamager())) {
event.setCancelled(true);
return;
}
boolean isFriend = getGuarding() != null && event.getEntity().getUniqueId().equals(getGuarding());
if (isMe || isFriend) {
if (isMe) {
@@ -364,6 +368,8 @@ public void whenAnEnemyDies(EntityDeathEvent event) {
currentTargets.remove(target);
}

private boolean sentinelProtected;

@Override
public void onAttach() {
FileConfiguration config = SentinelPlugin.instance.getConfig();
@@ -391,6 +397,7 @@ public void onAttach() {
}
autoswitch = config.getBoolean("sentinel defaults.autoswitch", false);
ignores.add(SentinelTarget.OWNER);
sentinelProtected = config.getBoolean("random.protected", false);
}

public void useItem() {
@@ -50,9 +50,11 @@ random:
shoot speed minimum: 20
# Whether to force damage through (particularly for ranged attacks).
enforce damage: false
# Whether NPCs are protected from damage by ignore targets.
protected: false

# How fast to recalculate, in ticks.
update rate: 10

# Do not touch!
config version: 6
# Do not touch! (Unless you know what you're doing!)
config version: 7

0 comments on commit 44c4466

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