Class ParticleBuilder

java.lang.Object
xyz.xenondevs.particle.ParticleBuilder

public class ParticleBuilder extends Object
A builder for particle packets.
Since:
24/01/2020
Author:
ByteZ
  • Constructor Details

  • Method Details

    • getParticle

      public ParticleEffect getParticle()
      The ParticleEffect that should be displayed by the client.
    • setLocation

      public ParticleBuilder setLocation(org.bukkit.Location location)
      Sets the Location of the particle.
      Parameters:
      location - The new Location of the particle.
      Returns:
      the current instance to support building operations
    • getLocation

      public org.bukkit.Location getLocation()
      The Location of the particle.
    • setOffsetX

      public ParticleBuilder setOffsetX(float offsetX)
      Sets the X offset.
      Parameters:
      offsetX - The new value of the offsetX field
      Returns:
      the current instance to support building operations
    • getOffsetX

      public float getOffsetX()
      This field has three uses:

      The offsetX defines in which x oriented range the particles can spawn.

      It represents the x velocity a particle with the PropertyType.DIRECTIONAL property should have.

      It sets the red value of a PropertyType.COLORABLE particle. However, since 1.13 a ParticleParam has to be used to set the colors of redstone.

    • setOffsetY

      public ParticleBuilder setOffsetY(float offsetY)
      Sets the Y offset.
      Parameters:
      offsetY - The new value of the offsetY field
      Returns:
      the current instance to support building operations
    • setOffset

      public ParticleBuilder setOffset(float offsetX, float offsetY, float offsetZ)
      Sets the offset.
      Parameters:
      offsetX - The new value of the offsetX field
      offsetY - The new value of the offsetY field
      offsetZ - The new value of the offsetZ field
      Returns:
      the current instance to support building operations
    • getOffsetY

      public float getOffsetY()
      This field has three uses:

      The offsetY defines in which y oriented range the particles can spawn.

      It represents the y velocity a particle with the PropertyType.DIRECTIONAL property should have.

      It sets the green value of a PropertyType.COLORABLE particle. However, since 1.13 a ParticleParam has to be used to set the colors of redstone.

    • setOffset

      public ParticleBuilder setOffset(org.bukkit.util.Vector offset)
      Sets the offset.
      Parameters:
      offset - a Vector containing the offset values.
      Returns:
      the current instance to support building operations
    • setOffsetZ

      public ParticleBuilder setOffsetZ(float offsetZ)
      Sets the Z offset.
      Parameters:
      offsetZ - The new value of the offsetZ field
      Returns:
      the current instance to support building operations
    • getOffsetZ

      public float getOffsetZ()
      This field has three uses:

      The offsetZ defines in which z oriented range the particles can spawn.

      It represents the z velocity a particle with the PropertyType.DIRECTIONAL property should have.

      It sets the blue value of a PropertyType.COLORABLE particle. However, since 1.13 a ParticleParam has to be used to set the colors of redstone.

    • setSpeed

      public ParticleBuilder setSpeed(float speed)
      Sets the speed.
      Parameters:
      speed - The new value of the speed field
      Returns:
      the current instance to support building operations
    • getSpeed

      public float getSpeed()
      Normally this field is used to multiply the velocity of a particle by the given speed. There are however some special cases where this value is used for something different. (e.g. ParticleEffect.NOTE).
    • setAmount

      public ParticleBuilder setAmount(int amount)
      Sets the amount.
      Parameters:
      amount - The new value of the amount field
      Returns:
      the current instance to support building operations
    • getAmount

      public int getAmount()
      The amount of particles that should be spawned. For the extra data defined in offsetX, offsetY and offsetZ to work the amount has to be set to 0.
    • setParticleData

      public ParticleBuilder setParticleData(ParticleData particleData)
      Sets the particleData.
      Parameters:
      particleData - The new value of the particleData field
      Returns:
      the current instance to support building operations
    • getParticleData

      public ParticleData getParticleData()
      The data of the particle which should be displayed. This data contains additional information the client needs to display the particle correctly.
    • setColor

      public ParticleBuilder setColor(Color color)
      Sets the color of the particle. Note that particle needs the PropertyType.COLORABLE PropertyType to work.
      Parameters:
      color - the Color of the particle.
      Returns:
      the current instance to support building operations
    • toPacket

      public Object toPacket()
      Creates a new ParticlePacket wit the given values.
      Returns:
      the new ParticlePacket
      Throws:
      IllegalStateException - if the location field isn't set yet.
    • display

      public void display()
      Displays the given particle to all players.
    • display

      public void display(org.bukkit.entity.Player... players)
      Displays the given particle to the players in the array.
      Parameters:
      players - The players that should see the particle.
    • display

      public void display(Predicate<org.bukkit.entity.Player> filter)
      Display the given particle to online player that match the given filter.
      Parameters:
      filter - a Predicate to filter out specific Players.
    • display

      public void display(Collection<? extends org.bukkit.entity.Player> players)
      Displays the given particle to all players in the Collection
      Parameters:
      players - a list of players that should receive the particle packet.