feat: update some code with Java 21 newest methods

This commit is contained in:
ineanto 2024-05-16 21:15:26 +02:00
parent eb23580bc4
commit 81b1c8275f
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
3 changed files with 4 additions and 4 deletions

View file

@ -27,7 +27,7 @@ public class RandomNameFetcher {
final String[] values = line.split("\n"); final String[] values = line.split("\n");
records.add(Arrays.asList(values)); records.add(Arrays.asList(values));
} }
return records.get(new Random().nextInt(records.size() - 1)).get(0); return records.get(new Random().nextInt(records.size() - 1)).getFirst();
} catch (IOException e) { } catch (IOException e) {
instance.getLogger().severe("Unable to fetch random names."); instance.getLogger().severe("Unable to fetch random names.");
return "Ineanto"; return "Ineanto";

View file

@ -106,10 +106,10 @@ public class I18N {
return new Translation(null, toTranslate); return new Translation(null, toTranslate);
} else if (name != null && (lore == null || lore.isEmpty())) { } else if (name != null && (lore == null || lore.isEmpty())) {
// Valid name, empty lore // Valid name, empty lore
return new Translation(toTranslate.get(0), new ArrayList<>(Collections.emptyList())); return new Translation(toTranslate.getFirst(), new ArrayList<>(Collections.emptyList()));
} else { } else {
// Valid name, valid lore // Valid name, valid lore
return new Translation(toTranslate.get(0), new ArrayList<>(toTranslate.subList(1, toTranslate.size()))); return new Translation(toTranslate.getFirst(), new ArrayList<>(toTranslate.subList(1, toTranslate.size())));
} }
} }

View file

@ -34,7 +34,7 @@ public class CustomLocaleMigrator implements Migrator {
try { try {
Files.copy(customLocale.getFile().toPath(), backupFile.toPath()); Files.copy(customLocale.getFile().toPath(), backupFile.toPath());
if (customLocale.getFile().delete()) { if (customLocale.getFile().delete()) {
customLocale.dumpIntoFile(Locale.ENGLISH); CustomLocale.dumpIntoFile(Locale.ENGLISH);
} }
instance.getLogger().info("Successfully migrated the custom locale."); instance.getLogger().info("Successfully migrated the custom locale.");
} catch (IOException e) { } catch (IOException e) {