Merge pull request #2332 from Owain94/merge-1102

project: Merge upstream
This commit is contained in:
Owain van Brakel
2020-02-11 20:09:28 +01:00
committed by GitHub
14 changed files with 320 additions and 90 deletions

View File

@@ -30,5 +30,6 @@ public enum LootRecordType
PLAYER, PLAYER,
EVENT, EVENT,
DEATH, DEATH,
PICKPOCKET,
UNKNOWN UNKNOWN
} }

View File

@@ -29,6 +29,16 @@ package net.runelite.api;
*/ */
public class Opcodes 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. * RuneLite execution opcode used to inject scripts.
*/ */

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2020, Trevor <https://github.com/Trevor159>
* 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;
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2020, Trevor <https://github.com/Trevor159>
* 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;
}

View File

@@ -40,6 +40,7 @@ import net.runelite.api.AnimationID;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.NPCDefinition;
import net.runelite.api.NpcID; import net.runelite.api.NpcID;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Tile; 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.ItemDespawned;
import net.runelite.api.events.ItemQuantityChanged; import net.runelite.api.events.ItemQuantityChanged;
import net.runelite.api.events.ItemSpawned; import net.runelite.api.events.ItemSpawned;
import net.runelite.api.events.NpcDefinitionChanged;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.PlayerDespawned; import net.runelite.api.events.PlayerDespawned;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
@@ -90,6 +92,9 @@ public class LootManager
private WorldPoint playerLocationLastTick; private WorldPoint playerLocationLastTick;
private WorldPoint krakenPlayerLocation; private WorldPoint krakenPlayerLocation;
private NPC delayedLootNpc;
private int delayedLootTickLimit;
@Inject @Inject
private LootManager( private LootManager(
final EventBus eventBus, final EventBus eventBus,
@@ -100,6 +105,7 @@ public class LootManager
this.client = client; this.client = client;
eventBus.subscribe(GameTick.class, this, this::onGameTick); eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(NpcDefinitionChanged.class, this, this::onNpcChanged);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned); eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned);
eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned); eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned);
@@ -111,6 +117,13 @@ public class LootManager
private void onNpcDespawned(NpcDespawned npcDespawned) private void onNpcDespawned(NpcDespawned npcDespawned)
{ {
final NPC npc = npcDespawned.getNpc(); final NPC npc = npcDespawned.getNpc();
if (npc == delayedLootNpc)
{
delayedLootNpc = null;
delayedLootTickLimit = 0;
}
if (!npc.isDead()) if (!npc.isDead())
{ {
int id = npc.getId(); 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) private void onGameTick(GameTick gameTick)
{ {
if (delayedLootNpc != null && delayedLootTickLimit-- > 0)
{
processDelayedLoot();
}
playerLocationLastTick = client.getLocalPlayer().getWorldLocation(); playerLocationLastTick = client.getLocalPlayer().getWorldLocation();
itemSpawns.clear(); itemSpawns.clear();
killPoints.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<ItemStack> 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) private void processNpcLoot(NPC npc)
{ {
final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation())); final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation()));
@@ -337,4 +395,32 @@ public class LootManager
return worldLocation; 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());
}
} }

View File

@@ -34,6 +34,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.SwingUtilities;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
@@ -134,9 +135,20 @@ public class ExternalPluginLoader
try 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); close(loader);
log.warn("unable to start plugin", ex); log.warn("unable to start plugin", ex);

View File

