SHARE
TWEET

Untitled

a guest Mar 20th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package BasicWoodcutter;
  2.  
  3. import org.dreambot.api.methods.Calculations;
  4. import org.dreambot.api.methods.map.Area;
  5. import org.dreambot.api.randoms.RandomSolver;
  6. import org.dreambot.api.script.AbstractScript;
  7. import org.dreambot.api.script.Category;
  8. import org.dreambot.api.script.ScriptManifest;
  9. import org.dreambot.api.wrappers.interactive.GameObject;
  10. import org.dreambot.api.wrappers.interactive.NPC;
  11.  
  12. import java.awt.*;
  13. import java.io.BufferedWriter;
  14. import java.io.FileWriter;
  15. import java.io.IOException;
  16. import java.io.PrintWriter;
  17.  
  18. @ScriptManifest(category = Category.WOODCUTTING, name = "Basic Woodcutter", author = "8ishop", version = 1.0)
  19. public class MainClass extends AbstractScript {
  20.  
  21.     Area bankArea = new Area(3092, 3240, 3097, 3246, 0);
  22.     Area treeArea = new Area(3142, 3213, 3122, 3216, 0);
  23.     int bankedLogs = 0;
  24.  
  25.  
  26.  
  27.     @Override
  28.     public void onStart() {
  29.         log("HI");
  30.     }
  31.  
  32.     @Override
  33.     public int onLoop() {
  34.  
  35.  
  36.         GameObject tree = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().equals("Tree"));
  37.         if (!getInventory().isFull()) {
  38.             if (treeArea.contains(getLocalPlayer())) {
  39.                 if (tree.interact("Chop down")) {
  40.                     int countLog = getInventory().count("Logs");
  41.                     sleepUntil(() -> getInventory().count("Logs") > countLog, 12000);
  42.                 }
  43.             } else {
  44.                 if (getWalking().walk(treeArea.getCenter())) {
  45.                     sleep(Calculations.random(3000, 6000));
  46.                 }
  47.             }
  48.  
  49.  
  50.         }
  51.  
  52.         if (bankedLogs >= 2000000);
  53.         if (getInventory().isFull()) { //it is time to bank
  54.             if (bankArea.contains(getLocalPlayer())) {
  55.                 NPC banker = getNpcs().closest(npc -> npc != null && npc.hasAction("Bank"));
  56.                 if (banker.interact("Bank")) {
  57.                     if (sleepUntil(() -> getBank().isOpen(), 9000)) {
  58.                         if (getBank().depositAllExcept(item -> item != null && item.getName().contains("axe"))) {
  59.  
  60.                             /////////////// BETWEEN THESE 2 LINES ARE MY EDITS /////////////////////////////
  61.                             // At this point you just deposited a load of logs, and the bank is open
  62.                             // So while we have the bank open update the .txt file
  63.                             // This is better on performance than updating it every single loop
  64.                             try {
  65.                                 log(" Status - WOODCUTTER - Generating woodcutter Data");
  66.                                 FileWriter fw = new FileWriter("8ishopslave.txt", false);
  67.                                 BufferedWriter bw = new BufferedWriter(fw);
  68.                                 PrintWriter out = new PrintWriter(bw);
  69.  
  70.                                 // out.println(this.getInventory().count("Logs"));
  71.                                 // We want to record the amount of Logs in the bank
  72.                                 out.println(getBank().count("Logs"));
  73.                                 bankedLogs = getBank().count("logs")
  74.                                 out.close();
  75.                             } catch (IOException e) {
  76.                                 log("8ishopslave");
  77.                                 e.printStackTrace();
  78.                             }
  79.                             /////////////////////////////////////////////////////////////////////////////
  80.  
  81.                             if (sleepUntil(() -> !getInventory().isFull(), 8000)) {
  82.                                 if (getBank().close()) {
  83.                                     sleepUntil(() -> !getBank().isOpen(), 8000);
  84.                                 }
  85.                             }
  86.                         }
  87.                     }
  88.                 }
  89.             } else {
  90.                 if (getWalking().walk(bankArea.getCenter())) {
  91.                     sleep(Calculations.random(3000, 6000));
  92.                 }
  93.             }
  94.  
  95.  
  96.         }
  97.  
  98.         return 600;
  99.     }
  100. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top