Skip to content

Commit cdcc48b

Browse files
committed
Save
1 parent 8edd6f8 commit cdcc48b

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

src/main/java/the/bytecode/club/jda/FileContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void add(ClassNode classNode) {
5151
classes.put(classNode.name, classNode);
5252
}
5353

54-
public Collection<ClassNode> values() {
54+
public Collection<ClassNode> getClasses() {
5555
return classes.values();
5656
}
5757
}

src/main/java/the/bytecode/club/jda/JDA.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ public static ClassNode getCurrentlyOpenedClassNode() {
156156
}
157157

158158
public static FileContainer findContainer(String containerName, String fileName) {
159-
boolean checkContainer = !containerName.endsWith(".class");
160-
System.out.println("Loading " + containerName + "$" + fileName);
159+
boolean isClassFile = containerName.endsWith(".class");
161160
for (FileContainer container : files) {
162-
if (checkContainer && !container.name.equals(containerName))
161+
if (!isClassFile && !container.name.equals(containerName))
162+
continue;
163+
else if (isClassFile && !container.name.endsWith(".class"))
163164
continue;
164165
if (container.getData().containsKey(fileName)) {
165-
System.out.println("Found it");
166166
return container;
167167
}
168168
}
@@ -272,7 +272,7 @@ public static ArrayList<ClassNode> getLoadedClasses() {
272272
ArrayList<ClassNode> a = new ArrayList<>();
273273

274274
for (FileContainer container : files)
275-
for (ClassNode c : container.values())
275+
for (ClassNode c : container.getClasses())
276276
if (!a.contains(c))
277277
a.add(c);
278278

@@ -362,7 +362,7 @@ public void run() {
362362
}
363363
}
364364
container.files = files;
365-
JDA.files.add(container);
365+
addFile(container);
366366
} else {
367367
if (fn.endsWith(".jar") || fn.endsWith(".zip")) {
368368
try {
@@ -382,7 +382,7 @@ public void run() {
382382
FileContainer container = new FileContainer(f);
383383
container.files.put(getClassfileName(cn), bytes);
384384
container.add(cn);
385-
JDA.files.add(container);
385+
addFile(container);
386386
} else {
387387
showMessage(fn + ": Header does not start with CAFEBABE, ignoring.");
388388
update = false;
@@ -399,7 +399,7 @@ public void run() {
399399

400400
FileContainer container = new FileContainer(f);
401401
container.files = files;
402-
JDA.files.add(container);
402+
addFile(container);
403403
}
404404
}
405405
}
@@ -419,6 +419,11 @@ public void run() {
419419
t.start();
420420
}
421421

422+
public static void addFile(FileContainer fc) {
423+
JDA.files.add(fc);
424+
plugins.forEach((plugin -> plugin.onAddFile(fc)));
425+
}
426+
422427
/**
423428
* Send a message to alert the user
424429
*
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package the.bytecode.club.jda.api;
22

3+
import the.bytecode.club.jda.FileContainer;
4+
35
public interface Plugin {
46
int onGUILoad();
57

68
int onExit();
9+
10+
int onAddFile(FileContainer container);
711
}

src/main/java/the/bytecode/club/jda/decompilers/FernflowerDecompiler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public String decompileClassNode(String containerName, final ClassNode cn) {
4747
result.set(null);
4848

4949
BaseDecompiler baseDecompiler = new BaseDecompiler((externalPath, internalPath) -> {
50+
// System.out.println("boi " + externalPath + " " + internalPath);
5051
ClassNode requestedCn = JDA.getClassNode(containerName, JDA.extractProxyClassName(externalPath));
5152
if (requestedCn == null) {
5253
System.err.println("Couldn't load " + externalPath);

0 commit comments

Comments
 (0)