Skip to content
This repository
Browse code

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

…rlds>. issue #345
  • Loading branch information...
commit b68a6a4cadf6d181db022171e47d7dd82128e70c 1 parent 8faf058
Igor Yamolov authored June 08, 2012
164  src/main/java/ru/tehkode/permissions/bukkit/commands/WorldCommands.java
@@ -32,85 +32,87 @@
32 32
 import ru.tehkode.utils.StringUtils;
33 33
 
34 34
 public class WorldCommands extends PermissionsCommand {
35  
-    
36  
-    @Command(name = "pex",
37  
-    syntax = "worlds",
38  
-    description = "Print loaded worlds",
39  
-    isPrimary = true,
40  
-    permission = "permissions.manage.worlds")
41  
-    public void worldsTree(Plugin plugin, CommandSender sender, Map<String, String> args) {
42  
-        List<World> worlds = Bukkit.getServer().getWorlds();
43  
-        
44  
-        PermissionManager manager = PermissionsEx.getPermissionManager();
45  
-        
46  
-        sender.sendMessage("Worlds on server: ");
47  
-        for (World world : worlds) {
48  
-            String[] parentWorlds = manager.getWorldInheritance(world.getName());
49  
-            String output = "  " + world.getName();
50  
-            if (parentWorlds.length > 0) {
51  
-                output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
52  
-            }
53  
-            
54  
-            sender.sendMessage(output);
55  
-        }
56  
-    }
57  
-    
58  
-    @Command(name = "pex",
59  
-    syntax = "world <world>",
60  
-    description = "Print <world> inheritance info",
61  
-    permission = "permissions.manage.worlds")
62  
-    public void worldPrintInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
63  
-        String worldName = this.autoCompleteWorldName(args.get("world"));
64  
-        PermissionManager manager = PermissionsEx.getPermissionManager();
65  
-        if (Bukkit.getServer().getWorld(worldName) == null) {
66  
-            sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
67  
-            return;
68  
-        }
69  
-        
70  
-        String[] parentWorlds = manager.getWorldInheritance(worldName);
71  
-        
72  
-        sender.sendMessage("World " + worldName + " inherit:");
73  
-        if (parentWorlds.length == 0) {
74  
-            sender.sendMessage("nothing :3");
75  
-            return;
76  
-        }
77  
-        
78  
-        for (String parentWorld : parentWorlds) {
79  
-            String[] parents = manager.getWorldInheritance(parentWorld);
80  
-            String output = "  " + parentWorld;
81  
-            if (parentWorlds.length > 0) {
82  
-                output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
83  
-            }
84  
-            
85  
-            sender.sendMessage(output);
86  
-        }
87  
-    }
88  
-    
89  
-    @Command(name = "pex",
90  
-    syntax = "world <world> inherit <parentWorlds>",
91  
-    description = "Set <parentWorlds> for <world>",
92  
-    permission = "permissions.manage.worlds.inheritance")
93  
-    public void worldSetInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
94  
-        String worldName = this.autoCompleteWorldName(args.get("world"));
95  
-        PermissionManager manager = PermissionsEx.getPermissionManager();
96  
-        if (Bukkit.getServer().getWorld(worldName) == null) {
97  
-            sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
98  
-            return;
99  
-        }
100  
-        
101  
-        List<String> parents = new ArrayList<String>();
102  
-        String parentWorlds = args.get("parentWorlds");
103  
-        if (parentWorlds.contains(",")) {
104  
-            for (String world : parentWorlds.split(",")) {
105  
-                world = this.autoCompleteWorldName(world, "parentWorlds");
106  
-                if (!parents.contains(world)) {
107  
-                    parents.add(world.trim());
108  
-                }
109  
-            }
110  
-        } else {
111  
-            parents.add(parentWorlds.trim());
112  
-        }
113  
-        
114  
-        manager.setWorldInheritance(worldName, parents.toArray(new String[0]));
115  
-    }
  35
