java.lang.Object
com.destroystokyo.paper.ParticleBuilder
org.skriptlang.skript.bukkit.particles.particleeffects.ParticleEffect
All Implemented Interfaces:
Debuggable, Cloneable
Direct Known Subclasses:
ConvergingEffect, DirectionalEffect, ScalableEffect

public class ParticleEffect extends com.destroystokyo.paper.ParticleBuilder implements Debuggable
A wrapper around Paper's ParticleBuilder to provide additional functionality and a more fluent API for spawning particle effects. Categories of particles with special behaviors may extend this class.
Particle behavior depends a lot on whether the count is zero or not. If count is zero, the offset and extra parameters are used to define a normal distribution for randomly offsetting particle positions. If count is greater than zero, the offset may be used for a number of special behaviors depending on the particle type. For example, DirectionalEffects will use the offset as a velocity vector, multiplied by the extra parameter. ScalableEffects will use the offset to determine scale.
  • Constructor Details

    • ParticleEffect

      protected ParticleEffect(org.bukkit.Particle particle)
      Internal constructor. Use of(Particle) instead.
      Parameters:
      particle - The particle type
  • Method Details

    • of

      @Contract("_ -> new") @NotNull public static @NotNull ParticleEffect of(org.bukkit.Particle particle)
      Creates the appropriate ParticleEffect subclass based on the particle type.
      Parameters:
      particle - The particle type
      Returns:
      The appropriate ParticleEffect instance
    • of

      @Contract("_ -> new") @NotNull public static @NotNull ParticleEffect of(@NotNull @NotNull com.destroystokyo.paper.ParticleBuilder builder)
      Creates the appropriate ParticleEffect with the properties of the provided ParticleBuilder
      Parameters:
      builder - The builder to copy values from
      Returns:
      The appropriate ParticleEffect instance with the properties copied from the builder
    • parse

      @Nullable public static @Nullable ParticleEffect parse(String input, ParseContext context)
      Parses a particle effect from a string input. Prints errors if the particle requires data.
      Parameters:
      input - the input string
      context - the parse context
      Returns:
      the parsed ParticleEffect, or null if parsing failed
    • toString

      public static String toString(org.bukkit.Particle particle, int flags)
      Converts a Particle to its string representation.
      Parameters:
      particle - the particle
      flags - parsing flags
      Returns:
      the string representation
    • getAllNamesWithoutData

      public static String @NotNull [] getAllNamesWithoutData()
      Gets all particle names that do not require data.
      Returns:
      array of particle names
    • spawn

      public ParticleEffect spawn()
      Overrides:
      spawn in class com.destroystokyo.paper.ParticleBuilder
    • spawn

      public ParticleEffect spawn(org.bukkit.Location location)
      Ease of use method to spawn at a location. Modifies the location value of this effect.
      Parameters:
      location - the location to spawn at.
      Returns:
      This effect, with the location value modified.
    • offset

      public org.joml.Vector3d offset()
      Returns:
      The offset of this particle as a JOML vector
    • offset

      public ParticleEffect offset(@NotNull @NotNull org.joml.Vector3d offset)
      Set the offset from a JOML vector
      Parameters:
      offset - the new offset
      Returns:
      This effect, with the offset modified.
    • receivers

      public ParticleEffect receivers(@NotNull @NotNull org.joml.Vector3i radii)
      Set the receiver radii from a JOML vector
      Parameters:
      radii - the new radii to check for receivers in
      Returns:
      This effect, with the receivers modified.
    • receivers

      public ParticleEffect receivers(@NotNull @NotNull org.joml.Vector3d radii)
      Set the receiver radii from a JOML vector. Values are truncated to ints.
      Parameters:
      radii - the new radii to check for receivers in
      Returns:
      This effect, with the receivers modified.
    • isUsingNormalDistribution

      public boolean isUsingNormalDistribution()
      Returns:
      Whether this effect will use its offset value as a normal distribution (count > 0)
    • distribution

      public org.joml.Vector3d distribution()
      An alias for the offset. Prefer using this when working with particles that have counts greater than 0. When isUsingNormalDistribution() is false, the returned value will not be the distribution and will instead depend on the particle's specific behavior when count = 0.
      Returns:
      the distribution of this particle. The distribution is defined as 3 normal distributions in the x/y/z axes, with the returned vector containing the standard deviations. The mean will always be 0.
    • distribution

      public ParticleEffect distribution(org.joml.Vector3d distribution)
      Sets the distribution for this particle. The distribution is defined as 3 normal distributions in the x/y/z axes, with the provided vector containing the standard deviations. The mean will always be 0. Sets the count to 1 if it was 0.
      Parameters:
      distribution - The new standard deviations to use.
    • data

      public <T> ParticleEffect data(@Nullable T data)
      Overrides:
      data in class com.destroystokyo.paper.ParticleBuilder
    • acceptsData

      public boolean acceptsData(@Nullable @Nullable Object data)
      Helper method to check if this effect accepts the provided data. Depends on the current particle.
      Parameters:
      data - The data to check.
      Returns:
      Whether the data is of the right class.
    • dataType

      public Class<?> dataType()
      Alias for this.particle().getDataType()
      Returns:
      The data type of the current particle.
    • copy

      public ParticleEffect copy()
      Returns:
      a copy of this effect.
    • toString

      public String toString()
      Description copied from interface: Debuggable
      Should return toString(null, false)
      Specified by:
      toString in interface Debuggable
      Overrides:
      toString in class Object
    • toString

      public String toString(@Nullable @Nullable org.bukkit.event.Event event, boolean debug)
      Specified by:
      toString in interface Debuggable
      Parameters:
      event - The event to get information from. This is always null if debug == false.
      debug - If true this should print more information, if false this should print what is shown to the end user
      Returns:
      String representation of this object
    • particle

      public ParticleEffect particle(org.bukkit.Particle particle)
      Overrides:
      particle in class com.destroystokyo.paper.ParticleBuilder
    • allPlayers

      public ParticleEffect allPlayers()
      Overrides:
      allPlayers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(@Nullable @Nullable List<org.bukkit.entity.Player> receivers)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(@Nullable @Nullable Collection<org.bukkit.entity.Player> receivers)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(org.bukkit.entity.Player @Nullable ... receivers)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(int radius)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(int radius, boolean byDistance)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(int xzRadius, int yRadius)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(int xzRadius, int yRadius, boolean byDistance)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • receivers

      public ParticleEffect receivers(int xRadius, int yRadius, int zRadius)
      Overrides:
      receivers in class com.destroystokyo.paper.ParticleBuilder
    • source

      public ParticleEffect source(@Nullable @Nullable org.bukkit.entity.Player source)
      Overrides:
      source in class com.destroystokyo.paper.ParticleBuilder
    • location

      public ParticleEffect location(org.bukkit.Location location)
      Overrides:
      location in class com.destroystokyo.paper.ParticleBuilder
    • location

      public ParticleEffect location(org.bukkit.World world, double x, double y, double z)
      Overrides:
      location in class com.destroystokyo.paper.ParticleBuilder
    • count

      public ParticleEffect count(int count)
      Overrides:
      count in class com.destroystokyo.paper.ParticleBuilder
    • offset

      public ParticleEffect offset(double offsetX, double offsetY, double offsetZ)
      Overrides:
      offset in class com.destroystokyo.paper.ParticleBuilder
    • extra

      public ParticleEffect extra(double extra)
      Overrides:
      extra in class com.destroystokyo.paper.ParticleBuilder
    • force

      public ParticleEffect force(boolean force)
      Overrides:
      force in class com.destroystokyo.paper.ParticleBuilder