Class ConsumableApplyEffect
java.lang.Object
valorless.rarespawns.builders.components.ConsumableApplyEffect
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable,org.bukkit.inventory.meta.components.consumable.effects.ConsumableApplyEffects,org.bukkit.inventory.meta.components.consumable.effects.ConsumableEffect
public class ConsumableApplyEffect
extends Object
implements org.bukkit.inventory.meta.components.consumable.effects.ConsumableApplyEffects
Represents a consumable effect for RareSpawns items.
Implements
ConsumableApplyEffects to apply potion effects with a probability when consumed.
Supports serialization and deserialization for configuration storage.-
Constructor Summary
ConstructorsConstructorDescriptionConsumableApplyEffect(List<org.bukkit.potion.PotionEffect> effects, float probability) Constructs a ConsumableApplyEffect with a list of effects and probability.ConsumableApplyEffect(org.bukkit.potion.PotionEffect... effects) Constructs a ConsumableApplyEffect with one or more potion effects (always applies).ConsumableApplyEffect(org.bukkit.potion.PotionEffect effect, float probability) Constructs a ConsumableApplyEffect with a single effect and probability. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.potion.PotionEffectaddEffect(org.bukkit.potion.PotionEffect effect) Adds a potion effect to the list.static ConsumableApplyEffectdeserialize(Map<String, Object> map) Deserializes a ConsumableApplyEffect from configuration data.List<org.bukkit.potion.PotionEffect> Gets an immutable list of potion effects to apply.floatGets the probability that the effects are applied.Serializes the ConsumableApplyEffect for configuration storage.voidsetEffects(List<org.bukkit.potion.PotionEffect> effects) Sets the list of potion effects to apply.voidsetProbability(float probability) Sets the probability that the effects are applied.
-
Constructor Details
-
ConsumableApplyEffect
public ConsumableApplyEffect(org.bukkit.potion.PotionEffect... effects) Constructs a ConsumableApplyEffect with one or more potion effects (always applies).- Parameters:
effects- One or more PotionEffect objects.
-
ConsumableApplyEffect
public ConsumableApplyEffect(org.bukkit.potion.PotionEffect effect, float probability) Constructs a ConsumableApplyEffect with a single effect and probability.- Parameters:
effect- The PotionEffect to apply.probability- The probability to apply the effect (0.0-1.0).
-
ConsumableApplyEffect
Constructs a ConsumableApplyEffect with a list of effects and probability.- Parameters:
effects- List of PotionEffect objects.probability- The probability to apply the effects (0.0-1.0).
-
-
Method Details
-
getEffects
Gets an immutable list of potion effects to apply.- Specified by:
getEffectsin interfaceorg.bukkit.inventory.meta.components.consumable.effects.ConsumableApplyEffects- Returns:
- List of PotionEffect objects.
-
setEffects
Sets the list of potion effects to apply.- Specified by:
setEffectsin interfaceorg.bukkit.inventory.meta.components.consumable.effects.ConsumableApplyEffects- Parameters:
effects- List of PotionEffect objects.
-
addEffect
public org.bukkit.potion.PotionEffect addEffect(org.bukkit.potion.PotionEffect effect) Adds a potion effect to the list.- Specified by:
addEffectin interfaceorg.bukkit.inventory.meta.components.consumable.effects.ConsumableApplyEffects- Parameters:
effect- The PotionEffect to add.- Returns:
- The added PotionEffect.
-
getProbability
public float getProbability()Gets the probability that the effects are applied.- Specified by:
getProbabilityin interfaceorg.bukkit.inventory.meta.components.consumable.effects.ConsumableApplyEffects- Returns:
- Probability value (0.0-1.0).
-
setProbability
public void setProbability(float probability) Sets the probability that the effects are applied.- Specified by:
setProbabilityin interfaceorg.bukkit.inventory.meta.components.consumable.effects.ConsumableApplyEffects- Parameters:
probability- Probability value (0.0-1.0).
-
serialize
Serializes the ConsumableApplyEffect for configuration storage.- Specified by:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable- Returns:
- Map of serialized data.
-
deserialize
Deserializes a ConsumableApplyEffect from configuration data.- Parameters:
map- The serialized data map.- Returns:
- A new ConsumableApplyEffect instance.
-