Skip to content

Instantly share code, notes, and snippets.

Created March 28, 2017 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/26be13656547372bfd4296cf424032ef to your computer and use it in GitHub Desktop.
Save anonymous/26be13656547372bfd4296cf424032ef to your computer and use it in GitHub Desktop.
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