Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. import org.parabot.environment.api.utils.Time;
  4. import org.parabot.environment.scripts.Category;
  5. import org.parabot.environment.scripts.Script;
  6. import org.parabot.environment.scripts.ScriptManifest;
  7. import org.parabot.environment.scripts.framework.SleepCondition;
  8. import org.parabot.environment.scripts.framework.Strategy;
  9. import org.rev317.min.Loader;
  10. import org.rev317.min.api.methods.Game;
  11. import org.rev317.min.api.methods.Inventory;
  12. import org.rev317.min.api.methods.Menu;
  13. import org.rev317.min.api.wrappers.Item;
  14.  
  15. @ScriptManifest(author = "Rah", category = Category.CRAFTING, description = "Makes Amulets of Glory for profit.", name = "rGloryHole", servers = {
  16. "Crandor" }, version = 1.1)
  17. public class rGloryHole extends Script {
  18.  
  19. private final ArrayList<Strategy> strategies = new ArrayList<>();
  20.  
  21. private static final int CHISEL_ID = 1756;
  22. private static final int CUT_ID = 1713;
  23. private static final int UNCUT_ID = 1632;
  24.  
  25. public boolean onExecute() {
  26. strategies.add(new SolveRandom());
  27. strategies.add(new Cut());
  28. strategies.add(new Buy());
  29. strategies.add(new Sell());
  30. provide(strategies);
  31. return true;
  32. }
  33.  
  34. private class Buy implements Strategy {
  35.  
  36. public boolean activate() {
  37. return (Inventory.getCount(UNCUT_ID) < 26) && !(Inventory.containts(CUT_ID))
  38. && Game.getOpenInterfaceId() != 16135;
  39. }
  40.  
  41. public void execute() {
  42. if (Game.getOpenInterfaceId() != 3824) {
  43. Menu.sendAction(20, 2495, 0, 0);
  44. Time.sleep(new SleepCondition() {
  45. public boolean isValid() {
  46. return Game.getOpenInterfaceId() != -1;
  47. }
  48. }, 2000);
  49. } else {
  50. Menu.sendAction(431, 1631, 14, 3900);
  51. Time.sleep(new SleepCondition() {
  52. public boolean isValid() {
  53. return Inventory.getCount(UNCUT_ID) >= 26;
  54. }
  55. }, 250);
  56. }
  57. }
  58.  
  59. }
  60.  
  61. private class Cut implements Strategy {
  62.  
  63. public boolean activate() {
  64. return (Inventory.getCount(UNCUT_ID) >= 1) && (Inventory.isFull()) && Game.getOpenInterfaceId() != 16135;
  65. }
  66.  
  67. public void execute() {
  68. Item chisel = Inventory.getItem(CHISEL_ID);
  69. if (Inventory.containts(UNCUT_ID)) {
  70. for (Item gem : Inventory.getItems(UNCUT_ID)) {
  71. chisel.interact(0);
  72. Time.sleep(50);
  73. Menu.sendAction(870, UNCUT_ID - 1, gem.getSlot(), 3214);
  74. }
  75. Time.sleep(new SleepCondition() {
  76. public boolean isValid() {
  77. return !Inventory.containts(UNCUT_ID);
  78. }
  79. }, 100);
  80. }
  81. }
  82.  
  83. }
  84.  
  85. private class Sell implements Strategy {
  86.  
  87. public boolean activate() {
  88. return (Inventory.getCount(CUT_ID) >= 26) && (Inventory.isFull()) && Game.getOpenInterfaceId() != 16135;
  89. }
  90.  
  91. public void execute() {
  92. if (Game.getOpenInterfaceId() == -1) {
  93. Menu.sendAction(20, 107, 0, 0);
  94. Time.sleep(new SleepCondition() {
  95. public boolean isValid() {
  96. return Game.getOpenInterfaceId() != -1;
  97. }
  98. }, 2000);
  99. } else {
  100. Menu.sendAction(434, 1712, 26, 3823);
  101. Time.sleep(100);
  102. Menu.sendAction(200, 946, 5, 3902);
  103. Time.sleep(new SleepCondition() {
  104. public boolean isValid() {
  105. return !Inventory.containts(CUT_ID);
  106. }
  107. }, 2000);
  108. }
  109. }
  110.  
  111. }
  112.  
  113. private class SolveRandom implements Strategy {
  114.  
  115. @Override
  116. public boolean activate() {
  117. return Game.getOpenInterfaceId() == 16135;
  118. }
  119.  
  120. @Override
  121. public void execute() {
  122. switch (getMessage()) {
  123. case "please select the bread.":
  124. sendAction(16140);
  125. break;
  126. case "please select the bagel.":
  127. sendAction(16137);
  128. break;
  129. case "please select the purple drink.":
  130. sendAction(16142);
  131. break;
  132. case "please select the triangle sandwich.":
  133. sendAction(16138);
  134. break;
  135. case "please select the square sandwich.":
  136. sendAction(16139);
  137. break;
  138. case "please select the chocolate.":
  139. sendAction(16143);
  140. break;
  141. case "please select the pie.":
  142. sendAction(16141);
  143. break;
  144. case "null":
  145. System.out.println("You done fucked up.");
  146. break;
  147. }
  148. }
  149. }
  150.  
  151. private void sendAction(int action3) {
  152. Menu.sendAction(315, 1631, 25, action3);
  153. Time.sleep(new SleepCondition() {
  154. @Override
  155. public boolean isValid() {
  156. return Game.getOpenInterfaceId() != 16135;
  157. }
  158. }, 1500);
  159. }
  160.  
  161. private String getMessage() {
  162. if (Loader.getClient().getInterfaceCache()[16145].getMessage() != null) {
  163. return Loader.getClient().getInterfaceCache()[16145].getMessage().toLowerCase();
  164. }
  165. return "null";
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement