Interface IElevator
-
public interface IElevatorRepresents a lightweight, immutable view of an elevator instance at a specific location.An
IElevatorcontains:- the backing
ShulkerBoxblock state, - a snapshot
IElevatorTypereference, - derived properties such as
LocationandDyeColor.
This object does not perform elevator logic on its own; it is intended to be passed into other API methods that require both elevator state and an elevator type.
Immutability: Implementations are expected to be immutable with respect to their stored references, but their derived values (location, block state, live type) may change as the world and registrations change.
- the backing
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull org.bukkit.DyeColorgetDyeColor()Returns the dye color of the backing shulker box.@NotNull org.bukkit.LocationgetLocation()Returns the location of the backing shulker box in the world.@NotNull org.bukkit.block.ShulkerBoxgetShulkerBox()Returns the backing shulker box block state for this elevator.@NotNull IElevatorTypegetSnapshotElevatorType()Returns the snapshot elevator type reference stored in this elevator record.booleanisValid()Returns whether this elevator record still matches the current world state and registered type.@NotNull java.util.Optional<IElevatorType>resolveElevatorTypeLive()Attempts to resolve the currently registered elevator type for this elevator.
-
-
-
Method Detail
-
getShulkerBox
@NotNull @NotNull org.bukkit.block.ShulkerBox getShulkerBox()
Returns the backing shulker box block state for this elevator.Contract: Never
null.- Returns:
- the shulker box backing this elevator
-
getSnapshotElevatorType
@NotNull @NotNull IElevatorType getSnapshotElevatorType()
Returns the snapshot elevator type reference stored in this elevator record.This is the elevator type that was associated with this elevator when it was originally resolved or constructed. It does not change over the lifetime of this
IElevatorinstance. If a reload occurs or the elevator type is deleted, this snapshot will become invalid.Contract:
- Never returns
null. - The returned type may no longer be registered or may be a replaced instance.
- Returns:
- the non-null snapshot elevator type reference
- Never returns
-
resolveElevatorTypeLive
@NotNull @NotNull java.util.Optional<IElevatorType> resolveElevatorTypeLive()
Attempts to resolve the currently registered elevator type for this elevator.This method performs a live lookup using the snapshot type's key and returns the currently registered
IElevatorType, if one exists.If the elevator type has been unregistered or replaced since this elevator was created, the returned
Optionalwill be empty.Contract:
- Never returns
null. - The returned
Optionalis empty if no matching elevator type is currently registered.
- Returns:
- an
Optionalcontaining the currently registered elevator type, or an emptyOptionalif none is registered
- Never returns
-
getLocation
@NotNull @NotNull org.bukkit.Location getLocation()
Returns the location of the backing shulker box in the world.Contract: For elevators resolved from placed blocks, this should be non-null.
- Returns:
- the elevator's location
-
getDyeColor
@NotNull @NotNull org.bukkit.DyeColor getDyeColor()
Returns the dye color of the backing shulker box.Invariant: Elevators cannot be created from undyed shulker boxes, so this is never
null.- Returns:
- the non-null dye color of this elevator
-
isValid
boolean isValid()
Returns whether this elevator record still matches the current world state and registered type.Implementations typically check that:
- the block at
getLocation()is still the same shulker box type, and - the snapshot type is still the currently registered type for its key.
Contract: Returns
falserather than throwing if the elevator can no longer be resolved live.- Returns:
trueif the elevator still appears valid; otherwisefalse
- the block at
-
-