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;
|
||||
}
|
||||
HashMap<PlotId, Plot> plots = PlotMain.getPlots(world);
|
||||
|
||||
if (plots != null) {
|
||||
if (plots.containsKey(id)) {
|
||||
return plots.get(id);
|
||||
|
@ -458,8 +458,8 @@ public class PlotHelper {
|
||||
}
|
||||
|
||||
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 PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
||||
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
||||
PlotHelper.removeSign(requester, plot);
|
||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||
|
@ -269,13 +269,15 @@ public class PlotMain extends JavaPlugin {
|
||||
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) {
|
||||
if (callEvent) {
|
||||
PlotDeleteEvent event = new PlotDeleteEvent(world, id);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
plots.get(world).remove(id);
|
||||
return true;
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ public class Clear extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
||||
plot.clear(plr);
|
||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
|
||||
}
|
||||
|
@ -149,8 +149,7 @@ public class DBFunc {
|
||||
* @param plot
|
||||
*/
|
||||
public static void delete(final String world, final Plot plot) {
|
||||
boolean result = PlotMain.removePlot(world, plot.id);
|
||||
if (result) {
|
||||
boolean result = PlotMain.removePlot(world, plot.id, false);
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -176,7 +175,6 @@ public class DBFunc {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create plot settings
|
||||
|
Loading…
Reference in New Issue
Block a user