mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Database correction / Code cleanup, Fixes #490
This commit is contained in:
		@@ -417,7 +417,7 @@ public class PS {
 | 
			
		||||
     * @return HashMap containing the world name, and another map with the plot id and the plot object
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> getAllPlotsRaw() {
 | 
			
		||||
    public Map<String, ConcurrentHashMap<PlotId, Plot>> getAllPlotsRaw() {
 | 
			
		||||
        return plots;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -927,7 +927,7 @@ public class PS {
 | 
			
		||||
     */
 | 
			
		||||
    public Set<Plot> getPlots(final String world, final UUID uuid) {
 | 
			
		||||
        final ArrayList<Plot> myplots = new ArrayList<>();
 | 
			
		||||
        for (final Plot plot : getPlots(world).values()) {
 | 
			
		||||
        for (final Plot plot : getPlotsInWorld(world)) {
 | 
			
		||||
            if (plot.hasOwner()) {
 | 
			
		||||
                if (PlotHandler.isOwner(plot, uuid)) {
 | 
			
		||||
                    myplots.add(plot);
 | 
			
		||||
@@ -979,16 +979,37 @@ public class PS {
 | 
			
		||||
     * @return HashMap of PlotId to Plot
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public Map<PlotId, Plot> getPlots(final String world) {
 | 
			
		||||
    public HashMap<PlotId, Plot> getPlots(final String world) {
 | 
			
		||||
        if (plots.containsKey(world)) {
 | 
			
		||||
            return new HashMap<>(lastMap);
 | 
			
		||||
        }
 | 
			
		||||
        return new HashMap<>();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Collection<Plot> getPlotsInWorld(final String world) {
 | 
			
		||||
        ConcurrentHashMap<PlotId, Plot> map = plots.get(world);
 | 
			
		||||
        if (map == null) {
 | 
			
		||||
            return new HashSet<>();
 | 
			
		||||
        }
 | 
			
		||||
        return map.values();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Plot getPlot(final String world, final PlotId id) {
 | 
			
		||||
        if (world == lastWorld) {
 | 
			
		||||
            return lastMap;
 | 
			
		||||
            if (lastMap != null) {
 | 
			
		||||
                return lastMap.get(id);
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        lastWorld = world;
 | 
			
		||||
        if (plots.containsKey(world)) {
 | 
			
		||||
            lastMap = plots.get(world);
 | 
			
		||||
            return lastMap;
 | 
			
		||||
            if (lastMap != null) {
 | 
			
		||||
                return lastMap.get(id);
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return new ConcurrentHashMap<>();
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -474,7 +474,7 @@ import com.plotsquared.bukkit.util.BukkitUtil;
 | 
			
		||||
     */
 | 
			
		||||
    public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
 | 
			
		||||
        final ArrayList<Plot> pPlots = new ArrayList<>();
 | 
			
		||||
        for (final Plot plot : PS.get().getPlots(world.getName()).values()) {
 | 
			
		||||
        for (final Plot plot : PS.get().getPlotsInWorld(world.getName())) {
 | 
			
		||||
            if (just_owner) {
 | 
			
		||||
                if ((plot.owner != null) && (plot.owner.equals(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr))))) {
 | 
			
		||||
                    pPlots.add(plot);
 | 
			
		||||
@@ -499,7 +499,7 @@ import com.plotsquared.bukkit.util.BukkitUtil;
 | 
			
		||||
     * @see com.intellectualcrafters.plot.object.Plot
 | 
			
		||||
     */
 | 
			
		||||
    public Plot[] getPlots(final World world) {
 | 
			
		||||
        Collection<Plot> plots = PS.get().getPlots(world.getName()).values();
 | 
			
		||||
        Collection<Plot> plots = PS.get().getPlotsInWorld(world.getName());
 | 
			
		||||
        return plots.toArray(new Plot[plots.size()]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -211,7 +211,7 @@ public class Auto extends SubCommand {
 | 
			
		||||
                MainUtil.lastPlot.put(worldname, start);
 | 
			
		||||
                if (lastPlot) {
 | 
			
		||||
                }
 | 
			
		||||
                if ((PS.get().getPlots(worldname).get(start) != null) && (PS.get().getPlots(worldname).get(start).owner != null)) {
 | 
			
		||||
                if ((PS.get().getPlot(worldname, start) != null) && (PS.get().getPlot(worldname, start).owner != null)) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                } else {
 | 
			
		||||
                    lastPlot = false;
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ public class Claim extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
            final String world = plot.world;
 | 
			
		||||
            final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
            final Plot plot2 = PS.get().getPlots(world).get(plot.id);
 | 
			
		||||
            final Plot plot2 = PS.get().getPlot(world, plot.id);
 | 
			
		||||
            if (plotworld.SCHEMATIC_ON_CLAIM) {
 | 
			
		||||
                Schematic sch;
 | 
			
		||||
                if (schematic.equals("")) {
 | 
			
		||||
 
 | 
			
		||||
@@ -144,7 +144,7 @@ public class Cluster extends SubCommand {
 | 
			
		||||
                }
 | 
			
		||||
                ClusterManager.clusters.get(world).add(cluster);
 | 
			
		||||
                // Add any existing plots to the current cluster
 | 
			
		||||
                for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld()).values()) {
 | 
			
		||||
                for (final Plot plot : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
 | 
			
		||||
                    final PlotCluster current = ClusterManager.getCluster(plot);
 | 
			
		||||
                    if (cluster.equals(current) && !cluster.isAdded(plot.owner)) {
 | 
			
		||||
                        cluster.invited.add(plot.owner);
 | 
			
		||||
@@ -221,7 +221,7 @@ public class Cluster extends SubCommand {
 | 
			
		||||
                final PlotWorld plotworld = PS.get().getPlotWorld(plr.getLocation().getWorld());
 | 
			
		||||
                if (plotworld.TYPE == 2) {
 | 
			
		||||
                    final ArrayList<Plot> toRemove = new ArrayList<>();
 | 
			
		||||
                    for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld()).values()) {
 | 
			
		||||
                    for (final Plot plot : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
 | 
			
		||||
                        final PlotCluster other = ClusterManager.getCluster(plot);
 | 
			
		||||
                        if (cluster.equals(other)) {
 | 
			
		||||
                            toRemove.add(plot);
 | 
			
		||||
 
 | 
			
		||||
@@ -76,7 +76,7 @@ public class Condense extends SubCommand {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final int radius = Integer.parseInt(args[2]);
 | 
			
		||||
                final Collection<Plot> plots = PS.get().getPlots(worldname).values();
 | 
			
		||||
                final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
 | 
			
		||||
                final int size = plots.size();
 | 
			
		||||
                final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
 | 
			
		||||
                if (radius < minimum_radius) {
 | 
			
		||||
@@ -165,7 +165,7 @@ public class Condense extends SubCommand {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final int radius = Integer.parseInt(args[2]);
 | 
			
		||||
                final Collection<Plot> plots = PS.get().getPlots(worldname).values();
 | 
			
		||||
                final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
 | 
			
		||||
                final int size = plots.size();
 | 
			
		||||
                final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
 | 
			
		||||
                if (radius < minimum_radius) {
 | 
			
		||||
 
 | 
			
		||||
@@ -93,8 +93,7 @@ public class DebugClaimTest extends SubCommand {
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<>();
 | 
			
		||||
        for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
 | 
			
		||||
            final Plot plot = MainUtil.getPlot(world, id);
 | 
			
		||||
            final boolean contains = PS.get().getPlots(world).containsKey(plot.id);
 | 
			
		||||
            if (contains) {
 | 
			
		||||
            if (PS.get().getPlot(world, plot.id) != null) {
 | 
			
		||||
                MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -72,6 +72,8 @@ import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.UUIDHandler;
 | 
			
		||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
 | 
			
		||||
import com.plotsquared.general.commands.Command;
 | 
			
		||||
import com.plotsquared.general.commands.CommandCaller;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
@@ -86,6 +88,19 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
    private ScriptEngine engine;
 | 
			
		||||
    private Bindings scope;
 | 
			
		||||
    
 | 
			
		||||
    public DebugExec() {
 | 
			
		||||
        File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js");
 | 
			
		||||
        if (file.exists()) {
 | 
			
		||||
            init();
 | 
			
		||||
            TaskManager.runTaskLater(new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    onCommand(ConsolePlayer.getConsole(), new String[] {"runasync", "start.js"});
 | 
			
		||||
                }
 | 
			
		||||
            }, 1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void init() {
 | 
			
		||||
        if (engine != null) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -350,6 +365,33 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringMan.join(allowed_params, "|") + ">");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                case "addcmd": {
 | 
			
		||||
                    try {
 | 
			
		||||
                    final String cmd = StringMan.join(Files.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8), System.getProperty("line.separator"));
 | 
			
		||||
                    Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) {
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public boolean onCommand(PlotPlayer plr, String[] args) {
 | 
			
		||||
                            try {
 | 
			
		||||
                                scope.put("PlotPlayer", plr);
 | 
			
		||||
                                scope.put("args", args);
 | 
			
		||||
                                engine.eval(cmd, scope);
 | 
			
		||||
                                return true;
 | 
			
		||||
                            } catch (ScriptException e) {
 | 
			
		||||
                                e.printStackTrace();
 | 
			
		||||
                                MainUtil.sendMessage(player, C.COMMAND_WENT_WRONG);
 | 
			
		||||
                                return false;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    };
 | 
			
		||||
                    MainCommand.getInstance().addCommand(subcommand);
 | 
			
		||||
                    return true;
 | 
			
		||||
                    }
 | 
			
		||||
                    catch (Exception e) {
 | 
			
		||||
                        e.printStackTrace();
 | 
			
		||||
                        MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec addcmd <file>");
 | 
			
		||||
                        return false;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                case "runasync": {
 | 
			
		||||
                    async = true;
 | 
			
		||||
                }
 | 
			
		||||
@@ -379,7 +421,7 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
            init();
 | 
			
		||||
            scope.put("PlotPlayer", player);
 | 
			
		||||
            System.out.print("> " + script);
 | 
			
		||||
            PS.debug("> " + script);
 | 
			
		||||
            try {
 | 
			
		||||
                if (async) {
 | 
			
		||||
                    final String toExec = script;
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,7 @@ public class DebugFixFlags extends SubCommand {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
 | 
			
		||||
        for (final Plot plot : PS.get().getPlots(world).values()) {
 | 
			
		||||
        for (final Plot plot : PS.get().getPlotsInWorld(world)) {
 | 
			
		||||
            final HashMap<String, Flag> flags = plot.getSettings().flags;
 | 
			
		||||
            Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
 | 
			
		||||
            boolean changed = false;
 | 
			
		||||
 
 | 
			
		||||
@@ -156,7 +156,7 @@ public class Merge extends SubCommand {
 | 
			
		||||
        HashSet<PlotId> multiPlots = new HashSet<>();
 | 
			
		||||
        final UUID u1 = plot.owner;
 | 
			
		||||
        for (final PlotId myid : plots) {
 | 
			
		||||
            final Plot myplot = PS.get().getPlots(world).get(myid);
 | 
			
		||||
            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;
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,9 @@ public class MusicSubcommand extends SubCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer player, final String[] args) {
 | 
			
		||||
        
 | 
			
		||||
        // TODO FIX PLOT MUSIC AS NPE FROM PLAYER.PLAYEFFECT
 | 
			
		||||
        System.out.print("TODO MUSIC");
 | 
			
		||||
        
 | 
			
		||||
        final Location loc = player.getLocation();
 | 
			
		||||
        final Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -100,7 +100,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(worldname, id);
 | 
			
		||||
            final int DBid = DBFunc.getId(MainUtil.getPlot(worldname, id));
 | 
			
		||||
            if (DBid != Integer.MAX_VALUE) {
 | 
			
		||||
                ids.add(DBid);
 | 
			
		||||
            }
 | 
			
		||||
@@ -117,7 +117,7 @@ public class Purge extends SubCommand {
 | 
			
		||||
            return finishPurge(length);
 | 
			
		||||
        }
 | 
			
		||||
        if (arg.equals("unknown")) {
 | 
			
		||||
            final Collection<Plot> plots = PS.get().getPlots(worldname).values();
 | 
			
		||||
            final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
 | 
			
		||||
            final Set<PlotId> ids = new HashSet<>();
 | 
			
		||||
            for (final Plot plot : plots) {
 | 
			
		||||
                if (plot.owner != null) {
 | 
			
		||||
@@ -135,7 +135,7 @@ public class Purge extends SubCommand {
 | 
			
		||||
            return finishPurge(length);
 | 
			
		||||
        }
 | 
			
		||||
        if (arg.equals("unowned")) {
 | 
			
		||||
            final Collection<Plot> plots = PS.get().getPlots(worldname).values();
 | 
			
		||||
            final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
 | 
			
		||||
            final Set<PlotId> ids = new HashSet<>();
 | 
			
		||||
            for (final Plot plot : plots) {
 | 
			
		||||
                if (plot.owner == null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -181,12 +181,11 @@ public class SchematicCmd extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall <world>");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final Map<PlotId, Plot> plotmap = PS.get().getPlots(args[1]);
 | 
			
		||||
                if ((plotmap == null) || (plotmap.size() == 0)) {
 | 
			
		||||
                Collection<Plot> plots = PS.get().getPlotsInWorld(args[1]);
 | 
			
		||||
                if ((plots.size() == 0)) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                Collection<Plot> plots = plotmap.values();
 | 
			
		||||
                boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
 | 
			
		||||
					@Override
 | 
			
		||||
					public void run() {
 | 
			
		||||
@@ -199,7 +198,7 @@ public class SchematicCmd extends SubCommand {
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                	MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
 | 
			
		||||
                	MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots...");
 | 
			
		||||
                	MainUtil.sendMessage(plr, "&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plots.size() + "&7 plots...");
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -210,7 +210,7 @@ public class Set extends SubCommand {
 | 
			
		||||
                MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG);
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            for (final Plot p : PS.get().getPlots(plr.getLocation().getWorld()).values()) {
 | 
			
		||||
            for (final Plot p : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
 | 
			
		||||
                if (p.getSettings().getAlias().equalsIgnoreCase(alias)) {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
 | 
			
		||||
                    return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -107,7 +107,7 @@ public class SetOwner extends SubCommand {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        for (final PlotId id : plots) {
 | 
			
		||||
            Plot current = PS.get().getPlots(world).get(id);
 | 
			
		||||
            Plot current = PS.get().getPlot(world, id);
 | 
			
		||||
            if (current == null) {
 | 
			
		||||
                current = MainUtil.getPlot(world, id);
 | 
			
		||||
                current.owner = uuid;
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ public class TP extends SubCommand {
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        for (final Plot p : PS.get().getPlots(world).values()) {
 | 
			
		||||
        for (final Plot p : PS.get().getPlotsInWorld(world)) {
 | 
			
		||||
            if ((p.getSettings().getAlias().length() > 0) && p.getSettings().getAlias().equalsIgnoreCase(a)) {
 | 
			
		||||
                return p;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ public class Target extends SubCommand {
 | 
			
		||||
            if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
 | 
			
		||||
                Plot closest = null;
 | 
			
		||||
                int distance = Integer.MAX_VALUE;
 | 
			
		||||
                for (Plot plot : PS.get().getPlots(ploc.getWorld()).values()) {
 | 
			
		||||
                for (Plot plot : PS.get().getPlotsInWorld(ploc.getWorld())) {
 | 
			
		||||
                    double current = plot.getBottom().getEuclideanDistanceSquared(ploc); 
 | 
			
		||||
                    if (current < distance) {
 | 
			
		||||
                        distance = (int) current;
 | 
			
		||||
 
 | 
			
		||||
@@ -116,7 +116,7 @@ public class Trim extends SubCommand {
 | 
			
		||||
        System.currentTimeMillis();
 | 
			
		||||
        sendMessage("Collecting region data...");
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<>();
 | 
			
		||||
        plots.addAll(PS.get().getPlots(world).values());
 | 
			
		||||
        plots.addAll(PS.get().getPlotsInWorld(world));
 | 
			
		||||
        final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
 | 
			
		||||
        sendMessage(" - MCA #: " + chunks.size());
 | 
			
		||||
        sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ public class Visit extends SubCommand {
 | 
			
		||||
            plots = PS.get().sortPlots(PS.get().getPlots(user), SortType.CREATION_DATE, null);
 | 
			
		||||
        } else if (PS.get().isPlotWorld(args[0])) {
 | 
			
		||||
            // do plots by world
 | 
			
		||||
            plots = PS.get().sortPlots(PS.get().getPlots(args[0]).values(), SortType.CREATION_DATE, null);
 | 
			
		||||
            plots = PS.get().sortPlots(PS.get().getPlotsInWorld(args[0]), SortType.CREATION_DATE, null);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            Plot plot = MainUtil.getPlotFromString(plr, args[0], true);
 | 
			
		||||
 
 | 
			
		||||
@@ -163,7 +163,7 @@ public class list extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                plots = new ArrayList<>(PS.get().getPlots(world).values());
 | 
			
		||||
                plots = new ArrayList<>(PS.get().getPlotsInWorld(world));
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            case "all": {
 | 
			
		||||
@@ -268,7 +268,7 @@ public class list extends SubCommand {
 | 
			
		||||
                        MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]);
 | 
			
		||||
                        return false;
 | 
			
		||||
                    }
 | 
			
		||||
                    plots = new ArrayList<>(PS.get().getPlots(args[0]).values());
 | 
			
		||||
                    plots = new ArrayList<>(PS.get().getPlotsInWorld(args[0]));
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                UUID uuid = UUIDHandler.getUUID(args[0], null);
 | 
			
		||||
 
 | 
			
		||||
@@ -104,7 +104,7 @@ public interface AbstractDB {
 | 
			
		||||
     *
 | 
			
		||||
     * @return Integer = Plot Entry Id
 | 
			
		||||
     */
 | 
			
		||||
    int getId(final String world, final PlotId id2);
 | 
			
		||||
    int getId(final Plot plot);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the id of a given plot cluster
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,7 @@ public class DBFunc {
 | 
			
		||||
    public static AbstractDB dbManager;
 | 
			
		||||
 | 
			
		||||
    public static void movePlot(final Plot originalPlot, final Plot newPlot) {
 | 
			
		||||
        if (originalPlot.temp != -1 || newPlot.temp != -1) {
 | 
			
		||||
        if (originalPlot.temp == -1 || newPlot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.movePlot(originalPlot, newPlot);
 | 
			
		||||
@@ -95,7 +95,7 @@ public class DBFunc {
 | 
			
		||||
     * @param uuid New Owner
 | 
			
		||||
     */
 | 
			
		||||
    public static void setOwner(final Plot plot, final UUID uuid) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setOwner(plot, uuid);
 | 
			
		||||
@@ -116,7 +116,7 @@ public class DBFunc {
 | 
			
		||||
     * @param plot Plot to create
 | 
			
		||||
     */
 | 
			
		||||
    public static void createPlot(final Plot plot) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.createPlot(plot);
 | 
			
		||||
@@ -128,7 +128,7 @@ public class DBFunc {
 | 
			
		||||
     * @param plot Plot to create
 | 
			
		||||
     */
 | 
			
		||||
    public static void createPlotAndSettings(final Plot plot) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.createPlotAndSettings(plot);
 | 
			
		||||
@@ -149,7 +149,7 @@ public class DBFunc {
 | 
			
		||||
     * @param plot Plot to delete
 | 
			
		||||
     */
 | 
			
		||||
    public static void delete(final Plot plot) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.delete(plot);
 | 
			
		||||
@@ -166,7 +166,7 @@ public class DBFunc {
 | 
			
		||||
     * @param plot Plot Object
 | 
			
		||||
     */
 | 
			
		||||
    public static void createPlotSettings(final int id, final Plot plot) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.createPlotSettings(id, plot);
 | 
			
		||||
@@ -190,8 +190,8 @@ public class DBFunc {
 | 
			
		||||
     * catch(SQLException e) { e.printStackTrace(); } return Integer.MAX_VALUE;
 | 
			
		||||
     * }
 | 
			
		||||
     */
 | 
			
		||||
    public static int getId(final String world, final PlotId id2) {
 | 
			
		||||
        return dbManager.getId(world, id2);
 | 
			
		||||
    public static int getId(final Plot plot) {
 | 
			
		||||
        return dbManager.getId(plot);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -202,14 +202,14 @@ public class DBFunc {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void setMerged(final Plot plot, final boolean[] merged) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setMerged(plot, merged);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void setFlags(final Plot plot, final Collection<Flag> flags) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setFlags(plot, flags);
 | 
			
		||||
@@ -224,7 +224,7 @@ public class DBFunc {
 | 
			
		||||
     * @param alias
 | 
			
		||||
     */
 | 
			
		||||
    public static void setAlias(final Plot plot, final String alias) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setAlias(plot, alias);
 | 
			
		||||
@@ -243,7 +243,7 @@ public class DBFunc {
 | 
			
		||||
     * @param position
 | 
			
		||||
     */
 | 
			
		||||
    public static void setPosition(final Plot plot, final String position) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setPosition(plot, position);
 | 
			
		||||
@@ -263,14 +263,14 @@ public class DBFunc {
 | 
			
		||||
     * @param comment
 | 
			
		||||
     */
 | 
			
		||||
    public static void removeComment(final Plot plot, final PlotComment comment) {
 | 
			
		||||
        if (plot != null && plot.temp != -1) {
 | 
			
		||||
        if (plot != null && plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.removeComment(plot, comment);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void clearInbox(final Plot plot, final String inbox) {
 | 
			
		||||
        if (plot != null && plot.temp != -1) {
 | 
			
		||||
        if (plot != null && plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.clearInbox(plot, inbox);
 | 
			
		||||
@@ -281,7 +281,7 @@ public class DBFunc {
 | 
			
		||||
     * @param comment
 | 
			
		||||
     */
 | 
			
		||||
    public static void setComment(final Plot plot, final PlotComment comment) {
 | 
			
		||||
        if (plot != null && plot.temp != -1) {
 | 
			
		||||
        if (plot != null && plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setComment(plot, comment);
 | 
			
		||||
@@ -291,7 +291,7 @@ public class DBFunc {
 | 
			
		||||
     * @param plot
 | 
			
		||||
     */
 | 
			
		||||
    public static void getComments(final Plot plot, final String inbox, RunnableVal whenDone) {
 | 
			
		||||
        if (plot != null && plot.temp != -1) {
 | 
			
		||||
        if (plot != null && plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.getComments(plot, inbox, whenDone);
 | 
			
		||||
@@ -302,7 +302,7 @@ public class DBFunc {
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public static void removeTrusted(final Plot plot, final UUID uuid) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.removeTrusted(plot, uuid);
 | 
			
		||||
@@ -337,7 +337,7 @@ public class DBFunc {
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public static void removeMember(final Plot plot, final UUID uuid) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.removeMember(plot, uuid);
 | 
			
		||||
@@ -358,7 +358,7 @@ public class DBFunc {
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public static void setTrusted(final Plot plot, final UUID uuid) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setTrusted(plot, uuid);
 | 
			
		||||
@@ -374,7 +374,7 @@ public class DBFunc {
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public static void setMember(final Plot plot, final UUID uuid) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setMember(plot, uuid);
 | 
			
		||||
@@ -390,7 +390,7 @@ public class DBFunc {
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public static void removeDenied(final Plot plot, final UUID uuid) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.removeDenied(plot, uuid);
 | 
			
		||||
@@ -402,21 +402,21 @@ public class DBFunc {
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
    public static void setDenied(final Plot plot, final UUID uuid) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setDenied(plot, uuid);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static HashMap<UUID, Integer> getRatings(final Plot plot) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return new HashMap<>();
 | 
			
		||||
        }
 | 
			
		||||
        return dbManager.getRatings(plot);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void setRating(Plot plot, UUID rater, int value) {
 | 
			
		||||
        if (plot.temp != -1) {
 | 
			
		||||
        if (plot.temp == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        dbManager.setRating(plot, rater, value);
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
@@ -51,6 +52,7 @@ import com.intellectualcrafters.plot.object.PlotSettings;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RunnableVal;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ClusterManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
 | 
			
		||||
@@ -672,7 +674,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                    stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
 | 
			
		||||
                    stmt.executeUpdate();
 | 
			
		||||
                    stmt.close();
 | 
			
		||||
                    final int id = getId(plot.world, plot.id);
 | 
			
		||||
                    final int id = getId(plot);
 | 
			
		||||
                    stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
 | 
			
		||||
                    stmt.setInt(1, id);
 | 
			
		||||
                    stmt.executeUpdate();
 | 
			
		||||
@@ -760,7 +762,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                PreparedStatement stmt = null;
 | 
			
		||||
                final int id = getId(plot.world, plot.id);
 | 
			
		||||
                final int id = getId(plot);
 | 
			
		||||
                try {
 | 
			
		||||
                    stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_settings` WHERE `plot_plot_id` = ?");
 | 
			
		||||
                    stmt.setInt(1, id);
 | 
			
		||||
@@ -817,15 +819,18 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getId(final String world, final PlotId id2) {
 | 
			
		||||
    public int getId(Plot plot) {
 | 
			
		||||
        if (plot.temp > 0) {
 | 
			
		||||
            return plot.temp;
 | 
			
		||||
        }
 | 
			
		||||
        PreparedStatement stmt = null;
 | 
			
		||||
        try {
 | 
			
		||||
            stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
 | 
			
		||||
            stmt.setInt(1, id2.x);
 | 
			
		||||
            stmt.setInt(2, id2.y);
 | 
			
		||||
            stmt.setString(3, world);
 | 
			
		||||
            stmt.setInt(1, plot.id.x);
 | 
			
		||||
            stmt.setInt(2, plot.id.y);
 | 
			
		||||
            stmt.setString(3, plot.world);
 | 
			
		||||
            final ResultSet r = stmt.executeQuery();
 | 
			
		||||
            int id = Integer.MAX_VALUE;
 | 
			
		||||
            while (r.next()) {
 | 
			
		||||
@@ -833,6 +838,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            }
 | 
			
		||||
            r.close();
 | 
			
		||||
            stmt.close();
 | 
			
		||||
            plot.temp = id;
 | 
			
		||||
            return id;
 | 
			
		||||
        } catch (final SQLException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
@@ -1160,7 +1166,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                    }
 | 
			
		||||
                    final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?");
 | 
			
		||||
                    stmt.setInt(1, n);
 | 
			
		||||
                    stmt.setInt(2, getId(plot.world, plot.id));
 | 
			
		||||
                    stmt.setInt(2, getId(plot));
 | 
			
		||||
                    stmt.execute();
 | 
			
		||||
                    stmt.close();
 | 
			
		||||
                } catch (final SQLException e) {
 | 
			
		||||
@@ -1183,8 +1189,8 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                 */
 | 
			
		||||
                try {
 | 
			
		||||
                    final String world = p1.world;
 | 
			
		||||
                    final int id1 = getId(world, p1.id);
 | 
			
		||||
                    final int id2 = getId(world, p2.id);
 | 
			
		||||
                    final int id1 = getId(p1);
 | 
			
		||||
                    final int id2 = getId(p2);
 | 
			
		||||
                    final PlotId pos1 = p1.getId();
 | 
			
		||||
                    final PlotId pos2 = p2.getId();
 | 
			
		||||
                    PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
 | 
			
		||||
@@ -1212,7 +1218,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final int id = getId(original.world, original.id);
 | 
			
		||||
                    final int id = getId(original);
 | 
			
		||||
                    final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
 | 
			
		||||
                    stmt.setInt(1, newPlot.id.x);
 | 
			
		||||
                    stmt.setInt(2, newPlot.id.y);
 | 
			
		||||
@@ -1243,7 +1249,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?");
 | 
			
		||||
                    stmt.setString(1, flag_string.toString());
 | 
			
		||||
                    stmt.setInt(2, getId(plot.world, plot.id));
 | 
			
		||||
                    stmt.setInt(2, getId(plot));
 | 
			
		||||
                    stmt.execute();
 | 
			
		||||
                    stmt.close();
 | 
			
		||||
                } catch (final SQLException e) {
 | 
			
		||||
@@ -1282,7 +1288,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                try {
 | 
			
		||||
                    stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `alias` = ?  WHERE `plot_plot_id` = ?");
 | 
			
		||||
                    stmt.setString(1, alias);
 | 
			
		||||
                    stmt.setInt(2, getId(plot.world, plot.id));
 | 
			
		||||
                    stmt.setInt(2, getId(plot));
 | 
			
		||||
                    stmt.executeUpdate();
 | 
			
		||||
                    stmt.close();
 | 
			
		||||
                } catch (final SQLException e) {
 | 
			
		||||
@@ -1375,7 +1381,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                try {
 | 
			
		||||
                    stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `position` = ?  WHERE `plot_plot_id` = ?");
 | 
			
		||||
                    stmt.setString(1, position);
 | 
			
		||||
                    stmt.setInt(2, getId(plot.world, plot.id));
 | 
			
		||||
                    stmt.setInt(2, getId(plot));
 | 
			
		||||
                    stmt.executeUpdate();
 | 
			
		||||
                    stmt.close();
 | 
			
		||||
                } catch (final SQLException e) {
 | 
			
		||||
@@ -1566,7 +1572,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
 | 
			
		||||
                    statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
                    statement.setInt(1, getId(plot));
 | 
			
		||||
                    statement.setString(2, uuid.toString());
 | 
			
		||||
                    statement.executeUpdate();
 | 
			
		||||
                    statement.close();
 | 
			
		||||
@@ -1585,7 +1591,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
 | 
			
		||||
                    statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
                    statement.setInt(1, getId(plot));
 | 
			
		||||
                    statement.setString(2, uuid.toString());
 | 
			
		||||
                    statement.executeUpdate();
 | 
			
		||||
                    statement.close();
 | 
			
		||||
@@ -1604,7 +1610,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
 | 
			
		||||
                    statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
                    statement.setInt(1, getId(plot));
 | 
			
		||||
                    statement.setString(2, uuid.toString());
 | 
			
		||||
                    statement.executeUpdate();
 | 
			
		||||
                    statement.close();
 | 
			
		||||
@@ -1641,7 +1647,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
 | 
			
		||||
                    statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
                    statement.setInt(1, getId(plot));
 | 
			
		||||
                    statement.setString(2, uuid.toString());
 | 
			
		||||
                    statement.executeUpdate();
 | 
			
		||||
                    statement.close();
 | 
			
		||||
@@ -1660,7 +1666,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
 | 
			
		||||
                    statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
                    statement.setInt(1, getId(plot));
 | 
			
		||||
                    statement.setString(2, uuid.toString());
 | 
			
		||||
                    statement.executeUpdate();
 | 
			
		||||
                    statement.close();
 | 
			
		||||
@@ -1679,7 +1685,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
 | 
			
		||||
                    statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
                    statement.setInt(1, getId(plot));
 | 
			
		||||
                    statement.setString(2, uuid.toString());
 | 
			
		||||
                    statement.executeUpdate();
 | 
			
		||||
                    statement.close();
 | 
			
		||||
@@ -1696,7 +1702,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
        HashMap<UUID, Integer> map = new HashMap<UUID, Integer>();
 | 
			
		||||
        try {
 | 
			
		||||
            final PreparedStatement statement = this.connection.prepareStatement("SELECT `rating`, `player` FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? ");
 | 
			
		||||
            statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
            statement.setInt(1, getId(plot));
 | 
			
		||||
            final ResultSet set = statement.executeQuery();
 | 
			
		||||
            while (set.next()) {
 | 
			
		||||
                UUID uuid = UUID.fromString(set.getString("player"));
 | 
			
		||||
@@ -1719,7 +1725,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_rating` (`plot_plot_id`, `rating`, `player`) VALUES(?,?,?)");
 | 
			
		||||
                    statement.setInt(1, getId(plot.world, plot.id));
 | 
			
		||||
                    statement.setInt(1, getId(plot));
 | 
			
		||||
                    statement.setInt(2, value);
 | 
			
		||||
                    statement.setString(3, rater.toString());
 | 
			
		||||
                    statement.executeUpdate();
 | 
			
		||||
@@ -2267,46 +2273,127 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void validateAllPlots(Set<Plot> toValidate) {
 | 
			
		||||
//        ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> database = getPlots();
 | 
			
		||||
//        
 | 
			
		||||
//        ArrayList<Plot> toCreate = new ArrayList<>();
 | 
			
		||||
//        ArrayList<UUID> toTrust1 = new ArrayList<>();
 | 
			
		||||
//        ArrayList<Plot> toTrust2 = new ArrayList<>();
 | 
			
		||||
//        
 | 
			
		||||
//        for (Plot plot : plots) {
 | 
			
		||||
//            if (plot.temp) {
 | 
			
		||||
//                continue;
 | 
			
		||||
//            }
 | 
			
		||||
//            ConcurrentHashMap<PlotId, Plot> worldplots = database.get(plot.world);
 | 
			
		||||
//            if (worldplots == null) {
 | 
			
		||||
//                toCreate.add(plot);
 | 
			
		||||
//                continue;
 | 
			
		||||
//            }
 | 
			
		||||
//            Plot dataplot = worldplots.get(plot.id);
 | 
			
		||||
//            if (dataplot == null) {
 | 
			
		||||
//                toCreate.add(plot);
 | 
			
		||||
//                continue;
 | 
			
		||||
//            }
 | 
			
		||||
//            // owner
 | 
			
		||||
//            if (!plot.owner.equals(dataplot)) {
 | 
			
		||||
//                toSet.add(plot);
 | 
			
		||||
//                continue;
 | 
			
		||||
//            }
 | 
			
		||||
//            plot.
 | 
			
		||||
//            // trusted
 | 
			
		||||
//            if (!plot.getTrusted().equals(dataplot.trusted)) {
 | 
			
		||||
//                toSet.add(plot);
 | 
			
		||||
//                continue;
 | 
			
		||||
//            }
 | 
			
		||||
//            if (!plot.getMembers().equals(dataplot.members)) {
 | 
			
		||||
//                toSet.add(plot);
 | 
			
		||||
//                continue;
 | 
			
		||||
//            }
 | 
			
		||||
//            if (!plot.getDenied().equals(dataplot.denied)) {
 | 
			
		||||
//                toSet.add(plot);
 | 
			
		||||
//                continue;
 | 
			
		||||
//            }
 | 
			
		||||
//            ssettings = plot.getSettings();
 | 
			
		||||
//        }
 | 
			
		||||
        PS.debug("$1All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
 | 
			
		||||
        try {
 | 
			
		||||
            connection.commit();
 | 
			
		||||
            connection.setAutoCommit(false);
 | 
			
		||||
        }
 | 
			
		||||
        catch (SQLException e) {}
 | 
			
		||||
        ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> database = getPlots();
 | 
			
		||||
        
 | 
			
		||||
        ArrayList<Plot> toCreate = new ArrayList<>();
 | 
			
		||||
        ArrayList<UUID> toTrusted = new ArrayList<>();
 | 
			
		||||
        ArrayList<Plot> toMember = new ArrayList<>();
 | 
			
		||||
        ArrayList<Plot> toDenied = new ArrayList<>();
 | 
			
		||||
        
 | 
			
		||||
        for (Plot plot : PS.get().getPlotsRaw()) {
 | 
			
		||||
            if (plot.temp == -1) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            ConcurrentHashMap<PlotId, Plot> worldplots = database.get(plot.world);
 | 
			
		||||
            if (worldplots == null) {
 | 
			
		||||
                PS.debug("&8 - &7Creating plot (1): " + plot);
 | 
			
		||||
                toCreate.add(plot);
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            Plot dataplot = worldplots.remove(plot.id);
 | 
			
		||||
            if (dataplot == null) {
 | 
			
		||||
                PS.debug("&8 - &7Creating plot (2): " + plot);
 | 
			
		||||
                toCreate.add(plot);
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            // owner
 | 
			
		||||
            if (!plot.owner.equals(dataplot.owner)) {
 | 
			
		||||
                PS.debug("&8 - &7Setting owner: " + plot +" -> " + MainUtil.getName(plot.owner));
 | 
			
		||||
                setOwner(plot, plot.owner);
 | 
			
		||||
            }
 | 
			
		||||
            // trusted
 | 
			
		||||
            if (!plot.getTrusted().equals(dataplot.trusted)) {
 | 
			
		||||
                HashSet<UUID> toAdd = (HashSet<UUID>) plot.getTrusted().clone();
 | 
			
		||||
                HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getTrusted().clone();
 | 
			
		||||
                toRemove.removeAll(plot.getTrusted());
 | 
			
		||||
                toAdd.removeAll(dataplot.getTrusted());
 | 
			
		||||
                PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " trusted for: " + plot);
 | 
			
		||||
                if (toRemove.size() > 0) {
 | 
			
		||||
                    for (UUID uuid : toRemove) {
 | 
			
		||||
                        removeTrusted(plot, uuid);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (toAdd.size() > 0) {
 | 
			
		||||
                    for (UUID uuid : toAdd) {
 | 
			
		||||
                        setTrusted(plot, uuid);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (!plot.getMembers().equals(dataplot.members)) {
 | 
			
		||||
                HashSet<UUID> toAdd = (HashSet<UUID>) plot.getMembers().clone();
 | 
			
		||||
                HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getMembers().clone();
 | 
			
		||||
                toRemove.removeAll(plot.getMembers());
 | 
			
		||||
                toAdd.removeAll(dataplot.getMembers());
 | 
			
		||||
                PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " members for: " + plot);
 | 
			
		||||
                if (toRemove.size() > 0) {
 | 
			
		||||
                    for (UUID uuid : toRemove) {
 | 
			
		||||
                        removeMember(plot, uuid);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (toAdd.size() > 0) {
 | 
			
		||||
                    for (UUID uuid : toAdd) {
 | 
			
		||||
                        setMember(plot, uuid);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (!plot.getDenied().equals(dataplot.denied)) {
 | 
			
		||||
                HashSet<UUID> toAdd = (HashSet<UUID>) plot.getDenied().clone();
 | 
			
		||||
                HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getDenied().clone();
 | 
			
		||||
                toRemove.removeAll(plot.getDenied());
 | 
			
		||||
                toAdd.removeAll(dataplot.getDenied());
 | 
			
		||||
                PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " denied for: " + plot);
 | 
			
		||||
                if (toRemove.size() > 0) {
 | 
			
		||||
                    for (UUID uuid : toRemove) {
 | 
			
		||||
                        removeDenied(plot, uuid);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (toAdd.size() > 0) {
 | 
			
		||||
                    for (UUID uuid : toAdd) {
 | 
			
		||||
                        setDenied(plot, uuid);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            PlotSettings ps = plot.getSettings();
 | 
			
		||||
            PlotSettings ds = dataplot.getSettings();
 | 
			
		||||
            boolean[] pm = ps.getMerged();
 | 
			
		||||
            boolean[] dm = ds.getMerged();
 | 
			
		||||
            if (pm[0] != dm[0] || pm[1] != dm[1] || pm[1] != dm[1] || pm[1] != dm[1]) {
 | 
			
		||||
                PS.debug("&8 - &7Correcting merge for: " + plot);
 | 
			
		||||
                setMerged(dataplot, ps.getMerged());
 | 
			
		||||
            }
 | 
			
		||||
            HashMap<String, Flag> pf = ps.flags;
 | 
			
		||||
            HashMap<String, Flag> df = ds.flags;
 | 
			
		||||
            if (pf.size() != 0 && df.size() != 0) {
 | 
			
		||||
                if (pf.size() != df.size() || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","),StringMan.joinOrdered(df.values(), ","))) {
 | 
			
		||||
                    PS.debug("&8 - &7Correcting flags for: " + plot);
 | 
			
		||||
                    setFlags(plot, pf.values());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            // TODO comments
 | 
			
		||||
            // TODO ratings
 | 
			
		||||
            // TODO alias
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        for (Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : database.entrySet()) {
 | 
			
		||||
            ConcurrentHashMap<PlotId, Plot> map = entry.getValue();
 | 
			
		||||
            if (map.size() > 0) {
 | 
			
		||||
                for (Entry<PlotId, Plot> entry2 : map.entrySet()) {
 | 
			
		||||
                    PS.debug("$1Plot was deleted: " + entry.getValue() + "// TODO implement this when sure safe");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        PS.debug("$4Done!");
 | 
			
		||||
        try {
 | 
			
		||||
            connection.commit();
 | 
			
		||||
            connection.setAutoCommit(true);
 | 
			
		||||
        }
 | 
			
		||||
        catch (SQLException e) {}
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -125,7 +125,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
            // This means you are in the intersection
 | 
			
		||||
            final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, 0, z + dpw.ROAD_WIDTH);
 | 
			
		||||
            final PlotId id = MainUtil.getPlotAbs(loc);
 | 
			
		||||
            final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
@@ -138,7 +138,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
            // You are on a road running West to East (yeah, I named the var poorly)
 | 
			
		||||
            final Location loc = new Location(plotworld.worldname, x, 0, z + dpw.ROAD_WIDTH);
 | 
			
		||||
            final PlotId id = MainUtil.getPlotAbs(loc);
 | 
			
		||||
            final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
@@ -151,7 +151,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
            // This is the road separating an Eastern and Western plot
 | 
			
		||||
            final Location loc = new Location(plotworld.worldname, x + dpw.ROAD_WIDTH, 0, z);
 | 
			
		||||
            final PlotId id = MainUtil.getPlotAbs(loc);
 | 
			
		||||
            final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
@@ -161,7 +161,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        final PlotId id = new PlotId(dx, dz);
 | 
			
		||||
        final Plot plot = PS.get().getPlots(plotworld.worldname).get(id);
 | 
			
		||||
        final Plot plot = PS.get().getPlot(plotworld.worldname, id);
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return id;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -218,7 +218,7 @@ public class ExpireManager {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static List<Plot> getOldPlots(final String world) {
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots(world).values());
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlotsInWorld(world));
 | 
			
		||||
        final List<Plot> toRemove = new ArrayList<>();
 | 
			
		||||
        Iterator<Plot> iter = plots.iterator();
 | 
			
		||||
        while (iter.hasNext()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
@@ -240,7 +241,7 @@ public class MainUtil {
 | 
			
		||||
                }
 | 
			
		||||
                worldname = PS.get().getPlotWorlds().iterator().next();
 | 
			
		||||
            }
 | 
			
		||||
            for (Plot p : PS.get().getPlots(worldname).values()) {
 | 
			
		||||
            for (Plot p : PS.get().getPlotsInWorld(worldname)) {
 | 
			
		||||
                String name = p.getSettings().getAlias();
 | 
			
		||||
                if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
 | 
			
		||||
                    return p;
 | 
			
		||||
@@ -248,7 +249,7 @@ public class MainUtil {
 | 
			
		||||
            }
 | 
			
		||||
            for (String world : PS.get().getPlotWorlds()) {
 | 
			
		||||
                if (!world.endsWith(worldname)) {
 | 
			
		||||
                    for (Plot p : PS.get().getPlots(world).values()) {
 | 
			
		||||
                    for (Plot p : PS.get().getPlotsInWorld(world)) {
 | 
			
		||||
                        String name = p.getSettings().getAlias();
 | 
			
		||||
                        if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
 | 
			
		||||
                            return p;
 | 
			
		||||
@@ -305,7 +306,7 @@ public class MainUtil {
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
        manager.startPlotUnlink(plotworld, ids);
 | 
			
		||||
        for (final PlotId id : ids) {
 | 
			
		||||
            final Plot myplot = PS.get().getPlots(world).get(id);
 | 
			
		||||
            final Plot myplot = PS.get().getPlot(world, id);
 | 
			
		||||
            if (plot == null) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
@@ -395,8 +396,8 @@ public class MainUtil {
 | 
			
		||||
    
 | 
			
		||||
    public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
 | 
			
		||||
 | 
			
		||||
        final Plot plot1 = PS.get().getPlots(world).get(pos1);
 | 
			
		||||
        final Plot plot2 = PS.get().getPlots(world).get(pos2);
 | 
			
		||||
        final Plot plot1 = PS.get().getPlot(world, pos1);
 | 
			
		||||
        final Plot plot2 = PS.get().getPlot(world, pos2);
 | 
			
		||||
        
 | 
			
		||||
        if (plot1 != null) {
 | 
			
		||||
            pos1 = getBottomPlot(plot1).id;
 | 
			
		||||
@@ -435,7 +436,7 @@ public class MainUtil {
 | 
			
		||||
    public static int getPlayerPlotCount(final String world, final PlotPlayer plr) {
 | 
			
		||||
        final UUID uuid = plr.getUUID();
 | 
			
		||||
        int count = 0;
 | 
			
		||||
        for (final Plot plot : PS.get().getPlots(world).values()) {
 | 
			
		||||
        for (final Plot plot : PS.get().getPlotsInWorld(world)) {
 | 
			
		||||
            if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) {
 | 
			
		||||
                count++;
 | 
			
		||||
            }
 | 
			
		||||
@@ -536,7 +537,7 @@ public class MainUtil {
 | 
			
		||||
        if (!worldBorder.containsKey(world)) {
 | 
			
		||||
            worldBorder.put(world, 0);
 | 
			
		||||
        }
 | 
			
		||||
        for (final Plot plot : PS.get().getPlots(world).values()) {
 | 
			
		||||
        for (final Plot plot : PS.get().getPlotsInWorld(world)) {
 | 
			
		||||
            updateWorldBorder(plot);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -641,7 +642,7 @@ public class MainUtil {
 | 
			
		||||
        for (int x = pos1.x; x <= pos2.x; x++) {
 | 
			
		||||
            for (int y = pos1.y; y <= pos2.y; y++) {
 | 
			
		||||
                final PlotId id = new PlotId(x, y);
 | 
			
		||||
                final Plot plot = PS.get().getPlots(world).get(id);
 | 
			
		||||
                final Plot plot = PS.get().getPlot(world, id);
 | 
			
		||||
                if (removeRoads) {
 | 
			
		||||
                    removeSign(plot);
 | 
			
		||||
                }
 | 
			
		||||
@@ -652,7 +653,7 @@ public class MainUtil {
 | 
			
		||||
                final boolean lx = x < pos2.x;
 | 
			
		||||
                final boolean ly = y < pos2.y;
 | 
			
		||||
                final PlotId id = new PlotId(x, y);
 | 
			
		||||
                final Plot plot = PS.get().getPlots(world).get(id);
 | 
			
		||||
                final Plot plot = PS.get().getPlot(world, id);
 | 
			
		||||
                Plot plot2 = null;
 | 
			
		||||
                if (lx) {
 | 
			
		||||
                    if (ly) {
 | 
			
		||||
@@ -663,7 +664,7 @@ public class MainUtil {
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if (!plot.getSettings().getMerged(1)) {
 | 
			
		||||
                        plot2 = PS.get().getPlots(world).get(new PlotId(x + 1, y));
 | 
			
		||||
                        plot2 = PS.get().getPlot(world, new PlotId(x + 1, y));
 | 
			
		||||
                        mergePlot(world, plot, plot2, removeRoads);
 | 
			
		||||
                        plot.getSettings().setMerged(1, true);
 | 
			
		||||
                        plot2.getSettings().setMerged(3, true);
 | 
			
		||||
@@ -671,7 +672,7 @@ public class MainUtil {
 | 
			
		||||
                }
 | 
			
		||||
                if (ly) {
 | 
			
		||||
                    if (!plot.getSettings().getMerged(2)) {
 | 
			
		||||
                        plot2 = PS.get().getPlots(world).get(new PlotId(x, y + 1));
 | 
			
		||||
                        plot2 = PS.get().getPlot(world, new PlotId(x, y + 1));
 | 
			
		||||
                        mergePlot(world, plot, plot2, removeRoads);
 | 
			
		||||
                        plot.getSettings().setMerged(2, true);
 | 
			
		||||
                        plot2.getSettings().setMerged(0, true);
 | 
			
		||||
@@ -684,7 +685,7 @@ public class MainUtil {
 | 
			
		||||
            for (int x = pos1.x; x <= pos2.x; x++) {
 | 
			
		||||
                for (int y = pos1.y; y <= pos2.y; y++) {
 | 
			
		||||
                    final PlotId id = new PlotId(x, y);
 | 
			
		||||
                    final Plot plot = PS.get().getPlots(world).get(id);
 | 
			
		||||
                    final Plot plot = PS.get().getPlot(world, id);
 | 
			
		||||
                    DBFunc.setMerged(plot, plot.getSettings().getMerged());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -901,7 +902,7 @@ public class MainUtil {
 | 
			
		||||
        final PlotId id_min = plots.get(0);
 | 
			
		||||
        final PlotId id_max = plots.get(plots.size() - 1);
 | 
			
		||||
        for (final PlotId myid : plots) {
 | 
			
		||||
            final Plot myplot = PS.get().getPlots(world).get(myid);
 | 
			
		||||
            final Plot myplot = PS.get().getPlot(world, myid);
 | 
			
		||||
            if ((myplot == null) || myplot.owner == null || !(myplot.owner.equals(uuid))) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
@@ -958,8 +959,7 @@ public class MainUtil {
 | 
			
		||||
     */
 | 
			
		||||
    public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
 | 
			
		||||
        final String w = plot.world;
 | 
			
		||||
        Map<PlotId, Plot> plots = PS.get().getPlots(plot.world);
 | 
			
		||||
        Plot p = plots.get(plot.id);
 | 
			
		||||
        Plot p = PS.get().getPlot(plot.world, plot.id);
 | 
			
		||||
        if (p != null) {
 | 
			
		||||
            return p;
 | 
			
		||||
        }
 | 
			
		||||
@@ -1250,7 +1250,7 @@ public class MainUtil {
 | 
			
		||||
     * @return Location top of mega plot
 | 
			
		||||
     */
 | 
			
		||||
    public static Location getPlotTopLoc(final String world, PlotId id) {
 | 
			
		||||
        final Plot plot = PS.get().getPlots(world).get(id);
 | 
			
		||||
        final Plot plot = PS.get().getPlot(world, id);
 | 
			
		||||
        if (plot != null) {
 | 
			
		||||
            id = getTopPlot(plot).id;
 | 
			
		||||
        }
 | 
			
		||||
@@ -1269,7 +1269,7 @@ public class MainUtil {
 | 
			
		||||
     * @return Location bottom of mega plot
 | 
			
		||||
     */
 | 
			
		||||
    public static Location getPlotBottomLoc(final String world, PlotId id) {
 | 
			
		||||
        final Plot plot = PS.get().getPlots(world).get(id);
 | 
			
		||||
        final Plot plot = PS.get().getPlot(world, id);
 | 
			
		||||
        if (plot != null) {
 | 
			
		||||
            id = getBottomPlot(plot).id;
 | 
			
		||||
        }
 | 
			
		||||
@@ -1310,8 +1310,8 @@ public class MainUtil {
 | 
			
		||||
        for (int x = pos1.x; x <= pos2.x; x++) {
 | 
			
		||||
            for (int y = pos1.y; y <= pos2.y; y++) {
 | 
			
		||||
                final PlotId id = new PlotId(x, y);
 | 
			
		||||
                if (PS.get().getPlots(world).get(id) != null) {
 | 
			
		||||
                    if (PS.get().getPlots(world).get(id).owner != null) {
 | 
			
		||||
                if (PS.get().getPlot(world, id) != null) {
 | 
			
		||||
                    if (PS.get().getPlot(world, id).owner != null) {
 | 
			
		||||
                        return false;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
@@ -1321,8 +1321,8 @@ public class MainUtil {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
 | 
			
		||||
        Plot p1 = PS.get().getPlots(world).get(current);
 | 
			
		||||
        Plot p2 = PS.get().getPlots(world).get(newPlot);
 | 
			
		||||
        Plot p1 = PS.get().getPlot(world, current);
 | 
			
		||||
        Plot p2 = PS.get().getPlot(world, newPlot);
 | 
			
		||||
        if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -1334,20 +1334,21 @@ public class MainUtil {
 | 
			
		||||
        p1.id.y = p2.id.y.intValue();
 | 
			
		||||
        p2.id.x = temp.x;
 | 
			
		||||
        p2.id.y = temp.y;
 | 
			
		||||
        PS.get().getPlots(world).remove(p1.id);
 | 
			
		||||
        PS.get().getPlots(world).remove(p2.id);
 | 
			
		||||
        Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
 | 
			
		||||
        raw.get(world).remove(p1.id);
 | 
			
		||||
        raw.get(world).remove(p2.id);
 | 
			
		||||
        p1.id.recalculateHash();
 | 
			
		||||
        p2.id.recalculateHash();
 | 
			
		||||
        PS.get().getPlots(world).put(p1.id, p1);
 | 
			
		||||
        PS.get().getPlots(world).put(p2.id, p2);
 | 
			
		||||
        raw.get(world).put(p1.id, p1);
 | 
			
		||||
        raw.get(world).put(p2.id, p2);
 | 
			
		||||
        // Swap database
 | 
			
		||||
        DBFunc.dbManager.swapPlots(p2, p1);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
 | 
			
		||||
        Plot p1 = PS.get().getPlots(world).get(current);
 | 
			
		||||
        Plot p2 = PS.get().getPlots(world).get(newPlot);
 | 
			
		||||
        Plot p1 = PS.get().getPlot(world, current);
 | 
			
		||||
        Plot p2 = PS.get().getPlot(world, newPlot);
 | 
			
		||||
        if (p1 == null || p1.owner == null) {
 | 
			
		||||
            if (p2 != null && p2.owner != null) {
 | 
			
		||||
                moveData(p2, p1, whenDone);
 | 
			
		||||
@@ -1368,12 +1369,13 @@ public class MainUtil {
 | 
			
		||||
        p1.id.y = p2.id.y.intValue();
 | 
			
		||||
        p2.id.x = temp.x;
 | 
			
		||||
        p2.id.y = temp.y;
 | 
			
		||||
        PS.get().getPlots(world).remove(p1.id);
 | 
			
		||||
        PS.get().getPlots(world).remove(p2.id);
 | 
			
		||||
        Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
 | 
			
		||||
        raw.get(world).remove(p1.id);
 | 
			
		||||
        raw.get(world).remove(p2.id);
 | 
			
		||||
        p1.id.recalculateHash();
 | 
			
		||||
        p2.id.recalculateHash();
 | 
			
		||||
        PS.get().getPlots(world).put(p1.id, p1);
 | 
			
		||||
        PS.get().getPlots(world).put(p2.id, p2);
 | 
			
		||||
        raw.get(world).put(p1.id, p1);
 | 
			
		||||
        raw.get(world).put(p2.id, p2);
 | 
			
		||||
        // Swap database
 | 
			
		||||
        DBFunc.dbManager.swapPlots(p2, p1);
 | 
			
		||||
        TaskManager.runTask(whenDone);
 | 
			
		||||
@@ -1397,12 +1399,13 @@ public class MainUtil {
 | 
			
		||||
        final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
 | 
			
		||||
        for (final PlotId id : selection) {
 | 
			
		||||
            DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
 | 
			
		||||
            final Plot plot = PS.get().getPlots(plot1.world).get(id);
 | 
			
		||||
            PS.get().getPlots(plot1.world).remove(id);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plot1.world, id);
 | 
			
		||||
            Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
 | 
			
		||||
            raw.get(plot1.world).remove(id);
 | 
			
		||||
            plot.id.x += offset_x;
 | 
			
		||||
            plot.id.y += offset_y;
 | 
			
		||||
            plot.id.recalculateHash();
 | 
			
		||||
            PS.get().getPlots(plot2.world).put(plot.id, plot);
 | 
			
		||||
            raw.get(plot2.world).put(plot.id, plot);
 | 
			
		||||
        }
 | 
			
		||||
        TaskManager.runTaskLater(whenDone, 1);
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -1431,12 +1434,13 @@ public class MainUtil {
 | 
			
		||||
        for (final PlotId id : selection) {
 | 
			
		||||
            String worldOriginal = plot1.world;
 | 
			
		||||
            PlotId idOriginal = new PlotId(id.x, id.y);
 | 
			
		||||
            final Plot plot = PS.get().getPlots(plot1.world).get(id);
 | 
			
		||||
            PS.get().getPlots(plot1.world).remove(id);
 | 
			
		||||
            final Plot plot = PS.get().getPlot(plot1.world, id);
 | 
			
		||||
            Map<String, ConcurrentHashMap<PlotId, Plot>> raw = PS.get().getAllPlotsRaw();
 | 
			
		||||
            raw.get(plot1.world).remove(id);
 | 
			
		||||
            plot.id.x += offset_x;
 | 
			
		||||
            plot.id.y += offset_y;
 | 
			
		||||
            plot.id.recalculateHash();
 | 
			
		||||
            PS.get().getPlots(plot2.world).put(plot.id, plot);
 | 
			
		||||
            raw.get(plot2.world).put(plot.id, plot);
 | 
			
		||||
            DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
 | 
			
		||||
        }
 | 
			
		||||
        ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() {
 | 
			
		||||
@@ -1499,7 +1503,7 @@ public class MainUtil {
 | 
			
		||||
                    DBFunc.setDenied(plot, denied);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            PS.get().getPlots(world).put(plot.id, plot);
 | 
			
		||||
            PS.get().updatePlot(plot);
 | 
			
		||||
        }
 | 
			
		||||
        ChunkManager.manager.copyRegion(bot1, top, bot2, whenDone);
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -1628,14 +1632,14 @@ public class MainUtil {
 | 
			
		||||
 | 
			
		||||
    public static Plot getBottomPlot(final Plot plot) {
 | 
			
		||||
        if (plot.getSettings().getMerged(0)) {
 | 
			
		||||
            final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1));
 | 
			
		||||
            final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x, plot.id.y - 1));
 | 
			
		||||
            if (p == null) {
 | 
			
		||||
                return plot;
 | 
			
		||||
            }
 | 
			
		||||
            return getBottomPlot(p);
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.getSettings().getMerged(3)) {
 | 
			
		||||
            final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y));
 | 
			
		||||
            final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x - 1, plot.id.y));
 | 
			
		||||
            if (p == null) {
 | 
			
		||||
                return plot;
 | 
			
		||||
            }
 | 
			
		||||
@@ -1646,14 +1650,14 @@ public class MainUtil {
 | 
			
		||||
 | 
			
		||||
    public static Plot getTopPlot(final Plot plot) {
 | 
			
		||||
        if (plot.getSettings().getMerged(2)) {
 | 
			
		||||
            final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1));
 | 
			
		||||
            final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x, plot.id.y + 1));
 | 
			
		||||
            if (p == null) {
 | 
			
		||||
                return plot;
 | 
			
		||||
            }
 | 
			
		||||
            return getTopPlot(p);
 | 
			
		||||
        }
 | 
			
		||||
        if (plot.getSettings().getMerged(1)) {
 | 
			
		||||
            final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y));
 | 
			
		||||
            final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x + 1, plot.id.y));
 | 
			
		||||
            if (p == null) {
 | 
			
		||||
                return plot;
 | 
			
		||||
            }
 | 
			
		||||
@@ -1679,8 +1683,9 @@ public class MainUtil {
 | 
			
		||||
        if (id == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (PS.get().getPlots(world).containsKey(id)) {
 | 
			
		||||
            return PS.get().getPlots(world).get(id);
 | 
			
		||||
        Plot plot = PS.get().getPlot(world, id);
 | 
			
		||||
        if (plot != null) {
 | 
			
		||||
            return plot;
 | 
			
		||||
        }
 | 
			
		||||
        return new Plot(world, id, null);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -693,7 +693,7 @@ public abstract class SchematicHandler {
 | 
			
		||||
     * @return tag
 | 
			
		||||
     */
 | 
			
		||||
    public void getCompoundTag(final String world, final PlotId id, RunnableVal<CompoundTag> whenDone) {
 | 
			
		||||
        if (!PS.get().getPlots(world).containsKey(id)) {
 | 
			
		||||
        if (PS.get().getPlot(world, id) == null) {
 | 
			
		||||
            whenDone.run();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
package com.intellectualcrafters.plot.util;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Array;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
@@ -125,6 +127,18 @@ public class StringMan {
 | 
			
		||||
        return join(collection.toArray(), delimiter);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static String joinOrdered(Collection<?> collection, String delimiter) {
 | 
			
		||||
        Object[] array = collection.toArray();
 | 
			
		||||
        Arrays.sort(array, new Comparator<Object>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public int compare(Object a, Object b) {
 | 
			
		||||
                return a.hashCode() - b.hashCode();
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        });
 | 
			
		||||
        return join(array, delimiter);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static String join(Collection<?> collection, char delimiter) {
 | 
			
		||||
        return join(collection.toArray(), delimiter + "");
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user