Auto-create account in both MySQL and PG

This commit is contained in:
P0nk
2024-09-26 07:59:27 +02:00
parent bf9c02bc16
commit 647e67f6e8
13 changed files with 158 additions and 49 deletions

View File

@@ -7,7 +7,9 @@ import constants.id.ItemId;
import constants.id.MapId;
import database.PgDatabaseConnection;
import database.character.CharacterRepository;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CharacterCreator {
private final PgDatabaseConnection connection;
private final CharacterRepository chrRepository;
@@ -20,9 +22,13 @@ public class CharacterCreator {
public boolean createNew(NewCharacterSpec spec, int accountId, int worldId) {
CharacterStats stats = getStarterStats(spec, accountId, worldId);
connection.getHandle().useTransaction(h -> {
// chrRepository.insert(h, stats); // TODO: account needs to exist first
});
try {
connection.getHandle().useTransaction(h -> {
chrRepository.insert(h, stats);
});
} catch (Exception e) {
log.warn("Failed to create new character in PG", e);
}
Item guide = getStarterGuide(spec.type());
// TODO, save:
// - character