summaryrefslogtreecommitdiffstats
path: root/EssentialsAntiBuild
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-08-31 06:06:33 +0100
committerKHobbits <rob@khobbits.co.uk>2012-08-31 06:06:33 +0100
commit0d98640b2afab980275f1ca924788d6e0b281fe3 (patch)
tree2a551c1fae99056e64e291a21b997d23727b2736 /EssentialsAntiBuild
parent7108e4f52c3beacabf211d2724fd1cde89c69b19 (diff)
downloadEssentials-0d98640b2afab980275f1ca924788d6e0b281fe3.tar
Essentials-0d98640b2afab980275f1ca924788d6e0b281fe3.tar.gz
Essentials-0d98640b2afab980275f1ca924788d6e0b281fe3.tar.lz
Essentials-0d98640b2afab980275f1ca924788d6e0b281fe3.tar.xz
Essentials-0d98640b2afab980275f1ca924788d6e0b281fe3.zip
Fix painting break in antibuild.
Diffstat (limited to 'EssentialsAntiBuild')
-rw-r--r--EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java49
1 files changed, 32 insertions, 17 deletions
diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java
index 7a1052cce..a877bc47e 100644
--- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java
+++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java
@@ -6,10 +6,13 @@ import com.earth2me.essentials.User;
import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.block.Block;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
+import org.bukkit.event.painting.PaintingBreakByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
@@ -34,6 +37,12 @@ public class EssentialsAntiBuildListener implements Listener
return metaPermCheck(user, action, block.getTypeId(), block.getData());
}
+ private boolean metaPermCheck(User user, String action, int blockId)
+ {
+ final String blockPerm = "essentials.build." + action + "." + blockId;
+ return user.isAuthorized(blockPerm);
+ }
+
private boolean metaPermCheck(User user, String action, int blockId, byte data)
{
final String blockPerm = "essentials.build." + action + "." + blockId;
@@ -54,14 +63,9 @@ public class EssentialsAntiBuildListener implements Listener
return user.isAuthorized(blockPerm);
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
-
final User user = ess.getUser(event.getPlayer());
final Block block = event.getBlockPlaced();
final int typeId = block.getTypeId();
@@ -95,13 +99,9 @@ public class EssentialsAntiBuildListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final User user = ess.getUser(event.getPlayer());
final Block block = event.getBlock();
final int typeId = block.getTypeId();
@@ -136,13 +136,28 @@ public class EssentialsAntiBuildListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onBlockPistonExtend(BlockPistonExtendEvent event)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onPaintingBreak(PaintingBreakByEntityEvent event)
{
- if (event.isCancelled())
+ final Entity entity = event.getRemover();
+ if (entity instanceof Player)
{
- return;
+ final User user = ess.getUser(entity);
+ if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")
+ && !metaPermCheck(user, "break", Material.PAINTING.getId()))
+ {
+ if (ess.getSettings().warnOnBuildDisallow())
+ {
+ user.sendMessage(_("antiBuildBreak", Material.PAINTING.toString()));
+ }
+ event.setCancelled(true);
+ }
}
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onBlockPistonExtend(BlockPistonExtendEvent event)
+ {
for (Block block : event.getBlocks())
{
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getTypeId()))
@@ -153,10 +168,10 @@ public class EssentialsAntiBuildListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event)
{
- if (event.isCancelled() || !event.isSticky())
+ if (!event.isSticky())
{
return;
}