Fzzy Config

Validated Choices

A set of choices with one active choice. Lists and sets can be automatically converted to choices with their toChoices() method.

ValidatedChoice is validation of the type the choices are, so the get() and apply() methods will return and consume choices in the relevant type directly.

// Defines a set of weights the user can choose from. Note the use of ValidatedSets toChoices()
public ValidatedChoice<Integer> validatedWeightChoices = ValidateSet.ofInt(1, 2, 5, 10, 20).toChoices(ValidatedChoice.WidgetType.CYCLING); //Validated choice has optional GUI and translation controls too.

Translation Providers

The choices provided may not be automatically Translatable, like numbers or strings. To provide translations and tooltips for your choices, ValidatedChoice accepts a translationProvider and descriptionProvider; BiFunctions that convert the choice into a translated text and hovered tooltip.

The weight choices from the example above might display like "Ultra Rare", "Very Rare", "Rare", "Uncommon", "Common" instead of 1, 2, 5, 10, 20, with hovered tooltips that explain what each rarity value means.

// Defines a set of weights the user can choose from. Note the use of ValidatedSets toChoices()
public ValidatedChoice<Integer> validatedWeightChoices = ValidateSet.ofInt(1, 2, 5, 10, 20).toChoices(
ValidatedChoice.WidgetType.CYCLING,
ValidatedChoice.translate(), //ValidatedChoice has a helper method that produces an automatic translated text based on a pre-defined key format.
ValidatedChoice.translate("desc") //see the documentation for details on the key format.
);