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"
(@NotNull String world, @Nullable String name, @Nullable CommandSender output)
| 353 | * @return Resulting generator, or null |
| 354 | */ |
| 355 | @Nullable |
| 356 | public static ChunkGenerator getGeneratorForName(@NotNull String world, @Nullable String name, @Nullable CommandSender output) { |
| 357 | ChunkGenerator result = null; |
| 358 | |
| 359 | if (world == null) { |
| 360 | throw new IllegalArgumentException("World name must be specified"); |
| 361 | } |
| 362 | |
| 363 | if (output == null) { |
| 364 | output = Bukkit.getConsoleSender(); |
| 365 | } |
| 366 | |
| 367 | if (name != null) { |
| 368 | String[] split = name.split(":", 2); |
| 369 | String id = (split.length > 1) ? split[1] : null; |
| 370 | Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]); |
| 371 | |
| 372 | if (plugin == null) { |
| 373 | output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + split[0] + "' does not exist"); |
| 374 | } else if (!plugin.isEnabled()) { |
| 375 | output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled"); |
| 376 | } else { |
| 377 | result = plugin.getDefaultWorldGenerator(world, id); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | return result; |
| 382 | } |
| 383 | } |
no test coverage detected