Package fr.skytasul.guardianbeam
Class Laser
java.lang.Object
fr.skytasul.guardianbeam.Laser
- Direct Known Subclasses:
Laser.CrystalLaser,Laser.GuardianLaser
An util to create Guardian Lasers and Ender Crystal Beams using packets and reflection.
- Author:
- SkytAsul
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic enumprotected static classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final intprotected booleanprotected org.bukkit.Locationprotected org.bukkit.scheduler.BukkitTaskprotected org.bukkit.scheduler.BukkitRunnableprotected org.bukkit.plugin.Pluginprotected Set<org.bukkit.entity.Player>protected org.bukkit.Locationprotected org.bukkit.scheduler.BukkitTask -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLaser(org.bukkit.Location start, org.bukkit.Location end, int duration, int distance) -
Method Summary
Modifier and TypeMethodDescriptionMakes the duration provided in the constructor passed as ticks and not secondsexecuteEnd(Runnable runnable) Adds a runnable to execute when the laser reaches its final durationorg.bukkit.LocationgetEnd()Gets the end location of the laser.abstract Laser.LaserTypeGets laser type.org.bukkit.LocationgetStart()Gets the start location of the laser.protected booleanisCloseEnough(org.bukkit.entity.Player player) booleanGets laser status.abstract voidmoveEnd(org.bukkit.Location location) Instantly moves the end of the laser to the location provided.voidMoves the end of the laser smoothly to the new location, within a given time.protected voidmoveFakeEntity(org.bukkit.Location location, Object fakeEntity) abstract voidmoveStart(org.bukkit.Location location) Instantly moves the start of the laser to the location provided.voidMoves the start of the laser smoothly to the new location, within a given time.protected abstract voidsendDestroyPackets(org.bukkit.entity.Player p) protected abstract voidsendStartPackets(org.bukkit.entity.Player p, boolean hasSeen) voidstart(org.bukkit.plugin.Plugin plugin) Starts this laser.voidstop()Stops this laser.
-
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
-
-
Constructor Details
-
Laser
protected Laser(org.bukkit.Location start, org.bukkit.Location end, int duration, int distance)
-
-
Method Details
-
executeEnd
Adds a runnable to execute when the laser reaches its final duration- Parameters:
runnable- action to execute- Returns:
- this
Laserinstance
-
durationInTicks
Makes the duration provided in the constructor passed as ticks and not seconds- Returns:
- this
Laserinstance
-
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:
trueif the laser is currently running (i.e.starthas been called and the duration is not over)
-
getLaserType
Gets laser type.- Returns:
- LaserType enum constant of this laser
-
moveStart
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
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
Moves the start of the laser smoothly to the new location, within a given time.- Parameters:
location- New start location to go toticks- Duration (in ticks) to make the movecallback-Runnableto execute at the end of the move (nullable)
-
moveEnd
Moves the end of the laser smoothly to the new location, within a given time.- Parameters:
location- New end location to go toticks- Duration (in ticks) to make the movecallback-Runnableto 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)
-