World arguments

The WorldArgument class allows a command sender to refer to a loaded Bukkit World.
Example - Unloading world
Example - Unloading world
Say we want to unload a world on our Minecraft server. We want to create a command with the following syntax:
mccmd
/unloadworld <world>Using the world from the WorldArgument, we can then unload the world safely using Bukkit.getServer().unloadWorld() and passing true (to save chunks):
java
new CommandAPICommand("unloadworld")
.withArguments(new WorldArgument("world"))
.executes((sender, args) -> {
World world = (World) args.get("world");
// Unload the world (and save the world's chunks)
Bukkit.getServer().unloadWorld(world, true);
})
.register();