Skip to content

Commit 644faf3

Browse files
committed
Improved testing with local version repo. Updated FF
1 parent 8251a00 commit 644faf3

File tree

6 files changed

+44
-30
lines changed

6 files changed

+44
-30
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asm_version=9.3
2-
fernflower_version=77d9d70d5fe65425f79e630e922fcf1774d9640f
2+
fernflower_version=37b85df64bf1978cb781f44b826d0cbf3c074c85
33
rdi_version=c3b784edb637d5d53c1ba5f292a23da97f383e62
44
stitch_version=fdbe41ae758bf2501fc7addb0b78938c7f7da226
55
jansi_version=2.4.0

src/main/java/org/mcphackers/mcp/gui/TextAreaOutputStream.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ public TextAreaOutputStream(JTextArea textArea, OutputStream out) {
1313
this.textArea = textArea;
1414
}
1515

16+
@Override
17+
public void print(Object o) {
18+
textArea.append(String.valueOf(o));
19+
super.print(o);
20+
}
21+
22+
@Override
23+
public void println(Object o) {
24+
super.println(o);
25+
textArea.append("\n");
26+
textArea.setCaretPosition(textArea.getDocument().getLength());
27+
}
28+
1629
@Override
1730
public void print(String s) {
1831
textArea.append(s);

src/main/java/org/mcphackers/mcp/tasks/Task.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public abstract class Task implements ProgressListener, TaskRunnable {
1212

13-
public enum Side {
13+
public static enum Side {
1414
ANY(-1, "Any"),
1515
CLIENT(0, "Client"),
1616
SERVER(1, "Server"),

src/main/java/org/mcphackers/mcp/tasks/TaskDecompile.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.mcphackers.mcp.tools.source.Constants;
2020
import org.mcphackers.mcp.tools.source.GLConstants;
2121
import org.mcphackers.mcp.tools.source.MathConstants;
22-
import org.mcphackers.rdi.injector.Injector;
2322
import org.mcphackers.rdi.injector.RDInjector;
2423
import org.mcphackers.rdi.util.IOUtil;
2524

@@ -117,19 +116,18 @@ protected Stage[] setStages() {
117116
Files.copy(remapped, tempExcOut);
118117
for(Side sideLocal : sides) {
119118
final Path exc = MCPPaths.get(mcp, MCPPaths.EXC, sideLocal);
119+
RDInjector injector = new RDInjector(tempExcOut);
120+
injector.fixInnerClasses();
121+
injector.fixSwitchMaps();
122+
injector.fixImplicitConstructors();
123+
injector.fixBridges();
120124
if (Files.exists(exc)) {
121-
Injector injector = new RDInjector(tempExcOut)
122-
.fixInnerClasses()
123-
.fixImplicitConstructors()
124-
.fixExceptions(exc);
125-
injector.transform();
126-
IOUtil.write(injector, Files.newOutputStream(excOut), tempExcOut);
127-
Files.deleteIfExists(tempExcOut);
128-
Files.copy(excOut, tempExcOut);
129-
}
130-
else {
131-
Files.copy(tempExcOut, excOut);
125+
injector.fixExceptions(exc);
132126
}
127+
injector.transform();
128+
IOUtil.write(injector, Files.newOutputStream(excOut), tempExcOut);
129+
Files.deleteIfExists(tempExcOut);
130+
Files.copy(excOut, tempExcOut);
133131
}
134132
// Copying a fixed jar to libs
135133
if(side == Side.CLIENT || side == Side.MERGED) {

src/main/java/org/mcphackers/mcp/tasks/TaskSetup.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ public void doTask() throws Exception {
5151
mcp.setCurrentVersion(VersionsParser.setCurrentVersion(mcp, chosenVersion));
5252
String currentVersion = mcp.getCurrentVersion();
5353

54-
//TODO Better handling for local versions.json
55-
if(Files.notExists(MCPPaths.get(mcp, "versions.json"))) {
56-
setProgress("Downloading mappings", 5);
57-
FileUtil.downloadFile(VersionsParser.downloadVersion(currentVersion), MCPPaths.get(mcp, MCPPaths.CONF + "conf.zip"));
58-
FileUtil.unzip(MCPPaths.get(mcp, MCPPaths.CONF + "conf.zip"), MCPPaths.get(mcp, MCPPaths.CONF), true);
59-
}
54+
setProgress("Downloading mappings", 5);
55+
FileUtil.downloadFile(VersionsParser.downloadVersion(currentVersion), MCPPaths.get(mcp, MCPPaths.CONF + "conf.zip"));
56+
FileUtil.unzip(MCPPaths.get(mcp, MCPPaths.CONF + "conf.zip"), MCPPaths.get(mcp, MCPPaths.CONF), true);
6057

6158
Files.deleteIfExists(MCPPaths.get(mcp, MCPPaths.JAR_ORIGINAL, Side.CLIENT));
6259
Files.deleteIfExists(MCPPaths.get(mcp, MCPPaths.JAR_ORIGINAL, Side.SERVER));

src/main/java/org/mcphackers/mcp/tools/VersionsParser.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import org.mcphackers.mcp.tasks.Task.Side;
2121

2222
public abstract class VersionsParser {
23-
24-
private static final String jsonURL = "https://mcphackers.github.io/versions/versions.json";
23+
24+
private static String versionsURL = "https://mcphackers.github.io/versions/";
2525
private static Exception cause = null;
2626

2727
public static final JSONObject json = getJson();
@@ -64,13 +64,20 @@ private static void checkJson() throws Exception {
6464
private static JSONObject getJson() {
6565
try {
6666
Path jsonPath = Paths.get("versions.json");
67+
String jsonURL = versionsURL + "versions.json";
6768
if(Files.exists(jsonPath) && !Files.isDirectory(jsonPath)) {
68-
return Util.parseJSONFile(jsonPath);
69-
}
70-
else {
71-
InputStream in = new URL(jsonURL).openStream();
72-
return Util.parseJSONFile(in);
69+
JSONObject jsonSource = Util.parseJSONFile(jsonPath);
70+
if(jsonSource.has("source")) {
71+
String src = jsonSource.getString("source");
72+
if(!src.startsWith("http")) {
73+
src = "file:" + src;
74+
}
75+
versionsURL = src;
76+
jsonURL = src + "versions.json";
77+
}
7378
}
79+
InputStream in = new URL(jsonURL).openStream();
80+
return Util.parseJSONFile(in);
7481
} catch (JSONException | IOException e) {
7582
cause = e;
7683
}
@@ -92,8 +99,7 @@ public static String getServerVersion(String version) throws Exception {
9299

93100
public static boolean hasServer(String version) throws Exception {
94101
checkJson();
95-
//TODO Better null pointer handling
96-
return version == null || json.getJSONObject(version).has("server_url");
102+
return json.getJSONObject(version).has("server_url");
97103
}
98104

99105
public static String getDownloadURL(String version, Side side) throws Exception {
@@ -108,7 +114,7 @@ public static String getDownloadURL(String version, Side side) throws Exception
108114
public static URL downloadVersion(String version) throws Exception {
109115
checkJson();
110116
if(json.getJSONObject(version).has("resources")) {
111-
return new URL("https://mcphackers.github.io/versions/" + json.getJSONObject(version).getString("resources"));
117+
return new URL(versionsURL + json.getJSONObject(version).getString("resources"));
112118
}
113119
throw new JSONException("Could not get download link for mappings");
114120
}

0 commit comments

Comments
 (0)