Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package xtpMPlanker;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.lang.reflect.Field;
- import java.util.ArrayList;
- import javax.swing.JOptionPane;
- import org.parabot.environment.api.interfaces.Paintable;
- import org.parabot.environment.scripts.Category;
- import org.parabot.environment.scripts.Script;
- import org.parabot.environment.scripts.ScriptManifest;
- import org.parabot.environment.scripts.framework.Strategy;
- import org.rev317.min.Loader;
- import org.parabot.environment.api.utils.Time;
- import org.parabot.environment.scripts.framework.SleepCondition;
- import org.rev317.min.api.methods.Npcs;
- import org.rev317.min.api.methods.Players;
- import org.rev317.min.api.methods.SceneObjects;
- import org.rev317.min.api.wrappers.Npc;
- import org.rev317.min.api.wrappers.SceneObject;
- import org.rev317.min.api.wrappers.Tile;
- import java.awt.event.KeyEvent;
- import org.parabot.environment.input.Keyboard;
- import org.rev317.min.api.methods.Inventory;
- import org.rev317.min.api.methods.Menu;
- import org.rev317.min.api.wrappers.Item;
- @ScriptManifest(author = "ToothPik, ",
- category = Category.OTHER,
- description = "Easy Planking",
- name = "Easy Planker",
- servers = { "PKHonor" },
- version = 1.)
- public class Main extends Script implements Paintable{
- public ArrayList<Strategy> strategies = new ArrayList<Strategy>();
- private boolean isPaintVisible;
- public boolean onExecute()
- {
- isPaintVisible = false;
- Globals.Status = Globals.BotStatus.BANKING;
- strategies.add(new AntiRandom());
- strategies.add(new Banker());
- strategies.add(new Planker());
- provide(strategies);
- showid();
- isPaintVisible = true;
- return true;
- }
- public void showid()
- {
- try{
- Class<?>c = Loader.getClient().getClass();
- Field f = c.getDeclaredField("h");
- f.setAccessible(true);
- f.setBoolean(Loader.getClient(), true);
- }catch (Exception ex)
- {
- }
- }
- public void paint(Graphics g)
- {
- if (!isPaintVisible)
- return;
- g.fillRect(2, 238, 108, 45);
- g.setColor(Color.blue);
- g.fillRect(2 , 224, 108, 14);
- g.setColor(Color.ORANGE);
- g.setFont(new Font("News Gothic MT", Font.BOLD, 12));;
- g.drawString("A ToothPik Bot", 12, 236);
- g.setColor(Color.white);
- g.setFont(new Font("verdana", Font.BOLD, 12));;
- g.drawString("Easy mPlanker", 4, 250);
- g.setColor(Color.cyan);
- g.setFont(new Font("Verdana", Font.PLAIN, 10));
- g.drawString("State: " + Globals.Status, 4, 260);
- g.drawString("Planks: " + Globals.PlanksMade, 4, 270);
- g.drawString("Randoms: " + ((AntiRandom)strategies.get(0)).RandomsComplete, 4, 280);
- }
- public class AntiRandom implements Strategy {
- public int RandomsComplete;
- //15814 = Preist (moderator must call this)
- public int[] randoms = { 1091, 410, 3117 };
- public AntiRandom()
- {
- this.RandomsComplete = 0;
- }
- @Override
- public boolean activate()
- {
- Npc[] rnds = Npcs.getNearest(randoms);
- for (Npc n : rnds)
- if (n != null && n.getLocation().distanceTo() < 3 && n.getInteractingCharacter().equals(Players.getMyPlayer()))
- return true;
- return false;
- }
- @Override
- public void execute()
- {
- Globals.BotStatus lastStatus = Globals.Status;
- Globals.Status = Globals.BotStatus.EVENT;
- Npc[] rnds = Npcs.getNearest(randoms);
- System.out.println("Random Event Detected");
- for (Npc n : rnds)
- {
- if (n.getDef().getId() == 1091)
- {
- System.out.println("Random Event: Bob's Island");
- //Bob's Island
- if (new Tile(2523, 4777).distanceTo() < 50)
- {
- SceneObject[] portals = SceneObjects.getNearest(8987);
- for (final SceneObject currentPortal : portals)
- {
- if (!(new Tile(2523, 4777).distanceTo() < 50))
- break;
- if (currentPortal != null)
- {
- currentPortal.interact(0);
- Time.sleep(new SleepCondition()
- {
- @Override
- public boolean isValid()
- {
- return currentPortal.getLocation().distanceTo() < 2;
- }
- }, 6000);
- currentPortal.interact(0);
- Time.sleep(800);
- }
- }
- }
- RandomsComplete++;
- System.out.println("Bob's Island Complete");
- }else if ((n.getDef().getId() == 3117 || n.getDef().getId() == 410) && n.getInteractingCharacter().equals(Players.getMyPlayer()))
- {
- int npcID = n.getDef().getId();
- String eventName = npcID == 3117 ? "Sandwich Lady" : "Mysterious Old Man";
- System.out.println("Random Event: " + eventName);
- n.interact(0);
- Time.sleep(1000);
- System.out.println("Random Event: " + eventName + " Complete");
- RandomsComplete++;
- }
- }
- Globals.Status = lastStatus;
- }
- }
- public class Banker implements Strategy{
- @Override
- public boolean activate()
- {
- return Globals.Status == Globals.BotStatus.BANKING;
- }
- @Override
- public void execute()
- {
- Npc[] npcs = Npcs.getNearest(4241);
- for (final Npc n : npcs)
- {
- if (n != null)
- {
- n.interact(0);
- Time.sleep(new SleepCondition(){
- @Override
- public boolean isValid()
- {
- return n.getLocation().distanceTo() < 2;
- }
- }, 15000);
- Time.sleep(new SleepCondition(){
- @Override
- public boolean isValid()
- {
- return Loader.getClient().getBackDialogId() == 2469;
- }
- }, 6000);
- Menu.sendAction(315,20987904,49,2471);
- Time.sleep(new SleepCondition()
- {
- @Override
- public boolean isValid()
- {
- return Loader.getClient().getOpenInterfaceId() == 23350;
- }
- }, 3500);
- Menu.sendAction(169, 558, 0, 23424);
- if (Inventory.getCount(false, 8783) > 0)
- {
- Globals.PlanksMade += Inventory.getCount(false, 8783);
- Item[] invenItems = Inventory.getItems();
- boolean eBreak = false;
- int looper = 0;
- while (looper < invenItems.length && !eBreak)
- {
- if (invenItems[looper].getId() == 8783)
- {
- int itemSlot = invenItems[looper].getSlot();
- Menu.sendAction(432, 8782,itemSlot,5064);
- Time.sleep(new SleepCondition()
- {
- @Override
- public boolean isValid()
- {
- return Inventory.getCount(false, 8783) == 0;
- }
- }, 1000);
- eBreak = true;
- }
- looper++;
- }
- }
- if (Inventory.getCount(true, 8795) == 0)
- {
- if (!playerHasBankItem(8795))
- {
- System.out.println("Saw not found in bank or inventory.");
- Globals.Status = Globals.BotStatus.ERROR;
- return;
- }
- }
- if (!(Inventory.getCount(true, 996) > 0))
- {
- if (!playerHasBankItem(996))
- {
- System.out.println("Money not found in invetory or bank.");
- Globals.Status = Globals.BotStatus.ERROR;
- return;
- }
- }
- if (!playerHasBankItem(6332))
- {
- System.out.println("Mahogany Logs not found in bank.");
- Globals.Status = Globals.BotStatus.ERROR;
- return;
- }
- if (!(Inventory.getCount(false, 8795) > 0))
- {
- int sawSlot = getBankSlot(8795);
- Menu.sendAction(632, 8794, sawSlot, 5382);
- Time.sleep(new SleepCondition()
- {
- @Override
- public boolean isValid()
- {
- return Inventory.getCount(false, 8795) > 0;
- }
- }, 6000);
- }
- if (!(Inventory.getCount(true, 996) > 0))
- {
- int moneySlot = getBankSlot(996);
- Menu.sendAction(432,995,moneySlot,5382);
- Time.sleep(new SleepCondition(){
- @Override
- public boolean isValid()
- {
- return Inventory.getCount(true, 996) > 0;
- }
- }, 6000);
- }
- int logSlot = getBankSlot(6333);
- Menu.sendAction(53, 6332, logSlot, 5382);
- Globals.Status = Globals.BotStatus.PLANKING;
- break;
- }
- }
- }
- public int getInputState(){
- try{
- Class<?> c = Loader.getClient().getClass();
- Field f = c.getDeclaredField("aq");
- f.setAccessible(true);
- return f.getInt(Loader.getClient());
- }catch(Exception e){
- e.printStackTrace();
- return -1;
- }
- }
- private String getWithdrawValue()
- {
- try
- {
- Class<?> c = Loader.getClient().getClass();
- Field f = c.getDeclaredField("eY");
- f.setAccessible(true);
- return (String)f.get(Loader.getClient());
- }catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return null;
- }
- private void setWithdrawValue(int val)
- {
- try{
- Class<?> c = Loader.getClient().getClass();
- Field f = c.getDeclaredField("eY");
- f.setAccessible(true);
- f.set(Loader.getClient(), Integer.toString(val));
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- //Thanks to minecraftftw for these 3 bank functions!
- private int getBankSlot(int id)
- {
- int[] bankIds = Loader.getClient().getInterfaceCache()[5382].getItems();
- for (int i = 0; i < bankIds.length; i++)
- if (bankIds[i] == id)
- return i;
- return 0;
- }
- private int getBankStackSize(int id)
- {
- int[] stacks = Loader.getClient().getInterfaceCache()[5382].getStackSizes();
- for (int i = 0; i < stacks.length; i++)
- if (i == getBankSlot(id))
- return stacks[i];
- return 0;
- }
- private boolean playerHasBankItem(int id)
- {
- return getBankStackSize(id) > 0;
- }
- }
- public static class Globals {
- public static String UserName;
- public static String Password;
- public static BotStatus Status;
- public static int PlanksMade;
- public enum BotStatus
- {
- RELOGGING,
- EVENT,
- BANKING,
- PLANKING,
- ERROR
- }
- }
- public class Planker implements Strategy {
- @Override
- public boolean activate()
- {
- return Globals.Status == Globals.BotStatus.PLANKING;
- }
- @Override
- public void execute()
- {
- if (Inventory.getCount(false, 8783) > 0)
- {
- Globals.Status = Globals.BotStatus.BANKING;
- return;
- }
- SceneObject[] workBenches = SceneObjects.getNearest(13708);
- if (Inventory.getCount(true, 996) < 54000)
- {
- System.out.println("Not enough money to continue the bot.");
- Globals.Status = Globals.BotStatus.ERROR;
- return;
- }
- for (SceneObject wb : workBenches)
- {
- if (wb != null)
- {
- wb.interact(0);
- Time.sleep(new SleepCondition()
- {
- @Override
- public boolean isValid()
- {
- return Loader.getClient().getBackDialogId() == 2459;
- }
- }, 20000);
- Menu.sendAction(315, 6332, 282, 2461);
- Globals.Status = Globals.BotStatus.BANKING;
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement