Class EnumSetting<T extends Enum<T>>
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.items.ItemSetting<String>
io.github.thebusybiscuit.slimefun4.api.items.settings.EnumSetting<T>
- Type Parameters:
T
- TheEnum
type
This variation of
ItemSetting
allows you to allow Enum
constants to be
used for ItemSetting
validation.- Author:
- TheBusyBiscuit
- See Also:
-
Constructor Summary
ConstructorDescriptionEnumSetting
(SlimefunItem item, String key, Class<T> enumClass, T defaultValue) -
Method Summary
Modifier and TypeMethodDescriptionT[]
This returns an array of validEnum
values.This will attempt to get the configured value as a constant of the desiredEnum
.protected String
This is an error message which should provide further context on what values are allowed.boolean
validateInput
(String input) This method checks if a given input would be valid as a value for thisItemSetting
.
-
Constructor Details
-
EnumSetting
@ParametersAreNonnullByDefault public EnumSetting(SlimefunItem item, String key, Class<T> enumClass, T defaultValue)
-
-
Method Details
-
getErrorMessage
Description copied from class:ItemSetting
This is an error message which should provide further context on what values are allowed.- Overrides:
getErrorMessage
in classItemSetting<String>
- Returns:
- An error message which is displayed when this
ItemSetting
is misconfigured.
-
getAllowedValues
This returns an array of validEnum
values. This method may be overridden to further limit the allowed values.- Returns:
- An array of allowed
Enum
constants
-
getAsEnumConstant
This will attempt to get the configured value as a constant of the desiredEnum
.- Returns:
- The value as an
Enum
constant
-
validateInput
Description copied from class:ItemSetting
This method checks if a given input would be valid as a value for thisItemSetting
. You can override this method to implement your own checks.- Overrides:
validateInput
in classItemSetting<String>
- Parameters:
input
- The input value to validate- Returns:
- Whether the given input was valid
-