mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Java can be a pain sometimes...
- Fixed weird bug with plot clear (I basically just swapped the plot.clear() method and DBFunc.delete(plot) as referencing the plot directly afterwards added it back to the HashMap)
This commit is contained in:
parent
04167997ad
commit
26249d00a3
@ -136,7 +136,6 @@ public class PlayerFunctions {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
HashMap<PlotId, Plot> plots = PlotMain.getPlots(world);
|
HashMap<PlotId, Plot> plots = PlotMain.getPlots(world);
|
||||||
|
|
||||||
if (plots != null) {
|
if (plots != null) {
|
||||||
if (plots.containsKey(id)) {
|
if (plots.containsKey(id)) {
|
||||||
return plots.get(id);
|
return plots.get(id);
|
||||||
|
@ -458,8 +458,8 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void clear(final Player requester, final Plot plot) {
|
public static void clear(final Player requester, final Plot plot) {
|
||||||
final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
|
||||||
final long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
|
final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
||||||
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
||||||
PlotHelper.removeSign(requester, plot);
|
PlotHelper.removeSign(requester, plot);
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||||
|
@ -269,12 +269,14 @@ public class PlotMain extends JavaPlugin {
|
|||||||
return (plots.get(world.getName()).values().toArray(new Plot[0]));
|
return (plots.get(world.getName()).values().toArray(new Plot[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removePlot(String world, PlotId id) {
|
public static boolean removePlot(String world, PlotId id, boolean callEvent) {
|
||||||
PlotDeleteEvent event = new PlotDeleteEvent(world, id);
|
if (callEvent) {
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
PlotDeleteEvent event = new PlotDeleteEvent(world, id);
|
||||||
if (event.isCancelled()) {
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
event.setCancelled(true);
|
if (event.isCancelled()) {
|
||||||
return false;
|
event.setCancelled(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
plots.get(world).remove(id);
|
plots.get(world).remove(id);
|
||||||
return true;
|
return true;
|
||||||
|
@ -32,10 +32,10 @@ public class Clear extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id);
|
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
|
||||||
if (result) {
|
if (result) {
|
||||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
|
||||||
plot.clear(plr);
|
plot.clear(plr);
|
||||||
|
DBFunc.delete(plr.getWorld().getName(), plot);
|
||||||
} else {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
|
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
|
||||||
}
|
}
|
||||||
|
@ -149,33 +149,31 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
public static void delete(final String world, final Plot plot) {
|
public static void delete(final String world, final Plot plot) {
|
||||||
boolean result = PlotMain.removePlot(world, plot.id);
|
boolean result = PlotMain.removePlot(world, plot.id, false);
|
||||||
if (result) {
|
runTask(new Runnable() {
|
||||||
runTask(new Runnable() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
PreparedStatement stmt = null;
|
||||||
PreparedStatement stmt = null;
|
int id = getId(world, plot.id);
|
||||||
int id = getId(world, plot.id);
|
try {
|
||||||
try {
|
stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?");
|
||||||
stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?");
|
stmt.setInt(1, id);
|
||||||
stmt.setInt(1, id);
|
stmt.executeUpdate();
|
||||||
stmt.executeUpdate();
|
stmt.close();
|
||||||
stmt.close();
|
stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?");
|
||||||
stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?");
|
stmt.setInt(1, id);
|
||||||
stmt.setInt(1, id);
|
stmt.executeUpdate();
|
||||||
stmt.executeUpdate();
|
stmt.close();
|
||||||
stmt.close();
|
stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?");
|
||||||
stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?");
|
stmt.setInt(1, id);
|
||||||
stmt.setInt(1, id);
|
stmt.executeUpdate();
|
||||||
stmt.executeUpdate();
|
stmt.close();
|
||||||
stmt.close();
|
} catch (SQLException e) {
|
||||||
} catch (SQLException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id);
|
||||||
Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user