Unload extensions when shutting down the server

This commit is contained in:
Felix Cravic 2020-12-03 17:35:04 +01:00
parent d61a598c94
commit 6f8cbeb73b
2 changed files with 13 additions and 0 deletions

View File

@ -738,6 +738,8 @@ public final class MinecraftServer {
connectionManager.shutdown();
nettyServer.stop();
storageManager.getLoadedLocations().forEach(StorageLocation::close);
LOGGER.info("Unloading all extensions.");
extensionManager.shutdown();
LOGGER.info("Shutting down all thread pools.");
benchmarkManager.disable();
commandManager.stopConsoleThread();

View File

@ -622,4 +622,15 @@ public class ExtensionManager {
// call GC to try to get rid of classes and classloader
System.gc();
}
/**
* Shutdowns all the extensions by unloading them.
*/
public void shutdown() {
Iterator<Extension> extensionIterator = extensionList.iterator();
while (extensionIterator.hasNext()) {
final Extension extension = extensionIterator.next();
unload(extension);
}
}
}