Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.parabot.core.reflect.RefClass;
- import org.parabot.environment.api.interfaces.Paintable;
- import org.parabot.environment.api.utils.Time;
- import org.parabot.environment.input.Keyboard;
- import org.parabot.environment.scripts.Category;
- import org.parabot.environment.scripts.Script;
- import org.parabot.environment.scripts.ScriptManifest;
- import org.parabot.environment.scripts.framework.SleepCondition;
- import org.parabot.environment.scripts.framework.Strategy;
- import org.rev317.min.Loader;
- import org.rev317.min.api.methods.Inventory;
- import org.rev317.min.api.methods.Menu;
- import org.rev317.min.api.methods.Npcs;
- import org.rev317.min.api.methods.Players;
- import org.rev317.min.api.wrappers.*;
- import java.awt.*;
- import java.awt.event.KeyEvent;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- @ScriptManifest(
- name = "SharkFisher",
- author = "",
- description = "Start at fishing spot with harpoon in invo.",
- version = 1.0,
- servers = "Simplicity",
- category = Category.FISHING
- )
- public class Fisher extends Script implements Paintable {
- public static String[] MOD_LIST = {"zezima", "king", "s u o m i", "fear reborn", "jacob", "ajw", "reign", "owls", "v", "levi", "xxx xxx"};
- public static ArrayList<String> customModList = new ArrayList<String>();
- public static Area SPOT = new Area(new Tile(2336, 3680), new Tile(2336, 3710), new Tile(2356, 3710), new Tile(2356, 3680));
- public static String status;
- private final ArrayList<Strategy> strategies = new ArrayList<Strategy>();
- private long startTime;
- public static int moneyMade = 0;
- private final ScriptManifest scriptManifest = (ScriptManifest) new RefClass(this).getAnnotations()[0];
- public static void depositAllExcept(int... itemIDs) {
- final ArrayList<Integer> dontDeposit = new ArrayList<Integer>();
- if (Inventory.getCount(false) <= 2) {
- return;
- } else {
- for (int i : itemIDs) {
- dontDeposit.add(i);
- }
- }
- for (Item inventoryItem : Inventory.getItems()) {
- if (!dontDeposit.contains(inventoryItem.getId())) {
- Menu.sendAction(431, inventoryItem.getId() - 1,
- inventoryItem.getSlot(), 5064, 2213, 3);
- Time.sleep(80);
- }
- }
- }
- public static class Bank
- {
- public static int BANK_INTERFACE = 5292;
- static
- {
- for(String mod : MOD_LIST){
- if(!customModList.contains(mod)){
- customModList.add(mod.toLowerCase());
- }
- }
- }
- /**
- * Gets nearest banker Npcs
- *
- * @return banker Npcs
- */
- public static Npc[] getNearestBankers()
- {
- return Npcs.getNearest(1360);
- }
- /**
- * Gets nearest banker
- *
- * @return nearest banker
- */
- public static Npc getBanker()
- {
- Npc[] bankers = getNearestBankers();
- if (bankers.length > 0 && bankers[0] != null)
- {
- return bankers[0];
- }
- return null;
- }
- /**
- * Opens bank using banker
- *
- * @return true if successfully interacted
- */
- public static boolean open()
- {
- if (isOpen())
- {
- return false;
- }
- Npc banker = getBanker();
- if (banker != null)
- {
- banker.interact(Npcs.Option.TALK_TO);
- return true;
- }
- return false;
- }
- /**
- * Closes the bank interface
- */
- public static void close()
- {
- if (!isOpen())
- {
- return;
- }
- Menu.sendAction(200, -1, -1, 5384);
- }
- /**
- * Determines if bank is open
- *
- * @return true if bank is open
- */
- public static boolean isOpen()
- {
- return Loader.getClient().getOpenInterfaceId() == BANK_INTERFACE;
- }
- }
- public boolean onExecute() {
- startTime = System.currentTimeMillis();
- strategies.add(new Fish());
- strategies.add(new Banklog());
- strategies.add(new Obank());
- provide(strategies);
- return true;
- }
- @Override
- public void onFinish() {
- }
- public class Fish implements Strategy {
- public boolean activate() {
- boolean atSpot = SPOT.contains(Players.getMyPlayer().getLocation());
- if(atSpot){
- try{
- for(Player p : Players.getNearest()){
- if(p != null){
- try{
- if (customModList.contains(p.getName().toLowerCase())) {
- Menu.sendAction(315, 195559424, 56, 2458, 1);
- Fisher.status = "Moderator:" + p.getName() + " was spotted. Taking a 5 minute break.";
- System.out.println("Moderator: " + p.getName() + " was spotted. Taking a 5 minute break.");
- Time.sleep(300000);
- Keyboard.getInstance().clickKey(KeyEvent.VK_ENTER);
- Keyboard.getInstance().clickKey(KeyEvent.VK_ENTER);
- Time.sleep(1000);
- return true;
- }
- }
- catch(Exception e) {
- System.out.println("Null Pointer somehow even though checked for nulls before...");
- }
- }
- }
- } catch (Exception e){
- System.out.println("API Problem Attack Line 64 from Players.getNearest");
- e.printStackTrace();
- }
- }
- Time.sleep(100);
- Npc i = Npcs.getClosest(313);
- return !Inventory.isFull()
- && Players.getMyPlayer().getAnimation() != 618
- && !Bank.isOpen()
- && i != null;
- }
- @Override
- public void execute() {
- Npc i = Npcs.getClosest(313);
- Time.sleep(new SleepCondition() {
- @Override
- public boolean isValid() {
- return i != null;
- } }, 2000 );
- if (i != null){
- i.interact(Npcs.Option.HARPOON);
- Fisher.status = "Fishing.";
- Time.sleep(new SleepCondition() {
- public boolean isValid() {
- return Players.getMyPlayer().getAnimation() == 618;
- } }, 2000 );
- Time.sleep(new SleepCondition() {
- public boolean isValid() {
- return Inventory.isFull()
- || Players.getMyPlayer().getAnimation() != 618;
- } }, 2000 );
- }
- if (i == null){
- Time.sleep(1000);
- }
- }
- }
- public class Banklog implements Strategy {
- @Override
- public boolean activate() {
- Time.sleep(100);
- return Inventory.isFull()
- && Players.getMyPlayer().getAnimation() == -1
- && Bank.isOpen();
- }
- @Override
- public void execute() {
- depositAllExcept(312);
- Fisher.status = "Depositing Fish";
- Time.sleep(1000);
- Time.sleep(new SleepCondition() {
- @Override
- public boolean isValid() {
- return Inventory.isEmpty();
- } } ,2000);
- Fisher.moneyMade += 27;
- Bank.close();
- Time.sleep(new SleepCondition() {
- @Override
- public boolean isValid() {
- return !Bank.isOpen();
- } } ,2000);
- }
- }
- public class Obank implements Strategy {
- @Override
- public boolean activate() { Time.sleep(100);
- return Inventory.isFull()
- && Players.getMyPlayer().getAnimation() == -1
- && !Bank.isOpen();
- }
- @Override
- public void execute() {
- Bank.open();
- Fisher.status = "Opening the bank.";
- Time.sleep(1000);
- Time.sleep(new SleepCondition() {
- @Override
- public boolean isValid() {
- return Bank.isOpen();
- } } ,2000);
- } }
- @Override
- public void paint(Graphics g)
- {
- Graphics2D g2d = (Graphics2D) g;
- g.setColor(Color.GREEN);
- // Title
- g.setFont(new Font("Cordia New", Font.PLAIN, 26));
- drawCenteredString(g2d, "Shark Fisher", 190, 543, 226);
- // Version
- g.setFont(new Font("Cordia New", Font.PLAIN, 14));
- drawCenteredString(g2d, "version " + scriptManifest .version(), 190, 543, 236);
- // Data
- g.setFont(new Font("Cordia New", Font.PLAIN, 20));
- g.drawString("Status : " + Fisher.status, 8, 325);
- drawCenteredString(g2d, "Runtime: " + runTime(startTime), 190, 543, 256);
- drawCenteredString(g2d, "Fish Caught: " + moneyMade, 190, 543, 276);
- drawCenteredString(g2d, "Fish P/H: "+ getPerHour(moneyMade), 190, 543, 296);
- }
- public void drawCenteredString(Graphics2D g2d, String text, int width, int x, int y)
- {
- int stringWidth = (int) g2d.getFontMetrics().getStringBounds(text, g2d).getWidth();
- int offset = (width - stringWidth)/2;
- g2d.setColor(Color.GREEN);
- g2d.drawString(text, x + offset, y);
- }
- public static String runTime(long i) {
- DecimalFormat nf = new DecimalFormat("00");
- long millis = System.currentTimeMillis() - i;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- return nf.format(hours) + ":" + nf.format(minutes) + ":"
- + nf.format(seconds);
- }
- public int getPerHour(int variable) {
- return (int) (((double) (variable - 0) * 3600000D) / (double) (System
- .currentTimeMillis() - startTime));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement