From 7143da0ebfd269b195844f555a7e9da574e61391 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 29 Jan 2015 18:45:14 +1100 Subject: [PATCH] Should be stable now --- .../intellectualcrafters/plot/PlotMain.java | 10 +++- .../plot/commands/Cluster.java | 50 ++++++++++++------- .../plot/commands/Command.java | 2 +- .../intellectualcrafters/plot/config/C.java | 2 +- .../plot/database/SQLManager.java | 25 ++++++---- .../intellectualcrafters/plot/flag/Flag.java | 11 +++- .../plot/flag/FlagManager.java | 16 +++++- .../plot/util/ClusterManager.java | 2 +- 8 files changed, 79 insertions(+), 39 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 5bcb85ae3..e0baba92b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -1224,6 +1224,7 @@ public class PlotMain extends JavaPlugin implements Listener { } // Setup configuration configs(); + defaultFlags(); // Setup metrics if (Settings.METRICS) { try { @@ -1244,12 +1245,18 @@ public class PlotMain extends JavaPlugin implements Listener { if (C.ENABLED.s().length() > 0) { sendConsoleSenderMessage(C.ENABLED); } + final String[] tables; if (Settings.ENABLE_CLUSTERS) { MainCommand.subCommands.add(new Cluster()); + tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments", "cluster"}; + } + else { + tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"}; } // Add tables to this one, if we create more :D - final String[] tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"}; + + // Use mysql? if (Settings.DB.USE_MYSQL) { @@ -1356,7 +1363,6 @@ public class PlotMain extends JavaPlugin implements Listener { // Forcefield listener getServer().getPluginManager().registerEvents(new ForceFieldListener(this), this); // Default flags - defaultFlags(); if (getServer().getPluginManager().getPlugin("BarAPI") != null) { barAPI = (BarAPI) getServer().getPluginManager().getPlugin("BarAPI"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index f9c951342..950400a89 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -50,9 +50,6 @@ public class Cluster extends SubCommand { @Override public boolean execute(final Player plr, final String... args) { - if (!ClusterManager.clusters.containsKey(plr.getWorld().getName())) { - return false; - } // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome if (args.length == 0) { @@ -75,17 +72,15 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + ""); for (PlotCluster cluster : clusters) { // Ignore unmanaged clusters - if (cluster.settings.getAlias().equals("")) { - continue; - } + String name = "'" + cluster.getName() + "' : " + cluster.toString(); if (UUIDHandler.getUUID(plr).equals(cluster.owner)) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + cluster.toString()); + PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name); } else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + cluster.toString()); + PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name); } else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + cluster.toString()); + PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name); } else { PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString()); @@ -129,11 +124,14 @@ public class Cluster extends SubCommand { PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr)); cluster.settings.setAlias(name); DBFunc.createCluster(world, cluster); + if (!ClusterManager.clusters.containsKey(world)) { + ClusterManager.clusters.put(world, new HashSet()); + } ClusterManager.clusters.get(world).add(cluster); // Add any existing plots to the current cluster for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) { PlotCluster current = ClusterManager.getCluster(plot); - if (cluster.equals(current)) { + if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { cluster.invited.add(plot.owner); DBFunc.setInvited(world, cluster, plot.owner); } @@ -146,16 +144,30 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete"); return false; } - if (args.length != 1) { - PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete"); + if (args.length != 1 && args.length != 2) { + PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]"); return false; } - PlotCluster toDelete = ClusterManager.getCluster(plr.getLocation()); - if (toDelete == null) { + PlotCluster cluster; + if (args.length == 2) { + cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + if (cluster == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + return false; + } + } + else { + cluster = ClusterManager.getCluster(plr.getLocation()); + if (cluster == null) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + return false; + } + } + if (cluster == null) { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } - if (!toDelete.owner.equals(UUIDHandler.getUUID(plr))) { + if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) { if (!PlotMain.hasPermission(plr, "plots.cluster.delete.other")) { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other"); return false; @@ -164,16 +176,16 @@ public class Cluster extends SubCommand { PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld()); if (plotworld.REQUIRE_CLUSTER) { for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) { - PlotCluster cluster = ClusterManager.getCluster(plot); - if (toDelete.equals(cluster)) { + PlotCluster other = ClusterManager.getCluster(plot); + if (cluster.equals(other)) { String world = plr.getWorld().getName(); DBFunc.delete(world, plot); } } } String world_delete = plr.getWorld().getName(); - ClusterManager.clusters.get(world_delete).remove(toDelete); - DBFunc.delete(toDelete); + ClusterManager.clusters.get(world_delete).remove(cluster); + DBFunc.delete(cluster); PlayerFunctions.sendMessage(plr, C.CLUSTER_DELETED); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 080d3c476..0e0aa9501 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -36,7 +36,7 @@ public enum Command { // (Rating system) (ratings can be stored as the average, and number of // ratings) // - /plot rate - CLUSTER("cluster", "cl"), + CLUSTER("cluster", "clusters"), BUY("buy","b"), CREATEROADSCHEMATIC("createroadschematic"), DEBUGROADREGEN("debugroadregen"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 58de5a5d6..fcaf3bae9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -58,7 +58,7 @@ public enum C { CLUSTER_ADDED_HELPER("&6Successfully added a helper to the cluster"), CLUSTER_REMOVED_HELPER("&6Successfully removed a helper to the cluster"), CLUSTER_TELEPORTING("&6Teleporting..."), - CLUSTER_INFO("&6Current cluster: %id%\nName: %name%\nOwner: %owner%\nSize: %size%\nRights: %rights%"), + CLUSTER_INFO("&6Current cluster: &7%id%\n&6Name: &7%name%\n&6Owner: &7%owner%\n&6Size: &7%size%\n&6Rights: &7%rights%"), /* * Border */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 36f3d25d4..dcfa3dbe4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -372,7 +372,7 @@ public class SQLManager implements AbstractDB { final boolean mysql = database.equals("mysql"); final Statement stmt = this.connection.createStatement(); if (mysql) { - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`tier` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); @@ -382,9 +382,9 @@ public class SQLManager implements AbstractDB { if (add_constraint) { stmt.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD CONSTRAINT `" + this.prefix + "plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `" + this.prefix + "plot` (`id`) ON DELETE CASCADE"); } - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + "`tier` INT(11) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + "`tier` INT(11) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); } else { @@ -396,7 +396,7 @@ public class SQLManager implements AbstractDB { stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ")"); @@ -1270,11 +1270,11 @@ public class SQLManager implements AbstractDB { public int getClusterId(String world, PlotClusterId id) { PreparedStatement stmt = null; try { - stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND world = ? ORDER BY `timestamp` ASC"); + stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC"); stmt.setInt(1, id.pos1.x); stmt.setInt(2, id.pos1.y); - stmt.setInt(3, id.pos1.x); - stmt.setInt(3, id.pos2.y); + stmt.setInt(3, id.pos2.x); + stmt.setInt(4, id.pos2.y); stmt.setString(5, world); final ResultSet r = stmt.executeQuery(); int c_id = Integer.MAX_VALUE; @@ -1342,7 +1342,7 @@ public class SQLManager implements AbstractDB { */ r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`"); while (r.next()) { - id = r.getInt("plot_plot_id"); + id = r.getInt("cluster_id"); owner = r.getString("user_uuid"); user = uuids.get(owner); if (user == null) { @@ -1361,7 +1361,7 @@ public class SQLManager implements AbstractDB { */ r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`"); while (r.next()) { - id = r.getInt("plot_plot_id"); + id = r.getInt("cluster_id"); owner = r.getString("user_uuid"); user = uuids.get(owner); if (user == null) { @@ -1377,7 +1377,7 @@ public class SQLManager implements AbstractDB { } r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`"); while (r.next()) { - id = r.getInt("plot_plot_id"); + id = r.getInt("cluster_id"); cluster = clusters.get(id); if (cluster != null) { final String b = r.getString("biome"); @@ -1393,6 +1393,9 @@ public class SQLManager implements AbstractDB { if (alias != null) { cluster.settings.setAlias(alias); } + else { + System.out.print("ALIAS IS NULL!!!"); + } final String pos = r.getString("position"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index 361e065a9..034a76373 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -24,8 +24,8 @@ package com.intellectualcrafters.plot.flag; import org.apache.commons.lang.StringUtils; public class Flag { - private final AbstractFlag key; - private final Object value; + private AbstractFlag key; + private Object value; /** * Flag object used to store basic information for a Plot. Flags are a key/value pair. For a flag to be usable by a @@ -54,6 +54,13 @@ public class Flag { throw new IllegalArgumentException(key.getValueDesc()); } } + + public void setKey(AbstractFlag key) { + this.key = key; + if (this.value instanceof String) { + this.value = key.parseValueRaw((String) this.value); + } + } /** * Warning: Unchecked diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 17ac3e04c..80f966345 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -31,6 +31,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotFlagAddEvent; import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent; @@ -61,8 +62,19 @@ import com.intellectualcrafters.plot.object.PlotWorld; * * @return success? */ - public static boolean addFlag(final AbstractFlag flag) { - return (getFlag(flag.getKey()) == null) && flags.add(flag); + public static boolean addFlag(final AbstractFlag af) { + PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&8 - Adding flag: &7" + af); + String key = af.getKey(); + if (PlotMain.getAllPlotsRaw() != null) { + for (Plot plot : PlotMain.getPlots()) { + for (Flag flag : plot.settings.flags) { + if (flag.getAbstractFlag().getKey().equals(af)) { + flag.setKey(af); + } + } + } + } + return (getFlag(af.getKey()) == null) && flags.add(af); } public static Flag getSettingFlag(String world, PlotSettings settings, String flag) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 5bf015f55..81106badd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -108,7 +108,7 @@ public class ClusterManager { } public static HashSet getIntersects(String world, PlotClusterId id) { - if (clusters.containsKey(world)) { + if (!clusters.containsKey(world)) { return new HashSet<>(); } HashSet list = new HashSet();