diff --git a/build.gradle.kts b/build.gradle.kts index eaaf69d..b8e823d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "pl.syntaxdevteam" -version = "1.0.0" +version = "1.0.0-profile.1" description = "Lightweight and versatile player plot protection plugin" repositories { diff --git a/docs/profile-details.md b/docs/profile-details.md new file mode 100644 index 0000000..d103fbf --- /dev/null +++ b/docs/profile-details.md @@ -0,0 +1,5 @@ +# Owner profile read API + +Read-only persisted snapshots for MiniPortalPlayerProfile 0.3.0. Existing snapshot constructors and existing API methods remain unchanged. New optional owner-list method provides composed detailed snapshots. No entity/chunk loading, teleport, database writes or simulation updates. + +getOwnedPlotProfiles(UUID) uses the existing plot cache and owner filter. PlotProfileSnapshot wraps the original plot and nullable configured teleport block. TP X/Z are integer block coordinates (in-game destination uses +0.5). It is not a safe destination guarantee: the normal teleport flow revalidates blocks and can select a fallback. A missing configured point must not be replaced with a fabricated TP. diff --git a/src/main/kotlin/pl/syntaxdevteam/plotsx/api/PlotsXApi.kt b/src/main/kotlin/pl/syntaxdevteam/plotsx/api/PlotsXApi.kt index 0938e8f..36fa41d 100644 --- a/src/main/kotlin/pl/syntaxdevteam/plotsx/api/PlotsXApi.kt +++ b/src/main/kotlin/pl/syntaxdevteam/plotsx/api/PlotsXApi.kt @@ -16,6 +16,7 @@ interface PlotsXApi { fun getPlot(id: Int): PlotSnapshot? fun getPlotAt(world: String, blockX: Int, blockZ: Int): PlotSnapshot? fun getPlots(): List + fun getOwnedPlotProfiles(owner: UUID): List fun getOwnedPlots(owner: UUID): List fun getAccessiblePlots(player: UUID): List fun getMembers(plotId: Int): List @@ -154,3 +155,7 @@ data class PlotRegionSnapshot(val x: Int, val z: Int, val radius: Int) { fun contains(x: Int, z: Int): Boolean = kotlin.math.abs(x.toLong() - this.x) <= radius && kotlin.math.abs(z.toLong() - this.z) <= radius } + +/** Configured teleport block, not a promise that it is currently safe. No chunk loads. */ +data class PlotProfileSnapshot(val plot: PlotSnapshot, val teleport: PlotTeleportSnapshot?) +data class PlotTeleportSnapshot(val x: Int, val y: Int, val z: Int) diff --git a/src/main/kotlin/pl/syntaxdevteam/plotsx/api/internal/DefaultPlotsXApi.kt b/src/main/kotlin/pl/syntaxdevteam/plotsx/api/internal/DefaultPlotsXApi.kt index 94a78ac..7e9bed8 100644 --- a/src/main/kotlin/pl/syntaxdevteam/plotsx/api/internal/DefaultPlotsXApi.kt +++ b/src/main/kotlin/pl/syntaxdevteam/plotsx/api/internal/DefaultPlotsXApi.kt @@ -37,6 +37,12 @@ internal class DefaultPlotsXApi(private val plugin: PlotsX) : PlotsXApi, Listene return plugin.cacheManager.getPlotAt(world, blockX, blockZ)?.snapshot() } override fun getPlots(): List { ready(); return immutable(plugin.cacheManager.getCachedPlots().map { it.snapshot() }) } + override fun getOwnedPlotProfiles(owner: UUID): List { + ready() + return immutable(plugin.cacheManager.getCachedPlots().filter { it.ownerUuid == owner }.map { + PlotProfileSnapshot(it.snapshot(), it.teleportSpawn?.let { spawn -> PlotTeleportSnapshot(spawn.x, spawn.y, spawn.z) }) + }) + } override fun getOwnedPlots(owner: UUID) = immutable(getPlots().filter { it.owner == owner }) override fun getAccessiblePlots(player: UUID) = immutable(getPlots().filter { it.owner == player || isMember(it.id, player) }) override fun getMembers(plotId: Int): List { diff --git a/src/main/kotlin/pl/syntaxdevteam/plotsx/databases/DatabaseHandler.kt b/src/main/kotlin/pl/syntaxdevteam/plotsx/databases/DatabaseHandler.kt index 9c6fdd5..db7ef1b 100644 --- a/src/main/kotlin/pl/syntaxdevteam/plotsx/databases/DatabaseHandler.kt +++ b/src/main/kotlin/pl/syntaxdevteam/plotsx/databases/DatabaseHandler.kt @@ -108,7 +108,7 @@ class DatabaseHandler(private val plugin: PlotsX) { username = user this.password = password } - DatabaseType.SQL_SERVER -> error("SQL Server schema support is not enabled in PlotsX") + else -> error("Database dialect $type is not supported by PlotsX") } pool { poolName = "PlotsX-SyntaxDB"