I have a few questions about world unloading. So when is a world unloaded? Only when the server stops, restarts, every chunk is unloaded, no players are in this world for x minutes or ... Then whats the difference between WorldSave- and WorldUnload event? Isn't a world only and always saved when it will unload?
I had many problems with world unloading too. To unload a world just use: Code:java plugin.getServer().unloadWorld(worldName, true); I had problems when I set the boolean save to false, because the world didn't unload completely. You can't unload a world as long as there are players in the world. That means that you have to teleport all players to another world beforeunloading and you have to force dead player to respawn before you teleport them. Code:java for (Player p : world.getPlayers()) { if (p.isDead()) { ((CraftPlayer) p).getHandle().playerConnection.a(new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN)); } } plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { for (Player p : world.getPlayers()) { p.teleport(l); } plugin.getServer().unloadWorld(world.getName(), true); } }, 20L); The world should be completely unloaded after this code
Ok, thx, the second question is completely answered. But I need to know, when a world is unloaded automatically? On /reload or when the server /stop s or ...
Zupsub I think world is auto-unloaded when: /stop is called, last player in that world switches to another world or disconnects, some plugin calls <world>.unload(boolean save), and there may be more, but I can't think of anything more right now.