Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.61 KB | None | 0 0
  1. package core;
  2.  
  3. import org.osbot.rs07.script.Script;
  4. import org.osbot.rs07.script.ScriptManifest;
  5.  
  6. import nodes.Banking;
  7. import nodes.Drinking;
  8.  
  9. import java.awt.*;
  10. import java.util.ArrayList;
  11. import java.util.Collections;
  12.  
  13. @ScriptManifest(author = "TheWind", info = "Drinks Wine Jugs", name = "Wine Jug Drinker", version = 1, logo = "")
  14. public class Main extends Script {
  15.    
  16.     //private String status = "";
  17.     private ArrayList<Node> nodes = new ArrayList<Node>();
  18.    
  19.     @Override
  20.     public void onStart() {
  21.         log("Starting Script!");
  22.         Collections.addAll(nodes,
  23.             new Banking(this),
  24.             new Drinking(this)
  25.                 );
  26.     }
  27.  
  28.     @Override
  29.     public int onLoop() throws InterruptedException {
  30.         for(Node n : nodes) {
  31.             if(n.validate()) {
  32.                 //status = n.status();
  33.                 if(n.execute()) {
  34.                     return random(200, 400);
  35.                 }
  36.             }
  37.         }
  38.        
  39.         return random(200, 300);
  40.     }
  41.    
  42.     @Override
  43.     public void onExit() {
  44.         log("Thanks for running my Wine Jug Drinker!");
  45.     }
  46.  
  47.     @Override
  48.     public void onPaint(Graphics2D g) {
  49.     }
  50. }
  51.  
  52. package nodes;
  53.  
  54. import org.osbot.rs07.script.Script;
  55.  
  56. import core.Node;
  57.  
  58. public class Banking extends Node{
  59.  
  60.     public Banking(Script s) {
  61.         super(s);
  62.     }
  63.    
  64.     @Override
  65.     public boolean validate() throws InterruptedException {
  66.         s.getBank().open();
  67.         if(s.getBank().isOpen())
  68.             return true;
  69.         s.log("No bank within range!");
  70.         return false;
  71.     }
  72.  
  73.     @Override
  74.     public boolean execute() throws InterruptedException {
  75.         if(!(s.getBank().contains("Jug of wine")) && !(s.getInventory().contains("Jug of wine")))
  76.             s.stop();
  77.         else if(s.getInventory().isFull())
  78.             s.getBank().depositAll("Jug");
  79.         else if(s.getBank().contains("Jug of wine")) {
  80.             s.getBank().withdraw("Jug of wine", 28);
  81.             s.getBank().close();
  82.         } else {
  83.             s.getBank().close();
  84.             return false;
  85.         }
  86.         return true;
  87.     }
  88. }
  89.  
  90. package nodes;
  91.  
  92. import org.osbot.rs07.api.model.Item;
  93. import org.osbot.rs07.script.MethodProvider;
  94. import org.osbot.rs07.script.Script;
  95.  
  96. import core.Node;
  97.  
  98. public class Drinking extends Node{
  99.  
  100.     public Drinking(Script s) {
  101.         super(s);
  102.     }
  103.  
  104.     @Override
  105.     public boolean validate() throws InterruptedException {
  106.         if(s.getInventory().contains("Jug of wine"))
  107.             return true;
  108.         return false;
  109.     }
  110.  
  111.     @Override
  112.     public boolean execute() throws InterruptedException {
  113.         for(Item item : s.getInventory().getItems()) {
  114.             if(item.hasAction("Drink")) {
  115.                 item.interact("Drink");
  116.                 MethodProvider.sleep(MethodProvider.random(1500, 1800));
  117.             }
  118.         }
  119.         return true;
  120.     }
  121.    
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement