package be.yurimoens.runemate.util;

import com.runemate.game.api.hybrid.entities.details.Interactable;
import com.runemate.game.api.hybrid.input.Mouse;
import com.runemate.game.api.hybrid.local.hud.InteractablePoint;
import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;
import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;
import com.runemate.game.api.hybrid.util.calculations.Random;
import com.runemate.game.api.script.Execution;

public class CMouse {

    public static boolean fastInteract(Interactable interactable, String action) {
        if (interactable == null) {
            return false;
        }
        Mouse.move(interactable);
        return interact(interactable, action);
    }

    public static String getTooltip() {
        InterfaceComponent tooltip = Interfaces.getAt(1477, 805, 0);
        if (tooltip == null || !tooltip.isValid()) {
            return "";
        } else {
            return tooltip.getText();
        }
    }

    public static void moveRandomFromPosition() {
        moveRandomFromPosition(40, 40);
    }

    public static void moveRandomFromPosition(int xRandom, int yRandom) {
        Mouse.move(new InteractablePoint((int) Mouse.getPosition().getX() + Random.nextInt(-xRandom, xRandom),(int) Mouse.getPosition().getY() + Random.nextInt(-yRandom, yRandom)));
    }

    public static void moveToMinimap() {
        Mouse.move(Interfaces.getAt(1465, 0).getInteractionPoint());
    }

    private static boolean interact(Interactable interactable, String action) {
        Execution.delayUntil(() -> getTooltip().contains(action), 350, 550);

        if (getTooltip().contains(action)) {
            return interactable.click();
        } else {
            return interactable.interact(action);
        }
    }

}

@@ -146,16 +146,66 @@
 .Mouse;%0A
+import com.runemate.game.api.hybrid.local.Camera;%0A
 import c
@@ -257,24 +257,24 @@
 tablePoint;%0A
-
 import com.r
@@ -517,16 +517,196 @@
 ution;%0A%0A
+import java.awt.*;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.Future;%0Aimport java.util.concurrent.FutureTask;%0A%0A
 public c
@@ -1395,31 +1395,37 @@
 ) %7B%0A        
-Mouse.m
+concurrentlyM
 ove(new Inte
@@ -1507,16 +1507,17 @@
 Random),
+ 
 (int) Mo
@@ -1579,32 +1579,453 @@
 ndom)));%0A    %7D%0A%0A
+    public static Future%3CBoolean%3E concurrentlyMove(Interactable target) %7B%0A        if (target == null %7C%7C target.getInteractionPoint() == null) %7B%0A            return new FutureTask%3C%3E(() -%3E false);%0A        %7D%0A%0A        FutureTask task = new FutureTask(() -%3E Mouse.move(target));%0A%0A        ExecutorService executorService = Executors.newSingleThreadExecutor();%0A%0A        executorService.submit(task);%0A%0A        return task;%0A    %7D%0A%0A
     public stati
@@ -2053,31 +2053,37 @@
 ) %7B%0A        
-Mouse.m
+concurrentlyM
 ove(Interfac

Add concurrentlyMove method.