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 net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
|
||||
@@ -43,27 +41,18 @@ public class LowMemoryPlugin extends Plugin
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
protected void startUp()
|
||||
{
|
||||
if (client.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
client.changeMemoryMode(true);
|
||||
}
|
||||
clientThread.invoke(() -> client.changeMemoryMode(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
protected void shutDown()
|
||||
{
|
||||
client.changeMemoryMode(false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
if (event.getGameState() == GameState.LOGIN_SCREEN)
|
||||
{
|
||||
client.changeMemoryMode(true);
|
||||
}
|
||||
clientThread.invoke(() -> client.changeMemoryMode(false));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user