Attempts to get the ChunkGenerator with the given name. If the generator is not found, null will be returned and a message will be printed to the specified CommandSender explaining why. The name must be in the "plugin:id" notation, or optionally just "plugin", where "plugin"
(String world, String name, CommandSender output)
| 217 | * @return Resulting generator, or null |
| 218 | */ |
| 219 | public static ChunkGenerator getGeneratorForName(String world, String name, CommandSender output) { |
| 220 | ChunkGenerator result = null; |
| 221 | |
| 222 | if (world == null) { |
| 223 | throw new IllegalArgumentException("World name must be specified"); |
| 224 | } |
| 225 | |
| 226 | if (output == null) { |
| 227 | output = Bukkit.getConsoleSender(); |
| 228 | } |
| 229 | |
| 230 | if (name != null) { |
| 231 | String[] split = name.split(":", 2); |
| 232 | String id = (split.length > 1) ? split[1] : null; |
| 233 | Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]); |
| 234 | |
| 235 | if (plugin == null) { |
| 236 | output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + split[0] + "' does not exist"); |
| 237 | } else if (!plugin.isEnabled()) { |
| 238 | output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled"); |
| 239 | } else { |
| 240 | result = plugin.getDefaultWorldGenerator(world, id); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | return result; |
| 245 | } |
| 246 | } |
no test coverage detected