Class ParticleDisplay

java.lang.Object
com.cryptomorin.xseries.particles.ParticleDisplay

public class ParticleDisplay
extends Object
By default the particle xyz offsets and speed aren't 0, but everything will be 0 by default in this class. Particles are spawned to a location. So all the nearby players can see it.

The fields of this class are publicly accessible for ease of use. All the fields can be null except the particle type.

For cross-version compatibility, instead of Bukkit's Color the java awt Color class is used.

the data field is used to store special particle data, such as colored particles. For colored particles a float list is used since the particle size is a float. The format of float list data for a colored particle is: [r, g, b, size]

Version:
3.0.1
Author:
Crypto Morin
See Also:
XParticle
  • Field Summary

    Fields 
    Modifier and Type Field Description
    int count  
    Object data  
    double extra  
    org.bukkit.Location location  
    double offsetx  
    double offsety  
    double offsetz  
    org.bukkit.Particle particle  
    org.bukkit.util.Vector rotation  
  • Constructor Summary

    Constructors 
    Constructor Description
    ParticleDisplay​(org.bukkit.Particle particle, org.bukkit.Location location)  
    ParticleDisplay​(org.bukkit.Particle particle, org.bukkit.Location location, int count)  
    ParticleDisplay​(org.bukkit.Particle particle, org.bukkit.Location location, int count, double offsetx, double offsety, double offsetz)  
    ParticleDisplay​(org.bukkit.Particle particle, org.bukkit.Location location, int count, double offsetx, double offsety, double offsetz, double extra)
    Make a new instance of particle display.
  • Method Summary

    Modifier and Type Method Description
    ParticleDisplay clone()
    Clones this particle settings.
    org.bukkit.Location cloneLocation​(double x, double y, double z)
    Clones the location of this particle display and adds xyz.
    ParticleDisplay cloneWithLocation​(double x, double y, double z)
    Clones this particle settings and adds xyz to its location.
    static ParticleDisplay colored​(org.bukkit.Location location, int r, int g, int b, float size)
    Builds a simple ParticleDisplay object with cross-version compatible Particle.DustOptions properties.
    static ParticleDisplay colored​(org.bukkit.Location location, Color color, float size)
    Builds a simple ParticleDisplay object with cross-version compatible Particle.DustOptions properties.
    ParticleDisplay directional()
    When a particle is set to be directional it'll only spawn one particle and the xyz offset values are used for the direction of the particle.
    static ParticleDisplay display​(org.bukkit.Location location, org.bukkit.Particle particle)
    A quick access method to display a simple particle.
    ParticleDisplay faceEntity​(org.bukkit.entity.Entity entity)
    Adjusts the rotation settings to face the entitys direction.
    static ParticleDisplay fromConfig​(org.bukkit.Location location, org.bukkit.configuration.ConfigurationSection config)
    Builds particle settings from a configuration section.
    boolean isDirectional()
    Check if this particle setting is a directional particle.
    ParticleDisplay offset​(double x, double y, double z)
    Set the xyz offset of the particle settings.
    ParticleDisplay rotate​(double x, double y, double z)
    Rotates the particle position based on the xyz radians.
    static org.bukkit.Location rotate​(org.bukkit.Location location, double x, double y, double z, org.bukkit.util.Vector rotation)
    Rotates the given xyz with the given rotation radians and adds the to the specified location.
    ParticleDisplay rotate​(org.bukkit.util.Vector vector)
    Rotates the particle position based on this vector.
    static ParticleDisplay simple​(org.bukkit.Location location, org.bukkit.Particle particle)
    Builds a simple ParticleDisplay object.
    void spawn()
    Spawns the particle at the current location.
    void spawn​(boolean rotate)
    Spawns the particle at the current location.
    org.bukkit.Location spawn​(double x, double y, double z)
    Adds xyz to the cloned loaction before spawning particle.
    void spawn​(org.bukkit.Location location)
    Spawns the particle at the given location.
    void spawn​(org.bukkit.Location loc, boolean rotate)
    Displays the particle in the specified location.
    void spawn​(org.bukkit.util.Vector location)
    Adds xyz of the given vector to the cloned location before spawning particles.
    ParticleDisplay withColor​(Color color, float size)
    Adds color properties to the particle settings.
    ParticleDisplay withCount​(int count)
    Changes the particle count of the particle settings.
    ParticleDisplay withExtra​(double extra)
    In most cases extra is the speed of the particles.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ParticleDisplay

      public ParticleDisplay​(@Nonnull org.bukkit.Particle particle, @Nullable org.bukkit.Location location, int count, double offsetx, double offsety, double offsetz, double extra)
      Make a new instance of particle display. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.
      Parameters:
      particle - the particle to spawn.
      location - the location to spawn the particle at.
      count - the count of particles to spawn.
      offsetx - the x offset.
      offsety - the y offset.
      offsetz - the z offset.
      extra - in most cases extra is the speed of the particles.
    • ParticleDisplay

      public ParticleDisplay​(@Nonnull org.bukkit.Particle particle, @Nullable org.bukkit.Location location, int count, double offsetx, double offsety, double offsetz)
    • ParticleDisplay

      public ParticleDisplay​(@Nonnull org.bukkit.Particle particle, @Nullable org.bukkit.Location location, int count)
    • ParticleDisplay

      public ParticleDisplay​(@Nonnull org.bukkit.Particle particle, @Nullable org.bukkit.Location location)
  • Method Details

    • colored

      @Nonnull public static ParticleDisplay colored​(@Nullable org.bukkit.Location location, int r, int g, int b, float size)
      Builds a simple ParticleDisplay object with cross-version compatible Particle.DustOptions properties.
      Parameters:
      location - the location of the display.
      size - the size of the dust.
      Returns:
      a redstone colored dust.
      Since:
      1.0.0
      See Also:
      simple(Location, Particle)
    • colored

      @Nonnull public static ParticleDisplay colored​(@Nullable org.bukkit.Location location, @Nonnull Color color, float size)
      Builds a simple ParticleDisplay object with cross-version compatible Particle.DustOptions properties.
      Parameters:
      location - the location of the display.
      color - the color of the particle.
      size - the size of the dust.
      Returns:
      a redstone colored dust.
      Since:
      3.0.0
      See Also:
      colored(Location, int, int, int, float)
    • simple

      @Nonnull public static ParticleDisplay simple​(@Nullable org.bukkit.Location location, @Nonnull org.bukkit.Particle particle)
      Builds a simple ParticleDisplay object. An invocation of this method yields exactly the same result as the expression:

      new ParticleDisplay(particle, location, 1, 0, 0, 0, 0);
      Parameters:
      location - the location of the display.
      particle - the particle of the display.
      Returns:
      a simple ParticleDisplay.
      Since:
      1.0.0
    • display

      public static ParticleDisplay display​(@Nonnull org.bukkit.Location location, @Nonnull org.bukkit.Particle particle)
      A quick access method to display a simple particle. An invocation of this method yields the same result as the expression:

      ParticleDisplay.simple(location, particle).spawn();
      Parameters:
      location - the location of the particle.
      particle - the particle to show.
      Returns:
      a simple ParticleDisplay.
      Since:
      1.0.0
    • fromConfig

      @Nonnull public static ParticleDisplay fromConfig​(@Nullable org.bukkit.Location location, @Nonnull org.bukkit.configuration.ConfigurationSection config)
      Builds particle settings from a configuration section.
      Parameters:
      location - the location for this particle settings.
      config - the config section for the settings.
      Returns:
      a parsed ParticleDisplay.
      Since:
      1.0.0
    • rotate

      @Nonnull public static org.bukkit.Location rotate​(@Nonnull org.bukkit.Location location, double x, double y, double z, @Nonnull org.bukkit.util.Vector rotation)
      Rotates the given xyz with the given rotation radians and adds the to the specified location.
      Parameters:
      location - the location to add the rotated axis.
      rotation - the xyz rotation radians.
      Returns:
      a cloned rotated location.
      Since:
      3.0.0
    • withCount

      @Nonnull public ParticleDisplay withCount​(int count)
      Changes the particle count of the particle settings.
      Parameters:
      count - the particle count.
      Returns:
      the same particle display.
      Since:
      3.0.0
    • withExtra

      @Nonnull public ParticleDisplay withExtra​(double extra)
      In most cases extra is the speed of the particles.
      Parameters:
      extra - the extra number.
      Returns:
      the same particle display.
      Since:
      3.0.1
    • withColor

      @Nonnull public ParticleDisplay withColor​(@Nonnull Color color, float size)
      Adds color properties to the particle settings.
      Parameters:
      color - the RGB color of the particle.
      size - the size of the particle.
      Returns:
      a colored particle.
      Since:
      3.0.0
      See Also:
      colored(Location, Color, float)
    • faceEntity

      @Nonnull public ParticleDisplay faceEntity​(@Nonnull org.bukkit.entity.Entity entity)
      Adjusts the rotation settings to face the entitys direction. Only some of the shapes support this method.
      Parameters:
      entity - the entity to face.
      Returns:
      the same particle display.
      Since:
      3.0.0
      See Also:
      rotate(Vector)
    • cloneLocation

      @Nullable public org.bukkit.Location cloneLocation​(double x, double y, double z)
      Clones the location of this particle display and adds xyz.
      Parameters:
      x - the x to add to the location.
      y - the y to add to the location.
      z - the z to add to the location.
      Returns:
      the cloned location.
      Since:
      1.0.0
      See Also:
      clone()
    • cloneWithLocation

      @Nonnull public ParticleDisplay cloneWithLocation​(double x, double y, double z)
      Clones this particle settings and adds xyz to its location.
      Parameters:
      x - the x to add.
      y - the y to add.
      z - the z to add.
      Returns:
      the cloned ParticleDisplay.
      Since:
      1.0.0
      See Also:
      clone()
    • clone

      @Nonnull public ParticleDisplay clone()
      Clones this particle settings.
      Overrides:
      clone in class Object
      Returns:
      the cloned ParticleDisplay.
      See Also:
      cloneWithLocation(double, double, double), cloneLocation(double, double, double)
    • rotate

      @Nonnull public ParticleDisplay rotate​(@Nonnull org.bukkit.util.Vector vector)
      Rotates the particle position based on this vector.
      Parameters:
      vector - the vector to rotate from. The xyz values of this vectors must be radians.
      Since:
      1.0.0
      See Also:
      rotate(double, double, double)
    • rotate

      @Nonnull public ParticleDisplay rotate​(double x, double y, double z)
      Rotates the particle position based on the xyz radians. Rotations are only supported for some shapes in XParticle. Rotating some of them can result in weird shapes.
      Since:
      3.0.0
      See Also:
      rotate(Vector)
    • offset

      @Nonnull public ParticleDisplay offset​(double x, double y, double z)
      Set the xyz offset of the particle settings.
      Since:
      1.1.0
    • directional

      @Nonnull public ParticleDisplay directional()
      When a particle is set to be directional it'll only spawn one particle and the xyz offset values are used for the direction of the particle.

      Colored particles in 1.12 and below don't support this.

      Since:
      1.1.0
      See Also:
      isDirectional()
    • isDirectional

      public boolean isDirectional()
      Check if this particle setting is a directional particle.
      Returns:
      true if the particle is directional, otherwise false.
      Since:
      2.1.0
      See Also:
      directional()
    • spawn

      public void spawn()
      Spawns the particle at the current location.
      Since:
      2.0.1
      See Also:
      spawn(boolean)
    • spawn

      public void spawn​(boolean rotate)
      Spawns the particle at the current location.
      Since:
      3.0.0
      See Also:
      spawn(Location, boolean)
    • spawn

      public void spawn​(@Nonnull org.bukkit.Location location)
      Spawns the particle at the given location.
      Since:
      1.0.0
      See Also:
      spawn(Location, boolean)
    • spawn

      public void spawn​(@Nonnull org.bukkit.util.Vector location)
      Adds xyz of the given vector to the cloned location before spawning particles.
      Parameters:
      location - the xyz to add.
      Since:
      1.0.0
    • spawn

      @Nonnull public org.bukkit.Location spawn​(double x, double y, double z)
      Adds xyz to the cloned loaction before spawning particle.
      Since:
      1.0.0
    • spawn

      public void spawn​(@Nonnull org.bukkit.Location loc, boolean rotate)
      Displays the particle in the specified location. This method does not support rotations if used directly.
      Parameters:
      loc - the location to display the particle at.
      Since:
      2.1.0
      See Also:
      spawn(double, double, double)