Class Trade


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

      Constructors 
      Constructor Description
      Trade()
      Deprecated.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated 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 of 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 specified screen with specified ID
      static Item getItem​(boolean myScreen, java.lang.String itemName)
      Returns item specified from screen specified 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 Trade getTrade()
      Deprecated.
      static java.lang.String getTradingWith()
      Gets the name of the player you're trading with.
      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 second trade screen
      • Methods inherited from class java.lang.Object

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

      • Trade

        @Deprecated
        public Trade()
        Deprecated.
    • Method Detail

      • getTrade

        @Deprecated
        public static Trade getTrade()
        Deprecated.
      • 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:
      • 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 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 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 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 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 of 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 specified screen contains GREATER THAN OR EQUAL TO of item with 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 of 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 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 of specified item IDs
        Parameters:
        myScreen - true if your screen, false if theirs
        itemIds - item ID's to check for
        Returns:
        Returns true if specified screen contains all of specified item ID's
      • getItem

        public static Item getItem​(boolean myScreen,
                                   java.lang.String itemName)
        Returns item specified from screen specified 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 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 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 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 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 amount is greater than or equal to 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 amount is greater than or equal to 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 amount is greater than or equal to current amount in trade, it removes ALL
        Parameters:
        i - Item to removeConnector
        amount - amount of item to removeConnector
        Returns:
        Whether interaction was successful