add simple reload action

This commit is contained in:
marhali 2022-04-09 12:33:35 +02:00
parent 09ebf454d4
commit b6fc0c08ff

View File

@ -52,6 +52,15 @@ public class InstanceManager {
return this.bus; return this.bus;
} }
/**
* Reloads the plugin instance. Unsaved cached data will be deleted.
* Fetches data from persistence layer and notifies all endpoints via {@link DataBus}.
*/
public void reload() {
store.loadFromPersistenceLayer((success) ->
bus.propagate().onUpdateData(store.getData()));
}
public void processUpdate(TranslationUpdate update) { public void processUpdate(TranslationUpdate update) {
if(update.isDeletion() || update.isKeyChange()) { // Remove origin translation if(update.isDeletion() || update.isKeyChange()) { // Remove origin translation
this.store.getData().setTranslation(update.getOrigin().getKey(), null); this.store.getData().setTranslation(update.getOrigin().getKey(), null);