Enum XPotion

java.lang.Object
java.lang.Enum<XPotion>
com.cryptomorin.xseries.XPotion
All Implemented Interfaces:
Serializable, Comparable<XPotion>

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.wiki/w/Status_effect Potions: https://minecraft.wiki/w/Potion

Version:
4.1.0
Author:
Crypto Morin
See Also:
  • PotionEffect
  • PotionEffectType
  • PotionType
  • Enum Constant Details

    • ABSORPTION

      public static final XPotion ABSORPTION
    • BAD_OMEN

      public static final XPotion BAD_OMEN
    • BLINDNESS

      public static final XPotion BLINDNESS
    • CONDUIT_POWER

      public static final XPotion CONDUIT_POWER
    • DARKNESS

      public static final XPotion DARKNESS
    • DOLPHINS_GRACE

      public static final XPotion DOLPHINS_GRACE
    • FIRE_RESISTANCE

      public static final XPotion FIRE_RESISTANCE
    • GLOWING

      public static final XPotion GLOWING
    • HASTE

      public static final XPotion HASTE
    • HEALTH_BOOST

      public static final XPotion HEALTH_BOOST
    • HERO_OF_THE_VILLAGE

      public static final XPotion HERO_OF_THE_VILLAGE
    • HUNGER

      public static final XPotion HUNGER
    • INFESTED

      public static final XPotion INFESTED
    • INSTANT_DAMAGE

      public static final XPotion INSTANT_DAMAGE
    • INSTANT_HEALTH

      public static final XPotion INSTANT_HEALTH
    • INVISIBILITY

      public static final XPotion INVISIBILITY
    • JUMP_BOOST

      public static final XPotion JUMP_BOOST
    • LEVITATION

      public static final XPotion LEVITATION
    • LUCK

      public static final XPotion LUCK
    • MINING_FATIGUE

      public static final XPotion MINING_FATIGUE
    • NAUSEA

      public static final XPotion NAUSEA
    • NIGHT_VISION

      public static final XPotion NIGHT_VISION
    • OOZING

      public static final XPotion OOZING
    • POISON

      public static final XPotion POISON
    • RAID_OMEN

      public static final XPotion RAID_OMEN
    • REGENERATION

      public static final XPotion REGENERATION
    • RESISTANCE

      public static final XPotion RESISTANCE
    • SATURATION

      public static final XPotion SATURATION
    • SLOWNESS

      public static final XPotion SLOWNESS
    • SLOW_FALLING

      public static final XPotion SLOW_FALLING
    • SPEED

      public static final XPotion SPEED
    • STRENGTH

      public static final XPotion STRENGTH
    • TRIAL_OMEN

      public static final XPotion TRIAL_OMEN
    • TURTLE_MASTER

      public static final XPotion TURTLE_MASTER
      Special type of effect. Minecraft itself doesn't recognize this as a separate potion type, but as a combination of two other potion types. However, Bukkit's PotionType.TURTLE_MASTER decided to add this, whereas PotionEffectType doesn't have such enum.
      Since:
      Minecraft v1.21
    • UNLUCK

      public static final XPotion UNLUCK
    • WATER_BREATHING

      public static final XPotion WATER_BREATHING
    • WEAKNESS

      public static final XPotion WEAKNESS
    • WEAVING

      public static final XPotion WEAVING
    • WIND_CHARGED

      public static final XPotion WIND_CHARGED
    • WITHER

      public static final XPotion WITHER
  • Field Details

    • VALUES

      public static final XPotion[] VALUES
      Cached list of values() to avoid allocating memory for calling the method every time.
      Since:
      1.0.0
    • DEBUFFS

      public static final Set<XPotion> DEBUFFS
      An unmodifiable set of "bad" potion effects.
      Since:
      1.1.0
  • Method Details

    • values

      public static XPotion[] 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

      public static XPotion valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • matchXPotion

      @Nonnull public static Optional<XPotion> matchXPotion(@Nonnull String potion)
      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

      public static XPotion matchXPotion(@Nonnull org.bukkit.potion.PotionType type)
    • matchXPotion

      @Nonnull public static XPotion matchXPotion(@Nonnull 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

      @Nullable public static XPotion.Effect parseEffect(@Nullable String potion)
      Parse a PotionEffect from 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 %50
       
      The 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(@Nonnull 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.
      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

      public static List<XPotion.Effect> parseEffects(@Nullable List<String> effectsString)
      Parameters:
      effectsString - a list of effects with a format following parseEffect(String)
      Returns:
      a list of parsed effets.
      Since:
      3.0.0
    • 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

      public static boolean canHaveEffects(@Nullable org.bukkit.Material material)
      Checks if a material can have potion effects. This method does not check for LEGACY 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
    • getPotionEffectType

      @Nullable public org.bukkit.potion.PotionEffectType getPotionEffectType()
      Parses the potion effect type.
      Returns:
      the parsed potion effect type.
      Since:
      1.0.0
      See Also:
    • 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:

      getPotionEffectType() != null
      Returns:
      true if the current version has this potion effect type, otherwise false.
      Since:
      1.0.0
    • or

      @Nullable public XPotion or(@Nullable XPotion alternatePotion)
      Checks if this potion is supported in the current version and returns itself if yes.

      In the other case, the alternate potion will get returned, no matter if it is supported or not.

      Parameters:
      alternatePotion - the potion to get if this one is not supported.
      Returns:
      this potion or the alternatePotion if not supported.
    • getPotionType

      @Nullable public 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 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

      public String toString()
      In most cases you should be using Enum.name() instead.
      Overrides:
      toString in class Enum<XPotion>
      Returns:
      a friendly readable string name.