Fix and improve loading of lang files, fixes #121. Bump version number

This commit is contained in:
HappyPikachu 2017-12-05 21:28:12 -05:00
parent 1b2eb65a10
commit c600e3e8d2
3 changed files with 9 additions and 22 deletions

View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>3.0.9</version>
<version>3.1.0</version>
<name>quests</name>
<url>https://github.com/FlyingPikachu/Quests/</url>
<packaging>jar</packaging>

View File

@ -131,7 +131,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public boolean load = false;
public int killDelay = 0;
public int totalQuestPoints = 0;
public Lang lang;
public Lang lang = new Lang(this);
public HashMap<String, Integer> commands = new HashMap<String, Integer>();
public HashMap<String, Integer> adminCommands = new HashMap<String, Integer>();
private static Quests instance = null;
@ -161,15 +161,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
saveResource("events.yml", false);
saveResource("data.yml", false);
// Save/load lang
defaultLangFile();
// Load files
loadConfig();
loadModules();
loadData();
loadCommands();
// Save/load lang
defaultLangFile();
// Save config with any new options
getConfig().options().copyDefaults(true);
saveConfig();
@ -182,7 +182,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
private void defaultLangFile() {
lang = new Lang(this);
lang.initPhrases();
if (new File(this.getDataFolder(), File.separator + "lang" + File.separator + "en.yml").exists() == false) {
getLogger().info("Translation data not found, writing defaults to file.");
@ -398,23 +397,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
killDelay = config.getInt("kill-delay", 600);
acceptTimeout = config.getInt("accept-timeout", 20);
convertData = config.getBoolean("convert-data-on-startup", false);
if (config.contains("language")) {
Lang.lang = config.getString("language");
} else {
config.set("language", "en");
}
if (config.contains("ignore-locked-quests")) {
ignoreLockedQuests = config.getBoolean("ignore-locked-quests");
} else {
config.set("ignore-locked-quests", false);
}
if (config.contains("max-quests")) {
maxQuests = config.getInt("max-quests");
} else {
config.set("max-quests", maxQuests);
}
ignoreLockedQuests = config.getBoolean("ignore-locked-quests", false);
maxQuests = config.getInt("max-quests", maxQuests);
for (String s : config.getStringList("quester-blacklist")) {
if (!s.equals("UUID")) {
if (!s.equalsIgnoreCase("UUID")) {
questerBlacklist.add(s);
}
}

View File

@ -992,6 +992,7 @@ public class Lang {
}
public void loadLang() {
System.out.println("lang reads = " + lang);
File langFile = new File(plugin.getDataFolder(), File.separator + "lang" + File.separator + lang + ".yml");
boolean newLangs = false;
if (langFile.exists()) {