Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.74 KB | None | 0 0
  1. import org.dreambot.api.wrappers.widgets.message.Message;
  2. import java.util.Random;
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import org.dreambot.api.wrappers.widgets.WidgetChild;
  7. import org.dreambot.api.wrappers.interactive.GameObject;
  8. import org.dreambot.api.wrappers.interactive.NPC;
  9. import org.dreambot.api.methods.tabs.Tab;
  10. import org.dreambot.api.methods.Calculations;
  11. import org.dreambot.api.methods.container.impl.bank.BankLocation;
  12. import org.dreambot.api.wrappers.interactive.Entity;
  13. import org.dreambot.api.methods.skills.Skill;
  14. import org.dreambot.api.utilities.Timer;
  15. import org.dreambot.api.script.Category;
  16. import org.dreambot.api.script.ScriptManifest;
  17. import org.dreambot.api.script.AbstractScript;
  18. import java.awt.Point;
  19.  
  20. @ScriptManifest(author = "Deus", category = Category.MISC, name = "Crafting", version = 1.0, description = "gets crafting lvls")
  21. public class main extends AbstractScript {
  22. private Timer timer;
  23. private String needle;
  24. private String leather;
  25. private boolean startup;
  26. int xp;
  27. int level;
  28.  
  29.  
  30. public main() {
  31. this.timer = new Timer();
  32. this.needle = "Needle";
  33. this.leather = "Leather";
  34. }
  35.  
  36. private State getState() {
  37. if (this.getSkills().getRealLevel(Skill.CRAFTING) < 7 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
  38. return State.gloves;
  39. }
  40. if (this.getSkills().getRealLevel(Skill.CRAFTING) < 9 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 7 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
  41. return State.boots;
  42. }
  43. if (this.getSkills().getRealLevel(Skill.CRAFTING) < 11 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 9 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
  44. return State.cowl;
  45. }
  46. if (this.getSkills().getRealLevel(Skill.CRAFTING) < 14 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 11 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
  47. return State.vambs;
  48. }
  49. if (this.getSkills().getRealLevel(Skill.CRAFTING) < 18 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 14 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
  50. return State.body;
  51. }
  52. if (this.getSkills().getRealLevel(Skill.CRAFTING) < 28 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 18 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
  53. return State.chaps;
  54. }
  55. if (this.getSkills().getRealLevel(Skill.CRAFTING) < 46 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 28 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
  56. return State.hardbody;
  57. }
  58. if (!this.getInventory().contains("Leather")) {
  59. return State.bank;
  60. }
  61. if (this.getDialogues().inDialogue()) {
  62. return State.dialog;
  63. }
  64. return State.nothing;
  65. }
  66.  
  67. public int onLoop() {
  68. switch (this.getState()) {
  69. case dialog: {
  70. if (this.getDialogues().canContinue()) {
  71. this.getDialogues().continueDialogue();
  72. sleep(300, 600);
  73. }
  74. break;
  75. }
  76. case gloves: {
  77. if (this.getWidgets().getWidget(154) == null) {
  78. this.getInventory().get(this.needle).useOn(this.leather);
  79. sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
  80. }
  81.  
  82. if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(127).interact("Make All pairs of Leather gloves")) {
  83. sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
  84. }
  85. break;
  86. }
  87. case boots: {
  88. if (this.getWidgets().getWidget(154) == null) {
  89. this.getInventory().get(this.needle).useOn(this.leather);
  90. sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
  91. }
  92.  
  93. if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(109).interact("Make All pairs of Leather boots")) {
  94. sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
  95. }
  96. break;
  97. }
  98. case cowl: {
  99. if (this.getWidgets().getWidget(154) == null) {
  100. this.getInventory().get(this.needle).useOn(this.leather);
  101. sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
  102. }
  103.  
  104. if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(113).interact("Make All Cowls")) {
  105. sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
  106. }
  107. break;
  108. }
  109. case vambs: {
  110. if (this.getWidgets().getWidget(154) == null) {
  111. this.getInventory().get(this.needle).useOn(this.leather);
  112. sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
  113. }
  114.  
  115. if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(110).interact("Make All pairs of Leather vambraces")) {
  116. sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
  117. }
  118. break;
  119. }
  120. case body: {
  121. if (this.getWidgets().getWidget(154) == null) {
  122. this.getInventory().get(this.needle).useOn(this.leather);
  123. sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
  124. }
  125.  
  126. if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(114).interact("Make All Leather bodies")) {
  127. sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
  128. } else if (this.getDialogues().canContinue()) {
  129. this.getDialogues().continueDialogue();
  130. sleep(300, 600);
  131. }
  132. else if (!this.getBank().isOpen() && !this.getInventory().contains("Leather")) {
  133. if (this.getBank().open(BankLocation.GRAND_EXCHANGE)) {
  134. this.getBank().deposit("Leather body", 30);
  135. this.getBank().withdraw("Leather", 26);
  136. sleep(300, 600);
  137. }
  138. break;
  139. }
  140. }
  141. case chaps: {
  142. if (this.getWidgets().getWidget(154) == null) {
  143. this.getInventory().get(this.needle).useOn(this.leather);
  144. sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
  145. }
  146.  
  147. if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(111).interact("Make All pairs of Leather chaps")) {
  148. sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
  149. } else if (!this.getBank().isOpen() && !this.getInventory().contains("Leather")) {
  150. if (this.getBank().open(BankLocation.GRAND_EXCHANGE)) {
  151. this.getBank().deposit("Leather chaps", 30);
  152. this.getBank().withdraw("Leather", 26);
  153. sleep(300, 600);
  154. }
  155. break;
  156. }
  157. }
  158. case hardbody: {
  159. if (this.getWidgets().getWidget(154) == null) {
  160. this.getInventory().get(this.needle).useOn(this.leather);
  161. sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
  162. }
  163.  
  164. if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(109).interact("Make All pairs of Leather boots")) {
  165. sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
  166. }
  167. break;
  168. }
  169. case bank: {
  170. if (!this.getBank().isOpen()) {
  171. if (!this.getInventory().contains("Leather")) {
  172. this.getBank().deposit("Leather gloves", 30);
  173. sleep(300, 600);
  174. }
  175.  
  176. if (!this.getInventory().contains("Leather")) {
  177. this.getBank().deposit("Leather boots", 30);
  178. sleep(300, 600);
  179. }
  180. if (!this.getInventory().contains("Leather")) {
  181. this.getBank().deposit("Leather cowl", 30);
  182. sleep(300, 600);
  183. }
  184. if (!this.getInventory().contains("Leather")) {
  185. this.getBank().deposit("Leather vambraces", 30);
  186. sleep(300, 600);
  187. }
  188. if (!this.getInventory().contains("Leather")) {
  189. this.getBank().deposit("Leather body", 30);
  190. sleep(300, 600);
  191. }
  192. if (!this.getInventory().contains("Leather")) {
  193. this.getBank().deposit("Leather chaps", 30);
  194. sleep(300, 600);
  195. }
  196. if (!this.getInventory().contains("Leather")) {
  197. this.getBank().deposit("Hardleather body", 30);
  198. sleep(300, 600);
  199. }
  200. if (this.getBank().contains("Leather")) {
  201. this.getBank().withdraw("Leather", 26);
  202. sleep(300, 600);
  203. this.getBank().close();
  204. } else {
  205. log("Bank doesn't contain Leather, stopping script.");
  206. this.stop();
  207. }
  208. return 0;
  209. }
  210. this.getBank().open(BankLocation.GRAND_EXCHANGE);
  211. return 0;
  212. }
  213.  
  214.  
  215. }
  216. return Calculations.random(500, 900);
  217. }
  218.  
  219.  
  220.  
  221. public void onPaint(final Graphics g) {
  222. g.setFont(new Font("Arial", 1, 16));
  223. g.setColor(Color.YELLOW);
  224. g.drawString("Runtime: " + this.timer.formatTime(), 25, 40);
  225. g.drawString("State: " + this.getState().name(), 25, 55);
  226. g.drawString("Levels gained = " + (this.getSkills().getRealLevel(Skill.CRAFTING) - this.level), 25, 70);
  227. g.drawString("xp gained = " + (this.getSkills().getExperience(Skill.CRAFTING) - this.xp) + " xp/hr = " + this.timer.getHourlyRate(this.getSkills().getExperience(Skill.MAGIC) - this.xp), 25, 85);
  228. }
  229.  
  230. public void onExit() {
  231. }
  232.  
  233. public void onStart() {
  234. this.xp = this.getSkills().getExperience(Skill.CRAFTING);
  235. this.level = this.getSkills().getRealLevel(Skill.CRAFTING);
  236. }
  237.  
  238. private static int randInt(final int min, final int max) {
  239. final Random rand = new Random();
  240. final int randomNum = rand.nextInt(max - min + 1) + min;
  241. return randomNum;
  242. }
  243.  
  244. private void customSleep(final boolean name) {
  245. sleepUntil(() -> name, (long)Calculations.random(2000, 4000));
  246. }
  247.  
  248. public enum State
  249. {
  250. nothing,
  251. dialog,
  252. bank,
  253. gloves,
  254. boots,
  255. cowl,
  256. vambs,
  257. body,
  258. chaps,
  259. hardbody;
  260.  
  261. }
  262. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement