Skip to content

Commit

Permalink
fix #178
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Feb 27, 2024
1 parent ea5cec6 commit eaf265c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void reloadLang() {
File langDirectory = new File(getDataFolder() + File.separator + "lang");
Files.createDirectories(langDirectory.toPath());
for (String fileName : getDefaultLanguageFiles()) {
final String localeString = fileName.substring(fileName.lastIndexOf(File.separator) + 1, fileName.lastIndexOf('.'));
final String localeString = fileName.substring(fileName.lastIndexOf('/') + 1, fileName.lastIndexOf('.'));
logger.info("Found language file for " + localeString);
languageCacheMap.put(localeString, new LanguageCache(localeString));
}
Expand All @@ -172,7 +172,7 @@ private Set<String> getDefaultLanguageFiles() {
try (final JarFile pluginJarFile = new JarFile(this.getFile())) {
return pluginJarFile.stream()
.map(ZipEntry::getName)
.filter(name -> name.startsWith("lang" + File.separator) && name.endsWith(".yml"))
.filter(name -> name.startsWith("lang/") && name.endsWith(".yml"))
.collect(Collectors.toSet());
} catch (IOException e) {
logger.severe("Failed getting default lang files! - "+e.getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public LanguageCache(String locale) throws Exception {
File parent = langYML.getParentFile();
if (!parent.exists() && !parent.mkdir())
AnarchyExploitFixes.getLog().severe("Unable to create lang directory.");
// Check if the file already exists and save the one from the plugins resources folder if it does not
// Check if the file already exists and save the one from the plugin's resources folder if it does not
if (!langYML.exists())
plugin.saveResource("lang" + File.separator + locale + ".yml", false);
// Finally load the lang file with configmaster
plugin.saveResource("lang/" + locale + ".yml", false);
// Finally, load the lang file with configmaster
this.lang = ConfigFile.loadConfig(langYML);

// Commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private Set<String> getDefaultLanguageFiles() {
try (final JarFile pluginJarFile = new JarFile(this.getFile())) {
return pluginJarFile.stream()
.map(ZipEntry::getName)
.filter(name -> name.startsWith("lang" + File.separator) && name.endsWith(".yml"))
.filter(name -> name.startsWith("lang/") && name.endsWith(".yml"))
.collect(Collectors.toSet());
} catch (IOException e) {
logger.severe("Failed getting default lang files! - "+e.getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public LanguageCache(String locale) throws Exception {
File parent = langYML.getParentFile();
if (!parent.exists() && !parent.mkdir())
AnarchyExploitFixes.getLog().severe("Unable to create lang directory.");
// Check if the file already exists and save the one from the plugins resources folder if it does not
// Check if the file already exists and save the one from the plugin's resources folder if it does not
if (!langYML.exists())
plugin.saveResource("lang" + File.separator + locale + ".yml", false);
// Finally load the lang file with configmaster
plugin.saveResource("lang/" + locale + ".yml", false);
// Finally, load the lang file with configmaster
this.lang = ConfigFile.loadConfig(langYML);

// Commands
Expand Down

0 comments on commit eaf265c

Please sign in to comment.