Package org.bukkit.event.player
Class PlayerItemMendEvent
- java.lang.Object
-
- org.bukkit.event.Event
-
- org.bukkit.event.player.PlayerEvent
-
- org.bukkit.event.player.PlayerItemMendEvent
-
- All Implemented Interfaces:
Cancellable
public class PlayerItemMendEvent extends PlayerEvent implements Cancellable
Represents when a player has an item repaired via the Mending enchantment.
This event is fired directly before thePlayerExpChangeEvent
, and the results of this event directly affect thePlayerExpChangeEvent
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result
-
-
Field Summary
-
Fields inherited from class org.bukkit.event.player.PlayerEvent
player
-
-
Constructor Summary
Constructors Constructor Description PlayerItemMendEvent(Player who, ItemStack item, ExperienceOrb experienceOrb, int repairAmount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExperienceOrb
getExperienceOrb()
Get the experience orb triggering the event.static HandlerList
getHandlerList()
HandlerList
getHandlers()
ItemStack
getItem()
Get theItemStack
to be repaired.int
getRepairAmount()
Get the amount the item is to be repaired.boolean
isCancelled()
Gets the cancellation state of this event.void
setCancelled(boolean cancelled)
Sets the cancellation state of this event.void
setRepairAmount(int amount)
Set the amount the item will be repaired.-
Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayer
-
Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
-
-
-
Constructor Detail
-
PlayerItemMendEvent
public PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull ExperienceOrb experienceOrb, int repairAmount)
-
-
Method Detail
-
getItem
@NotNull public ItemStack getItem()
Get theItemStack
to be repaired. This is not necessarily the item the player is holding.- Returns:
- the item to be repaired
-
getExperienceOrb
@NotNull public ExperienceOrb getExperienceOrb()
Get the experience orb triggering the event.- Returns:
- the experience orb
-
getRepairAmount
public int getRepairAmount()
Get the amount the item is to be repaired. The default value is twice the value of the consumed experience orb or the remaining damage left on the item, whichever is smaller.- Returns:
- how much damage will be repaired by the experience orb
-
setRepairAmount
public void setRepairAmount(int amount)
Set the amount the item will be repaired. Half of this value will be subtracted from the experience orb which initiated this event.- Parameters:
amount
- how much damage will be repaired on the item
-
isCancelled
public boolean isCancelled()
Description copied from interface:Cancellable
Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins- Specified by:
isCancelled
in interfaceCancellable
- Returns:
- true if this event is cancelled
-
setCancelled
public void setCancelled(boolean cancelled)
Description copied from interface:Cancellable
Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.- Specified by:
setCancelled
in interfaceCancellable
- Parameters:
cancelled
- true if you wish to cancel this event
-
getHandlers
@NotNull public HandlerList getHandlers()
- Specified by:
getHandlers
in classEvent
-
getHandlerList
@NotNull public static HandlerList getHandlerList()
-
-