no need to rewrite language file. fix #206

This commit is contained in:
DNx5 2015-09-15 00:02:52 +07:00
parent e9cf5de663
commit 7add63869e
2 changed files with 1 additions and 50 deletions

View File

@ -17,7 +17,6 @@ public class CustomConfiguration extends YamlConfiguration {
public CustomConfiguration(File file) { public CustomConfiguration(File file) {
this.configFile = file; this.configFile = file;
load(); load();
} }

View File

@ -13,59 +13,11 @@ public class Messages extends CustomConfiguration {
public Messages(File file, String lang) { public Messages(File file, String lang) {
super(file); super(file);
loadDefaults(file); load();
loadFile();
saveDefaults(file);
singleton = this; singleton = this;
this.lang = lang; this.lang = lang;
} }
/**
* Loads a file from the plugin jar and sets as default
*
* @param file The filename to open
*/
public final void loadDefaults(File file) {
if (file.isFile()) {
setDefaults(YamlConfiguration.loadConfiguration(file));
}
}
/**
* Saves the configuration to disk
*
* @return True if saved successfully
*/
public final boolean saved(File file) {
try {
save(file);
return true;
} catch (Exception ex) {
return false;
}
}
/**
* Saves current configuration (plus defaults) to disk.
* <p>
* If defaults and configuration are empty, saves blank file.
*
* @return True if saved successfully
*/
public final boolean saveDefaults(File file) {
options().copyDefaults(true);
options().copyHeader(true);
boolean success = saved(file);
options().copyDefaults(false);
options().copyHeader(false);
return success;
}
private void loadFile() {
load();
save();
}
public void send(CommandSender sender, String msg) { public void send(CommandSender sender, String msg) {
if (!Settings.messagesLanguage.equalsIgnoreCase(singleton.lang)) if (!Settings.messagesLanguage.equalsIgnoreCase(singleton.lang))
singleton.reloadMessages(); singleton.reloadMessages();