get Plugin Player Pref
Retrieves a plugin-specific preference with type safety and default value support.
This method provides type-safe access to plugin preferences with automatic type checking and default value fallback. It's the preferred method for retrieving preferences when you know the expected type.
Type Safety: The method uses Class.isInstance() to verify that the stored value matches the expected type before casting, preventing ClassCastException.
Usage Examples:
val enabled = playerData.getPluginPlayerPref("MyPlugin", "enabled", Boolean::class.java, false)
val maxLevel = playerData.getPluginPlayerPref("Skills", "max_level", Int::class.java, 100)
val playerClass = playerData.getPluginPlayerPref("RPG", "class", String::class.java, "warrior")Return Logic:
Returns the stored value if plugin exists, key exists, and type matches
Returns defaultValue if plugin doesn't exist
Returns defaultValue if key doesn't exist in plugin preferences
Returns defaultValue if stored value type doesn't match expected type
Return
The preference value cast to type T, or defaultValue if not available/valid
Parameters
The expected type of the preference value
The plugin identifier/namespace
The specific preference key within the plugin namespace
The Class object representing the expected type T
The value to return if preference not found or type mismatch
See also
Retrieves a plugin-specific preference without type checking.
This method provides raw access to plugin preferences without type safety. Use this when you need to inspect the stored value or when the type is unknown. For type-safe access, use the overloaded version with type parameter.
Usage Examples:
val rawValue = playerData.getPluginPlayerPref("MyPlugin", "complex_data")
val exists = playerData.getPluginPlayerPref("Settings", "theme") != nullReturn Behavior:
Returns the stored value (of type Any) if found
Returns null if plugin namespace doesn't exist
Returns null if preference key doesn't exist
Calling code must handle type casting manually
Return
The preference value as Any, or null if not found
Parameters
The plugin identifier/namespace
The specific preference key within the plugin namespace