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
This commit is contained in:
Konloch 2021-07-13 04:46:21 -07:00
parent 9f1877a81c
commit fc68fde546
1 changed files with 26 additions and 4 deletions

View File

@ -1,8 +1,11 @@
package the.bytecode.club.bytecodeviewer.api;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -30,6 +33,10 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
public abstract class Plugin extends Thread
{
//as long as your code is being called from the execute function
// this will be the current container
public ResourceContainer activeContainer = null;
@Override
public void run()
{
@ -40,7 +47,7 @@ public abstract class Plugin extends Thread
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
execute(BytecodeViewer.getLoadedClasses());
executeContainer();
} catch (Exception e) {
BytecodeViewer.handleException(e);
} finally {
@ -70,7 +77,22 @@ public abstract class Plugin extends Thread
}
/**
* Whenever the plugin is started, this method is called
* On plugin start each resource container is iterated through
*/
public void executeContainer()
{
BytecodeViewer.getResourceContainers().forEach(container -> {
//set the active container
activeContainer = container;
//call on the plugin code
execute(new ArrayList<>(container.resourceClasses.values()));
});
}
/**
* On plugin start each resource container is iterated through,
* then this is called with the resource container classes
*
* @param classNodeList all of the loaded classes for easy access.
*/