Add warning of player still in world while unloading

This commit is contained in:
Ben Woo 2023-09-14 11:26:07 +08:00
parent 23b429940c
commit 94bcca914f
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
1 changed files with 4 additions and 3 deletions

View File

@ -669,12 +669,13 @@ public class WorldManager {
unloadTracker.add(world.getName());
if (!Bukkit.unloadWorld(world, save)) {
// TODO: Localize this, maybe with MultiverseException
if (!world.getPlayers().isEmpty()) {
throw new Exception("There are still players in the world! Please use --remove-players flag to "
+ "your command if wish to teleport all players out of the world.");
}
throw new Exception("Is this the default world? You can't unload the default world!");
}
Logging.fine("Bukkit unloaded world: " + world.getName());
}).onFailure(exception -> {
Logging.severe("Failed to unload bukkit world: " + world.getName());
exception.printStackTrace();
}).andFinally(() -> unloadTracker.remove(world.getName()));
}