Package com.cryptomorin.xseries
Enum XPotion
- All Implemented Interfaces:
Serializable
,Comparable<XPotion>
,java.lang.constant.Constable
public enum XPotion extends Enum<XPotion>
Potion type support for multiple aliases.
Uses EssentialsX potion list for aliases.
Duration: The duration of the effect in ticks. Values 0 or lower are treated as 1. Optional, and defaults to 1 tick. Amplifier: The amplifier of the effect, with level I having value 0. Optional, and defaults to level I.
EssentialsX Potions: https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/Potions.java Status Effect: https://minecraft.gamepedia.com/Status_effect Potions: https://minecraft.gamepedia.com/Potion
- Version:
- 2.0.1
- Author:
- Crypto Morin
- See Also:
PotionEffect
,PotionEffectType
,PotionType
-
Nested Class Summary
-
Enum Constant Summary
-
Field Summary
-
Method Summary
Modifier and Type Method Description static void
addPotionEffectsFromString(org.bukkit.entity.Player player, List<String> effects)
Add a list of potion effects to a player from a string list, usually from config.static org.bukkit.inventory.ItemStack
buildItemWithEffects(org.bukkit.Material type, org.bukkit.Color color, org.bukkit.potion.PotionEffect... effects)
Builds an item with the given type, color and effects.static boolean
canHaveEffects(org.bukkit.Material material)
Checks if a material can have potion effects.org.bukkit.potion.PotionType
getPotionType()
Deprecated.not for removal, but usePotionEffectType
instead.boolean
isSupported()
Checks if this potion is supported in the current Minecraft version.static Optional<XPotion>
matchXPotion(String potion)
Parses a potion effect type from the given string.static XPotion
matchXPotion(org.bukkit.potion.PotionEffectType type)
Parses the XPotion for this potion effect.org.bukkit.potion.PotionEffect
parsePotion(int duration, int amplifier)
Builds a potion effect with the given duration and amplifier.static org.bukkit.potion.PotionEffect
parsePotionEffectFromString(String potion)
Parse aPotionEffect
from a string, usually from config.org.bukkit.potion.PotionEffectType
parsePotionEffectType()
Parses the potion effect type.static org.bukkit.entity.ThrownPotion
throwPotion(org.bukkit.entity.LivingEntity entity, org.bukkit.Color color, org.bukkit.potion.PotionEffect... effects)
Throws a splash potion from the target entity.String
toString()
In most cases your should be usingEnum.name()
instead.static XPotion
valueOf(String name)
Returns the enum constant of this type with the specified name.static XPotion[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ABSORPTION
-
BAD_OMEN
-
BLINDNESS
-
CONDUIT_POWER
-
CONFUSION
-
DAMAGE_RESISTANCE
-
DOLPHINS_GRACE
-
FAST_DIGGING
-
FIRE_RESISTANCE
-
GLOWING
-
HARM
-
HEAL
-
HEALTH_BOOST
-
HERO_OF_THE_VILLAGE
-
HUNGER
-
INCREASE_DAMAGE
-
INVISIBILITY
-
JUMP
-
LEVITATION
-
LUCK
-
NIGHT_VISION
-
POISON
-
REGENERATION
-
SATURATION
-
SLOW
-
SLOW_DIGGING
-
SLOW_FALLING
-
SPEED
-
UNLUCK
-
WATER_BREATHING
-
WEAKNESS
-
WITHER
-
-
Field Details
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
matchXPotion
Parses a potion effect type from the given string. Supports type IDs.- Parameters:
potion
- the type of the type's ID of the potion effect type.- Returns:
- a potion effect type.
- Since:
- 1.0.0
-
matchXPotion
Parses the XPotion for this potion effect.- Parameters:
type
- the potion effect type.- Returns:
- the XPotion of this potion effect.
- Throws:
IllegalArgumentException
- may be thrown as an unexpected exception.- Since:
- 1.0.0
-
parsePotionEffectFromString
@Nullable public static org.bukkit.potion.PotionEffect parsePotionEffectFromString(@Nullable String potion)Parse aPotionEffect
from a string, usually from config. Supports potion type IDs.WEAKNESS, 30, 1 SLOWNESS 200 10 1, 10000, 100
- Parameters:
potion
- the potion string to parse.- Returns:
- a potion effect, or null if the potion type is wrong.
- Since:
- 1.0.0
- See Also:
parsePotion(int, int)
-
addPotionEffectsFromString
public static void addPotionEffectsFromString(@Nonnull org.bukkit.entity.Player player, @Nullable List<String> effects)Add a list of potion effects to a player from a string list, usually from config.- Parameters:
player
- the player to add potion effects to.effects
- the list of potion effects to parse and add to the player.- Since:
- 1.0.0
- See Also:
parsePotionEffectFromString(String)
-
throwPotion
@Nonnull public static org.bukkit.entity.ThrownPotion throwPotion(@Nonnull org.bukkit.entity.LivingEntity entity, @Nullable org.bukkit.Color color, @Nullable org.bukkit.potion.PotionEffect... effects)Throws a splash potion from the target entity. This method is only compatible for 1.9+- Parameters:
entity
- the entity to throw the potion from.color
- the color of the potion's bottle.effects
- the effects of the potion.- Returns:
- a thrown splash potion.
- Since:
- 1.0.0
-
buildItemWithEffects
@Nonnull public static org.bukkit.inventory.ItemStack buildItemWithEffects(@Nonnull org.bukkit.Material type, @Nullable org.bukkit.Color color, @Nullable org.bukkit.potion.PotionEffect... effects)Builds an item with the given type, color and effects. This method is only compatible for 1.9+The item type must be one of the following:
Material.POTION
Material.SPLASH_POTION
Material.LINGERING_POTION
Material.TIPPED_ARROW
- Parameters:
type
- the type of the potion.color
- the color of the potion's bottle.effects
- the effects of the potion.- Returns:
- an item with the specified effects.
- Since:
- 1.0.0
-
canHaveEffects
Checks if a material can have potion effects. This method does not check forLEGACY
materials. You should avoid using them or use XMaterial instead.- Parameters:
material
- the material to check.- Returns:
- true if the material is a potion, otherwise false.
- Since:
- 1.0.0
-
parsePotionEffectType
Parses the potion effect type.- Returns:
- the parsed potion effect type.
- Since:
- 1.0.0
- See Also:
getPotionType()
-
isSupported
public boolean isSupported()Checks if this potion is supported in the current Minecraft version.An invocation of this method yields exactly the same result as the expression:
parsePotionEffectType()
!= null- Returns:
- true if the current version has this potion effect type, otherwise false.
- Since:
- 1.0.0
-
getPotionType
Deprecated.not for removal, but usePotionEffectType
instead.Gets the PotionType from this PotionEffectType. Usually for potion items.- Returns:
- a potion type for potions.
- Since:
- 1.0.0
- See Also:
parsePotionEffectType()
-
parsePotion
Builds a potion effect with the given duration and amplifier.- Parameters:
duration
- the duration of the potion effect.amplifier
- the amplifier of the potion effect.- Returns:
- a potion effect.
- Since:
- 1.0.0
- See Also:
parsePotionEffectFromString(String)
-
toString
In most cases your should be usingEnum.name()
instead.
-