Added SnowFormEvent. Thanks aPunch!

By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
Bukkit/Spigot 2011-05-02 01:21:47 -04:00
parent 4baa59e20f
commit 2fc8673c04
4 changed files with 97 additions and 0 deletions

View File

@ -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
*/

View File

@ -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) {
}
}

View File

@ -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;
}
}

View File

@ -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: