mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23: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) {
|
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));
|
PlotHelper.lastPlot.put(world, new PlotId(0,0));
|
||||||
}
|
}
|
||||||
return PlotHelper.lastPlot.get(world);
|
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.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Purge extends SubCommand {
|
@SuppressWarnings({"javadoc"}) public class Purge extends SubCommand {
|
||||||
|
|
||||||
public Purge() {
|
public Purge() {
|
||||||
super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false);
|
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")) {
|
if (arg.equals("all")) {
|
||||||
Set<PlotId> ids = PlotMain.getPlots(world).keySet();
|
Set<PlotId> ids = PlotMain.getPlots(world).keySet();
|
||||||
|
if (ids.size() == 0) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||||
|
}
|
||||||
DBFunc.purge(worldname, ids);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(ids.size());
|
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);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(ids.size());
|
return finishPurge(ids.size());
|
||||||
}
|
}
|
||||||
@ -149,6 +155,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
ids.add(plot.id);
|
ids.add(plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ids.size() == 0) {
|
||||||
|
return PlayerFunctions.sendMessage(null, "&cNo plots found");
|
||||||
|
}
|
||||||
DBFunc.purge(worldname, ids);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(ids.size());
|
return finishPurge(ids.size());
|
||||||
}
|
}
|
||||||
|
@ -837,31 +837,30 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (uniqueIds.size() > 0) {
|
if (uniqueIds.size() > 0) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String prefix = "";
|
String stmt_prefix = "";
|
||||||
final StringBuilder idstr = new StringBuilder("");
|
final StringBuilder idstr = new StringBuilder("");
|
||||||
|
|
||||||
for (final Integer id : uniqueIds) {
|
for (final Integer id : uniqueIds) {
|
||||||
idstr.append(prefix + id);
|
idstr.append(stmt_prefix + id);
|
||||||
prefix = " OR `plot_plot_id` = ";
|
stmt_prefix = " OR `plot_plot_id` = ";
|
||||||
}
|
}
|
||||||
|
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + this.prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + "");
|
||||||
PreparedStatement stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + "");
|
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
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.executeUpdate();
|
||||||
stmt.close();
|
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.executeUpdate();
|
||||||
stmt.close();
|
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.executeUpdate();
|
||||||
stmt.close();
|
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.setString(1, world);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -875,6 +874,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void purge(final String world, Set<PlotId> plots) {
|
public void purge(final String world, Set<PlotId> plots) {
|
||||||
|
for (PlotId id : plots) {
|
||||||
|
PlotMain.removePlot(world, id, true);
|
||||||
|
}
|
||||||
PreparedStatement stmt;
|
PreparedStatement stmt;
|
||||||
try {
|
try {
|
||||||
stmt = SQLManager.this.connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + this.prefix + "plot` WHERE `world` = ?");
|
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