mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
SPIGOT-7617: Add BlockExplodeEvent#getExplodedBlockState()
By: 2008Choco <hawkeboyz2@hotmail.com>
This commit is contained in:
parent
74cf79c267
commit
d8e657a271
1 changed files with 24 additions and 2 deletions
|
@ -2,26 +2,38 @@ package org.bukkit.event.block;
|
|||
|
||||
import java.util.List;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a block explodes
|
||||
* Called when a block explodes.
|
||||
* <p>
|
||||
* Note that due to the nature of explosions, {@link #getBlock()} will always be
|
||||
* an air block. {@link #getExplodedBlockState()} should be used to get
|
||||
* information about the block state that exploded.
|
||||
*/
|
||||
public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel;
|
||||
private final BlockState blockState;
|
||||
private final List<Block> blocks;
|
||||
private float yield;
|
||||
|
||||
public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) {
|
||||
public BlockExplodeEvent(@NotNull final Block what, @NotNull final BlockState blockState, @NotNull final List<Block> blocks, final float yield) {
|
||||
super(what);
|
||||
this.blockState = blockState;
|
||||
this.blocks = blocks;
|
||||
this.yield = yield;
|
||||
this.cancel = false;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) {
|
||||
this(what, what.getState(), blocks, yield);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
|
@ -32,6 +44,16 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
|||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the captured BlockState of the block that exploded.
|
||||
*
|
||||
* @return the block state
|
||||
*/
|
||||
@NotNull
|
||||
public BlockState getExplodedBlockState() {
|
||||
return blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of blocks that would have been removed or were removed
|
||||
* from the explosion event.
|
||||
|
|
Loading…
Reference in a new issue