mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 03:22:19 +01:00
Add PlayerItemDamageEvent
By: md_5 <md_5@live.com.au>
This commit is contained in:
parent
2f1a805931
commit
c4d30af0eb
1 changed files with 65 additions and 0 deletions
|
@ -0,0 +1,65 @@
|
|||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Called when an item used by the player takes durability damage as a result of
|
||||
* being used.
|
||||
*/
|
||||
public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ItemStack item;
|
||||
private int damage;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PlayerItemDamageEvent(Player player, ItemStack what, int damage) {
|
||||
super(player);
|
||||
this.item = what;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item being damaged.
|
||||
*
|
||||
* @return the item
|
||||
*/
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of durability damage this item will be taking.
|
||||
*
|
||||
* @return durability change
|
||||
*/
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue