low memory plugin: run changeMemoryMode on game thread
This method must now be called on game thread, and can be called regardless of game state.
This commit is contained in:
@@ -26,9 +26,7 @@ package net.runelite.client.plugins.lowmemory;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.client.callback.ClientThread;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
|
|
||||||
@@ -43,27 +41,18 @@ public class LowMemoryPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ClientThread clientThread;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp()
|
||||||
{
|
{
|
||||||
if (client.getGameState() == GameState.LOGGED_IN)
|
clientThread.invoke(() -> client.changeMemoryMode(true));
|
||||||
{
|
|
||||||
client.changeMemoryMode(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown() throws Exception
|
protected void shutDown()
|
||||||
{
|
{
|
||||||
client.changeMemoryMode(false);
|
clientThread.invoke(() -> client.changeMemoryMode(false));
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
private void onGameStateChanged(GameStateChanged event)
|
|
||||||
{
|
|
||||||
if (event.getGameState() == GameState.LOGIN_SCREEN)
|
|
||||||
{
|
|
||||||
client.changeMemoryMode(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user