mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
Added BlockSpread, BlockForm and BlockFade events.
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
5d515f5a85
commit
c3373081e2
6 changed files with 193 additions and 1 deletions
|
@ -376,6 +376,24 @@ public abstract class Event implements Serializable {
|
||||||
* @see org.bukkit.event.block.SnowFormEvent
|
* @see org.bukkit.event.block.SnowFormEvent
|
||||||
*/
|
*/
|
||||||
SNOW_FORM (Category.BLOCK),
|
SNOW_FORM (Category.BLOCK),
|
||||||
|
/**
|
||||||
|
* Called when a block is formed based on world conditions
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.block.BlockFormEvent
|
||||||
|
*/
|
||||||
|
BLOCK_FORM (Category.BLOCK),
|
||||||
|
/**
|
||||||
|
* Called when a block spreads based on world conditions
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.block.BlockSpreadEvent
|
||||||
|
*/
|
||||||
|
BLOCK_SPREAD (Category.BLOCK),
|
||||||
|
/**
|
||||||
|
* Called when a block fades, melts or disappears based on world conditions
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.block.BlockFadeEvent
|
||||||
|
*/
|
||||||
|
BLOCK_FADE (Category.BLOCK),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* INVENTORY EVENTS
|
* INVENTORY EVENTS
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.bukkit.event.block;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
/**
|
||||||
|
*Called when a block fades, melts or disappears based on world conditions
|
||||||
|
*/
|
||||||
|
public class BlockFadeEvent extends BlockEvent implements Cancellable {
|
||||||
|
private boolean cancelled;
|
||||||
|
private BlockState newState;
|
||||||
|
|
||||||
|
public BlockFadeEvent(Block block, BlockState newState) {
|
||||||
|
super(Type.BLOCK_FADE, block);
|
||||||
|
this.newState = newState;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state of the block that will be fading
|
||||||
|
*
|
||||||
|
* @return the block state
|
||||||
|
*/
|
||||||
|
public BlockState getNewState() {
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ice formation
|
||||||
|
*/
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.bukkit.event.block;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
/**
|
||||||
|
* Called when a block is formed or spreads based on world conditions
|
||||||
|
*/
|
||||||
|
public class BlockFormEvent extends BlockEvent implements Cancellable {
|
||||||
|
private boolean cancelled;
|
||||||
|
private BlockState newState;
|
||||||
|
|
||||||
|
public BlockFormEvent(Block block, BlockState newState) {
|
||||||
|
super(Type.BLOCK_FORM, block);
|
||||||
|
this.block = block;
|
||||||
|
this.newState = newState;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFormEvent(Type type, Block block, BlockState newState) {
|
||||||
|
super(type, block);
|
||||||
|
this.block = block;
|
||||||
|
this.newState = newState;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state of the block where it will form or spread to
|
||||||
|
*
|
||||||
|
* @return the block state
|
||||||
|
*/
|
||||||
|
public BlockState getNewState() {
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ice formation
|
||||||
|
*/
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -103,9 +103,32 @@ public class BlockListener implements Listener {
|
||||||
* Called when a world is attempting to place a block during a snowfall
|
* Called when a world is attempting to place a block during a snowfall
|
||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
|
* @deprecated be prepared to use onBlockForm instead as it will be replacing this event after the RB
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void onSnowForm(SnowFormEvent event) {}
|
public void onSnowForm(SnowFormEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a block is formed based on world conditions
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onBlockForm(BlockFormEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a block spreads based on world conditions
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onBlockSpread(BlockSpreadEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a block fades, melts or disappears based on world conditions
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onBlockFade(BlockFadeEvent event) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a block is dispensing an item
|
* Called when a block is dispensing an item
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.bukkit.event.block;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
/**
|
||||||
|
*Represents any event that spreads blocks
|
||||||
|
*/
|
||||||
|
public class BlockSpreadEvent extends BlockFormEvent {
|
||||||
|
private Block source;
|
||||||
|
|
||||||
|
public BlockSpreadEvent(Block block, Block source, BlockState newState) {
|
||||||
|
super(Type.BLOCK_SPREAD, block, newState);
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the source block
|
||||||
|
*
|
||||||
|
* @return the block state
|
||||||
|
*/
|
||||||
|
public Block getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
|
@ -490,6 +490,28 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case BLOCK_FORM:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((BlockListener) listener).onBlockForm((BlockFormEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
case BLOCK_SPREAD:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((BlockListener) listener).onBlockSpread((BlockSpreadEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
case BLOCK_FADE:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((BlockListener) listener).onBlockFade((BlockFadeEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
case BLOCK_DISPENSE:
|
case BLOCK_DISPENSE:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
public void execute(Listener listener, Event event) {
|
public void execute(Listener listener, Event event) {
|
||||||
|
|
Loading…
Reference in a new issue