mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
v4.5: Bulk delete, regex customization, QoL & API work (#486)
* Improve validator error specificity, fix #481 * Add more sanity-checking to cluster IDs, close #482 * Add bulk/player-delete command, close #484, close #257 * Fix checkstyle formatting in tests * Add missing strings to other locale files * Use morepaperlib for runtime command registration on spigot * api: make creation methods return a future, close #473 * Add name/description restriction regex customization * docs: Update config file with new regex options * bump version number to 4.5 * fix typo, correct command confirmation logic * Make confirmation locales more clear * Fix confirmation checking logic
This commit is contained in:
1 parent
e2c9a52911
commit
6bfd69f232
38 files changed
+1161
-692
No files matched your search
@@ -291,6 +291,21 @@ public class H2Database extends Database {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserData(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Instant> getCooldown(@NotNull TransactionResolver.Action action, @NotNull User user) {
|
||||
try (Connection connection = getConnection()) {
|
||||
@@ -1042,6 +1057,33 @@ public class H2Database extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllHomes(@NotNull String worldName, @NotNull String serverName) {
|
||||
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 `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete homes in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarp(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
@@ -1086,6 +1128,33 @@ public class H2Database extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllWarps(@NotNull String worldName, @NotNull String serverName) {
|
||||
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%`
|
||||
WHERE `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete warps in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminate() {
|
||||
if (connectionPool != null) {
|
||||
|
||||
Reference in new issue
Block a user