Fzzy Config

Validated Choices

Create non-enum sets of choices (sets of integers, strings, and so on). 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 the current choice in the relevant type, and take a new choice in that type as well.

// 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 type and values of choices provided may not be automatically Translatable, such as plain numbers or strings. If you still want to provide translations and tooltips for your choices, ValidatedChoice can accept a translationProvider and descriptionProvider; BiFunctions that convert the choice to display into a translated text and hovered tooltip instead.

Using the weights example from above, we can build out some translations and descriptions for the weight options.

Depending on the translation and descriptions provided, the choices 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 (chance an item will appear, for example)

// 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.
);