Skip to content

Commit d3be70e

Browse files
committed
Added generics guessing. Added Override annotations
1 parent 9b90b09 commit d3be70e

9 files changed

Lines changed: 46 additions & 25 deletions

File tree

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
asm_version=9.3
2-
fernflower_version=37b85df64bf1978cb781f44b826d0cbf3c074c85
3-
rdi_version=8a502c57b5e0a01bdb6f674c77c34a02ce147e38
2+
fernflower_version=5284b9c31e4a12a27e24b5161c4265406707e007
3+
rdi_version=841042981cb63f7be38a964487550d92dc01ac20
44
stitch_version=fdbe41ae758bf2501fc7addb0b78938c7f7da226
55
jansi_version=2.4.0
66
tr_version=0.8.4

src/main/java/org/mcphackers/mcp/Options.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public void setDefault(TaskParameter param) {
8888
case FULL_BUILD:
8989
case RUN_BUILD:
9090
case OBFUSCATION:
91+
case DECOMPILE_OVERRIDE:
9192
value = false;
9293
break;
9394
case PATCHES:
@@ -96,7 +97,7 @@ public void setDefault(TaskParameter param) {
9697
case IGNORED_PACKAGES:
9798
value = new String[] {"paulscode", "com/jcraft", "de/jarnbjo", "isom"};
9899
break;
99-
case INDENTION_STRING:
100+
case INDENTATION_STRING:
100101
value = "\t";
101102
break;
102103
case RUN_ARGS:

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ else if(task == TaskMode.UPDATE_MD5) {
125125

126126
topRightContainer = new JPanel(new FlowLayout(FlowLayout.RIGHT));
127127
reloadVersionList();
128-
updateButtonState();
128+
//updateButtonState();
129129

130130
JPanel topContainer = new JPanel(new BorderLayout());
131131

@@ -159,10 +159,15 @@ else if(task == TaskMode.UPDATE_MD5) {
159159
}
160160

161161
public void reloadVersionList() {
162+
163+
this.verLabel = new JLabel("Current version:");
164+
this.verList = new JComboBox<>(new String[] {"Loading..."});
165+
topRightContainer.removeAll();
166+
topRightContainer.add(this.verLabel);
167+
topRightContainer.add(this.verList);
168+
operateOnThread(() -> {
162169
try {
163-
topRightContainer.removeAll();
164-
JFrame frame = this;
165-
170+
setAllButtonsInactive();
166171
this.verList = new JComboBox<>(VersionsParser.getVersionList().toArray(new String[0]));
167172
this.verList.addPopupMenuListener(new PopupMenuListener() {
168173

@@ -174,7 +179,7 @@ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
174179
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
175180
operateOnThread(() -> {
176181
if (verList.getSelectedItem() != null && !verList.getSelectedItem().equals(mcp.getCurrentVersion())) {
177-
int response = JOptionPane.showConfirmDialog(frame, "Are you sure you want to run setup for selected version?", "Confirm Action", JOptionPane.YES_NO_OPTION);
182+
int response = JOptionPane.showConfirmDialog(MCPFrame.this, "Are you sure you want to run setup for selected version?", "Confirm Action", JOptionPane.YES_NO_OPTION);
178183
switch (response) {
179184
case 0:
180185
mcp.setParameter(TaskParameter.SETUP_VERSION, verList.getSelectedItem());
@@ -201,14 +206,18 @@ public void popupMenuCanceled(PopupMenuEvent e) {
201206
}
202207
this.verList.setMaximumRowCount(20);
203208
this.verLabel = new JLabel("Current version:");
209+
topRightContainer.removeAll();
204210
topRightContainer.add(this.verLabel);
205211
topRightContainer.add(this.verList);
206212
} catch (Exception e) {
207213
verLabel = new JLabel("Unable to get version list!");
208214
verLabel.setForeground(Color.RED);
215+
topRightContainer.removeAll();
209216
topRightContainer.add(verLabel);
210217
}
218+
updateButtonState();
211219
topRightContainer.updateUI();
220+
});
212221
}
213222

214223
public void updateButtonState() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private void initOptions() {
164164
"Running"
165165
};
166166
TaskParameter[][] params = {
167-
{TaskParameter.PATCHES, TaskParameter.INDENTION_STRING, TaskParameter.IGNORED_PACKAGES},
167+
{TaskParameter.PATCHES, TaskParameter.DECOMPILE_OVERRIDE, TaskParameter.INDENTATION_STRING, TaskParameter.IGNORED_PACKAGES},
168168
{TaskParameter.SOURCE_VERSION, TaskParameter.TARGET_VERSION, TaskParameter.JAVA_HOME},
169169
{TaskParameter.OBFUSCATION},
170170
{TaskParameter.FULL_BUILD},

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ protected Stage[] setStages() {
141141
//TODO Apply both javadocs if side == Side.MERGED
142142
//FIXME Javadocs
143143
final Path deobfMappings = MCPPaths.get(mcp, MCPPaths.MAPPINGS_DO, side == Side.MERGED ? Side.CLIENT : side);
144-
new Decompiler(this, excOut, srcZip, deobfMappings, mcp.getOptions().getStringParameter(TaskParameter.INDENTION_STRING)).decompile();
144+
new Decompiler(this, excOut, srcZip, deobfMappings,
145+
mcp.getOptions().getStringParameter(TaskParameter.INDENTATION_STRING),
146+
mcp.getOptions().getBooleanParameter(TaskParameter.DECOMPILE_OVERRIDE))
147+
.decompile();
145148
}),
146149
stage("Extracting sources", 84,
147150
() -> {

src/main/java/org/mcphackers/mcp/tasks/mode/TaskMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class TaskMode {
4242
TaskParameter.TARGET_VERSION,
4343
TaskParameter.JAVA_HOME,
4444
TaskParameter.IGNORED_PACKAGES,
45-
TaskParameter.INDENTION_STRING,
45+
TaskParameter.INDENTATION_STRING,
4646
TaskParameter.PATCHES,
4747
TaskParameter.SIDE
4848
})

src/main/java/org/mcphackers/mcp/tasks/mode/TaskParameter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ public enum TaskParameter {
77
SRC_CLEANUP("src", "Source cleanup", Boolean.class),
88
PATCHES("patch", "Apply patches", Boolean.class),
99
IGNORED_PACKAGES("ignore", "Set ignored packages", String[].class),
10-
INDENTION_STRING("ind", "Set indention string", String.class),
10+
INDENTATION_STRING("ind", "Set indentation string", String.class),
1111
OBFUSCATION("obf", "Obfuscation", Boolean.class),
1212
FULL_BUILD("fullbuild", "Full build", Boolean.class),
1313
RUN_BUILD("runbuild", "Run build", Boolean.class),
1414
RUN_ARGS("runargs", "Run arguments", String[].class),
1515
SETUP_VERSION("setup", "Setup version", String.class),
1616
SOURCE_VERSION("source", "Set a specific source version", Integer.class),
1717
TARGET_VERSION("target", "Set a specific target version", Integer.class),
18-
JAVA_HOME("javahome", "Set JAVA_HOME used for compiling", String.class);
18+
JAVA_HOME("javahome", "Set JAVA_HOME used for compiling", String.class),
19+
DECOMPILE_OVERRIDE("override", "Decompile @Override", Boolean.class);
1920

2021
public final String desc;
2122
public final String name;

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
package org.mcphackers.mcp.tools;
22

3-
import org.json.JSONArray;
4-
import org.json.JSONException;
5-
import org.json.JSONObject;
6-
73
import java.awt.Desktop;
84
import java.awt.Toolkit;
95
import java.awt.datatransfer.StringSelection;
10-
import java.io.*;
6+
import java.io.BufferedInputStream;
7+
import java.io.BufferedReader;
8+
import java.io.ByteArrayOutputStream;
9+
import java.io.File;
10+
import java.io.IOException;
11+
import java.io.InputStream;
12+
import java.io.InputStreamReader;
1113
import java.net.URI;
1214
import java.net.URISyntaxException;
13-
import java.nio.file.*;
15+
import java.nio.file.Files;
16+
import java.nio.file.Path;
1417
import java.security.MessageDigest;
1518
import java.security.NoSuchAlgorithmException;
1619
import java.util.ArrayList;
1720
import java.util.HashMap;
1821
import java.util.Iterator;
1922
import java.util.List;
2023
import java.util.Map;
21-
import java.util.Scanner;
2224
import java.util.concurrent.TimeUnit;
2325

26+
import org.json.JSONArray;
27+
import org.json.JSONException;
28+
import org.json.JSONObject;
29+
2430
public abstract class Util {
2531

2632
public static int runCommand(String[] cmd, Path dir, boolean killOnShutdown) throws IOException {
@@ -33,11 +39,11 @@ public static int runCommand(String[] cmd, Path dir, boolean killOnShutdown) thr
3339
if(killOnShutdown) {
3440
Runtime.getRuntime().addShutdownHook(hook);
3541
}
36-
Scanner err = new Scanner(proc.getErrorStream());
37-
Scanner in = new Scanner(proc.getInputStream());
42+
BufferedReader err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
43+
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
3844
while(proc.isAlive()) {
39-
if(in.hasNextLine()) System.out.println(in.nextLine());
40-
if(err.hasNextLine()) System.err.println(err.nextLine());
45+
while(in.ready()) System.out.println(in.readLine());
46+
while(err.ready()) System.err.println(err.readLine());
4147
}
4248
in.close();
4349
err.close();

src/main/java/org/mcphackers/mcp/tools/fernflower/Decompiler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ public class Decompiler implements IBytecodeProvider, IResultSaver {
3434
private Map<String, ZipOutputStream> mapArchiveStreams = new HashMap<String, ZipOutputStream>();
3535
private Map<String, Set<String>> mapArchiveEntries = new HashMap<String, Set<String>>();
3636

37-
public Decompiler(ProgressListener listener, Path source, Path out, Path javadocs, String ind) {
37+
public Decompiler(ProgressListener listener, Path source, Path out, Path javadocs, String ind, boolean override) {
3838
this.source = source;
3939
this.destination = out;
4040
this.log = new DecompileLogger(listener);
41+
mapOptions.put(IFernflowerPreferences.OVERRIDE_ANNOTATION, override ? "1" : "0");
4142
mapOptions.put(IFernflowerPreferences.NO_COMMENT_OUTPUT, "1");
4243
mapOptions.put(IFernflowerPreferences.REMOVE_BRIDGE, "0");
4344
mapOptions.put(IFernflowerPreferences.ASCII_STRING_CHARACTERS, "1");

0 commit comments

Comments
 (0)