Class Laser

java.lang.Object
fr.skytasul.guardianbeam.Laser
Direct Known Subclasses:
Laser.CrystalLaser, Laser.GuardianLaser

public abstract class Laser extends Object
An util to create Guardian Lasers and Ender Crystal Beams using packets and reflection.
Author:
SkytAsul
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static class 
     
    static enum 
     
    protected static class 
     
    static interface 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     
    protected final int
     
    protected boolean
     
    protected org.bukkit.Location
     
    protected org.bukkit.scheduler.BukkitTask
     
    protected org.bukkit.scheduler.BukkitRunnable
     
    protected org.bukkit.plugin.Plugin
     
    protected Set<org.bukkit.entity.Player>
     
    protected org.bukkit.Location
     
    protected org.bukkit.scheduler.BukkitTask
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Laser(org.bukkit.Location start, org.bukkit.Location end, int duration, int distance)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Makes the duration provided in the constructor passed as ticks and not seconds
    executeEnd(Runnable runnable)
    Adds a runnable to execute when the laser reaches its final duration
    org.bukkit.Location
    Gets the end location of the laser.
    Gets laser type.
    org.bukkit.Location
    Gets the start location of the laser.
    protected boolean
    isCloseEnough(org.bukkit.entity.Player player)
     
    boolean
    Gets laser status.
    abstract void
    moveEnd(org.bukkit.Location location)
    Instantly moves the end of the laser to the location provided.
    void
    moveEnd(org.bukkit.Location location, int ticks, Runnable callback)
    Moves the end of the laser smoothly to the new location, within a given time.
    protected void
    moveFakeEntity(org.bukkit.Location location, Object fakeEntity)
     
    abstract void
    moveStart(org.bukkit.Location location)
    Instantly moves the start of the laser to the location provided.
    void
    moveStart(org.bukkit.Location location, int ticks, Runnable callback)
    Moves the start of the laser smoothly to the new location, within a given time.
    protected abstract void
    sendDestroyPackets(org.bukkit.entity.Player p)
     
    protected abstract void
    sendStartPackets(org.bukkit.entity.Player p, boolean hasSeen)
     
    void
    start(org.bukkit.plugin.Plugin plugin)
    Starts this laser.
    void
    Stops this laser.

    Methods inherited from class java.lang.Object

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

    • distanceSquared

      protected final int distanceSquared
    • duration

      protected final int duration
    • durationInTicks

      protected boolean durationInTicks
    • start

      protected org.bukkit.Location start
    • end

      protected org.bukkit.Location end
    • plugin

      protected org.bukkit.plugin.Plugin plugin
    • main

      protected org.bukkit.scheduler.BukkitRunnable main
    • startMove

      protected org.bukkit.scheduler.BukkitTask startMove
    • endMove

      protected org.bukkit.scheduler.BukkitTask endMove
    • show

      protected Set<org.bukkit.entity.Player> show
  • Constructor Details

    • Laser

      protected Laser(org.bukkit.Location start, org.bukkit.Location end, int duration, int distance)
  • Method Details

    • executeEnd

      public Laser executeEnd(Runnable runnable)
      Adds a runnable to execute when the laser reaches its final duration
      Parameters:
      runnable - action to execute
      Returns:
      this Laser instance
    • durationInTicks

      public Laser durationInTicks()
      Makes the duration provided in the constructor passed as ticks and not seconds
      Returns:
      this Laser instance
    • start

      public void start(org.bukkit.plugin.Plugin plugin)
      Starts this laser.

      It will make the laser visible for nearby players and start the countdown to the final duration.

      Once finished, it will destroy the laser and execute all runnables passed with executeEnd.

      Parameters:
      plugin - plugin used to start the task
    • stop

      public void stop()
      Stops this laser.

      This will destroy the laser for every player and start execute all runnables passed with executeEnd

    • isStarted

      public boolean isStarted()
      Gets laser status.
      Returns:
      true if the laser is currently running (i.e. start has been called and the duration is not over)
    • getLaserType

      public abstract Laser.LaserType getLaserType()
      Gets laser type.
      Returns:
      LaserType enum constant of this laser
    • moveStart

      public abstract void moveStart(org.bukkit.Location location) throws ReflectiveOperationException
      Instantly moves the start of the laser to the location provided.
      Parameters:
      location - New start location
      Throws:
      ReflectiveOperationException - if a reflection exception occurred during laser moving
    • moveEnd

      public abstract void moveEnd(org.bukkit.Location location) throws ReflectiveOperationException
      Instantly moves the end of the laser to the location provided.
      Parameters:
      location - New end location
      Throws:
      ReflectiveOperationException - if a reflection exception occurred during laser moving
    • getStart

      public org.bukkit.Location getStart()
      Gets the start location of the laser.
      Returns:
      where exactly is the start position of the laser located
    • getEnd

      public org.bukkit.Location getEnd()
      Gets the end location of the laser.
      Returns:
      where exactly is the end position of the laser located
    • moveStart

      public void moveStart(org.bukkit.Location location, int ticks, Runnable callback)
      Moves the start of the laser smoothly to the new location, within a given time.
      Parameters:
      location - New start location to go to
      ticks - Duration (in ticks) to make the move
      callback - Runnable to execute at the end of the move (nullable)
    • moveEnd

      public void moveEnd(org.bukkit.Location location, int ticks, Runnable callback)
      Moves the end of the laser smoothly to the new location, within a given time.
      Parameters:
      location - New end location to go to
      ticks - Duration (in ticks) to make the move
      callback - Runnable to execute at the end of the move (nullable)
    • moveFakeEntity

      protected void moveFakeEntity(org.bukkit.Location location, Object fakeEntity) throws ReflectiveOperationException
      Throws:
      ReflectiveOperationException
    • sendStartPackets

      protected abstract void sendStartPackets(org.bukkit.entity.Player p, boolean hasSeen) throws ReflectiveOperationException
      Throws:
      ReflectiveOperationException
    • sendDestroyPackets

      protected abstract void sendDestroyPackets(org.bukkit.entity.Player p) throws ReflectiveOperationException
      Throws:
      ReflectiveOperationException
    • isCloseEnough

      protected boolean isCloseEnough(org.bukkit.entity.Player player)