mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 14:33:09 +01:00
Added SIGN_CHANGE event.
By: Timberjaw <timberjaw@gmail.com>
This commit is contained in:
parent
a3f7361535
commit
204952eed0
4 changed files with 90 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue