Interface IElevatorActionSetting<T>
-
- All Superinterfaces:
IElevatorSetting<java.lang.String>
public interface IElevatorActionSetting<T> extends IElevatorSetting<java.lang.String>
Represents an editable setting for anIElevatorActionvariable.This setting bridges a string-backed datastore (via
IElevatorSetting) with a typed valueTused during editing. Implementations typically:- parse the current string value into
T, - open a UI/editor to choose a new
T, - apply the chosen value either globally (action variable) or per-elevator (datastore override).
Click handling
Before invoking
onClickGlobal(Player, IElevatorType, Runnable, InventoryClickEvent, String)oronClickIndividual(Player, IElevator, Runnable, InventoryClickEvent, String), an onClick handler must be registered usingonClick(PentaConsumer).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanBeEditedIndividually(@NotNull IElevator elevator)Returns whether this setting can be edited per-elevator (i.e., supports individual overrides).@NotNull java.lang.StringgetGlobalValue(@NotNull IElevatorType elevatorType)Returns the current global value for this setting as a string.voidonClick(@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.voidonClickGlobal(@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).voidonClickIndividual(@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.-
Methods inherited from interface me.keehl.elevators.api.models.IElevatorSetting
addAction, clickGlobal, clickIndividual, createIcon, getIndividualValue, getPlugin, getSettingName, isSettingGlobalOnly, setIndividualValue
-
-
-
-
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- ifsetValueGlobalMethodisnull
-
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
currentValueintoT, then delegate to the registered onClick handler.- Specified by:
onClickGlobalin interfaceIElevatorSetting<T>- Parameters:
player- non-null clicking playerelevatorType- non-null elevator type being editedreturnMethod- non-null callback to return to the previous UIclickEvent- non-null inventory click eventcurrentValue- non-null current string value for this setting- Throws:
java.lang.IllegalStateException- if no onClick handler was registered viaonClick(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:
onClickIndividualin interfaceIElevatorSetting<T>- Parameters:
player- non-null clicking playerelevator- non-null elevator being editedreturnMethod- non-null callback to return to the previous UIclickEvent- non-null inventory click eventcurrentValue- non-null current string value for this setting- Throws:
java.lang.IllegalStateException- if no onClick handler was registered viaonClick(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:
getGlobalValuein interfaceIElevatorSetting<T>- Parameters:
elevatorType- non-null elevator type context- Returns:
- non-null current global value in string form
- Throws:
java.lang.NullPointerException- ifelevatorTypeisnull
-
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 storagedataType- non-null data type used for storage- Returns:
- the underlying (string) setting that was configured for storage
- Throws:
java.lang.NullPointerException- if any argument isnull
-
canBeEditedIndividually
boolean canBeEditedIndividually(@NotNull @NotNull IElevator elevator)Returns whether this setting can be edited per-elevator (i.e., supports individual overrides).- Specified by:
canBeEditedIndividuallyin interfaceIElevatorSetting<T>- Parameters:
elevator- non-null elevator context- Returns:
- true if individual editing is supported; otherwise false
- Throws:
java.lang.NullPointerException- ifelevatorisnull
-
-