diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/ResourceSvc.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/ResourceSvc.java index d9ca34e16..e87f78076 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/ResourceSvc.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/ResourceSvc.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.OpenOption; +import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.*; import java.util.function.Supplier; @@ -171,7 +172,9 @@ public class ResourceSvc implements ResourceService { WebResource original = source.get(); byte[] bytes = original.asBytes(); OpenOption[] overwrite = {StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE}; - Files.write(files.getCustomizationDirectory().resolve(fileName), bytes, overwrite); + Path to = files.getCustomizationDirectory().resolve(fileName); + Files.createDirectories(to.getParent()); + Files.write(to, bytes, overwrite); return original; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ResourceSettings.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ResourceSettings.java index 2882ab1aa..8efd3f170 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ResourceSettings.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ResourceSettings.java @@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.io.UncheckedIOException; +import java.util.Collections; public class ResourceSettings { @@ -33,13 +34,17 @@ public class ResourceSettings { public boolean shouldBeCustomized(String plugin, String fileName) { ConfigNode fileCustomization = config.getNode("Customized_files").orElseGet(() -> config.addNode("Customized_files")); + fileCustomization.setComment(Collections.singletonList("The files are placed in /Plan/web/ if the setting is 'true' when accessed.")); + ConfigNode pluginCustomization = fileCustomization.getNode(plugin).orElseGet(() -> fileCustomization.addNode(plugin)); String fileNameNonPath = StringUtils.replaceChars(fileName, '.', ','); + if (pluginCustomization.contains(fileNameNonPath)) { return pluginCustomization.getBoolean(fileNameNonPath); } else { pluginCustomization.set(fileNameNonPath, false); try { + pluginCustomization.sort(); pluginCustomization.save(); } catch (IOException e) { throw new UncheckedIOException("Could not save config.yml: " + e.getMessage(), e);