mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
SPIGOT-824: SpongeAbsorbEvent
This commit is contained in:
parent
b848d8ce63
commit
b7b10ad1c3
1 changed files with 60 additions and 0 deletions
60
src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
Normal file
60
src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package org.bukkit.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Called when a sponge absorbs water from the world.
|
||||
* <br>
|
||||
* The world will be in its previous state, and {@link #getBlocks()} will
|
||||
* represent the changes to be made to the world, if the event is not cancelled.
|
||||
* <br>
|
||||
* As this is a physics based event it may be called multiple times for "the
|
||||
* same" changes.
|
||||
*/
|
||||
public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final List<BlockState> blocks;
|
||||
|
||||
public SpongeAbsorbEvent(Block block, List<BlockState> waterblocks) {
|
||||
super(block);
|
||||
this.blocks = waterblocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all blocks to be removed by the sponge.
|
||||
* <br>
|
||||
* This list is mutable and contains the blocks in their removed state, i.e.
|
||||
* having a type of {@link Material#AIR}.
|
||||
*
|
||||
* @return list of the to be removed blocks.
|
||||
*/
|
||||
public List<BlockState> getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue