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
Represents when a player has an item repaired via the Mending enchantment.
 
This event is fired directly before the
This event is fired directly before the
PlayerExpChangeEvent, and the
 results of this event directly affect the PlayerExpChangeEvent.- 
Nested Class SummaryNested classes/interfaces inherited from class org.bukkit.event.EventEvent.Result
- 
Field SummaryFields inherited from class org.bukkit.event.player.PlayerEventplayer
- 
Constructor SummaryConstructorsConstructorDescriptionPlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull ExperienceOrb experienceOrb, int repairAmount) Deprecated.PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull EquipmentSlot slot, @NotNull ExperienceOrb experienceOrb, int repairAmount) Deprecated.PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull EquipmentSlot slot, @NotNull ExperienceOrb experienceOrb, int repairAmount, IntUnaryOperator durabilityToXpOp) 
- 
Method SummaryModifier and TypeMethodDescriptionintHelper method to get the amount of experience that will be consumed.Get the operation used to calculate xp used based on the set repair amount.Get the experience orb triggering the event.static @NotNull HandlerListgetItem()Get theItemStackto be repaired.intGet the amount the item is to be repaired.getSlot()Get theEquipmentSlotin which the repairedItemStackmay be found.booleanGets the cancellation state of this event.voidsetCancelled(boolean cancelled) Sets the cancellation state of this event.voidsetDurabilityToXpOperation(IntUnaryOperator durabilityToXpOp) Sets the operation used to calculate xp used based on the set repair amount.voidsetRepairAmount(int amount) Set the amount the item will be repaired.Methods inherited from class org.bukkit.event.player.PlayerEventgetPlayerMethods inherited from class org.bukkit.event.EventcallEvent, getEventName, isAsynchronous
- 
Constructor Details- 
PlayerItemMendEvent@Deprecated public PlayerItemMendEvent(@NotNull @NotNull Player who, @NotNull @NotNull ItemStack item, @NotNull @NotNull EquipmentSlot slot, @NotNull @NotNull ExperienceOrb experienceOrb, int repairAmount) Deprecated.
- 
PlayerItemMendEvent@Internal public PlayerItemMendEvent(@NotNull @NotNull Player who, @NotNull @NotNull ItemStack item, @NotNull @NotNull EquipmentSlot slot, @NotNull @NotNull ExperienceOrb experienceOrb, int repairAmount, @NotNull IntUnaryOperator durabilityToXpOp) 
- 
PlayerItemMendEvent@Deprecated public PlayerItemMendEvent(@NotNull @NotNull Player who, @NotNull @NotNull ItemStack item, @NotNull @NotNull ExperienceOrb experienceOrb, int repairAmount) Deprecated.
 
- 
- 
Method Details- 
getDurabilityToXpOperationGet the operation used to calculate xp used based on the set repair amount. Used to calculate how much of an XP orb will be consumed by this mend operation.- Returns:
- the durability-to-xp operation
 
- 
setDurabilityToXpOperationSets the operation used to calculate xp used based on the set repair amount. Used to calculate how much of an XP orb will be consumed by this mend operation.- Parameters:
- durabilityToXpOp- the durability-to-xp operation
 
- 
getConsumedExperiencepublic int getConsumedExperience()Helper method to get the amount of experience that will be consumed. This method just returns the result of inputtinggetRepairAmount()into the functiongetDurabilityToXpOperation().- Returns:
- the amount of xp that will be consumed
 
- 
getItemGet theItemStackto be repaired. This is not necessarily the item the player is holding.- Returns:
- the item to be repaired
 
- 
getSlotGet theEquipmentSlotin which the repairedItemStackmay be found.- Returns:
- the repaired slot
 
- 
getExperienceOrbGet the experience orb triggering the event.- Returns:
- the experience orb
 
- 
getRepairAmountpublic 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
 
- 
setRepairAmountpublic 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
 
- 
isCancelledpublic boolean isCancelled()Description copied from interface:CancellableGets 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:
- isCancelledin interface- Cancellable
- Returns:
- true if this event is cancelled
 
- 
setCancelledpublic void setCancelled(boolean cancelled) Description copied from interface:CancellableSets 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:
- setCancelledin interface- Cancellable
- Parameters:
- cancelled- true if you wish to cancel this event
 
- 
getHandlers- Specified by:
- getHandlersin class- Event
 
- 
getHandlerList
 
-