mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
delhome/delwarp all rewrite; add events for bulk-deletes, close #265
This commit is contained in:
1 parent
2402f12536
commit
834fdbfc0e
17 files changed
+379
-51
No files matched your search
@@ -1011,6 +1011,32 @@ public class SqLiteDatabase extends Database {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Integer> deleteAllHomes(@NotNull User user) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%homes_table%`
|
||||
WHERE `owner_uuid`=?
|
||||
)
|
||||
);"""))) {
|
||||
|
||||
statement.setString(1, user.uuid.toString());
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
getLogger().log(Level.SEVERE, "Failed to delete all homes for " + user.username + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteWarp(@NotNull UUID uuid) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
@@ -1036,6 +1062,29 @@ public class SqLiteDatabase extends Database {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Integer> deleteAllWarps() {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%warps_table%`
|
||||
)
|
||||
);"""))) {
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
getLogger().log(Level.SEVERE, "Failed to delete all warps from the database", e);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminate() {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user