Class MenuRowBuilder


  • public class MenuRowBuilder
    extends java.lang.Object
    Created by Nezz on 7/10/2022 Utility class to help create MenuRows to use in the new menu interactions
    • Constructor Detail

      • MenuRowBuilder

        public MenuRowBuilder()
    • Method Detail

      • buildFromObject

        public static MenuRow buildFromObject​(GameObject gameObject,
                                              java.lang.String action)
        Builds a MenuRow for a given GameObject and a given Action
        Parameters:
        gameObject - GameObject to build the MenuRow from
        action - Action to build the MenuRow with and find the opcode
        Returns:
        MenuRow for GameObject or null if GameObject is null, unable to find actions, or unable to find opcode
      • buildFromNpc

        public static MenuRow buildFromNpc​(NPC npc,
                                           java.lang.String action)
        Builds MenuRow for given NPC with given action
        Parameters:
        npc - NPC to build MenuRow from
        action - Action to build MenuRow with and to find opcode
        Returns:
        MenuRow for NPC or null if NPC is null, unable to find NPC action, or unable to find correct opcode
      • buildFromPlayer

        public static MenuRow buildFromPlayer​(Player player,
                                              java.lang.String action)
        Builds a MenuRow from a given Player with a given action
        Parameters:
        player - Player to build MenuRow from
        action - Action to build MenuRow with
        Returns:
        MenuRow for Player or null if player is null, unable to find player actions, or unable to find opcode.
      • buildFromGroundItem

        public static MenuRow buildFromGroundItem​(GroundItem groundItem,
                                                  java.lang.String action)
        Builds a menu row from a ground item with a given action
        Parameters:
        groundItem - GroundItem to build menu row with
        action - Action to find opcode with
        Returns:
        MenuRow for ground item with given action or null if opcode is not found
      • buildFromEntity

        public static MenuRow buildFromEntity​(Entity entity,
                                              java.lang.String action)
        Builds a menu row from a given entity with the provided action. Passes the method along to the appropriate entity builder
        Parameters:
        entity - Entity to build menu row from (Player, GameObject, NPC, GroundItem are supported)
        action - Action for the entity
        Returns:
        MenuRow built from entity, null if unsupported entity
      • buildForInventory

        public static MenuRow buildForInventory​(int slot,
                                                java.lang.String action)
        This is for normal inventory usage, adjusts for bank, GE, and shop
        Parameters:
        slot - slot of the item to use the action on
        action - action to call the item on
        Returns:
        Menu row built from information, otherwise null if no item in slot or if it fails to find the opcode or inventory widget
      • buildForBank

        public static MenuRow buildForBank​(int slot,
                                           java.lang.String action)
        Builds a MenuRow for a bank withdraw/deposit action
        Parameters:
        slot - Slot value for the bank to withdraw (on withdrawal remember with multiple tabs 'slot 0' is in tab 1, not the main tab)
        action - Action to use on the item
        Returns:
        The MenuRow for the given action on the given item slot, null if it can't find the widget or item
      • buildForSpell

        public static MenuRow buildForSpell​(Spell spell)
      • buildForSpell

        public static MenuRow buildForSpell​(Spell spell,
                                            java.lang.String action)
      • buildForWidget

        public static MenuRow buildForWidget​(WidgetChild widget,
                                             java.lang.String action,
                                             java.lang.String object)
        Builds a MenuRow for a given WidgetChild with the given action and object.
        Parameters:
        widget - WidgetChild to build the MenuRow from
        action - Action to find on the widget
        object - Object passed to the MenuRow (unused in calculations)
        Returns:
        MenuRow calculated for the action on the widget (index 0), null if unable to find opcode for the action
      • removeFormat

        public static java.lang.String removeFormat​(java.lang.String action,
                                                    java.util.regex.Pattern... patterns)
      • removeFormatting

        public static java.lang.String removeFormatting​(java.lang.String action)