@ -11,6 +11,7 @@ import javax.swing.JOptionPane;
|
||||
import envoy.client.Client;
|
||||
import envoy.client.Config;
|
||||
import envoy.client.LocalDB;
|
||||
import envoy.client.Settings;
|
||||
import envoy.client.util.EnvoyLog;
|
||||
import envoy.exception.EnvoyException;
|
||||
import envoy.schema.User;
|
||||
@ -126,5 +127,18 @@ public class Startup {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
// Save Settings and LocalDB on shutdown
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
try {
|
||||
logger.info("Saving local database...");
|
||||
localDB.save();
|
||||
logger.info("Saving settings...");
|
||||
Settings.getInstance().save();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
logger.log(Level.WARNING, "Unable to save the messages", e1);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user