All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.event.player.PlayerStartDiggingEvent Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
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;

/**
 * Called when a {@link Player} start digging a block,
 * can be used to forbid the {@link Player} from mining it.
 * 

* Be aware that cancelling this event does not necessary prevent the player from breaking the block * (could be because of high latency or a modified client) so cancelling {@link PlayerBlockBreakEvent} is also necessary. * Could be fixed in future Minestom version. */ public class PlayerStartDiggingEvent implements PlayerInstanceEvent, BlockEvent, CancellableEvent { private final Player player; private final Block block; private final BlockVec blockPosition; private final BlockFace blockFace; private boolean cancelled; public PlayerStartDiggingEvent(@NotNull Player player, @NotNull Block block, @NotNull BlockVec blockPosition, @NotNull BlockFace blockFace) { this.player = player; this.block = block; this.blockPosition = blockPosition; this.blockFace = blockFace; } /** * Gets the block which is being dug. * * @return the block */ @Override public @NotNull Block getBlock() { return block; } /** * Gets the block position. * * @return the block position */ @Override public @NotNull BlockVec getBlockPosition() { return blockPosition; } /** * Gets the face you are digging * * @return the block face */ public @NotNull BlockFace getBlockFace() { return blockFace; } @Override public boolean isCancelled() { return cancelled; } @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } @Override public @NotNull Player getPlayer() { return player; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy