Yay! version 2.10 is coming soon.

This commit is contained in:
boy0001 2015-04-30 23:57:44 +10:00
parent 5968b9e22e
commit 3540e1f6ca
8 changed files with 93 additions and 63 deletions

View file

@ -42,6 +42,7 @@ import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
/**
* plot functions
@ -66,6 +67,64 @@ public class MainUtil {
return true;
}
public static boolean unlinkPlot(final Plot plot) {
final String world = plot.world;
final PlotId pos1 = MainUtil.getBottomPlot(plot).id;
final PlotId pos2 = MainUtil.getTopPlot(plot).id;
final ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(pos1, pos2);
final boolean result = EventUtil.manager.callUnlink(world, ids);
if (!result) {
return false;
}
final PlotManager manager = PlotSquared.getPlotManager(world);
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
manager.startPlotUnlink(plotworld, ids);
for (final PlotId id : ids) {
final Plot myplot = PlotSquared.getPlots(world).get(id);
if (plot == null) {
continue;
}
if (plot.helpers != null) {
myplot.helpers = plot.helpers;
}
if (plot.denied != null) {
myplot.denied = plot.denied;
}
myplot.deny_entry = plot.deny_entry;
myplot.settings.setMerged(new boolean[] { false, false, false, false });
DBFunc.setMerged(world, myplot, myplot.settings.getMerged());
}
// FIXME unlink augmented
for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) {
final boolean lx = x < pos2.x;
final boolean ly = y < pos2.y;
final Plot p = MainUtil.getPlot(world, new PlotId(x, y));
if (lx) {
manager.createRoadEast(plotworld, p);
if (ly) {
manager.createRoadSouthEast(plotworld, p);
}
}
if (ly) {
manager.createRoadSouth(plotworld, p);
}
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
}
}
manager.finishPlotUnlink(plotworld, ids);
for (final PlotId id : ids) {
final Plot myPlot = MainUtil.getPlot(world, id);
if (plot.hasOwner()) {
final String name = UUIDHandler.getName(myPlot.owner);
if (name != null) {
MainUtil.setSign(name, myPlot);
}
}
}
return true;
}
public static boolean isPlotAreaAbs(final Location location) {
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
if (plotworld.TYPE == 2) {