Class ParticleShaper

java.lang.Object
hm.zelha.particlesfx.shapers.parents.RotationHandler
hm.zelha.particlesfx.shapers.parents.ParticleShaper
All Implemented Interfaces:
Shape
Direct Known Subclasses:
ParticleCircle, ParticleCylinder, ParticleFluid, ParticleImage, ParticleLine, ParticlePolygon, ParticleSpiral, ParticleText

public abstract class ParticleShaper extends RotationHandler implements Shape
  • Field Details

    • secondaryParticles

      protected final List<Pair<Particle,Integer>> secondaryParticles
    • mechanics

    • players

      protected final List<UUID> players
    • locationHelper

      protected final org.bukkit.Location locationHelper
    • vectorHelper

      protected final org.bukkit.util.Vector vectorHelper
    • animator

      protected org.bukkit.scheduler.BukkitTask animator
    • particle

      protected Particle particle
    • async

      protected boolean async
    • particleFrequency

      protected int particleFrequency
    • particlesPerDisplay

      protected int particlesPerDisplay
    • currentCount

      protected int currentCount
    • overallCount

      protected int overallCount
    • delay

      protected int delay
  • Constructor Details

    • ParticleShaper

      public ParticleShaper(Particle particle, int particleFrequency)
  • Method Details

    • start

      public ParticleShaper start()
      Specified by:
      start in interface Shape
      Returns:
      this object
    • stop

      public ParticleShaper stop()
      Specified by:
      stop in interface Shape
      Returns:
      this object
    • clone

      public ParticleShaper clone()
      Specified by:
      clone in interface Shape
      Overrides:
      clone in class Object
    • display

      public abstract void display()
      Specified by:
      display in interface Shape
    • cloneConstructor

      protected abstract ParticleShaper cloneConstructor()
    • getCurrentParticle

      protected Particle getCurrentParticle()
    • applyMechanics

      protected void applyMechanics(ShapeDisplayMechanic.Phase phase, Particle particle, org.bukkit.Location current, org.bukkit.util.Vector addition)
    • addParticle

      public void addParticle(Particle particle, int particlesUntilDisplay)
      Description copied from interface: Shape
      adds a particle for this shape to display after a certain amount of other particles
      Specified by:
      addParticle in interface Shape
      Parameters:
      particle - particle to add
      particlesUntilDisplay - how many particles need to be displayed before this one
    • addMechanic

      public void addMechanic(ShapeDisplayMechanic.Phase phase, ShapeDisplayMechanic mechanic)
      Description copied from interface: Shape
      Similar to Consumer
      in the case of phases ShapeDisplayMechanic.Phase.BEFORE_ROTATION and ShapeDisplayMechanic.Phase.AFTER_ROTATION the given mechanic will run before the location is modified to display the next particle, allowing you to modify the addition vector however you want, though doing so may be very volatile

      keep in mind that all changes to the given objects will be reflected in the display() method, and considering that the display() method often displays hundreds of particles, try to make sure the mechanic isn't very resource-intensive

      ShapeDisplayMechanic.apply(Particle, Location, Vector, int)
      Specified by:
      addMechanic in interface Shape
      Parameters:
      phase - phase that the mechanic should run at
      mechanic - mechanic to run during display
    • addPlayer

      public void addPlayer(org.bukkit.entity.Player player)
      Description copied from interface: Shape
      adds a player for this shape to display to, defaults to all online players in the shape's world if the list is empty
      Specified by:
      addPlayer in interface Shape
      Parameters:
      player - player to add
    • addPlayer

      public void addPlayer(UUID uuid)
      Description copied from interface: Shape
      adds a player for this shape to display to, defaults to all online players in the shape's world if the list is empty
      Specified by:
      addPlayer in interface Shape
      Parameters:
      uuid - ID of player to add
    • removeParticle

      public void removeParticle(int index)
      Specified by:
      removeParticle in interface Shape
      Parameters:
      index - index of particle in list (main particle is not in list)
      See Also:
    • removeMechanic

      public void removeMechanic(int index)
      Specified by:
      removeMechanic in interface Shape
      Parameters:
      index - index of mechanic in list
      See Also:
    • removePlayer

      public void removePlayer(int index)
      Specified by:
      removePlayer in interface Shape
      Parameters:
      index - index of player to remove from list
      See Also:
    • removePlayer

      public void removePlayer(org.bukkit.entity.Player player)
      Specified by:
      removePlayer in interface Shape
      Parameters:
      player - player to remove from list
      See Also:
    • hasPlayer

      public boolean hasPlayer(org.bukkit.entity.Player player)
      Specified by:
      hasPlayer in interface Shape
      Parameters:
      player - player to check for
      Returns:
      whether this shape displays to this player
    • setParticle

      public void setParticle(Particle particle)
      Specified by:
      setParticle in interface Shape
    • setParticleFrequency

      public void setParticleFrequency(int particleFrequency)
      Specified by:
      setParticleFrequency in interface Shape
      Parameters:
      particleFrequency - amount of times to display the particle per full animation
    • setParticlesPerDisplay

      public ParticleShaper setParticlesPerDisplay(int particlesPerDisplay)
      Description copied from interface: Shape
      0 means that the entire animation will be played when .display() is called
      Specified by:
      setParticlesPerDisplay in interface Shape
      Parameters:
      particlesPerDisplay - amount of particles that will be shown per display
    • setAsync

      public ParticleShaper setAsync(boolean async)
      Specified by:
      setAsync in interface Shape
    • setDelay

      public ParticleShaper setDelay(int delay)
      Specified by:
      setDelay in interface Shape
      Parameters:
      delay - amount of ticks between Shape.display() being called
    • setDisplayPosition

      public void setDisplayPosition(int position)
      Description copied from interface: Shape
      sets the current position of the shape's animation
      (aka, sets the tracker that tells the shape how many particles have been displayed until this point)
      Specified by:
      setDisplayPosition in interface Shape
      Parameters:
      position - position for shape to display at
    • setWorld

      public void setWorld(org.bukkit.World world)
      Specified by:
      setWorld in interface Shape
      Overrides:
      setWorld in class RotationHandler
    • getParticle

      public Particle getParticle()
      Specified by:
      getParticle in interface Shape
    • getSecondaryParticle

      public Pair<Particle,Integer> getSecondaryParticle(int index)
      Specified by:
      getSecondaryParticle in interface Shape
      Parameters:
      index - index of particle to get from the list
      Returns:
      a pair of the particle and the amount of particles before it should be displayed
      See Also:
    • getParticleFrequency

      public int getParticleFrequency()
      Specified by:
      getParticleFrequency in interface Shape
    • getParticlesPerDisplay

      public int getParticlesPerDisplay()
      Specified by:
      getParticlesPerDisplay in interface Shape
      Returns:
      the amount of particles per display
      See Also:
    • getDelay

      public int getDelay()
      Specified by:
      getDelay in interface Shape
      Returns:
      amount of ticks between display() being called
    • getSecondaryParticleAmount

      public int getSecondaryParticleAmount()
      Specified by:
      getSecondaryParticleAmount in interface Shape
      Returns:
      the amount of extra particles that this shape uses
      See Also:
    • getMechanicAmount

      public int getMechanicAmount()
      Specified by:
      getMechanicAmount in interface Shape
      Returns:
      the amount of mechanics used by this shape
      See Also:
    • getPlayers

      public List<UUID> getPlayers()
      Specified by:
      getPlayers in interface Shape
      Returns:
      the UUIDs of all the players that this shape displays to. displays to all players if this list is empty
    • getPlayerAmount

      public int getPlayerAmount()
      Specified by:
      getPlayerAmount in interface Shape
      Returns:
      amount of players this shape displays to
    • isAsync

      public boolean isAsync()
      Specified by:
      isAsync in interface Shape
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Shape