Class 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 the PlayerExpChangeEvent, and the results of this event directly affect the PlayerExpChangeEvent.
  • Constructor Details

  • Method Details

    • getDurabilityToXpOperation

      @Contract("-> fail") @Deprecated(forRemoval=true, since="1.21") @NotNull public IntUnaryOperator getDurabilityToXpOperation()
      Deprecated, for removal: This API element is subject to removal in a future version.
      the mending enchantment uses enchantment effects to compute how much durability is granted per xp. The enchantment effects operation are too complex to reliably offer the inverse function.
      Get 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
    • setDurabilityToXpOperation

      @Contract("_ -> fail") @Deprecated(forRemoval=true, since="1.21") public void setDurabilityToXpOperation(@NotNull IntUnaryOperator durabilityToXpOp)
      Deprecated, for removal: This API element is subject to removal in a future version.
      the mending enchantment uses enchantment effects to compute how much durability is granted per xp. The enchantment effects operation are too complex to reliably offer the inverse function.
      Sets 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
    • getConsumedExperience

      public int getConsumedExperience()
      Helper method to get the amount of experience that will be consumed. This method just returns the result of inputting getRepairAmount() into the function getDurabilityToXpOperation().
      Returns:
      the amount of xp that will be consumed
    • getItem

      @NotNull public @NotNull ItemStack getItem()
      Get the ItemStack to be repaired. This is not necessarily the item the player is holding.
      Returns:
      the item to be repaired
    • getSlot

      @NotNull public @NotNull EquipmentSlot getSlot()
      Get the EquipmentSlot in which the repaired ItemStack may be found.
      Returns:
      the repaired slot
    • getExperienceOrb

      @NotNull public @NotNull 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 interface Cancellable
      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 interface Cancellable
      Parameters:
      cancelled - true if you wish to cancel this event
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()