I just tried it again, once, and it somehow worked now. Did nothing differently. Anyway, here is the code, if it's still relevant for you.
Output.logMessage("cp-3");
// find player
Player tradePartner = null;
new ConditionalSleep(10100,Shared.getRandomCheckFrequency(760, 2400)) {
@Override
public boolean condition() {
return parent.getPlayers().closest(playerName) != null;
}
}.sleep();
Output.logMessage("cp-2");
try{
tradePartner = parent.getPlayers().closest(playerName);
}
catch (NullPointerException e){
Output.logError("couldn't find player (1): " + playerName);
return false;
}
if (tradePartner == null){
Output.logError("couldn't find player (2): " + playerName);
return false;
}
// once the other player is not null, send trade request to that player
Output.logMessage("cp-1");
It only ever got to "cp-3"