diff options
author | Jonas Herzig <me@johni0702.de> | 2019-06-17 17:20:04 +0200 |
---|---|---|
committer | Jonas Herzig <me@johni0702.de> | 2019-06-23 14:40:25 +0200 |
commit | 14c120609607cd9f74cfd411cfae80017ea4c4ab (patch) | |
tree | a857151fcd1a3c8a34ec2fec0cd157644647ee7c /src/main/java/com/replaymod/gradle/remap/legacy/LegacyMappingsReader.java | |
parent | 18a9a9d7b048e11981d2e3bf47af17e024e0ebef (diff) | |
download | Remap-14c120609607cd9f74cfd411cfae80017ea4c4ab.tar.gz Remap-14c120609607cd9f74cfd411cfae80017ea4c4ab.tar.bz2 Remap-14c120609607cd9f74cfd411cfae80017ea4c4ab.zip |
Use lorenz library for proper Mapping model
Diffstat (limited to 'src/main/java/com/replaymod/gradle/remap/legacy/LegacyMappingsReader.java')
-rw-r--r-- | src/main/java/com/replaymod/gradle/remap/legacy/LegacyMappingsReader.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/com/replaymod/gradle/remap/legacy/LegacyMappingsReader.java b/src/main/java/com/replaymod/gradle/remap/legacy/LegacyMappingsReader.java new file mode 100644 index 0000000..502f7ba --- /dev/null +++ b/src/main/java/com/replaymod/gradle/remap/legacy/LegacyMappingsReader.java @@ -0,0 +1,44 @@ +package com.replaymod.gradle.remap.legacy; + +import org.cadixdev.lorenz.MappingSet; +import org.cadixdev.lorenz.io.MappingsReader; +import org.cadixdev.lorenz.model.ClassMapping; + +import java.util.Map; + +public class LegacyMappingsReader extends MappingsReader { + private final Map<String, LegacyMapping> map; + + public LegacyMappingsReader(Map<String, LegacyMapping> map) { + this.map = map; + } + + @Override + public MappingSet read() { + return read(MappingSet.create(new LegacyMappingSetModelFactory())); + } + + @Override + public MappingSet read(MappingSet mappings) { + if (!(mappings.getModelFactory() instanceof LegacyMappingSetModelFactory)) { + throw new IllegalArgumentException("legacy mappings must use legacy model factory, use read() instead"); + } + for (LegacyMapping legacyMapping : map.values()) { + ClassMapping classMapping = mappings.getOrCreateClassMapping(legacyMapping.oldName) + .setDeobfuscatedName(legacyMapping.newName); + for (Map.Entry<String, String> entry : legacyMapping.fields.entrySet()) { + classMapping.getOrCreateFieldMapping(entry.getKey()) + .setDeobfuscatedName(entry.getValue()); + } + for (Map.Entry<String, String> entry : legacyMapping.methods.entrySet()) { + classMapping.getOrCreateMethodMapping(entry.getKey(), "()V") + .setDeobfuscatedName(entry.getValue()); + } + } + return mappings; + } + + @Override + public void close() { + } +} |