Ignore IllegalStateException(Shutdown in Progress)

This commit is contained in:
huangyuhui 2017-02-05 16:59:59 +08:00
parent ac66dfe476
commit 2ece71aae3

View File

@ -50,10 +50,13 @@ public class DefaultPlugin implements IPlugin {
auths.add(new OfflineAuthenticator(clientToken)); auths.add(new OfflineAuthenticator(clientToken));
auths.add(new YggdrasilAuthenticator(clientToken)); auths.add(new YggdrasilAuthenticator(clientToken));
Runtime.getRuntime().addShutdownHook(new Thread(() -> { try {
for (IAuthenticator i : auths) Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Settings.getInstance().setAuthenticatorConfig(i.id(), i.onSaveSettings()); for (IAuthenticator i : auths)
})); Settings.getInstance().setAuthenticatorConfig(i.id(), i.onSaveSettings());
}));
} catch(IllegalStateException ignore) { // Shutdown in progress
}
for (IAuthenticator i : auths) { for (IAuthenticator i : auths) {
i.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(i.id())); i.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(i.id()));
apply.accept(i); apply.accept(i);