Class CosmeticUnlockEvent

java.lang.Object
org.bukkit.event.Event
dev.itsharshxd.zentrix.api.events.ZentrixEvent
dev.itsharshxd.zentrix.api.events.cosmetics.CosmeticUnlockEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public final class CosmeticUnlockEvent extends ZentrixEvent implements org.bukkit.event.Cancellable
Called before cosmetics are unlocked for a player through the API: granted by an addon with CosmeticsService#grant or #grantTimed, or bought with CosmeticsService#purchase or in the cosmetics menu. The player may be offline.

Cancelling leaves the player's cosmetics as they are; a cancelled purchase takes no payment. Grants made by administrators' commands do not fire this event. CosmeticOwnershipChangeEvent reports every change after it was stored.

Main thread; only fired while a listener is registered.

Since:
1.11.0
  • Constructor Details

    • CosmeticUnlockEvent

      public CosmeticUnlockEvent(@NotNull @NotNull UUID playerId, @NotNull @NotNull CosmeticTypeKey type, @NotNull @NotNull Collection<String> cosmeticIds, @NotNull @NotNull CosmeticUnlockEvent.Cause cause, @Nullable @Nullable Duration duration, @Nullable @Nullable Double price)
      Parameters:
      duration - how long a timed grant lasts, or null for a permanent one
      price - what a purchase costs, or null for a grant
  • Method Details

    • getPlayerId

      @NotNull public @NotNull UUID getPlayerId()
      The player gaining them.
    • getType

      @NotNull public @NotNull CosmeticTypeKey getType()
      The type they belong to.
    • getCosmeticIds

      @NotNull public @NotNull Set<String> getCosmeticIds()
      The cosmetics unlocked.
    • getCause

      @NotNull public @NotNull CosmeticUnlockEvent.Cause getCause()
      How they are unlocked.
    • getDuration

      @NotNull public @NotNull Optional<Duration> getDuration()
      How long a timed grant lasts; empty for a permanent unlock.
    • getPrice

      @NotNull public @NotNull OptionalDouble getPrice()
      What a purchase costs; empty for a grant.
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Description copied from class: ZentrixEvent
      Gets the handler list for this event.
      Overrides:
      getHandlers in class ZentrixEvent
      Returns:
      The handler list
    • getHandlerList

      @NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()