summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsProtect')
-rw-r--r--EssentialsProtect/MANIFEST.MF4
-rw-r--r--EssentialsProtect/build.xml168
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java696
-rw-r--r--EssentialsProtect/src/plugin.yml16
4 files changed, 442 insertions, 442 deletions
diff --git a/EssentialsProtect/MANIFEST.MF b/EssentialsProtect/MANIFEST.MF
index b43aa699e..db70a3fda 100644
--- a/EssentialsProtect/MANIFEST.MF
+++ b/EssentialsProtect/MANIFEST.MF
@@ -1,2 +1,2 @@
-Manifest-Version: 1.0
-Class-Path: ../lib/mysql.jar ../lib/sqlite.jar
+Manifest-Version: 1.0
+Class-Path: ../lib/mysql.jar ../lib/sqlite.jar
diff --git a/EssentialsProtect/build.xml b/EssentialsProtect/build.xml
index a09cc7333..1f88786d0 100644
--- a/EssentialsProtect/build.xml
+++ b/EssentialsProtect/build.xml
@@ -1,84 +1,84 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE project [ <!ENTITY buildinc SYSTEM "../build.inc.xml"> ]>
-<!-- You may freely edit this file. See commented blocks below for -->
-<!-- some examples of how to customize the build. -->
-<!-- (If you delete it and reopen the project it will be recreated.) -->
-<!-- By default, only the Clean and Build commands use this build script. -->
-<!-- Commands such as Run, Debug, and Test only use this build script if -->
-<!-- the Compile on Save feature is turned off for the project. -->
-<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
-<!-- in the project's Project Properties dialog box.-->
-<project name="EssentialsProtect" default="default" basedir=".">
- <description>Builds, tests, and runs the project EssentialsProtect.</description>
- <import file="nbproject/build-impl.xml"/>
- <!--
-
- There exist several targets which are by default empty and which can be
- used for execution of your tasks. These targets are usually executed
- before and after some main targets. They are:
-
- -pre-init: called before initialization of project properties
- -post-init: called after initialization of project properties
- -pre-compile: called before javac compilation
- -post-compile: called after javac compilation
- -pre-compile-single: called before javac compilation of single file
- -post-compile-single: called after javac compilation of single file
- -pre-compile-test: called before javac compilation of JUnit tests
- -post-compile-test: called after javac compilation of JUnit tests
- -pre-compile-test-single: called before javac compilation of single JUnit test
- -post-compile-test-single: called after javac compilation of single JUunit test
- -pre-jar: called before JAR building
- -post-jar: called after JAR building
- -post-clean: called after cleaning build products
-
- (Targets beginning with '-' are not intended to be called on their own.)
-
- Example of inserting an obfuscator after compilation could look like this:
-
- <target name="-post-compile">
- <obfuscate>
- <fileset dir="${build.classes.dir}"/>
- </obfuscate>
- </target>
-
- For list of available properties check the imported
- nbproject/build-impl.xml file.
-
-
- Another way to customize the build is by overriding existing main targets.
- The targets of interest are:
-
- -init-macrodef-javac: defines macro for javac compilation
- -init-macrodef-junit: defines macro for junit execution
- -init-macrodef-debug: defines macro for class debugging
- -init-macrodef-java: defines macro for class execution
- -do-jar-with-manifest: JAR building (if you are using a manifest)
- -do-jar-without-manifest: JAR building (if you are not using a manifest)
- run: execution of project
- -javadoc-build: Javadoc generation
- test-report: JUnit report generation
-
- An example of overriding the target for project execution could look like this:
-
- <target name="run" depends="EssentialsProtect-impl.jar">
- <exec dir="bin" executable="launcher.exe">
- <arg file="${dist.jar}"/>
- </exec>
- </target>
-
- Notice that the overridden target depends on the jar target and not only on
- the compile target as the regular run target does. Again, for a list of available
- properties which you can use, check the target you are overriding in the
- nbproject/build-impl.xml file.
-
- -->
- <target name="-post-jar">
- <jar jarfile="${dist.dir}/EssentialsProtect.jar">
- <zipfileset src="${dist.jar}" excludes="META-INF/*" />
- <zipfileset src="../lib/c3p0-0.9.1.2.jar" excludes="META-INF/*" />
- <manifest>
- <attribute name="Classpath" value="EssentialsProtect.jar"/>
- </manifest>
- </jar>
- </target>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [ <!ENTITY buildinc SYSTEM "../build.inc.xml"> ]>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="EssentialsProtect" default="default" basedir=".">
+ <description>Builds, tests, and runs the project EssentialsProtect.</description>
+ <import file="nbproject/build-impl.xml"/>
+ <!--
+
+ There exist several targets which are by default empty and which can be
+ used for execution of your tasks. These targets are usually executed
+ before and after some main targets. They are:
+
+ -pre-init: called before initialization of project properties
+ -post-init: called after initialization of project properties
+ -pre-compile: called before javac compilation
+ -post-compile: called after javac compilation
+ -pre-compile-single: called before javac compilation of single file
+ -post-compile-single: called after javac compilation of single file
+ -pre-compile-test: called before javac compilation of JUnit tests
+ -post-compile-test: called after javac compilation of JUnit tests
+ -pre-compile-test-single: called before javac compilation of single JUnit test
+ -post-compile-test-single: called after javac compilation of single JUunit test
+ -pre-jar: called before JAR building
+ -post-jar: called after JAR building
+ -post-clean: called after cleaning build products
+
+ (Targets beginning with '-' are not intended to be called on their own.)
+
+ Example of inserting an obfuscator after compilation could look like this:
+
+ <target name="-post-compile">
+ <obfuscate>
+ <fileset dir="${build.classes.dir}"/>
+ </obfuscate>
+ </target>
+
+ For list of available properties check the imported
+ nbproject/build-impl.xml file.
+
+
+ Another way to customize the build is by overriding existing main targets.
+ The targets of interest are:
+
+ -init-macrodef-javac: defines macro for javac compilation
+ -init-macrodef-junit: defines macro for junit execution
+ -init-macrodef-debug: defines macro for class debugging
+ -init-macrodef-java: defines macro for class execution
+ -do-jar-with-manifest: JAR building (if you are using a manifest)
+ -do-jar-without-manifest: JAR building (if you are not using a manifest)
+ run: execution of project
+ -javadoc-build: Javadoc generation
+ test-report: JUnit report generation
+
+ An example of overriding the target for project execution could look like this:
+
+ <target name="run" depends="EssentialsProtect-impl.jar">
+ <exec dir="bin" executable="launcher.exe">
+ <arg file="${dist.jar}"/>
+ </exec>
+ </target>
+
+ Notice that the overridden target depends on the jar target and not only on
+ the compile target as the regular run target does. Again, for a list of available
+ properties which you can use, check the target you are overriding in the
+ nbproject/build-impl.xml file.
+
+ -->
+ <target name="-post-jar">
+ <jar jarfile="${dist.dir}/EssentialsProtect.jar">
+ <zipfileset src="${dist.jar}" excludes="META-INF/*" />
+ <zipfileset src="../lib/c3p0-0.9.1.2.jar" excludes="META-INF/*" />
+ <manifest>
+ <attribute name="Classpath" value="EssentialsProtect.jar"/>
+ </manifest>
+ </jar>
+ </target>
+</project>
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
index a71bcbd09..d85d2b3d7 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
@@ -1,348 +1,348 @@
-package com.earth2me.essentials.protect;
-
-import com.earth2me.essentials.EssentialsBlockListener;
-import com.earth2me.essentials.IEssentials;
-import com.earth2me.essentials.User;
-import java.util.HashSet;
-import java.util.Set;
-import net.minecraft.server.ChunkPosition;
-import net.minecraft.server.Packet60Explosion;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.block.BlockFace;
-import org.bukkit.craftbukkit.CraftServer;
-import org.bukkit.craftbukkit.CraftWorld;
-import org.bukkit.craftbukkit.entity.CraftFireball;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
-import org.bukkit.craftbukkit.entity.CraftTNTPrimed;
-import org.bukkit.entity.Creeper;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Fireball;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.TNTPrimed;
-import org.bukkit.event.entity.CreatureSpawnEvent;
-import org.bukkit.event.entity.EntityDamageByBlockEvent;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
-import org.bukkit.event.entity.EntityExplodeEvent;
-import org.bukkit.event.entity.EntityListener;
-import org.bukkit.event.entity.EntityTargetEvent;
-import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
-import org.bukkit.event.entity.ExplosionPrimeEvent;
-
-
-public class EssentialsProtectEntityListener extends EntityListener
-{
- private final transient IProtect prot;
- private final transient IEssentials ess;
-
- public EssentialsProtectEntityListener(final IProtect prot)
- {
- this.prot = prot;
- this.ess = prot.getEssentials();
- }
-
- @Override
- public void onEntityDamage(EntityDamageEvent event)
- {
- if (event.isCancelled())
- {
- return;
- }
- final Entity target = event.getEntity();
- final User user = ess.getUser(target);
- if (event instanceof EntityDamageByBlockEvent)
- {
- final DamageCause cause = event.getCause();
-
- if (prot.getSettingBool(ProtectConfig.disable_contactdmg)
- && cause == DamageCause.CONTACT
- && !(target instanceof Player
- && user.isAuthorized("essentials.protect.damage.contact")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- if (prot.getSettingBool(ProtectConfig.disable_lavadmg)
- && cause == DamageCause.LAVA
- && !(target instanceof Player
- && user.isAuthorized("essentials.protect.damage.lava")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- if (prot.getSettingBool(ProtectConfig.prevent_tnt_explosion)
- && cause == DamageCause.BLOCK_EXPLOSION
- && !(target instanceof Player
- && user.isAuthorized("essentials.protect.damage.tnt")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- }
-
- if (event instanceof EntityDamageByEntityEvent)
- {
- final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
- final Entity eAttack = edEvent.getDamager();
- final User attacker = ess.getUser(eAttack);
-
- // PVP Settings
- if (target instanceof Player && eAttack instanceof Player
- && prot.getSettingBool(ProtectConfig.disable_pvp)
- && (!user.isAuthorized("essentials.protect.pvp") || !attacker.isAuthorized("essentials.protect.pvp")))
- {
- event.setCancelled(true);
- return;
- }
-
- //Creeper explode prevention
- if (eAttack instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_explosion)
- && !(target instanceof Player
- && user.isAuthorized("essentials.protect.damage.creeper")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
-
- if (eAttack instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_playerdmg)
- && !(target instanceof Player
- && user.isAuthorized("essentials.protect.damage.creeper")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
-
- if (eAttack instanceof Fireball && prot.getSettingBool(ProtectConfig.prevent_fireball_playerdmg)
- && !(target instanceof Player
- && user.isAuthorized("essentials.protect.damage.fireball")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
-
- if (eAttack instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_playerdmg)
- && !(target instanceof Player
- && user.isAuthorized("essentials.protect.damage.tnt")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- }
-
- if (event instanceof EntityDamageByProjectileEvent
- && target instanceof Player
- && prot.getSettingBool(ProtectConfig.disable_projectiles)
- && !(user.isAuthorized("essentials.protect.damage.projectiles")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- ((EntityDamageByProjectileEvent)event).setBounce(true);
- return;
- }
-
- final DamageCause cause = event.getCause();
- if (target instanceof Player)
- {
- if (cause == DamageCause.FALL
- && prot.getSettingBool(ProtectConfig.disable_fall)
- && !(user.isAuthorized("essentials.protect.damage.fall")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
-
- if (cause == DamageCause.SUFFOCATION
- && prot.getSettingBool(ProtectConfig.disable_suffocate)
- && !(user.isAuthorized("essentials.protect.damage.suffocation")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- if ((cause == DamageCause.FIRE
- || cause == DamageCause.FIRE_TICK)
- && prot.getSettingBool(ProtectConfig.disable_firedmg)
- && !(user.isAuthorized("essentials.protect.damage.fire")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- if (cause == DamageCause.DROWNING
- && prot.getSettingBool(ProtectConfig.disable_drown)
- && !(user.isAuthorized("essentials.protect.damage.drowning")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- if (cause == DamageCause.LIGHTNING
- && prot.getSettingBool(ProtectConfig.disable_lightning)
- && !(user.isAuthorized("essentials.protect.damage.lightning")
- && !user.isAuthorized("essentials.protect.damage.disable")))
- {
- event.setCancelled(true);
- return;
- }
- }
- }
-
- @Override
- public void onEntityExplode(EntityExplodeEvent event)
- {
- if (event.isCancelled())
- {
- return;
- }
- final int maxHeight = ess.getSettings().getProtectCreeperMaxHeight();
- //Nicccccccccce plaaacccccccccce..
- if (event.getEntity() instanceof LivingEntity
- && (prot.getSettingBool(ProtectConfig.prevent_creeper_explosion)
- || prot.getSettingBool(ProtectConfig.prevent_creeper_blockdmg)
- || (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)))
- {
- final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
- final Player[] players = ess.getServer().getOnlinePlayers();
- final Set<ChunkPosition> blocksUnderPlayers = new HashSet<ChunkPosition>(players.length);
- final Location loc = event.getLocation();
- for (Player player : players)
- {
- if (player.getWorld().equals(loc.getWorld()))
- {
- blocksUnderPlayers.add(
- new ChunkPosition(
- player.getLocation().getBlockX(),
- player.getLocation().getBlockY() - 1,
- player.getLocation().getBlockZ()));
- }
- }
- ChunkPosition cp;
- for (Block block : event.blockList())
- {
- cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
- if (!blocksUnderPlayers.contains(cp))
- {
- set.add(cp);
- }
- }
-
- ((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0D, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension,
- new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set));
- event.setCancelled(true);
- return;
- }
- else if (event.getEntity() instanceof CraftTNTPrimed
- && prot.getSettingBool(ProtectConfig.prevent_tnt_explosion))
- {
- event.setCancelled(true);
- return;
- }
- else if (event.getEntity() instanceof CraftFireball
- && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion))
- {
- event.setCancelled(true);
- return;
- }
- // This code will prevent explosions near protected rails, signs or protected chests
- // TODO: Use protect db instead of this code
-
- for (Block block : event.blockList())
- {
- if ((block.getType() == Material.RAILS || block.getRelative(BlockFace.UP).getType() == Material.RAILS)
- && prot.getSettingBool(ProtectConfig.protect_rails))
- {
- event.setCancelled(true);
- return;
- }
- if ((block.getType() == Material.WALL_SIGN
- || block.getRelative(BlockFace.NORTH).getType() == Material.WALL_SIGN
- || block.getRelative(BlockFace.EAST).getType() == Material.WALL_SIGN
- || block.getRelative(BlockFace.SOUTH).getType() == Material.WALL_SIGN
- || block.getRelative(BlockFace.WEST).getType() == Material.WALL_SIGN
- || block.getType() == Material.SIGN_POST
- || block.getRelative(BlockFace.UP).getType() == Material.SIGN_POST)
- && prot.getSettingBool(ProtectConfig.protect_signs))
- {
- event.setCancelled(true);
- return;
- }
- /*if (EssentialsBlockListener.protectedBlocks.contains(block.getType())
- && EssentialsBlockListener.isBlockProtected(block))
- {
- event.setCancelled(true);
- return;
- }*/
- }
- }
-
- @Override
- public void onCreatureSpawn(final CreatureSpawnEvent event)
- {
- if (event.getEntity() instanceof CraftPlayer)
- {
- return;
- }
- if (event.isCancelled())
- {
- return;
- }
- final String creatureName = event.getCreatureType().toString().toLowerCase();
- if (creatureName == null || creatureName.isEmpty())
- {
- return;
- }
- if (ess.getSettings().getProtectPreventSpawn(creatureName))
- {
- event.setCancelled(true);
- }
- }
-
- @Override
- public void onEntityTarget(final EntityTargetEvent event)
- {
- if (event.isCancelled())
- {
- return;
- }
- if (!(event.getTarget() instanceof Player))
- {
- return;
- }
- final User user = ess.getUser(event.getTarget());
- if ((event.getReason() == TargetReason.CLOSEST_PLAYER
- || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
- || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET
- || event.getReason() == TargetReason.RANDOM_TARGET
- || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER
- || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET)
- && prot.getSettingBool(ProtectConfig.prevent_entitytarget)
- && !user.isAuthorized("essentials.protect.entitytarget.bypass"))
- {
- event.setCancelled(true);
- return;
- }
- }
-
- @Override
- public void onExplosionPrime(ExplosionPrimeEvent event)
- {
- if (event.getEntity() instanceof CraftFireball
- && prot.getSettingBool(ProtectConfig.prevent_fireball_fire))
- {
- event.setFire(false);
- }
- }
-}
+package com.earth2me.essentials.protect;
+
+import com.earth2me.essentials.EssentialsBlockListener;
+import com.earth2me.essentials.IEssentials;
+import com.earth2me.essentials.User;
+import java.util.HashSet;
+import java.util.Set;
+import net.minecraft.server.ChunkPosition;
+import net.minecraft.server.Packet60Explosion;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftFireball;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.entity.CraftTNTPrimed;
+import org.bukkit.entity.Creeper;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Fireball;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.TNTPrimed;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityDamageByBlockEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
+import org.bukkit.event.entity.EntityExplodeEvent;
+import org.bukkit.event.entity.EntityListener;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+
+
+public class EssentialsProtectEntityListener extends EntityListener
+{
+ private final transient IProtect prot;
+ private final transient IEssentials ess;
+
+ public EssentialsProtectEntityListener(final IProtect prot)
+ {
+ this.prot = prot;
+ this.ess = prot.getEssentials();
+ }
+
+ @Override
+ public void onEntityDamage(EntityDamageEvent event)
+ {
+ if (event.isCancelled())
+ {
+ return;
+ }
+ final Entity target = event.getEntity();
+ final User user = ess.getUser(target);
+ if (event instanceof EntityDamageByBlockEvent)
+ {
+ final DamageCause cause = event.getCause();
+
+ if (prot.getSettingBool(ProtectConfig.disable_contactdmg)
+ && cause == DamageCause.CONTACT
+ && !(target instanceof Player
+ && user.isAuthorized("essentials.protect.damage.contact")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ if (prot.getSettingBool(ProtectConfig.disable_lavadmg)
+ && cause == DamageCause.LAVA
+ && !(target instanceof Player
+ && user.isAuthorized("essentials.protect.damage.lava")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ if (prot.getSettingBool(ProtectConfig.prevent_tnt_explosion)
+ && cause == DamageCause.BLOCK_EXPLOSION
+ && !(target instanceof Player
+ && user.isAuthorized("essentials.protect.damage.tnt")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ if (event instanceof EntityDamageByEntityEvent)
+ {
+ final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
+ final Entity eAttack = edEvent.getDamager();
+ final User attacker = ess.getUser(eAttack);
+
+ // PVP Settings
+ if (target instanceof Player && eAttack instanceof Player
+ && prot.getSettingBool(ProtectConfig.disable_pvp)
+ && (!user.isAuthorized("essentials.protect.pvp") || !attacker.isAuthorized("essentials.protect.pvp")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+
+ //Creeper explode prevention
+ if (eAttack instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_explosion)
+ && !(target instanceof Player
+ && user.isAuthorized("essentials.protect.damage.creeper")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+
+ if (eAttack instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_playerdmg)
+ && !(target instanceof Player
+ && user.isAuthorized("essentials.protect.damage.creeper")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+
+ if (eAttack instanceof Fireball && prot.getSettingBool(ProtectConfig.prevent_fireball_playerdmg)
+ && !(target instanceof Player
+ && user.isAuthorized("essentials.protect.damage.fireball")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+
+ if (eAttack instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_playerdmg)
+ && !(target instanceof Player
+ && user.isAuthorized("essentials.protect.damage.tnt")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ if (event instanceof EntityDamageByProjectileEvent
+ && target instanceof Player
+ && prot.getSettingBool(ProtectConfig.disable_projectiles)
+ && !(user.isAuthorized("essentials.protect.damage.projectiles")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ ((EntityDamageByProjectileEvent)event).setBounce(true);
+ return;
+ }
+
+ final DamageCause cause = event.getCause();
+ if (target instanceof Player)
+ {
+ if (cause == DamageCause.FALL
+ && prot.getSettingBool(ProtectConfig.disable_fall)
+ && !(user.isAuthorized("essentials.protect.damage.fall")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+
+ if (cause == DamageCause.SUFFOCATION
+ && prot.getSettingBool(ProtectConfig.disable_suffocate)
+ && !(user.isAuthorized("essentials.protect.damage.suffocation")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ if ((cause == DamageCause.FIRE
+ || cause == DamageCause.FIRE_TICK)
+ && prot.getSettingBool(ProtectConfig.disable_firedmg)
+ && !(user.isAuthorized("essentials.protect.damage.fire")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ if (cause == DamageCause.DROWNING
+ && prot.getSettingBool(ProtectConfig.disable_drown)
+ && !(user.isAuthorized("essentials.protect.damage.drowning")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ if (cause == DamageCause.LIGHTNING
+ && prot.getSettingBool(ProtectConfig.disable_lightning)
+ && !(user.isAuthorized("essentials.protect.damage.lightning")
+ && !user.isAuthorized("essentials.protect.damage.disable")))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void onEntityExplode(EntityExplodeEvent event)
+ {
+ if (event.isCancelled())
+ {
+ return;
+ }
+ final int maxHeight = ess.getSettings().getProtectCreeperMaxHeight();
+ //Nicccccccccce plaaacccccccccce..
+ if (event.getEntity() instanceof LivingEntity
+ && (prot.getSettingBool(ProtectConfig.prevent_creeper_explosion)
+ || prot.getSettingBool(ProtectConfig.prevent_creeper_blockdmg)
+ || (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)))
+ {
+ final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
+ final Player[] players = ess.getServer().getOnlinePlayers();
+ final Set<ChunkPosition> blocksUnderPlayers = new HashSet<ChunkPosition>(players.length);
+ final Location loc = event.getLocation();
+ for (Player player : players)
+ {
+ if (player.getWorld().equals(loc.getWorld()))
+ {
+ blocksUnderPlayers.add(
+ new ChunkPosition(
+ player.getLocation().getBlockX(),
+ player.getLocation().getBlockY() - 1,
+ player.getLocation().getBlockZ()));
+ }
+ }
+ ChunkPosition cp;
+ for (Block block : event.blockList())
+ {
+ cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
+ if (!blocksUnderPlayers.contains(cp))
+ {
+ set.add(cp);
+ }
+ }
+
+ ((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0D, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension,
+ new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set));
+ event.setCancelled(true);
+ return;
+ }
+ else if (event.getEntity() instanceof CraftTNTPrimed
+ && prot.getSettingBool(ProtectConfig.prevent_tnt_explosion))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ else if (event.getEntity() instanceof CraftFireball
+ && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ // This code will prevent explosions near protected rails, signs or protected chests
+ // TODO: Use protect db instead of this code
+
+ for (Block block : event.blockList())
+ {
+ if ((block.getType() == Material.RAILS || block.getRelative(BlockFace.UP).getType() == Material.RAILS)
+ && prot.getSettingBool(ProtectConfig.protect_rails))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ if ((block.getType() == Material.WALL_SIGN
+ || block.getRelative(BlockFace.NORTH).getType() == Material.WALL_SIGN
+ || block.getRelative(BlockFace.EAST).getType() == Material.WALL_SIGN
+ || block.getRelative(BlockFace.SOUTH).getType() == Material.WALL_SIGN
+ || block.getRelative(BlockFace.WEST).getType() == Material.WALL_SIGN
+ || block.getType() == Material.SIGN_POST
+ || block.getRelative(BlockFace.UP).getType() == Material.SIGN_POST)
+ && prot.getSettingBool(ProtectConfig.protect_signs))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ /*if (EssentialsBlockListener.protectedBlocks.contains(block.getType())
+ && EssentialsBlockListener.isBlockProtected(block))
+ {
+ event.setCancelled(true);
+ return;
+ }*/
+ }
+ }
+
+ @Override
+ public void onCreatureSpawn(final CreatureSpawnEvent event)
+ {
+ if (event.getEntity() instanceof CraftPlayer)
+ {
+ return;
+ }
+ if (event.isCancelled())
+ {
+ return;
+ }
+ final String creatureName = event.getCreatureType().toString().toLowerCase();
+ if (creatureName == null || creatureName.isEmpty())
+ {
+ return;
+ }
+ if (ess.getSettings().getProtectPreventSpawn(creatureName))
+ {
+ event.setCancelled(true);
+ }
+ }
+
+ @Override
+ public void onEntityTarget(final EntityTargetEvent event)
+ {
+ if (event.isCancelled())
+ {
+ return;
+ }
+ if (!(event.getTarget() instanceof Player))
+ {
+ return;
+ }
+ final User user = ess.getUser(event.getTarget());
+ if ((event.getReason() == TargetReason.CLOSEST_PLAYER
+ || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
+ || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET
+ || event.getReason() == TargetReason.RANDOM_TARGET
+ || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER
+ || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET)
+ && prot.getSettingBool(ProtectConfig.prevent_entitytarget)
+ && !user.isAuthorized("essentials.protect.entitytarget.bypass"))
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ @Override
+ public void onExplosionPrime(ExplosionPrimeEvent event)
+ {
+ if (event.getEntity() instanceof CraftFireball
+ && prot.getSettingBool(ProtectConfig.prevent_fireball_fire))
+ {
+ event.setFire(false);
+ }
+ }
+}
diff --git a/EssentialsProtect/src/plugin.yml b/EssentialsProtect/src/plugin.yml
index e5212599d..31fc1ae99 100644
--- a/EssentialsProtect/src/plugin.yml
+++ b/EssentialsProtect/src/plugin.yml
@@ -1,9 +1,9 @@
-# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.)
-name: EssentialsProtect
-main: com.earth2me.essentials.protect.EssentialsProtect
-# Note to developers: This next line cannot change, or the automatic versioning system will break.
-version: TeamCity
-website: http://www.earth2me.net:8001/
-description: Provides protection for various parts of the world.
-authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
+# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.)
+name: EssentialsProtect
+main: com.earth2me.essentials.protect.EssentialsProtect
+# Note to developers: This next line cannot change, or the automatic versioning system will break.
+version: TeamCity
+website: http://www.earth2me.net:8001/
+description: Provides protection for various parts of the world.
+authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
depend: [Essentials] \ No newline at end of file