@@ -22,6 +22,7 @@ import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -343,9 +344,19 @@ class ExternalPluginManager
try 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); log.warn("unable to start plugin", ex);
return; return;
@@ -423,12 +434,22 @@ class ExternalPluginManager
try try
{ {
runelitePluginManager.stopPlugin(plugin); SwingUtilities.invokeAndWait(() ->
{
try
{
runelitePluginManager.stopPlugin(plugin);
}
catch (Exception e2)
{
throw new RuntimeException(e2);
}
});
runelitePluginManager.remove(plugin); runelitePluginManager.remove(plugin);
eventBus.post(ExternalPluginChanged.class, new ExternalPluginChanged(pluginId, plugin, false)); eventBus.post(ExternalPluginChanged.class, new ExternalPluginChanged(pluginId, plugin, false));
} }
catch (PluginInstantiationException ex) catch (Exception ex)
{ {
log.warn("unable to stop plugin", ex); log.warn("unable to stop plugin", ex);
return; return;
@@ -459,14 +480,24 @@ class ExternalPluginManager
try try
{ {
runelitePluginManager.stopPlugin(plugin); SwingUtilities.invokeAndWait(() ->
{
try
{
runelitePluginManager.stopPlugin(plugin);
}
catch (Exception e2)
{
throw new RuntimeException(e2);
}
});
runelitePluginManager.remove(plugin); runelitePluginManager.remove(plugin);
eventBus.post(ExternalPluginChanged.class, new ExternalPluginChanged(pluginId, plugin, false)); eventBus.post(ExternalPluginChanged.class, new ExternalPluginChanged(pluginId, plugin, false));
return pluginWrapper.getPluginPath(); return pluginWrapper.getPluginPath();
} }
catch (PluginInstantiationException ex) catch (Exception ex)
{ {
log.warn("unable to stop plugin", ex); log.warn("unable to stop plugin", ex);
return null; return null;

View File

@@ -53,7 +53,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
@@ -90,7 +89,6 @@ public class PluginManager
private final EventBus eventBus; private final EventBus eventBus;
private final Scheduler scheduler; private final Scheduler scheduler;
private final ConfigManager configManager; private final ConfigManager configManager;
private final ScheduledExecutorService executor;
private final Provider<GameEventManager> sceneTileManager; private final Provider<GameEventManager> sceneTileManager;
private final List<Plugin> plugins = new CopyOnWriteArrayList<>(); private final List<Plugin> plugins = new CopyOnWriteArrayList<>();
private final List<Plugin> activePlugins = new CopyOnWriteArrayList<>(); private final List<Plugin> activePlugins = new CopyOnWriteArrayList<>();
@@ -110,14 +108,12 @@ public class PluginManager
final EventBus eventBus, final EventBus eventBus,
final Scheduler scheduler, final Scheduler scheduler,
final ConfigManager configManager, final ConfigManager configManager,
final ScheduledExecutorService executor,
final Provider<GameEventManager> sceneTileManager) final Provider<GameEventManager> sceneTileManager)
{ {
this.developerMode = developerMode; this.developerMode = developerMode;
this.eventBus = eventBus; this.eventBus = eventBus;
this.scheduler = scheduler; this.scheduler = scheduler;
this.configManager = configManager; this.configManager = configManager;
this.executor = executor;
this.sceneTileManager = sceneTileManager; this.sceneTileManager = sceneTileManager;
if (eventBus != null) if (eventBus != null)
@@ -140,21 +136,30 @@ public class PluginManager
private void refreshPlugins() private void refreshPlugins()
{ {
loadDefaultPluginConfiguration(); loadDefaultPluginConfiguration();
getPlugins() SwingUtilities.invokeLater(() ->
.forEach(plugin -> executor.submit(() -> {
for (Plugin plugin : getPlugins())
{ {
try try
{ {
if (!startPlugin(plugin)) if (isPluginEnabled(plugin) != activePlugins.contains(plugin))
{ {
stopPlugin(plugin); if (activePlugins.contains(plugin))
{
stopPlugin(plugin);
}
else
{
startPlugin(plugin);
}
} }
} }
catch (PluginInstantiationException e) catch (PluginInstantiationException e)
{ {
log.warn("Error during starting/stopping plugin {}", plugin.getClass().getSimpleName(), e); log.warn("Error during starting/stopping plugin {}", plugin.getClass().getSimpleName(), e);
} }
})); }
});
} }
public Config getPluginConfigProxy(Plugin plugin) public Config getPluginConfigProxy(Plugin plugin)
@@ -217,22 +222,33 @@ public class PluginManager
public void startCorePlugins() public void startCorePlugins()
{ {
List<Plugin> scannedPlugins = new ArrayList<>(plugins); List<Plugin> scannedPlugins = new ArrayList<>(plugins);
int loaded = 0, started = 0; int loaded = 0;
AtomicInteger started = new AtomicInteger();
final Stopwatch timer = Stopwatch.createStarted(); final Stopwatch timer = Stopwatch.createStarted();
for (Plugin plugin : scannedPlugins) for (Plugin plugin : scannedPlugins)
{ {
try 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); throw new RuntimeException(e);
plugins.remove(plugin);
} }
loaded++; loaded++;
@@ -363,8 +379,11 @@ public class PluginManager
return scannedPlugins; 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)) if (activePlugins.contains(plugin) || !isPluginEnabled(plugin))
{ {
return false; return false;
@@ -374,19 +393,7 @@ public class PluginManager
try try
{ {
// plugins always start in the event thread plugin.startUp();
SwingUtilities.invokeAndWait(() ->
{
try
{
plugin.startUp();
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
});
plugin.addAnnotatedSubscriptions(eventBus); plugin.addAnnotatedSubscriptions(eventBus);
log.debug("Plugin {} is now running", plugin.getClass().getSimpleName()); log.debug("Plugin {} is now running", plugin.getClass().getSimpleName());
@@ -402,7 +409,7 @@ public class PluginManager
schedule(plugin); schedule(plugin);
eventBus.post(PluginChanged.class, new PluginChanged(plugin, true)); eventBus.post(PluginChanged.class, new PluginChanged(plugin, true));
} }
catch (InterruptedException | InvocationTargetException | IllegalArgumentException ex) catch (Exception ex)
{ {
throw new PluginInstantiationException(ex); throw new PluginInstantiationException(ex);
} }
@@ -410,39 +417,28 @@ public class PluginManager
return true; 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; return false;
} }
activePlugins.remove(plugin); unschedule(plugin);
try try
{ {
unschedule(plugin); plugin.shutDown();
// plugins always stop in the event thread
SwingUtilities.invokeAndWait(() ->
{
try
{
plugin.shutDown();
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
});
plugin.removeAnnotatedSubscriptions(eventBus); plugin.removeAnnotatedSubscriptions(eventBus);
log.debug("Plugin {} is now stopped", plugin.getClass().getSimpleName()); log.debug("Plugin {} is now stopped", plugin.getClass().getSimpleName());
eventBus.post(PluginChanged.class, new PluginChanged(plugin, false)); eventBus.post(PluginChanged.class, new PluginChanged(plugin, false));
} }
catch (InterruptedException | InvocationTargetException ex) catch (Exception ex)
{ {
throw new PluginInstantiationException(ex); throw new PluginInstantiationException(ex);
} }

View File

@@ -79,11 +79,13 @@ public class ConfigPlugin extends Plugin
pluginListPanel = pluginListPanelProvider.get(); pluginListPanel = pluginListPanelProvider.get();
pluginListPanel.addFakePlugin( pluginListPanel.addFakePlugin(
new PluginConfigurationDescriptor( 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) null, openOSRSConfig, configManager.getConfigDescriptor(openOSRSConfig)
), ),
new PluginConfigurationDescriptor( 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) null, runeLiteConfig, configManager.getConfigDescriptor(runeLiteConfig)
), ),
new PluginConfigurationDescriptor( new PluginConfigurationDescriptor(

View File

@@ -427,36 +427,30 @@ public class PluginListPanel extends PluginPanel
void startPlugin(Plugin plugin) void startPlugin(Plugin plugin)
{ {
executorService.submit(() -> pluginManager.setPluginEnabled(plugin, true);
{
pluginManager.setPluginEnabled(plugin, true);
try try
{ {
pluginManager.startPlugin(plugin); pluginManager.startPlugin(plugin);
} }
catch (PluginInstantiationException ex) catch (PluginInstantiationException ex)
{ {
log.warn("Error when starting plugin {}", plugin.getClass().getSimpleName(), ex); log.warn("Error when starting plugin {}", plugin.getClass().getSimpleName(), ex);
} }
});
} }
void stopPlugin(Plugin plugin) void stopPlugin(Plugin plugin)
{ {
executorService.submit(() -> pluginManager.setPluginEnabled(plugin, false);
{
pluginManager.setPluginEnabled(plugin, false);
try try
{ {
pluginManager.stopPlugin(plugin); pluginManager.stopPlugin(plugin);
} }
catch (PluginInstantiationException ex) catch (PluginInstantiationException ex)
{ {
log.warn("Error when stopping plugin {}", plugin.getClass().getSimpleName(), ex); log.warn("Error when stopping plugin {}", plugin.getClass().getSimpleName(), ex);
} }
});
} }
private List<String> getPinnedPluginNames() private List<String> getPinnedPluginNames()

View File

@@ -90,7 +90,6 @@ class InfoPanel extends PluginPanel
@Inject @Inject
public InfoPanel(final InfoPlugin plugin, final Client client) public InfoPanel(final InfoPlugin plugin, final Client client)
{ {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARK_GRAY_COLOR); setBackground(ColorScheme.DARK_GRAY_COLOR);
setBorder(new EmptyBorder(10, 10, 10, 10)); setBorder(new EmptyBorder(10, 10, 10, 10));

View File

@@ -25,7 +25,7 @@
package net.runelite.client.config; package net.runelite.client.config;
@ConfigGroup("test") @ConfigGroup("test")
public interface TestConfig public interface TestConfig extends Config
{ {
@ConfigItem( @ConfigItem(
keyName = "key", keyName = "key",

View File

@@ -116,7 +116,7 @@ public class PluginManagerTest
@Test @Test
public void testLoadPlugins() throws Exception 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.setOutdated(true);
pluginManager.loadCorePlugins(); pluginManager.loadCorePlugins();
Collection<Plugin> plugins = pluginManager.getPlugins(); Collection<Plugin> plugins = pluginManager.getPlugins();
@@ -127,7 +127,7 @@ public class PluginManagerTest
.count(); .count();
assertEquals(expected, plugins.size()); assertEquals(expected, plugins.size());
pluginManager = new PluginManager(false, null, null, null, null, null); pluginManager = new PluginManager(false, null, null, null, null);
pluginManager.loadCorePlugins(); pluginManager.loadCorePlugins();
plugins = pluginManager.getPlugins(); plugins = pluginManager.getPlugins();
@@ -146,7 +146,7 @@ public class PluginManagerTest
modules.add(new GraphvizModule()); modules.add(new GraphvizModule());
modules.add(new RuneLiteModule(() -> null, true)); 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(); pluginManager.loadCorePlugins();
modules.addAll(pluginManager.getPlugins()); modules.addAll(pluginManager.getPlugins());
@@ -198,7 +198,7 @@ public class PluginManagerTest
public void testEventbusAnnotations() throws PluginInstantiationException public void testEventbusAnnotations() throws PluginInstantiationException
{ {
EventBus eventbus = new EventBus(); EventBus eventbus = new EventBus();
PluginManager pluginManager = new PluginManager(true, eventbus, null, null, null, null) PluginManager pluginManager = new PluginManager(true, eventbus, null, null, null)
{ {
@Override @Override
public boolean isPluginEnabled(Plugin plugin) public boolean isPluginEnabled(Plugin plugin)

View File

@@ -29,6 +29,8 @@ import java.util.regex.Pattern;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.Opcodes.RUNELITE_EXECUTE; import static net.runelite.api.Opcodes.RUNELITE_EXECUTE;
import net.runelite.api.events.ScriptCallbackEvent; 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.Copy;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Mixin;
@@ -131,7 +133,20 @@ public abstract class ScriptVMMixin implements RSClient
try 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); 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 finally
{ {