@@ -127,19 +127,20 @@ object DatabaseManager {
127127 suspend fun setupCache () {
128128 execute {
129129 Tables .ActionIdentifier .all().forEach {
130- cache.actionIdentifierKeys.put( it.identifier, it.id.value)
130+ cache.actionIdentifierKeys[ it.identifier] = it.id.value
131131 }
132132 Tables .World .all().forEach {
133- cache.worldIdentifierKeys.put( it.identifier, it.id.value)
133+ cache.worldIdentifierKeys[ it.identifier] = it.id.value
134134 }
135135 Tables .ObjectIdentifier .all().forEach {
136- cache.objectIdentifierKeys.put( it.identifier, it.id.value)
136+ cache.objectIdentifierKeys[ it.identifier] = it.id.value
137137 }
138138 Tables .Source .all().forEach {
139- cache.sourceKeys.put( it.name, it.id.value)
139+ cache.sourceKeys[ it.name] = it.id.value
140140 }
141141 Tables .Player .all().forEach {
142- cache.playerKeys.put(it.playerId, it.id.value)
142+ cache.playerKeys[it.playerId] = it.id.value
143+ cache.playernameKeys[it.playerName] = it.id.value
143144 }
144145 }
145146 }
@@ -220,6 +221,7 @@ object DatabaseManager {
220221 val objectIdentifierCache = DatabaseCacheService .objectIdentifierKeys.inverse()
221222 val sourceCache = DatabaseCacheService .sourceKeys.inverse()
222223 val playerCache = DatabaseCacheService .playerKeys.inverse()
224+ val playerNameCache = DatabaseCacheService .playernameKeys.inverse()
223225
224226 for (action in query) {
225227 val typeSupplier = ActionRegistry .getType(
@@ -241,7 +243,7 @@ object DatabaseManager {
241243 type.oldObjectState = action[Tables .Actions .oldBlockState]
242244 type.sourceName = sourceCache[action[Tables .Actions .sourceName].value]!!
243245 type.sourceProfile = action.getOrNull(Tables .Actions .sourcePlayer)?.let {
244- Ledger .server.services().nameToIdCache?.get( playerCache[it.value]!! )?.orElse( null )
246+ NameAndId ( playerCache[it.value]!! , playerNameCache[it.value] !! )
245247 }
246248 type.extraData = action[Tables .Actions .extraData]
247249 type.rolledBack = action[Tables .Actions .rolledBack]
@@ -494,11 +496,14 @@ object DatabaseManager {
494496 if (player != null ) {
495497 player.lastJoin = Instant .now()
496498 player.playerName = name
499+ cache.playernameKeys[name] = player.id.value
497500 } else {
498- Tables .Player .new {
501+ val entity = Tables .Player .new {
499502 this .playerId = uuid
500503 this .playerName = name
501504 }
505+ cache.playerKeys[uuid] = entity.id.value
506+ cache.playernameKeys[name] = entity.id.value
502507 }
503508 }
504509
0 commit comments