Runnable Option
Introduction
RunnableOption
is a option class that encapsulates a task to be executed upon user interaction, specifically designed for actions that need to be triggered. This essentially acts as a boolean option but runs a task everytime the "boolean" is true.
Constructor Parameters
The RunnableOption class has two constructors that takes the following parameters:
One of the constructors uses the
BooleanPool
class to store and manage the Boolean values. This is when you don't want the hassle to create a new and unnecessary Boolean for every Runnable Option you create. This constructor does not contain thegetter
andsetter
variables.name
: Display name for the option.getter
: Supplier that checks if the task is currently considered active or running.setter
: Consumer that updates the task's active state based on user interaction.task
: The Runnable task to be executed.
Interactivity
Click: Toggles the task's active state and runs the task if set to active.
Render: Displays the option's name with a color change to indicate the active state.
Example Usage
Last updated
Was this helpful?