Class PreferencesManager

java.lang.Object
net.joseplay.allianceutils.api.preferences.data.PreferencesManager

public class PreferencesManager extends Object
Central registry for managing preferences and their categories.

This class stores preferences grouped by PreferencesCategory and provides static access methods for registration and retrieval.

Notes:

  • All data is stored statically (global state)
  • Thread-safety is partially handled via ConcurrentHashMap
  • Lists themselves are NOT thread-safe
  • Constructor Details

    • PreferencesManager

      public PreferencesManager()
  • Method Details

    • addCategory

      public static void addCategory(@NotNull @NotNull PreferencesCategory category)
      Registers a category.
      Parameters:
      category - category to register
    • removeCategory

      public static void removeCategory(PreferencesCategory category)
      Removes a category and its preferences.
      Parameters:
      category - category to remove
    • getCategory

      public static PreferencesCategory getCategory(@NotNull @NotNull String id)
      Retrieves a category by ID.
      Parameters:
      id - category identifier
      Returns:
      category or null if not found
    • addPreference

      public static void addPreference(@NotNull @NotNull Preference preference, @NotNull @NotNull PreferencesCategory category)
      Registers a preference under a category.
      Parameters:
      preference - preference instance
      category - category to associate
    • addPreference

      public static void addPreference(@NotNull @NotNull PreferencePermission preference, @NotNull @NotNull PreferencesCategory category)
      Registers a permission-based preference under a category.
    • removePreference

      public static void removePreference(PreferencesCategory category, Preference preference)
      Removes a preference from a specific category.
    • removePreference

      public static void removePreference(Preference preference)
      Removes a preference from all categories.
    • getPreferences

      public static List<Preference> getPreferences(PreferencesCategory category)
      Returns the preferences of a category.

      WARNING: returned list is mutable and not thread-safe.

    • getPreferences

      public static Map<PreferencesCategory,List<Preference>> getPreferences()
      Returns all preferences grouped by category.
      Returns:
      unmodifiable map view