mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-22 08:11:59 +01:00
Reworked BlockDamageEvent to match with the latest Mojang client/server changes.
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
parent
7824cc02e7
commit
1a8031fc8f
@ -1,15 +0,0 @@
|
|||||||
package org.bukkit.block;
|
|
||||||
|
|
||||||
public enum BlockDamageLevel {
|
|
||||||
STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2);
|
|
||||||
|
|
||||||
private int level;
|
|
||||||
|
|
||||||
private BlockDamageLevel(final int level) {
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel() {
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +1,24 @@
|
|||||||
package org.bukkit.event.block;
|
package org.bukkit.event.block;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockDamageLevel;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tkelly
|
* @author tkelly
|
||||||
*/
|
*/
|
||||||
public class BlockDamageEvent extends BlockEvent implements Cancellable {
|
public class BlockDamageEvent extends BlockEvent implements Cancellable {
|
||||||
private Player player;
|
private Player player;
|
||||||
private BlockDamageLevel damageLevel;
|
private boolean instaBreak;
|
||||||
private boolean cancel;
|
private boolean cancel;
|
||||||
|
private ItemStack itemstack;
|
||||||
|
|
||||||
public BlockDamageEvent(Type type, Block block, BlockDamageLevel level, Player player) {
|
public BlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
|
||||||
super(type, block);
|
super(Type.BLOCK_DAMAGE, block);
|
||||||
this.damageLevel = level;
|
this.instaBreak = instaBreak;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
this.itemstack = itemstack;
|
||||||
this.cancel = false;
|
this.cancel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,14 +32,31 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the level of damage to the block
|
* Returns if the block is set to instantly break
|
||||||
*
|
*
|
||||||
* @return
|
* @return boolean If the block should instantly break
|
||||||
*/
|
*/
|
||||||
public BlockDamageLevel getDamageLevel() {
|
public boolean getInstaBreak() {
|
||||||
return damageLevel;
|
return instaBreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if the block should instantly break
|
||||||
|
*/
|
||||||
|
public void setInstaBreak(boolean bool) {
|
||||||
|
this.instaBreak = bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ItemStack in hand
|
||||||
|
*
|
||||||
|
* @return Currently wielding itemstack
|
||||||
|
*/
|
||||||
|
public ItemStack getItemInHand() {
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user