This is by no means perfect and it isn't even tested. Wrote it in 5 minutes to give you an idea of a simple flow. I don't recommend copy/pasting it as I left some stuff out that makes it pretty susceptible to luring.
int trade(String target, String itemExpected, int amountExpected, String toSend, int amountToSend, boolean send) {
if(!trade.isCurrentlyTrading()) { // Accepting the trade via chatbox will be in the listener...
if(send) {
Player player = players.closest(target);
if (player != null) {
if (player.interact("Trade with")) {
sleepWhile(new Condition() {
@Override
public boolean evaluate() {
return !trade.isCurrentlyTrading();
}
}, 30000); // Waits for a max of 30 seconds
return 100;
}
}
}
} else {
if(trade.isFirstInterfaceOpen()) {
if(!trade.getOurOffers().contains(toSend)) {
trade.offer(toSend, amountToSend);
} else if(trade.getOurOffers().getItem(toSend).getAmount() != amountToSend) {
if(trade.getOurOffers().contains(toSend)) {
trade.removeAll(toSend);
} else {
trade.offer(toSend, amountToSend);
}
} else if(trade.getTheirOffers().contains(itemExpected) && trade.getTheirOffers().getItem(itemExpected).getAmount() >= amountExpected) {
trade.acceptTrade();
}
} else if(trade.isSecondInterfaceOpen()) {
//Check their stuff just in case
if(trade.getTheirOffers().contains(itemExpected) && trade.getTheirOffers().getItem(itemExpected).getAmount() >= amountExpected) {
trade.acceptTrade();
}
}
}
return 1000;
}
//Usage
trade("Bot123321", "Coins", 5000000, "Cowhide", 342, true); //Do this for the bot that will SEND the trade
trade(null, "Cowhide", 342, "Coins", 5000000, false); // This is prone to people abusing it, but you can figure out why...
@Override
public void onMessage(Message g) throws InterruptedException {
if(g.getType().equals(Message.MessageType.RECEIVE_TRADE)) {
mouse.click(0,0,false); //this is for the bot receiving the trade. you COULD probably just have them trade each other if you want to make it easier (Also, figure out the x,y yourself)
}
}