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 956ffd6400..4c9d205093 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -393,6 +393,13 @@ public abstract class Event implements Serializable { */ BLOCK_BREAK (Category.BLOCK), + /** + * Called when world attempts to place a snow block during a snowfall + * + * @see org.bukkit.event.block.SnowFormEvent + */ + SNOW_FORM (Category.BLOCK), + /** * INVENTORY EVENTS */ 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 dad87a6916..06d015fe75 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 @@ -108,4 +108,12 @@ public class BlockListener implements Listener { */ public void onBlockBreak(BlockBreakEvent event) { } + + /** + * Called when a world is attempting to place a block during a snowfall + * + * @param event Relevant event details + */ + public void onSnowForm(SnowFormEvent event) { + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/SnowFormEvent.java b/paper-api/src/main/java/org/bukkit/event/block/SnowFormEvent.java new file mode 100644 index 0000000000..dd2db53b91 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/block/SnowFormEvent.java @@ -0,0 +1,76 @@ +package org.bukkit.event.block; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.Cancellable; + +/** + * Called on snow formed by weather + */ +public class SnowFormEvent extends BlockEvent implements Cancellable { + private Material material; + private byte data; + private boolean cancel; + + public SnowFormEvent(Block block) { + super(Type.SNOW_FORM, block); + this.material = Material.SNOW; + this.cancel = false; + } + + /** + * Gets the material being placed on a block during snowfall + * + * @return the material being placed by a snowfall + */ + public Material getMaterial(){ + return material; + } + + /** + * Sets the material to be placed on a block during a snowfall + * + * @param material the material to be placed during a snowfall + */ + public void setMaterial(Material material){ + this.material = material; + } + + /** + * Gets the block data of a block involved in a snowfall + * + * @return the data of the block being placed by a snowfall + */ + public byte getData(){ + return data; + } + + /** + * Sets the block data of a block involved in a snowfall + * + * @param data + */ + public void setData(byte data){ + this.data = data; + } + + /** + * 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 snow from forming during a snowfall + */ + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } +} \ No newline at end of file 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 bca6616a19..013bc1d20d 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 @@ -400,6 +400,12 @@ public final class JavaPluginLoader implements PluginLoader { ((BlockListener) listener).onBlockBreak((BlockBreakEvent) event); } }; + case SNOW_FORM: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((BlockListener) listener).onSnowForm((SnowFormEvent) event); + } + }; // Server Events case PLUGIN_ENABLE: