mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-25 11:04:23 +00:00
This commit is contained in:
1 parent
2c9e3d1d39
commit
5afccbd4dd
15 files changed
+382
-85
No files matched your search
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* This file is part of Mixin, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.obfuscation;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import joptsimple.internal.Strings;
|
||||
|
||||
/**
|
||||
* Ported from <strong>Srg2Source</strong> (
|
||||
* <a href=\"https://github.com/MinecraftForge/Srg2Source\">
|
||||
* github.com/MinecraftForge/Srg2Source</a>).
|
||||
*/
|
||||
public class SrgContainer {
|
||||
|
||||
private final BiMap<String, String> classMap = HashBiMap.create();
|
||||
private final BiMap<String, String> fieldMap = HashBiMap.create();
|
||||
private final BiMap<String, String> packageMap = HashBiMap.create();
|
||||
private final BiMap<MethodData, MethodData> methodMap = HashBiMap.create();
|
||||
|
||||
public void readSrg(File srg) throws IOException {
|
||||
for (String line : Files.readLines(srg, Charset.defaultCharset())) {
|
||||
if (Strings.isNullOrEmpty(line) || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String type = line.substring(0, 2);
|
||||
String[] args = line.substring(4).split(" ");
|
||||
|
||||
if (type.equals("PK")) {
|
||||
this.packageMap.forcePut(args[0], args[1]);
|
||||
} else if (type.equals("CL")) {
|
||||
this.classMap.forcePut(args[0], args[1]);
|
||||
} else if (type.equals("FD")) {
|
||||
this.fieldMap.forcePut(args[0], args[1]);
|
||||
} else if (type.equals("MD")) {
|
||||
this.methodMap.forcePut(new MethodData(args[0], args[1]), new MethodData(args[2], args[3]));
|
||||
} else {
|
||||
throw new RuntimeException("Invalid SRG file: " + srg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MethodData getMethodMapping(MethodData methodName) {
|
||||
return this.methodMap.get(methodName);
|
||||
}
|
||||
|
||||
public String getFieldMapping(String fieldName) {
|
||||
return this.fieldMap.get(fieldName);
|
||||
}
|
||||
|
||||
public String getClassMapping(String className) {
|
||||
return this.classMap.get(className);
|
||||
}
|
||||
|
||||
public String getPackageMapping(String packageName) {
|
||||
return this.packageMap.get(packageName);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user