mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2025-01-02 18:28:33 +01:00
Sort language map using stream API instead of guava
This commit is contained in:
parent
62b70303c4
commit
9e85832a9f
@ -17,9 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.viaproxy.ui;
|
package net.raphimc.viaproxy.ui;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import net.raphimc.viabedrock.api.util.FileSystemUtil;
|
import net.raphimc.viabedrock.api.util.FileSystemUtil;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
|
|
||||||
@ -28,6 +25,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class I18n {
|
public class I18n {
|
||||||
|
|
||||||
@ -49,7 +47,9 @@ public class I18n {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new RuntimeException("Failed to load translations", e);
|
throw new RuntimeException("Failed to load translations", e);
|
||||||
}
|
}
|
||||||
LOCALES = ImmutableSortedMap.copyOf(LOCALES, Ordering.from(Comparator.comparing((Properties p) -> p.getProperty("language.name"))).onResultOf(Functions.forMap(LOCALES)));
|
LOCALES = LOCALES.entrySet().stream()
|
||||||
|
.sorted(Comparator.comparing(e -> e.getValue().getProperty("language.name")))
|
||||||
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> newValue, LinkedHashMap::new));
|
||||||
|
|
||||||
currentLocale = ViaProxy.getSaveManager().uiSave.get("locale");
|
currentLocale = ViaProxy.getSaveManager().uiSave.get("locale");
|
||||||
if (currentLocale == null || !LOCALES.containsKey(currentLocale)) {
|
if (currentLocale == null || !LOCALES.containsKey(currentLocale)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user