summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect
diff options
context:
space:
mode:
authorsnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-15 12:10:24 +0000
committersnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-15 12:10:24 +0000
commitf2f6c3fdaa06f7d01c527af64a1b3ca723df62c2 (patch)
tree0e9a4cd65489b22b5f34e32bdbacb9d280a081dd /EssentialsProtect
parent36520c5e2789501e23f36366fd83a5919ec8aa20 (diff)
downloadEssentials-f2f6c3fdaa06f7d01c527af64a1b3ca723df62c2.tar
Essentials-f2f6c3fdaa06f7d01c527af64a1b3ca723df62c2.tar.gz
Essentials-f2f6c3fdaa06f7d01c527af64a1b3ca723df62c2.tar.lz
Essentials-f2f6c3fdaa06f7d01c527af64a1b3ca723df62c2.tar.xz
Essentials-f2f6c3fdaa06f7d01c527af64a1b3ca723df62c2.zip
Added permissions to bypass EssentialsProtect damage protection.
As admin you want to disable this with - -essentials.protect.damage.* New permissions: essentials.protect.damage.contact essentials.protect.damage.lava essentials.protect.damage.tnt essentials.protect.damage.creeper essentials.protect.damage.projectiles essentials.protect.damage.fall essentials.protect.damage.suffocation essentials.protect.damage.fire essentials.protect.damage.drowning essentials.protect.damage.lightning git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1476 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'EssentialsProtect')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java113
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java1
2 files changed, 71 insertions, 43 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
index 4ded17f70..fa61b5b83 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
@@ -43,22 +43,31 @@ public class EssentialsProtectEntityListener extends EntityListener
@Override
public void onEntityDamage(EntityDamageEvent event)
{
- if (event.isCancelled()) return;
+ if (event.isCancelled())
+ {
+ return;
+ }
if (event instanceof EntityDamageByBlockEvent)
{
DamageCause cause = event.getCause();
- if (EssentialsProtect.playerSettings.get("protect.disable.contactdmg") && cause == DamageCause.CONTACT)
+ if (EssentialsProtect.playerSettings.get("protect.disable.contactdmg") && cause == DamageCause.CONTACT
+ && !(event.getEntity() instanceof Player
+ && Essentials.getStatic().getUser(event.getEntity()).isAuthorized("essentials.protect.damage.contact")))
{
event.setCancelled(true);
return;
}
- if (EssentialsProtect.playerSettings.get("protect.disable.lavadmg") && cause == DamageCause.LAVA)
+ if (EssentialsProtect.playerSettings.get("protect.disable.lavadmg") && cause == DamageCause.LAVA
+ && !(event.getEntity() instanceof Player
+ && Essentials.getStatic().getUser(event.getEntity()).isAuthorized("essentials.protect.damage.lava")))
{
event.setCancelled(true);
return;
}
- if (EssentialsProtect.guardSettings.get("protect.prevent.tnt-explosion") && cause == DamageCause.BLOCK_EXPLOSION)
+ if (EssentialsProtect.guardSettings.get("protect.prevent.tnt-explosion") && cause == DamageCause.BLOCK_EXPLOSION
+ && !(event.getEntity() instanceof Player
+ && Essentials.getStatic().getUser(event.getEntity()).isAuthorized("essentials.protect.damage.tnt")))
{
event.setCancelled(true);
return;
@@ -89,13 +98,17 @@ public class EssentialsProtectEntityListener extends EntityListener
//Creeper explode prevention
if (eAttack != null && eAttack instanceof Monster)
{
- if (eAttack instanceof Creeper && EssentialsProtect.guardSettings.get("protect.prevent.creeper-explosion"))
+ if (eAttack instanceof Creeper && EssentialsProtect.guardSettings.get("protect.prevent.creeper-explosion")
+ && !(event.getEntity() instanceof Player
+ && Essentials.getStatic().getUser(event.getEntity()).isAuthorized("essentials.protect.damage.creeper")))
{
event.setCancelled(true);
return;
}
- if (eAttack instanceof Creeper && EssentialsProtect.guardSettings.get("protect.prevent.creeper-playerdamage"))
+ if (eAttack instanceof Creeper && EssentialsProtect.guardSettings.get("protect.prevent.creeper-playerdamage")
+ && !(event.getEntity() instanceof Player
+ && Essentials.getStatic().getUser(event.getEntity()).isAuthorized("essentials.protect.damage.creeper")))
{
event.setCancelled(true);
return;
@@ -105,40 +118,47 @@ public class EssentialsProtectEntityListener extends EntityListener
if (event instanceof EntityDamageByProjectileEvent)
{
- if (event.getEntity() instanceof Player)
+ if (event.getEntity() instanceof Player
+ && EssentialsProtect.playerSettings.get("protect.disable.projectiles")
+ && !Essentials.getStatic().getUser(event.getEntity()).isAuthorized("essentials.protect.damage.projectiles"))
{
- event.setCancelled(EssentialsProtect.playerSettings.get("protect.disable.projectiles"));
+ event.setCancelled(true);
return;
}
}
-
+
DamageCause cause = event.getCause();
Entity casualty = event.getEntity();
if (casualty instanceof Player)
{
- if (EssentialsProtect.playerSettings.get("protect.disable.fall") && cause == DamageCause.FALL)
+ if (EssentialsProtect.playerSettings.get("protect.disable.fall") && cause == DamageCause.FALL
+ && !(Essentials.getStatic().getUser(casualty).isAuthorized("essentials.protect.damage.fall")))
{
event.setCancelled(true);
return;
}
- if (EssentialsProtect.playerSettings.get("protect.disable.suffocate") && cause == DamageCause.SUFFOCATION)
+ if (EssentialsProtect.playerSettings.get("protect.disable.suffocate") && cause == DamageCause.SUFFOCATION
+ && !(Essentials.getStatic().getUser(casualty).isAuthorized("essentials.protect.damage.suffocation")))
{
event.setCancelled(true);
return;
}
if (EssentialsProtect.playerSettings.get("protect.disable.firedmg") && (cause == DamageCause.FIRE
- || cause == DamageCause.FIRE_TICK))
+ || cause == DamageCause.FIRE_TICK)
+ && !(Essentials.getStatic().getUser(casualty).isAuthorized("essentials.protect.damage.fire")))
{
event.setCancelled(true);
return;
}
- if (EssentialsProtect.playerSettings.get("protect.disable.drown") && cause == DamageCause.DROWNING)
+ if (EssentialsProtect.playerSettings.get("protect.disable.drown") && cause == DamageCause.DROWNING
+ && !(Essentials.getStatic().getUser(casualty).isAuthorized("essentials.protect.damage.drowning")))
{
event.setCancelled(true);
return;
}
- if (EssentialsProtect.playerSettings.get("protect.disable.lightning") && cause == DamageCause.LIGHTNING)
+ if (EssentialsProtect.playerSettings.get("protect.disable.lightning") && cause == DamageCause.LIGHTNING
+ && !(Essentials.getStatic().getUser(casualty).isAuthorized("essentials.protect.damage.lightning")))
{
event.setCancelled(true);
return;
@@ -149,7 +169,10 @@ public class EssentialsProtectEntityListener extends EntityListener
@Override
public void onEntityExplode(EntityExplodeEvent event)
{
- if (event.isCancelled()) return;
+ if (event.isCancelled())
+ {
+ return;
+ }
if (event.getEntity() instanceof LivingEntity)
{
//Nicccccccccce plaaacccccccccce..
@@ -183,7 +206,7 @@ public class EssentialsProtectEntityListener extends EntityListener
}
((CraftServer)parent.getServer()).getHandle().a(loc.getX(), loc.getY(), loc.getZ(), 64.0D,
- new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set));
+ new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set));
event.setCancelled(true);
return;
}
@@ -205,20 +228,21 @@ public class EssentialsProtectEntityListener extends EntityListener
event.setCancelled(true);
return;
}
- if (( block.getType() == Material.WALL_SIGN ||
- block.getFace(BlockFace.NORTH).getType() == Material.WALL_SIGN ||
- block.getFace(BlockFace.EAST).getType() == Material.WALL_SIGN ||
- block.getFace(BlockFace.SOUTH).getType() == Material.WALL_SIGN ||
- block.getFace(BlockFace.WEST).getType() == Material.WALL_SIGN ||
- block.getType() == Material.SIGN_POST ||
- block.getFace(BlockFace.UP).getType() == Material.SIGN_POST) &&
- EssentialsProtect.genSettings.get("protect.protect.signs"))
+ if ((block.getType() == Material.WALL_SIGN
+ || block.getFace(BlockFace.NORTH).getType() == Material.WALL_SIGN
+ || block.getFace(BlockFace.EAST).getType() == Material.WALL_SIGN
+ || block.getFace(BlockFace.SOUTH).getType() == Material.WALL_SIGN
+ || block.getFace(BlockFace.WEST).getType() == Material.WALL_SIGN
+ || block.getType() == Material.SIGN_POST
+ || block.getFace(BlockFace.UP).getType() == Material.SIGN_POST)
+ && EssentialsProtect.genSettings.get("protect.protect.signs"))
{
event.setCancelled(true);
return;
}
- if ( EssentialsBlockListener.protectedBlocks.contains(block.getType()) &&
- EssentialsBlockListener.isBlockProtected(block)) {
+ if (EssentialsBlockListener.protectedBlocks.contains(block.getType())
+ && EssentialsBlockListener.isBlockProtected(block))
+ {
event.setCancelled(true);
return;
}
@@ -228,8 +252,14 @@ public class EssentialsProtectEntityListener extends EntityListener
@Override
public void onCreatureSpawn(CreatureSpawnEvent event)
{
- if (event.getEntity() instanceof CraftPlayer) return;
- if (event.isCancelled()) return;
+ if (event.getEntity() instanceof CraftPlayer)
+ {
+ return;
+ }
+ if (event.isCancelled())
+ {
+ return;
+ }
String creatureName = event.getCreatureType().toString().toLowerCase();
if (creatureName == null || creatureName.isEmpty())
{
@@ -242,22 +272,21 @@ public class EssentialsProtectEntityListener extends EntityListener
}
@Override
- public void onEntityTarget(EntityTargetEvent event) {
- if (!(event.getTarget() instanceof Player)) {
+ public void onEntityTarget(EntityTargetEvent event)
+ {
+ if (!(event.getTarget() instanceof Player))
+ {
return;
}
User user = Essentials.getStatic().getUser(event.getTarget());
- if ((event.getReason() == TargetReason.CLOSEST_PLAYER ||
- event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY ||
- event.getReason() == TargetReason.PIG_ZOMBIE_TARGET) &&
- EssentialsProtect.guardSettings.get("protect.prevent.entitytarget") &&
- !user.isAuthorized("essentials.protect.entitytarget.bypass")
- )
- {
- event.setCancelled(true);
- return;
- }
+ if ((event.getReason() == TargetReason.CLOSEST_PLAYER
+ || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
+ || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET)
+ && EssentialsProtect.guardSettings.get("protect.prevent.entitytarget")
+ && !user.isAuthorized("essentials.protect.entitytarget.bypass"))
+ {
+ event.setCancelled(true);
+ return;
+ }
}
-
-
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
index 758d0010a..9e1d35732 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
@@ -3,7 +3,6 @@ package com.earth2me.essentials.protect;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
-import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;