Interface IElevatorActionSetting<T>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean canBeEditedIndividually​(@NotNull IElevator elevator)
      Returns whether this setting can be edited per-elevator (i.e., supports individual overrides).
      @NotNull java.lang.String getGlobalValue​(@NotNull IElevatorType elevatorType)
      Returns the current global value for this setting as a string.
      void onClick​(@NotNull PentaConsumer<@NotNull org.bukkit.entity.Player,​@NotNull java.lang.Runnable,​@NotNull org.bukkit.event.inventory.InventoryClickEvent,​@NotNull T,​@NotNull java.util.function.Consumer<T>> setValueGlobalMethod)
      Registers the click handler used to edit this setting.
      void onClickGlobal​(@NotNull org.bukkit.entity.Player player, @NotNull IElevatorType elevatorType, @NotNull java.lang.Runnable returnMethod, @NotNull org.bukkit.event.inventory.InventoryClickEvent clickEvent, @NotNull java.lang.String currentValue)
      Invoked when this setting is clicked in the admin menu (applies to the action's global variable value).
      void onClickIndividual​(@NotNull org.bukkit.entity.Player player, @NotNull IElevator elevator, @NotNull java.lang.Runnable returnMethod, @NotNull org.bukkit.event.inventory.InventoryClickEvent clickEvent, @NotNull java.lang.String currentValue)
      Invoked when this setting is clicked in an "individual" context (applies per elevator instance).
      @NotNull IElevatorSetting<java.lang.String> setupDataStore​(@NotNull java.lang.String settingKey, @NotNull org.bukkit.persistence.PersistentDataType<?,​java.lang.String> dataType)
      Configures persistent storage for per-elevator values of this setting.
    • Method Detail

      • onClick

        void onClick​(@NotNull
                     @NotNull PentaConsumer<@NotNull org.bukkit.entity.Player,​@NotNull java.lang.Runnable,​@NotNull org.bukkit.event.inventory.InventoryClickEvent,​@NotNull T,​@NotNull java.util.function.Consumer<T>> setValueGlobalMethod)
        Registers the click handler used to edit this setting.

        The handler is provided:

        • the player,
        • a return callback to go back to the previous UI,
        • the click event,
        • the current parsed value (T),
        • a consumer that must be called with the new value to persist/apply it.

        Contract: Must be called exactly once during setup before any click methods are used.

        Parameters:
        setValueGlobalMethod - non-null click handler
        Throws:
        java.lang.NullPointerException - if setValueGlobalMethod is null
      • onClickGlobal

        void onClickGlobal​(@NotNull
                           @NotNull org.bukkit.entity.Player player,
                           @NotNull
                           @NotNull IElevatorType elevatorType,
                           @NotNull
                           @NotNull java.lang.Runnable returnMethod,
                           @NotNull
                           @NotNull org.bukkit.event.inventory.InventoryClickEvent clickEvent,
                           @NotNull
                           @NotNull java.lang.String currentValue)
        Invoked when this setting is clicked in the admin menu (applies to the action's global variable value).

        The implementation should parse currentValue into T, then delegate to the registered onClick handler.

        Specified by:
        onClickGlobal in interface IElevatorSetting<T>
        Parameters:
        player - non-null clicking player
        elevatorType - non-null elevator type being edited
        returnMethod - non-null callback to return to the previous UI
        clickEvent - non-null inventory click event
        currentValue - non-null current string value for this setting
        Throws:
        java.lang.IllegalStateException - if no onClick handler was registered via onClick(PentaConsumer)
      • onClickIndividual

        void onClickIndividual​(@NotNull
                               @NotNull org.bukkit.entity.Player player,
                               @NotNull
                               @NotNull IElevator elevator,
                               @NotNull
                               @NotNull java.lang.Runnable returnMethod,
                               @NotNull
                               @NotNull org.bukkit.event.inventory.InventoryClickEvent clickEvent,
                               @NotNull
                               @NotNull java.lang.String currentValue)
        Invoked when this setting is clicked in an "individual" context (applies per elevator instance).

        This is only called when canBeEditedIndividually(IElevator) is true.

        Specified by:
        onClickIndividual in interface IElevatorSetting<T>
        Parameters:
        player - non-null clicking player
        elevator - non-null elevator being edited
        returnMethod - non-null callback to return to the previous UI
        clickEvent - non-null inventory click event
        currentValue - non-null current string value for this setting
        Throws:
        java.lang.IllegalStateException - if no onClick handler was registered via onClick(PentaConsumer)
      • getGlobalValue

        @NotNull
        @NotNull java.lang.String getGlobalValue​(@NotNull
                                                 @NotNull IElevatorType elevatorType)
        Returns the current global value for this setting as a string.

        This is typically derived by serializing the action variable value.

        Specified by:
        getGlobalValue in interface IElevatorSetting<T>
        Parameters:
        elevatorType - non-null elevator type context
        Returns:
        non-null current global value in string form
        Throws:
        java.lang.NullPointerException - if elevatorType is null
      • setupDataStore

        @NotNull
        @NotNull IElevatorSetting<java.lang.String> setupDataStore​(@NotNull
                                                                   @NotNull java.lang.String settingKey,
                                                                   @NotNull
                                                                   @NotNull org.bukkit.persistence.PersistentDataType<?,​java.lang.String> dataType)
        Configures persistent storage for per-elevator values of this setting.

        Implementations may derive the actual storage key from settingKey (for example by prefixing with an action instance identifier).

        Parameters:
        settingKey - non-null base key for persistent storage
        dataType - non-null data type used for storage
        Returns:
        the underlying (string) setting that was configured for storage
        Throws:
        java.lang.NullPointerException - if any argument is null
      • canBeEditedIndividually

        boolean canBeEditedIndividually​(@NotNull
                                        @NotNull IElevator elevator)
        Returns whether this setting can be edited per-elevator (i.e., supports individual overrides).
        Specified by:
        canBeEditedIndividually in interface IElevatorSetting<T>
        Parameters:
        elevator - non-null elevator context
        Returns:
        true if individual editing is supported; otherwise false
        Throws:
        java.lang.NullPointerException - if elevator is null