runelite-client: Rename ClientThread::invokeLater to invoke
And add a invokeLater that actually invokes later all of the time
This commit is contained in:
@@ -41,9 +41,9 @@ public class ClientThread
|
|||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
public void invokeLater(Runnable r)
|
public void invoke(Runnable r)
|
||||||
{
|
{
|
||||||
invokeLater(() ->
|
invoke(() ->
|
||||||
{
|
{
|
||||||
r.run();
|
r.run();
|
||||||
return true;
|
return true;
|
||||||
@@ -54,7 +54,7 @@ public class ClientThread
|
|||||||
* Will run r on the game thread, at a unspecified point in the future.
|
* Will run r on the game thread, at a unspecified point in the future.
|
||||||
* If r returns false, r will be ran again, at a later point
|
* If r returns false, r will be ran again, at a later point
|
||||||
*/
|
*/
|
||||||
public void invokeLater(BooleanSupplier r)
|
public void invoke(BooleanSupplier r)
|
||||||
{
|
{
|
||||||
if (client.isClientThread())
|
if (client.isClientThread())
|
||||||
{
|
{
|
||||||
@@ -64,6 +64,25 @@ public class ClientThread
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invokeLater(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will run r on the game thread after this method returns
|
||||||
|
* If r returns false, r will be ran again, at a later point
|
||||||
|
*/
|
||||||
|
public void invokeLater(Runnable r)
|
||||||
|
{
|
||||||
|
invokeLater(() ->
|
||||||
|
{
|
||||||
|
r.run();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invokeLater(BooleanSupplier r)
|
||||||
|
{
|
||||||
invokes.add(r);
|
invokes.add(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +104,7 @@ public class ClientThread
|
|||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
log.warn("Exception in invokeLater", e);
|
log.warn("Exception in invoke", e);
|
||||||
}
|
}
|
||||||
if (remove)
|
if (remove)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class CommandManager
|
|||||||
}
|
}
|
||||||
resumed = true;
|
resumed = true;
|
||||||
|
|
||||||
clientThread.invokeLater(() -> sendChatboxInput(chatType, typedText));
|
clientThread.invoke(() -> sendChatboxInput(chatType, typedText));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
boolean stop = false;
|
boolean stop = false;
|
||||||
@@ -180,7 +180,7 @@ public class CommandManager
|
|||||||
}
|
}
|
||||||
resumed = true;
|
resumed = true;
|
||||||
|
|
||||||
clientThread.invokeLater(() -> sendPrivmsg(target, message));
|
clientThread.invoke(() -> sendPrivmsg(target, message));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class ChatboxInputManager
|
|||||||
this.changed = changed;
|
this.changed = changed;
|
||||||
this.characterLimit = characterLimit;
|
this.characterLimit = characterLimit;
|
||||||
this.open = true;
|
this.open = true;
|
||||||
clientThread.invokeLater(() -> client.runScript(
|
clientThread.invoke(() -> client.runScript(
|
||||||
ScriptID.RUNELITE_CHATBOX_INPUT_INIT,
|
ScriptID.RUNELITE_CHATBOX_INPUT_INIT,
|
||||||
text,
|
text,
|
||||||
defaul
|
defaul
|
||||||
@@ -99,7 +99,7 @@ public class ChatboxInputManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.open = false;
|
this.open = false;
|
||||||
clientThread.invokeLater(() -> client.runScript(
|
clientThread.invoke(() -> client.runScript(
|
||||||
ScriptID.CLOSE_CHATBOX_INPUT,
|
ScriptID.CLOSE_CHATBOX_INPUT,
|
||||||
1,
|
1,
|
||||||
1
|
1
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class ItemManager
|
|||||||
private AsyncBufferedImage loadImage(int itemId, int quantity, boolean stackable)
|
private AsyncBufferedImage loadImage(int itemId, int quantity, boolean stackable)
|
||||||
{
|
{
|
||||||
AsyncBufferedImage img = new AsyncBufferedImage(36, 32, BufferedImage.TYPE_INT_ARGB);
|
AsyncBufferedImage img = new AsyncBufferedImage(36, 32, BufferedImage.TYPE_INT_ARGB);
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
if (client.getGameState().ordinal() < GameState.LOGIN_SCREEN.ordinal())
|
if (client.getGameState().ordinal() < GameState.LOGIN_SCREEN.ordinal())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class SpriteManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
BufferedImage img = getSprite(archive, file);
|
BufferedImage img = getSprite(archive, file);
|
||||||
if (img == null)
|
if (img == null)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class AttackStylesPlugin extends Plugin
|
|||||||
|
|
||||||
if (client.getGameState() == GameState.LOGGED_IN)
|
if (client.getGameState() == GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(this::start);
|
clientThread.invoke(this::start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class CannonPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (cannonPlaced)
|
if (cannonPlaced)
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(this::addCounter);
|
clientThread.invoke(this::addCounter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ public class ChatKeyboardListener implements KeyListener
|
|||||||
replacement = "";
|
replacement = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
clientThread.invokeLater(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, replacement));
|
clientThread.invoke(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, replacement));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_BACK_SPACE:
|
case KeyEvent.VK_BACK_SPACE:
|
||||||
clientThread.invokeLater(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""));
|
clientThread.invoke(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class DemonicGorillaPlugin extends Plugin
|
|||||||
recentBoulders = new ArrayList<>();
|
recentBoulders = new ArrayList<>();
|
||||||
pendingAttacks = new ArrayList<>();
|
pendingAttacks = new ArrayList<>();
|
||||||
memorizedPlayers = new HashMap<>();
|
memorizedPlayers = new HashMap<>();
|
||||||
clientThread.invokeLater(this::reset); // Updates the list of gorillas and players
|
clientThread.invoke(this::reset); // Updates the list of gorillas and players
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class InterfaceStylesPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
overrideSprites();
|
overrideSprites();
|
||||||
overrideWidgetSprites();
|
overrideWidgetSprites();
|
||||||
@@ -92,7 +92,7 @@ public class InterfaceStylesPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
protected void shutDown() throws Exception
|
protected void shutDown() throws Exception
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
restoreWidgetDimensions();
|
restoreWidgetDimensions();
|
||||||
removeGameframe();
|
removeGameframe();
|
||||||
@@ -104,7 +104,7 @@ public class InterfaceStylesPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (config.getGroup().equals("interfaceStyles"))
|
if (config.getGroup().equals("interfaceStyles"))
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
removeGameframe();
|
removeGameframe();
|
||||||
overrideSprites();
|
overrideSprites();
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
overlayManager.add(npcMinimapOverlay);
|
overlayManager.add(npcMinimapOverlay);
|
||||||
keyManager.registerKeyListener(inputListener);
|
keyManager.registerKeyListener(inputListener);
|
||||||
highlights = getHighlights();
|
highlights = getHighlights();
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
skipNextSpawnCheck = true;
|
skipNextSpawnCheck = true;
|
||||||
rebuildAllNpcs();
|
rebuildAllNpcs();
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ public class ReportButtonPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void startUp()
|
public void startUp()
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(this::updateReportButtonTime);
|
clientThread.invoke(this::updateReportButtonTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutDown()
|
public void shutDown()
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
Widget reportButton = client.getWidget(WidgetInfo.CHATBOX_REPORT_TEXT);
|
Widget reportButton = client.getWidget(WidgetInfo.CHATBOX_REPORT_TEXT);
|
||||||
if (reportButton != null)
|
if (reportButton != null)
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
streak = config.streak();
|
streak = config.streak();
|
||||||
setExpeditiousChargeCount(config.expeditious());
|
setExpeditiousChargeCount(config.expeditious());
|
||||||
setSlaughterChargeCount(config.slaughter());
|
setSlaughterChargeCount(config.slaughter());
|
||||||
clientThread.invokeLater(() -> setTask(config.taskName(), config.amount()));
|
clientThread.invoke(() -> setTask(config.taskName(), config.amount()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,7 +459,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
|
|
||||||
if (config.showInfobox())
|
if (config.showInfobox())
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(this::addCounter);
|
clientThread.invoke(this::addCounter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user