Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.77 KB | None | 0 0
  1. import org.parabot.core.reflect.RefClass;
  2. import org.parabot.environment.api.interfaces.Paintable;
  3. import org.parabot.environment.api.utils.Time;
  4. import org.parabot.environment.input.Keyboard;
  5. import org.parabot.environment.scripts.Category;
  6. import org.parabot.environment.scripts.Script;
  7. import org.parabot.environment.scripts.ScriptManifest;
  8. import org.parabot.environment.scripts.framework.SleepCondition;
  9. import org.parabot.environment.scripts.framework.Strategy;
  10. import org.rev317.min.Loader;
  11. import org.rev317.min.api.methods.Inventory;
  12. import org.rev317.min.api.methods.Menu;
  13. import org.rev317.min.api.methods.Npcs;
  14. import org.rev317.min.api.methods.Players;
  15. import org.rev317.min.api.wrappers.*;
  16.  
  17. import java.awt.*;
  18. import java.awt.event.KeyEvent;
  19. import java.text.DecimalFormat;
  20. import java.util.ArrayList;
  21.  
  22. @ScriptManifest(
  23. name = "SharkFisher",
  24. author = "",
  25. description = "Start at fishing spot with harpoon in invo.",
  26. version = 1.0,
  27. servers = "Simplicity",
  28. category = Category.FISHING
  29. )
  30. public class Fisher extends Script implements Paintable {
  31.  
  32. public static String[] MOD_LIST = {"zezima", "king", "s u o m i", "fear reborn", "jacob", "ajw", "reign", "owls", "v", "levi", "xxx xxx"};
  33. public static ArrayList<String> customModList = new ArrayList<String>();
  34.  
  35. public static Area SPOT = new Area(new Tile(2336, 3680), new Tile(2336, 3710), new Tile(2356, 3710), new Tile(2356, 3680));
  36.  
  37. public static String status;
  38.  
  39. private final ArrayList<Strategy> strategies = new ArrayList<Strategy>();
  40.  
  41. private long startTime;
  42. public static int moneyMade = 0;
  43.  
  44. private final ScriptManifest scriptManifest = (ScriptManifest) new RefClass(this).getAnnotations()[0];
  45.  
  46. public static void depositAllExcept(int... itemIDs) {
  47. final ArrayList<Integer> dontDeposit = new ArrayList<Integer>();
  48. if (Inventory.getCount(false) <= 2) {
  49. return;
  50. } else {
  51. for (int i : itemIDs) {
  52. dontDeposit.add(i);
  53. }
  54. }
  55. for (Item inventoryItem : Inventory.getItems()) {
  56. if (!dontDeposit.contains(inventoryItem.getId())) {
  57. Menu.sendAction(431, inventoryItem.getId() - 1,
  58. inventoryItem.getSlot(), 5064, 2213, 3);
  59. Time.sleep(80);
  60. }
  61. }
  62. }
  63.  
  64.  
  65. public static class Bank
  66. {
  67.  
  68. public static int BANK_INTERFACE = 5292;
  69. static
  70. {
  71. for(String mod : MOD_LIST){
  72. if(!customModList.contains(mod)){
  73. customModList.add(mod.toLowerCase());
  74. }
  75. }
  76. }
  77.  
  78. /**
  79. * Gets nearest banker Npcs
  80. *
  81. * @return banker Npcs
  82. */
  83. public static Npc[] getNearestBankers()
  84. {
  85.  
  86. return Npcs.getNearest(1360);
  87. }
  88.  
  89.  
  90.  
  91. /**
  92. * Gets nearest banker
  93. *
  94. * @return nearest banker
  95. */
  96. public static Npc getBanker()
  97. {
  98. Npc[] bankers = getNearestBankers();
  99.  
  100. if (bankers.length > 0 && bankers[0] != null)
  101. {
  102. return bankers[0];
  103. }
  104.  
  105. return null;
  106. }
  107.  
  108. /**
  109. * Opens bank using banker
  110. *
  111. * @return true if successfully interacted
  112. */
  113. public static boolean open()
  114. {
  115.  
  116. if (isOpen())
  117. {
  118. return false;
  119. }
  120.  
  121. Npc banker = getBanker();
  122.  
  123.  
  124. if (banker != null)
  125. {
  126. banker.interact(Npcs.Option.TALK_TO);
  127. return true;
  128. }
  129.  
  130. return false;
  131. }
  132.  
  133. /**
  134. * Closes the bank interface
  135. */
  136. public static void close()
  137. {
  138. if (!isOpen())
  139. {
  140. return;
  141. }
  142. Menu.sendAction(200, -1, -1, 5384);
  143. }
  144.  
  145. /**
  146. * Determines if bank is open
  147. *
  148. * @return true if bank is open
  149. */
  150. public static boolean isOpen()
  151. {
  152. return Loader.getClient().getOpenInterfaceId() == BANK_INTERFACE;
  153. }
  154. }
  155.  
  156. public boolean onExecute() {
  157. startTime = System.currentTimeMillis();
  158. strategies.add(new Fish());
  159. strategies.add(new Banklog());
  160. strategies.add(new Obank());
  161. provide(strategies);
  162. return true;
  163. }
  164.  
  165. @Override
  166. public void onFinish() {
  167. }
  168.  
  169. public class Fish implements Strategy {
  170. public boolean activate() {
  171.  
  172. boolean atSpot = SPOT.contains(Players.getMyPlayer().getLocation());
  173.  
  174. if(atSpot){
  175. try{
  176. for(Player p : Players.getNearest()){
  177. if(p != null){
  178. try{
  179. if (customModList.contains(p.getName().toLowerCase())) {
  180. Menu.sendAction(315, 195559424, 56, 2458, 1);
  181. Fisher.status = "Moderator:" + p.getName() + " was spotted. Taking a 5 minute break.";
  182. System.out.println("Moderator: " + p.getName() + " was spotted. Taking a 5 minute break.");
  183. Time.sleep(300000);
  184. Keyboard.getInstance().clickKey(KeyEvent.VK_ENTER);
  185. Keyboard.getInstance().clickKey(KeyEvent.VK_ENTER);
  186. Time.sleep(1000);
  187. return true;
  188. }
  189. }
  190. catch(Exception e) {
  191. System.out.println("Null Pointer somehow even though checked for nulls before...");
  192. }
  193. }
  194. }
  195. } catch (Exception e){
  196. System.out.println("API Problem Attack Line 64 from Players.getNearest");
  197. e.printStackTrace();
  198. }
  199. }
  200.  
  201.  
  202.  
  203. Time.sleep(100);
  204. Npc i = Npcs.getClosest(313);
  205. return !Inventory.isFull()
  206. && Players.getMyPlayer().getAnimation() != 618
  207. && !Bank.isOpen()
  208. && i != null;
  209. }
  210.  
  211. @Override
  212. public void execute() {
  213. Npc i = Npcs.getClosest(313);
  214. Time.sleep(new SleepCondition() {
  215. @Override
  216. public boolean isValid() {
  217. return i != null;
  218. } }, 2000 );
  219. if (i != null){
  220. i.interact(Npcs.Option.HARPOON);
  221. Fisher.status = "Fishing.";
  222. Time.sleep(new SleepCondition() {
  223. public boolean isValid() {
  224. return Players.getMyPlayer().getAnimation() == 618;
  225. } }, 2000 );
  226. Time.sleep(new SleepCondition() {
  227. public boolean isValid() {
  228. return Inventory.isFull()
  229. || Players.getMyPlayer().getAnimation() != 618;
  230. } }, 2000 );
  231. }
  232. if (i == null){
  233. Time.sleep(1000);
  234. }
  235. }
  236. }
  237. public class Banklog implements Strategy {
  238. @Override
  239. public boolean activate() {
  240. Time.sleep(100);
  241. return Inventory.isFull()
  242. && Players.getMyPlayer().getAnimation() == -1
  243. && Bank.isOpen();
  244. }
  245.  
  246. @Override
  247. public void execute() {
  248. depositAllExcept(312);
  249. Fisher.status = "Depositing Fish";
  250. Time.sleep(1000);
  251. Time.sleep(new SleepCondition() {
  252. @Override
  253. public boolean isValid() {
  254.  
  255. return Inventory.isEmpty();
  256. } } ,2000);
  257. Fisher.moneyMade += 27;
  258. Bank.close();
  259. Time.sleep(new SleepCondition() {
  260. @Override
  261. public boolean isValid() {
  262.  
  263. return !Bank.isOpen();
  264. } } ,2000);
  265. }
  266.  
  267. }
  268.  
  269. public class Obank implements Strategy {
  270.  
  271. @Override
  272. public boolean activate() { Time.sleep(100);
  273. return Inventory.isFull()
  274. && Players.getMyPlayer().getAnimation() == -1
  275. && !Bank.isOpen();
  276. }
  277.  
  278. @Override
  279. public void execute() {
  280. Bank.open();
  281. Fisher.status = "Opening the bank.";
  282. Time.sleep(1000);
  283. Time.sleep(new SleepCondition() {
  284. @Override
  285. public boolean isValid() {
  286. return Bank.isOpen();
  287. } } ,2000);
  288. } }
  289. @Override
  290. public void paint(Graphics g)
  291. {
  292. Graphics2D g2d = (Graphics2D) g;
  293.  
  294. g.setColor(Color.GREEN);
  295.  
  296. // Title
  297. g.setFont(new Font("Cordia New", Font.PLAIN, 26));
  298. drawCenteredString(g2d, "Shark Fisher", 190, 543, 226);
  299.  
  300. // Version
  301. g.setFont(new Font("Cordia New", Font.PLAIN, 14));
  302. drawCenteredString(g2d, "version " + scriptManifest .version(), 190, 543, 236);
  303.  
  304. // Data
  305. g.setFont(new Font("Cordia New", Font.PLAIN, 20));
  306. g.drawString("Status : " + Fisher.status, 8, 325);
  307. drawCenteredString(g2d, "Runtime: " + runTime(startTime), 190, 543, 256);
  308. drawCenteredString(g2d, "Fish Caught: " + moneyMade, 190, 543, 276);
  309. drawCenteredString(g2d, "Fish P/H: "+ getPerHour(moneyMade), 190, 543, 296);
  310. }
  311.  
  312. public void drawCenteredString(Graphics2D g2d, String text, int width, int x, int y)
  313. {
  314. int stringWidth = (int) g2d.getFontMetrics().getStringBounds(text, g2d).getWidth();
  315.  
  316. int offset = (width - stringWidth)/2;
  317.  
  318. g2d.setColor(Color.GREEN);
  319. g2d.drawString(text, x + offset, y);
  320. }
  321.  
  322. public static String runTime(long i) {
  323. DecimalFormat nf = new DecimalFormat("00");
  324. long millis = System.currentTimeMillis() - i;
  325. long hours = millis / (1000 * 60 * 60);
  326. millis -= hours * (1000 * 60 * 60);
  327. long minutes = millis / (1000 * 60);
  328. millis -= minutes * (1000 * 60);
  329. long seconds = millis / 1000;
  330. return nf.format(hours) + ":" + nf.format(minutes) + ":"
  331. + nf.format(seconds);
  332. }
  333.  
  334. public int getPerHour(int variable) {
  335. return (int) (((double) (variable - 0) * 3600000D) / (double) (System
  336. .currentTimeMillis() - startTime));
  337. }
  338.  
  339. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement