mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Save plugin storage when plugins are reloaded, if dirty
This commit is contained in:
parent
3e45689d6e
commit
3fb709b098
2 changed files with 14 additions and 7 deletions
|
|
@ -47,6 +47,7 @@ public class PluginRepository {
|
|||
API.registeredMouseListeners.clear();
|
||||
API.registeredKeyListeners.clear();
|
||||
loadedPlugins.clear();
|
||||
SaveStorage();
|
||||
Init();
|
||||
}
|
||||
|
||||
|
|
@ -69,13 +70,7 @@ public class PluginRepository {
|
|||
} catch (Exception e) {e.printStackTrace();}
|
||||
}
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
try(FileOutputStream fos = new FileOutputStream(GlobalJsonConfig.instance.pluginsFolder + File.separator + "plsto")) {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
oos.writeObject(PluginRepository.pluginStorage);
|
||||
oos.close();
|
||||
} catch (Exception e) {e.printStackTrace();}
|
||||
}));
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(PluginRepository::SaveStorage));
|
||||
|
||||
try {
|
||||
URL[] classPath = {pluginsDirectory.toURI().toURL()};
|
||||
|
|
@ -183,4 +178,15 @@ public class PluginRepository {
|
|||
public static void OnLogin() {
|
||||
loadedPlugins.values().forEach((plugin) -> plugin.OnLogin());
|
||||
}
|
||||
|
||||
public static void SaveStorage() {
|
||||
if (pluginStorage.containsKey("_keystoreDirty")) {
|
||||
pluginStorage.remove("_keystoreDirty");
|
||||
try(FileOutputStream fos = new FileOutputStream(GlobalJsonConfig.instance.pluginsFolder + File.separator + "plsto")) {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
oos.writeObject(PluginRepository.pluginStorage);
|
||||
oos.close();
|
||||
} catch (Exception e) {e.printStackTrace();}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ public class API {
|
|||
|
||||
public static void StoreData(String key, Object value) {
|
||||
PluginRepository.pluginStorage.put(key, value);
|
||||
PluginRepository.pluginStorage.put("_keystoreDirty", true);
|
||||
}
|
||||
|
||||
public static Object GetData(String key) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue