runelite-client: Rename ClientThread::invokeLater to invoke

And add a invokeLater that actually invokes later all of the time
This commit is contained in:
Max Weber
2018-07-29 15:35:34 -06:00
parent 0217d5a6af
commit 0e9417963b
13 changed files with 42 additions and 23 deletions

View File

@@ -41,9 +41,9 @@ public class ClientThread
@Inject
private Client client;
public void invokeLater(Runnable r)
public void invoke(Runnable r)
{
invokeLater(() ->
invoke(() ->
{
r.run();
return true;
@@ -54,7 +54,7 @@ public class ClientThread
* 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
*/
public void invokeLater(BooleanSupplier r)
public void invoke(BooleanSupplier r)
{
if (client.isClientThread())
{
@@ -64,6 +64,25 @@ public class ClientThread
}
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);
}
@@ -85,7 +104,7 @@ public class ClientThread
}
catch (Throwable e)
{
log.warn("Exception in invokeLater", e);
log.warn("Exception in invoke", e);
}
if (remove)
{

View File

@@ -141,7 +141,7 @@ public class CommandManager
}
resumed = true;
clientThread.invokeLater(() -> sendChatboxInput(chatType, typedText));
clientThread.invoke(() -> sendChatboxInput(chatType, typedText));
}
};
boolean stop = false;
@@ -180,7 +180,7 @@ public class CommandManager
}
resumed = true;
clientThread.invokeLater(() -> sendPrivmsg(target, message));
clientThread.invoke(() -> sendPrivmsg(target, message));
}
};

View File

@@ -82,7 +82,7 @@ public class ChatboxInputManager
this.changed = changed;
this.characterLimit = characterLimit;
this.open = true;
clientThread.invokeLater(() -> client.runScript(
clientThread.invoke(() -> client.runScript(
ScriptID.RUNELITE_CHATBOX_INPUT_INIT,
text,
defaul
@@ -99,7 +99,7 @@ public class ChatboxInputManager
return;
}
this.open = false;
clientThread.invokeLater(() -> client.runScript(
clientThread.invoke(() -> client.runScript(
ScriptID.CLOSE_CHATBOX_INPUT,
1,
1

View File

@@ -216,7 +216,7 @@ public class ItemManager
private AsyncBufferedImage loadImage(int itemId, int quantity, boolean stackable)
{
AsyncBufferedImage img = new AsyncBufferedImage(36, 32, BufferedImage.TYPE_INT_ARGB);
clientThread.invokeLater(() ->
clientThread.invoke(() ->
{
if (client.getGameState().ordinal() < GameState.LOGIN_SCREEN.ordinal())
{

View File

@@ -87,7 +87,7 @@ public class SpriteManager
return;
}
clientThread.invokeLater(() ->
clientThread.invoke(() ->
{
BufferedImage img = getSprite(archive, file);
if (img == null)

View File

@@ -99,7 +99,7 @@ public class AttackStylesPlugin extends Plugin
if (client.getGameState() == GameState.LOGGED_IN)
{
clientThread.invokeLater(this::start);
clientThread.invoke(this::start);
}
}

View File

@@ -152,7 +152,7 @@ public class CannonPlugin extends Plugin
{
if (cannonPlaced)
{
clientThread.invokeLater(this::addCounter);
clientThread.invoke(this::addCounter);
}
}
}

View File

@@ -82,11 +82,11 @@ public class ChatKeyboardListener implements KeyListener
replacement = "";
}
clientThread.invokeLater(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, replacement));
clientThread.invoke(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, replacement));
}
break;
case KeyEvent.VK_BACK_SPACE:
clientThread.invokeLater(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""));
clientThread.invoke(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""));
break;
}
}

View File

@@ -97,7 +97,7 @@ public class DemonicGorillaPlugin extends Plugin
recentBoulders = new ArrayList<>();
pendingAttacks = new ArrayList<>();
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

View File

@@ -80,7 +80,7 @@ public class InterfaceStylesPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
clientThread.invokeLater(() ->
clientThread.invoke(() ->
{
overrideSprites();
overrideWidgetSprites();
@@ -92,7 +92,7 @@ public class InterfaceStylesPlugin extends Plugin
@Override
protected void shutDown() throws Exception
{
clientThread.invokeLater(() ->
clientThread.invoke(() ->
{
restoreWidgetDimensions();
removeGameframe();
@@ -104,7 +104,7 @@ public class InterfaceStylesPlugin extends Plugin
{
if (config.getGroup().equals("interfaceStyles"))
{
clientThread.invokeLater(() ->
clientThread.invoke(() ->
{
removeGameframe();
overrideSprites();

View File

@@ -188,7 +188,7 @@ public class NpcIndicatorsPlugin extends Plugin
overlayManager.add(npcMinimapOverlay);
keyManager.registerKeyListener(inputListener);
highlights = getHighlights();
clientThread.invokeLater(() ->
clientThread.invoke(() ->
{
skipNextSpawnCheck = true;
rebuildAllNpcs();

View File

@@ -80,13 +80,13 @@ public class ReportButtonPlugin extends Plugin
@Override
public void startUp()
{
clientThread.invokeLater(this::updateReportButtonTime);
clientThread.invoke(this::updateReportButtonTime);
}
@Override
public void shutDown()
{
clientThread.invokeLater(() ->
clientThread.invoke(() ->
{
Widget reportButton = client.getWidget(WidgetInfo.CHATBOX_REPORT_TEXT);
if (reportButton != null)

View File

@@ -179,7 +179,7 @@ public class SlayerPlugin extends Plugin
streak = config.streak();
setExpeditiousChargeCount(config.expeditious());
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())
{
clientThread.invokeLater(this::addCounter);
clientThread.invoke(this::addCounter);
}
else
{