Add nickname retrieval support: implemented NicknameMapper for database queries, updated ChatService to return player names with optional nicknames, and extended /chat/player/{uuid}/name API endpoint.

This commit is contained in:
2026-08-01 19:57:55 +02:00
parent f9f05dcc88
commit 8931bdc30d
7 changed files with 108 additions and 9 deletions
@@ -144,6 +144,26 @@ public class Connection {
}).start();
}
public <T> T runQueryWithResult(QueryFunction<T> function) {
if (sqlSessionFactory == null) {
sqlSessionFactory = createSqlSessionFactory(settings, addMappers);
}
try (SqlSession session = sqlSessionFactory.openSession()) {
T result = function.apply(session);
session.commit();
return result;
} catch (Exception e) {
log.error("Failed to run query", e);
throw e;
}
}
@FunctionalInterface
public interface QueryFunction<T> {
T apply(SqlSession session);
}
private SqlSessionFactory createSqlSessionFactory(DatabaseSettings settings, AddMappers addMappers) {
try {
Configuration configuration = getConfiguration(settings);