From b23d4f26e6960c4276a0cea418e299f3f4107629 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 18 Oct 2014 18:45:07 +1100 Subject: [PATCH] actually fixed purge --- .../plot/database/DBFunc.java | 73 ++++++++++--------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 60834e6f7..6a5d54360 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -650,42 +650,43 @@ public class DBFunc { Logger.add(LogLevel.WARNING, "FAILED TO PURGE WORLD '"+world+"'!"); return; } - - try { - - String prefix = ""; - StringBuilder idstr = new StringBuilder(""); - - for (Integer id:ids) { - idstr.append(prefix + id); - prefix = " OR `plot_plot_id` = "; - } - - PreparedStatement stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = "+idstr+""); - stmt.executeUpdate(); - stmt.close(); - - stmt = connection.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = "+idstr+""); - stmt.executeUpdate(); - stmt.close(); - - stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = "+idstr+""); - stmt.executeUpdate(); - stmt.close(); - - stmt = connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = "+idstr+""); - stmt.executeUpdate(); - stmt.close(); - - stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `world` = ?"); - stmt.setString(1, world); - stmt.executeUpdate(); - stmt.close(); - } - catch (SQLException e) { - e.printStackTrace(); - Logger.add(LogLevel.DANGER, "FAILED TO PURGE WORLD '"+world+"'!"); - return; + if (ids.size() > 0) { + try { + + String prefix = ""; + StringBuilder idstr = new StringBuilder(""); + + for (Integer id:ids) { + idstr.append(prefix + id); + prefix = " OR `plot_plot_id` = "; + } + + PreparedStatement stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = "+idstr+""); + stmt.executeUpdate(); + stmt.close(); + + stmt = connection.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = "+idstr+""); + stmt.executeUpdate(); + stmt.close(); + + stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = "+idstr+""); + stmt.executeUpdate(); + stmt.close(); + + stmt = connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = "+idstr+""); + stmt.executeUpdate(); + stmt.close(); + + stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `world` = ?"); + stmt.setString(1, world); + stmt.executeUpdate(); + stmt.close(); + } + catch (SQLException e) { + e.printStackTrace(); + Logger.add(LogLevel.DANGER, "FAILED TO PURGE WORLD '"+world+"'!"); + return; + } } Logger.add(LogLevel.GENERAL, "SUCCESSFULLY PURGED WORLD '"+world+"'!"); }