From ba35d8b7749c316afc749587f5e71aeb3a37eb94 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 10 Feb 2015 17:03:59 +1100 Subject: [PATCH] *Should fix issue with expired mega plots. [UNTESTED] --- .../plot/commands/Unlink.java | 39 +++++++++++-------- .../plot/generator/HybridPlotManager.java | 4 +- .../plot/util/ExpireManager.java | 4 ++ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 307f0e067..c6e73695c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -65,6 +65,27 @@ public class Unlink extends SubCommand { } final World world = plr.getWorld(); + if (!unlinkPlot(world, plot)) { + PlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled"); + return false; + } + try { + if (PlotHelper.canSetFast) { + SetBlockFast.update(plr); + } + } catch (final Exception e) { + // execute(final Player plr, final String... args) { + try { + PlotMain.sendConsoleSenderMessage("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); + } catch (final Exception ex) { + ex.printStackTrace(); + } + } + PlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!"); + return true; + } + + public static boolean unlinkPlot(World world, Plot plot) { final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id; final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id; final ArrayList ids = PlayerFunctions.getPlotSelectionIds(pos1, pos2); @@ -74,7 +95,6 @@ public class Unlink extends SubCommand { Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { event.setCancelled(true); - PlayerFunctions.sendMessage(plr, "&cUnlink has been cancelled"); return false; } @@ -119,25 +139,10 @@ public class Unlink extends SubCommand { if (ly) { manager.createRoadSouth(plotworld, p); } - PlotHelper.setSign(plr.getWorld(), UUIDHandler.getName(plot.owner), plot); + PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot); } } - try { - if (PlotHelper.canSetFast) { - SetBlockFast.update(plr); - } - } catch (final Exception e) { - // execute(final Player plr, final String... args) { - try { - PlotMain.sendConsoleSenderMessage("Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\""); - } catch (final Exception ex) { - ex.printStackTrace(); - } - } - manager.finishPlotUnlink(world, plotworld, ids); - - PlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!"); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 3da0fd41b..a62163d39 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -589,8 +589,8 @@ import com.intellectualcrafters.plot.util.SendChunk; final HybridPlotWorld dpw = ((HybridPlotWorld) PlotMain.getWorldSettings(world)); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); + final Location pos1 = PlotHelper.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1); + final Location pos2 = PlotHelper.getPlotTopLocAbs(world, plot.id); final PlotBlock[] plotfloor = dpw.TOP_BLOCK; final PlotBlock[] filling = dpw.MAIN_BLOCK; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index ce0649211..dd57f22e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -14,6 +14,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.commands.Unlink; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -108,6 +109,9 @@ public class ExpireManager { } final World worldobj = Bukkit.getWorld(world); final PlotManager manager = PlotMain.getPlotManager(world); + if (plot.settings.isMerged()) { + Unlink.unlinkPlot(Bukkit.getWorld(world), plot); + } manager.clearPlot(worldobj, plot, false); PlotHelper.removeSign(worldobj, plot); DBFunc.delete(world, plot);