From 56bf34db1e1657401de6a671530937b289c15ee1 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 30 Dec 2010 21:59:53 +0000 Subject: [PATCH 1/2] Added the single most important event ever to be conceived By: Dinnerbone --- .../org/bukkit/event/block/BlockEvent.java | 13 +++++ .../org/bukkit/event/block/BlockListener.java | 15 ++++++ .../bukkit/event/block/BlockPhysicsEvent.java | 47 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 paper-api/src/org/bukkit/event/block/BlockEvent.java create mode 100644 paper-api/src/org/bukkit/event/block/BlockListener.java create mode 100644 paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java diff --git a/paper-api/src/org/bukkit/event/block/BlockEvent.java b/paper-api/src/org/bukkit/event/block/BlockEvent.java new file mode 100644 index 0000000000..32ce6f78ea --- /dev/null +++ b/paper-api/src/org/bukkit/event/block/BlockEvent.java @@ -0,0 +1,13 @@ + +package org.bukkit.event.block; + +import org.bukkit.event.Event; + +/** + * Represents a block related event + */ +public class BlockEvent extends Event { + public BlockEvent(final Event.Type type) { + super(type); + } +} diff --git a/paper-api/src/org/bukkit/event/block/BlockListener.java b/paper-api/src/org/bukkit/event/block/BlockListener.java new file mode 100644 index 0000000000..bb503bcaf4 --- /dev/null +++ b/paper-api/src/org/bukkit/event/block/BlockListener.java @@ -0,0 +1,15 @@ + +package org.bukkit.event.block; + +import org.bukkit.event.Listener; + +/** + * Handles all events thrown in relation to Blocks + */ +public class BlockListener implements Listener { + public BlockListener() { + } + + public void onPhysics(BlockPhysicsEvent event) { + } +} diff --git a/paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java b/paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java new file mode 100644 index 0000000000..845491f26d --- /dev/null +++ b/paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java @@ -0,0 +1,47 @@ + +package org.bukkit.event.block; + +import org.bukkit.Block; +import org.bukkit.ItemStack; +import org.bukkit.event.Event; + +/** + * Thrown when a block physics check is called + */ +public class BlockPhysicsEvent extends BlockEvent { + private final Block block; + private final int changed; + + public BlockPhysicsEvent(final Event.Type type, final Block block, final int changed) { + super(type); + this.block = block; + this.changed = changed; + } + + /** + * Gets the block currently undergoing a physics check + * + * @return Block to check physics on + */ + public Block getBlock() { + return block; + } + + /** + * Gets the type of block that changed, causing this event + * + * @return Changed block's type ID + */ + public int getChangedTypeID() { + return changed; + } + + /** + * Gets the type of block that changed, causing this event + * + * @return Changed block's type + */ + public ItemStack.Type getChangedType() { + return ItemStack.Type.getType(changed); // TODO: Move type to its own file + } +} From fabb5e628a795db269cb5ec5d4b6b89e9ce0d9c8 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 30 Dec 2010 22:07:37 +0000 Subject: [PATCH 2/2] BlockPhysics can be canceled By: Dinnerbone --- .../bukkit/event/block/BlockPhysicsEvent.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java b/paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java index 845491f26d..77cdece0fb 100644 --- a/paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java +++ b/paper-api/src/org/bukkit/event/block/BlockPhysicsEvent.java @@ -11,6 +11,7 @@ import org.bukkit.event.Event; public class BlockPhysicsEvent extends BlockEvent { private final Block block; private final int changed; + private boolean cancel = false; public BlockPhysicsEvent(final Event.Type type, final Block block, final int changed) { super(type); @@ -44,4 +45,24 @@ public class BlockPhysicsEvent extends BlockEvent { public ItemStack.Type getChangedType() { return ItemStack.Type.getType(changed); // TODO: Move type to its own file } + + /** + * Gets the cancellation state of this event. A cancelled event will not + * be executed in the server, but will still pass to other plugins + * + * @return true if this event is cancelled + */ + public boolean isCancelled() { + return cancel; + } + + /** + * Sets the cancellation state of this event. A cancelled event will not + * be executed in the server, but will still pass to other plugins + * + * @param cancel true if you wish to cancel this event + */ + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } }