mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Fix for sponge
This commit is contained in:
		@@ -100,6 +100,7 @@ public class PS {
 | 
			
		||||
    private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
 | 
			
		||||
    
 | 
			
		||||
    // public:
 | 
			
		||||
    public File styleFile;
 | 
			
		||||
    public File configFile;
 | 
			
		||||
    public File translationFile;
 | 
			
		||||
    public YamlConfiguration style;
 | 
			
		||||
@@ -111,7 +112,6 @@ public class PS {
 | 
			
		||||
    public URL update;
 | 
			
		||||
    
 | 
			
		||||
    // private:
 | 
			
		||||
    private File styleFile;
 | 
			
		||||
    private File storageFile;
 | 
			
		||||
    private File FILE = null; // This file
 | 
			
		||||
    private int[] VERSION = null;
 | 
			
		||||
 
 | 
			
		||||
@@ -80,7 +80,7 @@ public class Buy extends SubCommand {
 | 
			
		||||
        if (currentPlots > MainUtil.getAllowedPlots(plr)) {
 | 
			
		||||
            return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
 | 
			
		||||
        }
 | 
			
		||||
        final Flag flag = FlagManager.getPlotFlag(plot, "price");
 | 
			
		||||
        final Flag flag = FlagManager.getPlotFlagRaw(plot, "price");
 | 
			
		||||
        if (flag == null) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_FOR_SALE);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -79,7 +79,7 @@ public class Clear extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if ((FlagManager.getPlotFlag(plot, "done") != null)
 | 
			
		||||
        if ((FlagManager.getPlotFlagRaw(plot, "done") != null)
 | 
			
		||||
        && (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && (MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr))))) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
 | 
			
		||||
            return false;
 | 
			
		||||
@@ -97,10 +97,10 @@ public class Clear extends SubCommand {
 | 
			
		||||
                            public void run() {
 | 
			
		||||
                                plot.removeRunning();
 | 
			
		||||
                                // If the state changes, then mark it as no longer done
 | 
			
		||||
                                if (FlagManager.getPlotFlag(plot, "done") != null) {
 | 
			
		||||
                                if (FlagManager.getPlotFlagRaw(plot, "done") != null) {
 | 
			
		||||
                                    FlagManager.removePlotFlag(plot, "done");
 | 
			
		||||
                                }
 | 
			
		||||
                                if (FlagManager.getPlotFlag(plot, "analysis") != null) {
 | 
			
		||||
                                if (FlagManager.getPlotFlagRaw(plot, "analysis") != null) {
 | 
			
		||||
                                    FlagManager.removePlotFlag(plot, "analysis");
 | 
			
		||||
                                }
 | 
			
		||||
                                MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
 | 
			
		||||
 
 | 
			
		||||
@@ -219,7 +219,7 @@ public class DebugExec extends SubCommand {
 | 
			
		||||
                    }
 | 
			
		||||
                    final String flag = args[1];
 | 
			
		||||
                    for (final Plot plot : PS.get().getPlots()) {
 | 
			
		||||
                        if (FlagManager.getPlotFlag(plot, flag) != null) {
 | 
			
		||||
                        if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
 | 
			
		||||
                            FlagManager.removePlotFlag(plot, flag);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ public class Download extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlag(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
 | 
			
		||||
        if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlagRaw(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,65 +20,21 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.regex.Matcher;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
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.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.object.RunnableVal;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.UUIDHandler;
 | 
			
		||||
import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO)
 | 
			
		||||
public class Info extends SubCommand {
 | 
			
		||||
    
 | 
			
		||||
    public static String getPlayerList(final Collection<UUID> uuids) {
 | 
			
		||||
        final ArrayList<UUID> l = new ArrayList<>(uuids);
 | 
			
		||||
        if ((l == null) || (l.size() < 1)) {
 | 
			
		||||
            return C.NONE.s();
 | 
			
		||||
        }
 | 
			
		||||
        final String c = C.PLOT_USER_LIST.s();
 | 
			
		||||
        final StringBuilder list = new StringBuilder();
 | 
			
		||||
        for (int x = 0; x < l.size(); x++) {
 | 
			
		||||
            if ((x + 1) == l.size()) {
 | 
			
		||||
                list.append(c.replace("%user%", getPlayerName(l.get(x))).replace(",", ""));
 | 
			
		||||
            } else {
 | 
			
		||||
                list.append(c.replace("%user%", getPlayerName(l.get(x))));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return list.toString();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static String getPlayerName(final UUID uuid) {
 | 
			
		||||
        if (uuid == null) {
 | 
			
		||||
            return C.UNKNOWN.s();
 | 
			
		||||
        }
 | 
			
		||||
        if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
 | 
			
		||||
            return "everyone";
 | 
			
		||||
        }
 | 
			
		||||
        final String name = UUIDHandler.getName(uuid);
 | 
			
		||||
        if (name == null) {
 | 
			
		||||
            return "unknown";
 | 
			
		||||
        }
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final PlotPlayer player, String[] args) {
 | 
			
		||||
        String arg = null;
 | 
			
		||||
@@ -166,16 +122,26 @@ public class Info extends SubCommand {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        String info = C.PLOT_INFO.s();
 | 
			
		||||
        boolean full;
 | 
			
		||||
        if (arg != null) {
 | 
			
		||||
            info = getCaption(arg);
 | 
			
		||||
            if (info == null) {
 | 
			
		||||
                MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            formatAndSend(info, plot.world, plot, player, true);
 | 
			
		||||
            full = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            formatAndSend(info, plot.world, plot, player, false);
 | 
			
		||||
            full = false;
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.format(info, plot, player, full, new RunnableVal<String>() {
 | 
			
		||||
            
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
 | 
			
		||||
                MainUtil.sendMessage(player, value, false);
 | 
			
		||||
                MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -205,71 +171,4 @@ public class Info extends SubCommand {
 | 
			
		||||
                return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private void formatAndSend(String info, final String world, final Plot plot, final PlotPlayer player, final boolean full) {
 | 
			
		||||
        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());
 | 
			
		||||
        final String denied = getPlayerList(plot.getDenied());
 | 
			
		||||
        
 | 
			
		||||
        final Flag descriptionFlag = FlagManager.getPlotFlag(plot, "description");
 | 
			
		||||
        final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
 | 
			
		||||
        
 | 
			
		||||
        final String flags = StringMan.replaceFromMap(
 | 
			
		||||
        "$2"
 | 
			
		||||
        + (StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true)
 | 
			
		||||
        .values(), "$1, $2") : C.NONE.s()), C.replacements);
 | 
			
		||||
        final boolean build = plot.isAdded(player.getUUID());
 | 
			
		||||
        
 | 
			
		||||
        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("%num%", num + "");
 | 
			
		||||
        info = info.replaceAll("%desc%", description);
 | 
			
		||||
        info = info.replaceAll("%biome%", biome);
 | 
			
		||||
        info = info.replaceAll("%owner%", owner);
 | 
			
		||||
        info = info.replaceAll("%members%", members);
 | 
			
		||||
        info = info.replaceAll("%trusted%", trusted);
 | 
			
		||||
        info = info.replaceAll("%helpers%", members);
 | 
			
		||||
        info = info.replaceAll("%denied%", denied);
 | 
			
		||||
        info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
 | 
			
		||||
        info = info.replaceAll("%build%", build + "");
 | 
			
		||||
        info = info.replaceAll("%desc%", "No description set.");
 | 
			
		||||
        if (info.contains("%rating%")) {
 | 
			
		||||
            final String newInfo = info;
 | 
			
		||||
            TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    int max = 10;
 | 
			
		||||
                    if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 0)) {
 | 
			
		||||
                        max = 8;
 | 
			
		||||
                    }
 | 
			
		||||
                    String info;
 | 
			
		||||
                    if (full && (Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
 | 
			
		||||
                        String rating = "";
 | 
			
		||||
                        String prefix = "";
 | 
			
		||||
                        final double[] ratings = MainUtil.getAverageRatings(plot);
 | 
			
		||||
                        for (int i = 0; i < ratings.length; i++) {
 | 
			
		||||
                            rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
 | 
			
		||||
                            prefix = ",";
 | 
			
		||||
                        }
 | 
			
		||||
                        info = newInfo.replaceAll("%rating%", rating);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        info = newInfo.replaceAll("%rating%", String.format("%.1f", MainUtil.getAverageRating(plot)) + "/" + max);
 | 
			
		||||
                    }
 | 
			
		||||
                    MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
 | 
			
		||||
                    MainUtil.sendMessage(player, info, false);
 | 
			
		||||
                    MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
 | 
			
		||||
        MainUtil.sendMessage(player, info, false);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@ 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 com.intellectualcrafters.plot.PS;
 | 
			
		||||
@@ -311,15 +310,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
 | 
			
		||||
        if (help_index != -1) {
 | 
			
		||||
            displayHelp(player, category, help_index, cmd);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        final StringBuilder builder = new StringBuilder(cmd).append(" ");
 | 
			
		||||
        final Iterator<String> iterator = Arrays.asList(args).iterator();
 | 
			
		||||
        while (iterator.hasNext()) {
 | 
			
		||||
            builder.append(iterator.next());
 | 
			
		||||
            if (iterator.hasNext()) {
 | 
			
		||||
                builder.append(" ");
 | 
			
		||||
        }
 | 
			
		||||
        if (args[0].contains(":")) {
 | 
			
		||||
            args[0] = args[0].replaceFirst(":", " ");
 | 
			
		||||
        }
 | 
			
		||||
        }
 | 
			
		||||
        String fullCmd = StringMan.join(args, " ");
 | 
			
		||||
        getInstance().handle(player, cmd + " " + fullCmd);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ public class Reload extends SubCommand {
 | 
			
		||||
        try {
 | 
			
		||||
            // The following won't affect world generation, as that has to be
 | 
			
		||||
            // loaded during startup unfortunately.
 | 
			
		||||
            PS.get().style.load(PS.get().styleFile);
 | 
			
		||||
            PS.get().config.load(PS.get().configFile);
 | 
			
		||||
            PS.get().setupConfig();
 | 
			
		||||
            C.load(PS.get().translationFile);
 | 
			
		||||
 
 | 
			
		||||
@@ -252,7 +252,7 @@ public class list extends SubCommand {
 | 
			
		||||
                }
 | 
			
		||||
                plots = new ArrayList<>();
 | 
			
		||||
                for (final Plot plot : PS.get().getPlots()) {
 | 
			
		||||
                    final Flag price = FlagManager.getPlotFlag(plot, "price");
 | 
			
		||||
                    final Flag price = FlagManager.getPlotFlagRaw(plot, "price");
 | 
			
		||||
                    if (price != null) {
 | 
			
		||||
                        plots.add(plot);
 | 
			
		||||
                    }
 | 
			
		||||
@@ -378,9 +378,9 @@ public class list extends SubCommand {
 | 
			
		||||
            } else {
 | 
			
		||||
                color = "$1";
 | 
			
		||||
            }
 | 
			
		||||
            final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", Info.getPlayerList(plot.getTrusted())))).color("$1");
 | 
			
		||||
            final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted())))).color("$1");
 | 
			
		||||
            
 | 
			
		||||
            final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.getMembers())))).color("$1");
 | 
			
		||||
            final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))).color("$1");
 | 
			
		||||
            
 | 
			
		||||
            String strFlags = StringMan.join(plot.getFlags().values(), ",");
 | 
			
		||||
            if (strFlags.length() == 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -451,6 +451,7 @@ public enum C {
 | 
			
		||||
     */
 | 
			
		||||
    NONE("None", "Info"),
 | 
			
		||||
    UNKNOWN("Unknown", "Info"),
 | 
			
		||||
    EVERYONE("Everyone", "Info"),
 | 
			
		||||
    PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"),
 | 
			
		||||
    PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"),
 | 
			
		||||
    PLOT_INFO_HEADER("$3&m---------&r $1INFO $3&m---------", false, "Info"),
 | 
			
		||||
 
 | 
			
		||||
@@ -1297,7 +1297,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
            if ((id == Integer.MAX_VALUE) || (id == 0)) {
 | 
			
		||||
                if (plot.temp > 0) {
 | 
			
		||||
                    return plot.temp;
 | 
			
		||||
                }
 | 
			
		||||
                }
 | 
			
		||||
                throw new SQLException("Plot does not exist in database");
 | 
			
		||||
            }
 | 
			
		||||
            plot.temp = id;
 | 
			
		||||
 
 | 
			
		||||
@@ -20,9 +20,11 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.flag;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringMan;
 | 
			
		||||
 | 
			
		||||
public class Flag {
 | 
			
		||||
public class Flag implements Cloneable {
 | 
			
		||||
    private AbstractFlag key;
 | 
			
		||||
    private Object value;
 | 
			
		||||
    
 | 
			
		||||
@@ -122,4 +124,24 @@ public class Flag {
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        return key.getKey().hashCode();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    protected Object clone() {
 | 
			
		||||
        try {
 | 
			
		||||
            if (value == null) {
 | 
			
		||||
                return super.clone();
 | 
			
		||||
            }
 | 
			
		||||
            if (value instanceof Cloneable) {
 | 
			
		||||
                Method method = value.getClass().getDeclaredMethod("clone");
 | 
			
		||||
                if (!method.isAccessible()) {
 | 
			
		||||
                    method.setAccessible(true);
 | 
			
		||||
                }
 | 
			
		||||
                return new Flag(key, method.invoke(value));
 | 
			
		||||
            }
 | 
			
		||||
            return new Flag(key, key.parseValueRaw(value.toString()));
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -129,13 +129,13 @@ public class FlagManager {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            if (plotworld.DEFAULT_FLAGS.size() == 0) {
 | 
			
		||||
                return null;
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            return plotworld.DEFAULT_FLAGS.get(id);
 | 
			
		||||
        }
 | 
			
		||||
        return flag;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
 | 
			
		||||
        final Flag flag = FlagManager.getPlotFlagRaw(plot, key);
 | 
			
		||||
        if (flag == null) {
 | 
			
		||||
@@ -153,6 +153,11 @@ public class FlagManager {
 | 
			
		||||
     * @param plot
 | 
			
		||||
     * @param flag
 | 
			
		||||
     * @return Flag
 | 
			
		||||
     */
 | 
			
		||||
    public static Flag getPlotFlag(final Plot plot, final String flag) {
 | 
			
		||||
        Flag result = getPlotFlagRaw(plot, flag);
 | 
			
		||||
        return result == null ? null : (Flag) result.clone();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Flag getPlotFlagRaw(final Plot plot, final String flag) {
 | 
			
		||||
        if (!plot.hasOwner()) {
 | 
			
		||||
@@ -163,7 +168,7 @@ public class FlagManager {
 | 
			
		||||
    
 | 
			
		||||
    public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) {
 | 
			
		||||
        if (plot.owner == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Flag flag = getPlotFlagRaw(plot, strFlag);
 | 
			
		||||
        return !((flag == null) || !((Boolean) flag.getValue()));
 | 
			
		||||
@@ -171,7 +176,7 @@ public class FlagManager {
 | 
			
		||||
    
 | 
			
		||||
    public static boolean isPlotFlagFalse(final Plot plot, final String strFlag) {
 | 
			
		||||
        if (plot.owner == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final Flag flag = getPlotFlagRaw(plot, strFlag);
 | 
			
		||||
        if ((flag == null) || ((Boolean) flag.getValue())) {
 | 
			
		||||
 
 | 
			
		||||
@@ -286,7 +286,7 @@ public abstract class FlagValue<T> {
 | 
			
		||||
            return "Flag value must be a number (negative decimals are allowed)";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    public interface ListValue extends Cloneable {
 | 
			
		||||
        void add(final Object t, final String value);
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
@@ -157,4 +157,9 @@ public class ConsolePlayer extends PlotPlayer {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void kick(final String message) {}
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isBanned() {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,9 @@ import java.lang.reflect.Constructor;
 | 
			
		||||
import java.lang.reflect.InvocationTargetException;
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created 2015-02-11 for PlotSquared
 | 
			
		||||
 *
 | 
			
		||||
@@ -70,6 +73,18 @@ public class Location implements Cloneable, Comparable<Location> {
 | 
			
		||||
    public String getWorld() {
 | 
			
		||||
        return world;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotWorld getPlotWorld() {
 | 
			
		||||
        return PS.get().getPlotWorld(world);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotManager getPlotManager() {
 | 
			
		||||
        return PS.get().getPlotManager(world);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Plot getPlot() {
 | 
			
		||||
        return MainUtil.getPlot(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setWorld(final String world) {
 | 
			
		||||
        this.world = world;
 | 
			
		||||
@@ -184,7 +199,7 @@ public class Location implements Cloneable, Comparable<Location> {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private Object getBukkitWorld() {
 | 
			
		||||
        try {
 | 
			
		||||
        try {
 | 
			
		||||
            final Class<?> clazz = Class.forName("org.bukkit.Bukkit");
 | 
			
		||||
            return clazz.getMethod("getWorld", String.class).invoke(null, world);
 | 
			
		||||
        } catch (final Exception e) {
 | 
			
		||||
@@ -196,7 +211,8 @@ public class Location implements Cloneable, Comparable<Location> {
 | 
			
		||||
        if (built) {
 | 
			
		||||
            return o;
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
        try {
 | 
			
		||||
            final Constructor<?> constructor = Class.forName("org.bukkit.Location").getConstructor(Class.forName("org.bukkit.World"), double.class, double.class, double.class, float.class,
 | 
			
		||||
            float.class);
 | 
			
		||||
            built = true;
 | 
			
		||||
            return (o = constructor.newInstance(Class.forName("org.bukkit.World").cast(getBukkitWorld()), x, y, z, yaw, pitch));
 | 
			
		||||
 
 | 
			
		||||
@@ -286,7 +286,7 @@ public class Plot {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (owner == null) {
 | 
			
		||||
            return ClusterManager.getCluster(this);
 | 
			
		||||
            return ClusterManager.getCluster(this);
 | 
			
		||||
        }
 | 
			
		||||
        Flag flag = FlagManager.getPlotFlagRaw(this, "cluster");
 | 
			
		||||
        if (flag != null) {
 | 
			
		||||
@@ -650,7 +650,7 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the flag for a given key
 | 
			
		||||
     * @param flag
 | 
			
		||||
     */
 | 
			
		||||
     */
 | 
			
		||||
    public Flag getFlag(final String key) {
 | 
			
		||||
        return FlagManager.getPlotFlagRaw(this, key);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ public class PlotAnalysis {
 | 
			
		||||
    public static PlotAnalysis MODIFIERS = new PlotAnalysis();
 | 
			
		||||
    
 | 
			
		||||
    public static PlotAnalysis getAnalysis(final Plot plot) {
 | 
			
		||||
        final Flag flag = FlagManager.getPlotFlag(plot, "analysis");
 | 
			
		||||
        final Flag flag = FlagManager.getPlotFlagRaw(plot, "analysis");
 | 
			
		||||
        if (flag != null) {
 | 
			
		||||
            final PlotAnalysis analysis = new PlotAnalysis();
 | 
			
		||||
            final List<Integer> values = (List<Integer>) flag.getValue();
 | 
			
		||||
 
 | 
			
		||||
@@ -6,11 +6,15 @@ import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.commands.RequiredType;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.util.EventUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ExpireManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.PlotGamemode;
 | 
			
		||||
import com.intellectualcrafters.plot.util.PlotWeather;
 | 
			
		||||
import com.intellectualcrafters.plot.util.UUIDHandler;
 | 
			
		||||
import com.plotsquared.general.commands.CommandCaller;
 | 
			
		||||
import com.plotsquared.listener.PlotListener;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created 2015-02-20 for PlotSquared
 | 
			
		||||
@@ -301,9 +305,35 @@ public abstract class PlotPlayer implements CommandCaller {
 | 
			
		||||
     * @param id
 | 
			
		||||
     */
 | 
			
		||||
    public abstract void playMusic(final Location loc, final int id);
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if the player is banned
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public abstract boolean isBanned();
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Kick the player from the game
 | 
			
		||||
     * @param message
 | 
			
		||||
     */
 | 
			
		||||
    public abstract void kick(final String message);
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the player quits
 | 
			
		||||
     */
 | 
			
		||||
    public void unregister() {
 | 
			
		||||
        final Plot plot = getCurrentPlot();
 | 
			
		||||
        if (plot != null) {
 | 
			
		||||
            PlotListener.plotExit(this, plot);
 | 
			
		||||
        }
 | 
			
		||||
        ExpireManager.dates.put(getUUID(), System.currentTimeMillis());
 | 
			
		||||
        EventUtil.unregisterPlayer(this);
 | 
			
		||||
        if (Settings.DELETE_PLOTS_ON_BAN && isBanned()) {
 | 
			
		||||
            for (final Plot owned : PS.get().getPlotsInWorld(getName())) {
 | 
			
		||||
                owned.deletePlot(null);
 | 
			
		||||
                PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), getName()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        UUIDHandler.getPlayers().remove(getName());
 | 
			
		||||
        PS.get().IMP.unregister(this);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,4 +5,9 @@ public abstract class RunnableVal<T> implements Runnable {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public abstract void run();
 | 
			
		||||
    
 | 
			
		||||
    public void run(T value) {
 | 
			
		||||
        this.value = value;
 | 
			
		||||
        run();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,17 @@
 | 
			
		||||
package com.intellectualcrafters.plot.util;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
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.PlotLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RegionWrapper;
 | 
			
		||||
import com.intellectualcrafters.plot.object.RunnableVal;
 | 
			
		||||
@@ -103,17 +105,72 @@ public abstract class ChunkManager {
 | 
			
		||||
    
 | 
			
		||||
    public abstract void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
 | 
			
		||||
    
 | 
			
		||||
    public abstract Set<ChunkLoc> getChunkChunks(final String world);
 | 
			
		||||
    public Set<ChunkLoc> getChunkChunks(final String world) {
 | 
			
		||||
        final String directory = PS.get().IMP.getWorldContainer() + File.separator + world + File.separator + "region";
 | 
			
		||||
        final File folder = new File(directory);
 | 
			
		||||
        final File[] regionFiles = folder.listFiles();
 | 
			
		||||
        final HashSet<ChunkLoc> chunks = new HashSet<>();
 | 
			
		||||
        if (regionFiles == null) {
 | 
			
		||||
            throw new RuntimeException("Could not find worlds folder.");
 | 
			
		||||
        }
 | 
			
		||||
        for (final File file : regionFiles) {
 | 
			
		||||
            final String name = file.getName();
 | 
			
		||||
            if (name.endsWith("mca")) {
 | 
			
		||||
                final String[] split = name.split("\\.");
 | 
			
		||||
                try {
 | 
			
		||||
                    final int x = Integer.parseInt(split[1]);
 | 
			
		||||
                    final int z = Integer.parseInt(split[2]);
 | 
			
		||||
                    final ChunkLoc loc = new ChunkLoc(x, z);
 | 
			
		||||
                    chunks.add(loc);
 | 
			
		||||
                } catch (final Exception e) {}
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return chunks;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public abstract void regenerateChunk(final String world, final ChunkLoc loc);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
 | 
			
		||||
    public void deleteRegionFiles(String world, List<ChunkLoc> chunks) {
 | 
			
		||||
        deleteRegionFiles(world, chunks, null);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks);
 | 
			
		||||
    public void deleteRegionFiles(final String world, final List<ChunkLoc> chunks, final Runnable whenDone) {
 | 
			
		||||
        TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                for (final ChunkLoc loc : chunks) {
 | 
			
		||||
                    final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
 | 
			
		||||
                    final File file = new File(PS.get().IMP.getWorldContainer(), directory);
 | 
			
		||||
                    PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
 | 
			
		||||
                    if (file.exists()) {
 | 
			
		||||
                        file.delete();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (whenDone != null) {
 | 
			
		||||
                    whenDone.run();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks, final Runnable whenDone);
 | 
			
		||||
    
 | 
			
		||||
    public abstract Plot hasPlot(String world, ChunkLoc chunk);
 | 
			
		||||
    public Plot hasPlot(String world, ChunkLoc chunk) {
 | 
			
		||||
        final int x1 = chunk.x << 4;
 | 
			
		||||
        final int z1 = chunk.z << 4;
 | 
			
		||||
        final int x2 = x1 + 15;
 | 
			
		||||
        final int z2 = z1 + 15;
 | 
			
		||||
        final Location bot = new Location(world, x1, 0, z1);
 | 
			
		||||
        Plot plot;
 | 
			
		||||
        plot = MainUtil.getPlotAbs(bot);
 | 
			
		||||
        if ((plot != null) && (plot.owner != null)) {
 | 
			
		||||
            return plot;
 | 
			
		||||
        }
 | 
			
		||||
        final Location top = new Location(world, x2, 0, z2);
 | 
			
		||||
        plot = MainUtil.getPlotAbs(top);
 | 
			
		||||
        if ((plot != null) && (plot.owner != null)) {
 | 
			
		||||
            return plot;
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Copy a region to a new location (in the same world)
 | 
			
		||||
 
 | 
			
		||||
@@ -86,14 +86,14 @@ public abstract class EventUtil {
 | 
			
		||||
                if (!plot.hasOwner()) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
 | 
			
		||||
                }
 | 
			
		||||
                final Flag use = FlagManager.getPlotFlag(plot, "use");
 | 
			
		||||
                final Flag use = FlagManager.getPlotFlagRaw(plot, "use");
 | 
			
		||||
                if (use != null) {
 | 
			
		||||
                    final HashSet<PlotBlock> value = (HashSet<PlotBlock>) use.getValue();
 | 
			
		||||
                    if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                final Flag destroy = FlagManager.getPlotFlag(plot, "break");
 | 
			
		||||
                final Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
 | 
			
		||||
                if (destroy != null) {
 | 
			
		||||
                    final HashSet<PlotBlock> value = (HashSet<PlotBlock>) destroy.getValue();
 | 
			
		||||
                    if (value.contains(PlotBlock.EVERYTHING) || value.contains(block.getPlotBlock())) {
 | 
			
		||||
@@ -142,7 +142,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (!plot.hasOwner()) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "use");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -156,7 +156,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (!plot.hasOwner()) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "place");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -173,7 +173,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "use");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -190,7 +190,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "use");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -207,7 +207,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "use");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -224,7 +224,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "use");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -242,7 +242,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "mob-place")) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "place");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -278,7 +278,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "place");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
@@ -296,7 +296,7 @@ public abstract class EventUtil {
 | 
			
		||||
                if (FlagManager.isPlotFlagTrue(plot, "vehicle-place")) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlag(plot, "place");
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
 | 
			
		||||
                final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
 | 
			
		||||
                if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
 | 
			
		||||
                    return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
 | 
			
		||||
 
 | 
			
		||||
@@ -223,7 +223,7 @@ public class ExpireManager {
 | 
			
		||||
        final Iterator<Plot> iter = plots.iterator();
 | 
			
		||||
        while (iter.hasNext()) {
 | 
			
		||||
            final Plot plot = iter.next();
 | 
			
		||||
            final Flag keepFlag = FlagManager.getPlotFlag(plot, "keep");
 | 
			
		||||
            final Flag keepFlag = FlagManager.getPlotFlagRaw(plot, "keep");
 | 
			
		||||
            if ((keepFlag != null) && (Boolean) keepFlag.getValue()) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -34,12 +34,14 @@ import java.util.Set;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		||||
import java.util.regex.Matcher;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
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.BlockLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
@@ -269,6 +271,8 @@ public class MainUtil {
 | 
			
		||||
    
 | 
			
		||||
    public static String getName(final UUID owner) {
 | 
			
		||||
        if (owner == null) {
 | 
			
		||||
            return C.NONE.s();
 | 
			
		||||
        } else if (owner.equals(DBFunc.everyone)) {
 | 
			
		||||
            return C.EVERYONE.s();
 | 
			
		||||
        }
 | 
			
		||||
        final String name = UUIDHandler.getName(owner);
 | 
			
		||||
@@ -518,10 +522,14 @@ public class MainUtil {
 | 
			
		||||
        final boolean result = EventUtil.manager.callUnlink(plot.world, ids);
 | 
			
		||||
        if (!result) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        }
 | 
			
		||||
        if (createSign) {
 | 
			
		||||
            plot.removeSign();
 | 
			
		||||
        }
 | 
			
		||||
        final PlotManager manager = PS.get().getPlotManager(plot.world);
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
 | 
			
		||||
        if (createRoad) {
 | 
			
		||||
            manager.startPlotUnlink(plotworld, ids);
 | 
			
		||||
        }
 | 
			
		||||
        if ((plotworld.TERRAIN != 3) && createRoad) {
 | 
			
		||||
            for (Plot current : plots) {
 | 
			
		||||
@@ -545,7 +553,9 @@ public class MainUtil {
 | 
			
		||||
            if (createSign) {
 | 
			
		||||
                MainUtil.setSign(getName(current.owner), current);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        }
 | 
			
		||||
        if (createRoad) {
 | 
			
		||||
            manager.finishPlotUnlink(plotworld, ids);
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
@@ -2157,8 +2167,13 @@ public class MainUtil {
 | 
			
		||||
            tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 0));
 | 
			
		||||
            if (!tmp.getMerged(2)) {
 | 
			
		||||
                // invalid merge
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                tmp.getSettings().setMerged(2, true);
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                if (tmp.hasOwner()) {
 | 
			
		||||
                    tmp.getSettings().setMerged(2, true);
 | 
			
		||||
                    DBFunc.setMerged(tmp, tmp.settings.getMerged());
 | 
			
		||||
                } else {
 | 
			
		||||
                    plot.getSettings().setMerged(0, false);
 | 
			
		||||
                    DBFunc.setMerged(plot, plot.settings.getMerged());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            queuecache.add(tmp);
 | 
			
		||||
@@ -2168,8 +2183,13 @@ public class MainUtil {
 | 
			
		||||
            tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 1));
 | 
			
		||||
            if (!tmp.getMerged(3)) {
 | 
			
		||||
                // invalid merge
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                tmp.getSettings().setMerged(3, true);
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                if (tmp.hasOwner()) {
 | 
			
		||||
                    tmp.getSettings().setMerged(3, true);
 | 
			
		||||
                    DBFunc.setMerged(tmp, tmp.settings.getMerged());
 | 
			
		||||
                } else {
 | 
			
		||||
                    plot.getSettings().setMerged(1, false);
 | 
			
		||||
                    DBFunc.setMerged(plot, plot.settings.getMerged());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            queuecache.add(tmp);
 | 
			
		||||
@@ -2179,8 +2199,13 @@ public class MainUtil {
 | 
			
		||||
            tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 2));
 | 
			
		||||
            if (!tmp.getMerged(0)) {
 | 
			
		||||
                // invalid merge
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                tmp.getSettings().setMerged(0, true);
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                if (tmp.hasOwner()) {
 | 
			
		||||
                    tmp.getSettings().setMerged(0, true);
 | 
			
		||||
                    DBFunc.setMerged(tmp, tmp.settings.getMerged());
 | 
			
		||||
                } else {
 | 
			
		||||
                    plot.getSettings().setMerged(2, false);
 | 
			
		||||
                    DBFunc.setMerged(plot, plot.settings.getMerged());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            queuecache.add(tmp);
 | 
			
		||||
@@ -2190,8 +2215,13 @@ public class MainUtil {
 | 
			
		||||
            tmp = getPlotAbs(plot.world, getPlotIdRelative(plot.id, 3));
 | 
			
		||||
            if (!tmp.getMerged(1)) {
 | 
			
		||||
                // invalid merge
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                tmp.getSettings().setMerged(1, true);
 | 
			
		||||
                PS.debug("Fixing invalid merge: " + plot);
 | 
			
		||||
                if (tmp.hasOwner()) {
 | 
			
		||||
                    tmp.getSettings().setMerged(1, true);
 | 
			
		||||
                    DBFunc.setMerged(tmp, tmp.settings.getMerged());
 | 
			
		||||
                } else {
 | 
			
		||||
                    plot.getSettings().setMerged(3, false);
 | 
			
		||||
                    DBFunc.setMerged(plot, plot.settings.getMerged());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            queuecache.add(tmp);
 | 
			
		||||
@@ -2381,4 +2411,84 @@ public class MainUtil {
 | 
			
		||||
    
 | 
			
		||||
    public static boolean setComponent(final Plot plot, final String component, final PlotBlock[] blocks) {
 | 
			
		||||
        return PS.get().getPlotManager(plot.world).setComponent(PS.get().getPlotWorld(plot.world), plot.id, component, blocks);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static void format(String info, final Plot plot, final PlotPlayer player, final boolean full, final RunnableVal<String> whenDone) {
 | 
			
		||||
        final int num = MainUtil.getConnectedPlots(plot).size();
 | 
			
		||||
        final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
 | 
			
		||||
        final Location bot = plot.getBottom();
 | 
			
		||||
        final String biome = BlockManager.manager.getBiome(plot.world, bot.getX(), bot.getZ());
 | 
			
		||||
        final String trusted = getPlayerList(plot.getTrusted());
 | 
			
		||||
        final String members = getPlayerList(plot.getMembers());
 | 
			
		||||
        final String denied = getPlayerList(plot.getDenied());
 | 
			
		||||
        
 | 
			
		||||
        final Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
 | 
			
		||||
        final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
 | 
			
		||||
        
 | 
			
		||||
        final String flags = StringMan.replaceFromMap(
 | 
			
		||||
        "$2"
 | 
			
		||||
        + (StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true)
 | 
			
		||||
        .values(), "$1, $2") : C.NONE.s()), C.replacements);
 | 
			
		||||
        final boolean build = plot.isAdded(player.getUUID());
 | 
			
		||||
        
 | 
			
		||||
        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("%num%", num + "");
 | 
			
		||||
        info = info.replaceAll("%desc%", description);
 | 
			
		||||
        info = info.replaceAll("%biome%", biome);
 | 
			
		||||
        info = info.replaceAll("%owner%", owner);
 | 
			
		||||
        info = info.replaceAll("%members%", members);
 | 
			
		||||
        info = info.replaceAll("%trusted%", trusted);
 | 
			
		||||
        info = info.replaceAll("%helpers%", members);
 | 
			
		||||
        info = info.replaceAll("%denied%", denied);
 | 
			
		||||
        info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
 | 
			
		||||
        info = info.replaceAll("%build%", build + "");
 | 
			
		||||
        info = info.replaceAll("%desc%", "No description set.");
 | 
			
		||||
        if (info.contains("%rating%")) {
 | 
			
		||||
            final String newInfo = info;
 | 
			
		||||
            TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    int max = 10;
 | 
			
		||||
                    if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 0)) {
 | 
			
		||||
                        max = 8;
 | 
			
		||||
                    }
 | 
			
		||||
                    String info;
 | 
			
		||||
                    if (full && (Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
 | 
			
		||||
                        String rating = "";
 | 
			
		||||
                        String prefix = "";
 | 
			
		||||
                        final double[] ratings = MainUtil.getAverageRatings(plot);
 | 
			
		||||
                        for (int i = 0; i < ratings.length; i++) {
 | 
			
		||||
                            rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
 | 
			
		||||
                            prefix = ",";
 | 
			
		||||
                        }
 | 
			
		||||
                        info = newInfo.replaceAll("%rating%", rating);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        info = newInfo.replaceAll("%rating%", String.format("%.1f", MainUtil.getAverageRating(plot)) + "/" + max);
 | 
			
		||||
                    }
 | 
			
		||||
                    whenDone.run(info);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        whenDone.run(info);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static String getPlayerList(final Collection<UUID> uuids) {
 | 
			
		||||
        final ArrayList<UUID> l = new ArrayList<>(uuids);
 | 
			
		||||
        if ((l == null) || (l.size() < 1)) {
 | 
			
		||||
            return C.NONE.s();
 | 
			
		||||
        }
 | 
			
		||||
        final String c = C.PLOT_USER_LIST.s();
 | 
			
		||||
        final StringBuilder list = new StringBuilder();
 | 
			
		||||
        for (int x = 0; x < l.size(); x++) {
 | 
			
		||||
            if ((x + 1) == l.size()) {
 | 
			
		||||
                list.append(c.replace("%user%", getName(l.get(x))).replace(",", ""));
 | 
			
		||||
            } else {
 | 
			
		||||
                list.append(c.replace("%user%", getName(l.get(x))));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return list.toString();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user