From debc7f6ab37b268cdf1ecb6ce29b043cb709c365 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 31 Jan 2015 19:22:53 +1100 Subject: [PATCH] cluster create feedback --- .../plot/commands/Cluster.java | 2 ++ .../intellectualcrafters/plot/config/C.java | 1 + .../plot/util/ClusterManager.java | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+) 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 39c4e568e..5ac80b428 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -101,7 +101,9 @@ public class Cluster extends SubCommand { return false; } if (args.length != 4) { + PlotId id = ClusterManager.estimatePlotId(plr.getLocation()); PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster create "); + PlayerFunctions.sendMessage(plr, C.CLUSTER_CURRENT_PLOTID, "" + id); return false; } // check pos1 / pos2 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 cf3fdcc9d..776b2d35a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -60,6 +60,7 @@ public enum C { CLUSTER_REGENERATED("&6Successfully started cluster regeneration"), CLUSTER_TELEPORTING("&6Teleporting..."), CLUSTER_INFO("&6Current cluster: &7%id%\n&6Name: &7%name%\n&6Owner: &7%owner%\n&6Size: &7%size%\n&6Rights: &7%rights%"), + CLUSTER_CURRENT_PLOTID("&6Current plot: &7%s"), /* * Border */ 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 861ea06f0..f8ea4f939 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -215,6 +215,33 @@ public class ClusterManager { return null; } + public static PlotId estimatePlotId(Location loc) { + PlotId a = new PlotId(0, 0); + PlotId b = new PlotId(1, 1); + int xw; + int zw; + + String world = loc.getWorld().getName(); + PlotWorld plotworld = PlotMain.getWorldSettings(world); + if (plotworld == null) { + xw = 39; + zw = 39; + } + else { + PlotManager manager = PlotMain.getPlotManager(world); + Location al = manager.getPlotBottomLocAbs(plotworld, a); + Location bl = manager.getPlotBottomLocAbs(plotworld, b); + + xw = bl.getBlockX() - al.getBlockX(); + zw = bl.getBlockZ() - al.getBlockZ(); + } + + int x = loc.getBlockX(); + int z = loc.getBlockZ(); + + return new PlotId((x/xw) + 1,(z/zw) + 1); + } + public static void regenCluster(final PlotCluster cluster) { if (regenerating.contains(cluster.world + ":" + cluster.getName())) { return;