Add pronouns in PlayerData
This commit is contained in:
parent
417bdad061
commit
98b0ca449a
4 changed files with 30 additions and 18 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue