Increment user XP on record creation

This commit is contained in:
floppydiskette 2024-09-05 03:37:21 +01:00
parent 1a196d9fb3
commit 3001616fcb
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
2 changed files with 4 additions and 2 deletions

View file

@ -64,7 +64,8 @@ public class LevellingListener extends ListenerAdapter {
} else { } else {
log.info("No record of user ID {} in server {}, creating blank record", user.getId(), guild.getId()); log.info("No record of user ID {} in server {}, creating blank record", user.getId(), guild.getId());
try { try {
DBUtils.createUserRecord(user.getIdLong(), guild.getIdLong(), user.getName()); UserRecord rec = DBUtils.createUserRecord(user.getIdLong(), guild.getIdLong(), user.getName());
LevellingUtils.incrementXp(log, rec);
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View file

@ -53,7 +53,7 @@ public class DBUtils {
* @param username The users username * @param username The users username
* @throws SQLException A SQL exception * @throws SQLException A SQL exception
*/ */
public static void createUserRecord(long user_id, long server_id, String username) throws SQLException { public static UserRecord createUserRecord(long user_id, long server_id, String username) throws SQLException {
Logger log = Logging.getLogger(); Logger log = Logging.getLogger();
log.info("Creating record (usr:{},srv:{},unm:{})", user_id, server_id, username); log.info("Creating record (usr:{},srv:{},unm:{})", user_id, server_id, username);
BasicDataSource dataSource = Doki.getDataSource(); BasicDataSource dataSource = Doki.getDataSource();
@ -67,6 +67,7 @@ public class DBUtils {
stmt.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now())); stmt.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now()));
stmt.execute(); stmt.execute();
log.info("Record (usr:{},srv:{},unm:{}) created!", user_id, server_id, username); log.info("Record (usr:{},srv:{},unm:{}) created!", user_id, server_id, username);
return new UserRecord(user_id, server_id, username);
} }
/** /**