Class Mouse


  • public class Mouse
    extends java.lang.Object

    Please note: In general you do not have to concern yourself with these methods.
    The methods here will be called from interact methods by the API (such as the interact method in RectangleDestination)

    • Method Detail

      • setMouseMovementAlgorithm

        @Deprecated
        public static void setMouseMovementAlgorithm​(MouseMovementAlgorithm algorithm)
        Sets the mouse algorithm the client uses.
        Parameters:
        algorithm - This is the algorithm that the client will use during mouse move events
      • setMouseAlgorithm

        public static void setMouseAlgorithm​(MouseAlgorithm algorithm)
        Sets the mouse algorithm implementation the client uses for mouse movement and clicks
        Parameters:
        algorithm - MouseAlgorithm implementation
      • getMouseMovementAlgorithm

        @Deprecated
        public static MouseMovementAlgorithm getMouseMovementAlgorithm()
        Deprecated.
        Returns the currently set mouse algorithm.
        Returns:
        The currently set mouse algorithm
      • setPosition

        public static void setPosition​(int x,
                                       int y)
      • getUIDCount

        public static int getUIDCount()
      • getRawOnCursorUIDs

        public static long[] getRawOnCursorUIDs()
      • getOnCursorUIDs

        public static long[] getOnCursorUIDs()
      • getIdleTime

        public static int getIdleTime()
        Gets idle time.
        Returns:
        the idle time.
      • getLastClicked

        public static java.awt.Point getLastClicked()
        Gets last clicked position by the client
        Returns:
        the position of the last mouse click the client performed
      • getLastClickedTime

        public static long getLastClickedTime()
        Returns the last click time in milliseconds. If there haven't been any clicks it will return 0. This method only counts clicks sent by the client itself, manual mouse clicks won't be reflected by this.
        Returns:
        Last click time in milliseconds, or 0 if there haven't been any clicks since client start
      • getLastClickedX

        public static int getLastClickedX()
        Gets last clicked x position by the client
        Returns:
        the x position of the last mouse click the client performed
      • getLastClickedY

        public static int getLastClickedY()
        Gets last clicked y position by the client
        Returns:
        the y position of the last mouse click the client performed
      • getX

        public static int getX()
        Gets the current mouse X coordinate of the mouse
        Returns:
        X coordinate of the mouse
      • getY

        public static int getY()
        Gets the current mouse Y coordinate of the mouse
        Returns:
        Y coordinate of the mouse
      • getPosition

        public static java.awt.Point getPosition()
        Gets the current mouse position
        Returns:
        Point of the position of the mouse
      • getMouseSettings

        public static MouseSettings getMouseSettings()
        Grabs the MouseSettings
      • getCrosshairColorID

        public static int getCrosshairColorID()
        Gets the current crosshair color of the mouse.
        Returns:
        0, 1, 2
      • getCrosshairState

        public static CrosshairState getCrosshairState()
        Gets the current crosshair color of the mouse.
        Returns:
        Crosshair state
      • getLastCrosshairColorID

        public static int getLastCrosshairColorID()
        Gets the crosshair color from the last click.
        Returns:
        0, 1, 2
      • setLastCrosshairColorID

        public static void setLastCrosshairColorID​(int last)
        Set internally during mouse click operations
        Parameters:
        last -
      • getEntitiesOnCursor

        public static java.util.List<Entity> getEntitiesOnCursor()
        Gets a list of the entities that the cursor is hovering over
        Returns:
        list of entities
      • getTileOnCursor

        public static Tile getTileOnCursor()
        Gets the closest tile that it on the mouse's cursor
        Returns:
        the closest tile if one exists, null otherwise
      • click

        public static boolean click​(java.awt.Rectangle destination)
        Moves mouse to rectangle, and preforms left click.
        Parameters:
        destination - The rectangle destination you wish click.
        Returns:
        true if clicked successfully.
      • click

        public static boolean click​(java.awt.Rectangle destination,
                                    boolean right)
        Moves mouse to rectangle, and preforms desired type of click, as determines by arguments.
        Parameters:
        destination - The rectangle destination you wish click.
        right - The type of click you wish to preform, right click if true, otherwise left click.
        Returns:
        true if clicked successfully.
      • click

        public static boolean click​(java.awt.Point destination)
        Moves mouse to point, and preforms left click.
        Parameters:
        destination - The point destination you wish click.
        Returns:
        true if clicked successfully.
      • click

        public static boolean click​(java.awt.Point destination,
                                    boolean right)
        Moves mouse to point, and preforms desired type of click, as determines by arguments.
        Parameters:
        destination - The point destination you wish click.
        right - The type of click you wish to preform, right click if true, otherwise left click.
        Returns:
        true if clicked successfully.
      • click

        public static boolean click​(Entity destination)
        Moves mouse to entity, and preforms left click.
        Parameters:
        destination - The Entity destination you wish click.
        Returns:
        true if clicked successfully.
      • click

        public static boolean click​(Entity destination,
                                    boolean right)
        Moves mouse to entity, and preforms desired type of click, as determines by arguments.
        Parameters:
        destination - The Entity destination you wish click.
        right - The type of click you wish to preform, right click if true, otherwise left click.
        Returns:
        true if clicked successfully.
      • click

        public static boolean click​(AbstractMouseDestination destination,
                                    boolean right)
        Moves mouse to destination, and preforms desired type of click, as determines by arguments.
        Parameters:
        destination - The destination you wish click.
        right - The type of click you wish to preform, right click if true, otherwise left click.
        Returns:
        true if clicked successfully.
      • click

        public static boolean click()
        Triggers a left click
        Returns:
        true if clicked successfully
      • click

        public static boolean click​(boolean right)
        Triggers a left click
        Returns:
        true if clicked successfully
      • click

        public static boolean click​(MouseButton mode)
        Triggers a click as determined by the MouseButton
        Returns:
        true if clicked successfully
      • click

        public static boolean click​(AbstractMouseDestination destination)
        Moves mouse to destination, and preforms left click.
        Parameters:
        destination - The destination you wish click.
        Returns:
        true if clicked successfully.
      • mouseDownUntil

        public static void mouseDownUntil​(int timeout,
                                          Condition c)
        Hold mouse down until condition is true, with specified timeout Does not create its own thread!
        Parameters:
        timeout - timeout in milliseconds
        c - condition to check
      • scrollUntil

        public static void scrollUntil​(boolean up,
                                       int timeout,
                                       Condition c)
        Scrolls mouse until the condition is true, with specified timeout
        Parameters:
        up - true to scroll up
        timeout - timeout in milliseconds
        c - condition to check
      • scroll

        public static boolean scroll​(boolean up,
                                     int timeout,
                                     Condition c)
        Scrolls mouse until the condition is true, with specified timeout
        Parameters:
        up - true to scroll up
        timeout - timeout in milliseconds
        c - condition to check
      • scrollDown

        public static boolean scrollDown​(int timeout,
                                         Condition c)
        Scrolls mouse wheel down until Condition is true or timeout is met
        Parameters:
        timeout - timeout in milliseconds
        c - Condition to check
      • scrollUp

        public static boolean scrollUp​(int timeout,
                                       Condition c)
        Scrolls mouse wheel up until Condition is true or timeout is met
        Parameters:
        timeout - timeout in milliseconds
        c - Condition to check
      • move

        public static boolean move​(java.awt.Rectangle rectangle)
        Moves the mouse to a specified rectangle
        Parameters:
        rectangle - The rectangle to move the mouse to.
        Returns:
        true if mouse moved successfully
      • move

        public static boolean move​(Entity entity)
        Moves the mouse to a destination
        Parameters:
        entity - the Entity which to move the mouse to.
        Returns:
        true if mouse moved successfully, otherwise false.
      • move

        public static boolean move​(java.awt.Point point)
        Moves the mouse to a specified point
        Parameters:
        point - The point to move the mouse to.
        Returns:
        true if mouse moved successfully
      • move

        public static boolean move​(Tile tile)
      • move

        public static boolean move()
        Moves the mouse to random gaussian distributed destination near the location of your current position if the mouse is on screen, otherwise will base position from center of canvas.
        Returns:
        true if mouse moved successfully, otherwise false.
      • drag

        public static boolean drag​(java.awt.Point point)
        Drags the mouse from current point to the given point
        Parameters:
        point - Point to drag mouse to
        Returns:
        True if successfully dragged, else false
      • drag

        public static boolean drag​(Tile tile)
        Drags the mouse from the current point to the given Tile
        Parameters:
        tile - Tile to drag mouse to
        Returns:
        True if successfully dragged, else false
      • drag

        public static boolean drag​(Entity entity)
        Drags the mouse from the current position to the given Entity
        Parameters:
        entity - Entity to drag mouse to
        Returns:
        True if successfully dragged, else false
      • drag

        public static boolean drag​(java.awt.Rectangle rectangle)
        Drags the mouse from current position to the given Rectangle
        Parameters:
        rectangle - The rectangle to drag the mouse to.
        Returns:
        True if successfully dragged, else false
      • drag

        public static boolean drag​(AbstractMouseDestination<?> destination)
        Drags the mouse to the given AbstractMouseDestination Automatically temporarily disables mouse hop if enabled
        Parameters:
        destination - AbstractMouseDestination to drag mouse to
        Returns:
        True if successfully dragged, else false
      • moveMouseOutsideScreen

        @Deprecated
        public static boolean moveMouseOutsideScreen()
        Deprecated.
      • moveOutsideScreen

        public static boolean moveOutsideScreen()
        Moves the mouse outside the screen and sends a focus lost event to the canvas See moveOutsideScreen(boolean) with param true
      • moveOutsideScreen

        public static boolean moveOutsideScreen​(boolean loseFocus)
        Moves mouse outside the screen, losing focus based on loseFocus parameter Does not run if mouse is not in screen If loseFocus is true see loseFocus(int) with a default time of random(100,3000)
        Parameters:
        loseFocus - Boolean whether to lose focus or not
        Returns:
        True if mouse already not in screen, or if successfully moves out of screen and if required loses focus
      • loseFocus

        public static boolean loseFocus​(int sleepBeforeLoseFocus)
        Moves mouse outside of screen, sleeps for the given amount in ms, then calls a focus lost event Does not run if client already doesn't have focus If Mouse is already outside of screen, it will not re-move it outside of screen
        Parameters:
        sleepBeforeLoseFocus - MS to sleep before calling focus lost
        Returns:
        True if client already is not focused or if mouse successfully moves outside of screen and focus is lost
      • isMouseInScreen

        public static boolean isMouseInScreen()
        Method to determine if the mouse cursor is in the screen.
        Returns:
        True if mouse is in the screen
      • hop

        public static boolean hop​(java.awt.Point destination)
        Method to 'hop' the mouse position, instantly.
        Parameters:
        destination - Point to jump to
        Returns:
        True if succeeded.
      • hop

        public static boolean hop​(int x,
                                  int y)
        Method to 'hop' the mouse position, instantly.
        Parameters:
        x - X-coordinate
        y - Y-coordinate
        Returns:
        True if succeeded.
      • getPointOutsideScreen

        public static java.awt.Point getPointOutsideScreen()
        Returns a random point slightly off of the game canvas
        Returns:
        a randomized Point outside the game canvas
      • setLastClickPosition

        public static void setLastClickPosition​(java.awt.Point lastClickPosition2)
      • getLastMouseMagnitude

        public static double getLastMouseMagnitude()
      • setLastMouseMagnitude

        public static void setLastMouseMagnitude​(double lastMouseMagnitude2)
      • getLastMouseDirection

        public static double getLastMouseDirection()
      • setLastMouseDirection

        public static void setLastMouseDirection​(double lastMouseDirection2)
      • getLastMouseMoveTime

        public static long getLastMouseMoveTime()
      • setLastMouseMoveTime

        public static void setLastMouseMoveTime​(long lastMouseMoveTime2)
      • getMouseMoveResetTimeMillis

        public static long getMouseMoveResetTimeMillis()
      • isAlwaysHop

        public static boolean isAlwaysHop()
      • setAlwaysHop

        public static void setAlwaysHop​(boolean alwaysHop)
      • getRSLastClickedX

        public static int getRSLastClickedX()
      • getRSLastClickedY

        public static int getRSLastClickedY()
      • getCurrentModifiers

        public static int getCurrentModifiers()
        Gets the current event modifiers from holding mouse buttons
      • addModifierFromClick

        public static void addModifierFromClick​(MouseButton mode)
        Adds to the current modifier based on the MouseButton.getMask() called before a MouseEvent.MOUSE_PRESSED event
      • removeModifierFromClick

        public static void removeModifierFromClick​(MouseButton mode)
        Removes the mask given by MouseButton.getMask(), called after a MouseEvent.MOUSE_CLICKED event
      • toggleButtonPressed

        public static void toggleButtonPressed​(MouseButton button,
                                               boolean pressed)
      • isButtonPressed

        public static boolean isButtonPressed​(MouseButton button)
      • resetButtons

        public static void resetButtons()
      • setMouseDragging

        public static void setMouseDragging​(boolean dragging)
      • isForceDrag

        public static boolean isForceDrag()
      • setForceDrag

        public static void setForceDrag​(boolean forceDrag)
      • isMouseHeldDown

        public static boolean isMouseHeldDown()
      • isMouseDragging

        public static boolean isMouseDragging()
      • getMouseAlgorithm

        public static MouseAlgorithm getMouseAlgorithm()
        Returns the currently set