Recommendations
The recommendation is to always set your configurations with default values, only not in Entity models. The reason for that is that KotlinBukkitAPI will load your configuration and saves the loaded Model again, this makes the removed keys from the Configuration File be restore for the user always have to configurable, this could be change by updating the alwaysRestoreDefaults value to false.
The entity use case
Think about a Kit object that should ALWAYS have a name and a price. In this case, is not allowed to have a kit that does not have this properties and in this case should throw an error.
@Serialiable
data class Kit(
val name: String,
val price: Double,
@ContexualSerialization
val icon: MaterialData = Material.PAPER.asMaterialData(),
val items: List<String> = listOf()
)
@Serializable
data class TestConfig(
val kits: List<Kit>
)Last updated