Class UserPrefsManager

java.lang.Object
net.minheur.potoflux.settings.UserPrefsManager

public final class UserPrefsManager extends Object
This class is used to store and retrieve user preferences.
  • Method Details

    • getValueFor

      public static Object getValueFor(@NotNull @NotNull PreferencesTypes type, Object defaultValue, ResourceLocation id)
      Returns the actual value (or default if not set) for a given setting.
      Parameters:
      type - the PreferencesTypes of the setting
      defaultValue - of the setting, if no value is set
      id - the ressource location of the setting. Is where the setting will be written and red from.
      Returns:
      the value of the setting.
      Throws:
      ClassCastException - if the default value is not the correct type for the type specified
    • getValueFor

      public static Object getValueFor(@NotNull @NotNull ISettingType<?> type, ResourceLocation id)
      Returns the actual value for a given setting, from the ISettingType
      Parameters:
      type - of the setting, used to get PreferencesTypes and default
      id - the resource location used as key
      Returns:
      the value of the setting.
      Throws:
      ClassCastException - if the default value is not the correct type for the type specified
    • getValueFor

      public static Object getValueFor(@NotNull @NotNull Setting setting)
      Returns the actual value (or default if not set) for a given setting.
      Parameters:
      setting - used to get ISettingType, id and default
      Returns:
      the value of the setting
      Throws:
      ClassCastException - if the default value is not the correct type for the type specified
    • setValueFor

      public static void setValueFor(ResourceLocation id, PreferencesTypes type, Object value)
      Sets a setting value
      Parameters:
      id - resource location used as key
      type - type of value, used to put the right type of setting
      value - of the setting, to be set
    • showReload

      public static void showReload()
      Shows a popup to ask the user to restart the app