Class PotionBuilder

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.PotionBuilder

public class PotionBuilder extends ItemBuilder
The PotionBuilder class extends ItemBuilder to provide additional functionality for modifying PotionMeta of an ItemStack. This class allows setting potion types, custom effects, and colors.
  • Constructor Details

    • PotionBuilder

      public PotionBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Constructs a PotionBuilder using an existing ItemStack.
      Parameters:
      itemStack - the item stack to modify
      Throws:
      IllegalArgumentException - if the item's meta is not an instance of PotionMeta
    • PotionBuilder

      public PotionBuilder(@NotNull @NotNull org.bukkit.Material material, int amount)
      Constructs a PotionBuilder with the specified Material and amount.
      Parameters:
      material - the material for the item stack
      amount - the quantity of items in the stack
      Throws:
      IllegalArgumentException - if the item's meta is not an instance of PotionMeta
  • Method Details

    • setBasePotionType

      public PotionBuilder setBasePotionType(@NotNull @NotNull org.bukkit.potion.PotionType type)
      Sets the base potion type.
      Parameters:
      type - the base potion type to set
      Returns:
      this PotionBuilder instance for chaining
    • getBasePotionType

      public org.bukkit.potion.PotionType getBasePotionType()
      Gets the base potion type.
      Returns:
      the base potion type
    • addCustomEffect

      public PotionBuilder addCustomEffect(@NotNull @NotNull org.bukkit.potion.PotionEffect effect, boolean overwrite)
      Adds a custom potion effect.
      Parameters:
      effect - the custom potion effect to add
      overwrite - whether to overwrite existing effects of the same type
      Returns:
      this PotionBuilder instance for chaining
    • removeCustomEffect

      public boolean removeCustomEffect(@NotNull @NotNull org.bukkit.potion.PotionEffectType type)
      Removes a custom potion effect by type.
      Parameters:
      type - the type of potion effect to remove
      Returns:
      true if the effect was removed, false if it did not exist
    • getCustomEffects

      public List<org.bukkit.potion.PotionEffect> getCustomEffects()
      Gets all custom potion effects.
      Returns:
      a list of custom potion effects
    • hasCustomEffects

      public boolean hasCustomEffects()
      Checks if the potion has any custom effects.
      Returns:
      true if there are custom effects, false otherwise
    • setColor

      public PotionBuilder setColor(@NotNull @NotNull org.bukkit.Color color)
      Sets the potion color.
      Parameters:
      color - the color to set
      Returns:
      this PotionBuilder instance for chaining
    • getColor

      public org.bukkit.Color getColor()
      Gets the potion color.
      Returns:
      the potion color, or null if not set
    • hasColor

      public boolean hasColor()
      Checks if the potion has a custom color.
      Returns:
      true if a color is set, false otherwise
    • setCustomName

      public PotionBuilder setCustomName(@NotNull @NotNull String name)
      Sets a custom name for the potion.
      Parameters:
      name - the custom name to set
      Returns:
      this PotionBuilder instance for chaining
    • getCustomName

      public String getCustomName()
      Gets the custom name of the potion.
      Returns:
      the custom name, or null if not set
    • hasCustomName

      public boolean hasCustomName()
      Checks if the potion has a custom name.
      Returns:
      true if a custom name is set, false otherwise