removed forcetp from chatuser

This commit is contained in:
Teriuihi 2021-06-07 15:41:05 +02:00
parent 3266cc05a3
commit cc6a9a5a46
2 changed files with 7 additions and 25 deletions

View File

@ -22,7 +22,7 @@ public class Queries {
List<String> tables = new ArrayList<>(); List<String> tables = new ArrayList<>();
tables.add("CREATE TABLE IF NOT EXISTS ignored_users (`uuid` VARCHAR(36) NOT NULL, `ignored_uuid` VARCHAR(36) NOT NULL, PRIMARY KEY (`uuid`, `ignored_uuid`))"); tables.add("CREATE TABLE IF NOT EXISTS ignored_users (`uuid` VARCHAR(36) NOT NULL, `ignored_uuid` VARCHAR(36) NOT NULL, PRIMARY KEY (`uuid`, `ignored_uuid`))");
tables.add("CREATE TABLE IF NOT EXISTS parties (`id` INT NOT NULL AUTO_INCREMENT, `owner_uuid` VARCHAR(36) NOT NULL, `party_name` VARCHAR(36) NOT NULL, `password` VARCHAR(36), PRIMARY KEY (`id`))"); tables.add("CREATE TABLE IF NOT EXISTS parties (`id` INT NOT NULL AUTO_INCREMENT, `owner_uuid` VARCHAR(36) NOT NULL, `party_name` VARCHAR(36) NOT NULL, `password` VARCHAR(36), PRIMARY KEY (`id`))");
tables.add("CREATE TABLE IF NOT EXISTS chat_users (`uuid` VARCHAR(36) NOT NULL, `party_id` INT NOT NULL, `toggled_chat` BIT(1) DEFAULT b'0', `force_tp` BIT(1) DEFAULT b'1', `toggled_gc` BIT(1) DEFAULT b'0', PRIMARY KEY (`uuid`))"); tables.add("CREATE TABLE IF NOT EXISTS chat_users (`uuid` VARCHAR(36) NOT NULL, `party_id` INT NOT NULL, `toggled_chat` BIT(1) DEFAULT b'0', `toggled_gc` BIT(1) DEFAULT b'0', PRIMARY KEY (`uuid`))");
try { try {
Connection connection = DatabaseConnection.getConnection(); Connection connection = DatabaseConnection.getConnection();
@ -262,7 +262,6 @@ public class Queries {
UUID uuid = UUID.fromString(resultSet.getString("uuid")); UUID uuid = UUID.fromString(resultSet.getString("uuid"));
int partyId = resultSet.getInt("party_id"); int partyId = resultSet.getInt("party_id");
boolean toggled_chat = resultSet.getInt("toggled_chat") == 1; boolean toggled_chat = resultSet.getInt("toggled_chat") == 1;
boolean force_tp = resultSet.getInt("force_tp") == 1;
boolean toggle_Gc = resultSet.getInt("toggled_gc") == 1; boolean toggle_Gc = resultSet.getInt("toggled_gc") == 1;
if (partyId == 0) { if (partyId == 0) {
@ -278,7 +277,7 @@ public class Queries {
continue; continue;
} }
party.addUser(new ChatUser(uuid, partyId, toggled_chat, force_tp, toggle_Gc)); party.addUser(new ChatUser(uuid, partyId, toggled_chat, toggle_Gc));
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -299,10 +298,9 @@ public class Queries {
UUID uuid = UUID.fromString(resultSet.getString("uuid")); UUID uuid = UUID.fromString(resultSet.getString("uuid"));
int partyId = resultSet.getInt("party_id"); int partyId = resultSet.getInt("party_id");
boolean toggled_chat = resultSet.getInt("toggled_chat") == 1; boolean toggled_chat = resultSet.getInt("toggled_chat") == 1;
boolean force_tp = resultSet.getInt("force_tp") == 1;
boolean toggle_Gc = resultSet.getInt("toggled_gc") == 1; boolean toggle_Gc = resultSet.getInt("toggled_gc") == 1;
// could do a constructor for chatuser to accept the record? // could do a constructor for chatuser to accept the record?
ChatUserManager.addUser(new ChatUser(uuid, partyId, toggled_chat, force_tp, toggle_Gc)); ChatUserManager.addUser(new ChatUser(uuid, partyId, toggled_chat, toggle_Gc));
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -311,7 +309,7 @@ public class Queries {
} }
public static void addUser(ChatUser user) { public static void addUser(ChatUser user) {
String query = "INSERT INTO chat_users (uuid, party_id, toggled_chat, force_tp, toggled_gc) VALUES (?, ?, ?, ?, ?)"; String query = "INSERT INTO chat_users (uuid, party_id, toggled_chat, toggled_gc) VALUES (?, ?, ?, ?)";
try { try {
Connection connection = DatabaseConnection.getConnection(); Connection connection = DatabaseConnection.getConnection();
@ -320,7 +318,6 @@ public class Queries {
statement.setString(1, user.getUuid().toString()); statement.setString(1, user.getUuid().toString());
statement.setInt(2, user.getPartyId()); statement.setInt(2, user.getPartyId());
statement.setInt(3, user.toggledPartyChat() ? 1 : 0); statement.setInt(3, user.toggledPartyChat() ? 1 : 0);
statement.setInt(4, user.ForceTp() ? 1 : 0);
statement.setInt(5, user.isGcOn() ? 1 : 0); statement.setInt(5, user.isGcOn() ? 1 : 0);
statement.execute(); statement.execute();
@ -333,10 +330,6 @@ public class Queries {
setBitWhereId("UPDATE chat_users set toggled_chat = ? WHERE uuid = ?", toggledChat, uuid); setBitWhereId("UPDATE chat_users set toggled_chat = ? WHERE uuid = ?", toggledChat, uuid);
} }
public static void setForceTpState(boolean forceTp, UUID uuid) {
setBitWhereId("UPDATE chat_users set force_tp = ? WHERE uuid = ?", forceTp, uuid);
}
private static void setBitWhereId(String query, boolean bool, UUID uuid) { private static void setBitWhereId(String query, boolean bool, UUID uuid) {
try { try {
Connection connection = DatabaseConnection.getConnection(); Connection connection = DatabaseConnection.getConnection();

View File

@ -10,7 +10,6 @@ public class ChatUser {
private final UUID uuid; // player uuid private final UUID uuid; // player uuid
private final int partyId; // the party they are in private final int partyId; // the party they are in
private boolean toggledPartyChat; // should chat messages instantly go to party chat when added, idk if this should be saved private boolean toggledPartyChat; // should chat messages instantly go to party chat when added, idk if this should be saved
private boolean forceTp; // idk ask teri
private String displayName; // the nickname, doesn't need to be saved with the chatuser object, could be saved but we can get it from the nicknamesview private String displayName; // the nickname, doesn't need to be saved with the chatuser object, could be saved but we can get it from the nicknamesview
private String prefix; // doesn't need saving, we get this from luckperms private String prefix; // doesn't need saving, we get this from luckperms
private String staffPrefix; // doesn't need saving, we get this from luckperms private String staffPrefix; // doesn't need saving, we get this from luckperms
@ -23,11 +22,10 @@ public class ChatUser {
private LinkedList<UUID> ignoredPlayers; // a list of UUID, a new table non unique, where one is is the player select * from ignores where ignoredby = thisplayer? where the result is the uuid of the player ignored by this player? private LinkedList<UUID> ignoredPlayers; // a list of UUID, a new table non unique, where one is is the player select * from ignores where ignoredby = thisplayer? where the result is the uuid of the player ignored by this player?
private LinkedList<UUID> ignoredBy; // a list of UUID, same table as above but select * from ignores where ignored = thisplayer? result should be the other user that ignored this player? private LinkedList<UUID> ignoredBy; // a list of UUID, same table as above but select * from ignores where ignored = thisplayer? result should be the other user that ignored this player?
public ChatUser(UUID uuid, int partyId, boolean toggled_chat, boolean force_tp, boolean toggle_Gc) { public ChatUser(UUID uuid, int partyId, boolean toggledChat, boolean toggleGc) {
this.uuid = uuid; this.uuid = uuid;
this.partyId = partyId; this.partyId = partyId;
this.toggledPartyChat = toggled_chat; this.toggledPartyChat = toggledChat;
this.forceTp = force_tp;
displayName = Queries.getNickname(uuid); displayName = Queries.getNickname(uuid);
if (displayName == null) { if (displayName == null) {
@ -39,7 +37,7 @@ public class ChatUser {
prefixAll = Utility.getPrefix(uuid, false); prefixAll = Utility.getPrefix(uuid, false);
toggleGc = toggle_Gc; this.toggleGc = toggleGc;
replyTarget = null; replyTarget = null;
gcCooldown = System.currentTimeMillis(); // players can't use gc for 30 seconds after logging in if we use this? gcCooldown = System.currentTimeMillis(); // players can't use gc for 30 seconds after logging in if we use this?
mails = new LinkedList<>(); // todo load mails mails = new LinkedList<>(); // todo load mails
@ -64,15 +62,6 @@ public class ChatUser {
Queries.setPartyChatState(toggledPartyChat, uuid); //TODO: Async pls - no CompleteableFuture<>! Queries.setPartyChatState(toggledPartyChat, uuid); //TODO: Async pls - no CompleteableFuture<>!
} }
public boolean ForceTp() {
return forceTp;
}
public void toggleForceTp() {
forceTp = !forceTp;
Queries.setForceTpState(forceTp, uuid); //TODO: Async pls - no CompleteableFuture<>!
}
public String getDisplayName() { public String getDisplayName() {
return displayName; return displayName;
} }