I think something like this would work:
Position dst = new Position(0,0,0);
INodeRouteFinder nrf = INodeRouteFinder.threadSafeWrapper(INodeRouteFinder.createAdvanced());
WebWalkEvent e = new WebWalkEvent(nrf, dst);
e.setBreakCondition(new Condition() {
@Override
public boolean evaluate() {
return random(100) == 1;
}
});
boolean success = execute(e).hasFinished();
if(!success) {
// Couldn't walk to dst or we breaked
}
You can either add a sleep in the evaluate of the break condition or if success = false