From be1ad0e0409117bf5b87e818fae0e454a8aca59c Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 31 Dec 2010 22:44:11 -0500 Subject: [PATCH] Added BlockCanBuild Event. Fixed Event enumeration By: durron597 --- paper-api/src/org/bukkit/event/Event.java | 3 +- .../event/block/BlockCanBuildEvent.java | 28 +++++++++++++++++++ .../org/bukkit/event/block/BlockListener.java | 6 ++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java diff --git a/paper-api/src/org/bukkit/event/Event.java b/paper-api/src/org/bukkit/event/Event.java index 1340b8f3c6..2362a31d61 100644 --- a/paper-api/src/org/bukkit/event/Event.java +++ b/paper-api/src/org/bukkit/event/Event.java @@ -76,7 +76,8 @@ public abstract class Event { /** * Block Events */ - BLOCK_DAMAGED (Category.BLOCK), + BLOCK_BROKEN (Category.BLOCK), + BLOCK_CANBUILD (Category.BLOCK), BLOCK_FLOW (Category.BLOCK), BLOCK_IGNITE (Category.BLOCK), BLOCK_PHYSICS (Category.BLOCK), diff --git a/paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java b/paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java new file mode 100644 index 0000000000..ebbe83c9a8 --- /dev/null +++ b/paper-api/src/org/bukkit/event/block/BlockCanBuildEvent.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.bukkit.event.block; + +import org.bukkit.Block; +import org.bukkit.event.Cancellable; + +/** + * @author durron597 + */ +public class BlockCanBuildEvent extends BlockEvent implements Cancellable { + protected boolean cancel; + + public BlockCanBuildEvent(Type type, Block block) { + super(type, block); + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } +} diff --git a/paper-api/src/org/bukkit/event/block/BlockListener.java b/paper-api/src/org/bukkit/event/block/BlockListener.java index 2165d4aab8..7bead1a76e 100644 --- a/paper-api/src/org/bukkit/event/block/BlockListener.java +++ b/paper-api/src/org/bukkit/event/block/BlockListener.java @@ -22,6 +22,12 @@ public class BlockListener implements Listener { public void onBlockBroken(BlockBrokenEvent event) { } + /** + * Called when we try to place a block, to see if we can build it + */ + public void canBuild(BlockCanBuildEvent event) { + } + /** * Called when a block flows (water/lava) *