Skip to content

Commit

Permalink
only load defaults if lang folder doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Dec 31, 2024
1 parent 1e5eb10 commit 565d23e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,9 @@ public void reloadLang() {

private @NotNull List<String> getAvailableTranslations() {
try (final JarFile pluginJar = new JarFile(getFile())) {
Files.createDirectories(new File(getDataFolder(), "/lang").toPath());
final Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
final File[] langDirFiles = new File(getDataFolder() + "/lang").listFiles();
return Stream.concat(pluginJar.stream().map(ZipEntry::getName), Arrays.stream(langDirFiles).map(File::getName))
final File langFolder = new File(getDataFolder(), "/lang");
return (langFolder.exists() ? Arrays.stream(langFolder.listFiles()).map(File::getName) : pluginJar.stream().map(ZipEntry::getName))
.map(langPattern::matcher)
.filter(Matcher::find)
.map(matcher -> matcher.group(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,9 @@ public void reloadLang() {

private @NotNull List<String> getAvailableTranslations() {
try (final JarFile pluginJar = new JarFile(getFile())) {
Files.createDirectories(new File(getDataFolder(), "/lang").toPath());
final Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
final File[] langDirFiles = new File(getDataFolder() + "/lang").listFiles();
return Stream.concat(pluginJar.stream().map(ZipEntry::getName), Arrays.stream(langDirFiles).map(File::getName))
final File langFolder = new File(getDataFolder(), "/lang");
return (langFolder.exists() ? Arrays.stream(langFolder.listFiles()).map(File::getName) : pluginJar.stream().map(ZipEntry::getName))
.map(langPattern::matcher)
.filter(Matcher::find)
.map(matcher -> matcher.group(1))
Expand Down

0 comments on commit 565d23e

Please sign in to comment.