From 98b0ca449ab647f165ec8ce73004b5323328e728 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Wed, 7 Aug 2024 12:12:25 +0200 Subject: [PATCH] Add pronouns in PlayerData --- gradle.properties | 4 +-- src/main/java/ct/server/CtServer.java | 26 +++++++++---------- .../java/ct/server/database/PlayerData.java | 11 +++++++- .../java/ct/server/database/PlayerTable.java | 7 +++-- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5a9a9fb..0cc6377 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,12 +9,12 @@ yarn_mappings=1.21+build.9 loader_version=0.15.11 # Mod Properties -mod_version=1.4.3 +mod_version=1.5.0 maven_group=ct archives_base_name=ct-server # Dependencies -fabric_version=0.100.8+1.21 +fabric_version=0.101.2+1.21 owo_version=0.12.11+1.21 diff --git a/src/main/java/ct/server/CtServer.java b/src/main/java/ct/server/CtServer.java index 03e7e4b..3401975 100644 --- a/src/main/java/ct/server/CtServer.java +++ b/src/main/java/ct/server/CtServer.java @@ -52,6 +52,18 @@ public class CtServer implements ModInitializer { return playerTable; } + public static float getTPS() { + return currentTps; + } + + public static float getMSPT() { + return currentMspt; + } + + public static int getPlayerCount() { + return currentPlayerCount; + } + public CtServer() { INSTANCE = this; } @@ -96,7 +108,7 @@ public class CtServer implements ModInitializer { PlayerWelcome.PLAYER_WELCOME.invoker().playerWelcome(player, playerData, server); // TODO: make it customizable via config - broadcastMessage(server, Text.literal("Welcome " + player.getName().getString() + " to the server!").formatted(Formatting.GREEN)); + broadcastMessage(server, Text.literal("Welcome " + player.getName().getString() + " to the server!").formatted(Formatting.LIGHT_PURPLE)); } else { if (!playerData.name().equals(player.getName().getString())) { playerData.name(player.getName().getString()); @@ -115,16 +127,4 @@ public class CtServer implements ModInitializer { player.sendMessage(message, false); } } - - public static float getTPS() { - return currentTps; - } - - public static float getMSPT() { - return currentMspt; - } - - public static int getPlayerCount() { - return currentPlayerCount; - } } \ No newline at end of file diff --git a/src/main/java/ct/server/database/PlayerData.java b/src/main/java/ct/server/database/PlayerData.java index c8f2ab5..1fc66e5 100644 --- a/src/main/java/ct/server/database/PlayerData.java +++ b/src/main/java/ct/server/database/PlayerData.java @@ -16,6 +16,9 @@ public class PlayerData { private boolean isBot = false; private boolean isAlt = false; + @Nullable + private String pronouns = null; + public PlayerData(UUID uuid) { this.uuid = uuid; } @@ -24,7 +27,6 @@ public class PlayerData { return uuid; } - public String name() { if (name == null) { return uuid.toString(); @@ -62,4 +64,11 @@ public class PlayerData { public void isAlt(boolean isAlt) { this.isAlt = isAlt; } + + public String pronouns() { + return pronouns; + } + public void pronouns(@Nullable String pronouns) { + this.pronouns = pronouns; + } } diff --git a/src/main/java/ct/server/database/PlayerTable.java b/src/main/java/ct/server/database/PlayerTable.java index d6d33f0..a242141 100644 --- a/src/main/java/ct/server/database/PlayerTable.java +++ b/src/main/java/ct/server/database/PlayerTable.java @@ -27,7 +27,8 @@ public class PlayerTable { "lastKnownName VARCHAR(16)," + "discordId VARCHAR," + "isBot BOOL DEFAULT FALSE," + - "isAlt BOOL DEFAULT FALSE" + + "isAlt BOOL DEFAULT FALSE," + + "pronouns VARCHAR DEFAULT NULL" + ");"); stmt.executeUpdate(); @@ -65,6 +66,7 @@ public class PlayerTable { playerData.discordId(set.getString("discordId")); playerData.isBot(set.getBoolean("isBot")); playerData.isAlt(set.getBoolean("isAlt")); + playerData.pronouns(set.getString("pronouns")); stmt.close(); @@ -98,7 +100,7 @@ public class PlayerTable { try { 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, pronouns) VALUES (?,?,?,?,?,?,?);"); stmt.setObject(1, playerData.uuid()); var timestamp = new Timestamp(playerData.firstJoinedDate().getTime()); stmt.setTimestamp(2, timestamp); @@ -106,6 +108,7 @@ public class PlayerTable { stmt.setString(4, playerData.discordId()); stmt.setBoolean(5, playerData.isBot()); stmt.setBoolean(6, playerData.isAlt()); + stmt.setString(7, playerData.pronouns()); stmt.execute(); stmt.close();