Package me.totalfreedom.particle
Interface Trail
public interface Trail
Represents a Trail instance for a specific player.
-
Method Summary
Modifier and TypeMethodDescription@NotNull org.bukkit.OfflinePlayerReturns the player associated with this trail.@NotNull UUIDReturns the UUID of the player associated with the trail.@Nullable org.bukkit.ColorgetColor()This method is nullable because if the value ofisGradient()is true, thengetColors()should be used instead, as that will contain the color data for our trail.@Nullable Set<org.bukkit.Color>This method is nullable because if the value ofisGradient()is false, thengetColor()should be used instead, as our trail is a single static color.@NotNull TrailTypeGets the Trail Type of this trail.booleanisActive()Gets whether the trail is active.booleanValidates whether this Trail is a gradient or a static trail.voidsetActive(boolean active) Turn the trail on or off.voidsetColor(@NotNull org.bukkit.Color color) Sets the static color of the trail.voidSets the colors of the trail.voidSpawns a particle (if gradient, the next particle) on the supplied location object.
-
Method Details
-
getAssociatedPlayerUUID
Returns the UUID of the player associated with the trail. This is for usage with our persistant storage container so that we can safely send and retrieve the trails without having to directly reference a player object.
TL;DR Memory optimization!- Returns:
- The UUID of the player associated with this trail.
-
getAssociatedPlayer
@NotNull @NotNull org.bukkit.OfflinePlayer getAssociatedPlayer()Returns the player associated with this trail. Trails are user specific, and should be persistent across all usages. This is also used when displaying the particles, as they will be relative to the player's back, which is an inverse offset of the player's eye location. We use OfflinePlayer as we can make a simple check and cast to determine if the player is online when spawning trails.- Returns:
- The player associated with this Trail.
-
getTrailType
Gets the Trail Type of this trail. This is used to determine what type of trail this is, and whatParticleit should use.- Returns:
- The Trail Type of this trail.
- See Also:
-
getColor
@Nullable @Nullable org.bukkit.Color getColor()This method is nullable because if the value ofisGradient()is true, thengetColors()should be used instead, as that will contain the color data for our trail.
However, this method will also be null if the particle type is not colorable.- Returns:
- The color of the trail, or null if the trail is a gradient or non-colorable.
- See Also:
-
ParticlegetColors()
-
setColor
void setColor(@NotNull @NotNull org.bukkit.Color color) Sets the static color of the trail. If you are trying to use a gradient, usesetColors(Set)instead.- Parameters:
color- The color to set the trail to.
-
getColors
This method is nullable because if the value ofisGradient()is false, thengetColor()should be used instead, as our trail is a single static color.
However, this method will also be null if the particle type is not colorable.- Returns:
- The colors of the trail, or null if the trail is not a gradient or non-colorable.
- See Also:
-
getColor()ParticleInterpolationUtilsInterpolator
-
setColors
Sets the colors of the trail. If you are trying to use a static color, usesetColor(Color)instead.
This should be used for trails that iterate over a set of colors, such as a rainbow trail.- Parameters:
colors- The colors to set the trail to. It is recommended to useInterpolationUtilsto generate interpolated gradients for this.
-
isGradient
boolean isGradient()Validates whether this Trail is a gradient or a static trail.
This is entirely based on whethergetColors()returns null or not.- Returns:
- True if
getColors()is not null, false otherwise.
-
isActive
boolean isActive()Gets whether the trail is active.- Returns:
- True if the trail is active, false if it is not.
-
setActive
void setActive(boolean active) Turn the trail on or off.- Parameters:
active- True if the trail should be active, false if it should not.
-
spawnParticle
void spawnParticle()Spawns a particle (if gradient, the next particle) on the supplied location object.
-