Skip to content

Commit

Permalink
Fix blank config file not being written
Browse files Browse the repository at this point in the history
The file creation and writing logic were previously in the wrong order.
  • Loading branch information
TechnoPorg committed Sep 14, 2024
1 parent 822cc68 commit bda8f1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public void onInitialize() {

DiscordBot bot = new DiscordBot();

LOGGER.info("DiscordVerifier finished initializing.");
LOGGER.info("DiscordVerifier initialization complete.");
}
}
14 changes: 7 additions & 7 deletions src/main/java/org/iolhaven/discord_verifier/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ private static ModConfig loadConfig() {
DiscordVerifier.LOGGER.error("Error loading config: {}", e.getMessage());
config = new ModConfig();
}
} else { // Write a blank config file to disk for the server admin to populate.
} else { // Write a blank config file to disk to be filled in by the server admin.
config = new ModConfig();
try (Writer writer = new FileWriter(CONFIG_FILE)) {
if(CONFIG_FILE.getParentFile() != null) {
CONFIG_FILE.getParentFile().mkdirs();
}
try {
CONFIG_FILE.getParentFile().mkdirs();
CONFIG_FILE.createNewFile();
GSON.toJson(config, writer);

DiscordVerifier.LOGGER.debug("Wrote new blank mod config.");
try (Writer writer = new FileWriter(CONFIG_FILE)) {
GSON.toJson(config, writer);
DiscordVerifier.LOGGER.debug("Wrote new blank mod config.");
}
}
catch (Exception e) {
DiscordVerifier.LOGGER.error("Error writing blank config: {}", e.getMessage());
Expand Down

0 comments on commit bda8f1e

Please sign in to comment.