+
  36
+	@Command(name = "pex",
  37
+	syntax = "worlds",
  38
+	description = "Print loaded worlds",
  39
+	isPrimary = true,
  40
+	permission = "permissions.manage.worlds")
  41
+	public void worldsTree(Plugin plugin, CommandSender sender, Map<String, String> args) {
  42
+		List<World> worlds = Bukkit.getServer().getWorlds();
  43
+
  44
+		PermissionManager manager = PermissionsEx.getPermissionManager();
  45
+
  46
+		sender.sendMessage("Worlds on server: ");
  47
+		for (World world : worlds) {
  48
+			String[] parentWorlds = manager.getWorldInheritance(world.getName());
  49
+			String output = "  " + world.getName();
  50
+			if (parentWorlds.length > 0) {
  51
+				output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
  52
+			}
  53
+
  54
+			sender.sendMessage(output);
  55
+		}
  56
+	}
  57
+
  58
+	@Command(name = "pex",
  59
+	syntax = "world <world>",
  60
+	description = "Print <world> inheritance info",
  61
+	permission = "permissions.manage.worlds")
  62
+	public void worldPrintInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
  63
+		String worldName = this.autoCompleteWorldName(args.get("world"));
  64
+		PermissionManager manager = PermissionsEx.getPermissionManager();
  65
+		if (Bukkit.getServer().getWorld(worldName) == null) {
  66
+			sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
  67
+			return;
  68
+		}
  69
+
  70
+		String[] parentWorlds = manager.getWorldInheritance(worldName);
  71
+
  72
+		sender.sendMessage("World " + worldName + " inherit:");
  73
+		if (parentWorlds.length == 0) {
  74
+			sender.sendMessage("nothing :3");
  75
+			return;
  76
+		}
  77
+
  78
+		for (String parentWorld : parentWorlds) {
  79
+			String[] parents = manager.getWorldInheritance(parentWorld);
  80
+			String output = "  " + parentWorld;
  81
+			if (parentWorlds.length > 0) {
  82
+				output += ChatColor.GREEN + " [" + ChatColor.WHITE + StringUtils.implode(parentWorlds, ", ") + ChatColor.GREEN + "]";
  83
+			}
  84
+
  85
+			sender.sendMessage(output);
  86
+		}
  87
+	}
  88
+
  89
+	@Command(name = "pex",
  90
+	syntax = "world <world> inherit <parentWorlds>",
  91
+	description = "Set <parentWorlds> for <world>",
  92
+	permission = "permissions.manage.worlds.inheritance")
  93
+	public void worldSetInheritance(Plugin plugin, CommandSender sender, Map<String, String> args) {
  94
+		String worldName = this.autoCompleteWorldName(args.get("world"));
  95
+		PermissionManager manager = PermissionsEx.getPermissionManager();
  96
+		if (Bukkit.getServer().getWorld(worldName) == null) {
  97
+			sender.sendMessage("Specified world \"" + args.get("world") + "\" not found.");
  98
+			return;
  99
+		}
  100
+
  101
+		List<String> parents = new ArrayList<String>();
  102
+		String parentWorlds = args.get("parentWorlds");
  103
+		if (parentWorlds.contains(",")) {
  104
+			for (String world : parentWorlds.split(",")) {
  105
+				world = this.autoCompleteWorldName(world, "parentWorlds");
  106
+				if (!parents.contains(world)) {
  107
+					parents.add(world.trim());
  108
+				}
  109
+			}
  110
+		} else {
  111
+			parents.add(parentWorlds.trim());
  112
+		}
  113
+
  114
+		manager.setWorldInheritance(worldName, parents.toArray(new String[0]));
  115
+
  116
+		sender.sendMessage("World " + worldName + " inherits " + StringUtils.implode(parents, ", "));
  117
+	}
116 118
 }

0 notes on commit b68a6a4

Please sign in to comment.
Something went wrong with that request. Please try again.