Class PreferencesManager
java.lang.Object
net.joseplay.allianceutils.api.preferences.data.PreferencesManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCategory(@NotNull PreferencesCategory category) Registers a category.static voidaddPreference(@NotNull PreferencePermission preference, @NotNull PreferencesCategory category) Registers a permission-based preference under a category.static voidaddPreference(@NotNull Preference preference, @NotNull PreferencesCategory category) Registers a preference under a category.static PreferencesCategorygetCategory(@NotNull String id) Retrieves a category by ID.static Map<PreferencesCategory, List<Preference>> Returns all preferences grouped by category.static List<Preference> getPreferences(PreferencesCategory category) Returns the preferences of a category.static voidremoveCategory(PreferencesCategory category) Removes a category and its preferences.static voidremovePreference(Preference preference) Removes a preference from all categories.static voidremovePreference(PreferencesCategory category, Preference preference) Removes a preference from a specific category.
-
Constructor Details
-
PreferencesManager
public PreferencesManager()
-
-
Method Details
-
addCategory
Registers a category.- Parameters:
category- category to register
-
removeCategory
Removes a category and its preferences.- Parameters:
category- category to remove
-
getCategory
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 instancecategory- 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
Removes a preference from a specific category. -
removePreference
Removes a preference from all categories. -
getPreferences
Returns the preferences of a category.WARNING: returned list is mutable and not thread-safe.
-
getPreferences
Returns all preferences grouped by category.- Returns:
- unmodifiable map view
-