It is fixed now
This commit is contained in:
parent
17e839c1a8
commit
7007feac5a
2 changed files with 9 additions and 6 deletions
|
@ -9,7 +9,7 @@ yarn_mappings=1.21+build.9
|
||||||
loader_version=0.15.11
|
loader_version=0.15.11
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.4.2
|
mod_version=1.4.3
|
||||||
maven_group=ct
|
maven_group=ct
|
||||||
archives_base_name=ct-server
|
archives_base_name=ct-server
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,15 @@ import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerTable {
|
public class PlayerTable {
|
||||||
private final DatabaseClient database = CtServer.getInstance().database();
|
|
||||||
private final HashMap<UUID, PlayerData> cache = new HashMap<>();
|
private final HashMap<UUID, PlayerData> cache = new HashMap<>();
|
||||||
|
|
||||||
|
private DatabaseClient database() {
|
||||||
|
return CtServer.getInstance().database();
|
||||||
|
}
|
||||||
|
|
||||||
public void ensureDatabaseCreated() {
|
public void ensureDatabaseCreated() {
|
||||||
try {
|
try {
|
||||||
var conn = database.connection();
|
var conn = database().connection();
|
||||||
|
|
||||||
var stmt = conn.prepareStatement(
|
var stmt = conn.prepareStatement(
|
||||||
"CREATE TABLE IF NOT EXISTS players (" +
|
"CREATE TABLE IF NOT EXISTS players (" +
|
||||||
|
@ -46,7 +49,7 @@ public class PlayerTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var conn = database.connection();
|
var conn = database().connection();
|
||||||
|
|
||||||
var stmt = conn.prepareStatement("SELECT * FROM players WHERE uuid = ?;");
|
var stmt = conn.prepareStatement("SELECT * FROM players WHERE uuid = ?;");
|
||||||
stmt.setObject(1, uuid);
|
stmt.setObject(1, uuid);
|
||||||
|
@ -75,7 +78,7 @@ public class PlayerTable {
|
||||||
|
|
||||||
public boolean deletePlayerData(UUID uuid) {
|
public boolean deletePlayerData(UUID uuid) {
|
||||||
try {
|
try {
|
||||||
var conn = database.connection();
|
var conn = database().connection();
|
||||||
|
|
||||||
var stmt = conn.prepareStatement("DELETE FROM players WHERE uuid = ?;");
|
var stmt = conn.prepareStatement("DELETE FROM players WHERE uuid = ?;");
|
||||||
stmt.setObject(1, uuid);
|
stmt.setObject(1, uuid);
|
||||||
|
@ -93,7 +96,7 @@ public class PlayerTable {
|
||||||
public boolean updatePlayerData(PlayerData playerData) {
|
public boolean updatePlayerData(PlayerData playerData) {
|
||||||
deletePlayerData(playerData.uuid());
|
deletePlayerData(playerData.uuid());
|
||||||
try {
|
try {
|
||||||
var conn = database.connection();
|
var conn = database().connection();
|
||||||
|
|
||||||
var stmt = conn.prepareStatement("INSERT INTO players(uuid, firstJoined, lastKnownName, discordId, isBot, isAlt) VALUES (?,?,?,?,?,?);");
|
var stmt = conn.prepareStatement("INSERT INTO players(uuid, firstJoined, lastKnownName, discordId, isBot, isAlt) VALUES (?,?,?,?,?,?);");
|
||||||
stmt.setObject(1, playerData.uuid());
|
stmt.setObject(1, playerData.uuid());
|
||||||
|
|
Loading…
Reference in a new issue