Merge pull request #66 from Parabot/feature/accept-trade

[Feature] Accept Trade
This commit is contained in:
Jeroen Ketelaar
2016-12-19 13:22:06 +01:00
committed by GitHub
@@ -24,7 +24,7 @@ public class Trading {
* @return True if the requested screen is open * @return True if the requested screen is open
*/ */
public static boolean isOpen(boolean first){ public static boolean isOpen(boolean first){
return Loader.getClient().getOpenInterfaceId() == (first ? settings.get("first_trade_interface_id") : settings.get("second_trade_interface_id")); return Interfaces.getOpenInterfaceId() == (first ? settings.get("first_trade_interface_id") : settings.get("second_trade_interface_id"));
} }
/** /**
@@ -32,7 +32,7 @@ public class Trading {
* @return True if open, false if not open * @return True if open, false if not open
*/ */
public static boolean isOpen(){ public static boolean isOpen(){
return Loader.getClient().getOpenInterfaceId() == settings.get("first_trade_interface_id") || Loader.getClient().getOpenInterfaceId() == settings.get("second_trade_interface_id"); return Interfaces.getOpenInterfaceId() == settings.get("first_trade_interface_id") || Interfaces.getOpenInterfaceId() == settings.get("second_trade_interface_id");
} }
/** /**
@@ -75,7 +75,7 @@ public class Trading {
private static int[] getItemIDs(int interfaceID) { private static int[] getItemIDs(int interfaceID) {
Interface i; Interface i;
if ((i = Loader.getClient().getInterfaceCache()[interfaceID]) != null) { if ((i = Interfaces.getInterfaces()[interfaceID]) != null) {
int[] items; int[] items;
if ((items = i.getItems()) != null && items.length > 0) { if ((items = i.getItems()) != null && items.length > 0) {
return items; return items;
@@ -87,7 +87,7 @@ public class Trading {
private static int[] getItemStacks(int interfaceID) { private static int[] getItemStacks(int interfaceID) {
Interface i; Interface i;
if ((i = Loader.getClient().getInterfaceCache()[interfaceID]) != null) { if ((i = Interfaces.getInterfaces()[interfaceID]) != null) {
int[] stacks; int[] stacks;
if ((stacks = i.getStackSizes()) != null && stacks.length > 0) { if ((stacks = i.getStackSizes()) != null && stacks.length > 0) {
return stacks; return stacks;
@@ -97,22 +97,32 @@ public class Trading {
} }
/** /**
* TODO Figure a way to use packets instead * TODO: Add the id into the settings
*
* Accepts the offer and hits the button to continue to the second screen * Accepts the offer and hits the button to continue to the second screen
*/ */
public static void acceptOffer() { public static void acceptOffer() {
Time.sleep(500, 750); Menu.clickButton(3420);
Mouse.getInstance().click(260, 190, true); Time.sleep(new SleepCondition() {
Time.sleep(500, 750); @Override
public boolean isValid() {
return Interfaces.getOpenInterfaceId() == settings.get("second_trade_interface_id");
}
}, 2500);
} }
/** /**
* TODO Figure a way to use packets instead * TODO: Add the id into the settings
*
* Accepts the trade and hits the button to complete the trade * Accepts the trade and hits the button to complete the trade
*/ */
public static void acceptTrade() { public static void acceptTrade() {
Time.sleep(500, 750); Menu.clickButton(3546);
Mouse.getInstance().click(230, 310, true); Time.sleep(new SleepCondition() {
Time.sleep(500, 750); @Override
public boolean isValid() {
return !isOpen();
}
}, 2500);
} }
} }