diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 706fbbc2f..ff5196e61 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -168,17 +168,31 @@ public class Auto extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } PlotCluster cluster = ClusterManager.getCluster(loc); + // Must be standing in a cluster + if (cluster == null) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + return false; + } PlotId bot = cluster.getP1(); PlotId top = cluster.getP2(); - PlotId id = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); + PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); + PlotId id = new PlotId(0, 0); int width = Math.max(top.x - bot.x, top.y - bot.y); int max = width * width; - - // TODO finish cluster auto claiming - + // for (int i = 0; i <= max; i++) { + PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); + Plot current = PlotHelper.getPlot(world, currentId); + if (current != null && !current.hasOwner() && cluster.equals(ClusterManager.getCluster(current))) { + Claim.claimPlot(plr, plot, true, true); + return true; + } id = getNextPlot(id, 1); } + + // no free plots + PlayerFunctions.sendMessage(plr, C.NO_FREE_PLOTS); + return false; } boolean br = false; 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 4e9ad99ad..f9c951342 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -25,15 +25,18 @@ import java.util.HashSet; import java.util.UUID; import org.bukkit.Bukkit; +import org.bukkit.Location; 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.object.BlockLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; @@ -50,7 +53,7 @@ public class Cluster extends SubCommand { if (!ClusterManager.clusters.containsKey(plr.getWorld().getName())) { return false; } - // list, create, delete, resize, invite, kick, leave, helpers, tp + // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome if (args.length == 0) { // return arguments @@ -127,6 +130,14 @@ public class Cluster extends SubCommand { cluster.settings.setAlias(name); DBFunc.createCluster(world, cluster); 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)) { + cluster.invited.add(plot.owner); + DBFunc.setInvited(world, cluster, plot.owner); + } + } PlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED); return true; } @@ -144,6 +155,22 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } + if (!toDelete.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; + } + } + 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)) { + 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); @@ -172,6 +199,12 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } + if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { + if (!PlotMain.hasPermission(plr, "plots.cluster.resize.other")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.other"); + return false; + } + } //check if overlap PlotClusterId id = new PlotClusterId(pos1, pos2); HashSet intersects = ClusterManager.getIntersects(plr.getWorld().getName(), id); @@ -199,6 +232,12 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); return false; } + if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { + if (!PlotMain.hasPermission(plr, "plots.cluster.invite.other")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.invite.other"); + return false; + } + } // check uuid UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { @@ -212,7 +251,7 @@ public class Cluster extends SubCommand { DBFunc.setInvited(world, cluster, uuid); Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { - PlayerFunctions.sendMessage(plr, C.CLUSTER_INVITED, cluster.getName()); + PlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); } } PlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_USER); @@ -227,6 +266,46 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster kick "); return false; } + PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + if (cluster == null) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + return false; + } + if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { + if (!PlotMain.hasPermission(plr, "plots.cluster.kick.other")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.kick.other"); + return false; + } + } + // check uuid + UUID uuid = UUIDHandler.getUUID(args[1]); + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + return false; + } + // Can't kick if the player is yourself, the owner, or not added to the cluster + if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.hasRights(uuid)) { + PlayerFunctions.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName()); + return false; + } + if (cluster.helpers.contains(uuid)) { + cluster.helpers.remove(uuid); + DBFunc.removeHelper(cluster, uuid); + } + cluster.invited.remove(uuid); + DBFunc.removeInvited(cluster, uuid); + Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); + if (player != null) { + PlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); + } + for (Plot plot : PlotMain.getPlots(plr.getWorld(), uuid)) { + PlotCluster current = ClusterManager.getCluster(plot); + if (current != null && current.equals(cluster)) { + String world = plr.getWorld().getName(); + DBFunc.delete(world, plot); + } + } + PlayerFunctions.sendMessage(plr, C.CLUSTER_KICKED_USER); return true; } case "leave": { @@ -238,6 +317,44 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]"); return false; } + 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; + } + } + UUID uuid = UUIDHandler.getUUID(plr); + if (!cluster.hasRights(uuid)) { + PlayerFunctions.sendMessage(plr, C.CLUSTER_NOT_ADDED); + return false; + } + if (uuid.equals(cluster.owner)) { + PlayerFunctions.sendMessage(plr, C.CLUSTER_CANNOT_LEAVE); + return false; + } + if (cluster.helpers.contains(uuid)) { + cluster.helpers.remove(uuid); + DBFunc.removeHelper(cluster, uuid); + } + cluster.invited.remove(uuid); + DBFunc.removeInvited(cluster, uuid); + PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); + for (Plot plot : PlotMain.getPlots(plr.getWorld(), uuid)) { + PlotCluster current = ClusterManager.getCluster(plot); + if (current != null && current.equals(cluster)) { + String world = plr.getWorld().getName(); + DBFunc.delete(world, plot); + } + } return true; } case "helpers": { @@ -249,7 +366,26 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); return false; } - return true; + PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + if (cluster == null) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + return false; + } + UUID uuid = UUIDHandler.getUUID(args[2]); + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + return false; + } + if (args[1].toLowerCase().equals("add")) { + cluster.helpers.add(uuid); + return PlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_HELPER); + } + if (args[1].toLowerCase().equals("remove")) { + cluster.helpers.remove(uuid); + return PlayerFunctions.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); + } + PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); + return false; } case "tp": { if (!PlotMain.hasPermission(plr, "plots.cluster.tp")) { @@ -260,7 +396,20 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster tp "); return false; } - return true; + PlotCluster cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]); + if (cluster == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]); + return false; + } + UUID uuid = UUIDHandler.getUUID(plr); + if (!cluster.hasRights(uuid)) { + if (!PlotMain.hasPermission(plr, "plots.cluster.tp.other")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); + return false; + } + } + plr.teleport(ClusterManager.getHome(cluster)); + return PlayerFunctions.sendMessage(plr, C.CLUSTER_TELEPORTING); } case "info": { if (!PlotMain.hasPermission(plr, "plots.cluster.info")) { @@ -271,8 +420,68 @@ public class Cluster extends SubCommand { PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]"); return false; } + 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; + } + } + String id = cluster.toString(); + String owner = UUIDHandler.getName(cluster.owner); + if (owner == null) { + owner = "unknown"; + } + String name = cluster.getName(); + String size = (cluster.getP2().x - cluster.getP1().x) + "x" + (cluster.getP2().y - cluster.getP1().y); + String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + ""; + + String message = C.CLUSTER_INFO.s(); + message = message.replaceAll("%id%", id); + message = message.replaceAll("%owner%", owner); + message = message.replaceAll("%name%", name); + message = message.replaceAll("%size%", size); + message = message.replaceAll("%rights%", rights); + + PlayerFunctions.sendMessage(plr, message); return true; } + case "sethome": { + if (!PlotMain.hasPermission(plr, "plots.cluster.sethome")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome"); + return false; + } + if (args.length != 1 && args.length != 2) { + PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome"); + return false; + } + PlotCluster cluster = ClusterManager.getCluster(plr.getLocation()); + if (cluster == null) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER); + return false; + } + if (!cluster.hasHelperRights(UUIDHandler.getUUID(plr))) { + if (!PlotMain.hasPermission(plr, "plots.cluster.sethome.other")) { + PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome.other"); + return false; + } + } + Location base = ClusterManager.getClusterBottom(cluster); + base.setY(0); + Location relative = plr.getLocation().subtract(base); + BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); + cluster.settings.setPosition(blockloc); + DBFunc.setPosition(cluster, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ()); + return PlayerFunctions.sendMessage(plr, C.POSITION_SET); + } } PlayerFunctions.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS); return false; 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 762248a45..58de5a5d6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -40,7 +40,7 @@ public enum C { /* * Cluster */ - CLUSTER_AVAILABLE_ARGS("&6The following sub commands are available: &clist, create, delete, resize, invite, kick, leave, helpers, info, tp"), + CLUSTER_AVAILABLE_ARGS("&6The following sub commands are available: &clist, create, delete, resize, invite, kick, leave, helpers, info, tp, sethome"), CLUSTER_LIST_HEADING("&cThere are %s clusters in this world"), CLUSTER_LIST_ELEMENT("&7 - &6%s\n"), CLUSTER_INTERSECTION("&6The proposed area overlaps with %s existing cluster/s"), @@ -48,7 +48,17 @@ public enum C { CLUSTER_DELETED("&6Successfully deleted the cluster."), CLUSTER_RESIZED("&6Successfully resized the cluster."), CLUSTER_ADDED_USER("&6Successfully added user to the cluster."), + CANNOT_KICK_PLAYER("&cYou cannot kick that player"), CLUSTER_INVITED("&6You have been invited to the following cluster: %s."), + CLUSTER_REMOVED("&cYou have been removed from cluster %s"), + CLUSTER_KICKED_USER("&6Successfully kicked the user"), + INVALID_CLUSTER("&cInvalid cluster name: %s"), + CLUSTER_NOT_ADDED("&cThat player was not added to the plot cluster"), + CLUSTER_CANNOT_LEAVE("&cYou must delete or transfer ownership before leaving"), + 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%"), /* * Border */ @@ -168,7 +178,7 @@ public enum C { * Position */ MISSING_POSITION("&cYou need to specify a position. Possible values: &6none"), - POSITION_SET("&cPlot home position set to your current location"), + POSITION_SET("&Home position set to your current location"), HOME_ARGUMENT("&cUse /plot set home [none]"), INVALID_POSITION("&cThat is not a valid position value"), /* @@ -221,8 +231,9 @@ public enum C { /* * No */ + NO_FREE_PLOTS("&cThere are no free plots available"), NOT_IN_PLOT("&cYou're not in a plot"), - NOT_IN_CLUSTER("&cYou're not in a plot cluster"), + NOT_IN_CLUSTER("&cYou must be within a plot cluster to perform that action"), NOT_IN_PLOT_WORLD("&cYou're not in a plot world"), NOT_VALID_WORLD("&cThat is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD("&cThat is not a valid plot world (case sensitive)"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 73885e260..2cf4092ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -239,11 +239,10 @@ public interface AbstractDB { public void removeTrusted(final String world, final Plot plot, final UUID uuid); /** * - * @param world * @param cluster * @param uuid */ - public void removeInvited(final String world, final PlotCluster cluster, final UUID uuid); + public void removeInvited(final PlotCluster cluster, final UUID uuid); /** * @param plot Plot Object * @param uuid Player that should be removed diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 632128493..bd39b52c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -275,8 +275,8 @@ public class DBFunc { * @param plot * @param uuid */ - public static void removeInvited(final String world, final PlotCluster cluster, final UUID uuid) { - dbManager.removeInvited(world, cluster, uuid); + public static void removeInvited(final PlotCluster cluster, final UUID uuid) { + dbManager.removeInvited(cluster, uuid); } /** 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 acbf1bc71..36f3d25d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1697,7 +1697,7 @@ public class SQLManager implements AbstractDB { } @Override - public void removeInvited(String world, final PlotCluster cluster, final UUID uuid) { + public void removeInvited(final PlotCluster cluster, final UUID uuid) { TaskManager.runTask(new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java index d72176065..c18c8002a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java @@ -45,8 +45,12 @@ public class PlotCluster { } public boolean hasRights(UUID uuid) { - return (invited.contains(uuid)|| invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone)); - } + return (owner.equals(uuid) || invited.contains(uuid)|| invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone)); + } + + public boolean hasHelperRights(UUID uuid) { + return (owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone)); + } public String getName() { return this.settings.getAlias(); 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 9816c1a90..5bf015f55 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -3,10 +3,12 @@ package com.intellectualcrafters.plot.util; import java.util.HashMap; import java.util.HashSet; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; @@ -36,6 +38,63 @@ public class ClusterManager { return new HashSet<>(); } + public static Location getHome(PlotCluster cluster) { + World world = Bukkit.getWorld(cluster.world); + BlockLoc home = cluster.settings.getPosition(); + Location toReturn; + if (home.y == 0) { + // default pos + PlotId center = getCenterPlot(cluster); + toReturn = PlotHelper.getPlotHome(world, center); + if (toReturn.getBlockY() == 0) { + final PlotManager manager = PlotMain.getPlotManager(world); + final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final Location loc = manager.getSignLoc(world, plotworld, PlotHelper.getPlot(world, center)); + toReturn.setY(loc.getY()); + } + } + else { + toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z); + } + int max = world.getHighestBlockAt(toReturn).getY(); + if (max > toReturn.getBlockY()) { + toReturn.setY(max); + } + return toReturn; + } + + public static PlotId getCenterPlot(PlotCluster cluster) { + PlotId bot = cluster.getP1(); + PlotId top = cluster.getP2(); + return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2); + } + + public static Location getClusterBottom(PlotCluster cluster) { + String world = cluster.world; + final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotMain.getPlotManager(world); + return manager.getPlotBottomLocAbs(plotworld, cluster.getP1()); + } + + public static Location getClusterTop(PlotCluster cluster) { + String world = cluster.world; + final PlotWorld plotworld = PlotMain.getWorldSettings(world); + final PlotManager manager = PlotMain.getPlotManager(world); + return manager.getPlotTopLocAbs(plotworld, cluster.getP2()); + } + + public static PlotCluster getCluster(String world, String name) { + if (!clusters.containsKey(world)) { + return null; + } + for (PlotCluster cluster : clusters.get(world)) { + if (cluster.getName().equals(name)) { + return cluster; + } + } + return null; + } + public static boolean contains(PlotCluster cluster, Location loc) { String world = loc.getWorld().getName(); PlotManager manager = PlotMain.getPlotManager(world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index 20ffa92ed..ec6177039 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -15,6 +15,7 @@ import com.google.common.collect.HashBiMap; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; @@ -140,6 +141,10 @@ public class UUIDHandler { StringWrapper nameWrap = new StringWrapper(name); add(nameWrap, uuid); } + + // add the Everyone '*' UUID + add(new StringWrapper("*"), DBFunc.everyone); + PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); } @@ -186,7 +191,6 @@ public class UUIDHandler { if (name == null) { return null; } - // check online Player player = Bukkit.getPlayer(name); if (player != null) {