Skip to content

Commit b4550bc

Browse files
author
debajit gayen
committed
Add timestamp to idler
1 parent ee74c1a commit b4550bc

File tree

1 file changed

+9
-6
lines changed
  • src/main/java/com/chromascape/utils/actions

1 file changed

+9
-6
lines changed

src/main/java/com/chromascape/utils/actions/Idler.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public class Idler {
2828
* Waits until either the specified timeout has elapsed or until the client chatbox reports that
2929
* the player is idle.
3030
*
31-
* <p>Specifically, this method monitors the "Latest Message" tab in the chatbox for a red message
32-
* containing the substring {@code "idle"}, which typically appears in the client message {@code
33-
* "You are now idle!"}.
31+
* <p>Specifically, this method monitors the "Latest Message" zone in the chatbox for a red message
32+
* containing the substring {@code "idle"} or {@code "moving"}, which typically appears when
33+
* using the Idle Notifier plugin
3434
*
3535
* @param base the active {@link BaseScript} instance, usually passed as {@code this}
3636
* @param timeoutSeconds the maximum number of seconds to remain idle before continuing
@@ -43,9 +43,12 @@ public static void waitUntilIdle(BaseScript base, int timeoutSeconds) {
4343
while (Instant.now().isBefore(deadline)) {
4444
Rectangle latestMessage = base.controller().zones().getChatTabs().get("Latest Message");
4545
ColourObj red = ColourInstances.getByName("ChatRed");
46-
String ocr = Ocr.extractText(latestMessage, "Plain 12", red, true);
47-
if ((ocr.contains("moving") || ocr.contains("idle")) && !ocr.equals(lastMessage)) {
48-
lastMessage = ocr;
46+
ColourObj black = ColourInstances.getByName("Black");
47+
String idleText = Ocr.extractText(latestMessage, "Plain 12", red, true);
48+
String timeStamp = Ocr.extractText(latestMessage, "Plain 12", black, true);
49+
logger.info(String.format("Idle: %s - %s", idleText, timeStamp));
50+
if ((idleText.contains("moving") || idleText.contains("idle")) && !timeStamp.equals(lastMessage)) {
51+
lastMessage = timeStamp;
4952
return;
5053
}
5154
}

0 commit comments

Comments
 (0)