Skip to content

Commit

Permalink
Don't discard all the activators on failed saving
Browse files Browse the repository at this point in the history
  • Loading branch information
imDaniX committed Mar 4, 2024
1 parent 712d9e7 commit 6acfe4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public final void saveActivator(@NotNull ConfigurationSection cfg) {
*
* @param cfg Section of activator
*/
public void saveOptions(@NotNull ConfigurationSection cfg) {
protected void saveOptions(@NotNull ConfigurationSection cfg) {
// Sometimes we don't need that
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,15 @@ private void saveGroup(@NotNull String name, @NotNull Set<Activator> activators)
}
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
for (Activator activator : activators) {
String typeStr = Objects.requireNonNull(types.get(activator.getClass())).getName();
ConfigurationSection typeCfg = ConfigUtils.getSection(cfg, typeStr);
activator.saveActivator(typeCfg.createSection(activator.getLogic().getName()));
try {
String typeStr = Objects.requireNonNull(types.get(activator.getClass())).getName();
ConfigurationSection typeCfg = ConfigUtils.getSection(cfg, typeStr);
activator.saveActivator(typeCfg.createSection(activator.getLogic().getName()));
} catch (Exception ex) {
logger.error("Something went wrong during activator saving. " +
activator.getLogic().getGroup() + "/" + activator.getLogic().getName() +
" (" + activator.getLogic().getType() + ")", ex);
}
}
try {
cfg.save(file);
Expand Down

0 comments on commit 6acfe4e

Please sign in to comment.