类 PotionEffect

java.lang.Object
org.bukkit.potion.PotionEffect
所有已实现的接口:
ConfigurationSerializable

public class PotionEffect extends Object implements ConfigurationSerializable
代表一个药水效果, 可应用于 LivingEntity. 药水效果有持续时长、倍率、作用于实体上的效果类型属性.
  • 字段详细资料

    • INFINITE_DURATION

      public static final int INFINITE_DURATION
      A constant denoting infinite potion duration.
      另请参阅:
  • 构造器详细资料

    • PotionEffect

      public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon)
      创建一个药水效果.

      原文:Creates a potion effect.

      参数:
      type - 效果类型
      duration - 持续时长 (单位为tick), 见 getDuration()
      amplifier - 效果倍率, 见 getAmplifier()
      ambient - ambient 状态, 见 isAmbient()
      particles - 粒子可见性, 见 hasParticles()
      icon - 图标可见性, 见 hasIcon()
    • PotionEffect

      public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles)
      创建一个药水效果, 不定义粒子颜色.

      原文:Creates a potion effect with no defined color.

      参数:
      type - 效果类型
      duration - 持续时长 (单位为tick), 见 getDuration()
      amplifier - 效果倍率, 见 getAmplifier()
      ambient - ambient 状态, 见 isAmbient()
      particles - 粒子可见性, 见 hasParticles()
    • PotionEffect

      public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient)
      创建一个药水效果, 使粒子效果可见.

      原文:Creates a potion effect. Assumes that particles are visible

      参数:
      type - 效果类型
      duration - 持续时长 (单位为tick), 见 getDuration()
      amplifier - 效果倍率, 见 getAmplifier()
      ambient - ambient 状态, 见 isAmbient()
    • PotionEffect

      public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier)
      创建一个药水效果, 使 ambient 为 true.

      原文:Creates a potion effect. Assumes ambient is true.

      参数:
      type - 效果类型
      duration - 持续时长 (单位为tick)
      amplifier - 效果倍率
      另请参阅:
    • PotionEffect

      public PotionEffect(@NotNull @NotNull Map<String,Object> map)
      用于反序列化的构造器.

      原文:Constructor for deserialization.

      参数:
      map - 反序列化使用的map
  • 方法详细资料

    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      从接口复制的说明: ConfigurationSerializable
      Creates a Map representation of this class.

      This class must provide a method to restore this class, as defined in the ConfigurationSerializable interface javadocs.

      指定者:
      serialize 在接口中 ConfigurationSerializable
      返回:
      Map containing the current state of this class
    • apply

      public boolean apply(@NotNull @NotNull LivingEntity entity)
      尝试添加此效果到指定的生物上.

      原文:Attempts to add the effect represented by this object to the given LivingEntity.

      参数:
      entity - 效果施加实体对象
      返回:
      效果是否可添加/添加成功
      另请参阅:
    • equals

      public boolean equals(Object obj)
      覆盖:
      equals 在类中 Object
    • getAmplifier

      public int getAmplifier()
      返回此效果的倍率. 更高的倍率意味着此药水效果在其作用时间内作用更频繁, 或者对目标有更多(更强)的效果.

      原文:Returns the amplifier of this effect. A higher amplifier means the potion effect happens more often over its duration and in some cases has more effect on its target.

      返回:
      效果倍率
    • getDuration

      public int getDuration()
      返回此效果的持续时间 (单位为tick).

      原文:Returns the duration (in ticks) that this effect will run for when applied to a LivingEntity.

      返回:
      效果持续时间, 如果效果持续时间无限, 则为-1
      另请参阅:
    • isInfinite

      public boolean isInfinite()
      Returns whether or not this potion effect has an infinite duration. Potion effects with infinite durations will display an infinite symbol and never expire unless manually removed.
      返回:
      whether this duration is infinite or not
    • isShorterThan

      public boolean isShorterThan(@NotNull @NotNull PotionEffect other)
      Returns whether or not this potion effect has a shorter duration than the provided potion effect.

      An infinite duration is considered longer than non-infinite durations. If both potion effects have infinite durations, then neither is shorter than the other and this method will return false.

      参数:
      other - the other effect
      返回:
      true if this effect is shorter than the other, false if longer or equal
    • getType

      返回此效果的类型.

      原文:Returns the PotionEffectType of this effect.

      返回:
      药水效果的类型
    • isAmbient

      public boolean isAmbient()
      此状态使药水效果产生更多的、半透明的粒子.

      原文:Makes potion effect produce more, translucent, particles.

      返回:
      此药水效果是否为环境型效果 (译注:比如信标产生的效果)
    • hasParticles

      public boolean hasParticles()
      返回:
      此效果是否有粒子效果
    • getColor

      @Deprecated @Nullable @Contract("-> null") public @Nullable Color getColor()
      已过时。
      现在粒子效果颜色不属于药水效果的一部分
      返回:
      药水效果粒子的颜色. 如果无粒子效果/未定义颜色, 将可能为null
    • hasIcon

      public boolean hasIcon()
      返回:
      此效果是否有图标
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object