Skip to content

Commit

Permalink
Fix subfolder not getting created when loading config that doesn't ex…
Browse files Browse the repository at this point in the history
…ist, also use Files.exists instead of Files.notExists
  • Loading branch information
magicmq committed Jun 20, 2024
1 parent c42023b commit 834cab1
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class ConfigManager {

private ConfigManager() {
configFolder = Paths.get(PySpigot.get().getDataFolder().getAbsolutePath(), "configs");
if (Files.notExists(configFolder)) {
if (!Files.exists(configFolder)) {
try {
Files.createDirectory(configFolder);
Files.createDirectories(configFolder);
} catch (IOException exception) {
PySpigot.get().getLogger().log(Level.SEVERE, "Error when creating configs folder for script config files", exception);
}
Expand Down Expand Up @@ -69,8 +69,10 @@ public boolean doesConfigExist(String filePath) {
public ScriptConfig loadConfig(String filePath) throws IOException, InvalidConfigurationException {
Path configFile = configFolder.resolve(Paths.get(filePath));

if (Files.notExists(configFile))
if (!Files.exists(configFile)) {
Files.createDirectories(configFile.getParent());
Files.createFile(configFile);
}

return ScriptConfig.loadConfig(configFile.toFile());
}
Expand Down

0 comments on commit 834cab1

Please sign in to comment.