diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/DataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/DataHandler.kt index 29019919..96416559 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/DataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/DataHandler.kt @@ -4,33 +4,35 @@ import com.willfp.eco.core.data.keys.KeyRegistry import com.willfp.eco.core.data.keys.PersistentDataKey import java.util.UUID -interface DataHandler { +abstract class DataHandler( + val type: HandlerType +) { /** * Read value from a key. */ - fun read(uuid: UUID, key: PersistentDataKey): T? + abstract fun read(uuid: UUID, key: PersistentDataKey): T? /** * Write value to a key. */ - fun write(uuid: UUID, key: PersistentDataKey, value: T) + abstract fun write(uuid: UUID, key: PersistentDataKey, value: T) /** * Save a set of keys for a given UUID. */ - fun saveKeysFor(uuid: UUID, keys: Set>) + abstract fun saveKeysFor(uuid: UUID, keys: Set>) // Everything below this are methods that are only needed for certain implementations. - fun save() { + open fun save() { } - fun categorize(key: PersistentDataKey<*>, category: KeyRegistry.KeyCategory) { + open fun categorize(key: PersistentDataKey<*>, category: KeyRegistry.KeyCategory) { } - fun initialize() { + open fun initialize() { } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MongoDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MongoDataHandler.kt index 0fdba910..2d4a2790 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MongoDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MongoDataHandler.kt @@ -21,7 +21,7 @@ import java.util.UUID class MongoDataHandler( plugin: EcoSpigotPlugin, private val handler: EcoProfileHandler -) : DataHandler { +) : DataHandler(HandlerType.MONGO) { private val client: CoroutineClient private val collection: CoroutineCollection diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MySQLDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MySQLDataHandler.kt index 2551ee4f..3166e9c1 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MySQLDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/MySQLDataHandler.kt @@ -57,7 +57,7 @@ the worst bodge I've shipped in production. class MySQLDataHandler( private val plugin: EcoSpigotPlugin, handler: EcoProfileHandler -) : DataHandler { +) : DataHandler(HandlerType.MYSQL) { private val playerHandler: ImplementedMySQLHandler private val serverHandler: ImplementedMySQLHandler diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/YamlDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/YamlDataHandler.kt index 29b030a4..37d528a6 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/YamlDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/storage/YamlDataHandler.kt @@ -11,7 +11,7 @@ import java.util.UUID class YamlDataHandler( plugin: EcoSpigotPlugin, private val handler: EcoProfileHandler -) : DataHandler { +) : DataHandler(HandlerType.YAML) { private val dataYml = plugin.dataYml override fun save() {