Interface PotionMeta

All Superinterfaces:
Cloneable, ConfigurationSerializable, ItemMeta, PersistentDataHolder, PersistentDataViewHolder

public interface PotionMeta extends ItemMeta
Represents a potion or item that can have custom effects.
  • Method Details

    • setBasePotionData

      @Deprecated(since="1.20.6") void setBasePotionData(@Nullable @Nullable PotionData data)
      Deprecated.
      Upgraded / extended potions are now their own PotionType use setBasePotionType(org.bukkit.potion.PotionType) instead.
      Sets the underlying potion data
      Parameters:
      data - PotionData to set the base potion state to
    • getBasePotionData

      @Nullable @Deprecated(since="1.20.6") @Nullable PotionData getBasePotionData()
      Deprecated.
      Upgraded / extended potions are now their own PotionType use getBasePotionType() instead.
      Returns the potion data about the base potion
      Returns:
      a PotionData object
    • setBasePotionType

      void setBasePotionType(@Nullable @Nullable PotionType type)
      Sets the underlying potion type
      Parameters:
      type - PotionType to set the base potion state to
    • getBasePotionType

      @Nullable @Nullable PotionType getBasePotionType()
      Returns the potion type about the base potion
      Returns:
      a PotionType object
    • hasBasePotionType

      boolean hasBasePotionType()
      Checks for the presence of a base potion type
      Returns:
      true if a base potion type is present
    • hasCustomEffects

      boolean hasCustomEffects()
      Checks for the presence of custom potion effects.
      Returns:
      true if custom potion effects are applied
    • getCustomEffects

      @NotNull @NotNull List<PotionEffect> getCustomEffects()
      Gets an immutable list containing all custom potion effects applied to this potion.

      Plugins should check that hasCustomEffects() returns true before calling this method.

      Returns:
      the immutable list of custom potion effects
    • addCustomEffect

      boolean addCustomEffect(@NotNull @NotNull PotionEffect effect, boolean overwrite)
      Adds a custom potion effect to this potion.
      Parameters:
      effect - the potion effect to add
      overwrite - true if any existing effect of the same type should be overwritten
      Returns:
      true if the potion meta changed as a result of this call
    • removeCustomEffect

      boolean removeCustomEffect(@NotNull @NotNull PotionEffectType type)
      Removes a custom potion effect from this potion.
      Parameters:
      type - the potion effect type to remove
      Returns:
      true if the potion meta changed as a result of this call
    • hasCustomEffect

      boolean hasCustomEffect(@NotNull @NotNull PotionEffectType type)
      Checks for a specific custom potion effect type on this potion.
      Parameters:
      type - the potion effect type to check for
      Returns:
      true if the potion has this effect
    • setMainEffect

      @Deprecated(since="1.9") boolean setMainEffect(@NotNull @NotNull PotionEffectType type)
      Moves a potion effect to the top of the potion effect list.

      This causes the client to display the potion effect in the potion's name.

      Parameters:
      type - the potion effect type to move
      Returns:
      true if the potion meta changed as a result of this call
    • clearCustomEffects

      boolean clearCustomEffects()
      Removes all custom potion effects from this potion.
      Returns:
      true if the potion meta changed as a result of this call
    • hasColor

      boolean hasColor()
      Checks for existence of a potion color.
      Returns:
      true if this has a custom potion color
    • getColor

      Gets the potion color that is set. A custom potion color will alter the display of the potion in an inventory slot.

      Plugins should check that hasColor() returns true before calling this method.

      Returns:
      the potion color that is set
    • setColor

      void setColor(@Nullable @Nullable Color color)
      Sets the potion color. A custom potion color will alter the display of the potion in an inventory slot.
      Parameters:
      color - the color to set
    • hasCustomName

      @Deprecated(forRemoval=true, since="1.21.4") default boolean hasCustomName()
      Deprecated, for removal: This API element is subject to removal in a future version.
      conflicting name, use hasCustomPotionName()
      Checks for existence of a custom potion name translation suffix.
      Specified by:
      hasCustomName in interface ItemMeta
      Returns:
      true if this has a custom potion name
    • getCustomName

      @Deprecated(forRemoval=true, since="1.21.4") @Nullable default @Nullable String getCustomName()
      Deprecated, for removal: This API element is subject to removal in a future version.
      conflicting name, use getCustomPotionName()
      Gets the potion name translation suffix that is set.

      Plugins should check that hasCustomPotionName() returns true before calling this method.

      Returns:
      the potion name that is set
    • setCustomName

      @Deprecated(forRemoval=true, since="1.21.4") default void setCustomName(@Nullable @Nullable String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      conflicting name, use setCustomPotionName(String)
      Sets the potion name translation suffix.
      Parameters:
      name - the name to set
    • hasCustomPotionName

      boolean hasCustomPotionName()
      Checks for existence of a custom potion name translation suffix.
      Returns:
      true if this has a custom potion name
    • getCustomPotionName

      @Nullable @Nullable String getCustomPotionName()
      Gets the potion name translation suffix that is set.

      Plugins should check that hasCustomPotionName() returns true before calling this method.

      Returns:
      the potion name that is set
    • setCustomPotionName

      void setCustomPotionName(@Nullable @Nullable String name)
      Sets the potion name translation suffix.
      Parameters:
      name - the name to set
    • clone

      PotionMeta clone()
      Specified by:
      clone in interface ItemMeta