From 3001616fcb6e12a608857726779bddcf03ab07f0 Mon Sep 17 00:00:00 2001 From: floppydiskette Date: Thu, 5 Sep 2024 03:37:21 +0100 Subject: [PATCH] Increment user XP on record creation --- src/main/java/net/hypr/doki/listeners/LevellingListener.java | 3 ++- src/main/java/net/hypr/doki/utils/DBUtils.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/hypr/doki/listeners/LevellingListener.java b/src/main/java/net/hypr/doki/listeners/LevellingListener.java index 2568523..330cb46 100644 --- a/src/main/java/net/hypr/doki/listeners/LevellingListener.java +++ b/src/main/java/net/hypr/doki/listeners/LevellingListener.java @@ -64,7 +64,8 @@ public class LevellingListener extends ListenerAdapter { } else { log.info("No record of user ID {} in server {}, creating blank record", user.getId(), guild.getId()); 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) { throw new RuntimeException(e); } diff --git a/src/main/java/net/hypr/doki/utils/DBUtils.java b/src/main/java/net/hypr/doki/utils/DBUtils.java index 7825b2a..48f04fc 100644 --- a/src/main/java/net/hypr/doki/utils/DBUtils.java +++ b/src/main/java/net/hypr/doki/utils/DBUtils.java @@ -53,7 +53,7 @@ public class DBUtils { * @param username The users username * @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(); log.info("Creating record (usr:{},srv:{},unm:{})", user_id, server_id, username); BasicDataSource dataSource = Doki.getDataSource(); @@ -67,6 +67,7 @@ public class DBUtils { stmt.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now())); stmt.execute(); log.info("Record (usr:{},srv:{},unm:{}) created!", user_id, server_id, username); + return new UserRecord(user_id, server_id, username); } /**