Record Class Potion

java.lang.Object
java.lang.Record
net.minestom.server.potion.Potion
All Implemented Interfaces:
NetworkBuffer.Writer

public record Potion(@NotNull PotionEffect effect, byte amplifier, int duration, byte flags) extends Record implements NetworkBuffer.Writer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
    A flag indicating that this Potion is ambient (it came from a beacon).
    static final byte
    A flag indicating that this Potion has an icon.
    static final byte
    A flag indicating that this Potion has particles.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Potion(@NotNull NetworkBuffer reader)
     
    Potion(@NotNull PotionEffect effect, byte amplifier, int duration)
     
    Potion(@NotNull PotionEffect effect, byte amplifier, int duration, byte flags)
    Creates an instance of a Potion record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    Returns the value of the amplifier record component.
    int
    Returns the value of the duration record component.
    @NotNull PotionEffect
    Returns the value of the effect record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    byte
    Returns the flags that this Potion has.
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether this Potion has an icon or not.
    boolean
    Returns whether this Potion has particles or not.
    boolean
    Returns whether this Potion is ambient (it came from a beacon) or not.
    void
    sendAddPacket(@NotNull Entity entity)
    Sends a packet that a potion effect has been applied to the entity.
    void
    sendRemovePacket(@NotNull Entity entity)
    Sends a packet that a potion effect has been removed from the entity.
    final String
    Returns a string representation of this record class.
    void
    write(@NotNull NetworkBuffer writer)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Potion

      public Potion(@NotNull @NotNull PotionEffect effect, byte amplifier, int duration)
    • Potion

      public Potion(@NotNull @NotNull NetworkBuffer reader)
    • Potion

      public Potion(@NotNull @NotNull PotionEffect effect, byte amplifier, int duration, byte flags)
      Creates an instance of a Potion record class.
      Parameters:
      effect - the value for the effect record component
      amplifier - the value for the amplifier record component
      duration - the value for the duration record component
      flags - the value for the flags record component
  • Method Details

    • flags

      public byte flags()
      Returns the flags that this Potion has.
      See Also:
    • isAmbient

      public boolean isAmbient()
      Returns whether this Potion is ambient (it came from a beacon) or not.
      Returns:
      true if the Potion is ambient
    • hasParticles

      public boolean hasParticles()
      Returns whether this Potion has particles or not.
      Returns:
      true if the Potion has particles
    • hasIcon

      public boolean hasIcon()
      Returns whether this Potion has an icon or not.
      Returns:
      true if the Potion has an icon
    • sendAddPacket

      public void sendAddPacket(@NotNull @NotNull Entity entity)
      Sends a packet that a potion effect has been applied to the entity.

      Used internally by Entity.addEffect(Potion)

      Parameters:
      entity - the entity to add the effect to
    • sendRemovePacket

      public void sendRemovePacket(@NotNull @NotNull Entity entity)
      Sends a packet that a potion effect has been removed from the entity.

      Used internally by Entity.removeEffect(PotionEffect)

      Parameters:
      entity - the entity to remove the effect from
    • write

      public void write(@NotNull @NotNull NetworkBuffer writer)
      Specified by:
      write in interface NetworkBuffer.Writer
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • effect

      @NotNull public @NotNull PotionEffect effect()
      Returns the value of the effect record component.
      Returns:
      the value of the effect record component
    • amplifier

      public byte amplifier()
      Returns the value of the amplifier record component.
      Returns:
      the value of the amplifier record component
    • duration

      public int duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component