Permalink
Browse files

Added confirmation message for /pex world <world> inherits <parent wo…

…rlds>. issue #345
  • Loading branch information...
1 parent 8faf058 commit b68a6a4cadf6d181db022171e47d7dd82128e70c @t3hk0d3 t3hk0d3 committed Jun 8, 2012
Showing with 83 additions and 81 deletions.
  1. +83 −81 src/main/java/ru/tehkode/permissions/bukkit/commands/WorldCommands.java
@@ -32,85 +32,87 @@
import ru.tehkode.utils.StringUtils;
public class WorldCommands extends PermissionsCommand {
-
- @Command(name = "pex",
- syntax = "worlds",
- description = "Print loaded worlds",
- isPrimary = true,
- permission = "permissions.manage.worlds")
- public void worldsTree(Plugin plugin, CommandSender sender, Map<String, String> args) {
- List<World> worlds = Bukkit.getServer().getWorlds();
-
- PermissionManager manager = PermissionsEx.getPermissionManager();
-
- sender.sendMessage("Worlds on server: ");
- for (World world : worlds) {
- String[] parentWorlds = manager.getWorldInheritance(world.getName());
- String output = " " + world.getName();
- if (parentWorlds.length > 0) {
- output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
- }
-
- sender.sendMessage(output);
- }
- }
-
- @Command(name = "pex",
- syntax = "world <world>",
- description = "Print <world> inheritance info",
- permission = "permissions.manage.worlds")
- public void worldPrintInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
- String worldName = this.autoCompleteWorldName(args.get("world"));
- PermissionManager manager = PermissionsEx.getPermissionManager();
- if (Bukkit.getServer().getWorld(worldName) == null) {
- sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
- return;
- }
-
- String[] parentWorlds = manager.getWorldInheritance(worldName);
-
- sender.sendMessage("World " + worldName + " inherit:");
- if (parentWorlds.length == 0) {
- sender.sendMessage("nothing :3");
- return;
- }
-
- for (String parentWorld : parentWorlds) {
- String[] parents = manager.getWorldInheritance(parentWorld);
- String output = " " + parentWorld;
- if (parentWorlds.length > 0) {
- output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
- }
-
- sender.sendMessage(output);
- }
- }
-
- @Command(name = "pex",
- syntax = "world <world> inherit <parentWorlds>",
- description = "Set <parentWorlds> for <world>",
- permission = "permissions.manage.worlds.inheritance")
- public void worldSetInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
- String worldName = this.autoCompleteWorldName(args.get("world"));
- PermissionManager manager = PermissionsEx.getPermissionManager();
- if (Bukkit.getServer().getWorld(worldName) == null) {
- sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
- return;
- }
-
- List<String> parents = new ArrayList<String>();
- String parentWorlds = args.get("parentWorlds");
- if (parentWorlds.contains(",")) {
- for (String world : parentWorlds.split(",")) {
- world = this.autoCompleteWorldName(world, "parentWorlds");
- if (!parents.contains(world)) {
- parents.add(world.trim());
- }
- }
- } else {
- parents.add(parentWorlds.trim());
- }
-
- manager.setWorldInheritance(worldName, parents.toArray(new String[0]));
- }
+
+ @Command(name = "pex",
+ syntax = "worlds",
+ description = "Print loaded worlds",
+ isPrimary = true,
+ permission = "permissions.manage.worlds")
+ public void worldsTree(Plugin plugin, CommandSender sender, Map<String, String> args) {
+ List<World> worlds = Bukkit.getServer().getWorlds();
+
+ PermissionManager manager = PermissionsEx.getPermissionManager();
+
+ sender.sendMessage("Worlds on server: ");
+ for (World world : worlds) {
+ String[] parentWorlds = manager.getWorldInheritance(world.getName());
+ String output = " " + world.getName();
+ if (parentWorlds.length > 0) {
+ output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
+ }
+
+ sender.sendMessage(output);
+ }
+ }
+
+ @Command(name = "pex",
+ syntax = "world <world>",
+ description = "Print <world> inheritance info",
+ permission = "permissions.manage.worlds")
+ public void worldPrintInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
+ String worldName = this.autoCompleteWorldName(args.get("world"));
+ PermissionManager manager = PermissionsEx.getPermissionManager();
+ if (Bukkit.getServer().getWorld(worldName) == null) {
+ sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
+ return;
+ }
+
+ String[] parentWorlds = manager.getWorldInheritance(worldName);
+
+ sender.sendMessage("World " + worldName + " inherit:");
+ if (parentWorlds.length == 0) {
+ sender.sendMessage("nothing :3");
+ return;
+ }
+
+ for (String parentWorld : parentWorlds) {
+ String[] parents = manager.getWorldInheritance(parentWorld);
+ String output = " " + parentWorld;
+ if (parentWorlds.length > 0) {
+ output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
+ }
+
+ sender.sendMessage(output);
+ }
+ }
+
+ @Command(name = "pex",
+ syntax = "world <world> inherit <parentWorlds>",
+ description = "Set <parentWorlds> for <world>",
+ permission = "permissions.manage.worlds.inheritance")
+ public void worldSetInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
+ String worldName = this.autoCompleteWorldName(args.get("world"));
+ PermissionManager manager = PermissionsEx.getPermissionManager();
+ if (Bukkit.getServer().getWorld(worldName) == null) {
+ sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
+ return;
+ }
+
+ List<String> parents = new ArrayList<String>();
+ String parentWorlds = args.get("parentWorlds");
+ if (parentWorlds.contains(",")) {
+ for (String world : parentWorlds.split(",")) {
+ world = this.autoCompleteWorldName(world, "parentWorlds");
+ if (!parents.contains(world)) {
+ parents.add(world.trim());
+ }
+ }
+ } else {
+ parents.add(parentWorlds.trim());
+ }
+
+ manager.setWorldInheritance(worldName, parents.toArray(new String[0]));
+
+ sender.sendMessage("World " + worldName + " inherits " + StringUtils.implode(parents, ", "));
+ }
}

0 comments on commit b68a6a4

Please sign in to comment.