diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index fe1d69207a..045da30edb 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -217,9 +217,9 @@ public abstract class Event { BLOCK_PLACED (Category.BLOCK), /** - * Called when a specific block is being sent to a player + * Called when leaves are decaying naturally */ - BLOCK_SENT (Category.BLOCK), + LEAVES_DECAY (Category.BLOCK), /** * Called when a liquid attempts to flow into a block which already diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java b/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java index c760758849..723572f99f 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java @@ -1,81 +1,89 @@ -package org.bukkit.event.block; - -import org.bukkit.event.Listener; - -/** - * Handles all events thrown in relation to Blocks - * - * @author durron597 - */ -public class BlockListener implements Listener { - /** - * Default Constructor - */ - public BlockListener() { - } - - /** - * Called when a block is broken (or destroyed) - * - * @param event Relevant event details - */ - public void onBlockBroken(BlockBrokenEvent event) { - } - - /** - * Called when we try to place a block, to see if we can build it - */ - public void onBlockCanBuild(BlockCanBuildEvent event) { - } - - /** - * Called when a block flows (water/lava) - * - * @param event Relevant event details - */ - public void onBlockFlow(BlockFromToEvent event) { - } - - /** - * Called when a block gets ignited - * - * @param event Relevant event details - */ - public void onBlockIgnite(BlockIgniteEvent event) { - } - - /** - * Called when block physics occurs - * - * @param event Relevant event details - */ - public void onBlockPhysics(BlockPhysicsEvent event) { - } - - /** - * Called when a player places a block - * - * @param event Relevant event details - */ - public void onBlockPlaced(BlockPlacedEvent event) { - } - - /** - * Called when redstone changes - * From: the source of the redstone change - * To: The redstone dust that changed - * - * @param event Relevant event details - */ - public void onBlockRedstoneChange(BlockFromToEvent event) { - } - - /** - * Called when a player right clicks a block - * - * @param event Relevant event details - */ - public void onBlockRightClicked(BlockRightClickedEvent event) { - } - -} +package org.bukkit.event.block; + +import org.bukkit.event.Listener; + +/** + * Handles all events thrown in relation to Blocks + * + * @author durron597 + */ +public class BlockListener implements Listener { + /** + * Default Constructor + */ + public BlockListener() { + } + + /** + * Called when a block is broken (or destroyed) + * + * @param event Relevant event details + */ + public void onBlockBroken(BlockBrokenEvent event) { + } + + /** + * Called when we try to place a block, to see if we can build it + */ + public void onBlockCanBuild(BlockCanBuildEvent event) { + } + + /** + * Called when a block flows (water/lava) + * + * @param event Relevant event details + */ + public void onBlockFlow(BlockFromToEvent event) { + } + + /** + * Called when a block gets ignited + * + * @param event Relevant event details + */ + public void onBlockIgnite(BlockIgniteEvent event) { + } + + /** + * Called when block physics occurs + * + * @param event Relevant event details + */ + public void onBlockPhysics(BlockPhysicsEvent event) { + } + + /** + * Called when a player places a block + * + * @param event Relevant event details + */ + public void onBlockPlaced(BlockPlacedEvent event) { + } + + /** + * Called when redstone changes + * From: the source of the redstone change + * To: The redstone dust that changed + * + * @param event Relevant event details + */ + public void onBlockRedstoneChange(BlockFromToEvent event) { + } + + /** + * Called when a player right clicks a block + * + * @param event Relevant event details + */ + public void onBlockRightClicked(BlockRightClickedEvent event) { + } + + /** + * Called when leaves are decaying naturally + * + * @param event Relevant event details + */ + public void onLeavesDecay(LeavesDecayEvent event) { + } + +} diff --git a/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java new file mode 100644 index 0000000000..1ee2f4039c --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java @@ -0,0 +1,36 @@ + +package org.bukkit.event.block; + +import org.bukkit.Block; +import org.bukkit.event.Cancellable; + +/** + * Called on leaves decaying + */ +public class LeavesDecayEvent extends BlockEvent implements Cancellable { + private boolean cancel = false; + + public LeavesDecayEvent(final Type type, final Block block) { + super(type, block); + } + + /** + * 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; + } +} diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 7cbccbe8be..2c9b507810 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -127,6 +127,9 @@ public final class JavaPluginLoader implements PluginLoader { case BLOCK_FLOW: trueListener.onBlockFlow((BlockFromToEvent)event); break; + case LEAVES_DECAY: + trueListener.onLeavesDecay((LeavesDecayEvent)event); + break; } } else if(listener instanceof ServerListener) { ServerListener trueListener = (ServerListener)listener;