Class Trade


  • public class Trade
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean acceptTrade()
      Accepts the trade based on which screen is currently open
      static boolean acceptTrade​(int tradeScreen)
      Accepts trade based on which screen you're in
      static boolean addItem​(int itemId, int amount)
      Adds an item from your inventory to trade screen.
      static boolean addItem​(java.lang.String itemName, int amount)
      Adds an item from your inventory to trade screen.
      static boolean addItem​(Item i, int amount)
      Adds an item from your inventory to trade screen.
      static boolean close()
      Closes screen based on which screen is currently open
      static boolean close​(int tradeScreen)
      Closes trade screen depending on which screen you input
      static boolean contains​(boolean myScreen, int... itemIds)
      Checks if your or their trade screen contains all the specified item IDs
      static boolean contains​(boolean myScreen, int amount, int itemId)
      Checks if your or their trade screen contains at least specified amount of specified item ID.
      static boolean contains​(boolean myScreen, int amount, java.lang.String itemName)
      Checks if your or their trade screen contains at least specified amount of specified item name.
      static boolean contains​(boolean myScreen, java.lang.String... itemNames)
      Checks if your or their trade screen contains all items specified
      static boolean declineTrade()
      Declines the trade based on which screen is currently open
      static boolean declineTrade​(int tradeScreen)
      Declines trade for screen specified
      static java.lang.String getFirstTitle()
      Gets the Title of the first trade screen - contains Trading With name
      static Item getItem​(boolean myScreen, int itemId)
      Returns the item from the specified screen with specified ID
      static Item getItem​(boolean myScreen, java.lang.String itemName)
      Returns item specified from the screen with name specified.
      static Item[] getItems​(boolean mine)
      Returns an array of items from the trade screen
      static Item[] getMyItems()
      Gets the items in your trade screen
      static Item[] getTheirItems()
      Gets the items in the other player's trade screen
      static java.lang.String getTradingWith()
      Gets the name of the player you're trading with.
      static int getValue​(boolean myOffer)
      Returns the value of the trade offer
      static boolean hasAcceptedTrade​(TradeUser tradeUser)
      Checks if the user specified has accepted the trade
      static boolean isOpen()
      Checks if trade is open at all
      static boolean isOpen​(int tradeScreen)
      Checks if specified trade screen is open
      static boolean removeItem​(int itemId, int amount)
      Removes an item from the trade screen.
      static boolean removeItem​(java.lang.String itemName, int amount)
      Removes an item from the trade screen.
      static boolean removeItem​(Item i, int amount)
      Removes an item from the trade screen.
      static boolean tradeWithPlayer​(java.lang.String playerName)
      Trades with player specified
      static boolean verifyTrade​(boolean myScreen, Item[] expected)
      Simply checks the given array of Items against the array of items in the screen - must be on the second trade screen
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getItems

        public static Item[] getItems​(boolean mine)
        Returns an array of items from the trade screen
        Parameters:
        mine - true if you want your items, false if you want their items
        Returns:
        An array of Items from the trade screen
      • getMyItems

        public static Item[] getMyItems()
        Gets the items in your trade screen
        Returns:
        get an array of Items
      • getTheirItems

        public static Item[] getTheirItems()
        Gets the items in the other player's trade screen
        Returns:
        an array of Items
      • isOpen

        public static boolean isOpen()
        Checks if trade is open at all
        Returns:
        true if either trade screen is open
      • isOpen

        public static boolean isOpen​(int tradeScreen)
        Checks if specified trade screen is open
        Parameters:
        tradeScreen - 1 or 2
        Returns:
        whether the trade screen is open
      • getFirstTitle

        public static java.lang.String getFirstTitle()
        Gets the Title of the first trade screen - contains Trading With name
        Returns:
        String
      • getTradingWith

        public static java.lang.String getTradingWith()
        Gets the name of the player you're trading with.
        Returns:
        the other player's name
      • acceptTrade

        public static boolean acceptTrade()
        Accepts the trade based on which screen is currently open
        Returns:
        Whether interaction with the Accept Button was successful
      • acceptTrade

        public static boolean acceptTrade​(int tradeScreen)
        Accepts trade based on which screen you're in
        Parameters:
        tradeScreen - 1 or 2
        Returns:
        whether interaction with the accept button was successful
      • hasAcceptedTrade

        public static boolean hasAcceptedTrade​(TradeUser tradeUser)
        Checks if the user specified has accepted the trade
        Parameters:
        tradeUser - Which user to check for acceptance
        Returns:
        true if they have accepted, false if they haven't or if the trade interface isn't open
      • declineTrade

        public static boolean declineTrade()
        Declines the trade based on which screen is currently open
        Returns:
        Whether interaction with the Decline Button was successful
      • declineTrade

        public static boolean declineTrade​(int tradeScreen)
        Declines trade for screen specified
        Parameters:
        tradeScreen - 1 or 2
        Returns:
        whether interaction with decline button was successful
      • close

        public static boolean close()
        Closes screen based on which screen is currently open
        Returns:
        Whether interaction with the close button was successful or true if trade isn't even open
      • close

        public static boolean close​(int tradeScreen)
        Closes trade screen depending on which screen you input
        Parameters:
        tradeScreen - 1 or 2
        Returns:
        whether interaction with the close button was successful
      • verifyTrade

        public static boolean verifyTrade​(boolean myScreen,
                                          Item[] expected)
        Simply checks the given array of Items against the array of items in the screen - must be on the second trade screen
        Parameters:
        myScreen - true if your screen, false if theirs
        expected - array of items to check for
        Returns:
        true if every item in expected is inside the trade screen, with equal amounts
      • contains

        public static boolean contains​(boolean myScreen,
                                       int amount,
                                       java.lang.String itemName)
        Checks if your or their trade screen contains at least specified amount of specified item name.
        Parameters:
        myScreen - true if your screen, false if theirs
        amount - amount to check for
        itemName - item name to check for
        Returns:
        Returns true if the specified screen contains GREATER THAN OR EQUAL TO of item with the specified name.
      • contains

        public static boolean contains​(boolean myScreen,
                                       java.lang.String... itemNames)
        Checks if your or their trade screen contains all items specified
        Parameters:
        myScreen - true if your screen, false if theirs
        itemNames - item names to check for
        Returns:
        Returns true if specified screen contains all the specified item names
      • contains

        public static boolean contains​(boolean myScreen,
                                       int amount,
                                       int itemId)
        Checks if your or their trade screen contains at least specified amount of specified item ID.
        Parameters:
        myScreen - true if your screen, false if theirs
        amount - amount to check for
        itemId - item ID to check for
        Returns:
        Returns true if the specified screen contains GREATER THAN OR EQUAL TO of item with specified ID.
      • contains

        public static boolean contains​(boolean myScreen,
                                       int... itemIds)
        Checks if your or their trade screen contains all the specified item IDs
        Parameters:
        myScreen - true if your screen, false if theirs
        itemIds - item ID's to check for
        Returns:
        Returns true if the specified screen contains all the specified item ID's
      • getValue

        public static int getValue​(boolean myOffer)
        Returns the value of the trade offer
        Parameters:
        myOffer - true for the value of your player's offer, false for the value of the other party
        Returns:
        The value of the offer, or -1 if it's unavailable for any reason
      • getItem

        public static Item getItem​(boolean myScreen,
                                   java.lang.String itemName)
        Returns item specified from the screen with name specified.
        Parameters:
        myScreen - true if your screen, false if theirs
        itemName - Item name
        Returns:
        Item from specified screen with specified name.
      • getItem

        public static Item getItem​(boolean myScreen,
                                   int itemId)
        Returns the item from the specified screen with specified ID
        Parameters:
        myScreen - true if your screen, false if theirs
        itemId - ID of the item you're looking for
        Returns:
        Item from specified screen with specified ID
      • tradeWithPlayer

        public static boolean tradeWithPlayer​(java.lang.String playerName)
        Trades with player specified
        Parameters:
        playerName - name of player to trade with
        Returns:
        whether interaction with player was successful or trade is already opened
      • addItem

        public static boolean addItem​(java.lang.String itemName,
                                      int amount)
        Adds an item from your inventory to trade screen. If the amount is greater than or equal to your current inventory amount, it puts all in.
        Parameters:
        itemName - name of item to add
        amount - amount of item to add
        Returns:
        returns whether interaction with item was successful
      • addItem

        public static boolean addItem​(int itemId,
                                      int amount)
        Adds an item from your inventory to trade screen. If the amount is greater than or equal to your current inventory amount, it puts all in.
        Parameters:
        itemId - ID of item to add
        amount - amount of item to add
        Returns:
        returns whether interaction with item was successful
      • addItem

        public static boolean addItem​(Item i,
                                      int amount)
        Adds an item from your inventory to trade screen. If the amount is greater than or equal to your current inventory amount, it puts all in.
        Parameters:
        i - Item to add
        amount - amount of item to add
        Returns:
        returns whether interaction with item was successful
      • removeItem

        public static boolean removeItem​(java.lang.String itemName,
                                         int amount)
        Removes an item from the trade screen. If the amount is greater than or equal to the current amount in trade, it removes ALL
        Parameters:
        itemName - name of item to removeConnector
        amount - amount of item to removeConnector
        Returns:
        Whether interaction was successful
      • removeItem

        public static boolean removeItem​(int itemId,
                                         int amount)
        Removes an item from the trade screen. If the amount is greater than or equal to the current amount in trade, it removes ALL
        Parameters:
        itemId - ID of item to removeConnector
        amount - amount of item to removeConnector
        Returns:
        Whether interaction was successful
      • removeItem

        public static boolean removeItem​(Item i,
                                         int amount)
        Removes an item from the trade screen. If the amount is greater than or equal to the current amount in trade, it removes ALL
        Parameters:
        i - Item to removeConnector
        amount - amount of item to removeConnector
        Returns:
        Whether interaction was successful