mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-08 08:02:13 -07:00
SPIGOT-7617: Add BlockExplodeEvent#getExplodedBlockState()
By: 2008Choco <hawkeboyz2@hotmail.com>
This commit is contained in:
@@ -2,26 +2,38 @@ package org.bukkit.event.block;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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 {
|
public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel;
|
private boolean cancel;
|
||||||
|
private final BlockState blockState;
|
||||||
private final List<Block> blocks;
|
private final List<Block> blocks;
|
||||||
private float yield;
|
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);
|
super(what);
|
||||||
|
this.blockState = blockState;
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.yield = yield;
|
this.yield = yield;
|
||||||
this.cancel = false;
|
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
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancel;
|
return cancel;
|
||||||
@@ -32,6 +44,16 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
|||||||
this.cancel = cancel;
|
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
|
* Returns the list of blocks that would have been removed or were removed
|
||||||
* from the explosion event.
|
* from the explosion event.
|
||||||
|
Reference in New Issue
Block a user