net.minestom.server.event.player.PlayerBlockBreakEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.event.player;
import net.minestom.server.coordinate.BlockVec;
import net.minestom.server.coordinate.Point;
import net.minestom.server.entity.Player;
import net.minestom.server.event.trait.BlockEvent;
import net.minestom.server.event.trait.CancellableEvent;
import net.minestom.server.event.trait.PlayerInstanceEvent;
import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.block.BlockFace;
import org.jetbrains.annotations.NotNull;
public class PlayerBlockBreakEvent implements PlayerInstanceEvent, BlockEvent, CancellableEvent {
private final Player player;
private final Block block;
private Block resultBlock;
private final BlockVec blockPosition;
private final BlockFace blockFace;
private boolean cancelled;
public PlayerBlockBreakEvent(@NotNull Player player,
@NotNull Block block, @NotNull Block resultBlock, @NotNull BlockVec blockPosition,
@NotNull BlockFace blockFace) {
this.player = player;
this.block = block;
this.resultBlock = resultBlock;
this.blockPosition = blockPosition;
this.blockFace = blockFace;
}
/**
* Gets the block to break
*
* @return the block
*/
@Override
public @NotNull Block getBlock() {
return block;
}
/**
* Gets the block which will replace {@link #getBlock()}.
*
* @return the result block
*/
public @NotNull Block getResultBlock() {
return resultBlock;
}
/**
* Gets the face at which the block was broken
*
* @return the block face
*/
public @NotNull BlockFace getBlockFace() {
return blockFace;
}
/**
* Changes the result of the event.
*
* @param resultBlock the new block
*/
public void setResultBlock(@NotNull Block resultBlock) {
this.resultBlock = resultBlock;
}
/**
* Gets the block position.
*
* @return the block position
*/
@Override
public @NotNull BlockVec getBlockPosition() {
return blockPosition;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public @NotNull Player getPlayer() {
return player;
}
}