From 51fdc38f8c2887d6fb8312dedfa9610eb5f12cce Mon Sep 17 00:00:00 2001 From: Xefir Date: Wed, 9 May 2012 22:11:36 +0200 Subject: [PATCH] EnderPearl added --- .../bukkit/simplyperms/SimplyPrevents.java | 5 ++-- .../preventions/projectile/EnderPearl.java | 28 +++++++++++++++++++ src/plugin.yml | 1 + 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/net/crystalyx/bukkit/simplyperms/preventions/projectile/EnderPearl.java diff --git a/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java b/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java index a405ae2..b8f3573 100755 --- a/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java +++ b/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java @@ -51,6 +51,7 @@ public abstract class SimplyPrevents implements Listener { "loot.Drop", "loot.Pickup", "projectile.Egg", + "projectile.EnderPearl", "projectile.Potion", "projectile.Snowball", "vehicle.Collision", @@ -83,9 +84,7 @@ public abstract class SimplyPrevents implements Listener { protected boolean prevent(Cancellable event, Player player, String node) { if (node.contains(",")) { for (String subNode : node.split(",")) { - if (prevent(event, player, subNode)) { - return true; - } else if (player.isPermissionSet("permissions.allow." + subNode)) { + if (!prevent(event, player, subNode)) { return false; } } diff --git a/src/net/crystalyx/bukkit/simplyperms/preventions/projectile/EnderPearl.java b/src/net/crystalyx/bukkit/simplyperms/preventions/projectile/EnderPearl.java new file mode 100644 index 0000000..51b880d --- /dev/null +++ b/src/net/crystalyx/bukkit/simplyperms/preventions/projectile/EnderPearl.java @@ -0,0 +1,28 @@ +package net.crystalyx.bukkit.simplyperms.preventions.projectile; + +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +import net.crystalyx.bukkit.simplyperms.SimplyPlugin; +import net.crystalyx.bukkit.simplyperms.SimplyPrevents; + +public class EnderPearl extends SimplyPrevents { + + public EnderPearl(SimplyPlugin plugin) { + super(plugin); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void egg(PlayerInteractEvent event) { + if (event.getAction() == Action.RIGHT_CLICK_AIR + || event.getAction() == Action.RIGHT_CLICK_BLOCK) { + if (event.getPlayer().getItemInHand().getType() == Material.ENDER_PEARL) { + prevent(event, event.getPlayer(), "enderpearl,projectile"); + } + } + } + +} diff --git a/src/plugin.yml b/src/plugin.yml index 98a708d..c6d7bc7 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -262,6 +262,7 @@ permissions: permissions.allow.egg: true permissions.allow.potion: true permissions.allow.snowball: true + permissions.allow.enderpearl: true permissions.allow.vehicle: description: Allows the player to use vehicles children: