mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
*console commands
Added plot purge
This commit is contained in:
parent
0010b06afa
commit
a64e4c9578
@ -630,7 +630,60 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void purge(final String world) {
|
public static void purge(final String world) {
|
||||||
// TODO purge
|
runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ArrayList<Integer> ids = new ArrayList<Integer>();
|
||||||
|
try {
|
||||||
|
PreparedStatement stmt = connection.prepareStatement("SELECT `id`, FROM `plot` WHERE `world` = ?");
|
||||||
|
stmt.setString(1, world);
|
||||||
|
ResultSet result = stmt.executeQuery();
|
||||||
|
while (result.next()) {
|
||||||
|
int id = result.getInt("id");
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
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` WHERE `world` = ?");
|
||||||
|
stmt.setString(1, world);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Logger.add(LogLevel.WARNING, "FAILED TO PURGE WORLD '"+world+"'!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logger.add(LogLevel.GENERAL, "SUCCESSFULLY PURGED WORLD '"+world+"'!");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user