3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00

Move loadFullMappings to MappingDataBase, use loadMiMappings

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-05-05 14:41:30 +02:00
Ursprung fc9d5b6d9d
Commit f1b92fea8d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
2 geänderte Dateien mit 13 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -132,8 +132,19 @@ public class MappingDataBase implements MappingData {
return MappingDataLoader.INSTANCE.loadMappings(data, key);
}
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
return MappingDataLoader.INSTANCE.loadFullMappings(data, unmappedIdentifiers, mappedIdentifiers, key);
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
return null;
}
final List<String> unmappedIdentifiers = identifiersFromGlobalIds(unmappedIdentifiersTag, key);
final List<String> mappedIdentifiers = identifiersFromGlobalIds(mappedIdentifiersTag, key);
Mappings mappings = loadBiMappings(data, key); // Load as bi-mappings to keep the inverse cached
if (mappings == null) {
mappings = new IdentityMappings(unmappedIdentifiers.size(), mappedIdentifiers.size());
}
return new FullMappingsBase(unmappedIdentifiers, mappedIdentifiers, mappings);
}
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {

Datei anzeigen

@ -53,7 +53,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MappingDataLoader {
@ -276,21 +275,6 @@ public class MappingDataLoader {
return mappingsSupplier.create(mappings, mappedSizeTag.asInt());
}
public FullMappings loadFullMappings(final CompoundTag mappingsTag, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
return null;
}
final List<String> unmappedIdentifiers = identifiersFromGlobalIds(unmappedIdentifiersTag, key);
final List<String> mappedIdentifiers = identifiersFromGlobalIds(mappedIdentifiersTag, key);
Mappings mappings = loadMappings(mappingsTag, key);
if (mappings == null) {
mappings = new IdentityMappings(unmappedIdentifiers.size(), mappedIdentifiers.size());
}
return new FullMappingsBase(unmappedIdentifiers, mappedIdentifiers, mappings);
}
public @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
final Mappings mappings = loadMappings(mappingsTag, key);
if (mappings == null) {