diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index 50332a42..99af742e 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -330,6 +330,13 @@ public abstract class Event { */ LEAVES_DECAY (Category.BLOCK), + /** + * Called when a sign is changed + * + * @see org.bukkit.event.block.SignChangeEvent + */ + SIGN_CHANGE (Category.BLOCK), + /** * Called when a liquid attempts to flow into a block which already * contains a "breakable" block, such as redstone wire diff --git a/src/main/java/org/bukkit/event/block/BlockListener.java b/src/main/java/org/bukkit/event/block/BlockListener.java index c5964688..7cf893c9 100644 --- a/src/main/java/org/bukkit/event/block/BlockListener.java +++ b/src/main/java/org/bukkit/event/block/BlockListener.java @@ -94,6 +94,14 @@ public class BlockListener implements Listener { public void onLeavesDecay(LeavesDecayEvent event) { } + /** + * Called when a sign is changed + * + * @param event Relevant event details + */ + public void onSignChange(SignChangeEvent event) { + } + /** * Called when a block is destroyed from burning * diff --git a/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/src/main/java/org/bukkit/event/block/SignChangeEvent.java new file mode 100644 index 00000000..89fec625 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/SignChangeEvent.java @@ -0,0 +1,70 @@ +package org.bukkit.event.block; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; + +/** + * Called on sign change + */ +public class SignChangeEvent extends BlockEvent implements Cancellable { + private boolean cancel = false; + private Player player; + private String[] lines; + + public SignChangeEvent(final Type type, final Block theBlock, final Player thePlayer, String[] theLines) { + super(type, theBlock); + this.player = thePlayer; + this.lines = theLines; + } + + /** + * Gets all of the text lines from this event + * + * @return String[] of the event's text lines + */ + public String[] getLines() + { + return lines; + } + + /** + * Gets a single line from this event + * + * @param index index of the line to get + * @return String line + */ + public String getLine(int index) throws IndexOutOfBoundsException { + return lines[index]; + } + + /** + * Sets a single line for this event + * + * @param index index of the line to set + * @param line text to set + */ + public void setLine(int index, String line) throws IndexOutOfBoundsException { + lines[index] = line; + } + + /** + * 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/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index b13aa9c1..840b7cca 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -241,6 +241,11 @@ public final class JavaPluginLoader implements PluginLoader { ((BlockListener)listener).onLeavesDecay( (LeavesDecayEvent)event ); } }; + case SIGN_CHANGE: + return new EventExecutor() { public void execute( Listener listener, Event event ) { + ((BlockListener)listener).onSignChange( (SignChangeEvent)event ); + } + }; case BLOCK_IGNITE: return new EventExecutor() { public void execute( Listener listener, Event event ) { ((BlockListener)listener).onBlockIgnite( (BlockIgniteEvent)event );