Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.moneymaking.iplankfarmer.woodcutting;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api2007.GroundItems;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSGroundItem;
- import org.tribot.api2007.types.RSItem;
- import scripts.moneymaking.iplankfarmer.utils.Constants;
- public class BirdsNest {
- private Woodcutting woodcutting;
- private int[] nestRewards = new int[10];
- private int nestRewardIndex = 0;
- public BirdsNest(Woodcutting woodcutting) {
- setWoodcutting(woodcutting);
- }
- public void pickUp() {
- RSGroundItem[] nest = getNest();
- if(nest != null && nest.length > 0) {
- WebWalking.walkTo(nest[0]);
- nest[0].click("Take");
- if(isNestPickedUp(nest[0].getID(), 3000)) {
- int nests = getWoodcutting().getScript().getData().getNestsFound();
- getWoodcutting().getScript().getData().setNestsFound(nests + 1);
- emptyNest();
- }
- }
- }
- private boolean isOldReward(int id) {
- for(int i = 0; i < nestRewards.length; i++) {
- if(nestRewards[i] == id) {
- return true;
- }
- }
- return false;
- }
- private void emptyNest() {
- RSItem[] nest = Inventory.find(Constants.BIRD_NEST);
- if(nest != null && nest.length > 0) {
- while(Inventory.isFull()) {
- RSItem[] logs = Inventory.find(getWoodcutting().getScript().getPlank().getLogId());
- if(logs != null && logs.length > 0) {
- logs[0].click("Drop");
- } else {
- break;
- }
- }
- nest[0].click("Search");
- getWoodcutting().getScript().sleep(1000, 1500);
- double nestPrice = getWoodcutting().getScript().getCrushedNestPrice();
- getWoodcutting().getScript().println("Found Birds Nest worth " + moneyFormat(nestPrice));
- double moneyMade = getWoodcutting().getScript().getData().getMoneyMade();
- getWoodcutting().getScript().getData().setMoneyMade(moneyMade + nestPrice);
- /*@SuppressWarnings("unchecked")
- RSItem[] seed = Inventory.find(Inventory.generateFilterGroup(new Filter<RSItem>() {
- @Override
- public boolean accept(RSItem item) {
- for(int i = 0; i < Constants.SEED_REWARD.length; i++) {
- if(item.getID() == Constants.SEED_REWARD[i] && !isOldReward(item.getID())) {
- return true;
- }
- }
- return false;
- }
- }));
- if(seed != null && seed.length > 0) {
- moneyMade = getWoodcutting().getScript().getData().getMoneyMade();
- String seedName = seed[0].getDefinition().getName();
- int seedPrice = Zybez.getPrice(seedName.toLowerCase());
- getWoodcutting().getScript().getData().setMoneyMade(moneyMade + seedPrice);
- getWoodcutting().getScript().println("Found " + seedName + " worth "
- + getWoodcutting().getScript().setInMoneyFormat(seedPrice));
- getNestRewards()[nestRewardIndex++] = seed[0].getID();
- return;
- }
- @SuppressWarnings("unchecked")
- RSItem[] ring = Inventory.find(Inventory.generateFilterGroup(new Filter<RSItem>() {
- @Override
- public boolean accept(RSItem item) {
- for(int i = 0; i < Constants.RING_REWARD.length; i++) {
- if(item.getID() == Constants.RING_REWARD[i] && !isOldReward(item.getID())) {
- return true;
- }
- }
- return false;
- }
- }));
- if(ring != null && ring.length > 0) {
- moneyMade = getWoodcutting().getScript().getData().getMoneyMade();
- String ringName = ring[0].getDefinition().getName();
- int ringPrice = Zybez.getPrice(ringName.toLowerCase());
- getWoodcutting().getScript().getData().setMoneyMade(moneyMade + ringPrice);
- getWoodcutting().getScript().println("Found " + ringName + " worth "
- + getWoodcutting().getScript().setInMoneyFormat(ringPrice));
- getNestRewards()[nestRewardIndex++] = ring[0].getID();
- }*/ // UNSUPPORTED CODE
- }
- }
- private String moneyFormat(double amount) {
- return getWoodcutting().getScript().setInMoneyFormat(amount);
- }
- private RSGroundItem[] getNest() {
- return GroundItems.findNearest(Constants.BIRD_NEST);
- }
- public boolean isOnGround() {
- if(getNest() != null && getNest().length > 0) {
- return true;
- }
- return false;
- }
- private boolean isNestPickedUp(int id, int i) {
- while(Player.isMoving()) {
- getWoodcutting().getScript().sleep(40, 80);
- }
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i + General.random(100, 200)) {
- if (Inventory.getCount(id) > 0) {
- return true;
- }
- getWoodcutting().getScript().sleep(40, 80);
- }
- return false;
- }
- public void setNestRewards(int[] nestRewards) {
- this.nestRewards = nestRewards;
- }
- public int[] getNestRewards() {
- return nestRewards;
- }
- public void setWoodcutting(Woodcutting woodcutting) {
- this.woodcutting = woodcutting;
- }
- public Woodcutting getWoodcutting() {
- return woodcutting;
- }
- public int getNestRewardIndex() {
- return nestRewardIndex;
- }
- public void setNestRewardIndex(int nestRewardIndex) {
- this.nestRewardIndex = nestRewardIndex;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement