Class ElevatorEffect
- java.lang.Object
-
- me.keehl.elevators.api.models.ElevatorEffect
-
- All Implemented Interfaces:
IElevatorEffect
public abstract class ElevatorEffect extends java.lang.Object implements IElevatorEffect
Convenience base class for implementing customIElevatorEffects.Third-party developers may extend this class to create custom effects while reusing common helpers such as effect location and dye-based particle color.
Key normalization
The provided
effectKeyis normalized to uppercase for consistency. Consumers should treat effect keys as case-insensitive.Threading
Effects typically interact with the world (particles/sounds). Implementations should assume
playEffect(IElevatorEventData, IElevator)is called from the server thread. Will run on location threads if in a Folia environment
-
-
Constructor Summary
Constructors Constructor Description ElevatorEffect(@NotNull java.lang.String effectKey, @NotNull org.bukkit.inventory.ItemStack icon)Creates a new effect with a server-wide identifying key and an icon.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @NotNull java.lang.StringgetEffectKey()Returns the server-wide key that identifies this effect.protected @NotNull org.bukkit.LocationgetEffectLocation(@NotNull IElevator elevator)Returns the base location where effects should be played.@NotNull org.bukkit.inventory.ItemStackgetIcon()Returns the icon used to represent this effect in UIs.protected @NotNull org.bukkit.ColorgetParticleColor(@NotNull IElevator elevator)Returns the particle color derived from the elevator's dye color.abstract voidplayEffect(@NotNull IElevatorEventData teleportResult, @NotNull IElevator elevator)Plays this effect for the given event and elevator.
-
-
-
Constructor Detail
-
ElevatorEffect
public ElevatorEffect(@NotNull @NotNull java.lang.String effectKey, @NotNull @NotNull org.bukkit.inventory.ItemStack icon)Creates a new effect with a server-wide identifying key and an icon.Contract:
effectKeyandiconmust be non-null.effectKeyis stored in uppercase.
- Parameters:
effectKey- non-null identifying key for this effecticon- non-null icon used for UI display- Throws:
java.lang.NullPointerException- if any argument isnull
-
-
Method Detail
-
getEffectLocation
@NotNull protected @NotNull org.bukkit.Location getEffectLocation(@NotNull @NotNull IElevator elevator)Returns the base location where effects should be played.The default implementation returns a clone of
IElevator.getLocation()to avoid mutating the elevator's underlying location.Subclasses may override to offset the effect location (for example, above the shulker box).
- Parameters:
elevator- non-null elevator instance- Returns:
- non-null effect location
- Throws:
java.lang.NullPointerException- ifelevatorisnull
-
getParticleColor
@NotNull protected @NotNull org.bukkit.Color getParticleColor(@NotNull @NotNull IElevator elevator)Returns the particle color derived from the elevator's dye color.The default implementation uses
IElevator.getDyeColor()to derive an RGBColor.- Parameters:
elevator- non-null elevator instance- Returns:
- non-null particle color
- Throws:
java.lang.NullPointerException- ifelevatorisnull
-
getEffectKey
@NotNull public final @NotNull java.lang.String getEffectKey()
Returns the server-wide key that identifies this effect.- Specified by:
getEffectKeyin interfaceIElevatorEffect- Returns:
- the non-null effect key
-
getIcon
@NotNull public final @NotNull org.bukkit.inventory.ItemStack getIcon()
Returns the icon used to represent this effect in UIs.- Specified by:
getIconin interfaceIElevatorEffect- Returns:
- the non-null icon
-
playEffect
public abstract void playEffect(@NotNull @NotNull IElevatorEventData teleportResult, @NotNull @NotNull IElevator elevator)Plays this effect for the given event and elevator.Implementations may spawn particles, play sounds, or otherwise interact with the world.
- Specified by:
playEffectin interfaceIElevatorEffect- Parameters:
teleportResult- non-null event context describing the elevator interaction/teleportelevator- non-null elevator instance
-
-