Class WidgetEntity

  • All Implemented Interfaces:
    Interactable<net.runelite.api.widgets.Widget>

    public class WidgetEntity
    extends AbstractEntity<net.runelite.api.widgets.Widget>
    • Constructor Summary

      Constructors 
      Constructor Description
      WidgetEntity​(Context ctx, net.runelite.api.widgets.Widget raw)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getId()
      The item ID for the wrapped game entity
      java.lang.String getName()
      The game entities name.
      boolean interact​(java.lang.String action)
      Interacts with the entity using the given action verb.
      boolean interact​(java.lang.String menu, java.lang.String action)
      Interacts with a widget by invoking a specified menu and action.
      boolean isVisible()
      Checks if the widget is currently visible.
      boolean matches​(java.lang.String search, boolean exact)
      Checks if the widget text, name, or actions match the input.
      boolean useOn​(net.runelite.api.GameObject gameObject)
      Uses a widget on a Game Object (i.e.
      boolean useOn​(net.runelite.api.NPC npc)
      Uses a widget on an NPC (i.e.
      boolean useOn​(net.runelite.api.widgets.Widget destinationWidget)
      Uses a widget on another widget.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WidgetEntity

        public WidgetEntity​(Context ctx,
                            net.runelite.api.widgets.Widget raw)
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from interface: Interactable
        The game entities name.
        Returns:
        The name of the game entity i.e. NPC name for NPC's, item name for ContainerItem's, and GameObject name for various game objects.
      • getId

        public int getId()
        Description copied from interface: Interactable
        The item ID for the wrapped game entity
        Returns:
        int Item id
      • matches

        public boolean matches​(java.lang.String search,
                               boolean exact)
        Checks if the widget text, name, or actions match the input.
        Parameters:
        search - The search string to match
        exact - True if only exact matches of the search string should be accepted
        Returns:
        true if there is a match within the search string for a specific widget and false otherwise
      • interact

        public boolean interact​(java.lang.String action)
        Description copied from interface: Interactable
        Interacts with the entity using the given action verb.
        Parameters:
        action - The menu action to trigger (e.g., "Attack", "Talk-to", "Take")
        Returns:
        true if the interaction packet was successfully queued/sent
      • interact

        public boolean interact​(java.lang.String menu,
                                java.lang.String action)
        Interacts with a widget by invoking a specified menu and action.

        This method attempts to perform an interaction on a widget identified by its underlying raw representation. If the raw widget is null, the method will immediately return false. Otherwise, it delegates the interaction process to the interaction manager.

        Parameters:
        menu - The menu option to be selected during the interaction. For example, this could represent a contextual menu option like "Use" or "Examine".
        action - The specific action to be invoked within the selected menu option. This typically represents the intended effect of the interaction, such as "Wield".
        Returns:
        true if the interaction process was initiated successfully; false if the underlying widget was null and no action was performed.
      • isVisible

        public boolean isVisible()
        Checks if the widget is currently visible.

        A widget is considered visible if it is not marked as hidden in its underlying raw state.

        Returns:
        true if the widget is visible; false otherwise.
      • useOn

        public boolean useOn​(net.runelite.api.widgets.Widget destinationWidget)
        Uses a widget on another widget. (i.e. High Alchemy)
        Parameters:
        destinationWidget - The destination widget to use this entity on
        Returns:
        True if the action is successful and false otherwise.
      • useOn

        public boolean useOn​(net.runelite.api.NPC npc)
        Uses a widget on an NPC (i.e. Crumble Undead Spell on the Undead Spawn from Vorkath)
        Parameters:
        npc - NPC to use the widget on.
        Returns:
        True if the action was successful and false otherwise.
      • useOn

        public boolean useOn​(net.runelite.api.GameObject gameObject)
        Uses a widget on a Game Object (i.e. Bones on the Chaos Altar)
        Parameters:
        gameObject - The Game Object to use the widget on.
        Returns:
        True if the action was successful and false otherwise.