From b87a886345707d0575c510e8e297612da0947d17 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 13 Feb 2016 03:25:04 +1100 Subject: [PATCH] Additions / Fixes Added `/plot area` command for area info and management Fixed typo for player meta table preventing the plugin from starting / cleanup Moved pagination from list to subcommand Removed default PlotArea values Added pair and tuple RunnableVal classes Tweak pom so that it actually compiles More command categories Removed unclaim and limit command Fixed a few issues with the 2d mapping of plot areas --- pom.xml | 23 +- .../com/intellectualcrafters/plot/PS.java | 21 +- .../plot/commands/Add.java | 2 +- .../plot/commands/Alias.java | 2 +- .../plot/commands/Area.java | 426 ++++++++++++++++++ .../plot/commands/BO3.java | 2 +- .../plot/commands/Biome.java | 2 +- .../plot/commands/Chat.java | 2 +- .../plot/commands/Clear.java | 2 +- .../plot/commands/Cluster.java | 2 +- .../plot/commands/CommandCategory.java | 29 +- .../plot/commands/Comment.java | 2 +- .../plot/commands/Condense.java | 2 +- .../plot/commands/Confirm.java | 2 +- .../plot/commands/Continue.java | 2 +- .../plot/commands/Copy.java | 2 +- .../plot/commands/CreateRoadSchematic.java | 2 +- .../plot/commands/Database.java | 2 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/Deny.java | 2 +- .../plot/commands/Desc.java | 2 +- .../plot/commands/Done.java | 2 +- .../plot/commands/Download.java | 2 +- .../plot/commands/FlagCmd.java | 2 +- .../plot/commands/Inbox.java | 2 +- .../plot/commands/Kick.java | 2 +- .../plot/commands/Limit.java | 62 --- .../plot/commands/Load.java | 2 +- .../plot/commands/MainCommand.java | 2 +- .../plot/commands/Merge.java | 2 +- .../plot/commands/Move.java | 2 +- .../plot/commands/MusicSubcommand.java | 9 +- .../plot/commands/Owner.java | 12 +- .../plot/commands/Purge.java | 2 +- .../plot/commands/Rate.java | 2 +- .../plot/commands/RegenAllRoads.java | 2 +- .../plot/commands/Reload.java | 2 +- .../plot/commands/Remove.java | 2 +- .../plot/commands/Save.java | 2 +- .../plot/commands/SchematicCmd.java | 2 +- .../plot/commands/Set.java | 2 +- .../plot/commands/SetHome.java | 2 +- .../plot/commands/Setup.java | 2 +- .../plot/commands/SubCommand.java | 45 ++ .../plot/commands/Swap.java | 2 +- .../plot/commands/Target.java | 2 +- .../plot/commands/Template.java | 2 +- .../plot/commands/Toggle.java | 2 +- .../plot/commands/Trim.java | 2 +- .../plot/commands/Trust.java | 2 +- .../plot/commands/Unclaim.java | 63 --- .../plot/commands/Undeny.java | 2 +- .../plot/commands/Unlink.java | 2 +- .../plot/commands/Untrust.java | 2 +- .../plot/commands/Update.java | 2 +- .../plot/commands/WE_Anywhere.java | 2 +- .../plot/commands/list.java | 126 ++---- .../intellectualcrafters/plot/config/C.java | 20 +- .../plot/database/AbstractDB.java | 3 +- .../plot/database/SQLManager.java | 194 +++++--- .../plot/generator/ClassicPlotWorld.java | 53 +-- .../plot/generator/HybridGen.java | 4 +- .../plot/generator/HybridPlotWorld.java | 2 +- .../plot/generator/SquarePlotWorld.java | 12 +- .../plot/object/PlotArea.java | 104 ++--- .../plot/object/PlotPlayer.java | 9 +- .../plot/object/RunnableVal2.java | 20 + .../plot/object/RunnableVal3.java | 22 + .../plot/util/ChunkManager.java | 9 +- .../plot/util/SetupUtils.java | 3 - .../plot/util/area/QuadMap.java | 10 +- .../plot/util/helpmenu/HelpMenu.java | 2 +- .../bukkit/util/BukkitSetupUtils.java | 12 +- .../sponge/util/SpongeBlockManager.java | 16 +- 74 files changed, 908 insertions(+), 497 deletions(-) create mode 100644 src/main/java/com/intellectualcrafters/plot/commands/Area.java delete mode 100644 src/main/java/com/intellectualcrafters/plot/commands/Limit.java delete mode 100644 src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java create mode 100644 src/main/java/com/intellectualcrafters/plot/object/RunnableVal2.java create mode 100644 src/main/java/com/intellectualcrafters/plot/object/RunnableVal3.java diff --git a/pom.xml b/pom.xml index 89234726f..7a2d2ec82 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ - ${project.name}-Bukkit-${project.version} + ${project.name}-Bukkit src/main/java @@ -144,7 +144,8 @@ - + + persistence-api javax.persistence @@ -295,13 +297,13 @@ - + - + + diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java index 08f79a151..431aba48d 100644 --- a/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/src/main/java/com/intellectualcrafters/plot/PS.java @@ -509,6 +509,7 @@ public class PS { } } } + return null; } if (areas.length == 1) { return areas[0]; @@ -1445,16 +1446,15 @@ public class PS { if (world.equals("CheckingPlotSquaredGenerator")) { return; } - PlotArea[] areas = plotareamap.get(world); - if (areas != null) { - PS.debug("World already loaded: " + world); - return; - } final Set worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet()); final String path = "worlds." + world; ConfigurationSection worldSection = config.getConfigurationSection(path); int type = worldSection != null ? worldSection.getInt("generator.type") : 0; if (type == 0) { + if (plotareamap.containsKey(world)) { + PS.debug("World possibly already loaded: " + world); + return; + } IndependentPlotGenerator pg; if (baseGenerator != null && baseGenerator.isFull()) { pg = baseGenerator.getPlotGenerator(); @@ -1502,13 +1502,16 @@ public class PS { pg.initialize(plotArea); plotArea.setupBorder(); } else { - // Augmented / Partial if (!worlds.contains(world)) { return; } - log(C.PREFIX.s() + "&aDetected world load for '" + world + "'"); ConfigurationSection areasSection = worldSection.getConfigurationSection("areas"); if (areasSection == null) { + if (plotareamap.containsKey(world)) { + PS.debug("World possibly already loaded: " + world); + return; + } + log(C.PREFIX.s() + "&aDetected world load for '" + world + "'"); String gen_string = worldSection.getString("generator.plugin"); if (gen_string == null) { gen_string = "PlotSquared"; @@ -1580,6 +1583,9 @@ public class PS { if (pos1 == null || pos2 == null || name.length() == 0) { throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `--`"); } + if (getPlotArea(world, name) != null) { + continue; + } ConfigurationSection section = areasSection.getConfigurationSection(areaId); YamlConfiguration clone = new YamlConfiguration(); for (String key : section.getKeys(true)) { @@ -1628,6 +1634,7 @@ public class PS { } catch (final IOException e) { e.printStackTrace(); } + log(C.PREFIX.s() + "&aDetected area load for '" + world + "'"); log(C.PREFIX.s() + "&c | &9generator: &7" + baseGenerator + ">" + areaGen); log(C.PREFIX.s() + "&c | &9plotworld: &7" + pa); log(C.PREFIX.s() + "&c | &9manager: &7" + pa.getPlotManager()); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Add.java b/src/main/java/com/intellectualcrafters/plot/commands/Add.java index f41a1d625..2ab3ab5f8 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Add.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -39,7 +39,7 @@ command = "add", aliases = { "a" }, description = "Allow a user to build while you are online", usage = "/plot add ", -category = CommandCategory.ACTIONS, +category = CommandCategory.SETTINGS, permission = "plots.add", requiredType = RequiredType.NONE) public class Add extends SubCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Alias.java b/src/main/java/com/intellectualcrafters/plot/commands/Alias.java index 295da9af3..66067dcf4 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Alias.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Alias.java @@ -36,7 +36,7 @@ permission = "plots.set.alias", description = "Set the plot name", usage = "/plot alias ", aliases = { "alias", "sa", "name", "rename", "setname", "seta" }, -category = CommandCategory.ACTIONS, + category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Alias extends SetCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Area.java b/src/main/java/com/intellectualcrafters/plot/commands/Area.java new file mode 100644 index 000000000..924ba24a2 --- /dev/null +++ b/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -0,0 +1,426 @@ +package com.intellectualcrafters.plot.commands; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Set; + +import com.intellectualcrafters.configuration.ConfigurationSection; +import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Configuration; +import com.intellectualcrafters.plot.generator.AugmentedUtils; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.PlotArea; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotMessage; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.object.RunnableVal3; +import com.intellectualcrafters.plot.object.SetupObject; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.CmdConfirm; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.MathMan; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.SetupUtils; +import com.intellectualcrafters.plot.util.StringMan; +import com.intellectualcrafters.plot.util.WorldUtil; +import com.plotsquared.general.commands.CommandDeclaration; + +@CommandDeclaration( +command = "area", +permission = "plots.area", +category = CommandCategory.ADMINISTRATION, +requiredType = RequiredType.NONE, +description = "Create a new PlotArea", +aliases = { "world" }, +usage = "/plot area ") +//plot createarea partial +public class Area extends SubCommand { + + @Override + public boolean onCommand(final PlotPlayer plr, String[] args) { + if (args.length == 0) { + C.COMMAND_SYNTAX.send(plr, getUsage()); + return false; + } + switch (args[0].toLowerCase()) { + case "c": + case "setup": + case "create": { + if (!Permissions.hasPermission(plr, "plots.area.create")) { + C.NO_PERMISSION.send(plr, "plots.area.create"); + return false; + } + switch (args.length) { + case 1: { + C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [=]..."); + return false; + } + case 2: { + switch (args[1].toLowerCase()) { + case "pos1": { // Set position 1 + HybridPlotWorld area = plr. getMeta("area_create_area"); + if (area == null) { + C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [=]..."); + return false; + } + Location loc = plr.getLocation(); + plr.setMeta("area_pos1", loc); + C.SET_ATTRIBUTE.send(plr, "area_pos1", loc.getX() + "," + loc.getZ()); + MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2" + + "\nNote: The chosen plot size may result in the created area not exactly matching your second position."); + return true; + } + case "pos2": { // Set position 2 and finish creation for type=2 (partial) + final HybridPlotWorld area = plr. getMeta("area_create_area"); + if (area == null) { + C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [=]..."); + return false; + } + Location pos1 = plr.getLocation(); + Location pos2 = plr. getMeta("area_pos1"); + int dx = Math.abs(pos1.getX() - pos2.getX()); + int dz = Math.abs(pos1.getZ() - pos2.getZ()); + int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE); + int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE); + final int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH); + final int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH); + int bx = Math.min(pos1.getX(), pos2.getX()) + ddx; + int bz = Math.min(pos1.getZ(), pos2.getZ()) + ddz; + int tx = Math.max(pos1.getX(), pos2.getX()) - ddx; + int tz = Math.max(pos1.getZ(), pos2.getZ()) - ddz; + int lower = (area.ROAD_WIDTH & 1) == 0 ? area.ROAD_WIDTH / 2 - 1 : area.ROAD_WIDTH / 2; + final int offsetx = bx - (area.ROAD_WIDTH == 0 ? 0 : lower); + final int offsetz = bz - (area.ROAD_WIDTH == 0 ? 0 : lower); + final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz); + Set areas = PS.get().getPlotAreas(area.worldname, region); + if (areas.size() > 0) { + C.CLUSTER_INTERSECTION.send(plr, areas.iterator().next().toString()); + return false; + } + final SetupObject object = new SetupObject(); + object.world = area.worldname; + object.id = area.id; + object.terrain = area.TERRAIN; + object.type = area.TYPE; + object.min = new PlotId(0, 0); + object.max = new PlotId(numx - 1, numz - 1); + object.plotManager = "PlotSquared"; + object.setupGenerator = "PlotSquared"; + object.step = area.getSettingNodes(); + final String path = "worlds." + area.worldname + ".areas." + area.id + "-" + object.min + "-" + object.max; + CmdConfirm.addPending(plr, "/plot area create pos2 (Creates world)", new Runnable() { + @Override + public void run() { + if (offsetx != 0) { + PS.get().config.set(path + ".road.offset.x", offsetx); + } + if (offsetz != 0) { + PS.get().config.set(path + ".road.offset.z", offsetz); + } + final String world = SetupUtils.manager.setupWorld(object); + if (WorldUtil.IMP.isWorld(world)) { + PS.get().loadWorld(world, null); + C.SETUP_FINISHED.send(plr); + plr.teleport(WorldUtil.IMP.getSpawn(world)); + if (area.TERRAIN != 3) { + ChunkManager.largeRegionTask(world, region, new RunnableVal() { + @Override + public void run(ChunkLoc value) { + AugmentedUtils.generate(world, value.x, value.z); + } + }, null); + } + } else { + MainUtil.sendMessage(plr, "An error occured while creating the world: " + area.worldname); + } + } + }); + return true; + } + } + } + default: // Start creation + final SetupObject object = new SetupObject(); + String[] split = args[1].split(":"); + String id; + if (split.length == 2) { + id = split[1]; + } else { + id = null; + } + object.world = split[0]; + final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, new HybridGen(), null, null); + if (PS.get().getPlotArea(pa.worldname, id) != null) { + C.SETUP_WORLD_TAKEN.send(plr, pa.worldname); + return false; + } + Set areas = PS.get().getPlotAreas(pa.worldname); + if (areas.size() > 0) { + PlotArea area = areas.iterator().next(); + pa.TYPE = area.TYPE; + } + for (int i = 2; i < args.length; i++) { + String[] pair = args[i].split("="); + if (pair.length != 2) { + C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [=]..."); + return false; + } + switch (pair[0].toLowerCase()) { + case "s": + case "size": { + pa.PLOT_WIDTH = Integer.parseInt(pair[1]); + pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH); + break; + } + case "g": + case "gap": { + pa.ROAD_WIDTH = Integer.parseInt(pair[1]); + pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH); + break; + } + case "h": + case "height": { + int value = Integer.parseInt(pair[1]); + pa.PLOT_HEIGHT = value; + pa.ROAD_HEIGHT = value; + pa.WALL_HEIGHT = value; + break; + } + case "f": + case "floor": { + pa.TOP_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]); + break; + } + case "m": + case "main": { + pa.MAIN_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]); + break; + } + case "w": + case "wall": { + pa.WALL_FILLING = Configuration.BLOCK.parseString(pair[1]); + break; + } + case "b": + case "border": { + pa.WALL_BLOCK = Configuration.BLOCK.parseString(pair[1]); + break; + } + case "terrain": { + pa.TERRAIN = Integer.parseInt(pair[1]); + object.terrain = pa.TERRAIN; + break; + } + case "type": { + pa.TYPE = Integer.parseInt(pair[1]); + object.type = pa.TYPE; + break; + } + default: { + C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [=]..."); + return false; + } + } + } + if (pa.TYPE != 2) { + if (WorldUtil.IMP.isWorld(pa.worldname)) { + C.SETUP_WORLD_TAKEN.send(plr, pa.worldname); + return false; + } + CmdConfirm.addPending(plr, "/plot area " + StringMan.join(args, " "), new Runnable() { + @Override + public void run() { + String path = "worlds." + pa.worldname; + if (!PS.get().config.contains(path)) { + PS.get().config.createSection(path); + } + ConfigurationSection section = PS.get().config.getConfigurationSection(path); + pa.saveConfiguration(section); + pa.loadConfiguration(section); + object.plotManager = "PlotSquared"; + object.setupGenerator = "PlotSquared"; + String world = SetupUtils.manager.setupWorld(object); + if (WorldUtil.IMP.isWorld(world)) { + C.SETUP_FINISHED.send(plr); + plr.teleport(WorldUtil.IMP.getSpawn(world)); + } else { + MainUtil.sendMessage(plr, "An error occured while creating the world: " + pa.worldname); + } + try { + PS.get().config.save(PS.get().configFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + return true; + } + if (pa.id == null) { + C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [=]..."); + return false; + } + if (WorldUtil.IMP.isWorld(pa.worldname)) { + if (!plr.getLocation().getWorld().equals(pa.worldname)) { + plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname)); + } + } else { + object.terrain = 0; + object.type = 0; + SetupUtils.manager.setupWorld(object); + plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname)); + } + plr.setMeta("area_create_area", pa); + MainUtil.sendMessage(plr, "$1Go to the first corner and use: $2/plot area create pos1"); + break; + } + return true; + } + case "i": + case "info": { + if (!Permissions.hasPermission(plr, "plots.area.info")) { + C.NO_PERMISSION.send(plr, "plots.area.info"); + return false; + } + PlotArea area; + switch (args.length) { + case 1: + area = plr.getApplicablePlotArea(); + break; + case 2: + area = PS.get().getPlotAreaByString(args[1]); + break; + default: + C.COMMAND_SYNTAX.send(plr, "/plot area info [area]"); + return false; + } + if (area == null) { + if (args.length == 2) { + C.NOT_VALID_PLOT_WORLD.send(plr, args[1]); + } else { + C.NOT_IN_PLOT_WORLD.send(plr); + } + return false; + } + String name; + double percent; + int claimed = area.getPlotCount(); + int clusters = area.getClusters().size(); + String region; + String generator = area.getGenerator() + ""; + if (area.TYPE == 2) { + PlotId min = area.getMin(); + PlotId max = area.getMax(); + name = area.worldname + ";" + area.id + ";" + min + ";" + max; + int size = (max.x - min.x + 1) * (max.y - min.y + 1); + percent = claimed == 0 ? 0 : size / (double) claimed; + region = area.getRegion().toString(); + } else { + name = area.worldname; + percent = claimed == 0 ? 0 : Short.MAX_VALUE * Short.MAX_VALUE / (double) claimed; + region = "N/A"; + } + String value = "&r$1NAME: " + name + + "\n$1Type: $2" + area.TYPE + + "\n$1Terrain: $2" + area.TERRAIN + + "\n$1Usage: $2" + String.format("%.2f", percent) + "%" + + "\n$1Claimed: $2" + claimed + + "\n$1Clusters: $2" + clusters + + "\n$1Region: $2" + region + + "\n$1Generator: $2" + generator; + MainUtil.sendMessage(plr, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false); + return true; + } + case "l": + case "list": { + if (!Permissions.hasPermission(plr, "plots.area.list")) { + C.NO_PERMISSION.send(plr, "plots.area.list"); + return false; + } + int page; + switch (args.length) { + case 1: + page = 0; + break; + case 2: + if (MathMan.isInteger(args[1])) { + page = Integer.parseInt(args[1]); + break; + } + default: + C.COMMAND_SYNTAX.send(plr, "/plot area list [#]"); + return false; + } + ArrayList areas = new ArrayList<>(PS.get().getPlotAreas()); + paginate(plr, areas, 8, page, new RunnableVal3() { + @Override + public void run(Integer i, PlotArea area, PlotMessage message) { + String name; + double percent; + int claimed = area.getPlotCount(); + int clusters = area.getClusters().size(); + String region; + String generator = area.getGenerator() + ""; + if (area.TYPE == 2) { + PlotId min = area.getMin(); + PlotId max = area.getMax(); + name = area.worldname + ";" + area.id + ";" + min + ";" + max; + int size = (max.x - min.x + 1) * (max.y - min.y + 1); + percent = claimed == 0 ? 0 : size / (double) claimed; + region = area.getRegion().toString(); + } else { + name = area.worldname; + percent = claimed == 0 ? 0 : Short.MAX_VALUE * Short.MAX_VALUE / (double) claimed; + region = "N/A"; + } + PlotMessage tooltip = new PlotMessage() + .text("Claimed=").color("$1").text("" + claimed).color("$2") + .text("\nUsage=").color("$1").text(String.format("%.2f", percent) + "%").color("$2") + .text("\nClusters=").color("$1").text("" + clusters).color("$2") + .text("\nRegion=").color("$1").text(region).color("$2") + .text("\nGenerator=").color("$1").text(generator).color("$2"); + + // type / terrain + String visit = "/plot area tp " + area.toString(); + message.text("[").color("$3") + .text(i + "").command(visit).tooltip(visit).color("$1") + .text("]").color("$3") + .text(" " + name).tooltip(tooltip).command("/plot area info " + area).color("$1").text(" - ").color("$2") + .text(area.TYPE + ":" + area.TERRAIN).color("$3"); + } + }, "/plot area list", C.AREA_LIST_HEADER_PAGED.s()); + return true; + } + case "goto": + case "v": + case "teleport": + case "visit": + case "tp": { + if (!Permissions.hasPermission(plr, "plots.area.tp")) { + C.NO_PERMISSION.send(plr, "plots.area.tp"); + return false; + } + if (args.length != 2) { + C.COMMAND_SYNTAX.send(plr, "/plot visit [area]"); + return false; + } + PlotArea area = PS.get().getPlotAreaByString(args[1]); + if (area == null) { + C.NOT_VALID_PLOT_WORLD.send(plr, args[1]); + return false; + } + Location spawn = WorldUtil.IMP.getSpawn(area.worldname); + plr.teleport(spawn); + return true; + } + } + C.COMMAND_SYNTAX.send(plr, getUsage()); + return false; + } + +} diff --git a/src/main/java/com/intellectualcrafters/plot/commands/BO3.java b/src/main/java/com/intellectualcrafters/plot/commands/BO3.java index d797212e3..e775bfdfa 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/BO3.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/BO3.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "bo3", aliases = { "bo2" }, description = "Mark a plot as done", permission = "plots.bo3", category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE) +@CommandDeclaration(command = "bo3", aliases = { "bo2" }, description = "Mark a plot as done", permission = "plots.bo3", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE) public class BO3 extends SubCommand { public void noArgs(final PlotPlayer plr) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Biome.java b/src/main/java/com/intellectualcrafters/plot/commands/Biome.java index 7b8123a5d..2fbdf20a8 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Biome.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Biome.java @@ -34,7 +34,7 @@ permission = "plots.set.biome", description = "Set the plot biome", usage = "/plot biome [biome]", aliases = { "biome", "sb", "setb", "b" }, -category = CommandCategory.ACTIONS, +category = CommandCategory.APPEARANCE, requiredType = RequiredType.NONE) public class Biome extends SetCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Chat.java b/src/main/java/com/intellectualcrafters/plot/commands/Chat.java index db2a8e621..1b23c5a2c 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Chat.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Chat.java @@ -8,7 +8,7 @@ command = "chat", description = "Toggle plot chat on or off", usage = "/plot chat [on|off]", permission = "plots.chat", -category = CommandCategory.ACTIONS, +category = CommandCategory.CHAT, requiredType = RequiredType.NONE) public class Chat extends SubCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index b3fbd3603..2c492eec9 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "clear", description = "Clear a plot", permission = "plots.clear", category = CommandCategory.ACTIONS, usage = "/plot clear [id]") +@CommandDeclaration(command = "clear", description = "Clear a plot", permission = "plots.clear", category = CommandCategory.APPEARANCE, usage = "/plot clear [id]") public class Clear extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 272fdd474..266577bd0 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -46,7 +46,7 @@ import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( command = "cluster", aliases = { "clusters" }, -category = CommandCategory.ACTIONS, +category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, permission = "plots.cluster", description = "Manage a plot cluster") diff --git a/src/main/java/com/intellectualcrafters/plot/commands/CommandCategory.java b/src/main/java/com/intellectualcrafters/plot/commands/CommandCategory.java index 704528e4f..62d1d1280 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/CommandCategory.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/CommandCategory.java @@ -16,25 +16,40 @@ public enum CommandCategory { * * Such as: /plot visit */ - TELEPORT("Teleportation"), + TELEPORT("Teleport"), /** - * Action Commands - * - * Such as: /plot clear + * Protection */ - ACTIONS("Actions"), + SETTINGS("Protection"), + /** + * Chat + */ + CHAT("Chat"), + /** + * Web + */ + SCHEMATIC("Web"), + /** + * Cosmetic + */ + APPEARANCE("Cosmetic"), /** * Information Commands * * Such as: /plot info */ - INFO("Information"), + INFO("Info"), /** * Debug Commands * * Such as: /plot debug */ - DEBUG("Debug"); + DEBUG("Debug"), + /** + * Administration commands + */ + ADMINISTRATION("Admin"); + /** * The category name (Readable) */ diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 37b1a9d45..22933b616 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "comment", aliases = { "msg" }, description = "Comment on a plot", category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE, permission = "plots.comment") +@CommandDeclaration(command = "comment", aliases = { "msg" }, description = "Comment on a plot", category = CommandCategory.CHAT, requiredType = RequiredType.NONE, permission = "plots.comment") public class Comment extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index e3d014e36..95a281dea 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -39,7 +39,7 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "condense", permission = "plots.admin", description = "Condense a plotworld", category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE) +@CommandDeclaration(command = "condense", permission = "plots.admin", description = "Condense a plotworld", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE) public class Condense extends SubCommand { public static boolean TASK = false; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java b/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java index 88574f225..aad253e82 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java @@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "confirm", permission = "plots.use", description = "Confirm an action", category = CommandCategory.ACTIONS) +@CommandDeclaration(command = "confirm", permission = "plots.use", description = "Confirm an action", category = CommandCategory.INFO) public class Confirm extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Continue.java b/src/main/java/com/intellectualcrafters/plot/commands/Continue.java index 3dc4ef0d4..d096ae1d6 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Continue.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Continue.java @@ -34,7 +34,7 @@ import com.plotsquared.general.commands.CommandDeclaration; command = "continue", description = "Continue a plot that was previously marked as done", permission = "plots.continue", -category = CommandCategory.ACTIONS, +category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Continue extends SubCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index af23bbfe2..bc21211d1 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -32,7 +32,7 @@ import com.plotsquared.general.commands.CommandDeclaration; command = "copy", permission = "plots.copy", aliases = { "copypaste" }, -category = CommandCategory.ACTIONS, +category = CommandCategory.CLAIMING, description = "Copy a plot", usage = "/plot copy ", requiredType = RequiredType.NONE) diff --git a/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java b/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java index 52049e0f1..2da7c2107 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -32,7 +32,7 @@ import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( command = "createroadschematic", aliases = { "crs" }, -category = CommandCategory.DEBUG, +category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, permission = "plots.createroadschematic", description = "Add a road schematic to your world using the roads around your current plot", diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 27bb1bfeb..0d62f65b0 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -22,7 +22,7 @@ import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( command = "database", aliases = { "convert" }, -category = CommandCategory.DEBUG, +category = CommandCategory.ADMINISTRATION, permission = "plots.database", description = "Convert/Backup Storage", requiredType = RequiredType.CONSOLE, diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index a4f894e21..ac293d003 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -41,7 +41,7 @@ permission = "plots.delete", description = "Delete a plot", usage = "/plot delete", aliases = { "dispose", "del" }, -category = CommandCategory.ACTIONS, +category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE) public class Delete extends SubCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index a05d1187d..94eed1ad5 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "deny", aliases = { "d" }, description = "Deny a user from a plot", usage = "/plot deny ", category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE) +@CommandDeclaration(command = "deny", aliases = { "d" }, description = "Deny a user from a plot", usage = "/plot deny ", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Deny extends SubCommand { public Deny() { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Desc.java b/src/main/java/com/intellectualcrafters/plot/commands/Desc.java index 80b8bf286..151399546 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Desc.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Desc.java @@ -34,7 +34,7 @@ permission = "plots.set.desc", description = "Set the plot description", usage = "/plot desc ", aliases = { "desc", "setdesc", "setd", "description" }, -category = CommandCategory.ACTIONS, + category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Desc extends SetCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Done.java b/src/main/java/com/intellectualcrafters/plot/commands/Done.java index 81e261d21..25d08e32c 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Done.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Done.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "done", aliases = { "submit" }, description = "Mark a plot as done", permission = "plots.done", category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE) +@CommandDeclaration(command = "done", aliases = { "submit" }, description = "Mark a plot as done", permission = "plots.done", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Done extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Download.java b/src/main/java/com/intellectualcrafters/plot/commands/Download.java index afe501197..8650d610f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Download.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Download.java @@ -16,7 +16,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "download", aliases = { "dl" }, category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download") +@CommandDeclaration(command = "download", aliases = { "dl" }, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download") public class Download extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index d966146e8..c99e830ec 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -43,7 +43,7 @@ command = "setflag", aliases = { "f", "flag", "setf", "setflag" }, usage = "/plot flag ", description = "Set plot flags", -category = CommandCategory.ACTIONS, +category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.flag") public class FlagCmd extends SubCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 361a7e0c9..2dce85fa2 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -39,7 +39,7 @@ command = "inbox", description = "Review the comments for a plot", usage = "/plot inbox [inbox] [delete |clear|page]", permission = "plots.inbox", -category = CommandCategory.ACTIONS, +category = CommandCategory.CHAT, requiredType = RequiredType.NONE) public class Inbox extends SubCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 49eac2261..123b34be6 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "kick", aliases = { "k" }, description = "Kick a player from your plot", permission = "plots.kick", category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE) +@CommandDeclaration(command = "kick", aliases = { "k" }, description = "Kick a player from your plot", permission = "plots.kick", category = CommandCategory.TELEPORT, requiredType = RequiredType.NONE) public class Kick extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Limit.java b/src/main/java/com/intellectualcrafters/plot/commands/Limit.java deleted file mode 100644 index d1d0be6f2..000000000 --- a/src/main/java/com/intellectualcrafters/plot/commands/Limit.java +++ /dev/null @@ -1,62 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// PlotSquared - A plot manager and world generator for the Bukkit API / -// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / -// / -// This program is free software; you can redistribute it and/or modify / -// it under the terms of the GNU General Public License as published by / -// the Free Software Foundation; either version 3 of the License, or / -// (at your option) any later version. / -// / -// This program is distributed in the hope that it will be useful, / -// but WITHOUT ANY WARRANTY; without even the implied warranty of / -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / -// GNU General Public License for more details. / -// / -// You should have received a copy of the GNU General Public License / -// along with this program; if not, write to the Free Software Foundation, / -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / -// / -// You can contact us via: support@intellectualsites.com / -//////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.commands; - -import java.util.UUID; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.general.commands.Argument; -import com.plotsquared.general.commands.CommandDeclaration; - -@CommandDeclaration( -command = "limit", -permission = "plots.limit", -description = "Set or increment player plot claim limits", -aliases = { "setlimit" }, -usage = "/plot limit ", -category = CommandCategory.DEBUG) -public class Limit extends SubCommand { - - public Limit() { - requiredArguments = new Argument[] { Argument.String, Argument.String }; - } - - @Override - public boolean onCommand(final PlotPlayer plr, final String[] args) { - final UUID uuid = UUIDHandler.getUUID(args[0], null); - if (uuid == null) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); - return false; - } - UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid); - - // get current plot limit - // increase - - // EconHandler.manager.setPermission(op, perm, value); - plr.sendMessage("TODO"); - - return true; - } -} diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Load.java b/src/main/java/com/intellectualcrafters/plot/commands/Load.java index 2034d263e..6514c3068 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Load.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Load.java @@ -21,7 +21,7 @@ import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( command = "load", aliases = { "restore" }, -category = CommandCategory.ACTIONS, +category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Load your plot", permission = "plots.load", diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index fce95e9b8..25596fe08 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -68,13 +68,13 @@ public class MainCommand extends CommandManager { createCommand(new Buy()); createCommand(new Save()); createCommand(new Load()); - createCommand(new Unclaim()); createCommand(new Confirm()); createCommand(new Template()); createCommand(new Download()); createCommand(new Update()); createCommand(new Template()); createCommand(new Setup()); + createCommand(new Area()); createCommand(new DebugSaveTest()); createCommand(new DebugLoadTest()); createCommand(new CreateRoadSchematic()); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index a4069390c..ebb92c895 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -43,7 +43,7 @@ aliases = { "m" }, description = "Merge the plot you are standing on, with another plot", permission = "plots.merge", usage = "/plot merge [removeroads]", -category = CommandCategory.ACTIONS, +category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Merge extends SubCommand { public final static String[] values = new String[] { "north", "east", "south", "west", "auto" }; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/src/main/java/com/intellectualcrafters/plot/commands/Move.java index aff5aad98..8ce8579ae 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -34,7 +34,7 @@ command = "move", description = "Move a plot", aliases = { "debugmove" }, permission = "plots.move", -category = CommandCategory.ACTIONS, +category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE) public class Move extends SubCommand { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index a57309ca0..51d4e705d 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -29,11 +29,16 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotInventory; import com.intellectualcrafters.plot.object.PlotItemStack; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "music", permission = "plots.music", description = "Player music in a plot", usage = "/plot music", category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE) +@CommandDeclaration( +command = "music", +permission = "plots.music", +description = "Player music in a plot", +usage = "/plot music", +category = CommandCategory.APPEARANCE, +requiredType = RequiredType.NONE) public class MusicSubcommand extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Owner.java b/src/main/java/com/intellectualcrafters/plot/commands/Owner.java index 489d1ef85..60cd720ef 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Owner.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Owner.java @@ -38,7 +38,7 @@ permission = "plots.set.owner", description = "Set the plot owner", usage = "/plot setowner ", aliases = { "owner", "so", "seto" }, -category = CommandCategory.ACTIONS, +category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE) public class Owner extends SetCommand { @@ -58,6 +58,16 @@ public class Owner extends SetCommand { name = name == null ? value : name; } if (uuid == null) { + if (value.equalsIgnoreCase("none")) { + HashSet connected = plot.getConnectedPlots(); + plot.unlink(); + for (Plot current : connected) { + current.unclaim(); + current.removeSign(); + } + MainUtil.sendMessage(plr, C.SET_OWNER); + return true; + } C.INVALID_PLAYER.send(plr, value); return false; } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index bb69a00c4..98d48a97f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -43,7 +43,7 @@ usage = "/plot purge world: area: id: owner: shared: void paginate(PlotPlayer player, List c, int size, int page, RunnableVal3 add, String baseCommand, String header) { + // Calculate pages & index + if (page < 0) { + page = 0; + } + final int totalPages = (int) Math.ceil(c.size() / size); + if (page > totalPages) { + page = totalPages; + } + int max = (page * size) + size; + if (max > c.size()) { + max = c.size(); + } + // Send the header + header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", totalPages + "").replaceAll("%word%", "all"); + MainUtil.sendMessage(player, header); + // Send the page content + final List subList = c.subList(page * size, max); + int i = page * size; + for (final T obj : subList) { + i++; + PlotMessage msg = new PlotMessage(); + add.run(i, obj, msg); + msg.send(player); + } + // Send the footer + if ((page < totalPages) && (page > 0)) { // Back | Next + new PlotMessage().text("<-").color("$1").command(baseCommand + " " + (page)).text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2)) + .text(C.CLICKABLE.s()).color("$2").send(player); + return; + } + if ((page == 0) && (totalPages != 0)) { // Next + new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2)).text(C.CLICKABLE.s()).color("$2").send(player); + return; + } + if ((page == totalPages) && (totalPages != 0)) { // Back + new PlotMessage().text("<-").color("$1").command(baseCommand + " " + (page)).text(" | ").color("$3").text("->").color("$3").text(C.CLICKABLE.s()).color("$2").send(player); + return; + } + } } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index da7b254f3..81baf1d5f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(usage = "/plot swap ", command = "swap", description = "Swap two plots", aliases = { "switch" }, category = CommandCategory.ACTIONS, requiredType = RequiredType.NONE) +@CommandDeclaration(usage = "/plot swap ", command = "swap", description = "Swap two plots", aliases = { "switch" }, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE) public class Swap extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/src/main/java/com/intellectualcrafters/plot/commands/Target.java index 1ee250ae1..be7337f0f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -35,7 +35,7 @@ usage = "/plot target <|nearest>", description = "Target a plot with your compass", permission = "plots.target", requiredType = RequiredType.NONE, -category = CommandCategory.ACTIONS) +category = CommandCategory.INFO) public class Target extends SubCommand { @Override diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/src/main/java/com/intellectualcrafters/plot/commands/Template.java index de3a87f8e..62b4561a2 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -51,7 +51,7 @@ command = "template", permission = "plots.admin", description = "Create or use a world template", usage = "/plot template [import|export]