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 - The Enum type

public class EnumSetting<T extends Enum<T>> extends ItemSetting<String>
This variation of ItemSetting allows you to allow Enum constants to be used for ItemSetting validation.
Author:
TheBusyBiscuit
See Also:
  • Constructor Details

    • EnumSetting

      @ParametersAreNonnullByDefault public EnumSetting(SlimefunItem item, String key, Class<T> enumClass, T defaultValue)
  • Method Details

    • getErrorMessage

      @Nonnull protected String getErrorMessage()
      Description copied from class: ItemSetting
      This is an error message which should provide further context on what values are allowed.
      Overrides:
      getErrorMessage in class ItemSetting<String>
      Returns:
      An error message which is displayed when this ItemSetting is misconfigured.
    • getAllowedValues

      @Nonnull public T[] getAllowedValues()
      This returns an array of valid Enum values. This method may be overridden to further limit the allowed values.
      Returns:
      An array of allowed Enum constants
    • getAsEnumConstant

      @Nonnull public T getAsEnumConstant()
      This will attempt to get the configured value as a constant of the desired Enum.
      Returns:
      The value as an Enum constant
    • validateInput

      public boolean validateInput(String input)
      Description copied from class: ItemSetting
      This method checks if a given input would be valid as a value for this ItemSetting. You can override this method to implement your own checks.
      Overrides:
      validateInput in class ItemSetting<String>
      Parameters:
      input - The input value to validate
      Returns:
      Whether the given input was valid