fallback to hex string when a player UUID has no corresponding filename

This commit is contained in:
Kae 2023-11-24 20:35:21 +11:00
parent 81198f091c
commit de53f8c7d7
2 changed files with 6 additions and 4 deletions

View File

@ -272,11 +272,13 @@ Json PlayerStorage::getMetadata(String const& key) {
return m_metadata.value(key); return m_metadata.value(key);
} }
String const& PlayerStorage::uuidFileName(Uuid const& uuid) const { String const& PlayerStorage::uuidFileName(Uuid const& uuid) {
if (auto fileName = m_playerFileNames.rightPtr(uuid)) if (auto fileName = m_playerFileNames.rightPtr(uuid))
return *fileName; return *fileName;
else else {
throw PlayerException::format("No matching filename for uuid '{}'", uuid.hex()); m_playerFileNames.insert(uuid, uuid.hex());
return *m_playerFileNames.rightPtr(uuid);
}
} }
void PlayerStorage::writeMetadata() { void PlayerStorage::writeMetadata() {

View File

@ -44,7 +44,7 @@ public:
Json getMetadata(String const& key); Json getMetadata(String const& key);
private: private:
String const& uuidFileName(Uuid const& uuid) const; String const& uuidFileName(Uuid const& uuid);
void writeMetadata(); void writeMetadata();
mutable RecursiveMutex m_mutex; mutable RecursiveMutex m_mutex;