Fixes reload bug when locale folder is missing.

https://github.com/BentoBoxWorld/bentobox/issues/385
This commit is contained in:
tastybento 2018-12-15 23:38:20 -08:00
parent 3b87ff7aae
commit b556b7160e
2 changed files with 8 additions and 6 deletions

View File

@ -27,11 +27,12 @@ public class LocalesManager {
private BentoBox plugin;
private Map<Locale, BentoBoxLocale> languages = new HashMap<>();
private static final String LOCALE_FOLDER = "locales";
private static final String BENTOBOX = "BentoBox";
public LocalesManager(BentoBox plugin) {
this.plugin = plugin;
copyLocalesFromJar(plugin.getName());
loadLocalesFromFile(plugin.getName()); // Default
copyLocalesFromJar(BENTOBOX);
loadLocalesFromFile(BENTOBOX); // Default
}
/**
@ -95,10 +96,10 @@ public class LocalesManager {
}
}
}
/**
* Loads all the locales available in the locale folder given. Used for loading all locales from plugin and addons
*
*
* @param localeFolder - locale folder location relative to the plugin's data folder
*/
public void loadLocalesFromFile(String localeFolder) {
@ -164,12 +165,13 @@ public class LocalesManager {
public Map<Locale, BentoBoxLocale> getLanguages() {
return this.languages;
}
/**
* Reloads all the language files from the filesystem
*/
public void reloadLanguages() {
languages.clear();
copyLocalesFromJar(plugin.getName());
loadLocalesFromFile(plugin.getName());
plugin.getAddonsManager().getAddons().forEach(addon -> loadLocalesFromFile(addon.getDescription().getName()));
}

View File

@ -64,7 +64,7 @@ import world.bentobox.bentobox.util.Util;
@PrepareForTest( { Bukkit.class, BentoBox.class, Util.class, Location.class })
public class IslandsManagerTest {
private static BentoBox plugin;
private BentoBox plugin;
private UUID uuid;
private User user;
private PlayersManager pm;