Interface IElevator


  • public interface IElevator
    Represents a lightweight, immutable view of an elevator instance at a specific location.

    An IElevator contains:

    • the backing ShulkerBox block state,
    • a snapshot IElevatorType reference,
    • derived properties such as Location and DyeColor.

    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.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      @NotNull org.bukkit.DyeColor getDyeColor()
      Returns the dye color of the backing shulker box.
      @NotNull org.bukkit.Location getLocation()
      Returns the location of the backing shulker box in the world.
      @NotNull org.bukkit.block.ShulkerBox getShulkerBox()
      Returns the backing shulker box block state for this elevator.
      @NotNull IElevatorType getSnapshotElevatorType()
      Returns the snapshot elevator type reference stored in this elevator record.
      boolean isValid()
      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 IElevator instance. 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
      • 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 Optional will be empty.

        Contract:

        • Never returns null.
        • The returned Optional is empty if no matching elevator type is currently registered.
        Returns:
        an Optional containing the currently registered elevator type, or an empty Optional if none is registered
      • 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 false rather than throwing if the elevator can no longer be resolved live.

        Returns:
        true if the elevator still appears valid; otherwise false