Class PotionBuilder
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.PotionBuilder
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 Summary
ConstructorsConstructorDescriptionPotionBuilder
(@NotNull org.bukkit.Material material, int amount) Constructs aPotionBuilder
with the specifiedMaterial
and amount.PotionBuilder
(@NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aPotionBuilder
using an existingItemStack
. -
Method Summary
Modifier and TypeMethodDescriptionaddCustomEffect
(@NotNull org.bukkit.potion.PotionEffect effect, boolean overwrite) Adds a custom potion effect.org.bukkit.potion.PotionType
Gets the base potion type.org.bukkit.Color
getColor()
Gets the potion color.List
<org.bukkit.potion.PotionEffect> Gets all custom potion effects.Gets the custom name of the potion.boolean
hasColor()
Checks if the potion has a custom color.boolean
Checks if the potion has any custom effects.boolean
Checks if the potion has a custom name.boolean
removeCustomEffect
(@NotNull org.bukkit.potion.PotionEffectType type) Removes a custom potion effect by type.setBasePotionType
(@NotNull org.bukkit.potion.PotionType type) Sets the base potion type.setColor
(@NotNull org.bukkit.Color color) Sets the potion color.setCustomName
(@NotNull String name) Sets a custom name for the potion.Methods inherited from class io.github.lucfr1746.llibrary.itemstack.ItemBuilder
addAttributeModifier, addEnchant, addEnchant, addEnchant, addItemFlags, addLore, build, getAmount, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCustomModelData, getDamageResistant, getDisplayName, getEnchantable, getEnchantLevel, getEnchantmentGlintOverride, getEnchants, getEquippableComponent, getFoodComponent, getItemFlags, getItemMeta, getItemModel, getJukeboxPlayableComponent, getMaxStackSize, getRarity, getToolComponent, getTooltipStyle, getTranslationKey, getType, getUseCooldownComponent, getUseRemainder, hasAttributeModifiers, hasConflictingEnchant, hasCustomModelData, hasDamageResistant, hasEnchant, hasEnchantable, hasEnchantmentGlintOverride, hasEnchants, hasEquippableComponent, hasFoodComponent, hasItemFlag, hasItemModel, hasJukeboxPlayableComponent, hasMaxStackSize, hasRarity, hasToolComponent, hasTooltipStyle, hasUseCooldownComponent, hasUseRemainder, hideAllItemFlags, insertLore, isGlider, isHideTooltip, isUnbreakable, removeAttributeModifier, removeAttributeModifier, removeAttributeModifier, removeEnchant, removeEnchants, removeItemFlags, replaceLore, setAmount, setAttributeModifiers, setCustomModelData, setDamageResistant, setDisplayName, setEnchantable, setEnchantmentGlintOverride, setEquippableComponent, setEquippableComponent, setFood, setFoodComponent, setGlider, setHideTooltip, setItemModel, setItemModel, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setLores, setLores, setMaxStackSize, setRarity, setToolComponent, setToolComponent, setTooltipStyle, setTooltipStyle, setType, setUnbreakable, setUseCooldownComponent, setUseCooldownComponent, setUseCooldownComponent, setUseRemainder
-
Constructor Details
-
PotionBuilder
public PotionBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aPotionBuilder
using an existingItemStack
.- Parameters:
itemStack
- the item stack to modify- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofPotionMeta
-
PotionBuilder
public PotionBuilder(@NotNull @NotNull org.bukkit.Material material, int amount) Constructs aPotionBuilder
with the specifiedMaterial
and amount.- Parameters:
material
- the material for the item stackamount
- the quantity of items in the stack- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofPotionMeta
-
-
Method Details
-
setBasePotionType
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 addoverwrite
- 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
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
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
Sets a custom name for the potion.- Parameters:
name
- the custom name to set- Returns:
- this
PotionBuilder
instance for chaining
-
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
-