summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorementalo <ementalodev@gmx.co.uk>2012-10-13 19:40:55 +0100
committerementalo <ementalodev@gmx.co.uk>2012-10-13 19:40:55 +0100
commiteca8b54ef595e543c5ba9a94cc1b62e0c62a64d4 (patch)
tree73d7dbe23331b56179541efe1a0390c377634fc1
parent590430fcec682b190d6ab1f697cbf10c42623fbc (diff)
downloadEssentials-eca8b54ef595e543c5ba9a94cc1b62e0c62a64d4.tar
Essentials-eca8b54ef595e543c5ba9a94cc1b62e0c62a64d4.tar.gz
Essentials-eca8b54ef595e543c5ba9a94cc1b62e0c62a64d4.tar.lz
Essentials-eca8b54ef595e543c5ba9a94cc1b62e0c62a64d4.tar.xz
Essentials-eca8b54ef595e543c5ba9a94cc1b62e0c62a64d4.zip
entity target bypass protect permission split out to essentials.protect.entity.bypass.entityname for per entity settings
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java11
-rw-r--r--EssentialsProtect/src/net/ess3/protect/Permissions.java6
2 files changed, 13 insertions, 4 deletions
diff --git a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
index 5bde19973..7b3b8dc9d 100644
--- a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
@@ -190,7 +190,13 @@ public class EssentialsProtectEntityListener implements Listener
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(final EntityTargetEvent event)
{
- if (event.getTarget().getType() == EntityType.PLAYER)
+ final Entity entity = event.getTarget();
+ if(entity == null)
+ {
+ return;
+ }
+
+ if (entity.getType() == EntityType.PLAYER)
{
final Player user = (Player)event.getTarget();
if ((event.getReason() == TargetReason.CLOSEST_PLAYER
@@ -199,7 +205,8 @@ public class EssentialsProtectEntityListener implements Listener
|| event.getReason() == TargetReason.RANDOM_TARGET
|| event.getReason() == TargetReason.TARGET_ATTACKED_OWNER
|| event.getReason() == TargetReason.OWNER_ATTACKED_TARGET)
- && Permissions.ENTITYTARGET.isAuthorized(user))
+ && !prot.getSettings().getData().getPrevent().isEntitytarget()
+ && !Permissions.ENTITY_TARGET_BYPASS.isAuthorized(user, event.getEntity().getType().getName().toLowerCase()))
{
event.setCancelled(true);
}
diff --git a/EssentialsProtect/src/net/ess3/protect/Permissions.java b/EssentialsProtect/src/net/ess3/protect/Permissions.java
index 5edde818e..6226fdf7f 100644
--- a/EssentialsProtect/src/net/ess3/protect/Permissions.java
+++ b/EssentialsProtect/src/net/ess3/protect/Permissions.java
@@ -3,13 +3,13 @@ package net.ess3.protect;
import java.util.Locale;
import net.ess3.api.IPermission;
import net.ess3.bukkit.PermissionFactory;
+import net.ess3.permissions.DotStarPermission;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
public enum Permissions implements IPermission
-{
- ENTITYTARGET(PermissionDefault.TRUE),
+{
PVP(PermissionDefault.TRUE),
PREVENTDAMAGE_FALL(PermissionDefault.FALSE),
PREVENTDAMAGE_CREEPER(PermissionDefault.FALSE),
@@ -70,4 +70,6 @@ public enum Permissions implements IPermission
{
return PermissionFactory.checkPermission(sender, this);
}
+
+ public static DotStarPermission ENTITY_TARGET_BYPASS = new DotStarPermission("essentials.protect.entitytarget.bypass");
}