mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-26 09:11:39 +01:00
Fixed bug with locale files being saved from BentoBox into addon locales
This commit is contained in:
parent
686b4398bc
commit
ca4db42e8d
@ -192,7 +192,6 @@ public class AddonsManager {
|
|||||||
* @param jar - the jar file
|
* @param jar - the jar file
|
||||||
* @param folderPath - the path within the jar
|
* @param folderPath - the path within the jar
|
||||||
* @return a list of files
|
* @return a list of files
|
||||||
- if the file cannot be read
|
|
||||||
*/
|
*/
|
||||||
public List<String> listJarYamlFiles(JarFile jar, String folderPath) {
|
public List<String> listJarYamlFiles(JarFile jar, String folderPath) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
@ -30,6 +30,7 @@ public class LocalesManager {
|
|||||||
|
|
||||||
public LocalesManager(BentoBox plugin) {
|
public LocalesManager(BentoBox plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
loadLocalesFromJar("BentoBox");
|
||||||
loadLocales("BentoBox"); // Default
|
loadLocales("BentoBox"); // Default
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,15 +56,7 @@ public class LocalesManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void loadLocalesFromJar(String parent) {
|
||||||
* Loads all the locales available. If the locale folder does not exist, one will be created and
|
|
||||||
* filled with locale files from the jar.
|
|
||||||
*/
|
|
||||||
public void loadLocales(String parent) {
|
|
||||||
// Describe the filter - we only want files that are correctly named
|
|
||||||
// Files must be 9 chars long
|
|
||||||
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase(java.util.Locale.ENGLISH).endsWith(".yml") && name.length() == 9;
|
|
||||||
|
|
||||||
// Run through the files and store the locales
|
// Run through the files and store the locales
|
||||||
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + parent);
|
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + parent);
|
||||||
// If the folder does not exist, then make it and fill with the locale files from the jar
|
// If the folder does not exist, then make it and fill with the locale files from the jar
|
||||||
@ -83,6 +76,19 @@ public class LocalesManager {
|
|||||||
plugin.logError("Could not copy locale files from jar " + e.getMessage());
|
plugin.logError("Could not copy locale files from jar " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all the locales available. If the locale folder does not exist, one will be created and
|
||||||
|
* filled with locale files from the jar.
|
||||||
|
*/
|
||||||
|
public void loadLocales(String parent) {
|
||||||
|
// Describe the filter - we only want files that are correctly named
|
||||||
|
// Files must be 9 chars long
|
||||||
|
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase(java.util.Locale.ENGLISH).endsWith(".yml") && name.length() == 9;
|
||||||
|
|
||||||
|
// Run through the files and store the locales
|
||||||
|
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + parent);
|
||||||
|
|
||||||
// Store all the locales available
|
// Store all the locales available
|
||||||
for (File language : Objects.requireNonNull(localeDir.listFiles(ymlFilter))) {
|
for (File language : Objects.requireNonNull(localeDir.listFiles(ymlFilter))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user