From 7007feac5ab809d725119676040aa01e9cc2275c Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Tue, 6 Aug 2024 13:23:03 +0200 Subject: [PATCH] It is fixed now --- gradle.properties | 2 +- src/main/java/ct/server/database/PlayerTable.java | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index c2ae994..5a9a9fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.21+build.9 loader_version=0.15.11 # Mod Properties -mod_version=1.4.2 +mod_version=1.4.3 maven_group=ct archives_base_name=ct-server diff --git a/src/main/java/ct/server/database/PlayerTable.java b/src/main/java/ct/server/database/PlayerTable.java index 79d2e5c..d6d33f0 100644 --- a/src/main/java/ct/server/database/PlayerTable.java +++ b/src/main/java/ct/server/database/PlayerTable.java @@ -10,12 +10,15 @@ import java.util.HashMap; import java.util.UUID; public class PlayerTable { - private final DatabaseClient database = CtServer.getInstance().database(); private final HashMap cache = new HashMap<>(); + private DatabaseClient database() { + return CtServer.getInstance().database(); + } + public void ensureDatabaseCreated() { try { - var conn = database.connection(); + var conn = database().connection(); var stmt = conn.prepareStatement( "CREATE TABLE IF NOT EXISTS players (" + @@ -46,7 +49,7 @@ public class PlayerTable { } try { - var conn = database.connection(); + var conn = database().connection(); var stmt = conn.prepareStatement("SELECT * FROM players WHERE uuid = ?;"); stmt.setObject(1, uuid); @@ -75,7 +78,7 @@ public class PlayerTable { public boolean deletePlayerData(UUID uuid) { try { - var conn = database.connection(); + var conn = database().connection(); var stmt = conn.prepareStatement("DELETE FROM players WHERE uuid = ?;"); stmt.setObject(1, uuid); @@ -93,7 +96,7 @@ public class PlayerTable { public boolean updatePlayerData(PlayerData playerData) { deletePlayerData(playerData.uuid()); try { - var conn = database.connection(); + var conn = database().connection(); var stmt = conn.prepareStatement("INSERT INTO players(uuid, firstJoined, lastKnownName, discordId, isBot, isAlt) VALUES (?,?,?,?,?,?);"); stmt.setObject(1, playerData.uuid());