mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
The delete command also deletes records in the position_data table. (#492)
* The delete command also deletes records in the position_data table. * fix typos * Optimize SQL statements, add delete respawn_position
This commit is contained in:
1 parent
f7c09170aa
commit
f8218d78a2
3 files changed
+50
-14
No files matched your search
@@ -294,13 +294,24 @@ public class H2Database extends Database {
|
||||
@Override
|
||||
public void deleteUserData(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""))) {
|
||||
// Delete Position
|
||||
PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `id`
|
||||
IN ((SELECT `last_position` FROM `%players_table%` WHERE `uuid` = ?),
|
||||
(SELECT `offline_position` FROM `%players_table%` WHERE `uuid` = ?),
|
||||
(SELECT `respawn_position` FROM `%players_table%` WHERE `uuid` = ?));"""));
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.setString(3, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""));
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete a player from the database", e);
|
||||
}
|
||||
|
||||
@@ -332,13 +332,24 @@ public class MySqlDatabase extends Database {
|
||||
@Override
|
||||
public void deleteUserData(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""))) {
|
||||
// Delete Position
|
||||
PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `id`
|
||||
IN ((SELECT `last_position` FROM `%players_table%` WHERE `uuid` = ?),
|
||||
(SELECT `offline_position` FROM `%players_table%` WHERE `uuid` = ?),
|
||||
(SELECT `respawn_position` FROM `%players_table%` WHERE `uuid` = ?));"""));
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.setString(3, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""));
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete a player from the database", e);
|
||||
}
|
||||
|
||||
@@ -323,11 +323,25 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
@Override
|
||||
public void deleteUserData(@NotNull UUID uuid) {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
try {
|
||||
// Delete Position
|
||||
PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `id`
|
||||
IN ((SELECT `last_position` FROM `%players_table%` WHERE `uuid` = ?),
|
||||
(SELECT `offline_position` FROM `%players_table%` WHERE `uuid` = ?),
|
||||
(SELECT `respawn_position` FROM `%players_table%` WHERE `uuid` = ?));"""));
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.setString(3, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""))) {
|
||||
WHERE `uuid`=?;"""));
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete a player from the database", e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user