Merge pull request #2332 from Owain94/merge-1102
project: Merge upstream
This commit is contained in:
@@ -30,5 +30,6 @@ public enum LootRecordType
|
||||
PLAYER,
|
||||
EVENT,
|
||||
DEATH,
|
||||
PICKPOCKET,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<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)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<GameEventManager> sceneTileManager;
|
||||
private final List<Plugin> plugins = new CopyOnWriteArrayList<>();
|
||||
private final List<Plugin> activePlugins = new CopyOnWriteArrayList<>();
|
||||
@@ -110,14 +108,12 @@ public class PluginManager
|
||||
final EventBus eventBus,
|
||||
final Scheduler scheduler,
|
||||
final ConfigManager configManager,
|
||||
final ScheduledExecutorService executor,
|
||||
final Provider<GameEventManager> 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<Plugin> 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);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<String> getPinnedPluginNames()
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
package net.runelite.client.config;
|
||||
|
||||
@ConfigGroup("test")
|
||||
public interface TestConfig
|
||||
public interface TestConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "key",
|
||||
|
||||
@@ -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<Plugin> 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)
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user