# Custom Elevator Settings

The ElevatorSettings API allows developers to define their own reusable settings that can be globally configured or customized per elevator. These settings are ideal for toggling features, adjusting variables, or adding meaningful controls that your plugin logic can interpret.


# Getting Started

To begin creating a custom setting, use the builder method:

ElevatorSetting.builder("setting-key", defaultValue, ElevatorsDataType.TYPE)
  • setting-key – A unique key for the setting. This must fit the pattern [a-z0-9/._-]+
  • defaultValue – The default value to use if none is configured
  • ElevatorsDataType – The type of data this setting holds (e.g., BOOLEAN, INTEGER)

You can also use PersistentDataType<?,T> if you prefer Bukkit’s native types.


# Builder Methods

Method Description
.addAction(String, String) Adds a click description to the item’s lore
.allowPerEleCustomization() Allows this setting to appear in per-elevator menus
.setCanEditIndividually() A more robust method to determine if this setting should appear in per-elevator menus
.addComment(String) Adds a YAML comment above the setting in the config
.onClick(Consumer) Handles clicks on the setting's icon in the UI
.register(...) Registers the setting with Elevators and defines how it appears in the GUI

# Handling Click Events

Use .onClick(context -> { ... }) to respond when the setting’s icon is clicked. You'll receive a ElevatorSettingClickContext object.

# ElevatorSettingClickContext

Method Description
.setValue() Updates the current value of the setting
.getCurrentValue() Gets the value before the click occurred
.getClickEvent() Returns the InventoryClickEvent that triggered this
.getPlayer() The player who clicked
.close() Closes the UI and returns to the previous menu

# Example: Boolean Toggle Setting

ElevatorSetting.builder("test-setting", true, ElevatorsDataType.BOOLEAN)
    .addAction("Left click", "Toggle")
    .allowPerEleCustomization()
    .addComment("This is an example comment. Heck yeah")
    .onClick(context -> {
        context.setValue(!context.getCurrentValue());
        context.close();
    })
    .register(myPlugin, ChatColor.AQUA + "", "Test Setting", Material.ITEM_FRAME);

# Notes

  • Registered settings do not perform actions automatically — it's up to your plugin to read and respond to them as needed.

🧪 Want to contribute more settings? Feel free to fork the plugin and submit PRs via GitHub!


# See Also