Package com.cryptomorin.xseries
Enum Class XPotion
- All Implemented Interfaces:
XBase<XPotion,,org.bukkit.potion.PotionEffectType> Serializable,Comparable<XPotion>,Constable
public enum XPotion
extends Enum<XPotion>
implements XBase<XPotion,org.bukkit.potion.PotionEffectType>
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.
There are two types of classes that we should distinguish between each other.
A Potion is an ItemStack (with meta PotionMeta) that can have one or multiple PotionEffectTypes.
PotionEffectType: These are all the available Minecraft effects. Some of these effects cannot be gained in form of potions.PotionType: A potion type doesn't only contain information about aPotionEffectTypebut also its amplifier and duration.- A PotionType with enhanced amplifier (level 2 amplifier) starts with the prefix
STRONG(usingXMaterial.GLOWSTONEwithin aBrewingStand). These potions cannot have extended duration. - A PotionType with extended duration (base duration multiplied by
2.666) starts with the prefixLONG(usingXMaterial.REDSTONEwithin aBrewingStand). These potions cannot be enhanced. PotionType.AWKWARDA potion with no effects (usingXMaterial.NETHER_WARTwithin aBrewingStand)PotionType.MUNDANECreated when usingXMaterial.GLOWSTONEon anPotionType.AWKWARDpotion within aBrewingStand.PotionType.THICKCreated when usingXMaterial.REDSTONEon anPotionType.AWKWARDpotion within aBrewingStand.PotionType.TURTLE_MASTERThere is noPotionEffectTypefor this potion type because it's a combination ofPotionEffectType.SLOWNESSandPotionEffectType.RESISTANCE, not a completely different PotionEffectType of itself.
- A PotionType with enhanced amplifier (level 2 amplifier) starts with the prefix
PotionEffectis a custom type ofPotionType(with custom amplifier and duration) that is not defined by Vanilla potions.
PotionEffectType mapping. However, it does provide a few utilities
for PotionType and maps them when possible.
EssentialsX Potions: https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/Potions.java Status Effect: https://minecraft.wiki/w/Status_effect Potions: https://minecraft.wiki/w/Potion
- Version:
- 5.0.0
- Author:
- Crypto Morin
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFor now, this merely acts as a chance wrapper for potion effects.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEffects(@NotNull org.bukkit.entity.LivingEntity entity, @Nullable List<String> effects) Add a list of potion effects to an entity from a string list, usually from config.static @NotNull org.bukkit.inventory.ItemStackbuildItemWithEffects(@NotNull 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.@Nullable org.bukkit.potion.PotionEffectbuildPotionEffect(int duration, int amplifier) Builds a potion effect with the given duration and amplifier.static booleancanHaveEffects(@Nullable org.bukkit.Material material) Checks if a material can have potion effects.@Nullable org.bukkit.potion.PotionEffectTypeget()String[]getNames()@Nullable org.bukkit.potion.PotionEffectTypeParses the potion effect type.@Nullable org.bukkit.potion.PotionTypeGets the PotionType from this PotionEffectType.matchXPotion(@NotNull String potion) Deprecated.Useof(String)instead.static @NotNull XPotionmatchXPotion(@NotNull org.bukkit.potion.PotionEffectType type) Deprecated.Useof(PotionEffectType)instead.static XPotionmatchXPotion(@NotNull org.bukkit.potion.PotionType type) Deprecated.Useof(PotionType)instead.static @NotNull XPotionof(@NotNull org.bukkit.potion.PotionEffectType type) Parses the XPotion for this potion effect.static @NotNull XPotionof(@NotNull org.bukkit.potion.PotionType potion) static @Nullable XPotion.EffectparseEffect(@Nullable String potion) Parse aPotionEffectfrom a string, usually from config.static List<XPotion.Effect> parseEffects(@Nullable List<String> effectsString) static @NotNull org.bukkit.entity.ThrownPotionthrowPotion(@NotNull org.bukkit.entity.LivingEntity entity, @Nullable org.bukkit.Color color, @Nullable org.bukkit.potion.PotionEffect... effects) Throws a splash potion from the target entity.toString()In most cases you should be usingEnum.name()instead.static XPotionReturns the enum constant of this class with the specified name.static XPotion[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOfMethods inherited from interface com.cryptomorin.xseries.base.XBase
friendlyName, getMetadata, isSupported, name, or
-
Enum Constant Details
-
ABSORPTION
-
BAD_OMEN
-
BLINDNESS
-
CONDUIT_POWER
-
DARKNESS
-
DOLPHINS_GRACE
-
FIRE_RESISTANCE
-
GLOWING
-
HASTE
-
HEALTH_BOOST
-
HERO_OF_THE_VILLAGE
-
HUNGER
-
INFESTED
-
INSTANT_DAMAGE
-
INSTANT_HEALTH
-
INVISIBILITY
-
JUMP_BOOST
-
LEVITATION
-
LUCK
-
MINING_FATIGUE
-
NAUSEA
-
NIGHT_VISION
-
OOZING
-
POISON
-
RAID_OMEN
-
REGENERATION
-
RESISTANCE
-
SATURATION
-
SLOWNESS
-
SLOW_FALLING
-
SPEED
-
STRENGTH
-
TRIAL_OMEN
-
UNLUCK
-
WATER_BREATHING
-
WEAKNESS
-
WEAVING
-
WIND_CHARGED
-
WITHER
-
-
Field Details
-
VALUES
Cached list ofvalues()to avoid allocating memory for calling the method every time.- Since:
- 1.0.0
-
DEBUFFS
Deprecated.UseXTag.DEBUFFSinstead.An unmodifiable set of "bad" potion effects.- Since:
- 1.1.0
-
REGISTRY
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
matchXPotion
@NotNull @Deprecated public static @NotNull Optional<XPotion> matchXPotion(@NotNull @NotNull String potion) Deprecated.Useof(String)instead.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
-
of
-
of
-
matchXPotion
Deprecated.Useof(PotionType)instead. -
matchXPotion
@NotNull @Deprecated public static @NotNull XPotion matchXPotion(@NotNull @NotNull org.bukkit.potion.PotionEffectType type) Deprecated.Useof(PotionEffectType)instead.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
-
of
@NotNull public static @NotNull XPotion of(@NotNull @NotNull org.bukkit.potion.PotionEffectType type) 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
-
parseEffect
Parse aPotionEffectfrom a string, usually from config. Supports potion type IDs.
Format: Potion, Duration (in seconds), Amplifier (level) [%chance]WEAKNESS, 30, 1 SLOWNESS, 200, 10 1, 10000, 100, %50The last argument can also include a chance (written in percent) which if not met, returns null.- 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:
-
addEffects
public static void addEffects(@NotNull @NotNull org.bukkit.entity.LivingEntity entity, @Nullable @Nullable List<String> effects) Add a list of potion effects to an entity from a string list, usually from config.- Parameters:
entity- the entity to add potion effects to.effects- the list of potion effects to parse and add to the entity.- Since:
- 1.0.0
- See Also:
-
parseEffects
- Parameters:
effectsString- a list of effects with a format followingparseEffect(String)- Returns:
- a list of parsed effets.
- Since:
- 3.0.0
-
throwPotion
@NotNull public static @NotNull org.bukkit.entity.ThrownPotion throwPotion(@NotNull @NotNull org.bukkit.entity.LivingEntity entity, @Nullable @Nullable org.bukkit.Color color, @Nullable @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
@NotNull public static @NotNull org.bukkit.inventory.ItemStack buildItemWithEffects(@NotNull @NotNull org.bukkit.Material type, @Nullable @Nullable org.bukkit.Color color, @Nullable @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.POTIONMaterial.SPLASH_POTIONMaterial.LINGERING_POTIONMaterial.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
public static boolean canHaveEffects(@Nullable @Nullable org.bukkit.Material material) Checks if a material can have potion effects. This method does not check forLEGACYmaterials. 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
-
getPotionEffectType
@Nullable public @Nullable org.bukkit.potion.PotionEffectType getPotionEffectType()Parses the potion effect type.- Returns:
- the parsed potion effect type.
- Since:
- 1.0.0
- See Also:
-
getNames
-
get
@Nullable public @Nullable org.bukkit.potion.PotionEffectType get() -
getPotionType
@Nullable public @Nullable org.bukkit.potion.PotionType getPotionType()Gets the PotionType from this PotionEffectType. Usually for potion items.- Returns:
- a potion type for potions.
- Since:
- 1.0.0
- See Also:
-
buildPotionEffect
@Nullable public @Nullable org.bukkit.potion.PotionEffect buildPotionEffect(int duration, int amplifier) Builds a potion effect with the given duration and amplifier.- Parameters:
duration- the duration of the potion effect in ticks.amplifier- the level of the potion effect (starting from 1).- Returns:
- a potion effect.
- Since:
- 1.0.0
- See Also:
-
toString
In most cases you should be usingEnum.name()instead.
-
XTag.DEBUFFSinstead.