3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Merge pull request #1081 from creeper123123321/master

Use less ram on translation mappings
Dieser Commit ist enthalten in:
Myles 2018-11-12 16:45:19 +00:00 committet von GitHub
Commit 7f77cbfd74
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 1081 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -49,7 +49,8 @@ public class MappingData {
Via.getPlatform().getLogger().info("Loading sound mapping..."); Via.getPlatform().getLogger().info("Loading sound mapping...");
soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds")); soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
Via.getPlatform().getLogger().info("Loading translation mappping"); Via.getPlatform().getLogger().info("Loading translation mappping");
translateMapping = GsonUtil.getGson().fromJson( translateMapping = new HashMap<>();
Map<String, String> translateData = GsonUtil.getGson().fromJson(
new InputStreamReader( new InputStreamReader(
MappingData.class.getClassLoader() MappingData.class.getClassLoader()
.getResourceAsStream("assets/viaversion/data/mapping-lang-1.12-1.13.json") .getResourceAsStream("assets/viaversion/data/mapping-lang-1.12-1.13.json")
@ -65,8 +66,15 @@ public class MappingData {
if (line.isEmpty()) continue; if (line.isEmpty()) continue;
String[] keyAndTranslation = line.split("=", 2); String[] keyAndTranslation = line.split("=", 2);
if (keyAndTranslation.length != 2) continue; if (keyAndTranslation.length != 2) continue;
if (!translateMapping.containsKey(keyAndTranslation[0])) { String key = keyAndTranslation[0];
translateMapping.put(keyAndTranslation[0], keyAndTranslation[1]); String translation = keyAndTranslation[1];
if (!translateData.containsKey(key)) {
translateMapping.put(key, translation);
} else {
String dataValue = translateData.get(keyAndTranslation[0]);
if (dataValue != null) {
translateMapping.put(key, dataValue);
}
} }
} }
} catch (IOException e) { } catch (IOException e) {