Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Cannot convert my script to JAR in Intelij


    DtohhM8
     Share

    Recommended Posts

    Main.java

    @ScriptManifest(author = "Dtohh", category = Category.WOODCUTTING, name = "Cow n Hide", version = 1.0)
    public class Main extends AbstractScript {
        protected BankingScript bank = new BankingScript(this);
        protected AntiBanScript antiBan = new AntiBanScript(this);
    
        @Override
        public void onStart() {
            bank.depositAll();
        }
    
        @Override
        public int onLoop() {
            if(getInventory().isFull()) {
                bank.depositAll();
            } else {
                GameObject cow = getGameObjects().closest("cow");
                if(cow != null) {
                    cow.interact("Attack");
                    sleepUntil(() -> !getLocalPlayer().isAnimating(), 5000);
                } else {
                    // Try find some stuff to collect
                    GroundItem cowHide = getGroundItems().closest("Cow Hide");
                    if(cowHide != null) {
                        cowHide.interact("Pick Up");
                        sleepUntil(() -> !getLocalPlayer().isMoving(), 3000);
                        sleep(500, 600);
                    } else {
                        antiBan.walkX();
                        antiBan.talk();
                        sleep(500,600);
                    }
                }
            }
            return 600;
        }
    
        @Override
        public void onExit() {
    
        }
    }

    AntiBanScript.java

    public class AntiBanScript {
        private Main inst;
    
        public AntiBanScript(Main inst) {
            this.inst = inst;
        }
    
        public void walkX() {
            inst.getWalking().walk(new Tile(inst.getLocalPlayer().getTile().getX() +1, inst.getLocalPlayer().getTile().getY(), inst.getLocalPlayer().getTile().getZ()));
            inst.sleep(500, 600);
        }
    
        protected String[] scripts = new String[] {
            "This is so long", "What lvl are you?", "Anybody donating?", "Hows life?", "Hi all"
        };
    
        public void talk() {
            inst.getKeyboard().type(scripts[Utils.generateRandomInt(scripts.length -1, 0)], true);
        }
    }

    BankingScript.java

    public class BankingScript {
    
        private Main inst;
        private Tile trainingPlace;
    
    
        public BankingScript(Main inst) {
            this.inst = inst;
            trainingPlace = inst.getLocalPlayer().getTile();
        }
    
        protected boolean isInBankLocation() {
            return inst.getBank().getClosestBankLocation().getArea(3).contains(inst.getLocalPlayer());
        }
    
        protected void walkToBankLocation() {
            inst.getWalking().walk(inst.getBank().getClosestBankLocation().getArea(3).getRandomTile());
            inst.sleepUntil(() -> !inst.getLocalPlayer().isMoving(), 30000);
        }
    
        protected void walkBackToTrainingLocation() {
            inst.getWalking().walk(trainingPlace);
            inst.sleepUntil(() -> !inst.getLocalPlayer().isMoving(), 30000);
        }
    
        public void withdraw(String item) {
            if(isInBankLocation()) {
                inst.getBank().withdrawAll(item);
                inst.sleep(500,600);
                walkBackToTrainingLocation();
            } else {
                walkToBankLocation();
            }
        }
    
        public void depositAll() {
            if(isInBankLocation()) {
                inst.getBank().depositAllItems();
                inst.sleep(500,600);
                walkBackToTrainingLocation();
            } else {
                walkToBankLocation();
            }
        }
    }

    Utils.java

    public class Utils {
        public static int generateRandomInt(double max, double min) {
            return (int) Math.round(Math.random() * (max + 1 - min) + min);
        }
    }

    App.java

    public class App {
        public static void main(String[] args) {
            new Main();
        }
    }

     

    When I go to my project structures > artifacts and add a new jar from module dependencies and set the main class to App.java and the output directory to my DreamBot > plugins directory and try to open my local scripts in DreamBot it does not show.

     

    How can I export the Jar correctly?

    Link to comment
    Share on other sites

    The error I get is when I try to run this script is:

    log4j:WARN No such property [conversionPattern] in org.apache.log4j.PatternLayout.
    log4j:WARN No such property [conversionPattern] in org.apache.log4j.PatternLayout.
    log4j:WARN No such property [maxFileSize] in org.apache.log4j.RollingFileAppender.
    log4j:WARN No such property [file] in org.apache.log4j.RollingFileAppender.
    log4j:WARN File option not set for appender [LocalFile].
    log4j:WARN Are you using FileAppender instead of ConsoleAppender?
    Exception in thread "main" java.lang.NullPointerException
    	at org.dreambot.api.methods.MethodContext.getLocalPlayer(MethodContext.java:186)
    	at libs.BankingScript.<init>(BankingScript.java:14)
    	at dtohh.Main.<init>(Main.java:13)
    	at dtohh.App.main(App.java:5)

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.