Class VarParticle

java.lang.Object
de.marcely.bedwars.tools.VarParticle
All Implemented Interfaces:
Cloneable

public abstract class VarParticle extends Object implements Cloneable
Easy solution for using VarParticles that are being supported on any version.
  • Field Details

    • NONE

      public static final VarParticle NONE
      Doesn't actually play any particle. Used as a placeholder.
    • PARTICLE_SMOKE

      public static final VarParticle PARTICLE_SMOKE
      Plays the "SMOKE" particle effect.
    • PARTICLE_EXPLOSION_HUGE

      public static final VarParticle PARTICLE_EXPLOSION_HUGE
      Plays the "EXPLOSION_HUGE" ("EXPLOSION_EMITTER" with 1.20.5+) particle effect.
    • PARTICLE_CLOUD

      public static final VarParticle PARTICLE_CLOUD
      Plays the "CLOUD" particle effect.
    • PARTICLE_POTION_INVISIBILITY

      public static final VarParticle PARTICLE_POTION_INVISIBILITY
      Plays the "MOB_SPELL" particle effect with the colors R129 G133 B149.
  • Method Details

    • play

      public abstract void play(Location loc)
      Plays the particle globally at the given location.
      Parameters:
      loc - The loaction where it shall be played.
    • play

      public abstract void play(Location loc, Player player)
      Plays the particle for at the given location.
      Parameters:
      loc - The loaction where it shall be played.
      player - The player who shall see it
    • getName

      public abstract String getName()
      Returns the name of the name/particle.
      Returns:
      The name of the particle
    • isInternallyEffect

      public abstract boolean isInternallyEffect()
      Returns whether Effect is being used.
      Returns:
      true when Bukkit's Effect API is being used
    • isInternallyParticle

      public abstract boolean isInternallyParticle()
      Returns whether Particle is being used.
      Returns:
      true when Bukkit's Particle API is being used
    • getOffsetX

      public abstract float getOffsetX()
      Defines the random offset at the x-coordinate at which a particle may be spawned.
      Returns:
      The defined x-offset
    • getOffsetY

      public abstract float getOffsetY()
      Defines the random offset at the y-coordinate at which a particle may be spawned.
      Returns:
      The defined y-offset
    • getOffsetZ

      public abstract float getOffsetZ()
      Defines the random offset at the z-coordinate at which a particle may be spawned.
      Returns:
      The defined z-offset
    • setOffset

      public abstract void setOffset(float x, float y, float z)
      Set the random offset at which a particle may be spawned.
      Parameters:
      x - Max radius for the x-coordinate
      y - Max radius for the y-coordinate
      z - Max radius for the z-coordinate
    • getCount

      public abstract int getCount()
      Get the amount of particles that will be shown.
      Returns:
      The amount of particles
    • setCount

      public abstract void setCount(int count)
      Set the amount of particles that will be shown.
      Parameters:
      count - The new amount of particles
    • testPlayAsync

      protected boolean testPlayAsync(Location loc)
    • clone

      public VarParticle clone()
      Overrides:
      clone in class Object
    • parse

      public static VarParticle parse(ConfigurationSection config) throws IllegalArgumentException
      Parses a given config.

      Goes through all existing particles and effects within Bukkit. It's possible that the data vary between the versions.

      It'll read the following fields:

      • type (string, the name of the particle/effect)
      • count (int)
      • offset-x (double)
      • offset-y (double)
      • offset-z (double)
      • extra (double)
      • data (depends on the type)

      When parsing a particle (1.9+) then there are the following possible types for the data:

      • DustOptions: <red>,<blue>,<green>:<size>
      • ItemStack: <itemstack in mbedwars format>
      • BlockData: <material>
      • MaterialData: <material>[:data]
      Parameters:
      config - The config that shall be parsed
      Returns:
      The parsed VarParticle instance that's ready to be played
      Throws:
      IllegalArgumentException - If an error occured while parsing
    • newDyedParticle

      public static VarParticle newDyedParticle(Color color)
      Constructs a new VarParticle that displays a redstone dust at the given color.
      Parameters:
      color - The color of the redstone dust
      Returns:
      A new instance with that color
    • newDyedMobSpell

      public static VarParticle newDyedMobSpell(Color color)
      Constructs a new VarParticle that displays swirls as seen with potion effects.
      Parameters:
      color - The color of the swirl particle
      Returns:
      A new instance with that color
    • newRandomizedDyedSwirl

      public static VarParticle newRandomizedDyedSwirl(int count, double offset)
      Returns a new instance of VarParticle that persists of a random color.

      Uses the particle POTION_SWIRL on 1.12 or older. Uses REDSTONE on 1.13+

      Parameters:
      count - The amount of particles
      offset - The offset of particles
      Returns:
      A newly constructed instance with a random color
      See Also:
    • newInstanceByName

      public static VarParticle newInstanceByName(String type) throws IllegalArgumentException
      Looks up for a particle/effect by the given name and returns a new instance.
      Parameters:
      type - The name
      Returns:
      A new VarParticle instance with the given type
      Throws:
      IllegalArgumentException - When the given name is invalid