mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	restructure a couple things.
This commit is contained in:
		@@ -399,6 +399,9 @@ public class PS {
 | 
			
		||||
            plots.put(world, new ConcurrentHashMap<PlotId, Plot>());
 | 
			
		||||
        }
 | 
			
		||||
        plots.get(world).put(plot.id, plot);
 | 
			
		||||
        for (PlotPlayer pp : plot.getPlayersInPlot()) {
 | 
			
		||||
            pp.setMeta("lastplot", plot);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
@@ -1090,13 +1093,13 @@ public class PS {
 | 
			
		||||
            }
 | 
			
		||||
            return new HashMap<>(myplots);
 | 
			
		||||
        }
 | 
			
		||||
        return new HashMap<>();
 | 
			
		||||
        return new HashMap<>(0);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Collection<Plot> getPlotsInWorld(final String world) {
 | 
			
		||||
        final ConcurrentHashMap<PlotId, Plot> map = plots.get(world);
 | 
			
		||||
        if (map == null) {
 | 
			
		||||
            return new HashSet<>();
 | 
			
		||||
            return new HashSet<>(0);
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
            return map.values();
 | 
			
		||||
@@ -1776,24 +1779,25 @@ public class PS {
 | 
			
		||||
        // Clearing + Expiry
 | 
			
		||||
        options.put("clear.fastmode", Settings.ENABLE_CLUSTERS);
 | 
			
		||||
        options.put("clear.on.ban", false);
 | 
			
		||||
        options.put("clear.auto.enabled", false);
 | 
			
		||||
        options.put("clear.auto.days", 365);
 | 
			
		||||
        options.put("clear.auto.enabled", true);
 | 
			
		||||
        options.put("clear.auto.days", 7);
 | 
			
		||||
        options.put("clear.auto.clear-interval-seconds", Settings.CLEAR_INTERVAL);
 | 
			
		||||
        options.put("clear.auto.calibration.changes", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.faces", 2);
 | 
			
		||||
        options.put("clear.auto.calibration.data", 32);
 | 
			
		||||
        options.put("clear.auto.calibration.faces", 0);
 | 
			
		||||
        options.put("clear.auto.calibration.data", 0);
 | 
			
		||||
        options.put("clear.auto.calibration.air", 0);
 | 
			
		||||
        options.put("clear.auto.calibration.variety", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.changes_sd", 64);
 | 
			
		||||
        options.put("clear.auto.calibration.faces_sd", 32);
 | 
			
		||||
        options.put("clear.auto.calibration.data_sd", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.variety", 0);
 | 
			
		||||
        options.put("clear.auto.calibration.changes_sd", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.faces_sd", 0);
 | 
			
		||||
        options.put("clear.auto.calibration.data_sd", 0);
 | 
			
		||||
        options.put("clear.auto.calibration.air_sd", 0);
 | 
			
		||||
        options.put("clear.auto.calibration.variety_sd", 1);
 | 
			
		||||
        options.put("clear.auto.calibration.variety_sd", 0);
 | 
			
		||||
        
 | 
			
		||||
        final int keep = config.getInt("clear.keep-if-modified");
 | 
			
		||||
        final int ignore = config.getInt("clear.ignore-if-modified");
 | 
			
		||||
        if ((keep > 0) || (ignore > 0)) {
 | 
			
		||||
            options.put("clear.auto.threshold", 1);
 | 
			
		||||
            options.put("clear.auto.enabled", false);
 | 
			
		||||
            log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
 | 
			
		||||
            log("&cSorry for all the exclamation marks, but this could be important.");
 | 
			
		||||
            log("&cPlot clearing has changed to a new system that requires calibration.");
 | 
			
		||||
 
 | 
			
		||||
@@ -429,11 +429,11 @@ public class PlotAPI {
 | 
			
		||||
     * @param x     Plot Location X Co-ord
 | 
			
		||||
     * @param z     Plot Location Z Co-ord
 | 
			
		||||
     *
 | 
			
		||||
     * @return plot, null if ID is wrong
 | 
			
		||||
     * @return plot, null if ID is wrong
 | 
			
		||||
     *
 | 
			
		||||
     * @see MainUtil#getPlotAbs(String, com.intellectualcrafters.plot.object.PlotId)
 | 
			
		||||
     * @see com.intellectualcrafters.plot.object.Plot
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public Plot getPlot(final World world, final int x, final int z) {
 | 
			
		||||
        return MainUtil.getPlotAbs(world.getName(), new PlotId(x, z));
 | 
			
		||||
    }
 | 
			
		||||
@@ -443,11 +443,11 @@ public class PlotAPI {
 | 
			
		||||
     *
 | 
			
		||||
     * @param l The location that you want to to retrieve the plot from
 | 
			
		||||
     *
 | 
			
		||||
     * @return plot if found, otherwise it creates a temporary plot-
 | 
			
		||||
     * @return plot if found, otherwise it creates a temporary plot-
 | 
			
		||||
     *
 | 
			
		||||
     * @see MainUtil#getPlotAbs(com.intellectualcrafters.plot.object.Location)
 | 
			
		||||
     * @see com.intellectualcrafters.plot.object.Plot
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public Plot getPlot(final Location l) {
 | 
			
		||||
        return MainUtil.getPlotAbs(BukkitUtil.getLocation(l));
 | 
			
		||||
    }
 | 
			
		||||
@@ -558,8 +558,8 @@ public class PlotAPI {
 | 
			
		||||
     * com.intellectualcrafters.plot.object.Plot)
 | 
			
		||||
     * @see com.intellectualcrafters.plot.object.Plot
 | 
			
		||||
     */
 | 
			
		||||
    public Location[] getLocations(final Plot p) {
 | 
			
		||||
        return new Location[] {
 | 
			
		||||
    public Location[] getLocations(final Plot p) {
 | 
			
		||||
        return new Location[] {
 | 
			
		||||
        BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.id).subtract(1, 0, 1)),
 | 
			
		||||
        BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.id)),
 | 
			
		||||
        BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id)) };
 | 
			
		||||
@@ -590,7 +590,7 @@ public class PlotAPI {
 | 
			
		||||
     * @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(String,
 | 
			
		||||
     * com.intellectualcrafters.plot.object.PlotId)
 | 
			
		||||
     * @see com.intellectualcrafters.plot.object.Plot
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public Location getBottomLocation(final Plot p) {
 | 
			
		||||
        return BukkitUtil.getLocation(MainUtil.getPlotBottomLocAbs(p.world, p.id).subtract(1, 0, 1));
 | 
			
		||||
    }
 | 
			
		||||
@@ -604,7 +604,7 @@ public class PlotAPI {
 | 
			
		||||
     *
 | 
			
		||||
     * @see MainUtil#getPlotTopLoc(String, com.intellectualcrafters.plot.object.PlotId)
 | 
			
		||||
     * @see com.intellectualcrafters.plot.object.Plot
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public Location getTopLocation(final Plot p) {
 | 
			
		||||
        return BukkitUtil.getLocation(MainUtil.getPlotTopLocAbs(p.world, p.id));
 | 
			
		||||
    }
 | 
			
		||||
@@ -614,10 +614,10 @@ public class PlotAPI {
 | 
			
		||||
     *
 | 
			
		||||
     * @param player who we're checking for
 | 
			
		||||
     *
 | 
			
		||||
     * @return true if the player is in a plot, false if not-
 | 
			
		||||
     * @return true if the player is in a plot, false if not-
 | 
			
		||||
     *
 | 
			
		||||
     * @see com.intellectualcrafters.plot.util.MainUtil#getPlotAbs(com.intellectualcrafters.plot.object.Location)
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isInPlot(final Player player) {
 | 
			
		||||
        return MainUtil.getPlotAbs(BukkitUtil.getLocation(player)) != null;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ public class Add extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -161,7 +161,7 @@ public class Auto extends SubCommand {
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
 | 
			
		||||
        if (plotworld.TYPE == 2) {
 | 
			
		||||
            final Location loc = plr.getLocation();
 | 
			
		||||
            final Plot plot = MainUtil.getPlot(new Location(worldname, loc.getX(), loc.getY(), loc.getZ()));
 | 
			
		||||
            final Plot plot = MainUtil.getPlotAbs(new Location(worldname, loc.getX(), loc.getY(), loc.getZ()));
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                return sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
            }
 | 
			
		||||
@@ -180,8 +180,8 @@ public class Auto extends SubCommand {
 | 
			
		||||
            //
 | 
			
		||||
            for (int i = 0; i <= max; i++) {
 | 
			
		||||
                final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
 | 
			
		||||
                final Plot current = MainUtil.getPlot(worldname, currentId);
 | 
			
		||||
                if (MainUtil.canClaim(plr, current) && (current.getSettings().isMerged() == false) && cluster.equals(current.getCluster())) {
 | 
			
		||||
                final Plot current = MainUtil.getPlotAbs(worldname, currentId);
 | 
			
		||||
                if (MainUtil.canClaim(plr, current) && (current.isMerged() == false) && cluster.equals(current.getCluster())) {
 | 
			
		||||
                    Claim.claimPlot(plr, current, true, true);
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
@@ -194,7 +194,7 @@ public class Auto extends SubCommand {
 | 
			
		||||
        boolean br = false;
 | 
			
		||||
        if ((size_x == 1) && (size_z == 1)) {
 | 
			
		||||
            while (!br) {
 | 
			
		||||
                final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname));
 | 
			
		||||
                final Plot plot = MainUtil.getPlotAbs(worldname, getLastPlot(worldname));
 | 
			
		||||
                if (MainUtil.canClaim(plr, plot)) {
 | 
			
		||||
                    Claim.claimPlot(plr, plot, true, true);
 | 
			
		||||
                    br = true;
 | 
			
		||||
@@ -217,7 +217,7 @@ public class Auto extends SubCommand {
 | 
			
		||||
                if (MainUtil.canClaim(plr, worldname, start, end)) {
 | 
			
		||||
                    for (int i = start.x; i <= end.x; i++) {
 | 
			
		||||
                        for (int j = start.y; j <= end.y; j++) {
 | 
			
		||||
                            final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j));
 | 
			
		||||
                            final Plot plot = MainUtil.getPlotAbs(worldname, new PlotId(i, j));
 | 
			
		||||
                            final boolean teleport = ((i == end.x) && (j == end.y));
 | 
			
		||||
                            Claim.claimPlot(plr, plot, teleport, true);
 | 
			
		||||
                        }
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ public class BO3 extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if ((plot == null) || !plot.hasOwner()) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,9 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
@@ -58,64 +61,54 @@ public class Buy extends SubCommand {
 | 
			
		||||
        if (!PS.get().isPlotWorld(world)) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
 | 
			
		||||
        }
 | 
			
		||||
        Set<Plot> plots;
 | 
			
		||||
        Plot plot;
 | 
			
		||||
        if (args.length > 0) {
 | 
			
		||||
            try {
 | 
			
		||||
                final String[] split = args[0].split(";");
 | 
			
		||||
                final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
 | 
			
		||||
                plot = MainUtil.getPlot(world, id);
 | 
			
		||||
                plot = MainUtil.getPlotAbs(world, id);
 | 
			
		||||
                plots = MainUtil.getConnectedPlots(plot);
 | 
			
		||||
            } catch (final Exception e) {
 | 
			
		||||
                return sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            plot = MainUtil.getPlot(loc);
 | 
			
		||||
            plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
            plots = MainUtil.getConnectedPlots(plot);
 | 
			
		||||
        }
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
        if (plots == null) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr);
 | 
			
		||||
        if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
 | 
			
		||||
            return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.hasOwner()) {
 | 
			
		||||
            return sendMessage(plr, C.PLOT_UNOWNED);
 | 
			
		||||
        }
 | 
			
		||||
        if (PlotHandler.isOwner(plot, plr.getUUID())) {
 | 
			
		||||
            return sendMessage(plr, C.CANNOT_BUY_OWN);
 | 
			
		||||
        final int currentPlots = MainUtil.getPlayerPlotCount(plr) + plots.size();
 | 
			
		||||
        if (currentPlots > MainUtil.getAllowedPlots(plr)) {
 | 
			
		||||
            return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
 | 
			
		||||
        }
 | 
			
		||||
        final Flag flag = FlagManager.getPlotFlag(plot, "price");
 | 
			
		||||
        if (flag == null) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_FOR_SALE);
 | 
			
		||||
        }
 | 
			
		||||
        double initPrice = (double) flag.getValue();
 | 
			
		||||
        double price = initPrice;
 | 
			
		||||
        final PlotId id = plot.id;
 | 
			
		||||
        final PlotId id2 = MainUtil.getTopPlot(plot).id;
 | 
			
		||||
        final int size = MainUtil.getPlotSelectionIds(id, id2).size();
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
        if (plotworld.USE_ECONOMY) {
 | 
			
		||||
            price += plotworld.PLOT_PRICE * size;
 | 
			
		||||
            initPrice += plotworld.SELL_PRICE * size;
 | 
			
		||||
        if (plot.isOwner(plr.getUUID())) {
 | 
			
		||||
            return sendMessage(plr, C.CANNOT_BUY_OWN);
 | 
			
		||||
        }
 | 
			
		||||
        double price = (double) flag.getValue();
 | 
			
		||||
        if ((EconHandler.manager != null) && (price > 0d)) {
 | 
			
		||||
            if (EconHandler.manager.getMoney(plr) < price) {
 | 
			
		||||
                return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
 | 
			
		||||
            }
 | 
			
		||||
            EconHandler.manager.withdrawMoney(plr, price);
 | 
			
		||||
            sendMessage(plr, C.REMOVED_BALANCE, price + "");
 | 
			
		||||
            EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), initPrice);
 | 
			
		||||
            EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
 | 
			
		||||
            final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
 | 
			
		||||
            if (owner != null) {
 | 
			
		||||
                sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
 | 
			
		||||
                sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), price + "");
 | 
			
		||||
            }
 | 
			
		||||
            FlagManager.removePlotFlag(plot, "price");
 | 
			
		||||
        }
 | 
			
		||||
        final Plot top = MainUtil.getTopPlot(plot);
 | 
			
		||||
        
 | 
			
		||||
        for (final PlotId myId : MainUtil.getPlotSelectionIds(plot.id, top.id)) {
 | 
			
		||||
            final Plot myPlot = MainUtil.getPlot(plot.world, myId);
 | 
			
		||||
            myPlot.owner = plr.getUUID();
 | 
			
		||||
            DBFunc.setOwner(plot, myPlot.owner);
 | 
			
		||||
        for (final Plot current : plots) {
 | 
			
		||||
            plot.setOwner(plr.getUUID());
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(plr, C.CLAIMED);
 | 
			
		||||
        return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ public class Claim extends SubCommand {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
 | 
			
		||||
        if (plot.hasOwner() || plot.getSettings().isMerged()) {
 | 
			
		||||
        if (plot.hasOwner() || plot.isMerged()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final boolean result = EventUtil.manager.callClaim(player, plot, false);
 | 
			
		||||
@@ -94,13 +94,12 @@ public class Claim extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        
 | 
			
		||||
        String schematic = "";
 | 
			
		||||
        if (args.length >= 1) {
 | 
			
		||||
            schematic = args[0];
 | 
			
		||||
        }
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.CmdConfirm;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.UUIDHandler;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
@@ -59,10 +60,10 @@ public class Clear extends SubCommand {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                plot = MainUtil.getPlot(loc.getWorld(), id);
 | 
			
		||||
                plot = MainUtil.getPlotAbs(loc.getWorld(), id);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            plot = MainUtil.getPlot(loc);
 | 
			
		||||
            plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        }
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot clear [X;Z|mine]");
 | 
			
		||||
@@ -71,11 +72,10 @@ public class Clear extends SubCommand {
 | 
			
		||||
        //        if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
 | 
			
		||||
        //            return sendMessage(plr, C.UNLINK_REQUIRED);
 | 
			
		||||
        //        }
 | 
			
		||||
        if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {
 | 
			
		||||
        if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {
 | 
			
		||||
            return sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
        }
 | 
			
		||||
        assert plot != null;
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
        if (plot.getRunning() != 0) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -91,19 +91,29 @@ public class Clear extends SubCommand {
 | 
			
		||||
                final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        // If the state changes, then mark it as no longer done
 | 
			
		||||
                        if (FlagManager.getPlotFlag(plot, "done") != null) {
 | 
			
		||||
                            FlagManager.removePlotFlag(plot, "done");
 | 
			
		||||
                        }
 | 
			
		||||
                        if (FlagManager.getPlotFlag(plot, "analysis") != null) {
 | 
			
		||||
                            FlagManager.removePlotFlag(plot, "analysis");
 | 
			
		||||
                        }
 | 
			
		||||
                        MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
 | 
			
		||||
                        plot.unlink();
 | 
			
		||||
                        SetBlockQueue.addNotify(new Runnable() {
 | 
			
		||||
                            @Override
 | 
			
		||||
                            public void run() {
 | 
			
		||||
                                plot.removeRunning();
 | 
			
		||||
                                // If the state changes, then mark it as no longer done
 | 
			
		||||
                                if (FlagManager.getPlotFlag(plot, "done") != null) {
 | 
			
		||||
                                    FlagManager.removePlotFlag(plot, "done");
 | 
			
		||||
                                }
 | 
			
		||||
                                if (FlagManager.getPlotFlag(plot, "analysis") != null) {
 | 
			
		||||
                                    FlagManager.removePlotFlag(plot, "analysis");
 | 
			
		||||
                                }
 | 
			
		||||
                                MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                if (!result) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    plot.addRunning();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
 | 
			
		||||
 
 | 
			
		||||
@@ -59,10 +59,10 @@ public class Comment extends SubCommand {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            index = 2;
 | 
			
		||||
            plot = MainUtil.getPlot(loc.getWorld(), id);
 | 
			
		||||
            plot = MainUtil.getPlotAbs(loc.getWorld(), id);
 | 
			
		||||
        } else {
 | 
			
		||||
            index = 1;
 | 
			
		||||
            plot = MainUtil.getPlot(loc);
 | 
			
		||||
            plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        }
 | 
			
		||||
        if (!inbox.canWrite(plot, player)) {
 | 
			
		||||
            sendMessage(player, C.NO_PERM_INBOX, "");
 | 
			
		||||
 
 | 
			
		||||
@@ -23,8 +23,10 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicBoolean;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
@@ -33,6 +35,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MathMan;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(command = "condense", permission = "plots.admin", description = "Condense a plotworld", category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE)
 | 
			
		||||
@@ -70,18 +73,53 @@ public class Condense extends SubCommand {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final int radius = Integer.parseInt(args[2]);
 | 
			
		||||
                final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
 | 
			
		||||
                final int size = plots.size();
 | 
			
		||||
                ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlotsInWorld(worldname));
 | 
			
		||||
                // remove non base plots
 | 
			
		||||
                Iterator<Plot> iter = plots.iterator();
 | 
			
		||||
                int maxSize = 0;
 | 
			
		||||
                ArrayList<Integer> sizes = new ArrayList<>();
 | 
			
		||||
                while (iter.hasNext()) {
 | 
			
		||||
                    Plot plot = iter.next();
 | 
			
		||||
                    if (!plot.isBasePlot()) {
 | 
			
		||||
                        iter.remove();
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                    int size = plot.getConnectedPlots().size();
 | 
			
		||||
                    if (size > maxSize) {
 | 
			
		||||
                        maxSize = size;
 | 
			
		||||
                    }
 | 
			
		||||
                    sizes.add(size - 1);
 | 
			
		||||
                }
 | 
			
		||||
                // Sort plots by size (buckets?)]
 | 
			
		||||
                ArrayList<Plot>[] buckets = new ArrayList[maxSize];
 | 
			
		||||
                for (int i = 0; i < plots.size(); i++) {
 | 
			
		||||
                    Plot plot = plots.get(i);
 | 
			
		||||
                    int size = sizes.get(i);
 | 
			
		||||
                    ArrayList<Plot> array = buckets[size];
 | 
			
		||||
                    if (array == null) {
 | 
			
		||||
                        array = new ArrayList<Plot>();
 | 
			
		||||
                        buckets[size] = array;
 | 
			
		||||
                    }
 | 
			
		||||
                    array.add(plot);
 | 
			
		||||
                }
 | 
			
		||||
                final ArrayList<Plot> allPlots = new ArrayList<Plot>(plots.size());
 | 
			
		||||
                for (int i = buckets.length - 1; i >= 0; i--) {
 | 
			
		||||
                    ArrayList<Plot> array = buckets[i];
 | 
			
		||||
                    if (array != null) {
 | 
			
		||||
                        allPlots.addAll(array);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                final int size = allPlots.size();
 | 
			
		||||
                final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
 | 
			
		||||
                if (radius < minimum_radius) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final List<PlotId> to_move = new ArrayList<>(getPlots(plots, radius));
 | 
			
		||||
                final List<PlotId> to_move = new ArrayList<>(getPlots(allPlots, radius));
 | 
			
		||||
                final List<PlotId> free = new ArrayList<>();
 | 
			
		||||
                PlotId start = new PlotId(0, 0);
 | 
			
		||||
                while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
 | 
			
		||||
                    final Plot plot = MainUtil.getPlot(worldname, start);
 | 
			
		||||
                    final Plot plot = MainUtil.getPlotAbs(worldname, start);
 | 
			
		||||
                    if (!plot.hasOwner()) {
 | 
			
		||||
                        free.add(plot.id);
 | 
			
		||||
                    }
 | 
			
		||||
@@ -91,53 +129,54 @@ public class Condense extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(plr, "NO FREE PLOTS FOUND");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), new Runnable() {
 | 
			
		||||
                MainUtil.sendMessage(plr, "TASK STARTED...");
 | 
			
		||||
                Runnable run = new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        if (!TASK) {
 | 
			
		||||
                            MainUtil.sendMessage(plr, "CONDENSE TASK CANCELLED");
 | 
			
		||||
                            return;
 | 
			
		||||
                            MainUtil.sendMessage(plr, "TASK CANCELLED.");
 | 
			
		||||
                        }
 | 
			
		||||
                        to_move.remove(0);
 | 
			
		||||
                        free.remove(0);
 | 
			
		||||
                        int index = 0;
 | 
			
		||||
                        for (final PlotId id : to_move) {
 | 
			
		||||
                            final Plot plot = MainUtil.getPlot(worldname, id);
 | 
			
		||||
                            if (plot.hasOwner()) {
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                            index++;
 | 
			
		||||
                        }
 | 
			
		||||
                        for (int i = 0; i < index; i++) {
 | 
			
		||||
                            to_move.remove(0);
 | 
			
		||||
                        }
 | 
			
		||||
                        index = 0;
 | 
			
		||||
                        for (final PlotId id : free) {
 | 
			
		||||
                            final Plot plot = MainUtil.getPlot(worldname, id);
 | 
			
		||||
                            if (!plot.hasOwner()) {
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                            index++;
 | 
			
		||||
                        }
 | 
			
		||||
                        for (int i = 0; i < index; i++) {
 | 
			
		||||
                            free.remove(0);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (to_move.size() == 0) {
 | 
			
		||||
                            MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
 | 
			
		||||
                        if (allPlots.size() == 0) {
 | 
			
		||||
                            TASK = false;
 | 
			
		||||
                            MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        final Runnable task = this;
 | 
			
		||||
                        final Plot origin = allPlots.remove(0);
 | 
			
		||||
                        int i = 0;
 | 
			
		||||
                        while (free.size() > i) {
 | 
			
		||||
                            final Plot possible = MainUtil.getPlotAbs(origin.world, free.get(i));
 | 
			
		||||
                            if (possible.owner != null) {
 | 
			
		||||
                                free.remove(i);
 | 
			
		||||
                                continue;
 | 
			
		||||
                            }
 | 
			
		||||
                            i++;
 | 
			
		||||
                            final AtomicBoolean result = new AtomicBoolean(false);
 | 
			
		||||
                            result.set(MainUtil.move(origin, possible, new Runnable() {
 | 
			
		||||
                                @Override
 | 
			
		||||
                                public void run() {
 | 
			
		||||
                                    if (result.get()) {
 | 
			
		||||
                                        MainUtil.sendMessage(plr, "Moving: " + origin + " -> " + possible);
 | 
			
		||||
                                        TaskManager.runTaskLater(task, 1);
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }, false));
 | 
			
		||||
                            if (result.get()) {
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        if (free.size() == 0) {
 | 
			
		||||
                            MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
 | 
			
		||||
                            TASK = false;
 | 
			
		||||
                            MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        MainUtil.sendMessage(plr, "MOVING " + to_move.get(0) + " to " + free.get(0));
 | 
			
		||||
                        MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), this);
 | 
			
		||||
                        if (i >= free.size()) {
 | 
			
		||||
                            MainUtil.sendMessage(plr, "SKIPPING COMPLEX PLOT: " + origin);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                };
 | 
			
		||||
                TASK = true;
 | 
			
		||||
                MainUtil.sendMessage(plr, "TASK STARTED...");
 | 
			
		||||
                TaskManager.runTaskAsync(run);
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            case "stop": {
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ public class Continue extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if ((plot == null) || !plot.hasOwner()) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -49,7 +49,7 @@ public class Continue extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.getSettings().flags.containsKey("done")) {
 | 
			
		||||
        if (!plot.getFlags().containsKey("done")) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -57,7 +57,7 @@ public class Continue extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.continue");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
        if (plot.getRunning() > 0) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
@@ -45,29 +44,30 @@ public class Copy extends SubCommand {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String... args) {
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot1 = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot1 = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot1 == null) {
 | 
			
		||||
            return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
 | 
			
		||||
        if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final String world = loc.getWorld();
 | 
			
		||||
        final PlotId plot2 = MainUtil.parseId(args[0]);
 | 
			
		||||
        final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
 | 
			
		||||
        if ((plot2 == null)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot1.equals(plot2)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot1.id.equals(plot2)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
 | 
			
		||||
        if (!plot1.getWorld().equals(plot2.getWorld())) {
 | 
			
		||||
            C.PLOTWORLD_INCOMPATIBLE.send(plr);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.copy(world, plot1.id, plot2, new Runnable() {
 | 
			
		||||
        if (MainUtil.copy(plot1, plot2, new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.COPY_SUCCESS);
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ public class CreateRoadSchematic extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer player, final String... args) {
 | 
			
		||||
        final Location loc = player.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return sendMessage(player, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -95,7 +95,7 @@ public class DebugClaimTest extends SubCommand {
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<>();
 | 
			
		||||
        for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
 | 
			
		||||
            final Plot plot = MainUtil.getPlot(world, id);
 | 
			
		||||
            final Plot plot = MainUtil.getPlotAbs(world, id);
 | 
			
		||||
            if (PS.get().getPlot(world, plot.id) != null) {
 | 
			
		||||
                MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
 | 
			
		||||
                continue;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,67 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// PlotSquared - A plot manager and world generator for the Bukkit API                             /
 | 
			
		||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters                                       /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// This program is free software; you can redistribute it and/or modify                            /
 | 
			
		||||
// it under the terms of the GNU General Public License as published by                            /
 | 
			
		||||
// the Free Software Foundation; either version 3 of the License, or                               /
 | 
			
		||||
// (at your option) any later version.                                                             /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// This program is distributed in the hope that it will be useful,                                 /
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                  /
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                   /
 | 
			
		||||
// GNU General Public License for more details.                                                    /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// You should have received a copy of the GNU General Public License                               /
 | 
			
		||||
// along with this program; if not, write to the Free Software Foundation,                         /
 | 
			
		||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA                               /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// You can contact us via: support@intellectualsites.com                                           /
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.intellectualcrafters.plot.util.UUIDHandler;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(command = "debugclear", aliases = { "fastclear" }, description = "Clear a plot using a fast experiment algorithm", category = CommandCategory.DEBUG)
 | 
			
		||||
public class DebugClear extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        if ((plot == null) || !(PS.get().getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
 | 
			
		||||
            return sendMessage(plr, C.UNLINK_REQUIRED);
 | 
			
		||||
        }
 | 
			
		||||
        if ((!plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
 | 
			
		||||
            return sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
        }
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id);
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.runners.put(plot, 1);
 | 
			
		||||
        ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                MainUtil.runners.remove(plot);
 | 
			
		||||
                MainUtil.sendMessage(plr, "&aDone!");
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -160,7 +160,7 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
            boolean async = false;
 | 
			
		||||
            switch (arg) {
 | 
			
		||||
                case "analyze": {
 | 
			
		||||
                    final Plot plot = MainUtil.getPlot(player.getLocation());
 | 
			
		||||
                    final Plot plot = MainUtil.getPlotAbs(player.getLocation());
 | 
			
		||||
                    if (plot == null) {
 | 
			
		||||
                        MainUtil.sendMessage(player, C.NOT_IN_PLOT);
 | 
			
		||||
                        return false;
 | 
			
		||||
@@ -168,7 +168,7 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
                    final PlotAnalysis analysis = plot.getComplexity();
 | 
			
		||||
                    if (analysis != null) {
 | 
			
		||||
                        final int complexity = analysis.getComplexity();
 | 
			
		||||
                        MainUtil.sendMessage(player, "Changes: " + analysis.changes);
 | 
			
		||||
                        MainUtil.sendMessage(player, "Changes/column: " + (analysis.changes / 1.0));
 | 
			
		||||
                        MainUtil.sendMessage(player, "Complexity: " + complexity);
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,166 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// PlotSquared - A plot manager and world generator for the Bukkit API                             /
 | 
			
		||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters                                       /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// This program is free software; you can redistribute it and/or modify                            /
 | 
			
		||||
// it under the terms of the GNU General Public License as published by                            /
 | 
			
		||||
// the Free Software Foundation; either version 3 of the License, or                               /
 | 
			
		||||
// (at your option) any later version.                                                             /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// This program is distributed in the hope that it will be useful,                                 /
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                  /
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                   /
 | 
			
		||||
// GNU General Public License for more details.                                                    /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// You should have received a copy of the GNU General Public License                               /
 | 
			
		||||
// along with this program; if not, write to the Free Software Foundation,                         /
 | 
			
		||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA                               /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// You can contact us via: support@intellectualsites.com                                           /
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotBlock;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
command = "fill",
 | 
			
		||||
permission = "plots.fill",
 | 
			
		||||
description = "Fill or surround a plot in bedrock",
 | 
			
		||||
usage = "/plot fill",
 | 
			
		||||
aliases = { "debugfill" },
 | 
			
		||||
category = CommandCategory.DEBUG,
 | 
			
		||||
requiredType = RequiredType.NONE)
 | 
			
		||||
public class DebugFill extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer player, final String... args) {
 | 
			
		||||
        if ((args.length != 1) || (!args[0].equalsIgnoreCase("outline") && !args[0].equalsIgnoreCase("all"))) {
 | 
			
		||||
            MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill <outline|all>");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        final Location loc = player.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(player, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.hasOwner()) {
 | 
			
		||||
            MainUtil.sendMessage(player, C.PLOT_UNOWNED);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.fill")) {
 | 
			
		||||
            MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
            MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
 | 
			
		||||
        MainUtil.sendMessage(player, "&cPreparing task");
 | 
			
		||||
        MainUtil.runners.put(plot, 1);
 | 
			
		||||
        SetBlockQueue.addNotify(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        MainUtil.sendMessage(player, "&7 - Starting");
 | 
			
		||||
                        if (args[0].equalsIgnoreCase("all")) {
 | 
			
		||||
                            int height = 255;
 | 
			
		||||
                            PlotBlock block = new PlotBlock((short) 7, (byte) 0);
 | 
			
		||||
                            final PlotBlock air = new PlotBlock((short) 0, (byte) 0);
 | 
			
		||||
                            if (args.length > 2) {
 | 
			
		||||
                                try {
 | 
			
		||||
                                    block = new PlotBlock(Short.parseShort(args[1]), (byte) 0);
 | 
			
		||||
                                    if (args.length == 3) {
 | 
			
		||||
                                        height = Integer.parseInt(args[2]);
 | 
			
		||||
                                    }
 | 
			
		||||
                                } catch (final Exception e) {
 | 
			
		||||
                                    MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill all <id> <height>");
 | 
			
		||||
                                    MainUtil.runners.remove(plot);
 | 
			
		||||
                                    return;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            for (int y = 0; y <= height; y++) {
 | 
			
		||||
                                for (int x = bottom.getX(); x <= top.getX(); x++) {
 | 
			
		||||
                                    for (int z = bottom.getZ(); z <= top.getZ(); z++) {
 | 
			
		||||
                                        SetBlockQueue.setBlock(plot.world, x, y, z, block);
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            for (int y = height + 1; y <= 255; y++) {
 | 
			
		||||
                                for (int x = bottom.getX(); x <= top.getX(); x++) {
 | 
			
		||||
                                    for (int z = bottom.getZ(); z <= top.getZ(); z++) {
 | 
			
		||||
                                        SetBlockQueue.setBlock(plot.world, x, y, z, air);
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            SetBlockQueue.addNotify(new Runnable() {
 | 
			
		||||
                                @Override
 | 
			
		||||
                                public void run() {
 | 
			
		||||
                                    MainUtil.runners.remove(plot);
 | 
			
		||||
                                    MainUtil.sendMessage(player, "&aFill task complete!");
 | 
			
		||||
                                }
 | 
			
		||||
                            });
 | 
			
		||||
                        } else if (args[0].equals("outline")) {
 | 
			
		||||
                            int x, z;
 | 
			
		||||
                            z = bottom.getZ();
 | 
			
		||||
                            for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
 | 
			
		||||
                                for (int y = 1; y <= 255; y++) {
 | 
			
		||||
                                    SetBlockQueue.setBlock(plot.world, x, y, z, 7);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            x = top.getX();
 | 
			
		||||
                            for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) {
 | 
			
		||||
                                for (int y = 1; y <= 255; y++) {
 | 
			
		||||
                                    SetBlockQueue.setBlock(plot.world, x, y, z, 7);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            z = top.getZ();
 | 
			
		||||
                            for (x = top.getX(); x >= (bottom.getX() + 1); x--) {
 | 
			
		||||
                                for (int y = 1; y <= 255; y++) {
 | 
			
		||||
                                    SetBlockQueue.setBlock(plot.world, x, y, z, 7);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            x = bottom.getX();
 | 
			
		||||
                            for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) {
 | 
			
		||||
                                for (int y = 1; y <= 255; y++) {
 | 
			
		||||
                                    SetBlockQueue.setBlock(plot.world, x, y, z, 7);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            SetBlockQueue.addNotify(new Runnable() {
 | 
			
		||||
                                @Override
 | 
			
		||||
                                public void run() {
 | 
			
		||||
                                    MainUtil.sendMessage(player, "&aWalls complete! The ceiling will take a while :(");
 | 
			
		||||
                                    bottom.setY(255);
 | 
			
		||||
                                    top.add(1, 0, 1);
 | 
			
		||||
                                    SetBlockQueue.setSlow(true);
 | 
			
		||||
                                    MainUtil.setSimpleCuboidAsync(plot.world, bottom, top, new PlotBlock((short) 7, (byte) 0));
 | 
			
		||||
                                    SetBlockQueue.addNotify(new Runnable() {
 | 
			
		||||
                                        @Override
 | 
			
		||||
                                        public void run() {
 | 
			
		||||
                                            MainUtil.runners.remove(plot);
 | 
			
		||||
                                            MainUtil.sendMessage(player, "&aFill task complete!");
 | 
			
		||||
                                            SetBlockQueue.setSlow(false);
 | 
			
		||||
                                        }
 | 
			
		||||
                                    });
 | 
			
		||||
                                }
 | 
			
		||||
                            });
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -58,7 +58,7 @@ public class DebugFixFlags extends SubCommand {
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
 | 
			
		||||
        for (final Plot plot : PS.get().getPlotsInWorld(world)) {
 | 
			
		||||
            final HashMap<String, Flag> flags = plot.getSettings().flags;
 | 
			
		||||
            final HashMap<String, Flag> flags = plot.getFlags();
 | 
			
		||||
            final Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
 | 
			
		||||
            boolean changed = false;
 | 
			
		||||
            while (i.hasNext()) {
 | 
			
		||||
@@ -68,7 +68,7 @@ public class DebugFixFlags extends SubCommand {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (changed) {
 | 
			
		||||
                DBFunc.setFlags(plot, plot.getSettings().flags.values());
 | 
			
		||||
                DBFunc.setFlags(plot, plot.getFlags().values());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(plr, "&aDone!");
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,8 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
@@ -49,51 +51,52 @@ public class Delete extends SubCommand {
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
 | 
			
		||||
            return !sendMessage(plr, C.UNLINK_REQUIRED);
 | 
			
		||||
        if (!plot.hasOwner()) {
 | 
			
		||||
            return !sendMessage(plr, C.PLOT_UNOWNED);
 | 
			
		||||
        }
 | 
			
		||||
        if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
 | 
			
		||||
        if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
 | 
			
		||||
            return !sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
        }
 | 
			
		||||
        final PlotWorld pWorld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Runnable runnable = new Runnable() {
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
        final HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
 | 
			
		||||
        final Runnable run = new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if ((EconHandler.manager != null) && pWorld.USE_ECONOMY && plot.hasOwner() && plot.isOwner(UUIDHandler.getUUID(plr))) {
 | 
			
		||||
                    final double c = pWorld.SELL_PRICE;
 | 
			
		||||
                    if (c > 0d) {
 | 
			
		||||
                        EconHandler.manager.depositMoney(plr, c);
 | 
			
		||||
                        sendMessage(plr, C.ADDED_BALANCE, c + "");
 | 
			
		||||
                    }
 | 
			
		||||
                if (plot.getRunning() > 0) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                if (plot.unclaim()) {
 | 
			
		||||
                    final long start = System.currentTimeMillis();
 | 
			
		||||
                    final boolean result = MainUtil.clearAsPlayer(plot, true, new Runnable() {
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public void run() {
 | 
			
		||||
                            MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
 | 
			
		||||
                final long start = System.currentTimeMillis();
 | 
			
		||||
                boolean result = plot.deletePlot(new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        plot.removeRunning();
 | 
			
		||||
                        if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
 | 
			
		||||
                            final double value = plotworld.SELL_PRICE * plots.size();
 | 
			
		||||
                            if (value > 0d) {
 | 
			
		||||
                                EconHandler.manager.depositMoney(plr, value);
 | 
			
		||||
                                sendMessage(plr, C.ADDED_BALANCE, value + "");
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                    if (!result) {
 | 
			
		||||
                        MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
                        MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.UNCLAIM_FAILED);
 | 
			
		||||
                });
 | 
			
		||||
                if (result) {
 | 
			
		||||
                    plot.addRunning();
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
 | 
			
		||||
            CmdConfirm.addPending(plr, "/plot delete " + plot.id, runnable);
 | 
			
		||||
            CmdConfirm.addPending(plr, "/plot delete " + plot.id, run);
 | 
			
		||||
        } else {
 | 
			
		||||
            TaskManager.runTask(runnable);
 | 
			
		||||
            TaskManager.runTask(run);
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ public class Deny extends SubCommand {
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -95,7 +95,7 @@ public class Deny extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    private void handleKick(final UUID uuid, final Plot plot) {
 | 
			
		||||
        final PlotPlayer pp = UUIDHandler.getPlayer(uuid);
 | 
			
		||||
        if ((pp != null) && plot.equals(MainUtil.getPlot(pp.getLocation()))) {
 | 
			
		||||
        if ((pp != null) && plot.equals(MainUtil.getPlotAbs(pp.getLocation()))) {
 | 
			
		||||
            pp.teleport(BlockManager.manager.getSpawn(pp.getLocation().getWorld()));
 | 
			
		||||
            MainUtil.sendMessage(pp, C.YOU_GOT_DENIED);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ public class Done extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if ((plot == null) || !plot.hasOwner()) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -48,11 +48,11 @@ public class Done extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.getSettings().flags.containsKey("done")) {
 | 
			
		||||
        if (plot.getFlags().containsKey("done")) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
        if (plot.getRunning() > 0) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ public class Download extends SubCommand {
 | 
			
		||||
        if (!PS.get().isPlotWorld(world)) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
 | 
			
		||||
        }
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(plr.getLocation());
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(plr.getLocation());
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -42,7 +42,7 @@ public class Download extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
        if (plot.getRunning() > 0) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -68,7 +68,7 @@ public class FlagCmd extends SubCommand {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Location loc = player.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            MainUtil.sendMessage(player, C.NOT_IN_PLOT);
 | 
			
		||||
            return false;
 | 
			
		||||
@@ -172,7 +172,7 @@ public class FlagCmd extends SubCommand {
 | 
			
		||||
                if ((args.length == 3) && flag.getAbstractFlag().isList()) {
 | 
			
		||||
                    final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
 | 
			
		||||
                    ((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
 | 
			
		||||
                    DBFunc.setFlags(plot, plot.getSettings().flags.values());
 | 
			
		||||
                    DBFunc.setFlags(plot, plot.getFlags().values());
 | 
			
		||||
                } else {
 | 
			
		||||
                    final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
 | 
			
		||||
                    if (!result) {
 | 
			
		||||
@@ -222,7 +222,7 @@ public class FlagCmd extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                DBFunc.setFlags(plot, plot.getSettings().flags.values());
 | 
			
		||||
                DBFunc.setFlags(plot, plot.getFlags().values());
 | 
			
		||||
                MainUtil.sendMessage(player, C.FLAG_ADDED);
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -83,7 +83,7 @@ public class Inbox extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer player, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(player.getLocation());
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(player.getLocation());
 | 
			
		||||
        if (args.length == 0) {
 | 
			
		||||
            sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
 | 
			
		||||
            for (final CommentInbox inbox : CommentManager.inboxes.values()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -32,10 +32,12 @@ import com.intellectualcrafters.plot.flag.Flag;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.FlagManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotBlock;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotInventory;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotItemStack;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
@@ -139,14 +141,14 @@ public class Info extends SubCommand {
 | 
			
		||||
            inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] {
 | 
			
		||||
            "&cID: &6" + plot.getId().toString(),
 | 
			
		||||
            "&cOwner: &6" + name,
 | 
			
		||||
            "&cAlias: &6" + plot.getSettings().getAlias(),
 | 
			
		||||
            "&cAlias: &6" + plot.getAlias(),
 | 
			
		||||
            "&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(),
 | 
			
		||||
            "&cCan Build: &6" + plot.isAdded(uuid),
 | 
			
		||||
            "&cIs Denied: &6" + plot.isDenied(uuid) }));
 | 
			
		||||
            inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] { "&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users" }));
 | 
			
		||||
            inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] { "&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members" }));
 | 
			
		||||
            inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] { "&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players" }));
 | 
			
		||||
            inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", new String[] { "&cFlags", "&cAmount: &6" + plot.getSettings().flags.size(), "&8Click to view a list of plot flags" }));
 | 
			
		||||
            inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", new String[] { "&cFlags", "&cAmount: &6" + plot.getFlags().size(), "&8Click to view a list of plot flags" }));
 | 
			
		||||
            inv.openInventory();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
@@ -205,12 +207,10 @@ public class Info extends SubCommand {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private void formatAndSend(String info, final String world, final Plot plot, final PlotPlayer player, final boolean full) {
 | 
			
		||||
        final PlotId id = plot.id;
 | 
			
		||||
        final PlotId id2 = MainUtil.getTopPlot(plot).id;
 | 
			
		||||
        final int num = MainUtil.getPlotSelectionIds(id, id2).size();
 | 
			
		||||
        final String alias = plot.getSettings().getAlias().length() > 0 ? plot.getSettings().getAlias() : C.NONE.s();
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc(world, plot.id);
 | 
			
		||||
        final Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
 | 
			
		||||
        final int num = MainUtil.getConnectedPlots(plot).size();
 | 
			
		||||
        final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLocAbs(world, plot.id);
 | 
			
		||||
        final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id);
 | 
			
		||||
        final String biome = BlockManager.manager.getBiome(plot.world, bot.getX() + ((top.getX() - bot.getX()) / 2), bot.getZ() + ((top.getZ() - bot.getZ()) / 2));
 | 
			
		||||
        final String trusted = getPlayerList(plot.getTrusted());
 | 
			
		||||
        final String members = getPlayerList(plot.getMembers());
 | 
			
		||||
@@ -227,9 +227,8 @@ public class Info extends SubCommand {
 | 
			
		||||
        
 | 
			
		||||
        final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
 | 
			
		||||
        
 | 
			
		||||
        info = info.replaceAll("%id%", plot.id.toString());
 | 
			
		||||
        info = info.replaceAll("%alias%", alias);
 | 
			
		||||
        info = info.replaceAll("%id%", id.toString());
 | 
			
		||||
        info = info.replaceAll("%id2%", id2.toString());
 | 
			
		||||
        info = info.replaceAll("%num%", num + "");
 | 
			
		||||
        info = info.replaceAll("%desc%", description);
 | 
			
		||||
        info = info.replaceAll("%biome%", biome);
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ public class Kick extends SubCommand {
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -55,7 +55,7 @@ public class Kick extends SubCommand {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Location otherLoc = player.getLocation();
 | 
			
		||||
        if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(MainUtil.getPlot(otherLoc))) {
 | 
			
		||||
        if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(MainUtil.getPlotAbs(otherLoc))) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ public class Load extends SubCommand {
 | 
			
		||||
        if (!PS.get().isPlotWorld(world)) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
 | 
			
		||||
        }
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(plr.getLocation());
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(plr.getLocation());
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -51,14 +51,13 @@ public class Load extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
        if (plot.getRunning() > 0) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (args.length != 0) {
 | 
			
		||||
            if (args.length == 1) {
 | 
			
		||||
                // TODO load save here
 | 
			
		||||
                final List<String> schematics = (List<String>) plr.getMeta("plot_schematics");
 | 
			
		||||
                if (schematics == null) {
 | 
			
		||||
                    // No schematics found:
 | 
			
		||||
 
 | 
			
		||||
@@ -72,13 +72,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
 | 
			
		||||
        createCommand(new Download());
 | 
			
		||||
        createCommand(new Update());
 | 
			
		||||
        createCommand(new Template());
 | 
			
		||||
        createCommand(new Setup());
 | 
			
		||||
        createCommand(new Setup());
 | 
			
		||||
        createCommand(new DebugSaveTest());
 | 
			
		||||
        createCommand(new DebugLoadTest());
 | 
			
		||||
        createCommand(new CreateRoadSchematic());
 | 
			
		||||
        createCommand(new DebugAllowUnsafe());
 | 
			
		||||
        createCommand(new RegenAllRoads());
 | 
			
		||||
        createCommand(new RegenAllRoads());
 | 
			
		||||
        createCommand(new Claim());
 | 
			
		||||
        createCommand(new Auto());
 | 
			
		||||
@@ -294,9 +292,9 @@ public class MainCommand extends CommandManager<PlotPlayer> {
 | 
			
		||||
                id = null;
 | 
			
		||||
                world = null;
 | 
			
		||||
            }
 | 
			
		||||
            if ((id != null) && PS.get().isPlotWorld(world)) {
 | 
			
		||||
            if ((id != null) && PS.get().isPlotWorld(world)) {
 | 
			
		||||
                final Plot plot = MainUtil.getPlotAbs(world, id);
 | 
			
		||||
                if (plot != null) {
 | 
			
		||||
                if (plot != null) {
 | 
			
		||||
                    player.teleport(plot.getBottomAbs());
 | 
			
		||||
                    args = Arrays.copyOfRange(args, 1, args.length);
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -50,8 +50,8 @@ usage = "/plot merge [direction]",
 | 
			
		||||
category = CommandCategory.ACTIONS,
 | 
			
		||||
requiredType = RequiredType.NONE)
 | 
			
		||||
public class Merge extends SubCommand {
 | 
			
		||||
    public final static String[] values = new String[] { "north", "east", "south", "west" };
 | 
			
		||||
    public final static String[] aliases = new String[] { "n", "e", "s", "w" };
 | 
			
		||||
    public final static String[] values = new String[] { "north", "east", "south", "west", "auto" };
 | 
			
		||||
    public final static String[] aliases = new String[] { "n", "e", "s", "w", "all" };
 | 
			
		||||
    
 | 
			
		||||
    public static String direction(float yaw) {
 | 
			
		||||
        yaw = yaw / 90;
 | 
			
		||||
@@ -77,9 +77,8 @@ public class Merge extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocationFull();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -92,27 +91,46 @@ public class Merge extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
        if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d && EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
 | 
			
		||||
            sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        int direction = -1;
 | 
			
		||||
        final int size = plot.getConnectedPlots().size();
 | 
			
		||||
        final int maxSize = Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS); 
 | 
			
		||||
        if (size >= maxSize) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + size);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (args.length == 0) {
 | 
			
		||||
            switch (direction(plr.getLocationFull().getYaw())) {
 | 
			
		||||
                case "NORTH":
 | 
			
		||||
                    direction = 0;
 | 
			
		||||
                    break;
 | 
			
		||||
                case "EAST":
 | 
			
		||||
                    direction = 1;
 | 
			
		||||
                    break;
 | 
			
		||||
                case "SOUTH":
 | 
			
		||||
                    direction = 2;
 | 
			
		||||
                    break;
 | 
			
		||||
                case "WEST":
 | 
			
		||||
                    direction = 3;
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
//            switch (direction(plr.getLocationFull().getYaw())) {
 | 
			
		||||
//                case "NORTH":
 | 
			
		||||
//                    direction = 0;
 | 
			
		||||
//                    break;
 | 
			
		||||
//                case "EAST":
 | 
			
		||||
//                    direction = 1;
 | 
			
		||||
//                    break;
 | 
			
		||||
//                case "SOUTH":
 | 
			
		||||
//                    direction = 2;
 | 
			
		||||
//                    break;
 | 
			
		||||
//                case "WEST":
 | 
			
		||||
//                    direction = 3;
 | 
			
		||||
//                    break;
 | 
			
		||||
//            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if (args[0].equalsIgnoreCase("all")) {
 | 
			
		||||
                plot.autoMerge((args.length != 2) || !args[1].equalsIgnoreCase("false"));
 | 
			
		||||
                MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
 | 
			
		||||
                return true;
 | 
			
		||||
            if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("auto")) {
 | 
			
		||||
                if (MainUtil.autoMerge(plot, -1, maxSize - size, plr.getUUID(), (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
 | 
			
		||||
                    if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
 | 
			
		||||
                        EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
 | 
			
		||||
                        sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
 | 
			
		||||
                    }
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
 | 
			
		||||
                return false;
 | 
			
		||||
                
 | 
			
		||||
            }
 | 
			
		||||
            for (int i = 0; i < values.length; i++) {
 | 
			
		||||
                if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
 | 
			
		||||
@@ -122,135 +140,63 @@ public class Merge extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (direction == -1) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(values, C.BLOCK_LIST_SEPARATER.s()));
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + ">");
 | 
			
		||||
            MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        PlotId bot = MainUtil.getBottomPlot(plot).id;
 | 
			
		||||
        PlotId top = MainUtil.getTopPlot(plot).id;
 | 
			
		||||
        ArrayList<PlotId> selPlots;
 | 
			
		||||
        final String world = loc.getWorld();
 | 
			
		||||
        switch (direction) {
 | 
			
		||||
            case 0: // north = -y
 | 
			
		||||
                selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
 | 
			
		||||
                break;
 | 
			
		||||
            case 1: // east = +x
 | 
			
		||||
                selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
 | 
			
		||||
                break;
 | 
			
		||||
            case 2: // south = +y
 | 
			
		||||
                selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
 | 
			
		||||
                break;
 | 
			
		||||
            case 3: // west = -x
 | 
			
		||||
                selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                return false;
 | 
			
		||||
        }
 | 
			
		||||
        final int size = selPlots.size();
 | 
			
		||||
        if (Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS) < size) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + size);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final PlotId botId = selPlots.get(0);
 | 
			
		||||
        final PlotId topId = selPlots.get(selPlots.size() - 1);
 | 
			
		||||
        final PlotId bot1 = MainUtil.getBottomPlot(MainUtil.getPlot(world, botId)).id;
 | 
			
		||||
        final PlotId bot2 = MainUtil.getBottomPlot(MainUtil.getPlot(world, topId)).id;
 | 
			
		||||
        final PlotId top1 = MainUtil.getTopPlot(MainUtil.getPlot(world, topId)).id;
 | 
			
		||||
        final PlotId top2 = MainUtil.getTopPlot(MainUtil.getPlot(world, botId)).id;
 | 
			
		||||
        bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
 | 
			
		||||
        top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
 | 
			
		||||
        final ArrayList<PlotId> plots = MainUtil.getMaxPlotSelectionIds(world, bot, top);
 | 
			
		||||
        boolean multiMerge = false;
 | 
			
		||||
        final HashSet<UUID> multiUUID = new HashSet<UUID>();
 | 
			
		||||
        final HashSet<PlotId> multiPlots = new HashSet<>();
 | 
			
		||||
        final UUID u1 = plot.owner;
 | 
			
		||||
        for (final PlotId myid : plots) {
 | 
			
		||||
            final Plot myplot = PS.get().getPlot(world, myid);
 | 
			
		||||
            if ((myplot == null) || (myplot.owner == null)) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
 | 
			
		||||
                return false;
 | 
			
		||||
        if (MainUtil.autoMerge(plot, direction, maxSize - size, plot.owner, (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
 | 
			
		||||
            if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
 | 
			
		||||
                EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
 | 
			
		||||
                sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
 | 
			
		||||
            }
 | 
			
		||||
            final UUID u2 = myplot.owner;
 | 
			
		||||
            if (u2.equals(u1)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final PlotPlayer p2 = UUIDHandler.getPlayer(u2);
 | 
			
		||||
            if (p2 == null) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            multiMerge = true;
 | 
			
		||||
            multiPlots.add(myid);
 | 
			
		||||
            multiUUID.add(u2);
 | 
			
		||||
        }
 | 
			
		||||
        if (multiMerge) {
 | 
			
		||||
            if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER.s());
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            for (final UUID uuid : multiUUID) {
 | 
			
		||||
                final PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
 | 
			
		||||
                CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        final PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
 | 
			
		||||
                        multiUUID.remove(uuid);
 | 
			
		||||
                        if (multiUUID.size() == 0) {
 | 
			
		||||
                            final PlotPlayer pp = UUIDHandler.getPlayer(u1);
 | 
			
		||||
                            if (pp == null) {
 | 
			
		||||
                                sendMessage(accepter, C.MERGE_NOT_VALID);
 | 
			
		||||
                                return;
 | 
			
		||||
                            }
 | 
			
		||||
                            final PlotWorld plotWorld = PS.get().getPlotWorld(world);
 | 
			
		||||
                            if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
 | 
			
		||||
                                double cost = plotWorld.MERGE_PRICE;
 | 
			
		||||
                                cost = plots.size() * cost;
 | 
			
		||||
                                if (cost > 0d) {
 | 
			
		||||
                                    if (EconHandler.manager.getMoney(plr) < cost) {
 | 
			
		||||
                                        sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
 | 
			
		||||
                                        return;
 | 
			
		||||
                                    }
 | 
			
		||||
                                    EconHandler.manager.withdrawMoney(plr, cost);
 | 
			
		||||
                                    sendMessage(plr, C.REMOVED_BALANCE, cost + "");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            final boolean result = EventUtil.manager.callMerge(world, plot, plots);
 | 
			
		||||
                            if (!result) {
 | 
			
		||||
                                MainUtil.sendMessage(plr, "&cMerge has been cancelled");
 | 
			
		||||
                                return;
 | 
			
		||||
                            }
 | 
			
		||||
                            MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
 | 
			
		||||
                            MainUtil.mergePlots(world, plots, true, true);
 | 
			
		||||
                            MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
 | 
			
		||||
                        }
 | 
			
		||||
                        MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            MainUtil.sendMessage(plr, C.MERGE_REQUESTED);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        final PlotWorld plotWorld = PS.get().getPlotWorld(world);
 | 
			
		||||
        if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
 | 
			
		||||
            double cost = plotWorld.MERGE_PRICE;
 | 
			
		||||
            cost = plots.size() * cost;
 | 
			
		||||
            if (cost > 0d) {
 | 
			
		||||
                if (EconHandler.manager.getMoney(plr) < cost) {
 | 
			
		||||
                    sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                EconHandler.manager.withdrawMoney(plr, cost);
 | 
			
		||||
                sendMessage(plr, C.REMOVED_BALANCE, cost + "");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        final boolean result = EventUtil.manager.callMerge(world, plot, plots);
 | 
			
		||||
        if (!result) {
 | 
			
		||||
            MainUtil.sendMessage(plr, "&cMerge has been cancelled");
 | 
			
		||||
        Plot adjacent = MainUtil.getPlotAbs(plot.world, MainUtil.getPlotIdRelative(plot.id, direction));
 | 
			
		||||
        if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
 | 
			
		||||
        MainUtil.mergePlots(world, plots, true, true);
 | 
			
		||||
        MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
 | 
			
		||||
        if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER.s());
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        HashSet<UUID> uuids = adjacent.getOwners();
 | 
			
		||||
        boolean isOnline = false;
 | 
			
		||||
        for (final UUID uuid : uuids) {
 | 
			
		||||
            final PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
 | 
			
		||||
            if (accepter == null) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            isOnline = true;
 | 
			
		||||
            final int dir = direction;
 | 
			
		||||
            CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
 | 
			
		||||
                    MainUtil.autoMerge(plot, dir, maxSize - size, uuid, true);
 | 
			
		||||
                    final PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
 | 
			
		||||
                    if (pp == null) {
 | 
			
		||||
                        sendMessage(accepter, C.MERGE_NOT_VALID);
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
 | 
			
		||||
                        if (EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
 | 
			
		||||
                            sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
 | 
			
		||||
                        sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
 | 
			
		||||
                    }
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        if (isOnline == false) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(plr, C.MERGE_REQUESTED);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -41,40 +41,26 @@ public class Move extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot1 = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot1 = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot1 == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
            return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
 | 
			
		||||
        if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final String world = loc.getWorld();
 | 
			
		||||
        final PlotId plot2id = MainUtil.parseId(args[0]);
 | 
			
		||||
        if ((plot2id == null)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
 | 
			
		||||
        final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
 | 
			
		||||
        if ((plot2 == null)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        String world2;
 | 
			
		||||
        if (args.length == 2) {
 | 
			
		||||
            final PlotWorld other = PS.get().getPlotWorld(args[1]);
 | 
			
		||||
            final PlotWorld current = PS.get().getPlotWorld(loc.getWorld());
 | 
			
		||||
            if ((other == null) || (current == null) || !other.equals(current)) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE);
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            world2 = other.worldname;
 | 
			
		||||
        } else {
 | 
			
		||||
            world2 = world;
 | 
			
		||||
        }
 | 
			
		||||
        final Plot plot2 = MainUtil.getPlot(world2, plot2id);
 | 
			
		||||
        
 | 
			
		||||
        if (plot1.equals(plot2)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot1.getWorld().equals(plot2.getWorld())) {
 | 
			
		||||
            C.PLOTWORLD_INCOMPATIBLE.send(plr);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.move(plot1, plot2, new Runnable() {
 | 
			
		||||
@@ -82,11 +68,12 @@ public class Move extends SubCommand {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.MOVE_SUCCESS);
 | 
			
		||||
            }
 | 
			
		||||
        })) {
 | 
			
		||||
        }, false)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        } else {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ public class MusicSubcommand extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer player, final String[] args) {
 | 
			
		||||
        final Location loc = player.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(player, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -93,7 +93,7 @@ public class Purge extends SubCommand {
 | 
			
		||||
        final PlotId id = getId(arg);
 | 
			
		||||
        if (id != null) {
 | 
			
		||||
            final HashSet<Integer> ids = new HashSet<Integer>();
 | 
			
		||||
            final int DBid = DBFunc.getId(MainUtil.getPlot(worldname, id));
 | 
			
		||||
            final int DBid = DBFunc.getId(MainUtil.getPlotAbs(worldname, id));
 | 
			
		||||
            if (DBid != Integer.MAX_VALUE) {
 | 
			
		||||
                ids.add(DBid);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -82,7 +82,7 @@ public class Rate extends SubCommand {
 | 
			
		||||
                });
 | 
			
		||||
                final UUID uuid = player.getUUID();
 | 
			
		||||
                for (final Plot p : plots) {
 | 
			
		||||
                    if ((!Settings.REQUIRE_DONE || p.getSettings().flags.containsKey("done"))
 | 
			
		||||
                    if ((!Settings.REQUIRE_DONE || p.getFlags().containsKey("done"))
 | 
			
		||||
                    && p.isBasePlot()
 | 
			
		||||
                    && ((p.getSettings().ratings == null) || !p.getSettings().ratings.containsKey(uuid))
 | 
			
		||||
                    && !p.isAdded(uuid)) {
 | 
			
		||||
@@ -96,7 +96,7 @@ public class Rate extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        final Location loc = player.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(player, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -108,7 +108,7 @@ public class Rate extends SubCommand {
 | 
			
		||||
            sendMessage(player, C.RATING_NOT_YOUR_OWN);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (Settings.REQUIRE_DONE && !plot.getSettings().flags.containsKey("done")) {
 | 
			
		||||
        if (Settings.REQUIRE_DONE && !plot.getFlags().containsKey("done")) {
 | 
			
		||||
            sendMessage(player, C.RATING_NOT_DONE);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
@@ -66,7 +67,7 @@ public class RegenAllRoads extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final List<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
 | 
			
		||||
        final Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
 | 
			
		||||
        MainUtil.sendMessage(plr, "&cIf no schematic is set, the following will not do anything");
 | 
			
		||||
        MainUtil.sendMessage(plr, "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
 | 
			
		||||
        MainUtil.sendMessage(plr, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,7 @@ public class Remove extends SubCommand {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import com.intellectualcrafters.jnbt.CompoundTag;
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
@@ -32,7 +33,7 @@ public class Save extends SubCommand {
 | 
			
		||||
        if (!PS.get().isPlotWorld(world)) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
 | 
			
		||||
        }
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(plr.getLocation());
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(plr.getLocation());
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -44,7 +45,7 @@ public class Save extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
        if (plot.getRunning() > 0) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -57,7 +58,8 @@ public class Save extends SubCommand {
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        final String time = (System.currentTimeMillis() / 1000) + "";
 | 
			
		||||
                        final String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
 | 
			
		||||
                        final int size = (plot.getTop().getX() - plot.getBottom().getX()) + 1;
 | 
			
		||||
                        Location[] corners = MainUtil.getCorners(plot);
 | 
			
		||||
                        final int size = (corners[1].getX() - corners[0].getX()) + 1;
 | 
			
		||||
                        final PlotId id = plot.id;
 | 
			
		||||
                        final String world = plot.world.replaceAll("[^A-Za-z0-9]", "");
 | 
			
		||||
                        final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name;
 | 
			
		||||
 
 | 
			
		||||
@@ -40,8 +40,6 @@ import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
// TODO Add sub-subcommands
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
command = "schematic",
 | 
			
		||||
permission = "plots.schematic",
 | 
			
		||||
@@ -73,7 +71,7 @@ public class SchematicCmd extends SubCommand {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                final Location loc = plr.getLocation();
 | 
			
		||||
                final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
                final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
                if (plot == null) {
 | 
			
		||||
                    return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
                }
 | 
			
		||||
@@ -130,37 +128,38 @@ public class SchematicCmd extends SubCommand {
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            case "test": {
 | 
			
		||||
                if (!Permissions.hasPermission(plr, "plots.schematic.test")) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                if (args.length < 2) {
 | 
			
		||||
                    sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final Location loc = plr.getLocation();
 | 
			
		||||
                final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
                if (plot == null) {
 | 
			
		||||
                    sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                file = args[1];
 | 
			
		||||
                schematic = SchematicHandler.manager.getSchematic(file);
 | 
			
		||||
                if (schematic == null) {
 | 
			
		||||
                    sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final int l1 = schematic.getSchematicDimension().getX();
 | 
			
		||||
                final int l2 = schematic.getSchematicDimension().getZ();
 | 
			
		||||
                final int length = MainUtil.getPlotWidth(loc.getWorld(), plot.id);
 | 
			
		||||
                if ((l1 < length) || (l2 < length)) {
 | 
			
		||||
                    sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                sendMessage(plr, C.SCHEMATIC_VALID);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
//            TODO test
 | 
			
		||||
//            case "test": {
 | 
			
		||||
//                if (!Permissions.hasPermission(plr, "plots.schematic.test")) {
 | 
			
		||||
//                    MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
 | 
			
		||||
//                    return false;
 | 
			
		||||
//                }
 | 
			
		||||
//                if (args.length < 2) {
 | 
			
		||||
//                    sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
 | 
			
		||||
//                    return false;
 | 
			
		||||
//                }
 | 
			
		||||
//                final Location loc = plr.getLocation();
 | 
			
		||||
//                final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
//                if (plot == null) {
 | 
			
		||||
//                    sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
//                    return false;
 | 
			
		||||
//                }
 | 
			
		||||
//                file = args[1];
 | 
			
		||||
//                schematic = SchematicHandler.manager.getSchematic(file);
 | 
			
		||||
//                if (schematic == null) {
 | 
			
		||||
//                    sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
 | 
			
		||||
//                    return false;
 | 
			
		||||
//                }
 | 
			
		||||
//                final int l1 = schematic.getSchematicDimension().getX();
 | 
			
		||||
//                final int l2 = schematic.getSchematicDimension().getZ();
 | 
			
		||||
//                final int length = MainUtil.getPlotWidth(loc.getWorld(), plot.id);
 | 
			
		||||
//                if ((l1 < length) || (l2 < length)) {
 | 
			
		||||
//                    sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
 | 
			
		||||
//                    break;
 | 
			
		||||
//                }
 | 
			
		||||
//                sendMessage(plr, C.SCHEMATIC_VALID);
 | 
			
		||||
//                break;
 | 
			
		||||
//            }
 | 
			
		||||
            case "saveall":
 | 
			
		||||
            case "exportall": {
 | 
			
		||||
                if (!ConsolePlayer.isConsole(plr)) {
 | 
			
		||||
@@ -203,7 +202,7 @@ public class SchematicCmd extends SubCommand {
 | 
			
		||||
                }
 | 
			
		||||
                final Plot p2;
 | 
			
		||||
                final Location loc = plr.getLocation();
 | 
			
		||||
                final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
                final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
                if (plot == null) {
 | 
			
		||||
                    return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,6 @@ import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
import com.intellectualcrafters.plot.util.UUIDHandler;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
// TODO Make sub-subcommands
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
command = "set",
 | 
			
		||||
description = "Set a plot value",
 | 
			
		||||
@@ -62,9 +61,8 @@ public class Set extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -93,7 +91,7 @@ public class Set extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (args[0].equalsIgnoreCase("flag")) {
 | 
			
		||||
            List<String> arglist = Arrays.asList("flag", "set");
 | 
			
		||||
            List<String> arglist = new ArrayList<>(Arrays.asList("flag", "set"));
 | 
			
		||||
            for (String arg : Arrays.copyOfRange(args, 1, args.length)) {
 | 
			
		||||
                arglist.add(arg);
 | 
			
		||||
            }
 | 
			
		||||
@@ -113,7 +111,7 @@ public class Set extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
            //set to current location
 | 
			
		||||
            final String world = plr.getLocation().getWorld();
 | 
			
		||||
            final Location base = MainUtil.getPlotBottomLoc(world, plot.id);
 | 
			
		||||
            final Location base = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1);
 | 
			
		||||
            base.setY(0);
 | 
			
		||||
            final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ());
 | 
			
		||||
            final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ(), relative.getYaw(), relative.getPitch());
 | 
			
		||||
@@ -159,7 +157,7 @@ public class Set extends SubCommand {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            for (final Plot p : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
 | 
			
		||||
                if (p.getSettings().getAlias().equalsIgnoreCase(alias)) {
 | 
			
		||||
                if (p.getAlias().equalsIgnoreCase(alias)) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
@@ -179,26 +177,26 @@ public class Set extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
            if (args.length < 2) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.NEED_BIOME);
 | 
			
		||||
                return true;
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            if (args[1].length() < 2) {
 | 
			
		||||
                sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2");
 | 
			
		||||
                return true;
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            final int biome = BlockManager.manager.getBiomeFromString(args[1]);
 | 
			
		||||
            if (biome == -1) {
 | 
			
		||||
                MainUtil.sendMessage(plr, getBiomeList(BlockManager.manager.getBiomeList()));
 | 
			
		||||
                return true;
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
            if (plot.getRunning() > 0) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            MainUtil.runners.put(plot, 1);
 | 
			
		||||
            plot.addRunning();
 | 
			
		||||
            plot.setBiome(args[1].toUpperCase(), new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    MainUtil.runners.remove(plot);
 | 
			
		||||
                    plot.removeRunning();
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + args[1].toLowerCase());
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
@@ -265,17 +263,19 @@ public class Set extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, args[1]);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
                if (plot.getRunning() > 0) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                MainUtil.runners.put(plot, 1);
 | 
			
		||||
                manager.setComponent(plotworld, plot.id, component, blocks);
 | 
			
		||||
                plot.addRunning();
 | 
			
		||||
                for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
                    manager.setComponent(plotworld, current.id, component, blocks);
 | 
			
		||||
                }
 | 
			
		||||
                MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
 | 
			
		||||
                SetBlockQueue.addNotify(new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        MainUtil.runners.remove(plot);
 | 
			
		||||
                        plot.removeRunning();
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
@@ -58,7 +59,7 @@ public class SetOwner extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if ((plot == null) || ((plot.owner == null) && !Permissions.hasPermission(plr, "plots.admin.command.setowner"))) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
            return false;
 | 
			
		||||
@@ -67,14 +68,11 @@ public class SetOwner extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NEED_USER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        final PlotId bot = MainUtil.getBottomPlot(plot).id;
 | 
			
		||||
        final PlotId top = MainUtil.getTopPlot(plot).id;
 | 
			
		||||
        final ArrayList<PlotId> plots = MainUtil.getPlotSelectionIds(bot, top);
 | 
			
		||||
        
 | 
			
		||||
        HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
 | 
			
		||||
        UUID uuid = UUIDHandler.getUUID(args[0], null);
 | 
			
		||||
        final PlotPlayer other = UUIDHandler.getPlayer(args[0]);
 | 
			
		||||
        if (other == null) {
 | 
			
		||||
            if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
 | 
			
		||||
            if (uuid == null || !Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
@@ -88,32 +86,13 @@ public class SetOwner extends SubCommand {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (!plot.isOwner(plr.getUUID())) {
 | 
			
		||||
            if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        final String world = loc.getWorld();
 | 
			
		||||
        final UUID uuid = getUUID(args[0]);
 | 
			
		||||
        if (uuid == null) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        for (final PlotId id : plots) {
 | 
			
		||||
            Plot current = PS.get().getPlot(world, id);
 | 
			
		||||
            if (current == null) {
 | 
			
		||||
                current = MainUtil.getPlot(world, id);
 | 
			
		||||
                current.owner = uuid;
 | 
			
		||||
                current.create();
 | 
			
		||||
            } else {
 | 
			
		||||
                current.owner = uuid;
 | 
			
		||||
                DBFunc.setOwner(current, current.owner);
 | 
			
		||||
            }
 | 
			
		||||
            PS.get().updatePlot(current);
 | 
			
		||||
        }
 | 
			
		||||
        plot.setOwner(uuid);
 | 
			
		||||
        MainUtil.setSign(args[0], plot);
 | 
			
		||||
        MainUtil.sendMessage(plr, C.SET_OWNER);
 | 
			
		||||
        if (other != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -40,91 +40,38 @@ public class Swap extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        MainUtil.sendMessage(plr, "&cThis command has not been optimized for large selections yet. Please bug me if this becomes an issue.");
 | 
			
		||||
        if (args.length < 1) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NEED_PLOT_ID);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        final Plot plot1 = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot1 == null) {
 | 
			
		||||
            return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) {
 | 
			
		||||
        if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        final Plot bot1 = MainUtil.getBottomPlot(plot);
 | 
			
		||||
        final Plot top1 = MainUtil.getTopPlot(plot);
 | 
			
		||||
        
 | 
			
		||||
        final PlotId id2 = PlotId.fromString(args[0]);
 | 
			
		||||
        if (id2 == null) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
 | 
			
		||||
        final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
 | 
			
		||||
        if ((plot2 == null)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final String world = loc.getWorld();
 | 
			
		||||
        final Plot plot2 = MainUtil.getPlot(world, id2);
 | 
			
		||||
        final PlotId id3 = new PlotId((id2.x + top1.id.x) - bot1.id.x, (id2.y + top1.id.y) - bot1.id.y);
 | 
			
		||||
        final Plot plot3 = MainUtil.getPlot(world, id3);
 | 
			
		||||
        
 | 
			
		||||
        // Getting secon selection
 | 
			
		||||
        final Plot bot2 = MainUtil.getBottomPlot(plot2);
 | 
			
		||||
        final Plot top2 = MainUtil.getTopPlot(plot3);
 | 
			
		||||
        
 | 
			
		||||
        // cancel swap if intersection
 | 
			
		||||
        final PlotCluster cluster1 = new PlotCluster(world, bot1.id, top1.id, null);
 | 
			
		||||
        final PlotClusterId cluster2id = new PlotClusterId(bot2.id, top2.id);
 | 
			
		||||
        if (ClusterManager.intersects(cluster1, cluster2id)) {
 | 
			
		||||
        if (plot1.equals(plot2)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot1.getWorld().equals(plot2.getWorld())) {
 | 
			
		||||
            C.PLOTWORLD_INCOMPATIBLE.send(plr);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.move(plot1, plot2, new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.SWAP_SUCCESS);
 | 
			
		||||
            }
 | 
			
		||||
        }, true)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        } else {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.SWAP_OVERLAP);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // Check dimensions
 | 
			
		||||
        if (((top1.id.x - bot1.id.x) != (top2.id.x - bot2.id.x)) || ((top1.id.y - bot1.id.y) != (top2.id.y - bot2.id.y))) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.SWAP_DIMENSIONS, "1");
 | 
			
		||||
            MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // Getting selections as ids
 | 
			
		||||
        final ArrayList<PlotId> selection1 = MainUtil.getPlotSelectionIds(bot1.id, top1.id);
 | 
			
		||||
        final ArrayList<PlotId> selection2 = MainUtil.getPlotSelectionIds(bot2.id, top2.id);
 | 
			
		||||
        
 | 
			
		||||
        // Getting selections as location coordinates
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLocAbs(world, bot1.id);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLocAbs(world, top1.id).subtract(1, 0, 1);
 | 
			
		||||
        final Location pos3 = MainUtil.getPlotBottomLocAbs(world, bot2.id);
 | 
			
		||||
        final Location pos4 = MainUtil.getPlotTopLocAbs(world, top2.id).subtract(1, 0, 1);
 | 
			
		||||
        
 | 
			
		||||
        if (MainUtil.getPlot(pos2) != null) {
 | 
			
		||||
            pos1.add(1, 0, 1);
 | 
			
		||||
            pos2.add(1, 0, 1);
 | 
			
		||||
            pos3.add(1, 0, 1);
 | 
			
		||||
            pos4.add(1, 0, 1);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // Swapping the blocks, states and entites
 | 
			
		||||
        ChunkManager.manager.swap(world, pos1, pos2, pos3, pos4);
 | 
			
		||||
        
 | 
			
		||||
        // Swapping the plot data
 | 
			
		||||
        for (int i = 0; i < selection1.size(); i++) {
 | 
			
		||||
            final boolean last = i == (selection1.size() - 1);
 | 
			
		||||
            final PlotId swaper = selection1.get(i);
 | 
			
		||||
            final PlotId swapee = selection2.get(i);
 | 
			
		||||
            MainUtil.swapData(world, swaper, swapee, new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    if (last) {
 | 
			
		||||
                        MainUtil.sendMessage(plr, C.SWAP_SUCCESS);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(plr, C.STARTED_SWAP);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ public class TP extends SubCommand {
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
            plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
 | 
			
		||||
            MainUtil.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid));
 | 
			
		||||
            MainUtil.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlotAbs(world, plotid));
 | 
			
		||||
            return true;
 | 
			
		||||
        } catch (final Exception e) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
 | 
			
		||||
@@ -90,7 +90,7 @@ public class TP extends SubCommand {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        for (final Plot p : PS.get().getPlotsInWorld(world)) {
 | 
			
		||||
            if ((p.getSettings().getAlias().length() > 0) && p.getSettings().getAlias().equalsIgnoreCase(a)) {
 | 
			
		||||
            if ((p.getAlias().length() > 0) && p.getAlias().equalsIgnoreCase(a)) {
 | 
			
		||||
                return p;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ public class Target extends SubCommand {
 | 
			
		||||
                Plot closest = null;
 | 
			
		||||
                int distance = Integer.MAX_VALUE;
 | 
			
		||||
                for (final Plot plot : PS.get().getPlotsInWorld(ploc.getWorld())) {
 | 
			
		||||
                    final double current = plot.getBottom().getEuclideanDistanceSquared(ploc);
 | 
			
		||||
                    final double current = plot.getBottomAbs().getEuclideanDistanceSquared(ploc);
 | 
			
		||||
                    if (current < distance) {
 | 
			
		||||
                        distance = (int) current;
 | 
			
		||||
                        closest = plot;
 | 
			
		||||
 
 | 
			
		||||
@@ -133,8 +133,8 @@ public class Trim extends SubCommand {
 | 
			
		||||
                    }
 | 
			
		||||
                    final Plot plot = plots.remove(0);
 | 
			
		||||
                    
 | 
			
		||||
                    final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id);
 | 
			
		||||
                    final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
 | 
			
		||||
                    final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id);
 | 
			
		||||
                    final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
 | 
			
		||||
                    
 | 
			
		||||
                    final int ccx1 = (pos1.getX() >> 9);
 | 
			
		||||
                    final int ccz1 = (pos1.getZ() >> 9);
 | 
			
		||||
@@ -204,7 +204,7 @@ public class Trim extends SubCommand {
 | 
			
		||||
            sendMessage(C.TRIM_IN_PROGRESS.s());
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        sendMessage(C.TRIM_START.s());
 | 
			
		||||
        sendMessage(C.TASK_START.s());
 | 
			
		||||
        final ArrayList<ChunkLoc> empty = new ArrayList<>();
 | 
			
		||||
        getTrimRegions(empty, world, new Runnable() {
 | 
			
		||||
            public void run() {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ public class Trust extends SubCommand {
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -31,33 +31,25 @@ import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(command = "unclaim", usage = "/plot unclaim", requiredType = RequiredType.NONE, description = "Unclaim a plot", category = CommandCategory.ACTIONS)
 | 
			
		||||
/**
 | 
			
		||||
 * Unclaiming a plot makes no changes to the terrain or plot border and only removes the owner and should be regarded as an admin command. 
 | 
			
		||||
 */
 | 
			
		||||
@CommandDeclaration(command = "unclaim", usage = "/plot unclaim", requiredType = RequiredType.NONE, description = "Unclaim a plot (admin command)", category = CommandCategory.ACTIONS)
 | 
			
		||||
public class Unclaim extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.hasOwner()) {
 | 
			
		||||
            return !sendMessage(plr, C.PLOT_NOT_CLAIMED);
 | 
			
		||||
        }
 | 
			
		||||
        if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
 | 
			
		||||
            return !sendMessage(plr, C.UNLINK_REQUIRED);
 | 
			
		||||
        }
 | 
			
		||||
        if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) {
 | 
			
		||||
            return !sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
        }
 | 
			
		||||
        final PlotWorld pWorld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
        if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) {
 | 
			
		||||
            final double c = pWorld.SELL_PRICE;
 | 
			
		||||
            if (c > 0d) {
 | 
			
		||||
                EconHandler.manager.depositMoney(plr, c);
 | 
			
		||||
                sendMessage(plr, C.ADDED_BALANCE, c + "");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.unclaim()) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.UNCLAIM_SUCCESS);
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ public class Undeny extends SubCommand {
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -38,20 +38,23 @@ public class Unlink extends SubCommand {
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
 | 
			
		||||
        if (!plot.hasOwner()) {
 | 
			
		||||
            return !sendMessage(plr, C.PLOT_UNOWNED);
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
 | 
			
		||||
            return sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
 | 
			
		||||
        if (!plot.isMerged()) {
 | 
			
		||||
            return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
 | 
			
		||||
        }
 | 
			
		||||
        final Runnable runnable = new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (!MainUtil.unlinkPlot(plot, true)) {
 | 
			
		||||
                if (!MainUtil.unlinkPlot(plot, true, true)) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, "&cUnlink has been cancelled");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ public class Untrust extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer plr, final String[] args) {
 | 
			
		||||
        final Location loc = plr.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
@@ -170,7 +171,7 @@ public class list extends SubCommand {
 | 
			
		||||
                    match = null;
 | 
			
		||||
                }
 | 
			
		||||
                for (final Plot plot : PS.get().getPlots()) {
 | 
			
		||||
                    final Flag flag = plot.getSettings().flags.get("done");
 | 
			
		||||
                    final Flag flag = plot.getFlags().get("done");
 | 
			
		||||
                    if (flag == null) {
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
@@ -189,8 +190,8 @@ public class list extends SubCommand {
 | 
			
		||||
                Collections.sort(plots, new Comparator<Plot>() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public int compare(final Plot a, final Plot b) {
 | 
			
		||||
                        final String va = a.getSettings().flags.get("done").getValueString();
 | 
			
		||||
                        final String vb = b.getSettings().flags.get("done").getValueString();
 | 
			
		||||
                        final String va = a.getFlags().get("done").getValueString();
 | 
			
		||||
                        final String vb = b.getFlags().get("done").getValueString();
 | 
			
		||||
                        if (MathMan.isInteger(va)) {
 | 
			
		||||
                            if (MathMan.isInteger(vb)) {
 | 
			
		||||
                                return Integer.parseInt(vb) - Integer.parseInt(va);
 | 
			
		||||
@@ -332,6 +333,13 @@ public class list extends SubCommand {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void displayPlots(final PlotPlayer player, List<Plot> plots, final int pageSize, int page, final String world, final String[] args, final boolean sort) {
 | 
			
		||||
        int rawSize = plots.size();
 | 
			
		||||
        Iterator<Plot> iter = plots.iterator();
 | 
			
		||||
        while (iter.hasNext()) {
 | 
			
		||||
            if (!iter.next().isBasePlot()) {
 | 
			
		||||
                iter.remove();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (sort) {
 | 
			
		||||
            plots = PS.get().sortPlots(plots, SortType.DISTANCE_FROM_ORIGIN, world);
 | 
			
		||||
        }
 | 
			
		||||
@@ -351,17 +359,12 @@ public class list extends SubCommand {
 | 
			
		||||
        final List<Plot> subList = plots.subList(page * pageSize, max);
 | 
			
		||||
        
 | 
			
		||||
        // Header
 | 
			
		||||
        final String header = C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", plots.size() + "")
 | 
			
		||||
        final String header = C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", plots.size() + "/" + rawSize)
 | 
			
		||||
        .replaceAll("%word%", "all");
 | 
			
		||||
        MainUtil.sendMessage(player, header);
 | 
			
		||||
        
 | 
			
		||||
        int i = page * pageSize;
 | 
			
		||||
        for (final Plot plot : subList) {
 | 
			
		||||
            if (plot.getSettings().isMerged()) {
 | 
			
		||||
                if (!MainUtil.getBottomPlot(plot).equals(plot)) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            i++;
 | 
			
		||||
            String color;
 | 
			
		||||
            if (plot.owner == null) {
 | 
			
		||||
@@ -379,7 +382,7 @@ public class list extends SubCommand {
 | 
			
		||||
            
 | 
			
		||||
            final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.getMembers())))).color("$1");
 | 
			
		||||
            
 | 
			
		||||
            String strFlags = StringMan.join(plot.getSettings().flags.values(), ",");
 | 
			
		||||
            String strFlags = StringMan.join(plot.getFlags().values(), ",");
 | 
			
		||||
            if (strFlags.length() == 0) {
 | 
			
		||||
                strFlags = C.NONE.s();
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -283,6 +283,7 @@ public enum C {
 | 
			
		||||
    /*
 | 
			
		||||
     * Core Stuff
 | 
			
		||||
     */
 | 
			
		||||
    TASK_START("Starting task...", "Core"),
 | 
			
		||||
    PREFIX("$3[$1P2$3] $2", "Core"),
 | 
			
		||||
    ENABLED("$1PlotSquared is now enabled", "Core"),
 | 
			
		||||
    EXAMPLE_MESSAGE("$2This is an example message &k!!!", "Core"),
 | 
			
		||||
@@ -328,16 +329,20 @@ public enum C {
 | 
			
		||||
    CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user", "Permission"),
 | 
			
		||||
    CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once", "Permission"),
 | 
			
		||||
    YOU_BE_DENIED("$2You are not allowed to enter this plot", "Permission"),
 | 
			
		||||
    NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%", "Permission"),
 | 
			
		||||
    UNLINK_REQUIRED("$2An unlink is required to do this.", "Permission"),
 | 
			
		||||
    UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot", "Permission"),
 | 
			
		||||
    UNLINK_SUCCESS("$2Successfully unlinked plots.", "Permission"),
 | 
			
		||||
    NO_MERGE_TO_MEGA("$2Mega plots cannot be merged into. Please merge from the desired mega plot.", "Permission"),
 | 
			
		||||
    MERGE_NOT_VALID("$2This merge request is no longer valid.", "Permission"),
 | 
			
		||||
    MERGE_ACCEPTED("$2The merge request has been accepted", "Permission"),
 | 
			
		||||
    SUCCESS_MERGE("$2Plots have been merged!", "Permission"),
 | 
			
		||||
    MERGE_REQUESTED("$2Successfully sent a merge request", "Permission"),
 | 
			
		||||
    
 | 
			
		||||
    /*
 | 
			
		||||
     * Merge
 | 
			
		||||
     */
 | 
			
		||||
    MERGE_NOT_VALID("$2This merge request is no longer valid.", "Merge"),
 | 
			
		||||
    MERGE_ACCEPTED("$2The merge request has been accepted", "Merge"),
 | 
			
		||||
    SUCCESS_MERGE("$2Plots have been merged!", "Merge"),
 | 
			
		||||
    MERGE_REQUESTED("$2Successfully sent a merge request", "Merge"),
 | 
			
		||||
    MERGE_REQUEST_CONFIRM("merge request from %s", "Permission"),
 | 
			
		||||
    NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%", "Merge"),
 | 
			
		||||
    NO_AVAILABLE_AUTOMERGE("$2You do not own any adjacent plots in the specified direction.", "Merge"),
 | 
			
		||||
    UNLINK_REQUIRED("$2An unlink is required to do this.", "Merge"),
 | 
			
		||||
    UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot", "Merge"),
 | 
			
		||||
    UNLINK_SUCCESS("$2Successfully unlinked plots.", "Merge"),
 | 
			
		||||
    /*
 | 
			
		||||
     * Commands
 | 
			
		||||
     */
 | 
			
		||||
@@ -368,7 +373,6 @@ public enum C {
 | 
			
		||||
     * trim
 | 
			
		||||
     */
 | 
			
		||||
    TRIM_SYNTAX("Use /plot trim <all|x;y> <world>", "Trim"),
 | 
			
		||||
    TRIM_START("Starting a world trim task...", "Trim"),
 | 
			
		||||
    TRIM_IN_PROGRESS("A world trim task is already in progress!", "Trim"),
 | 
			
		||||
    NOT_VALID_HYBRID_PLOT_WORLD("The hybrid plot manager is required to perform this action", "Trim"),
 | 
			
		||||
    /*
 | 
			
		||||
 
 | 
			
		||||
@@ -212,10 +212,7 @@ public class Settings {
 | 
			
		||||
 | 
			
		||||
     */
 | 
			
		||||
    public static class DB {
 | 
			
		||||
        /**
 | 
			
		||||
         * MongoDB enabled?
 | 
			
		||||
         */
 | 
			
		||||
        public static boolean USE_MONGO = false; /*
 | 
			
		||||
        /**
 | 
			
		||||
         * MongoDB enabled?
 | 
			
		||||
         */
 | 
			
		||||
        public static boolean USE_MONGO = false;
 | 
			
		||||
 
 | 
			
		||||
@@ -151,6 +151,7 @@ public class DBFunc {
 | 
			
		||||
    public static void delete(final Plot plot) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.delete(plot);
 | 
			
		||||
        plot.temp = -1;
 | 
			
		||||
    }
 | 
			
		||||
@@ -399,7 +400,7 @@ public class DBFunc {
 | 
			
		||||
        dbManager.setDenied(plot, uuid);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static HashMap<UUID, Integer> getRatings(final Plot plot) {
 | 
			
		||||
    public static HashMap<UUID, Integer> getRatings(final Plot plot) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return new HashMap<>(0);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -763,11 +763,8 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                    }
 | 
			
		||||
                    stmt.setString((i * 10) + 8, flag_string.toString());
 | 
			
		||||
                }
 | 
			
		||||
                final boolean[] merged = pair.settings.getMerged();
 | 
			
		||||
                int n = 0;
 | 
			
		||||
                for (int j = 0; j < 4; ++j) {
 | 
			
		||||
                    n = (n << 1) + (merged[j] ? 1 : 0);
 | 
			
		||||
                }
 | 
			
		||||
                final boolean[] merged = pair.settings.getMerged();
 | 
			
		||||
                int hash = MainUtil.hash(merged);
 | 
			
		||||
                stmt.setInt((i * 10) + 9, hash);
 | 
			
		||||
                final BlockLoc loc = pair.settings.getPosition();
 | 
			
		||||
                String position;
 | 
			
		||||
@@ -1311,9 +1308,6 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
        return Integer.MAX_VALUE;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void updateTables() {
 | 
			
		||||
        
 | 
			
		||||
        // TODO task
 | 
			
		||||
    public void updateTables() {
 | 
			
		||||
        if (PS.get().getVersion().equals(PS.get().getLastVersion()) || (PS.get().getLastVersion() == null)) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -1646,11 +1640,8 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
        plot.getSettings().setMerged(merged);
 | 
			
		||||
        addPlotTask(plot, new UniqueStatement("setMerged") {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void set(final PreparedStatement stmt) throws SQLException {
 | 
			
		||||
                int n = 0;
 | 
			
		||||
                for (int i = 0; i < 4; ++i) {
 | 
			
		||||
                    n = (n << 1) + (merged[i] ? 1 : 0);
 | 
			
		||||
                }
 | 
			
		||||
            public void set(final PreparedStatement stmt) throws SQLException {
 | 
			
		||||
                int hash = MainUtil.hash(merged);
 | 
			
		||||
                stmt.setInt(1, hash);
 | 
			
		||||
                stmt.setInt(2, getId(plot));
 | 
			
		||||
            }
 | 
			
		||||
@@ -1702,12 +1693,13 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void set(final PreparedStatement stmt) throws SQLException {
 | 
			
		||||
                stmt.setInt(1, newPlot.id.x);
 | 
			
		||||
                stmt.setInt(2, newPlot.id.y);
 | 
			
		||||
                stmt.setInt(2, newPlot.id.y);
 | 
			
		||||
                stmt.setString(3, newPlot.world);
 | 
			
		||||
                stmt.setInt(4, getId(original));
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            @Override
 | 
			
		||||
            public PreparedStatement get() throws SQLException {
 | 
			
		||||
            public PreparedStatement get() throws SQLException {
 | 
			
		||||
                return connection.prepareStatement("UPDATE `" + prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ?, `world` = ? WHERE `id` = ?");
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 
 | 
			
		||||
@@ -45,10 +45,6 @@ import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 */
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
public class FlagManager {
 | 
			
		||||
    // TODO add some flags
 | 
			
		||||
    // - Plot clear interval
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
public class FlagManager {
 | 
			
		||||
    
 | 
			
		||||
@@ -108,7 +104,7 @@ public class FlagManager {
 | 
			
		||||
                flag.setKey(af);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (PS.get().getAllPlotsRaw() != null) {
 | 
			
		||||
        if (PS.get().getAllPlotsRaw() != null) {
 | 
			
		||||
            for (final Plot plot : PS.get().getPlotsRaw()) {
 | 
			
		||||
                final Flag flag = plot.getFlags().get(af.getKey());
 | 
			
		||||
                if (flag != null) {
 | 
			
		||||
@@ -204,14 +200,16 @@ public class FlagManager {
 | 
			
		||||
    /**
 | 
			
		||||
     * Add a flag to a plot
 | 
			
		||||
     * @param plot
 | 
			
		||||
     * @param flag
 | 
			
		||||
     */
 | 
			
		||||
     * @param flag
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean addPlotFlag(final Plot origin, final Flag flag) {
 | 
			
		||||
        final boolean result = EventUtil.manager.callFlagAdd(flag, origin);
 | 
			
		||||
        if (!result) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        plot.getSettings().flags.put(flag.getKey(), flag);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        for (Plot plot : MainUtil.getConnectedPlots(origin)) {
 | 
			
		||||
            plot.getFlags().put(flag.getKey(), flag);
 | 
			
		||||
            MainUtil.reEnterPlot(plot);
 | 
			
		||||
            DBFunc.setFlags(plot, plot.getFlags().values());
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -220,7 +218,7 @@ public class FlagManager {
 | 
			
		||||
    public static boolean addPlotFlagAbs(final Plot plot, final Flag flag) {
 | 
			
		||||
        final boolean result = EventUtil.manager.callFlagAdd(flag, plot);
 | 
			
		||||
        if (!result) {
 | 
			
		||||
            return false;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        plot.getFlags().put(flag.getKey(), flag);
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -270,17 +268,17 @@ public class FlagManager {
 | 
			
		||||
    public static HashMap<String, Flag> getSettingFlags(final String world, final PlotSettings settings) {
 | 
			
		||||
        return getPlotFlags(world, settings, false);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    public static boolean removePlotFlag(final Plot plot, final String id) {
 | 
			
		||||
        final Flag flag = plot.getFlags().remove(id);
 | 
			
		||||
        if (flag == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final boolean result = EventUtil.manager.callFlagRemove(flag, plot);
 | 
			
		||||
        final boolean result = EventUtil.manager.callFlagRemove(flag, plot);
 | 
			
		||||
        if (!result) {
 | 
			
		||||
            plot.getFlags().put(id, flag);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.reEnterPlot(plot);
 | 
			
		||||
        DBFunc.setFlags(plot, plot.getFlags().values());
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -298,19 +296,21 @@ public class FlagManager {
 | 
			
		||||
        }
 | 
			
		||||
        DBFunc.setFlags(cluster, cluster.settings.flags.values());
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void setPlotFlags(final Plot plot, final Set<Flag> flags) {
 | 
			
		||||
        if ((flags != null) && (flags.size() != 0)) {
 | 
			
		||||
            plot.getSettings().flags.clear();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void setPlotFlags(final Plot origin, final Set<Flag> flags) {
 | 
			
		||||
        for (Plot plot : origin.getConnectedPlots()) {
 | 
			
		||||
            if ((flags != null) && (flags.size() != 0)) {
 | 
			
		||||
                plot.getFlags().clear();
 | 
			
		||||
                for (final Flag flag : flags) {
 | 
			
		||||
                    plot.getFlags().put(flag.getKey(), flag);
 | 
			
		||||
                }
 | 
			
		||||
            } else if (plot.getFlags().size() == 0) {
 | 
			
		||||
                return;
 | 
			
		||||
            } else {
 | 
			
		||||
                plot.getSettings().flags.put(flag.getKey(), flag);
 | 
			
		||||
            }
 | 
			
		||||
        } else if (plot.getSettings().flags.size() == 0) {
 | 
			
		||||
            return;
 | 
			
		||||
                plot.getFlags().clear();
 | 
			
		||||
            }
 | 
			
		||||
            MainUtil.reEnterPlot(plot);
 | 
			
		||||
            plot.getSettings().flags.clear();
 | 
			
		||||
        }
 | 
			
		||||
            DBFunc.setFlags(plot, plot.getFlags().values());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PseudoRandom;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
 | 
			
		||||
 | 
			
		||||
@@ -26,6 +27,14 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
                setWallFilling(plotworld, plotid, blocks);
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            case "all": {
 | 
			
		||||
                setAir(plotworld, plotid, blocks);
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            case "outline": {
 | 
			
		||||
                setOutline(plotworld, plotid, blocks);
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            case "border": {
 | 
			
		||||
                setWall(plotworld, plotid, blocks);
 | 
			
		||||
                return true;
 | 
			
		||||
@@ -46,12 +55,81 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean setFloor(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
 | 
			
		||||
        Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
 | 
			
		||||
        if (plot.isBasePlot()) {
 | 
			
		||||
            final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
 | 
			
		||||
            for (RegionWrapper region : MainUtil.getRegions(plot)) {
 | 
			
		||||
                Location pos1 = new Location(plot.world, region.minX, dpw.PLOT_HEIGHT, region.minZ);
 | 
			
		||||
                Location pos2 = new Location(plot.world, region.maxX, dpw.PLOT_HEIGHT, region.maxZ);
 | 
			
		||||
                MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean setAir(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
 | 
			
		||||
        Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
 | 
			
		||||
        if (!plot.isBasePlot()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1, 0, 1);
 | 
			
		||||
        pos1.setY(dpw.PLOT_HEIGHT);
 | 
			
		||||
        pos2.setY(dpw.PLOT_HEIGHT + 1);
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
 | 
			
		||||
        for (RegionWrapper region : MainUtil.getRegions(plot)) {
 | 
			
		||||
            Location pos1 = new Location(plot.world, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
 | 
			
		||||
            Location pos2 = new Location(plot.world, region.maxX, 255, region.maxZ);
 | 
			
		||||
            MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean setOutline(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
 | 
			
		||||
        final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
 | 
			
		||||
        if (dpw.ROAD_WIDTH == 0) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
 | 
			
		||||
        final Location bottom = MainUtil.getPlotBottomLocAbs(plotworld.worldname, plotid);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc_(plot);
 | 
			
		||||
        final PseudoRandom random = new PseudoRandom();
 | 
			
		||||
        if (!plot.getMerged(0)) {
 | 
			
		||||
            int z = bottom.getZ();
 | 
			
		||||
            for (int x = bottom.getX(); x <= (top.getX()); x++) {
 | 
			
		||||
                for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.getMerged(3)) {
 | 
			
		||||
            int x = bottom.getX();
 | 
			
		||||
            for (int z = bottom.getZ(); z <= (top.getZ()); z++) {
 | 
			
		||||
                for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (!plot.getMerged(2)) {
 | 
			
		||||
            int z = top.getZ();
 | 
			
		||||
            for (int x = bottom.getX(); x <= (top.getX()); x++) {
 | 
			
		||||
                for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.getMerged(1)) {
 | 
			
		||||
            int x = top.getX();
 | 
			
		||||
            for (int z = bottom.getZ(); z <= (top.getZ()); z++) {
 | 
			
		||||
                for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.isBasePlot()) {
 | 
			
		||||
            for (RegionWrapper region : MainUtil.getRegions(plot)) {
 | 
			
		||||
                Location pos1 = new Location(plot.world, region.minX, 255, region.minZ);
 | 
			
		||||
                Location pos2 = new Location(plot.world, region.maxX, 255, region.maxZ);
 | 
			
		||||
                MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -60,32 +138,40 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        if (dpw.ROAD_WIDTH == 0) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1, 0, 1);
 | 
			
		||||
        int x, z;
 | 
			
		||||
        z = bottom.getZ();
 | 
			
		||||
        Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
 | 
			
		||||
        final Location bot = MainUtil.getPlotBottomLoc_(plot).subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc_(plot).add(1, 0, 1);
 | 
			
		||||
        final PseudoRandom random = new PseudoRandom();
 | 
			
		||||
        for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
 | 
			
		||||
            for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(0)) {
 | 
			
		||||
            int z = bot.getZ();
 | 
			
		||||
            for (int x = bot.getX(); x < (top.getX()); x++) {
 | 
			
		||||
                for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        x = top.getX();
 | 
			
		||||
        for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) {
 | 
			
		||||
            for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(3)) {
 | 
			
		||||
            int x = bot.getX();
 | 
			
		||||
            for (int z = bot.getZ(); z < (top.getZ()); z++) {
 | 
			
		||||
                for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        z = top.getZ();
 | 
			
		||||
        for (x = top.getX(); x >= (bottom.getX() + 1); x--) {
 | 
			
		||||
            for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(2)) {
 | 
			
		||||
            int z = top.getZ();
 | 
			
		||||
            for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) {
 | 
			
		||||
                for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        x = bottom.getX();
 | 
			
		||||
        for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) {
 | 
			
		||||
            for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(1)) {
 | 
			
		||||
            int x = top.getX();
 | 
			
		||||
            for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) {
 | 
			
		||||
                for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
 | 
			
		||||
                    SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -96,26 +182,34 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        if (dpw.ROAD_WIDTH == 0) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1, 0, 1);
 | 
			
		||||
        int x, z;
 | 
			
		||||
        z = bottom.getZ();
 | 
			
		||||
        Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
 | 
			
		||||
        final Location bot = MainUtil.getPlotBottomLoc_(plot).subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc_(plot).add(1, 0, 1);
 | 
			
		||||
        final PseudoRandom random = new PseudoRandom();
 | 
			
		||||
        final int y = dpw.WALL_HEIGHT + 1;
 | 
			
		||||
        for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
 | 
			
		||||
            SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(0)) {
 | 
			
		||||
            int z = bot.getZ();
 | 
			
		||||
            for (int x = bot.getX(); x < (top.getX()); x++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        x = top.getX();
 | 
			
		||||
        for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) {
 | 
			
		||||
            SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(3)) {
 | 
			
		||||
            int x = bot.getX();
 | 
			
		||||
            for (int z = bot.getZ(); z < (top.getZ()); z++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        z = top.getZ();
 | 
			
		||||
        for (x = top.getX(); x >= (bottom.getX() + 1); x--) {
 | 
			
		||||
            SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(2)) {
 | 
			
		||||
            int z = top.getZ();
 | 
			
		||||
            for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        x = bottom.getX();
 | 
			
		||||
        for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) {
 | 
			
		||||
            SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
        if (!plot.getMerged(1)) {
 | 
			
		||||
            int x = top.getX();
 | 
			
		||||
            for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) {
 | 
			
		||||
                SetBlockQueue.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
@@ -130,19 +224,18 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
 | 
			
		||||
        final int sx = pos2.getX() + 1;
 | 
			
		||||
        final int ex = (sx + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        final int sz = pos1.getZ() - 1;
 | 
			
		||||
        final int sz = pos1.getZ() - 2;
 | 
			
		||||
        final int ez = pos2.getZ() + 2;
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex + 1,
 | 
			
		||||
        257, ez), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7,
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), new PlotBlock((short) 7,
 | 
			
		||||
        (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 2, ez),
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, ez - 1),
 | 
			
		||||
        dpw.WALL_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, 1, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.WALL_HEIGHT + 2, ez),
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, ez - 1),
 | 
			
		||||
        dpw.WALL_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -153,18 +246,17 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
 | 
			
		||||
        final int sz = pos2.getZ() + 1;
 | 
			
		||||
        final int ez = (sz + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        final int sx = pos1.getX() - 1;
 | 
			
		||||
        final int sx = pos1.getX() - 2;
 | 
			
		||||
        final int ex = pos2.getX() + 2;
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 257,
 | 
			
		||||
        ez + 1), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), new Location(plotworld.worldname, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 2, sz + 1),
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), new Location(plotworld.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz),
 | 
			
		||||
        dpw.WALL_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, ez), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 2, ez + 1),
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, ez), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT, ez), dpw.WALL_FILLING);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(plotworld.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez),
 | 
			
		||||
        dpw.WALL_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -176,10 +268,10 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        final int ex = (sx + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        final int sz = pos2.getZ() + 1;
 | 
			
		||||
        final int ez = (sz + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex, 257, ez), new PlotBlock(
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock(
 | 
			
		||||
        (short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), new Location(plotworld.worldname, ex, 1, ez), new PlotBlock((short) 7, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), new Location(plotworld.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0));
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz + 1), new Location(plotworld.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -190,12 +282,11 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
 | 
			
		||||
        final int sx = pos2.getX() + 1;
 | 
			
		||||
        final int ex = (sx + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        final int sz = pos1.getZ();
 | 
			
		||||
        final int sz = pos1.getZ() - 1;
 | 
			
		||||
        final int ez = pos2.getZ() + 1;
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex + 1, 257,
 | 
			
		||||
        ez + 1), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT, ez), dpw.MAIN_BLOCK);
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz + 1), new Location(plotworld.worldname, ex + 1, dpw.PLOT_HEIGHT + 1, ez), dpw.TOP_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.PLOT_HEIGHT, sz + 1), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -206,12 +297,11 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
 | 
			
		||||
        final int sz = pos2.getZ() + 1;
 | 
			
		||||
        final int ez = (sz + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        final int sx = pos1.getX();
 | 
			
		||||
        final int sx = pos1.getX() - 1;
 | 
			
		||||
        final int ex = pos2.getX() + 1;
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex + 1, 257,
 | 
			
		||||
        ez + 1), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.PLOT_HEIGHT, sz), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.PLOT_HEIGHT, sz), new Location(plotworld.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -223,10 +313,9 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
        final int ex = (sx + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        final int sz = loc.getZ() + 1;
 | 
			
		||||
        final int ez = (sz + dpw.ROAD_WIDTH) - 1;
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(plotworld.worldname, ex + 1, 257, ez + 1), new PlotBlock(
 | 
			
		||||
        (short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex + 1, dpw.ROAD_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz), new Location(plotworld.worldname, ex + 1, dpw.ROAD_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
 | 
			
		||||
        MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
 | 
			
		||||
        MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -235,11 +324,12 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
 | 
			
		||||
        final PlotId pos1 = plotIds.get(0);
 | 
			
		||||
        final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
 | 
			
		||||
        final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
 | 
			
		||||
        if ((block.id != 0) || !block.equals(unclaim)) {
 | 
			
		||||
            setWall(plotworld, pos1, new PlotBlock[] { block });
 | 
			
		||||
            for (final PlotId id : plotIds) {
 | 
			
		||||
                setWall(plotworld, id, new PlotBlock[] { block });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
@@ -278,16 +368,17 @@ public class ClassicPlotManager extends SquarePlotManager {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid) {
 | 
			
		||||
        return new String[] { "floor", "wall", "border" };
 | 
			
		||||
        return new String[] { "floor", "wall", "border", "all", "outline" };
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Remove sign for a plot
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public Location getSignLoc(final PlotWorld plotworld, final Plot plot) {
 | 
			
		||||
    public Location getSignLoc(final PlotWorld plotworld, Plot plot) {
 | 
			
		||||
        final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
 | 
			
		||||
        final Location bot = MainUtil.getPlotBottomLoc(plotworld.worldname, plot.id);
 | 
			
		||||
        return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getX(), dpw.ROAD_HEIGHT + 1, bot.getZ() - 1);
 | 
			
		||||
        plot = plot.getBasePlot(false);
 | 
			
		||||
        final Location bot = plot.getBottomAbs();
 | 
			
		||||
        return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -171,8 +171,8 @@ public class HybridPlotManager extends ClassicPlotManager {
 | 
			
		||||
        final String world = plotworld.worldname;
 | 
			
		||||
        final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
 | 
			
		||||
        
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc_(plot);
 | 
			
		||||
        // If augmented
 | 
			
		||||
        final boolean canRegen = (plotworld.TYPE == 0) && (plotworld.TERRAIN == 0);
 | 
			
		||||
        // The component blocks
 | 
			
		||||
@@ -198,7 +198,7 @@ public class HybridPlotManager extends ClassicPlotManager {
 | 
			
		||||
                MainUtil.setBiome(world, value[2], value[3], value[4], value[5], dpw.PLOT_BIOME);
 | 
			
		||||
                // These two locations are for each component (e.g. bedrock, main block, floor, air)
 | 
			
		||||
                final Location bot = new Location(world, value[2], 0, value[3]);
 | 
			
		||||
                final Location top = new Location(world, value[4] + 1, 1, value[5] + 1);
 | 
			
		||||
                final Location top = new Location(world, value[4], 1, value[5]);
 | 
			
		||||
                MainUtil.setCuboidAsync(world, bot, top, bedrock);
 | 
			
		||||
                // Each component has a different layer
 | 
			
		||||
                bot.setY(1);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,21 @@
 | 
			
		||||
package com.intellectualcrafters.plot.generator;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.ArrayDeque;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.jnbt.CompoundTag;
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.Flag;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.FlagManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
@@ -18,6 +25,7 @@ import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RunnableVal;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
@@ -29,12 +37,78 @@ public abstract class HybridUtils {
 | 
			
		||||
    
 | 
			
		||||
    public static HybridUtils manager;
 | 
			
		||||
    
 | 
			
		||||
    public abstract void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone);
 | 
			
		||||
    public abstract void analyzeRegion(final String world, final RegionWrapper region, final RunnableVal<PlotAnalysis> whenDone);
 | 
			
		||||
    
 | 
			
		||||
    public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) {
 | 
			
		||||
        final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(MainUtil.getRegions(origin));
 | 
			
		||||
        final ArrayList<PlotAnalysis> analysis = new ArrayList<>();
 | 
			
		||||
        Runnable run = new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (zones.size() == 0) {
 | 
			
		||||
                    if (analysis.size() > 0) {
 | 
			
		||||
                        whenDone.value = new PlotAnalysis();
 | 
			
		||||
                        for (PlotAnalysis data : analysis) {
 | 
			
		||||
                            whenDone.value.air += data.air;
 | 
			
		||||
                            whenDone.value.air_sd += data.air_sd;
 | 
			
		||||
                            whenDone.value.changes += data.changes;
 | 
			
		||||
                            whenDone.value.changes_sd += data.changes_sd;
 | 
			
		||||
                            whenDone.value.data += data.data;
 | 
			
		||||
                            whenDone.value.data_sd += data.data_sd;
 | 
			
		||||
                            whenDone.value.faces += data.faces;
 | 
			
		||||
                            whenDone.value.faces_sd += data.faces_sd;
 | 
			
		||||
                            whenDone.value.variety += data.variety;
 | 
			
		||||
                            whenDone.value.variety_sd += data.variety_sd;
 | 
			
		||||
                        }
 | 
			
		||||
                        whenDone.value.air /= analysis.size();
 | 
			
		||||
                        whenDone.value.air_sd /= analysis.size();
 | 
			
		||||
                        whenDone.value.changes /= analysis.size();
 | 
			
		||||
                        whenDone.value.changes_sd /= analysis.size();
 | 
			
		||||
                        whenDone.value.data /= analysis.size();
 | 
			
		||||
                        whenDone.value.data_sd /= analysis.size();
 | 
			
		||||
                        whenDone.value.faces /= analysis.size();
 | 
			
		||||
                        whenDone.value.faces_sd /= analysis.size();
 | 
			
		||||
                        whenDone.value.variety /= analysis.size();
 | 
			
		||||
                        whenDone.value.variety_sd /= analysis.size();
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        whenDone.value = analysis.get(0);
 | 
			
		||||
                    }
 | 
			
		||||
                    final List<Integer> result = new ArrayList<>();
 | 
			
		||||
                    result.add(whenDone.value.changes);
 | 
			
		||||
                    result.add(whenDone.value.faces);
 | 
			
		||||
                    result.add(whenDone.value.data);
 | 
			
		||||
                    result.add(whenDone.value.air);
 | 
			
		||||
                    result.add(whenDone.value.variety);
 | 
			
		||||
                    
 | 
			
		||||
                    result.add(whenDone.value.changes_sd);
 | 
			
		||||
                    result.add(whenDone.value.faces_sd);
 | 
			
		||||
                    result.add(whenDone.value.data_sd);
 | 
			
		||||
                    result.add(whenDone.value.air_sd);
 | 
			
		||||
                    result.add(whenDone.value.variety_sd);
 | 
			
		||||
                    final Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
 | 
			
		||||
                    FlagManager.addPlotFlag(origin, flag);
 | 
			
		||||
                    TaskManager.runTask(whenDone);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                RegionWrapper region = zones.poll();
 | 
			
		||||
                final Runnable task = this;
 | 
			
		||||
                analyzeRegion(origin.world, region, new RunnableVal<PlotAnalysis>() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        analysis.add(value);
 | 
			
		||||
                        TaskManager.runTaskLater(task, 1);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        run.run();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
 | 
			
		||||
    
 | 
			
		||||
    public static List<ChunkLoc> regions;
 | 
			
		||||
    public static List<ChunkLoc> chunks = new ArrayList<>();
 | 
			
		||||
    public static Set<ChunkLoc> regions;
 | 
			
		||||
    public static Set<ChunkLoc> chunks = new HashSet<>();
 | 
			
		||||
    public static String world;
 | 
			
		||||
    public static boolean UPDATE = false;
 | 
			
		||||
    
 | 
			
		||||
@@ -50,12 +124,15 @@ public abstract class HybridUtils {
 | 
			
		||||
        return chunks;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks all connected plots
 | 
			
		||||
     * @param plot
 | 
			
		||||
     * @param whenDone
 | 
			
		||||
     */
 | 
			
		||||
    public void checkModified(final Plot plot, final RunnableVal<Integer> whenDone) {
 | 
			
		||||
        if (whenDone == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
        if (!(plotworld instanceof ClassicPlotWorld)) {
 | 
			
		||||
            whenDone.value = -1;
 | 
			
		||||
@@ -64,25 +141,36 @@ public abstract class HybridUtils {
 | 
			
		||||
        }
 | 
			
		||||
        whenDone.value = 0;
 | 
			
		||||
        final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
 | 
			
		||||
        ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
 | 
			
		||||
        final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(MainUtil.getRegions(plot));
 | 
			
		||||
        Runnable run = new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                final ChunkLoc loc = new ChunkLoc(value[0], value[1]);
 | 
			
		||||
                ChunkManager.manager.loadChunk(plot.world, loc, false);
 | 
			
		||||
                final int bx = value[2];
 | 
			
		||||
                final int bz = value[3];
 | 
			
		||||
                final int ex = value[4];
 | 
			
		||||
                final int ez = value[5];
 | 
			
		||||
                whenDone.value += checkModified(plot.world, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK);
 | 
			
		||||
                whenDone.value += checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK);
 | 
			
		||||
                whenDone.value += checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) });
 | 
			
		||||
                if (zones.size() == 0) {
 | 
			
		||||
                    
 | 
			
		||||
                    TaskManager.runTask(whenDone);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                RegionWrapper region = zones.poll();
 | 
			
		||||
                Location pos1 = new Location(plot.world, region.minX, region.minY, region.minZ);
 | 
			
		||||
                Location pos2 = new Location(plot.world, region.maxX, region.maxY, region.maxZ);
 | 
			
		||||
                ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        final ChunkLoc loc = new ChunkLoc(value[0], value[1]);
 | 
			
		||||
                        ChunkManager.manager.loadChunk(plot.world, loc, false);
 | 
			
		||||
                        final int bx = value[2];
 | 
			
		||||
                        final int bz = value[3];
 | 
			
		||||
                        final int ex = value[4];
 | 
			
		||||
                        final int ez = value[5];
 | 
			
		||||
                        whenDone.value += checkModified(plot.world, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK);
 | 
			
		||||
                        whenDone.value += checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK);
 | 
			
		||||
                        whenDone.value += checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) });
 | 
			
		||||
                    }
 | 
			
		||||
                }, this, 5);
 | 
			
		||||
                
 | 
			
		||||
            }
 | 
			
		||||
        }, new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                TaskManager.runTask(whenDone);
 | 
			
		||||
            }
 | 
			
		||||
        }, 5);
 | 
			
		||||
        };
 | 
			
		||||
        run.run();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean scheduleRoadUpdate(final String world, final int extend) {
 | 
			
		||||
@@ -90,14 +178,14 @@ public abstract class HybridUtils {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        HybridUtils.UPDATE = true;
 | 
			
		||||
        final List<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(world);
 | 
			
		||||
        final Set<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(world);
 | 
			
		||||
        return scheduleRoadUpdate(world, regions, extend);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean scheduleRoadUpdate(final String world, final List<ChunkLoc> rgs, final int extend) {
 | 
			
		||||
    public boolean scheduleRoadUpdate(final String world, final Set<ChunkLoc> rgs, final int extend) {
 | 
			
		||||
        HybridUtils.regions = rgs;
 | 
			
		||||
        HybridUtils.world = world;
 | 
			
		||||
        chunks = new ArrayList<ChunkLoc>();
 | 
			
		||||
        chunks = new HashSet<ChunkLoc>();
 | 
			
		||||
        final AtomicInteger count = new AtomicInteger(0);
 | 
			
		||||
        final long baseTime = System.currentTimeMillis();
 | 
			
		||||
        final AtomicInteger last = new AtomicInteger();
 | 
			
		||||
@@ -106,9 +194,10 @@ public abstract class HybridUtils {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (UPDATE == false) {
 | 
			
		||||
                    last.set(0);
 | 
			
		||||
                    while (chunks.size() > 0) {
 | 
			
		||||
                        final ChunkLoc chunk = chunks.get(0);
 | 
			
		||||
                        chunks.remove(0);
 | 
			
		||||
                    Iterator<ChunkLoc> iter = chunks.iterator();
 | 
			
		||||
                    while (iter.hasNext()) {
 | 
			
		||||
                        final ChunkLoc chunk = iter.next();
 | 
			
		||||
                        iter.remove();
 | 
			
		||||
                        regenerateRoad(world, chunk, extend);
 | 
			
		||||
                        ChunkManager.manager.unloadChunk(world, chunk, true, true);
 | 
			
		||||
                    }
 | 
			
		||||
@@ -135,11 +224,12 @@ public abstract class HybridUtils {
 | 
			
		||||
                                }
 | 
			
		||||
                                if (chunks.size() < 1024) {
 | 
			
		||||
                                    if (regions.size() > 0) {
 | 
			
		||||
                                        final ChunkLoc loc = regions.get(0);
 | 
			
		||||
                                        Iterator<ChunkLoc> iter = regions.iterator();
 | 
			
		||||
                                        final ChunkLoc loc = iter.next();
 | 
			
		||||
                                        iter.remove();
 | 
			
		||||
                                        PS.debug("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
 | 
			
		||||
                                        PS.debug(" - Remaining: " + regions.size());
 | 
			
		||||
                                        chunks.addAll(getChunks(loc));
 | 
			
		||||
                                        regions.remove(0);
 | 
			
		||||
                                        System.gc();
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
@@ -148,8 +238,9 @@ public abstract class HybridUtils {
 | 
			
		||||
                                    if (((System.currentTimeMillis() - baseTime - last.get()) > 2000) && (last.get() != 0)) {
 | 
			
		||||
                                        last.set(0);
 | 
			
		||||
                                        PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
 | 
			
		||||
                                        final ChunkLoc chunk = chunks.get(0);
 | 
			
		||||
                                        chunks.remove(0);
 | 
			
		||||
                                        Iterator<ChunkLoc> iter = chunks.iterator();
 | 
			
		||||
                                        final ChunkLoc chunk = iter.next();
 | 
			
		||||
                                        iter.remove();
 | 
			
		||||
                                        TaskManager.runTask(new Runnable() {
 | 
			
		||||
                                            @Override
 | 
			
		||||
                                            public void run() {
 | 
			
		||||
@@ -162,8 +253,9 @@ public abstract class HybridUtils {
 | 
			
		||||
                                    }
 | 
			
		||||
                                    if ((((System.currentTimeMillis() - baseTime) - last.get()) < 1500) && (last.get() != 0)) {
 | 
			
		||||
                                        while ((System.currentTimeMillis() < diff) && (chunks.size() > 0)) {
 | 
			
		||||
                                            final ChunkLoc chunk = chunks.get(0);
 | 
			
		||||
                                            chunks.remove(0);
 | 
			
		||||
                                            Iterator<ChunkLoc> iter = chunks.iterator();
 | 
			
		||||
                                            final ChunkLoc chunk = iter.next();
 | 
			
		||||
                                            iter.remove();
 | 
			
		||||
                                            TaskManager.runTask(new Runnable() {
 | 
			
		||||
                                                @Override
 | 
			
		||||
                                                public void run() {
 | 
			
		||||
@@ -176,7 +268,9 @@ public abstract class HybridUtils {
 | 
			
		||||
                                }
 | 
			
		||||
                            } catch (final Exception e) {
 | 
			
		||||
                                e.printStackTrace();
 | 
			
		||||
                                final ChunkLoc loc = regions.get(0);
 | 
			
		||||
                                Iterator<ChunkLoc> iter = regions.iterator();
 | 
			
		||||
                                final ChunkLoc loc = iter.next();
 | 
			
		||||
                                iter.remove();
 | 
			
		||||
                                PS.debug("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
 | 
			
		||||
                                final int sx = loc.x << 5;
 | 
			
		||||
                                final int sz = loc.z << 5;
 | 
			
		||||
@@ -204,8 +298,8 @@ public abstract class HybridUtils {
 | 
			
		||||
    
 | 
			
		||||
    public boolean setupRoadSchematic(final Plot plot) {
 | 
			
		||||
        final String world = plot.world;
 | 
			
		||||
        final Location bot = MainUtil.getPlotBottomLoc(world, plot.id);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLoc(world, plot.id);
 | 
			
		||||
        final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1);
 | 
			
		||||
        final Location top = MainUtil.getPlotTopLocAbs(world, plot.id);
 | 
			
		||||
        final HybridPlotWorld plotworld = (HybridPlotWorld) PS.get().getPlotWorld(world);
 | 
			
		||||
        final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1;
 | 
			
		||||
        final int sz = bot.getZ() + 1;
 | 
			
		||||
@@ -221,14 +315,18 @@ public abstract class HybridUtils {
 | 
			
		||||
        final int tx = ex;
 | 
			
		||||
        final int tz = sz - 1;
 | 
			
		||||
        final int ty = get_ey(world, bx, tx, bz, tz, by);
 | 
			
		||||
        
 | 
			
		||||
        final Set<RegionWrapper> sideroad = new HashSet<>(Arrays.asList(new RegionWrapper(sx, ex, sz, ez)));
 | 
			
		||||
        final Set<RegionWrapper> intersection = new HashSet<>(Arrays.asList(new RegionWrapper(bx, tx, bz, tz)));
 | 
			
		||||
        
 | 
			
		||||
        final Location pos3 = new Location(world, bx, by, bz);
 | 
			
		||||
        final Location pos4 = new Location(world, tx, ty, tz);
 | 
			
		||||
        final String dir = PS.get().IMP.getDirectory() + File.separator + "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.world + File.separator;
 | 
			
		||||
        SchematicHandler.manager.getCompoundTag(world, pos1, pos2, new RunnableVal<CompoundTag>() {
 | 
			
		||||
        SchematicHandler.manager.getCompoundTag(world, sideroad, new RunnableVal<CompoundTag>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                SchematicHandler.manager.save(value, dir + "sideroad.schematic");
 | 
			
		||||
                SchematicHandler.manager.getCompoundTag(world, pos3, pos4, new RunnableVal<CompoundTag>() {
 | 
			
		||||
                SchematicHandler.manager.getCompoundTag(world, intersection, new RunnableVal<CompoundTag>() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        SchematicHandler.manager.save(value, dir + "intersection.schematic");
 | 
			
		||||
@@ -272,14 +370,14 @@ public abstract class HybridUtils {
 | 
			
		||||
            final boolean result = ChunkManager.manager.loadChunk(world, chunk, false);
 | 
			
		||||
            if (result) {
 | 
			
		||||
                if (id1 != null) {
 | 
			
		||||
                    final Plot p1 = MainUtil.getPlot(world, id1);
 | 
			
		||||
                    if ((p1 != null) && p1.hasOwner() && p1.getSettings().isMerged()) {
 | 
			
		||||
                    final Plot p1 = MainUtil.getPlotAbs(world, id1);
 | 
			
		||||
                    if ((p1 != null) && p1.hasOwner() && p1.isMerged()) {
 | 
			
		||||
                        toCheck = true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if ((id2 != null) && !toCheck) {
 | 
			
		||||
                    final Plot p2 = MainUtil.getPlot(world, id2);
 | 
			
		||||
                    if ((p2 != null) && p2.hasOwner() && p2.getSettings().isMerged()) {
 | 
			
		||||
                    final Plot p2 = MainUtil.getPlotAbs(world, id2);
 | 
			
		||||
                    if ((p2 != null) && p2.hasOwner() && p2.isMerged()) {
 | 
			
		||||
                        toCheck = true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,17 @@
 | 
			
		||||
package com.intellectualcrafters.plot.generator;
 | 
			
		||||
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A plot manager with a square grid layout, with square shaped plots
 | 
			
		||||
@@ -14,9 +19,23 @@ import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final Runnable whenDone) {
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
 | 
			
		||||
        ChunkManager.manager.regenerateRegion(pos1, pos2, whenDone);
 | 
			
		||||
        final HashSet<RegionWrapper> regions = MainUtil.getRegions(plot);
 | 
			
		||||
        Runnable run = new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (regions.size() == 0) {
 | 
			
		||||
                    whenDone.run();
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                Iterator<RegionWrapper> iter = regions.iterator();
 | 
			
		||||
                RegionWrapper region = iter.next();
 | 
			
		||||
                iter.remove();
 | 
			
		||||
                Location pos1 = new Location(plot.world, region.minX, region.minY, region.minZ);
 | 
			
		||||
                Location pos2 = new Location(plot.world, region.maxX, region.maxY, region.maxZ);
 | 
			
		||||
                ChunkManager.manager.regenerateRegion(pos1, pos2, this);
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        run.run();
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -33,8 +52,12 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
    @Override
 | 
			
		||||
    public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, final int y, int z) {
 | 
			
		||||
        final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
 | 
			
		||||
        x -= dpw.ROAD_OFFSET_X;
 | 
			
		||||
        z -= dpw.ROAD_OFFSET_Z;
 | 
			
		||||
        if (dpw.ROAD_OFFSET_X != 0) {
 | 
			
		||||
            x -= dpw.ROAD_OFFSET_X;
 | 
			
		||||
        }
 | 
			
		||||
        if (dpw.ROAD_OFFSET_Z != 0) {
 | 
			
		||||
            z -= dpw.ROAD_OFFSET_Z;
 | 
			
		||||
        }
 | 
			
		||||
        int pathWidthLower;
 | 
			
		||||
        int end;
 | 
			
		||||
        if (dpw.ROAD_WIDTH == 0) {
 | 
			
		||||
@@ -65,12 +88,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
            idz = (z / size) + 1;
 | 
			
		||||
            z = (z % size);
 | 
			
		||||
        }
 | 
			
		||||
        final boolean northSouth = (z <= pathWidthLower) || (z > end);
 | 
			
		||||
        final boolean eastWest = (x <= pathWidthLower) || (x > end);
 | 
			
		||||
        if (northSouth || eastWest) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return new PlotId(idx, idz);
 | 
			
		||||
        return ((z <= pathWidthLower) || (z > end) || (x <= pathWidthLower) || (x > end)) ? null : new PlotId(idx, idz);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -113,53 +131,46 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
            dz = (z / size) + 1;
 | 
			
		||||
            rz = (z % size);
 | 
			
		||||
        }
 | 
			
		||||
        final boolean northSouth = (rz <= pathWidthLower) || (rz > end);
 | 
			
		||||
        final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
 | 
			
		||||
        if (northSouth && eastWest) {
 | 
			
		||||
            // This means you are in the intersection
 | 
			
		||||
            final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH + dpw.ROAD_OFFSET_X, 0, z + dpw.ROAD_WIDTH + dpw.ROAD_OFFSET_Z);
 | 
			
		||||
            final PlotId id = MainUtil.getPlotAbs(loc);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            if ((plot.getMerged(0) && plot.getMerged(3))) {
 | 
			
		||||
                return MainUtil.getBottomPlot(plot).id;
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (northSouth) {
 | 
			
		||||
            // You are on a road running West to East (yeah, I named the var poorly)
 | 
			
		||||
            final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_OFFSET_X, 0, z + dpw.ROAD_WIDTH + dpw.ROAD_OFFSET_Z);
 | 
			
		||||
            final PlotId id = MainUtil.getPlotAbs(loc);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            if (plot.getMerged(0)) {
 | 
			
		||||
                return MainUtil.getBottomPlot(plot).id;
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (eastWest) {
 | 
			
		||||
            // This is the road separating an Eastern and Western plot
 | 
			
		||||
            final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH + dpw.ROAD_OFFSET_X, 0, z + dpw.ROAD_OFFSET_Z);
 | 
			
		||||
            final PlotId id = MainUtil.getPlotAbs(loc);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            if (plot.getMerged(3)) {
 | 
			
		||||
                return MainUtil.getBottomPlot(plot).id;
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        final PlotId id = new PlotId(dx, dz);
 | 
			
		||||
        final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
        PlotId id = new PlotId(dx, dz);
 | 
			
		||||
        boolean[] merged = new boolean[] {(rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower)};
 | 
			
		||||
        int hash = MainUtil.hash(merged);
 | 
			
		||||
        // Not merged, and no need to check if it is
 | 
			
		||||
        if (hash == 0) {
 | 
			
		||||
            return id;
 | 
			
		||||
        }
 | 
			
		||||
        return MainUtil.getBottomPlot(plot).id;
 | 
			
		||||
        Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
        // Not merged, and standing on road
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        switch (hash) {
 | 
			
		||||
            case 8:
 | 
			
		||||
                // north
 | 
			
		||||
                return plot.getMerged(0) ? id : null;
 | 
			
		||||
            case 4:
 | 
			
		||||
                // east
 | 
			
		||||
                return plot.getMerged(1) ? id : null;
 | 
			
		||||
            case 2:
 | 
			
		||||
                // south
 | 
			
		||||
                return plot.getMerged(2) ? id : null;
 | 
			
		||||
            case 1:
 | 
			
		||||
                // west
 | 
			
		||||
                return plot.getMerged(3) ? id : null;
 | 
			
		||||
            case 12:
 | 
			
		||||
                // northest
 | 
			
		||||
                return plot.getMerged(4) ? id : null;
 | 
			
		||||
            case 6:
 | 
			
		||||
                // southeast
 | 
			
		||||
                return plot.getMerged(5) ? id : null;
 | 
			
		||||
            case 3:
 | 
			
		||||
                // southwest
 | 
			
		||||
                return plot.getMerged(6) ? id : null;
 | 
			
		||||
            case 9:
 | 
			
		||||
                // northwest
 | 
			
		||||
                return plot.getMerged(7) ? id : null;
 | 
			
		||||
        }
 | 
			
		||||
        PS.debug("invalid location: " + merged);
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
@@ -170,8 +181,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
        final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
 | 
			
		||||
        final int px = plotid.x;
 | 
			
		||||
        final int pz = plotid.y;
 | 
			
		||||
        final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
 | 
			
		||||
        final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
 | 
			
		||||
        final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2));
 | 
			
		||||
        final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2));
 | 
			
		||||
        return new Location(plotworld.worldname, x, plotworld.MIN_BUILD_HEIGHT, z);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -32,4 +32,9 @@ public class ChunkLoc {
 | 
			
		||||
        final ChunkLoc other = (ChunkLoc) obj;
 | 
			
		||||
        return ((x == other.x) && (z == other.z));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return x + "," + z;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.object;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
@@ -38,6 +39,7 @@ import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.database.DBFunc;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.Flag;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.FlagManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BO3Handler;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
@@ -131,7 +133,8 @@ public class Plot {
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for a new plot<br>
 | 
			
		||||
     * (Only changes after plot.create() will be properly set in the database)
 | 
			
		||||
     * (Only changes after plot.create() will be properly set in the database)
 | 
			
		||||
     *
 | 
			
		||||
     * @see Plot#getPlot(String, PlotId) for existing plots
 | 
			
		||||
     * @see Plot#getPlot(Location) for existing plots
 | 
			
		||||
     *
 | 
			
		||||
@@ -143,6 +146,20 @@ public class Plot {
 | 
			
		||||
        this.world = world;
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.owner = owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for an unowned plot<br>
 | 
			
		||||
     * (Only changes after plot.create() will be properly set in the database)
 | 
			
		||||
     *
 | 
			
		||||
     * @see Plot#getPlot(String, PlotId) for existing plots
 | 
			
		||||
     *
 | 
			
		||||
     * @param world
 | 
			
		||||
     * @param id
 | 
			
		||||
     */
 | 
			
		||||
    public Plot(final String world, final PlotId id) {
 | 
			
		||||
        this.world = world;
 | 
			
		||||
        this.id = id;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
@@ -173,7 +190,7 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for a temporary plot (use -1 for temp)<br>
 | 
			
		||||
     * The database will ignore any queries regarding temporary plots.
 | 
			
		||||
     * Please note that some bulk plot management functions may still affect temporary plots (TODO: fix this)
 | 
			
		||||
     * Please note that some bulk plot management functions may still affect temporary plots (TODO: fix this)
 | 
			
		||||
     *
 | 
			
		||||
     * @see Plot#getPlot(String, PlotId) for existing plots
 | 
			
		||||
     *
 | 
			
		||||
@@ -190,7 +207,7 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for a saved plots (Used by the database manager when plots are fetched)
 | 
			
		||||
     * Constructor for a saved plots (Used by the database manager when plots are fetched)
 | 
			
		||||
     *
 | 
			
		||||
     * @see Plot#getPlot(String, PlotId) for existing plots
 | 
			
		||||
     *
 | 
			
		||||
@@ -203,7 +220,7 @@ public class Plot {
 | 
			
		||||
    public Plot(final PlotId id, final UUID owner, final HashSet<UUID> trusted, final HashSet<UUID> members, final HashSet<UUID> denied, final String alias, final BlockLoc position,
 | 
			
		||||
    final Collection<Flag> flags, final String world, final boolean[] merged, final long timestamp, final int temp) {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.world = world;
 | 
			
		||||
        this.world = world;
 | 
			
		||||
        this.owner = owner;
 | 
			
		||||
        settings = new PlotSettings();
 | 
			
		||||
        this.members = members;
 | 
			
		||||
@@ -354,20 +371,32 @@ public class Plot {
 | 
			
		||||
    public PlotId getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the plot world object for this plot<br>
 | 
			
		||||
     *  - The generic PlotWorld object can be casted to it's respective class for more control
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
     * @return PlotWorld
 | 
			
		||||
     */
 | 
			
		||||
    public PlotWorld getWorld() {
 | 
			
		||||
        return PS.get().getPlotWorld(world);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the plot manager object for this plot<br>
 | 
			
		||||
     *  - The generic PlotManager object can be casted to it's respective class for more control
 | 
			
		||||
     * @return PlotManager
 | 
			
		||||
     */
 | 
			
		||||
    public PlotManager getManager() {
 | 
			
		||||
        return PS.get().getPlotManager(world);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get or create plot settings
 | 
			
		||||
     * @return PlotSettings
 | 
			
		||||
     * @deprecated use equivalent plot method;
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public PlotSettings getSettings() {
 | 
			
		||||
    public PlotSettings getSettings() {
 | 
			
		||||
        if (settings == null) {
 | 
			
		||||
            settings = new PlotSettings();
 | 
			
		||||
        }
 | 
			
		||||
@@ -377,10 +406,54 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if the plot is not merged, or it is the base plot of multiple merged plots
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isBasePlot() {
 | 
			
		||||
        if (settings == null || !isMerged()) {
 | 
			
		||||
            return true;
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return equals(getBasePlot(false));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * The cached origin plot<br>
 | 
			
		||||
     *  - The origin plot is used for plot grouping and relational data
 | 
			
		||||
     */
 | 
			
		||||
    private Plot origin;
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * The base plot is an arbitrary but specific connected plot. It is useful for the following:<br>
 | 
			
		||||
     *  - Merged plots need to be treated as a single plot for most purposes<br>
 | 
			
		||||
     *  - Some data such as home location needs to be associated with the group rather than each plot<br>
 | 
			
		||||
     *  - If the plot is not merged it will return itself.<br>
 | 
			
		||||
     *  - The result is cached locally
 | 
			
		||||
     * @return base Plot
 | 
			
		||||
     */
 | 
			
		||||
    public Plot getBasePlot(boolean recalculate) {
 | 
			
		||||
        if ((origin != null && !recalculate)) {
 | 
			
		||||
            return origin;
 | 
			
		||||
        }
 | 
			
		||||
        if (!isMerged()) {
 | 
			
		||||
            origin = this;
 | 
			
		||||
            return origin;
 | 
			
		||||
        }
 | 
			
		||||
        int min = Integer.MAX_VALUE;
 | 
			
		||||
        for (Plot plot : MainUtil.getConnectedPlots(this)) {
 | 
			
		||||
            if (plot.temp != -1) {
 | 
			
		||||
                if (plot.temp < min) {
 | 
			
		||||
                    min = plot.temp;
 | 
			
		||||
                    origin = plot;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                if (plot.hashCode() < min) {
 | 
			
		||||
                    origin = plot;
 | 
			
		||||
                    min = plot.hashCode();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        for (Plot plot : MainUtil.getConnectedPlots(this)) {
 | 
			
		||||
            plot.origin = origin;
 | 
			
		||||
        }
 | 
			
		||||
        return origin;
 | 
			
		||||
    }
 | 
			
		||||
@@ -414,7 +487,25 @@ public class Plot {
 | 
			
		||||
     */
 | 
			
		||||
    public boolean getMerged(final int direction) {
 | 
			
		||||
        if (settings == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        switch (direction) {
 | 
			
		||||
            case 0:
 | 
			
		||||
            case 1:
 | 
			
		||||
            case 2:
 | 
			
		||||
            case 3:
 | 
			
		||||
                return settings.getMerged(direction);
 | 
			
		||||
            case 7:
 | 
			
		||||
                int i = direction - 4;
 | 
			
		||||
                int i2 = 0;
 | 
			
		||||
                return settings.getMerged(i2) && settings.getMerged(i) && MainUtil.getPlotAbs(world, MainUtil.getPlotIdRelative(id, i)).getMerged(i2) && settings.getMerged(i) && settings.getMerged(i2) && MainUtil.getPlotAbs(world, MainUtil.getPlotIdRelative(id, i2)).getMerged(i);
 | 
			
		||||
            case 4:
 | 
			
		||||
            case 5:
 | 
			
		||||
            case 6:
 | 
			
		||||
                i = direction - 4;
 | 
			
		||||
                i2 = direction - 3;
 | 
			
		||||
                return settings.getMerged(i2) && settings.getMerged(i) && MainUtil.getPlotAbs(world, MainUtil.getPlotIdRelative(id, i)).getMerged(i2) && settings.getMerged(i) && settings.getMerged(i2) && MainUtil.getPlotAbs(world, MainUtil.getPlotIdRelative(id, i2)).getMerged(i);
 | 
			
		||||
                
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@@ -456,9 +547,7 @@ public class Plot {
 | 
			
		||||
     * Deny someone (updates database as well)
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public void addDenied(final UUID uuid) {
 | 
			
		||||
        if (getDenied().add(uuid)) {
 | 
			
		||||
     */
 | 
			
		||||
    public void addDenied(final UUID uuid) {
 | 
			
		||||
        PlotHandler.addDenied(this, uuid);
 | 
			
		||||
    }
 | 
			
		||||
@@ -467,9 +556,7 @@ public class Plot {
 | 
			
		||||
     * Add someone as a helper (updates database as well)
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public void addTrusted(final UUID uuid) {
 | 
			
		||||
        if (getTrusted().add(uuid)) {
 | 
			
		||||
     */
 | 
			
		||||
    public void addTrusted(final UUID uuid) {
 | 
			
		||||
        PlotHandler.addTrusted(this, uuid);
 | 
			
		||||
    }
 | 
			
		||||
@@ -478,9 +565,7 @@ public class Plot {
 | 
			
		||||
     * Add someone as a trusted user (updates database as well)
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public void addMember(final UUID uuid) {
 | 
			
		||||
        if (getMembers().add(uuid)) {
 | 
			
		||||
     */
 | 
			
		||||
    public void addMember(final UUID uuid) {
 | 
			
		||||
        PlotHandler.addMember(this, uuid);
 | 
			
		||||
    }
 | 
			
		||||
@@ -488,10 +573,7 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the plot owner (and update the database)
 | 
			
		||||
     * @param owner
 | 
			
		||||
     */
 | 
			
		||||
    public void setOwner(final UUID owner) {
 | 
			
		||||
        if (!this.owner.equals(owner)) {
 | 
			
		||||
            this.owner = owner;
 | 
			
		||||
     */
 | 
			
		||||
    public void setOwner(final UUID owner) {
 | 
			
		||||
        PlotHandler.setOwner(this, owner);
 | 
			
		||||
    }
 | 
			
		||||
@@ -499,19 +581,7 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the trusted users for this plot
 | 
			
		||||
     * @param uuids
 | 
			
		||||
     */
 | 
			
		||||
    public void setTrusted(final Set<UUID> uuids) {
 | 
			
		||||
        if (uuids.size() == 0) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if ((trusted != null) && (trusted.size() > 0)) {
 | 
			
		||||
            trusted.removeAll(uuids);
 | 
			
		||||
            for (final UUID uuid : trusted) {
 | 
			
		||||
                DBFunc.removeTrusted(this, uuid);
 | 
			
		||||
            }
 | 
			
		||||
            trusted.clear();
 | 
			
		||||
        }
 | 
			
		||||
        for (final UUID uuid : uuids) {
 | 
			
		||||
     */
 | 
			
		||||
    public void setTrusted(final Set<UUID> uuids) {
 | 
			
		||||
        PlotHandler.setTrusted(this, uuids);
 | 
			
		||||
    }
 | 
			
		||||
@@ -519,19 +589,7 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the members for this plot
 | 
			
		||||
     * @param uuids
 | 
			
		||||
     */
 | 
			
		||||
    public void setMembers(final Set<UUID> uuids) {
 | 
			
		||||
        if (uuids.size() == 0) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if ((members != null) && (members.size() > 0)) {
 | 
			
		||||
            members.removeAll(uuids);
 | 
			
		||||
            for (final UUID uuid : members) {
 | 
			
		||||
                DBFunc.removeMember(this, uuid);
 | 
			
		||||
            }
 | 
			
		||||
            members.clear();
 | 
			
		||||
        }
 | 
			
		||||
        for (final UUID uuid : uuids) {
 | 
			
		||||
     */
 | 
			
		||||
    public void setMembers(final Set<UUID> uuids) {
 | 
			
		||||
        PlotHandler.setMembers(this, uuids);
 | 
			
		||||
    }
 | 
			
		||||
@@ -539,19 +597,7 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the denied users for this plot
 | 
			
		||||
     * @param uuids
 | 
			
		||||
     */
 | 
			
		||||
    public void setDenied(final Set<UUID> uuids) {
 | 
			
		||||
        if (uuids.size() == 0) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if ((denied != null) && (denied.size() > 0)) {
 | 
			
		||||
            denied.removeAll(uuids);
 | 
			
		||||
            for (final UUID uuid : denied) {
 | 
			
		||||
                DBFunc.removeDenied(this, uuid);
 | 
			
		||||
            }
 | 
			
		||||
            denied.clear();
 | 
			
		||||
        }
 | 
			
		||||
        for (final UUID uuid : uuids) {
 | 
			
		||||
     */
 | 
			
		||||
    public void setDenied(final Set<UUID> uuids) {
 | 
			
		||||
        PlotHandler.setDenied(this, uuids);
 | 
			
		||||
    }
 | 
			
		||||
@@ -586,6 +632,15 @@ public class Plot {
 | 
			
		||||
     */
 | 
			
		||||
    public void setFlag(final String flag, final Object value) {
 | 
			
		||||
        FlagManager.addPlotFlag(this, new Flag(FlagManager.getFlag(flag), value));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Set a flag for this plot
 | 
			
		||||
     * @param flag
 | 
			
		||||
     * @param value
 | 
			
		||||
     */
 | 
			
		||||
    public void setFlags(Set<Flag> flags) {
 | 
			
		||||
        FlagManager.setPlotFlags(this, flags);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
@@ -607,25 +662,45 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Delete a plot (use null for the runnable if you don't need to be notified on completion)
 | 
			
		||||
     * @see PS#removePlot(String, PlotId, boolean)
 | 
			
		||||
     * @see #clear(Runnable) to simply clear a plot
 | 
			
		||||
     */
 | 
			
		||||
    public void deletePlot(final Runnable whenDone) {
 | 
			
		||||
        MainUtil.removeSign(this);
 | 
			
		||||
        MainUtil.clear(this, true, new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (PS.get().removePlot(world, id, true)) {
 | 
			
		||||
                    DBFunc.delete(Plot.this);
 | 
			
		||||
     * @see #clear(Runnable) to simply clear a plot
 | 
			
		||||
     */
 | 
			
		||||
    public boolean deletePlot(final Runnable whenDone) {
 | 
			
		||||
        boolean result = MainUtil.delete(this, whenDone);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if a previous task was running
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public int addRunning() {
 | 
			
		||||
        int value = getRunning();
 | 
			
		||||
        for (Plot plot : getConnectedPlots()) {
 | 
			
		||||
            MainUtil.runners.put(plot, value + 1);
 | 
			
		||||
        }
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int removeRunning() {
 | 
			
		||||
        int value = getRunning();
 | 
			
		||||
        if (value < 2) {
 | 
			
		||||
            for (Plot plot : getConnectedPlots()) {
 | 
			
		||||
                }
 | 
			
		||||
                MainUtil.runners.remove(plot);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            for (Plot plot : getConnectedPlots()) {
 | 
			
		||||
                MainUtil.runners.put(plot, value - 1);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getRunning() {
 | 
			
		||||
        Integer value = MainUtil.runners.get(this);
 | 
			
		||||
        return value == null ? 0 : value;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean unclaim() {
 | 
			
		||||
        if (PS.get().removePlot(world, id, true)) {
 | 
			
		||||
            DBFunc.delete(Plot.this);
 | 
			
		||||
            return true;
 | 
			
		||||
    
 | 
			
		||||
    public boolean unclaim() {
 | 
			
		||||
        return PlotHandler.unclaim(this);
 | 
			
		||||
    }
 | 
			
		||||
@@ -634,7 +709,7 @@ public class Plot {
 | 
			
		||||
     * Unlink a plot and remove the roads
 | 
			
		||||
     * @see MainUtil#unlinkPlot(Plot, boolean removeRoad)
 | 
			
		||||
     * @return true if plot was linked
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public boolean unlink() {
 | 
			
		||||
        return MainUtil.unlinkPlot(this, true, true);
 | 
			
		||||
    }
 | 
			
		||||
@@ -681,7 +756,7 @@ public class Plot {
 | 
			
		||||
     * Set the home location
 | 
			
		||||
     * @param loc
 | 
			
		||||
     */
 | 
			
		||||
    public void setHome(final BlockLoc loc) {
 | 
			
		||||
    public void setHome(final BlockLoc loc) {
 | 
			
		||||
        final BlockLoc pos = getSettings().getPosition();
 | 
			
		||||
        if (((pos == null || pos.equals(new BlockLoc(0, 0, 0))) && (loc == null)) || ((pos != null) && pos.equals(loc))) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -746,8 +821,8 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Auto merge the plot with any adjacent plots of the same owner
 | 
			
		||||
     * @see MainUtil#autoMerge(Plot, UUID) to specify the owner
 | 
			
		||||
     * @param removeRoads If to remove roads when merging
 | 
			
		||||
     */
 | 
			
		||||
     * @param removeRoads If to remove roads when merging
 | 
			
		||||
     */
 | 
			
		||||
    public boolean autoMerge(final boolean removeRoads) {
 | 
			
		||||
        return MainUtil.autoMerge(this, -1, Integer.MAX_VALUE, owner, removeRoads);
 | 
			
		||||
    }
 | 
			
		||||
@@ -761,23 +836,27 @@ public class Plot {
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Set components such as border, wall, floor
 | 
			
		||||
     *  (components are generator specific)
 | 
			
		||||
     */
 | 
			
		||||
     *  (components are generator specific)
 | 
			
		||||
     */
 | 
			
		||||
    public boolean setComponent(final String component, final PlotBlock... blocks) {
 | 
			
		||||
        return MainUtil.setComponent(this, component, blocks);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Set components such as border, wall, floor
 | 
			
		||||
     *  (components are generator specific)
 | 
			
		||||
     */
 | 
			
		||||
     *  (components are generator specific)
 | 
			
		||||
     */
 | 
			
		||||
    public boolean setComponent(final String component, final String blocks) {
 | 
			
		||||
        PlotBlock[] parsed = Configuration.BLOCKLIST.parseString(blocks);
 | 
			
		||||
        if (parsed == null || parsed.length == 0) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return MainUtil.setComponent(this, component, parsed);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the biome (String)
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public String getBiome() {
 | 
			
		||||
        final Location loc = getBottomAbs();
 | 
			
		||||
        return BlockManager.manager.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
 | 
			
		||||
@@ -785,32 +864,68 @@ public class Plot {
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the top location for the plot
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public Location getTopAbs() {
 | 
			
		||||
        return MainUtil.getPlotTopLocAbs(world, id);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the bottom location for the plot
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public Location getBottomAbs() {
 | 
			
		||||
        return MainUtil.getPlotBottomLocAbs(world, id);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the top and bottom connected plot.<br>
 | 
			
		||||
     *  - If the plot is not connected, it will return itself for the top/bottom<br>
 | 
			
		||||
     *  - the returned IDs will not necessarily correspond to claimed plots if the connected plots do not form a rectangular shape
 | 
			
		||||
     * @deprecated as merged plots no longer need to be rectangular
 | 
			
		||||
     * @param plot
 | 
			
		||||
     * @return new PlotId[] { bottom, top }
 | 
			
		||||
     * @see MainUtil#getCornerIds(Plot)
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public Location[] getCorners() {
 | 
			
		||||
        return MainUtil.getCorners(this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * @deprecated in favor of getCorners()[0];
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public Location getBottom() {
 | 
			
		||||
        return getCorners()[0];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * @deprecated in favor of getCorners()[1];
 | 
			
		||||
     * @return The bottom plot
 | 
			
		||||
     */
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public Location getTop() {
 | 
			
		||||
        return getCorners()[0];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get a set of plots connected (and including) this plot<br>
 | 
			
		||||
     *  - This result is cached globally
 | 
			
		||||
     * @see MainUtil#getConnectedPlots(Plot)
 | 
			
		||||
     * @return The bottom plot
 | 
			
		||||
     */
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public Set<Plot> getConnectedPlots() {
 | 
			
		||||
        return MainUtil.getConnectedPlots(this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * This will combine each plot into effective rectangular regions
 | 
			
		||||
     *  - This result is cached globally
 | 
			
		||||
     * @see MainUtil#getRegions(Plot) 
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public Set<RegionWrapper> getRegions() {
 | 
			
		||||
        return MainUtil.getRegions(this);
 | 
			
		||||
    }
 | 
			
		||||
@@ -819,13 +934,13 @@ public class Plot {
 | 
			
		||||
     * Swap the plot contents and settings with another location<br>
 | 
			
		||||
     *  - The destination must correspond to a valid plot of equal dimensions
 | 
			
		||||
     * @see ChunkManager#swap(String, bot1, top1, bot2, top2) to swap terrain
 | 
			
		||||
     * @see MainUtil#getPlotSelectionIds(PlotId, PlotId) to get the plots inside a selection
 | 
			
		||||
     * @see MainUtil#getPlotSelectionIds(PlotId, PlotId) to get the plots inside a selection
 | 
			
		||||
     * @see MainUtil#swapData(String, PlotId, PlotId, Runnable) to swap plot settings
 | 
			
		||||
     * @param other The other plot to swap with
 | 
			
		||||
     * @param whenDone A task to run when finished, or null
 | 
			
		||||
     * @see MainUtil#swapData(String, PlotId, PlotId, Runnable)
 | 
			
		||||
     * @return boolean if swap was successful
 | 
			
		||||
     */
 | 
			
		||||
     * @return boolean if swap was successful
 | 
			
		||||
     */
 | 
			
		||||
    public boolean swap(final Plot destination, final Runnable whenDone) {
 | 
			
		||||
        return MainUtil.move(this, destination, whenDone, true);
 | 
			
		||||
    }
 | 
			
		||||
@@ -836,7 +951,7 @@ public class Plot {
 | 
			
		||||
     * @param destination Where to move the plot
 | 
			
		||||
     * @param whenDone A task to run when done, or null
 | 
			
		||||
     * @return if the move was successful
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public boolean move(final Plot destination, final Runnable whenDone) {
 | 
			
		||||
        return MainUtil.move(this, destination, whenDone, false);
 | 
			
		||||
    }
 | 
			
		||||
@@ -846,8 +961,8 @@ public class Plot {
 | 
			
		||||
     *  - The destination must correspond to an empty location
 | 
			
		||||
     * @param destination The location to copy to
 | 
			
		||||
     * @param whenDone The task to run when done
 | 
			
		||||
     * @return If the copy was successful
 | 
			
		||||
     */
 | 
			
		||||
     * @return If the copy was successful
 | 
			
		||||
     */
 | 
			
		||||
    public boolean copy(final Plot destination, final Runnable whenDone) {
 | 
			
		||||
        return MainUtil.copy(this, destination, whenDone);
 | 
			
		||||
    }
 | 
			
		||||
@@ -996,4 +1111,56 @@ public class Plot {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        return id.hashCode();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public HashMap<String, Flag> getFlags() {
 | 
			
		||||
        if (settings == null) {
 | 
			
		||||
            return new HashMap<>(0);
 | 
			
		||||
        }
 | 
			
		||||
        return settings.flags;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getAlias() {
 | 
			
		||||
        return getSettings().getAlias();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the raw merge data<br>
 | 
			
		||||
     *  - Updates DB
 | 
			
		||||
     *  - Does not modify terrain
 | 
			
		||||
     * @param merged
 | 
			
		||||
     */
 | 
			
		||||
    public void setMerged(boolean[] merged) {
 | 
			
		||||
        getSettings().merged = merged;
 | 
			
		||||
        DBFunc.setMerged(this, merged);
 | 
			
		||||
        MainUtil.connected_cache = null;
 | 
			
		||||
        MainUtil.regions_cache = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the raw merge data<br>
 | 
			
		||||
     *  - Updates DB
 | 
			
		||||
     *  - Does not modify terrain
 | 
			
		||||
     * @param merged
 | 
			
		||||
     */
 | 
			
		||||
    public void setMerged(int direction, boolean value) {
 | 
			
		||||
        if (getSettings().setMerged(direction, value)) {
 | 
			
		||||
            DBFunc.setMerged(this, getSettings().getMerged());
 | 
			
		||||
            MainUtil.connected_cache = null;
 | 
			
		||||
            MainUtil.regions_cache = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean[] getMerged() {
 | 
			
		||||
        if (settings == null) {
 | 
			
		||||
            return new boolean[] {false, false, false, false };
 | 
			
		||||
        }
 | 
			
		||||
        return settings.getMerged();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BlockLoc getPosition() {
 | 
			
		||||
        if (settings == null) {
 | 
			
		||||
            return new BlockLoc(0, 0, 0);
 | 
			
		||||
        }
 | 
			
		||||
        return settings.getPosition();
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ public class PlotCluster {
 | 
			
		||||
        this.pos1 = pos1;
 | 
			
		||||
        this.pos2 = pos2;
 | 
			
		||||
        this.owner = owner;
 | 
			
		||||
        settings = new PlotSettings(null);
 | 
			
		||||
        settings = new PlotSettings();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean isAdded(final UUID uuid) {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,10 @@ package com.intellectualcrafters.plot.object;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.database.DBFunc;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.UUIDHandler;
 | 
			
		||||
@@ -15,13 +17,14 @@ public class PlotHandler {
 | 
			
		||||
            return new HashSet<UUID>();
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.isMerged()) {
 | 
			
		||||
            final HashSet<UUID> owners = new HashSet<UUID>();
 | 
			
		||||
            final Plot top = MainUtil.getTopPlot(plot);
 | 
			
		||||
            final ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id);
 | 
			
		||||
            for (final PlotId id : ids) {
 | 
			
		||||
                final UUID owner = MainUtil.getPlot(plot.world, id).owner;
 | 
			
		||||
                if (owner != null) {
 | 
			
		||||
                    owners.add(owner);
 | 
			
		||||
            HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
 | 
			
		||||
            final HashSet<UUID> owners = new HashSet<UUID>(2);
 | 
			
		||||
            UUID last = plot.owner;
 | 
			
		||||
            owners.add(plot.owner);
 | 
			
		||||
            for (Plot current : plots) {
 | 
			
		||||
                if (last == null || current.owner.getMostSignificantBits() != last.getMostSignificantBits()) {
 | 
			
		||||
                    owners.add(current.owner);
 | 
			
		||||
                    last = current.owner;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return owners;
 | 
			
		||||
@@ -33,37 +36,49 @@ public class PlotHandler {
 | 
			
		||||
        if (plot.owner == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.isMerged()) {
 | 
			
		||||
            final Plot top = MainUtil.getTopPlot(plot);
 | 
			
		||||
            final ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id);
 | 
			
		||||
            for (final PlotId id : ids) {
 | 
			
		||||
                final UUID owner = MainUtil.getPlot(plot.world, id).owner;
 | 
			
		||||
                if ((owner != null) && owner.equals(uuid)) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
        if (plot.owner.equals(uuid)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (!plot.isMerged()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
            if (current.owner.equals(uuid)) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return plot.owner.equals(uuid);
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static boolean isOnline(final Plot plot) {
 | 
			
		||||
        if (plot.owner == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.isMerged()) {
 | 
			
		||||
            final Plot top = MainUtil.getTopPlot(plot);
 | 
			
		||||
            final ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id);
 | 
			
		||||
            for (final PlotId id : ids) {
 | 
			
		||||
                final UUID owner = MainUtil.getPlot(plot.world, id).owner;
 | 
			
		||||
                if (owner != null) {
 | 
			
		||||
                    if (UUIDHandler.getPlayer(owner) != null) {
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        if (!plot.isMerged()) {
 | 
			
		||||
            return UUIDHandler.getPlayer(plot.owner) != null;
 | 
			
		||||
        }
 | 
			
		||||
        for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
            if (current.owner != null && UUIDHandler.getPlayer(current.owner) != null) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void setOwner(Plot plot, UUID owner) {
 | 
			
		||||
        if (!plot.isMerged()) {
 | 
			
		||||
            if (!plot.owner.equals(owner)) {
 | 
			
		||||
                plot.owner = owner;
 | 
			
		||||
                DBFunc.setOwner(plot, owner);
 | 
			
		||||
            }
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
            if (!owner.equals(current.owner)) {
 | 
			
		||||
                current.owner = owner;
 | 
			
		||||
                DBFunc.setOwner(current, owner);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return UUIDHandler.getPlayer(plot.owner) != null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static boolean sameOwners(final Plot plot1, final Plot plot2) {
 | 
			
		||||
@@ -79,30 +94,116 @@ public class PlotHandler {
 | 
			
		||||
        if (plot.owner == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (isOwner(plot, uuid)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.getDenied().contains(uuid)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.getTrusted().contains(uuid) || plot.getTrusted().contains(DBFunc.everyone)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (isOwner(plot, uuid)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.getMembers().contains(uuid) || plot.getMembers().contains(DBFunc.everyone)) {
 | 
			
		||||
            if (PlotHandler.isOnline(plot)) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.isMerged()) {
 | 
			
		||||
            final Plot top = MainUtil.getTopPlot(plot);
 | 
			
		||||
            final ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id);
 | 
			
		||||
            for (final PlotId id : ids) {
 | 
			
		||||
                final UUID owner = MainUtil.getPlot(plot.world, id).owner;
 | 
			
		||||
                if ((owner != null) && owner.equals(uuid)) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void setDenied(Plot plot, Set<UUID> uuids) {
 | 
			
		||||
        boolean larger = uuids.size() > plot.getDenied().size();
 | 
			
		||||
        HashSet<UUID> intersection = new HashSet<>(larger ? plot.getDenied() : uuids);
 | 
			
		||||
        intersection.retainAll(larger ? uuids : plot.getDenied());
 | 
			
		||||
        uuids.removeAll(intersection);
 | 
			
		||||
        HashSet<UUID> toRemove = new HashSet<>(plot.getDenied());
 | 
			
		||||
        toRemove.removeAll(intersection);
 | 
			
		||||
        for (UUID uuid : toRemove) {
 | 
			
		||||
            plot.removeDenied(uuid);
 | 
			
		||||
        }
 | 
			
		||||
        for (UUID uuid : uuids) {
 | 
			
		||||
            plot.addDenied(uuid);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void setTrusted(Plot plot, Set<UUID> uuids) {
 | 
			
		||||
        boolean larger = uuids.size() > plot.getTrusted().size();
 | 
			
		||||
        HashSet<UUID> intersection = new HashSet<>(larger ? plot.getTrusted() : uuids);
 | 
			
		||||
        intersection.retainAll(larger ? uuids : plot.getTrusted());
 | 
			
		||||
        uuids.removeAll(intersection);
 | 
			
		||||
        HashSet<UUID> toRemove = new HashSet<>(plot.getTrusted());
 | 
			
		||||
        toRemove.removeAll(intersection);
 | 
			
		||||
        for (UUID uuid : toRemove) {
 | 
			
		||||
            plot.removeTrusted(uuid);
 | 
			
		||||
        }
 | 
			
		||||
        for (UUID uuid : uuids) {
 | 
			
		||||
            plot.addTrusted(uuid);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void setMembers(Plot plot, Set<UUID> uuids) {
 | 
			
		||||
        boolean larger = uuids.size() > plot.getMembers().size();
 | 
			
		||||
        HashSet<UUID> intersection = new HashSet<>(larger ? plot.getMembers() : uuids);
 | 
			
		||||
        intersection.retainAll(larger ? uuids : plot.getMembers());
 | 
			
		||||
        uuids.removeAll(intersection);
 | 
			
		||||
        HashSet<UUID> toRemove = new HashSet<>(plot.getMembers());
 | 
			
		||||
        toRemove.removeAll(intersection);
 | 
			
		||||
        for (UUID uuid : toRemove) {
 | 
			
		||||
            plot.removeMember(uuid);
 | 
			
		||||
        }
 | 
			
		||||
        for (UUID uuid : uuids) {
 | 
			
		||||
            plot.addMember(uuid);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void set(Plot plot, Set<UUID> uuids) {
 | 
			
		||||
        boolean larger = uuids.size() > plot.getDenied().size();
 | 
			
		||||
        HashSet<UUID> intersection = new HashSet<>(larger ? plot.getDenied() : uuids);
 | 
			
		||||
        intersection.retainAll(larger ? uuids : plot.getDenied());
 | 
			
		||||
        uuids.removeAll(intersection);
 | 
			
		||||
        HashSet<UUID> toRemove = new HashSet<>(plot.getDenied());
 | 
			
		||||
        toRemove.removeAll(intersection);
 | 
			
		||||
        for (UUID uuid : toRemove) {
 | 
			
		||||
            plot.removeDenied(uuid);
 | 
			
		||||
        }
 | 
			
		||||
        for (UUID uuid : uuids) {
 | 
			
		||||
            plot.addDenied(uuid);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void addDenied(Plot plot, UUID uuid) {
 | 
			
		||||
        for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
            if (current.getDenied().add(uuid)) {
 | 
			
		||||
                DBFunc.setDenied(current, uuid);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void addMember(Plot plot, UUID uuid) {
 | 
			
		||||
        for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
            if (current.getMembers().add(uuid)) {
 | 
			
		||||
                DBFunc.setMember(current, uuid);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void addTrusted(Plot plot, UUID uuid) {
 | 
			
		||||
        for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
            if (current.getTrusted().add(uuid)) {
 | 
			
		||||
                DBFunc.setTrusted(current, uuid);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean unclaim(Plot plot) {
 | 
			
		||||
        if (plot.owner == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        for (Plot current : MainUtil.getConnectedPlots(plot)) {
 | 
			
		||||
            current.settings = null;
 | 
			
		||||
            PS.get().removePlot(current.world, current.id, true);
 | 
			
		||||
            DBFunc.delete(current);
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -33,24 +33,19 @@ import com.intellectualcrafters.plot.object.comment.PlotComment;
 | 
			
		||||
 * plot settings
 | 
			
		||||
 *
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
public class PlotSettings {
 | 
			
		||||
    /**
 | 
			
		||||
     * Plot
 | 
			
		||||
 */
 | 
			
		||||
public class PlotSettings {
 | 
			
		||||
    /**
 | 
			
		||||
     * merged plots
 | 
			
		||||
     * merged plots
 | 
			
		||||
     */
 | 
			
		||||
    public boolean[] merged = new boolean[] { false, false, false, false };
 | 
			
		||||
    /**
 | 
			
		||||
     * plot alias
 | 
			
		||||
     * plot alias
 | 
			
		||||
     */
 | 
			
		||||
    public String alias = "";
 | 
			
		||||
    /**
 | 
			
		||||
     * Comments
 | 
			
		||||
     * Comments
 | 
			
		||||
     */
 | 
			
		||||
    public List<PlotComment> comments = null;
 | 
			
		||||
    
 | 
			
		||||
@@ -71,9 +66,7 @@ public class PlotSettings {
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor
 | 
			
		||||
     *
 | 
			
		||||
     * @param plot object
 | 
			
		||||
     */
 | 
			
		||||
    public PlotSettings(final Plot plot) {
 | 
			
		||||
     * @param plot object
 | 
			
		||||
     */
 | 
			
		||||
    public PlotSettings() {
 | 
			
		||||
        flags = new HashMap<>();
 | 
			
		||||
@@ -103,8 +96,12 @@ public class PlotSettings {
 | 
			
		||||
    
 | 
			
		||||
    public void setMerged(final boolean[] merged) {
 | 
			
		||||
        this.merged = merged;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean setMerged(final int direction, final boolean merged) {
 | 
			
		||||
        if (this.merged[direction] != merged) {
 | 
			
		||||
            this.merged[direction] = merged;
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@@ -131,8 +128,8 @@ public class PlotSettings {
 | 
			
		||||
     */
 | 
			
		||||
    public void setAlias(final String alias) {
 | 
			
		||||
        this.alias = alias;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public String getJoinMessage(String world) {
 | 
			
		||||
        final Flag greeting = FlagManager.getSettingFlag(world, this, "greeting");
 | 
			
		||||
        if (greeting != null) {
 | 
			
		||||
@@ -144,8 +141,8 @@ public class PlotSettings {
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the "farewell" flag value
 | 
			
		||||
     *
 | 
			
		||||
     * @return Farewell flag
 | 
			
		||||
     */
 | 
			
		||||
     * @return Farewell flag
 | 
			
		||||
     */
 | 
			
		||||
    public String getLeaveMessage(String world) {
 | 
			
		||||
        final Flag farewell = FlagManager.getSettingFlag(world, this, "farewell");
 | 
			
		||||
        if (farewell != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -63,80 +63,7 @@ public abstract class PlotWorld {
 | 
			
		||||
    public final static int MAX_BUILD_HEIGHT_DEFAULT = 256;
 | 
			
		||||
    public final static int MIN_BUILD_HEIGHT_DEFAULT = 1;
 | 
			
		||||
    public final static PlotGamemode GAMEMODE_DEFAULT = PlotGamemode.CREATIVE;
 | 
			
		||||
    // are plot clusters enabled
 | 
			
		||||
    // require claim in cluster
 | 
			
		||||
    // TODO make this configurable
 | 
			
		||||
    // make non static and static_default_valu + add config option
 | 
			
		||||
    public static int[] BLOCKS;
 | 
			
		||||
    static {
 | 
			
		||||
        BLOCKS = new int[] {
 | 
			
		||||
        1,
 | 
			
		||||
        2,
 | 
			
		||||
        3,
 | 
			
		||||
        4,
 | 
			
		||||
        5,
 | 
			
		||||
        7,
 | 
			
		||||
        14,
 | 
			
		||||
        15,
 | 
			
		||||
        16,
 | 
			
		||||
        17,
 | 
			
		||||
        19,
 | 
			
		||||
        21,
 | 
			
		||||
        22,
 | 
			
		||||
        23,
 | 
			
		||||
        24,
 | 
			
		||||
        25,
 | 
			
		||||
        35,
 | 
			
		||||
        41,
 | 
			
		||||
        42,
 | 
			
		||||
        43,
 | 
			
		||||
        45,
 | 
			
		||||
        47,
 | 
			
		||||
        48,
 | 
			
		||||
        49,
 | 
			
		||||
        52,
 | 
			
		||||
        56,
 | 
			
		||||
        57,
 | 
			
		||||
        58,
 | 
			
		||||
        61,
 | 
			
		||||
        62,
 | 
			
		||||
        73,
 | 
			
		||||
        74,
 | 
			
		||||
        80,
 | 
			
		||||
        82,
 | 
			
		||||
        84,
 | 
			
		||||
        86,
 | 
			
		||||
        87,
 | 
			
		||||
        88,
 | 
			
		||||
        91,
 | 
			
		||||
        97,
 | 
			
		||||
        98,
 | 
			
		||||
        99,
 | 
			
		||||
        100,
 | 
			
		||||
        103,
 | 
			
		||||
        110,
 | 
			
		||||
        112,
 | 
			
		||||
        120,
 | 
			
		||||
        121,
 | 
			
		||||
        123,
 | 
			
		||||
        124,
 | 
			
		||||
        125,
 | 
			
		||||
        129,
 | 
			
		||||
        133,
 | 
			
		||||
        153,
 | 
			
		||||
        155,
 | 
			
		||||
        159,
 | 
			
		||||
        162,
 | 
			
		||||
        165,
 | 
			
		||||
        166,
 | 
			
		||||
        168,
 | 
			
		||||
        170,
 | 
			
		||||
        172,
 | 
			
		||||
        173,
 | 
			
		||||
        174,
 | 
			
		||||
        179,
 | 
			
		||||
        181 };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public final String worldname;
 | 
			
		||||
    public int MAX_PLOT_MEMBERS;
 | 
			
		||||
    public boolean AUTO_MERGE;
 | 
			
		||||
@@ -183,6 +110,9 @@ public abstract class PlotWorld {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final PlotWorld plotworld = (PlotWorld) obj;
 | 
			
		||||
        if (this.worldname.equals(plotworld.worldname)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        final ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
 | 
			
		||||
        for (final ConfigurationNode setting : plotworld.getSettingNodes()) {
 | 
			
		||||
            final Object constant = section.get(plotworld.worldname + "." + setting.getConstant());
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ public class Rating {
 | 
			
		||||
    
 | 
			
		||||
    public List<String> getCategories() {
 | 
			
		||||
        if (ratingMap.size() == 1) {
 | 
			
		||||
            return new ArrayList<>();
 | 
			
		||||
            return new ArrayList<>(0);
 | 
			
		||||
        }
 | 
			
		||||
        return new ArrayList<>(ratingMap.keySet());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -33,4 +33,29 @@ public class RegionWrapper {
 | 
			
		||||
    public boolean isIn(final int x, final int z) {
 | 
			
		||||
        return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        return minX + 13 * maxX + 23 * minZ + 39 * maxZ;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals(Object obj) {
 | 
			
		||||
        if (obj == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (obj == this) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (obj instanceof RegionWrapper) {
 | 
			
		||||
            RegionWrapper other = (RegionWrapper) obj;
 | 
			
		||||
            return minX == other.minX && minZ == other.minZ && minY == other.minY && maxX == other.maxX && maxZ == other.maxZ && maxY == other.maxY;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return minX + "->" + maxX + "," + minZ + "->" + maxZ;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets;
 | 
			
		||||
import java.nio.file.Files;
 | 
			
		||||
import java.nio.file.StandardOpenOption;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
 | 
			
		||||
@@ -17,8 +18,10 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotBlock;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
 | 
			
		||||
public class BO3Handler {
 | 
			
		||||
    
 | 
			
		||||
@@ -54,54 +57,60 @@ public class BO3Handler {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final String alias = plot.toString();
 | 
			
		||||
        final Location pos1 = plot.getBottom();
 | 
			
		||||
        final Location pos2 = plot.getTop();
 | 
			
		||||
        Location[] corners = MainUtil.getCorners(plot);
 | 
			
		||||
        Location bot = corners[0];
 | 
			
		||||
        Location top = corners[1];
 | 
			
		||||
        final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
 | 
			
		||||
        final int height = cpw.PLOT_HEIGHT;
 | 
			
		||||
        
 | 
			
		||||
        final int cx = (pos1.getX() + pos2.getX()) / 2;
 | 
			
		||||
        final int cz = (pos1.getZ() + pos2.getZ()) / 2;
 | 
			
		||||
        final int cx = (bot.getX() + top.getX()) / 2;
 | 
			
		||||
        final int cz = (bot.getZ() + top.getZ()) / 2;
 | 
			
		||||
        
 | 
			
		||||
        final HashMap<ChunkLoc, BO3> map = new HashMap<>();
 | 
			
		||||
        
 | 
			
		||||
        HashSet<RegionWrapper> regions = MainUtil.getRegions(plot);
 | 
			
		||||
        boolean content = false;
 | 
			
		||||
        for (int x = pos1.getX(); x <= pos2.getX(); x++) {
 | 
			
		||||
            final int X = ((x + 7) - cx) >> 4;
 | 
			
		||||
            final int xx = (x - cx) % 16;
 | 
			
		||||
            for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
 | 
			
		||||
                final int Z = ((z + 7) - cz) >> 4;
 | 
			
		||||
                final int zz = (z - cz) % 16;
 | 
			
		||||
                final ChunkLoc loc = new ChunkLoc(X, Z);
 | 
			
		||||
                BO3 bo3 = map.get(loc);
 | 
			
		||||
                for (int y = 1; y < height; y++) {
 | 
			
		||||
                    final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
 | 
			
		||||
                    if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) {
 | 
			
		||||
        for (RegionWrapper region : regions) {
 | 
			
		||||
            Location pos1 = new Location(plot.world, region.minX, region.minY, region.minZ);
 | 
			
		||||
            Location pos2 = new Location(plot.world, region.maxX, region.maxY, region.maxZ);
 | 
			
		||||
            for (int x = pos1.getX(); x <= pos2.getX(); x++) {
 | 
			
		||||
                final int X = ((x + 7) - cx) >> 4;
 | 
			
		||||
                final int xx = (x - cx) % 16;
 | 
			
		||||
                for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
 | 
			
		||||
                    final int Z = ((z + 7) - cz) >> 4;
 | 
			
		||||
                    final int zz = (z - cz) % 16;
 | 
			
		||||
                    final ChunkLoc loc = new ChunkLoc(X, Z);
 | 
			
		||||
                    BO3 bo3 = map.get(loc);
 | 
			
		||||
                    for (int y = 1; y < height; y++) {
 | 
			
		||||
                        final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
 | 
			
		||||
                        if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) {
 | 
			
		||||
                            if (bo3 == null) {
 | 
			
		||||
                                bo3 = new BO3(alias, loc);
 | 
			
		||||
                                map.put(loc, bo3);
 | 
			
		||||
                                content = true;
 | 
			
		||||
                            }
 | 
			
		||||
                            bo3.addBlock(xx, y - height - 1, zz, block);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    final PlotBlock floor = BlockManager.manager.getBlock(new Location(plot.world, x, height, z));
 | 
			
		||||
                    if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) {
 | 
			
		||||
                        if (bo3 == null) {
 | 
			
		||||
                            bo3 = new BO3(alias, loc);
 | 
			
		||||
                            map.put(loc, bo3);
 | 
			
		||||
                            content = true;
 | 
			
		||||
                        }
 | 
			
		||||
                        bo3.addBlock(xx, y - height - 1, zz, block);
 | 
			
		||||
                        bo3.addBlock(xx, -1, zz, floor);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                final PlotBlock floor = BlockManager.manager.getBlock(new Location(plot.world, x, height, z));
 | 
			
		||||
                if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) {
 | 
			
		||||
                    if (bo3 == null) {
 | 
			
		||||
                        bo3 = new BO3(alias, loc);
 | 
			
		||||
                        map.put(loc, bo3);
 | 
			
		||||
                        content = true;
 | 
			
		||||
                    }
 | 
			
		||||
                    bo3.addBlock(xx, -1, zz, floor);
 | 
			
		||||
                }
 | 
			
		||||
                for (int y = height + 1; y < 256; y++) {
 | 
			
		||||
                    final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
 | 
			
		||||
                    if ((block != null) && (block.id != 0)) {
 | 
			
		||||
                        if (bo3 == null) {
 | 
			
		||||
                            bo3 = new BO3(alias, loc);
 | 
			
		||||
                            map.put(loc, bo3);
 | 
			
		||||
                            content = true;
 | 
			
		||||
                    for (int y = height + 1; y < 256; y++) {
 | 
			
		||||
                        final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
 | 
			
		||||
                        if ((block != null) && (block.id != 0)) {
 | 
			
		||||
                            if (bo3 == null) {
 | 
			
		||||
                                bo3 = new BO3(alias, loc);
 | 
			
		||||
                                map.put(loc, bo3);
 | 
			
		||||
                                content = true;
 | 
			
		||||
                            }
 | 
			
		||||
                            bo3.addBlock(xx, y - height - 1, zz, block);
 | 
			
		||||
                        }
 | 
			
		||||
                        bo3.addBlock(xx, y - height - 1, zz, block);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
@@ -102,7 +103,7 @@ public abstract class ChunkManager {
 | 
			
		||||
    
 | 
			
		||||
    public abstract boolean unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
 | 
			
		||||
    
 | 
			
		||||
    public abstract List<ChunkLoc> getChunkChunks(final String world);
 | 
			
		||||
    public abstract Set<ChunkLoc> getChunkChunks(final String world);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void regenerateChunk(final String world, final ChunkLoc loc);
 | 
			
		||||
    
 | 
			
		||||
@@ -114,6 +115,9 @@ public abstract class ChunkManager {
 | 
			
		||||
    
 | 
			
		||||
    public abstract Plot hasPlot(String world, ChunkLoc chunk);
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Copy a region to a new location (in the same world)
 | 
			
		||||
     */
 | 
			
		||||
    public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone);
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
@@ -129,7 +133,5 @@ public abstract class ChunkManager {
 | 
			
		||||
    
 | 
			
		||||
    public abstract void clearAllEntities(final Location pos1, final Location pos2);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void swap(final String world, final PlotId id, final PlotId plotid);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void swap(final String worldname, final Location bot1, final Location top1, final Location bot2, final Location top2);
 | 
			
		||||
    public abstract void swap(final Location bot1, final Location top1, final Location bot2, final Location top2, Runnable whenDone);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ public class ClusterManager {
 | 
			
		||||
        if (clusters.containsKey(world)) {
 | 
			
		||||
            return clusters.get(world);
 | 
			
		||||
        }
 | 
			
		||||
        return new HashSet<>();
 | 
			
		||||
        return new HashSet<>(0);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static int getPlayerClusterCount(final String world, final PlotPlayer player) {
 | 
			
		||||
@@ -74,7 +74,7 @@ public class ClusterManager {
 | 
			
		||||
            if (toReturn.getY() == 0) {
 | 
			
		||||
                final PlotManager manager = PS.get().getPlotManager(cluster.world);
 | 
			
		||||
                final PlotWorld plotworld = PS.get().getPlotWorld(cluster.world);
 | 
			
		||||
                final Location loc = manager.getSignLoc(plotworld, MainUtil.getPlot(cluster.world, center));
 | 
			
		||||
                final Location loc = manager.getSignLoc(plotworld, MainUtil.getPlotAbs(cluster.world, center));
 | 
			
		||||
                toReturn.setY(loc.getY());
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -124,13 +124,13 @@ public class ClusterManager {
 | 
			
		||||
        final PlotManager manager = PS.get().getPlotManager(world);
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
        final Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
 | 
			
		||||
        final Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1, 0, 1);
 | 
			
		||||
        return (bot.getX() < loc.getX()) && (bot.getZ() < loc.getZ()) && (top.getX() > loc.getX()) && (top.getZ() > loc.getZ());
 | 
			
		||||
        final Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2());
 | 
			
		||||
        return (bot.getX() <= loc.getX()) && (bot.getZ() <= loc.getZ()) && (top.getX() >= loc.getX()) && (top.getZ() >= loc.getZ());
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static HashSet<PlotCluster> getIntersects(final String world, final PlotClusterId id) {
 | 
			
		||||
        if (!clusters.containsKey(world)) {
 | 
			
		||||
            return new HashSet<>();
 | 
			
		||||
            return new HashSet<>(0);
 | 
			
		||||
        }
 | 
			
		||||
        final HashSet<PlotCluster> list = new HashSet<PlotCluster>();
 | 
			
		||||
        for (final PlotCluster cluster : clusters.get(world)) {
 | 
			
		||||
@@ -236,7 +236,7 @@ public class ClusterManager {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static PlotId estimatePlotId(final Location loc) {
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        if (plot != null) {
 | 
			
		||||
            return plot.id;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ public abstract class EventUtil {
 | 
			
		||||
    public abstract void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added);
 | 
			
		||||
    
 | 
			
		||||
    public boolean checkPlayerBlockEvent(final PlotPlayer pp, final PlayerBlockEventType type, final Location loc, final LazyBlock block, final boolean notifyPerms) {
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        final Plot plot = MainUtil.getPlotAbs(loc);
 | 
			
		||||
        final UUID uuid = pp.getUUID();
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            if (!MainUtil.isPlotAreaAbs(loc)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -129,7 +129,7 @@ public class ExpireManager {
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                if (plot.isMerged()) {
 | 
			
		||||
                                    MainUtil.unlinkPlot(plot, true);
 | 
			
		||||
                                    MainUtil.unlinkPlot(plot, true, false);
 | 
			
		||||
                                }
 | 
			
		||||
                                plot.deletePlot(null);
 | 
			
		||||
                                expiredPlots.get(world).remove(plot);
 | 
			
		||||
@@ -144,7 +144,7 @@ public class ExpireManager {
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        };
 | 
			
		||||
                        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
                        if (plot.getRunning() > 0) {
 | 
			
		||||
                            PS.debug("$2[&5Expire&dManager$2] &bSkipping plot in use: " + plot);
 | 
			
		||||
                            expiredPlots.get(world).remove(plot);
 | 
			
		||||
                            run();
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -24,6 +24,7 @@ import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.zip.GZIPInputStream;
 | 
			
		||||
import java.util.zip.GZIPOutputStream;
 | 
			
		||||
@@ -46,6 +47,7 @@ import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotBlock;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RunnableVal;
 | 
			
		||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
 | 
			
		||||
import com.plotsquared.object.schematic.StateWrapper;
 | 
			
		||||
@@ -92,15 +94,6 @@ public abstract class SchematicHandler {
 | 
			
		||||
                } else {
 | 
			
		||||
                    directory = outputDir.getPath();
 | 
			
		||||
                }
 | 
			
		||||
                final Location top = plot.getTop();
 | 
			
		||||
                final Location bot = plot.getBottom();
 | 
			
		||||
                final int area = ((1 + top.getX()) - bot.getX()) * ((1 + top.getZ()) - bot.getZ());
 | 
			
		||||
                if (area > 4096) {
 | 
			
		||||
                    PS.debug("The plot is > 64 x 64 - Fast lossy schematic saving will be used");
 | 
			
		||||
                }
 | 
			
		||||
                //                if (area <= 4096 && PS.get().worldEdit != null) {
 | 
			
		||||
                //                    new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
 | 
			
		||||
                //                }
 | 
			
		||||
                final Runnable THIS = this;
 | 
			
		||||
                SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
 | 
			
		||||
                    @Override
 | 
			
		||||
@@ -162,9 +155,8 @@ public abstract class SchematicHandler {
 | 
			
		||||
                    final int LENGTH = demensions.getZ();
 | 
			
		||||
                    final int HEIGHT = demensions.getY();
 | 
			
		||||
                    // Validate dimensions
 | 
			
		||||
                    final Location bottom = plot.getBottom();
 | 
			
		||||
                    final Location top = plot.getTop();
 | 
			
		||||
                    if ((((top.getX() - bottom.getX()) + 1) < WIDTH) || (((top.getZ() - bottom.getZ()) + 1) < LENGTH) || (HEIGHT > 256)) {
 | 
			
		||||
                    RegionWrapper region = MainUtil.getLargestRegion(plot);
 | 
			
		||||
                    if ((((region.maxX - region.minX + x_offset) + 1) < WIDTH) || (((region.maxZ - region.minZ + z_offset) + 1) < LENGTH) || (HEIGHT > 256)) {
 | 
			
		||||
                        PS.debug("Schematic is too large");
 | 
			
		||||
                        TaskManager.runTask(whenDone);
 | 
			
		||||
                        return;
 | 
			
		||||
@@ -177,9 +169,10 @@ public abstract class SchematicHandler {
 | 
			
		||||
                    if (HEIGHT >= 256) {
 | 
			
		||||
                        y_offset = 0;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        y_offset = MainUtil.getHeighestBlock(plot.world, bottom.getX() + 1, bottom.getZ() + 1);
 | 
			
		||||
                        y_offset = MainUtil.getHeighestBlock(plot.world, region.minX + 1, region.minZ + 1);
 | 
			
		||||
                    }
 | 
			
		||||
                    final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1 + x_offset, y_offset - 1, 1 + z_offset);
 | 
			
		||||
                    final Location pos1 = new Location(plot.world, region.minX + x_offset, y_offset, region.minZ + z_offset);
 | 
			
		||||
//                    Location pos2 = new Location(plot.world, region.maxX, region.maxY, region.maxZ);
 | 
			
		||||
                    final Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
 | 
			
		||||
                    // TODO switch to ChunkManager.chunkTask(pos1, pos2, task, whenDone, allocate);
 | 
			
		||||
                    final int p1x = pos1.getX();
 | 
			
		||||
@@ -369,14 +362,14 @@ public abstract class SchematicHandler {
 | 
			
		||||
        if (items == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
 | 
			
		||||
        RegionWrapper region = MainUtil.getLargestRegion(plot);
 | 
			
		||||
        Location l1 = new Location(plot.world, region.minX + x_offset, 1, region.minZ + z_offset);
 | 
			
		||||
//        Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
 | 
			
		||||
        final int sy = MainUtil.getHeighestBlock(plot.world, l1.getX() + 1, l1.getZ() + 1);
 | 
			
		||||
        final Dimension demensions = schematic.getSchematicDimension();
 | 
			
		||||
        final int HEIGHT = demensions.getY();
 | 
			
		||||
        if ((HEIGHT < 255)) {
 | 
			
		||||
            l1 = l1.add(1, sy - 1, 1);
 | 
			
		||||
        } else {
 | 
			
		||||
            l1 = l1.add(1, 0, 1);
 | 
			
		||||
            l1 = l1.add(0, sy - 1, 0);
 | 
			
		||||
        }
 | 
			
		||||
        final int X = l1.getX() + x_offset;
 | 
			
		||||
        final int Y = l1.getY();
 | 
			
		||||
@@ -675,25 +668,11 @@ public abstract class SchematicHandler {
 | 
			
		||||
        return new CompoundTag("Schematic", schematic);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the schematic of a plot
 | 
			
		||||
     *
 | 
			
		||||
     * @param world to check
 | 
			
		||||
     * @param id    plot
 | 
			
		||||
     *
 | 
			
		||||
     * @return tag
 | 
			
		||||
     */
 | 
			
		||||
    public void getCompoundTag(final String world, final PlotId id, final RunnableVal<CompoundTag> whenDone) {
 | 
			
		||||
        if (PS.get().getPlot(world, id) == null) {
 | 
			
		||||
            whenDone.run();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLoc(world, id).add(1, -1, 1);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc(world, id);
 | 
			
		||||
        getCompoundTag(world, pos1, pos2, whenDone);
 | 
			
		||||
    }
 | 
			
		||||
    public abstract void getCompoundTag(final String world, Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void getCompoundTag(final String world, final Location pos1, final Location pos2, final RunnableVal<CompoundTag> whenDone);
 | 
			
		||||
    public void getCompoundTag(final String world, PlotId id, final RunnableVal<CompoundTag> whenDone) {
 | 
			
		||||
        getCompoundTag(world, MainUtil.getRegions(MainUtil.getPlotAbs(world, id)), whenDone);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean pastePart(final String world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) {
 | 
			
		||||
        int length = 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user