Skip to content

Commit

Permalink
Fixed issues with updating config
Browse files Browse the repository at this point in the history
  • Loading branch information
Picono435 committed Aug 22, 2020
1 parent d8089c1 commit dc44a82
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void onEnable() {
getConfig().options().copyDefaults(true);
getConfig().set("config-version", getDescription().getVersion());
saveConfig();
LanguageManager.updateFile();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,25 @@ public static void createLanguageFile() {
e.printStackTrace();
}
}

public static void updateFile() {
String lang = PicoJobsAPI.getSettingsManager().getLanguage();
File old = new File(PicoJobsPlugin.getPlugin().getDataFolder(), "langs" + File.separatorChar + lang + "_old.yml");
language_file.renameTo(old);
File f = new File(PicoJobsPlugin.getPlugin().getDataFolder(), "langs" + File.separatorChar + lang + ".yml");
PicoJobsPlugin.getPlugin().saveResource("langs" + File.separatorChar + lang + ".yml", false);
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(f);
f.delete();
old.delete();

language.setDefaults(fileConfiguration);

language.options().copyDefaults(true);

try {
language.save(language_file);
} catch (IOException e) {
e.printStackTrace();
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/langs/en-GB.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is a language file, here you can change all the messages for this language
# Remember that some messages may not be used because they are PREMIUM ONLY
# Placeholders only work with PlaceholderAPI, for more information see the comment down here.
#
# NOTE:
# In order to use any placeholder [ex: %jobplayer_job%, %player_name%] you will need to install the
Expand Down

0 comments on commit dc44a82

Please sign in to comment.