mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
fixed auto/purge
This commit is contained in:
parent
6a238fe099
commit
8e8ff6d3aa
@ -201,7 +201,7 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
|
||||
public PlotId getLastPlot(String world) {
|
||||
if (PlotHelper.lastPlot == null) {
|
||||
if (PlotHelper.lastPlot == null || !PlotHelper.lastPlot.containsKey(world)) {
|
||||
PlotHelper.lastPlot.put(world, new PlotId(0,0));
|
||||
}
|
||||
return PlotHelper.lastPlot.get(world);
|
||||
|
@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
@SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Purge extends SubCommand {
|
||||
@SuppressWarnings({"javadoc"}) public class Purge extends SubCommand {
|
||||
|
||||
public Purge() {
|
||||
super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false);
|
||||
@ -124,6 +124,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
}
|
||||
if (arg.equals("all")) {
|
||||
Set<PlotId> ids = PlotMain.getPlots(world).keySet();
|
||||
if (ids.size() == 0) {
|
||||
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||
}
|
||||
DBFunc.purge(worldname, ids);
|
||||
return finishPurge(ids.size());
|
||||
}
|
||||
@ -138,6 +141,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ids.size() == 0) {
|
||||
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||
}
|
||||
DBFunc.purge(worldname, ids);
|
||||
return finishPurge(ids.size());
|
||||
}
|
||||
@ -149,6 +155,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
ids.add(plot.id);
|
||||
}
|
||||
}
|
||||
if (ids.size() == 0) {
|
||||
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||
}
|
||||
DBFunc.purge(worldname, ids);
|
||||
return finishPurge(ids.size());
|
||||
}
|
||||
|
@ -831,37 +831,36 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge all plots with the f ollowing database IDs
|
||||
* Purge all plots with the following database IDs
|
||||
*/
|
||||
public void purgeIds(final String world, final Set<Integer> uniqueIds) {
|
||||
if (uniqueIds.size() > 0) {
|
||||
try {
|
||||
|
||||
String prefix = "";
|
||||
String stmt_prefix = "";
|
||||
final StringBuilder idstr = new StringBuilder("");
|
||||
|
||||
for (final Integer id : uniqueIds) {
|
||||
idstr.append(prefix + id);
|
||||
prefix = " OR `plot_plot_id` = ";
|
||||
idstr.append(stmt_prefix + id);
|
||||
stmt_prefix = " OR `plot_plot_id` = ";
|
||||
}
|
||||
|
||||
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + "");
|
||||
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + "");
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr + "");
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr + "");
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr + "");
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr + "");
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr + "");
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr + "");
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot` WHERE `world` = ?");
|
||||
stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot` WHERE `world` = ?");
|
||||
stmt.setString(1, world);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
@ -875,6 +874,9 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
@Override
|
||||
public void purge(final String world, Set<PlotId> plots) {
|
||||
for (PlotId id : plots) {
|
||||
PlotMain.removePlot(world, id, true);
|
||||
}
|
||||
PreparedStatement stmt;
|
||||
try {
|
||||
stmt = SQLManager.this.connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + this.prefix + "plot` WHERE `world` = ?");
|
||||
|
Loading…
Reference in New Issue
Block a user