diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index 83e5159b..d82b1ad8 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -398,6 +398,21 @@ public class BytecodeViewer return a; } + /** + * Called any time refresh is called to automatically compile all of the compilable panes that're opened. + */ + public static boolean autoCompileSuccessful() + { + if(!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()) + return true; + + try { + return compile(true); + } catch (NullPointerException ignored) { + return false; + } + } + /** * Compile all of the compilable panes that're opened. * @@ -682,7 +697,7 @@ public class BytecodeViewer Thread resourceExport = new Thread(() -> { - if (viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; JFileChooser fc = new FileChooser(Configuration.getLastDirectory(), diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneRefresh.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneRefresh.java index 947a8fbf..2b1fb53b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneRefresh.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneRefresh.java @@ -23,11 +23,8 @@ public class WorkPaneRefresh implements Runnable @Override public void run() { - if (BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()) - try { - if (!BytecodeViewer.compile(false)) - return; - } catch (NullPointerException ignored) { } + if (!BytecodeViewer.autoCompileSuccessful()) + return; JButton src = null; if(event != null && event.getSource() instanceof JButton) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java index 84320394..e4c0a21b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginManager.java @@ -1,9 +1,7 @@ package the.bytecode.club.bytecodeviewer.plugin; import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import java.util.*; import javax.swing.filechooser.FileFilter; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.api.Plugin; @@ -41,7 +39,7 @@ public final class PluginManager { private static final Map launchStrategies = new HashMap<>(); private static final PluginFileFilter filter = new PluginFileFilter(); - private static Plugin pluginInstance; + private static List pluginInstances = new ArrayList<>(); static { @@ -67,14 +65,16 @@ public final class PluginManager { * * @param newPluginInstance the new plugin instance */ - public static void runPlugin(Plugin newPluginInstance) { - if (pluginInstance == null || pluginInstance.isFinished()) { - pluginInstance = newPluginInstance; - pluginInstance.start(); // start the thread - } else if (!pluginInstance.isFinished()) { - BytecodeViewer.showMessage("There is currently another plugin running right now, please wait for that to " - + "finish executing."); - } + public static void runPlugin(Plugin newPluginInstance) + { + //clean the plugin list from dead threads + pluginInstances.removeIf(Plugin::isFinished); + + //add to the list of running instances + pluginInstances.add(newPluginInstance); + + //start the plugin thread + newPluginInstance.start(); } /** diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java index 9990ca00..40447473 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java @@ -126,7 +126,7 @@ public class PluginWriter extends JFrame { Thread exportThread = new Thread(() -> { - if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; if(savePath == null) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java index 6fcef0fa..628f169d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java @@ -8,13 +8,11 @@ import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; import the.bytecode.club.bytecodeviewer.util.DialogueUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; import javax.swing.*; -import javax.swing.filechooser.FileFilter; import java.io.File; import java.util.Objects; @@ -37,7 +35,7 @@ public class ResourceDecompiling Thread decompileThread = new Thread(() -> { - if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; JFileChooser fc = new FileChooser(Configuration.getLastDirectory(), @@ -189,7 +187,7 @@ public class ResourceDecompiling } Thread decompileThread = new Thread(() -> { - if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; final String s = BytecodeViewer.viewer.workPane.getCurrentViewer().cn.name; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java index eff5e0c6..d29bc3f4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/APKExport.java @@ -67,7 +67,7 @@ public class APKExport implements Exporter Thread exportThread = new Thread(() -> { - if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; JFileChooser fc = new FileChooser(Configuration.getLastDirectory(), diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java index d0466fe6..500eaacd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/DexExport.java @@ -3,7 +3,6 @@ package the.bytecode.club.bytecodeviewer.resources.exporting.impl; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; import the.bytecode.club.bytecodeviewer.util.Dex2Jar; import the.bytecode.club.bytecodeviewer.util.DialogueUtils; @@ -34,7 +33,7 @@ public class DexExport implements Exporter Thread exportThread = new Thread(() -> { - if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; JFileChooser fc = new FileChooser(Configuration.getLastDirectory(), diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java index a799e420..b3c3b79c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java @@ -4,7 +4,6 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.ExportJar; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; import the.bytecode.club.bytecodeviewer.util.DialogueUtils; @@ -28,7 +27,7 @@ public class RunnableJarExporter implements Exporter Thread exportThread = new Thread(() -> { - if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; JFileChooser fc = new FileChooser(Configuration.getLastDirectory(), diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java index 271367ca..9397a4e4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/ZipExport.java @@ -3,7 +3,6 @@ package the.bytecode.club.bytecodeviewer.resources.exporting.impl; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; -import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue; import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter; import the.bytecode.club.bytecodeviewer.util.DialogueUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils; @@ -28,7 +27,7 @@ public class ZipExport implements Exporter Thread exportThread = new Thread(() -> { - if (BytecodeViewer.viewer.compileOnSave.isSelected() && !BytecodeViewer.compile(false)) + if (BytecodeViewer.autoCompileSuccessful()) return; JFileChooser fc = new FileChooser(Configuration.getLastDirectory(),