JdbcLocationRepository

class JdbcLocationRepository(dataSource: DataSource, logger: Logger, poolCloseable: AutoCloseable? = null) : LocationRepository

Database-backed LocationRepository that works for SQLite and MySQL/MariaDB — the SQL is deliberately dialect-agnostic (CREATE TABLE IF NOT EXISTS, INT/VARCHAR, a composite primary key). It talks to a JDBC DataSource (a HikariCP pool in production) and touches only java.sql / javax.sql, so nothing here needs to be shaded into the plugin jar.

Writes are per-owner and transactional: saveOwners deletes and re-inserts each given owner's rows inside one transaction.

Constructors

Link copied to clipboard
constructor(dataSource: DataSource, logger: Logger, poolCloseable: AutoCloseable? = null)

Functions

Link copied to clipboard
open override fun close()

Releases any resources (e.g. a connection pool). No-op for file backends.

Link copied to clipboard
open override fun loadAll(): List<DespawnLocation>

Loads every stored location. Malformed entries are skipped, not fatal.

Link copied to clipboard
open override fun saveOwners(owners: Collection<UUID>, locationsOf: (UUID) -> Collection<DespawnLocation>)

Persists exactly the owners in owners, sourcing each owner's current locations from locationsOf. An owner with no locations is removed from storage. This is the incremental write path — callers pass only the owners that changed.