Skip to content

Commit

Permalink
- Replace usage of deprecated IOUtils method.
Browse files Browse the repository at this point in the history
  • Loading branch information
LlmDl committed Feb 23, 2024
1 parent e2cb09d commit e9c134a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Towny/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<artifactId>towny</artifactId>
<packaging>jar</packaging>
<version>0.100.1.16</version>
<version>0.100.1.17</version>

<licenses>
<license>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3601,6 +3601,7 @@ public static boolean isLanguageEnabled(@NotNull String locale) {
// have english translations and/or are missing a translation for the enabled
// language(s) on this server need to be able to inject their english
// tranlations.
locale = locale.replace("-", "_");
if (getString(ConfigNodes.ENABLED_LANGUAGES).equals("*") || locale.equalsIgnoreCase("en_us"))
return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ private Set<String> getLangFileNamesFromPlugin() {
uri = clazz.getResource("").toURI();

try (final FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap()); Stream<Path> stream = Files.list(fs.getRootDirectories().iterator().next().resolve("/lang"))) {
stream.filter(p -> TownySettings.isLanguageEnabled(FileNameUtils.getBaseName(p.toString().replace("-", "_"))))
.forEach(p -> lang.add(FileNameUtils.getBaseName(p.toString())));
stream.filter(p -> TownySettings.isLanguageEnabled(FileNameUtils.getBaseName(p)))
.forEach(p -> lang.add(FileNameUtils.getBaseName(p)));
}
} catch (URISyntaxException | IOException e) {
plugin.getLogger().log(Level.WARNING, "An exception occurred while getting language file names from the plugin jar", e);
Expand Down Expand Up @@ -247,11 +247,11 @@ void loadOverrideFiles() {
File[] overrideFiles = new File(langFolderPath + File.separator + "override").listFiles();
if (overrideFiles != null) {
for (File file : overrideFiles) {
if (file.isFile() && FileNameUtils.getExtension(file.getName()).equalsIgnoreCase("yml")
&& !file.getName().equalsIgnoreCase("global.yml") && TownySettings.isLanguageEnabled(FileNameUtils.getBaseName(file.getName()).replaceAll("-", "_"))) {
if (file.isFile() && FileNameUtils.getExtension(file.toPath()).equalsIgnoreCase("yml")
&& !file.getName().equalsIgnoreCase("global.yml") && TownySettings.isLanguageEnabled(FileNameUtils.getBaseName(file.toPath()))) {
try (FileInputStream is = new FileInputStream(file)) {
Map<String, Object> values = new Yaml(new SafeConstructor(new LoaderOptions())).load(is);
String lang = FileNameUtils.getBaseName(file.getName()).replaceAll("-", "_");
String lang = FileNameUtils.getBaseName(file.toPath()).replaceAll("-", "_");

if (values != null) {
newTranslations.computeIfAbsent(lang, k -> new HashMap<>());
Expand Down
4 changes: 3 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9557,4 +9557,6 @@ v0.92.0.11:
- Futureproof falling block checking, courtesy of Warrior with PR #7273.
- Add list metadata type, courtesy of Warrior with PR #7274.
- Remove locale message on first join, courtesy of Warrior with PR #7276.
- Skip copying light data for our chunk snapshots, courtesy of Warrior with PR #7281.
- Skip copying light data for our chunk snapshots, courtesy of Warrior with PR #7281.
0.100.1.17:
- Replace usage of deprecated IOUtils method.

0 comments on commit e9c134a

Please # to comment.