mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Fixes
Fixes #556 Fixes #540 Fixed plot analysis being slow Fixed auto updating
This commit is contained in:
		@@ -109,6 +109,7 @@ public class PS {
 | 
			
		||||
    private File storageFile;
 | 
			
		||||
    private File FILE = null; // This file
 | 
			
		||||
    private int[] VERSION = null;
 | 
			
		||||
    private String PLATFORM = null;
 | 
			
		||||
    private String LAST_VERSION;
 | 
			
		||||
    private boolean LOADING_WORLD = false;
 | 
			
		||||
    private ConcurrentHashMap<String, ConcurrentHashMap<PlotId, Plot>> plots;
 | 
			
		||||
@@ -120,7 +121,7 @@ public class PS {
 | 
			
		||||
     * Initialize PlotSquared with the desired Implementation class
 | 
			
		||||
     * @param imp_class
 | 
			
		||||
     */
 | 
			
		||||
    public PS(final IPlotMain imp_class) {
 | 
			
		||||
    public PS(final IPlotMain imp_class, String platform) {
 | 
			
		||||
        try {
 | 
			
		||||
            instance = this;
 | 
			
		||||
            this.thread = Thread.currentThread();
 | 
			
		||||
@@ -135,13 +136,11 @@ public class PS {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared.jar");
 | 
			
		||||
                if (!FILE.exists()) {
 | 
			
		||||
                    FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared-Bukkit.jar");
 | 
			
		||||
                    if (!FILE.exists()) {
 | 
			
		||||
                        FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared-Sponge.jar");
 | 
			
		||||
                    }
 | 
			
		||||
                    FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared-" + platform + ".jar");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            VERSION = IMP.getPluginVersion();
 | 
			
		||||
            PLATFORM = platform;
 | 
			
		||||
            EconHandler.manager = IMP.getEconomyHandler();
 | 
			
		||||
            if (getJavaVersion() < 1.7) {
 | 
			
		||||
                log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
 | 
			
		||||
@@ -220,9 +219,6 @@ public class PS {
 | 
			
		||||
                    URL url = getUpdate();
 | 
			
		||||
                    if (url != null) {
 | 
			
		||||
                        update = url;
 | 
			
		||||
                        log("&6You are running an older version of PlotSquared...");
 | 
			
		||||
                        log("&8 - &3Use: &7/plot update");
 | 
			
		||||
                        log("&8 - &3Or: &7" + url);
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (LAST_VERSION != null && !StringMan.join(VERSION,".").equals(LAST_VERSION)) {
 | 
			
		||||
                        log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
 | 
			
		||||
@@ -324,6 +320,14 @@ public class PS {
 | 
			
		||||
    public int[] getVersion() {
 | 
			
		||||
        return VERSION;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the platform this is running on (Bukkit, Sponge)
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public String getPlatform() {
 | 
			
		||||
        return PLATFORM;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Log a message to the IPlotMain logger
 | 
			
		||||
@@ -1412,48 +1416,38 @@ public class PS {
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public URL getUpdate() {
 | 
			
		||||
        String resource = "plotsquared.1177";
 | 
			
		||||
        String url = "https://www.spigotmc.org/resources/" + resource + "/history";
 | 
			
		||||
        String download = "<a href=\"resources/" + resource + "/download?version=";
 | 
			
		||||
        String version = "<td class=\"version\">";
 | 
			
		||||
        String pom = "https://raw.githubusercontent.com/IntellectualSites/PlotSquared/master/pom.xml";
 | 
			
		||||
        String dl = "https://raw.githubusercontent.com/IntellectualSites/PlotSquared/master/target/PlotSquared-${PLATFORM}.jar";
 | 
			
		||||
        String agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1";
 | 
			
		||||
        try {
 | 
			
		||||
            URL history = new URL(url);
 | 
			
		||||
            URLConnection con = history.openConnection();
 | 
			
		||||
            con.addRequestProperty("User-Agent", "Mozilla/5.0");
 | 
			
		||||
            InputStream stream = con.getInputStream();
 | 
			
		||||
            BufferedReader in = new BufferedReader(new InputStreamReader(stream));
 | 
			
		||||
            String l;
 | 
			
		||||
            URL link = null;
 | 
			
		||||
            String cur_ver = config.getString("version");
 | 
			
		||||
            String new_ver = null;
 | 
			
		||||
            while ((l = in.readLine()) != null) {
 | 
			
		||||
                if (l.length() > version.length() && l.startsWith(version)) {
 | 
			
		||||
                    new_ver = l.substring(version.length(), l.length() - 5);
 | 
			
		||||
            URL page = new URL(pom);
 | 
			
		||||
            URLConnection con = page.openConnection();
 | 
			
		||||
            con.addRequestProperty("User-Agent", agent);
 | 
			
		||||
            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
 | 
			
		||||
            String line = null;
 | 
			
		||||
            while ((line = in.readLine()) !=  null) {
 | 
			
		||||
                line = line.trim();
 | 
			
		||||
                if (line.startsWith("<version>")) {
 | 
			
		||||
                    line = line.replaceAll("[^\\d.]", "");
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                if (link == null && l.length() > download.length() && l.startsWith(download)) {
 | 
			
		||||
                    String subString = l.substring(download.length());
 | 
			
		||||
                    link = new URL("https://www.spigotmc.org/resources/" + resource + "/download?version=" + subString.substring(0, subString.indexOf("\"")));
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            stream.close();
 | 
			
		||||
            in.close();
 | 
			
		||||
            if (new_ver == null || !canUpdate(cur_ver, new_ver))  {
 | 
			
		||||
            if (!canUpdate(config.getString("version"), line) ) {
 | 
			
		||||
                PS.debug("&7PlotSquared is already up to date!");
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            if (link == null) {
 | 
			
		||||
                PS.debug("&dCould not check for updates (1)");
 | 
			
		||||
                PS.debug("&7 - Manually check for updates: " + url);
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            return link;
 | 
			
		||||
            dl = dl.replaceAll("${PLATFORM}", getPlatform());
 | 
			
		||||
            log("&6PlotSquared v" + line + " is available:");
 | 
			
		||||
            log("&8 - &3Use: &7/plot update");
 | 
			
		||||
            log("&8 - &3Or: &7" + dl);
 | 
			
		||||
            return new URL(dl);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            PS.debug("&dCould not check for updates (2)");
 | 
			
		||||
            PS.debug("&7 - Manually check for updates: " + url);
 | 
			
		||||
            return null;
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            log("&dCould not check for updates (0)");
 | 
			
		||||
            log("&7 - Manually check for updates: " + pom);
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean update(PlotPlayer sender, URL url) {
 | 
			
		||||
@@ -1505,7 +1499,6 @@ public class PS {
 | 
			
		||||
     */
 | 
			
		||||
    public void copyFile(String file, String folder) {
 | 
			
		||||
        try {
 | 
			
		||||
            byte[] buffer = new byte[2048];
 | 
			
		||||
            File output = IMP.getDirectory();
 | 
			
		||||
            if (!output.exists()) {
 | 
			
		||||
                output.mkdirs();
 | 
			
		||||
@@ -1514,26 +1507,39 @@ public class PS {
 | 
			
		||||
            if (newFile.exists()) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE));
 | 
			
		||||
            ZipEntry ze = zis.getNextEntry();
 | 
			
		||||
            while (ze != null) {
 | 
			
		||||
                String name = ze.getName();
 | 
			
		||||
                if (name.equals(file)) {
 | 
			
		||||
                    new File(newFile.getParent()).mkdirs();
 | 
			
		||||
                    FileOutputStream fos = new FileOutputStream(newFile);
 | 
			
		||||
                    int len;
 | 
			
		||||
                    while ((len = zis.read(buffer)) > 0) {
 | 
			
		||||
                        fos.write(buffer, 0, len);
 | 
			
		||||
            InputStream stream = IMP.getClass().getResourceAsStream(file);
 | 
			
		||||
            byte[] buffer = new byte[2048];
 | 
			
		||||
            if (stream == null) {
 | 
			
		||||
                ZipInputStream zis = new ZipInputStream(new FileInputStream(FILE));
 | 
			
		||||
                ZipEntry ze = zis.getNextEntry();
 | 
			
		||||
                while (ze != null) {
 | 
			
		||||
                    String name = ze.getName();
 | 
			
		||||
                    if (name.equals(file)) {
 | 
			
		||||
                        new File(newFile.getParent()).mkdirs();
 | 
			
		||||
                        FileOutputStream fos = new FileOutputStream(newFile);
 | 
			
		||||
                        int len;
 | 
			
		||||
                        while ((len = zis.read(buffer)) > 0) {
 | 
			
		||||
                            fos.write(buffer, 0, len);
 | 
			
		||||
                        }
 | 
			
		||||
                        fos.close();
 | 
			
		||||
                        ze = null;
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        ze = zis.getNextEntry();
 | 
			
		||||
                    }
 | 
			
		||||
                    fos.close();
 | 
			
		||||
                    ze = null;
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    ze = zis.getNextEntry();
 | 
			
		||||
                }
 | 
			
		||||
                zis.closeEntry();
 | 
			
		||||
                zis.close();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            zis.closeEntry();
 | 
			
		||||
            zis.close();
 | 
			
		||||
            newFile.createNewFile();
 | 
			
		||||
            FileOutputStream fos = new FileOutputStream(newFile);
 | 
			
		||||
            int len;
 | 
			
		||||
            while ((len = stream.read(buffer)) > 0) {
 | 
			
		||||
                fos.write(buffer, 0, len);
 | 
			
		||||
            }
 | 
			
		||||
            fos.close();
 | 
			
		||||
            stream.close();
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
@@ -1726,6 +1732,7 @@ public class PS {
 | 
			
		||||
    public void setupConfig() {
 | 
			
		||||
        LAST_VERSION = config.getString("version");
 | 
			
		||||
        config.set("version", StringMan.join(VERSION,"."));
 | 
			
		||||
        config.set("platform", PLATFORM);
 | 
			
		||||
        
 | 
			
		||||
        final Map<String, Object> options = new HashMap<>();
 | 
			
		||||
        // Command confirmation
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,7 @@ public class Clear extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (Settings.DONE_RESTRICTS_BUILDING && FlagManager.isPlotFlagTrue(plot, "done" ) && (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr)))) {
 | 
			
		||||
        if (FlagManager.isPlotFlagTrue(plot, "done" ) && (!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;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -60,6 +60,10 @@ public class Continue extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (FlagManager.isPlotFlagTrue(plot, "done" ) && (!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;
 | 
			
		||||
        }
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
 | 
			
		||||
            return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -124,11 +124,11 @@ public class FlagCmd extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
 | 
			
		||||
                final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
 | 
			
		||||
                if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase()) && !Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase())) {
 | 
			
		||||
                    MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
 | 
			
		||||
                final Object parsed = af.parseValueRaw(value);
 | 
			
		||||
                if (parsed == null) {
 | 
			
		||||
                    MainUtil.sendMessage(player, "&c" + af.getValueDesc());
 | 
			
		||||
@@ -157,11 +157,15 @@ public class FlagCmd extends SubCommand {
 | 
			
		||||
                    MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
 | 
			
		||||
                    MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
 | 
			
		||||
                if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
 | 
			
		||||
                    for (String entry : args[2].split(",")) {
 | 
			
		||||
                        if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
 | 
			
		||||
                            MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
 | 
			
		||||
                            return false;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (flag == null) {
 | 
			
		||||
                    MainUtil.sendMessage(player, C.FLAG_NOT_IN_PLOT);
 | 
			
		||||
                    return false;
 | 
			
		||||
@@ -195,8 +199,12 @@ public class FlagCmd extends SubCommand {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
 | 
			
		||||
                    MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
 | 
			
		||||
                    return false;
 | 
			
		||||
                    for (String entry : args[2].split(",")) {
 | 
			
		||||
                        if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
 | 
			
		||||
                            MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
 | 
			
		||||
                            return false;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
 | 
			
		||||
                final Object parsed = af.parseValueRaw(value);
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
 | 
			
		||||
        permission = "plots.admin",
 | 
			
		||||
        description = "Update PlotSquared",
 | 
			
		||||
        usage = "/plot update",
 | 
			
		||||
        requiredType = RequiredType.PLAYER,
 | 
			
		||||
        requiredType = RequiredType.NONE,
 | 
			
		||||
        aliases = {"updateplugin"},
 | 
			
		||||
        category = CommandCategory.DEBUG
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
@@ -213,7 +213,7 @@ public enum C {
 | 
			
		||||
    /*
 | 
			
		||||
     * Done
 | 
			
		||||
     */
 | 
			
		||||
    DONE_ALREADY_DONE("$2This plot is already marked as done.","Done"),
 | 
			
		||||
    DONE_ALREADY_DONE("$2This plot is already marked as done, and you are not allowed to claim more plots","Done"),
 | 
			
		||||
    DONE_NOT_DONE("$2This plot is not marked as done.","Done"),
 | 
			
		||||
    DONE_INSUFFICIENT_COMPLEXITY("$2This plot is too simple. Please add more detail before using this command.","Done"),
 | 
			
		||||
    DONE_SUCCESS("$1Successfully marked this plot as done.","Done"),
 | 
			
		||||
 
 | 
			
		||||
@@ -181,6 +181,7 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
                        last = System.currentTimeMillis();
 | 
			
		||||
                        try {
 | 
			
		||||
                            close();
 | 
			
		||||
                            CLOSED = false;
 | 
			
		||||
                            connection = database.forceConnection();
 | 
			
		||||
                        } catch (SQLException | ClassNotFoundException e) {
 | 
			
		||||
                            e.printStackTrace();
 | 
			
		||||
@@ -2419,6 +2420,15 @@ public class SQLManager implements AbstractDB {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void validateAllPlots(Set<Plot> toValidate) {
 | 
			
		||||
        try {
 | 
			
		||||
            if (connection.isClosed() || CLOSED) {
 | 
			
		||||
                CLOSED = false;
 | 
			
		||||
                connection = database.forceConnection();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
        PS.debug("$1All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
 | 
			
		||||
        commit();
 | 
			
		||||
        while (true) {
 | 
			
		||||
 
 | 
			
		||||
@@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.config.Configuration;
 | 
			
		||||
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.util.BO3Handler;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
@@ -118,12 +119,16 @@ public class Plot {
 | 
			
		||||
    public int temp;
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Session only plot metadata (session is until the server stops)
 | 
			
		||||
     * Session only plot metadata (session is until the server stops)<br>
 | 
			
		||||
     * <br>
 | 
			
		||||
     *  For persistent metadata use the flag system
 | 
			
		||||
     *  @see FlagManager
 | 
			
		||||
     */
 | 
			
		||||
    private ConcurrentHashMap<String, Object> meta;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for a new plot
 | 
			
		||||
     * Constructor for a new plot<br>
 | 
			
		||||
     * (Only changes after plot.create() will be properly set in the database)
 | 
			
		||||
     * 
 | 
			
		||||
     * @param world
 | 
			
		||||
     * @param id
 | 
			
		||||
@@ -136,7 +141,9 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for a temporary plot
 | 
			
		||||
     * Constructor for a temporary plot (use -1 for temp)<br>
 | 
			
		||||
     * The database will ignore any queries regarding temporary plots. 
 | 
			
		||||
     * Please note that some bulk plot management functions may still affect temporary plots (TODO: fix this)
 | 
			
		||||
     * 
 | 
			
		||||
     * @param world
 | 
			
		||||
     * @param id
 | 
			
		||||
@@ -151,7 +158,7 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for a saved plots
 | 
			
		||||
     * Constructor for a saved plots (Used by the database manager when plots are fetched)
 | 
			
		||||
     *
 | 
			
		||||
     * @param id
 | 
			
		||||
     * @param owner
 | 
			
		||||
@@ -180,7 +187,10 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Set some session only metadata for the plot
 | 
			
		||||
     * Session only plot metadata (session is until the server stops)<br>
 | 
			
		||||
     * <br>
 | 
			
		||||
     * For persistent metadata use the flag system
 | 
			
		||||
     * @see FlagManager
 | 
			
		||||
     * @param key
 | 
			
		||||
     * @param value
 | 
			
		||||
     */
 | 
			
		||||
@@ -245,18 +255,18 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if the player is either the owner or on the trusted list
 | 
			
		||||
     * Check if the player is either the owner or on the trusted/added list
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     *
 | 
			
		||||
     * @return true if the player is added as a helper or is the owner
 | 
			
		||||
     * @return true if the player is added/trusted or is the owner
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isAdded(final UUID uuid) {
 | 
			
		||||
        return PlotHandler.isAdded(this, uuid);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Should the player be allowed to enter?
 | 
			
		||||
     * Should the player be denied from entering?
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     *
 | 
			
		||||
@@ -303,6 +313,10 @@ public class Plot {
 | 
			
		||||
        return !settings.getMerged(0) && !settings.getMerged(3);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if the plot is merged
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isMerged() {
 | 
			
		||||
        if (settings == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
@@ -310,6 +324,10 @@ public class Plot {
 | 
			
		||||
        return settings.getMerged(0) || settings.getMerged(2) || settings.getMerged(1) || settings.getMerged(3);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the timestamp in milliseconds of when the plot was created (unreliable)
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public long getTimestamp() {
 | 
			
		||||
        if (timestamp == 0) {
 | 
			
		||||
            timestamp = System.currentTimeMillis();
 | 
			
		||||
@@ -363,7 +381,7 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Deny someone (use DBFunc.addDenied() as well)
 | 
			
		||||
     * Deny someone (updates database as well)
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
@@ -372,7 +390,7 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add someone as a helper (use DBFunc as well)
 | 
			
		||||
     * Add someone as a helper (updates database as well)
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
@@ -381,7 +399,7 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add someone as a trusted user (use DBFunc as well)
 | 
			
		||||
     * Add someone as a trusted user (updates database as well)
 | 
			
		||||
     *
 | 
			
		||||
     * @param uuid
 | 
			
		||||
     */
 | 
			
		||||
@@ -390,7 +408,7 @@ public class Plot {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the plot owner
 | 
			
		||||
     * Set the plot owner (and update the database)
 | 
			
		||||
     * @param owner
 | 
			
		||||
     */
 | 
			
		||||
    public void setOwner(final UUID owner) {
 | 
			
		||||
@@ -811,8 +829,7 @@ public class Plot {
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the plot hashcode
 | 
			
		||||
     *
 | 
			
		||||
     * @return integer. You can easily make this a character array <br> xI = c[0] x = c[1 -> xI...] yI = c[xI ... + 1] y
 | 
			
		||||
     * = c[xI ... + 2 -> yI ...]
 | 
			
		||||
     * @return integer.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ public class ExpireManager {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void runTask() {
 | 
			
		||||
        ExpireManager.task = TaskManager.runTaskRepeat(new Runnable() {
 | 
			
		||||
        ExpireManager.task = TaskManager.runTaskRepeatAsync(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
 
 | 
			
		||||
@@ -526,8 +526,13 @@ public class MainUtil {
 | 
			
		||||
 | 
			
		||||
    public static int getBorder(final String worldname) {
 | 
			
		||||
        if (worldBorder.containsKey(worldname)) {
 | 
			
		||||
            PS.get().getPlotWorld(worldname);
 | 
			
		||||
            return worldBorder.get(worldname) + 16;
 | 
			
		||||
            int border = worldBorder.get(worldname) + 16;
 | 
			
		||||
            if (border == 0) {
 | 
			
		||||
                return Integer.MAX_VALUE;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                return border;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return Integer.MAX_VALUE;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,14 +20,6 @@ public class Permissions {
 | 
			
		||||
        if (player.hasPermission(perm)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        final String[] nodes = perm.split("\\.");
 | 
			
		||||
        final StringBuilder n = new StringBuilder();
 | 
			
		||||
        for (int i = 0; i < (nodes.length - 1); i++) {
 | 
			
		||||
            n.append(nodes[i] + ("."));
 | 
			
		||||
            if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user