diff --git a/http-api/src/main/java/net/runelite/http/api/loottracker/LootRecordType.java b/http-api/src/main/java/net/runelite/http/api/loottracker/LootRecordType.java index daf515b896..94535413ea 100644 --- a/http-api/src/main/java/net/runelite/http/api/loottracker/LootRecordType.java +++ b/http-api/src/main/java/net/runelite/http/api/loottracker/LootRecordType.java @@ -30,5 +30,6 @@ public enum LootRecordType PLAYER, EVENT, DEATH, + PICKPOCKET, UNKNOWN } diff --git a/runelite-api/src/main/java/net/runelite/api/Opcodes.java b/runelite-api/src/main/java/net/runelite/api/Opcodes.java index 1ee96df082..b5fe92196a 100644 --- a/runelite-api/src/main/java/net/runelite/api/Opcodes.java +++ b/runelite-api/src/main/java/net/runelite/api/Opcodes.java @@ -29,6 +29,16 @@ package net.runelite.api; */ public class Opcodes { + /** + * opcode used to return from scripts. + */ + public static final int RETURN = 21; + + /** + * opcode used to invoke scripts. + */ + public static final int INVOKE = 40; + /** * RuneLite execution opcode used to inject scripts. */ diff --git a/runelite-api/src/main/java/net/runelite/api/events/ScriptPostFired.java b/runelite-api/src/main/java/net/runelite/api/events/ScriptPostFired.java new file mode 100644 index 0000000000..c9264e0c11 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/ScriptPostFired.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020, Trevor + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.events; + +import lombok.Value; + +/** + * An event that is fired after the designated script is ran + */ +@Value +public class ScriptPostFired implements Event +{ + /** + * The script id of the invoked script + */ + private final int scriptId; +} diff --git a/runelite-api/src/main/java/net/runelite/api/events/ScriptPreFired.java b/runelite-api/src/main/java/net/runelite/api/events/ScriptPreFired.java new file mode 100644 index 0000000000..a338145e4f --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/ScriptPreFired.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020, Trevor + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.events; + +import lombok.Data; +import net.runelite.api.ScriptEvent; + +/** + * An event that is fired before the designated script is ran + */ +@Data +public class ScriptPreFired implements Event +{ + /** + * The script id of the invoked script + */ + private final int scriptId; + + /** + * The input of the script invoke, this will be null unless it is the root script + */ + private ScriptEvent scriptEvent; +} diff --git a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java index d7df941b1d..d6f792e0ca 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java @@ -40,6 +40,7 @@ import net.runelite.api.AnimationID; import net.runelite.api.Client; import net.runelite.api.ItemID; import net.runelite.api.NPC; +import net.runelite.api.NPCDefinition; import net.runelite.api.NpcID; import net.runelite.api.Player; import net.runelite.api.Tile; @@ -51,6 +52,7 @@ import net.runelite.api.events.GameTick; import net.runelite.api.events.ItemDespawned; import net.runelite.api.events.ItemQuantityChanged; import net.runelite.api.events.ItemSpawned; +import net.runelite.api.events.NpcDefinitionChanged; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.PlayerDespawned; import net.runelite.client.eventbus.EventBus; @@ -90,6 +92,9 @@ public class LootManager private WorldPoint playerLocationLastTick; private WorldPoint krakenPlayerLocation; + private NPC delayedLootNpc; + private int delayedLootTickLimit; + @Inject private LootManager( final EventBus eventBus, @@ -100,6 +105,7 @@ public class LootManager this.client = client; eventBus.subscribe(GameTick.class, this, this::onGameTick); + eventBus.subscribe(NpcDefinitionChanged.class, this, this::onNpcChanged); eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned); eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned); @@ -111,6 +117,13 @@ public class LootManager private void onNpcDespawned(NpcDespawned npcDespawned) { final NPC npc = npcDespawned.getNpc(); + + if (npc == delayedLootNpc) + { + delayedLootNpc = null; + delayedLootTickLimit = 0; + } + if (!npc.isDead()) { int id = npc.getId(); @@ -241,13 +254,58 @@ public class LootManager } } + private void onNpcChanged(NpcDefinitionChanged npcChanged) + { + final NPC npc = npcChanged.getNpc(); + if (npc.getId() == NpcID.THE_NIGHTMARE_9433) + { + delayedLootNpc = npc; + delayedLootTickLimit = 15; + } + } + private void onGameTick(GameTick gameTick) { + if (delayedLootNpc != null && delayedLootTickLimit-- > 0) + { + processDelayedLoot(); + } + playerLocationLastTick = client.getLocalPlayer().getWorldLocation(); itemSpawns.clear(); killPoints.clear(); } + private void processDelayedLoot() + { + final WorldPoint adjacentLootTile = getAdjacentSquareLootTile(delayedLootNpc); + final LocalPoint localPoint = LocalPoint.fromWorld(client, adjacentLootTile); + + if (localPoint == null) + { + log.debug("Scene changed away from delayed loot location"); + delayedLootNpc = null; + delayedLootTickLimit = 0; + return; + } + + final int sceneX = localPoint.getSceneX(); + final int sceneY = localPoint.getSceneY(); + final int packed = sceneX << 8 | sceneY; + final List itemStacks = itemSpawns.get(packed); + if (itemStacks.isEmpty()) + { + // no loot yet + return; + } + + log.debug("Got delayed loot stack from {}: {}", delayedLootNpc.getName(), itemStacks); + eventBus.post(NpcLootReceived.class, new NpcLootReceived(delayedLootNpc, itemStacks)); + + delayedLootNpc = null; + delayedLootTickLimit = 0; + } + private void processNpcLoot(NPC npc) { final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation())); @@ -337,4 +395,32 @@ public class LootManager return worldLocation; } + + private WorldPoint getAdjacentSquareLootTile(NPC npc) + { + final NPCDefinition composition = npc.getDefinition(); + final WorldPoint worldLocation = npc.getWorldLocation(); + int x = worldLocation.getX(); + int y = worldLocation.getY(); + + if (playerLocationLastTick.getX() < x) + { + x -= 1; + } + else + { + x += Math.min(playerLocationLastTick.getX() - x, composition.getSize()); + } + + if (playerLocationLastTick.getY() < y) + { + y -= 1; + } + else + { + y += Math.min(playerLocationLastTick.getY() - y, composition.getSize()); + } + + return new WorldPoint(x, y, worldLocation.getPlane()); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginLoader.java b/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginLoader.java index 3abf4f1c9e..3bb6101a22 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginLoader.java @@ -34,6 +34,7 @@ import java.util.List; import java.util.Objects; import javax.inject.Inject; import javax.inject.Singleton; +import javax.swing.SwingUtilities; import lombok.extern.slf4j.Slf4j; import net.runelite.client.RuneLite; import net.runelite.client.config.Config; @@ -134,9 +135,20 @@ public class ExternalPluginLoader try { - pluginManager.startPlugin(plugin); + SwingUtilities.invokeAndWait(() -> + { + try + { + pluginManager.startPlugin(plugin); + } + catch (PluginInstantiationException e) + { + throw new RuntimeException(e); + } + }); + } - catch (PluginInstantiationException ex) + catch (Exception ex) { close(loader); log.warn("unable to start plugin", ex); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginManager.java index e6a40bcb51..393f86711d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ExternalPluginManager.java @@ -22,6 +22,7 @@ import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Singleton; import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -343,9 +344,19 @@ class ExternalPluginManager try { - runelitePluginManager.startPlugin(plugin); + SwingUtilities.invokeAndWait(() -> + { + try + { + runelitePluginManager.startPlugin(plugin); + } + catch (PluginInstantiationException e) + { + throw new RuntimeException(e); + } + }); } - catch (PluginInstantiationException ex) + catch (Exception ex) { log.warn("unable to start plugin", ex); return; @@ -423,12 +434,22 @@ class ExternalPluginManager try { - runelitePluginManager.stopPlugin(plugin); + SwingUtilities.invokeAndWait(() -> + { + try + { + runelitePluginManager.stopPlugin(plugin); + } + catch (Exception e2) + { + throw new RuntimeException(e2); + } + }); runelitePluginManager.remove(plugin); eventBus.post(ExternalPluginChanged.class, new ExternalPluginChanged(pluginId, plugin, false)); } - catch (PluginInstantiationException ex) + catch (Exception ex) { log.warn("unable to stop plugin", ex); return; @@ -459,14 +480,24 @@ class ExternalPluginManager try { - runelitePluginManager.stopPlugin(plugin); + SwingUtilities.invokeAndWait(() -> + { + try + { + runelitePluginManager.stopPlugin(plugin); + } + catch (Exception e2) + { + throw new RuntimeException(e2); + } + }); runelitePluginManager.remove(plugin); eventBus.post(ExternalPluginChanged.class, new ExternalPluginChanged(pluginId, plugin, false)); return pluginWrapper.getPluginPath(); } - catch (PluginInstantiationException ex) + catch (Exception ex) { log.warn("unable to stop plugin", ex); return null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index bf8fc03750..fa36dabdf8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -53,7 +53,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import javax.inject.Inject; @@ -90,7 +89,6 @@ public class PluginManager private final EventBus eventBus; private final Scheduler scheduler; private final ConfigManager configManager; - private final ScheduledExecutorService executor; private final Provider sceneTileManager; private final List plugins = new CopyOnWriteArrayList<>(); private final List activePlugins = new CopyOnWriteArrayList<>(); @@ -110,14 +108,12 @@ public class PluginManager final EventBus eventBus, final Scheduler scheduler, final ConfigManager configManager, - final ScheduledExecutorService executor, final Provider sceneTileManager) { this.developerMode = developerMode; this.eventBus = eventBus; this.scheduler = scheduler; this.configManager = configManager; - this.executor = executor; this.sceneTileManager = sceneTileManager; if (eventBus != null) @@ -140,21 +136,30 @@ public class PluginManager private void refreshPlugins() { loadDefaultPluginConfiguration(); - getPlugins() - .forEach(plugin -> executor.submit(() -> + SwingUtilities.invokeLater(() -> + { + for (Plugin plugin : getPlugins()) { try { - if (!startPlugin(plugin)) + if (isPluginEnabled(plugin) != activePlugins.contains(plugin)) { - stopPlugin(plugin); + if (activePlugins.contains(plugin)) + { + stopPlugin(plugin); + } + else + { + startPlugin(plugin); + } } } catch (PluginInstantiationException e) { log.warn("Error during starting/stopping plugin {}", plugin.getClass().getSimpleName(), e); } - })); + } + }); } public Config getPluginConfigProxy(Plugin plugin) @@ -217,22 +222,33 @@ public class PluginManager public void startCorePlugins() { List scannedPlugins = new ArrayList<>(plugins); - int loaded = 0, started = 0; + int loaded = 0; + AtomicInteger started = new AtomicInteger(); final Stopwatch timer = Stopwatch.createStarted(); for (Plugin plugin : scannedPlugins) { try { - if (startPlugin(plugin)) + SwingUtilities.invokeAndWait(() -> { - ++started; - } + try + { + if (startPlugin(plugin)) + { + started.incrementAndGet(); + } + } + catch (PluginInstantiationException ex) + { + log.warn("Unable to start plugin {}", plugin.getClass().getSimpleName(), ex); + plugins.remove(plugin); + } + }); } - catch (PluginInstantiationException ex) + catch (InterruptedException | InvocationTargetException e) { - log.warn("Unable to start plugin {}", plugin.getClass().getSimpleName(), ex); - plugins.remove(plugin); + throw new RuntimeException(e); } loaded++; @@ -363,8 +379,11 @@ public class PluginManager return scannedPlugins; } - public synchronized boolean startPlugin(Plugin plugin) throws PluginInstantiationException + public boolean startPlugin(Plugin plugin) throws PluginInstantiationException { + // plugins always start in the EDT + assert SwingUtilities.isEventDispatchThread(); + if (activePlugins.contains(plugin) || !isPluginEnabled(plugin)) { return false; @@ -374,19 +393,7 @@ public class PluginManager try { - // plugins always start in the event thread - SwingUtilities.invokeAndWait(() -> - { - try - { - plugin.startUp(); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - }); - + plugin.startUp(); plugin.addAnnotatedSubscriptions(eventBus); log.debug("Plugin {} is now running", plugin.getClass().getSimpleName()); @@ -402,7 +409,7 @@ public class PluginManager schedule(plugin); eventBus.post(PluginChanged.class, new PluginChanged(plugin, true)); } - catch (InterruptedException | InvocationTargetException | IllegalArgumentException ex) + catch (Exception ex) { throw new PluginInstantiationException(ex); } @@ -410,39 +417,28 @@ public class PluginManager return true; } - public synchronized boolean stopPlugin(Plugin plugin) throws PluginInstantiationException + public boolean stopPlugin(Plugin plugin) throws PluginInstantiationException { - if (!activePlugins.contains(plugin) || isPluginEnabled(plugin)) + // plugins always stop in the EDT + assert SwingUtilities.isEventDispatchThread(); + + if (!activePlugins.remove(plugin)) { return false; } - activePlugins.remove(plugin); + unschedule(plugin); try { - unschedule(plugin); - - // plugins always stop in the event thread - SwingUtilities.invokeAndWait(() -> - { - try - { - plugin.shutDown(); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - }); - + plugin.shutDown(); plugin.removeAnnotatedSubscriptions(eventBus); log.debug("Plugin {} is now stopped", plugin.getClass().getSimpleName()); eventBus.post(PluginChanged.class, new PluginChanged(plugin, false)); } - catch (InterruptedException | InvocationTargetException ex) + catch (Exception ex) { throw new PluginInstantiationException(ex); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java index b8422e9d01..8071d6d904 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java @@ -79,11 +79,13 @@ public class ConfigPlugin extends Plugin pluginListPanel = pluginListPanelProvider.get(); pluginListPanel.addFakePlugin( new PluginConfigurationDescriptor( - "OpenOSRS", "OpenOSRS client settings", PluginType.IMPORTANT, new String[]{"client"}, + "OpenOSRS", "OpenOSRS client settings", PluginType.IMPORTANT, + new String[]{"sorting", "external", "logs", "categories", "colors", "opacity", "pin"}, null, openOSRSConfig, configManager.getConfigDescriptor(openOSRSConfig) ), new PluginConfigurationDescriptor( - "RuneLite", "RuneLite client settings", PluginType.IMPORTANT, new String[]{"client"}, + "RuneLite", "RuneLite client settings", PluginType.IMPORTANT, + new String[]{"client", "notification", "size", "position", "window", "chrome", "focus", "font", "overlay", "tooltip", "infobox"}, null, runeLiteConfig, configManager.getConfigDescriptor(runeLiteConfig) ), new PluginConfigurationDescriptor( diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java index 35d7b30053..e44d0625a7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java @@ -427,36 +427,30 @@ public class PluginListPanel extends PluginPanel void startPlugin(Plugin plugin) { - executorService.submit(() -> - { - pluginManager.setPluginEnabled(plugin, true); + pluginManager.setPluginEnabled(plugin, true); - try - { - pluginManager.startPlugin(plugin); - } - catch (PluginInstantiationException ex) - { - log.warn("Error when starting plugin {}", plugin.getClass().getSimpleName(), ex); - } - }); + try + { + pluginManager.startPlugin(plugin); + } + catch (PluginInstantiationException ex) + { + log.warn("Error when starting plugin {}", plugin.getClass().getSimpleName(), ex); + } } void stopPlugin(Plugin plugin) { - executorService.submit(() -> - { - pluginManager.setPluginEnabled(plugin, false); + pluginManager.setPluginEnabled(plugin, false); - try - { - pluginManager.stopPlugin(plugin); - } - catch (PluginInstantiationException ex) - { - log.warn("Error when stopping plugin {}", plugin.getClass().getSimpleName(), ex); - } - }); + try + { + pluginManager.stopPlugin(plugin); + } + catch (PluginInstantiationException ex) + { + log.warn("Error when stopping plugin {}", plugin.getClass().getSimpleName(), ex); + } } private List getPinnedPluginNames() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java index dc090ff573..2a985fba83 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java @@ -90,7 +90,6 @@ class InfoPanel extends PluginPanel @Inject public InfoPanel(final InfoPlugin plugin, final Client client) { - setLayout(new BorderLayout()); setBackground(ColorScheme.DARK_GRAY_COLOR); setBorder(new EmptyBorder(10, 10, 10, 10)); diff --git a/runelite-client/src/test/java/net/runelite/client/config/TestConfig.java b/runelite-client/src/test/java/net/runelite/client/config/TestConfig.java index 9bc5f29b37..66e659d98a 100644 --- a/runelite-client/src/test/java/net/runelite/client/config/TestConfig.java +++ b/runelite-client/src/test/java/net/runelite/client/config/TestConfig.java @@ -25,7 +25,7 @@ package net.runelite.client.config; @ConfigGroup("test") -public interface TestConfig +public interface TestConfig extends Config { @ConfigItem( keyName = "key", diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java index b52f3cbf02..a9b6f2f4c0 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java @@ -116,7 +116,7 @@ public class PluginManagerTest @Test public void testLoadPlugins() throws Exception { - PluginManager pluginManager = new PluginManager(false, null, null, null, null, null); + PluginManager pluginManager = new PluginManager(false, null, null, null, null); pluginManager.setOutdated(true); pluginManager.loadCorePlugins(); Collection plugins = pluginManager.getPlugins(); @@ -127,7 +127,7 @@ public class PluginManagerTest .count(); assertEquals(expected, plugins.size()); - pluginManager = new PluginManager(false, null, null, null, null, null); + pluginManager = new PluginManager(false, null, null, null, null); pluginManager.loadCorePlugins(); plugins = pluginManager.getPlugins(); @@ -146,7 +146,7 @@ public class PluginManagerTest modules.add(new GraphvizModule()); modules.add(new RuneLiteModule(() -> null, true)); - PluginManager pluginManager = new PluginManager(true, null, null, null, null, null); + PluginManager pluginManager = new PluginManager(true, null, null, null, null); pluginManager.loadCorePlugins(); modules.addAll(pluginManager.getPlugins()); @@ -198,7 +198,7 @@ public class PluginManagerTest public void testEventbusAnnotations() throws PluginInstantiationException { EventBus eventbus = new EventBus(); - PluginManager pluginManager = new PluginManager(true, eventbus, null, null, null, null) + PluginManager pluginManager = new PluginManager(true, eventbus, null, null, null) { @Override public boolean isPluginEnabled(Plugin plugin) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java index 22062a9e31..8e223ec9b5 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java @@ -29,6 +29,8 @@ import java.util.regex.Pattern; import net.runelite.api.Client; import static net.runelite.api.Opcodes.RUNELITE_EXECUTE; import net.runelite.api.events.ScriptCallbackEvent; +import net.runelite.api.events.ScriptPostFired; +import net.runelite.api.events.ScriptPreFired; import net.runelite.api.mixins.Copy; import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Mixin; @@ -131,7 +133,20 @@ public abstract class ScriptVMMixin implements RSClient try { + if (event.getArguments() != null && event.getArguments().length > 0) + { + ScriptPreFired scriptPreFired = new ScriptPreFired((Integer) event.getArguments()[0]); + scriptPreFired.setScriptEvent(event); + client.getCallbacks().post(ScriptPreFired.class, scriptPreFired); + } + rs$runScript(event, maxExecutionTime); + + if (event.getArguments() != null && event.getArguments().length > 0) + { + ScriptPostFired scriptPostFired = new ScriptPostFired((Integer) event.getArguments()[0]); + client.getCallbacks().post(ScriptPostFired.class, scriptPostFired); + } } finally {