Skip to content

Commit fc68fde

Browse files
committed
Better Plugin Handling
This isn't a perfect solution since it will create a new console window for each resource, however it maintains compatibility and makes it easy on plugin authors A new plugin class would be a good idea for a better alternative, then more advanced plugins could use that as the class base instead of just the.bytecode.club.bytecodeviewer.api.Plugin
1 parent 9f1877a commit fc68fde

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

  • src/main/java/the/bytecode/club/bytecodeviewer/api

‎src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package the.bytecode.club.bytecodeviewer.api;
22

33
import java.util.ArrayList;
4+
import java.util.List;
5+
46
import org.objectweb.asm.tree.ClassNode;
57
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
8+
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
69

710
/***************************************************************************
811
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@@ -30,6 +33,10 @@
3033

3134
public abstract class Plugin extends Thread
3235
{
36+
//as long as your code is being called from the execute function
37+
// this will be the current container
38+
public ResourceContainer activeContainer = null;
39+
3340
@Override
3441
public void run()
3542
{
@@ -39,8 +46,8 @@ public void run()
3946
{
4047
if (BytecodeViewer.promptIfNoLoadedClasses())
4148
return;
42-
43-
execute(BytecodeViewer.getLoadedClasses());
49+
50+
executeContainer();
4451
} catch (Exception e) {
4552
BytecodeViewer.handleException(e);
4653
} finally {
@@ -68,9 +75,24 @@ public boolean isFinished() {
6875
public void setFinished() {
6976
finished = true;
7077
}
71-
78+
79+
/**
80+
* On plugin start each resource container is iterated through
81+
*/
82+
public void executeContainer()
83+
{
84+
BytecodeViewer.getResourceContainers().forEach(container -> {
85+
//set the active container
86+
activeContainer = container;
87+
88+
//call on the plugin code
89+
execute(new ArrayList<>(container.resourceClasses.values()));
90+
});
91+
}
92+
7293
/**
73-
* Whenever the plugin is started, this method is called
94+
* On plugin start each resource container is iterated through,
95+
* then this is called with the resource container classes
7496
*
7597
* @param classNodeList all of the loaded classes for easy access.
7698
*/

0 commit comments

Comments
 (0)