Created
March 28, 2017 13:49
-
-
Save anonymous/26be13656547372bfd4296cf424032ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final Area SHEEP_AREA = new Area(3211, 3259, 3195, 3274).setPlane(0); | |
private final ConditionalSleep animationSleep = new ConditionalSleep(500, 5000) { | |
@Override | |
public boolean condition() throws InterruptedException { | |
return myPlayer().isAnimating(); | |
} | |
}; | |
private Optional<NPC> getClosestSheep() { | |
return Optional.ofNullable(getNpcs().closest(true, npc -> | |
npc.getName().equals("Sheep") && npc.hasAction("Shear") && SHEEP_AREA.contains(npc) | |
)); | |
} | |
@Override | |
public int onLoop() throws InterruptedException { | |
if (getInventory().isFull()) { | |
if (Banks.LUMBRIDGE_UPPER.contains(myPlayer())) { | |
if (getBank().isOpen()) { | |
if (!getInventory().isEmptyExcept("Shears")) { | |
getBank().depositAllExcept("Shears"); | |
} | |
} else { | |
getBank().open(); | |
} | |
} else { | |
if (execute(new WebWalkEvent(Banks.LUMBRIDGE_UPPER)).hasFinished()) { | |
return 100; | |
} | |
} | |
} else { | |
if (SHEEP_AREA.contains(myPlayer())) { | |
if (!myPlayer().isAnimating()) { | |
getClosestSheep().ifPresent(npc -> { | |
if (npc.interact("Shear")) { | |
animationSleep.sleep(); | |
} | |
}); | |
} | |
} else { | |
if (getBank().isOpen()) { | |
getBank().close(); | |
} else { | |
if (execute(new WebWalkEvent(SHEEP_AREA)).hasFinished()) { | |
return 100; | |
} | |
} | |
} | |
} | |
return 1000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment