JsonObf.java
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.mumfrey.liteloader.transformers.event.json;
import java.io.Serializable;
import java.util.UUID;
import com.google.gson.annotations.SerializedName;
import com.mumfrey.liteloader.core.runtime.Obf;
public class JsonObf implements Serializable
{
private static final long serialVersionUID = 1L;
@SerializedName("id")
private String key;
@SerializedName("mcp")
private String mcp;
@SerializedName("srg")
private String srg;
@SerializedName("obf")
private String obf;
public String getKey()
{
if (this.key == null)
{
this.key = "UserObfuscationMapping" + UUID.randomUUID().toString();
}
return this.key;
}
public Obf parse()
{
String seargeName = this.getFirstValidEntry(this.srg, this.mcp, this.obf, this.getKey());
String obfName = this.getFirstValidEntry(this.obf, this.srg, this.mcp, this.getKey());
String mcpName = this.getFirstValidEntry(this.mcp, this.srg, this.obf, this.getKey());
return new Mapping(seargeName, obfName, mcpName);
}
private String getFirstValidEntry(String... entries)
{
for (String entry : entries)
{
if (entry != null) return entry;
}
throw new InvalidEventJsonException("No valid entry found in list!");
}
public static class Mapping extends Obf
{
protected Mapping(String seargeName, String obfName, String mcpName)
{
super(seargeName, obfName, mcpName);
}
}
}