From de1833607c0643534d68c520de4fa15943017846 Mon Sep 17 00:00:00 2001 From: Dico Date: Mon, 6 Aug 2018 02:57:46 +0100 Subject: More todo things --- src/main/kotlin/io/dico/parcels2/PlayerProfile.kt | 4 ++++ src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt | 2 +- todo.md | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/io/dico/parcels2/PlayerProfile.kt b/src/main/kotlin/io/dico/parcels2/PlayerProfile.kt index 2e543dc..b096665 100644 --- a/src/main/kotlin/io/dico/parcels2/PlayerProfile.kt +++ b/src/main/kotlin/io/dico/parcels2/PlayerProfile.kt @@ -16,6 +16,7 @@ import java.util.UUID interface PlayerProfile { val uuid: UUID? get() = null val name: String? + val nameOrBukkitName: String? val notNullName: String val isStar: Boolean get() = false val exists: Boolean get() = this is RealImpl @@ -75,6 +76,8 @@ interface PlayerProfile { interface Real : PlayerProfile { override val uuid: UUID + override val nameOrBukkitName: String? + get() = name ?: Bukkit.getOfflinePlayer(uuid).takeIf { it.isValid }?.name override val notNullName: String get() = name ?: getPlayerNameOrDefault(uuid) @@ -121,6 +124,7 @@ interface PlayerProfile { abstract class NameOnly(override val name: String) : BaseImpl() { override val notNullName get() = name + override val nameOrBukkitName: String get() = name override fun matches(player: OfflinePlayer, allowNameMatch: Boolean): Boolean { return allowNameMatch && player.name == name diff --git a/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt b/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt index 45386e8..9b383af 100644 --- a/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt +++ b/src/main/kotlin/io/dico/parcels2/storage/exposed/IdTables.kt @@ -93,7 +93,7 @@ object ProfilesT : IdTransactionsTable("parcel_profile val uuid = binary("uuid", 16).nullable() val name = varchar("name", 32).nullable() - // MySQL dialect MUST permit multiple null values for this to work + // MySQL dialect MUST permit multiple null values for this to work. Server SQL does not allow this. That dialect is shit anyway. val uuid_constraint = uniqueIndexR("uuid_constraint", uuid) val index_pair = uniqueIndexR("index_pair", uuid, name) diff --git a/todo.md b/todo.md index 959c628..a3d98ed 100644 --- a/todo.md +++ b/todo.md @@ -77,4 +77,6 @@ Use an atomic GET OR INSERT query so that parallel execution doesn't cause probl Implement a container that doesn't require loading all parcel data on startup (Complex). +Update player profiles in the database on join to account for name changes. + -- cgit v1.2.3