├── .docker ├── Dockerfile.gui ├── Dockerfile.headless └── build-dockerfile.gradle ├── .github └── workflows │ └── build-and-release.yml ├── .gitignore ├── .idea ├── .gitignore ├── artifacts │ └── Script_Template.xml ├── compiler.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── jarRepositories.xml ├── misc.xml ├── runConfigurations.xml ├── runConfigurations │ ├── script_template__botRunGUI_.xml │ ├── script_template__botRunHeadless_.xml │ ├── script_template__dockerRunGUI_.xml │ └── script_template__dockerRunHeadless_.xml ├── uiDesigner.xml └── vcs.xml ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── build-CI.gradle ├── build.gradle ├── docker-compose-wireguard.yml ├── docker-compose.yml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main └── java ├── GCannon.java └── basicloopbot └── Main.java /.docker/Dockerfile.gui: -------------------------------------------------------------------------------- 1 | # syntax = docker/dockerfile:1.2 2 | # Enable BuildKit https://docs.docker.com/develop/develop-images/build_enhancements/ 3 | # Using multistage docker build 4 | # ref: https://docs.docker.com/develop/develop-images/multistage-build/ 5 | # Variable to use across build stages 6 | ARG BUILD_HOME=/usr/app 7 | 8 | # temp container to cache gradle 9 | FROM gradle:7.4.2-jdk17-jammy AS cache 10 | # Environment vars 11 | ARG BUILD_HOME 12 | ENV APP_HOME=$BUILD_HOME/bot 13 | WORKDIR $APP_HOME 14 | # Copy gradle settings and config to /app in the image 15 | COPY /.docker/build-dockerfile.gradle settings.gradle $APP_HOME 16 | 17 | # Build gradle - caches dependencies 18 | RUN gradle --no-daemon build || return 0 19 | 20 | # Build container 21 | FROM cache AS builder 22 | ARG BUILD_HOME 23 | ENV APP_HOME=$BUILD_HOME/bot 24 | 25 | WORKDIR $APP_HOME 26 | 27 | COPY --from=cache /root/.gradle /root/.gradle 28 | COPY --from=cache $APP_HOME/build-dockerfile.gradle $APP_HOME/settings.gradle $APP_HOME 29 | COPY src/ src/ 30 | 31 | RUN gradle --no-daemon -b build-dockerfile.gradle clean build 32 | 33 | # We need to build the jar for interactive botting 34 | # Note we could run this headless and skip this stage 35 | FROM gradle:7.4.2-jdk17-jammy AS bot 36 | 37 | ARG BUILD_HOME 38 | # Set where to pull OSRSBot from - default OSRSB 39 | ENV REPO=OSRSB 40 | # Set where git should store the OSRSBPlugin project 41 | ENV PLUGIN_REPO=OSRSBPlugin/ 42 | ENV APP_HOME=$BUILD_HOME/$PLUGIN_REPO 43 | 44 | WORKDIR $APP_HOME 45 | 46 | # We need to clone the project and cache the git pull - everytime there's something new pushed 47 | # to master it will pull the latest changes 48 | RUN --mount=type=cache,target=/tmp/git_cache/ \ 49 | git clone --single-branch --branch main https://github.com/$REPO/OSRSBPlugin.git /tmp/git_cache/$PLUGIN_REPO; \ 50 | cd /tmp/git_cache/$PLUGIN_REPO \ 51 | && git pull origin main \ 52 | && cp -r ./ $APP_HOME 53 | 54 | RUN gradle --no-daemon clean shadedJar 55 | 56 | # actual container 57 | # Set base image from Docker image repo 58 | # https://adoptium.net/temurin 59 | FROM eclipse-temurin:17-jdk-jammy 60 | 61 | ARG BUILD_HOME 62 | ENV APP_HOME=$BUILD_HOME/bot 63 | # Name of the built OSRSBot jar file 64 | ENV BOT_JAR_FILE OSRSBPlugin.jar 65 | 66 | # Installs XDisplay packages so we can actually view the container (and run the bot) 67 | # Caches our apt-get(s) with BuildKit 68 | # Remove the apt list to save space 69 | RUN --mount=type=cache,target=/var/cache/apt apt-get update \ 70 | && apt-get upgrade -y \ 71 | && apt-get install -yqq --no-install-recommends libxext6 libxrender1 libxtst6 libxi6 \ 72 | && apt-get clean \ 73 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 74 | 75 | # Adds the scripts to the container (copies source files, if you want the built jar comment this out and uncomment the line below) 76 | #COPY --from=builder $APP_HOME/build/scripts root/.config/OsrsBot/Scripts/Sources 77 | COPY --from=builder $APP_HOME/build/libs /root/.config/OsrsBot/Scripts/Precompiled 78 | # Adds the bot jar to the container 79 | COPY --from=bot $BUILD_HOME/OSRSBPlugin/$BOT_JAR_FILE $APP_HOME/$BOT_JAR_FILE 80 | # Adds runelite config settings to the container 81 | # COPY /config/.runelite/settings.properties /root/.runelite/settings.properties 82 | # Adds osrsbot account config to the container 83 | # COPY /config/.config/osrsbot_acct.ini /root/.config/osrsbot_acct.ini 84 | 85 | EXPOSE 8080 86 | 87 | # Launch the bot with the GUI 88 | ENTRYPOINT java -debug -jar $APP_HOME/${BOT_JAR_FILE} --bot-runelite --developer-mode 89 | -------------------------------------------------------------------------------- /.docker/Dockerfile.headless: -------------------------------------------------------------------------------- 1 | # TODO 2 | ## Add headless option, right now we should use Dockerfile.gui 3 | ## Ideally we have Dockerfile in the root that passes an ARG so we can have 1 4 | ## docker-compose that we pass the args needed i.e. we have an ARG for headless/gui -------------------------------------------------------------------------------- /.docker/build-dockerfile.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | group = 'com.github.OSRSB' 6 | def runeLiteVersion = getRuneLiteVersion() 7 | 8 | allprojects { 9 | repositories { 10 | maven { url "https://jitpack.io" } 11 | } 12 | } 13 | 14 | repositories { 15 | mavenLocal() 16 | maven { 17 | url = 'https://repo.runelite.net' 18 | } 19 | mavenCentral() 20 | } 21 | 22 | sourceSets { 23 | main { 24 | java { 25 | srcDirs= ["src/main/java"] 26 | } 27 | } 28 | } 29 | 30 | jar { 31 | configurations.implementation.setCanBeResolved(true) 32 | from { 33 | configurations.implementation.filter {it.name.startsWith('Dax')}.collect {zipTree(it)} 34 | } 35 | 36 | exclude 'META-INF/*.RSA' 37 | exclude 'META-INF/*.SF' 38 | exclude 'META-INF/*.DSA' 39 | 40 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE 41 | } 42 | 43 | dependencies { 44 | compileOnly 'org.projectlombok:lombok:1.18.24' 45 | annotationProcessor 'org.projectlombok:lombok:1.18.24' 46 | 47 | testImplementation 'junit:junit:4.13.2' 48 | testImplementation 'org.slf4j:slf4j-simple:1.7.36' 49 | 50 | implementation group: 'net.sf.jopt-simple', name:'jopt-simple', version: '5.0.4' 51 | 52 | compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion 53 | 54 | testImplementation group: 'net.runelite', name:'client', version: runeLiteVersion 55 | testImplementation group: 'net.runelite', name:'jshell', version: runeLiteVersion 56 | 57 | implementation 'com.github.OSRSB:OsrsBot:master-SNAPSHOT' 58 | implementation 'com.github.OSRSB:DaxWalkerOSRSBot:master-SNAPSHOT' 59 | } 60 | 61 | tasks.withType(JavaCompile) { 62 | options.encoding = 'UTF-8' 63 | } 64 | 65 | static def getRuneLiteVersion() { 66 | URL url = new URL("http://repo.runelite.net/net/runelite/client/maven-metadata.xml") 67 | URLConnection urlConnection = url.openConnection() 68 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( 69 | urlConnection.getInputStream())) 70 | String latestName = null 71 | String inputLine 72 | while ((inputLine = bufferedReader.readLine()) != null) { 73 | inputLine = inputLine.trim() 74 | if (inputLine.contains("")) { 75 | latestName = inputLine.replace("", "").replace("", "") 76 | } 77 | } 78 | bufferedReader.close() 79 | return latestName 80 | } 81 | -------------------------------------------------------------------------------- /.github/workflows/build-and-release.yml: -------------------------------------------------------------------------------- 1 | name: Java CI with Gradle 2 | 3 | on: 4 | push: 5 | branches: [ master, main ] 6 | tags: 7 | - "**" 8 | pull_request: 9 | branches: [ master, main ] 10 | 11 | jobs: 12 | build-script-jar: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout project sources 16 | uses: actions/checkout@v3 17 | - name: Set up JDK 17 18 | uses: actions/setup-java@v3 19 | with: 20 | java-version: 17 21 | distribution: temurin 22 | - name: Run build with Gradle Wrapper 23 | uses: gradle/gradle-build-action@v2 24 | with: 25 | arguments: -b build-CI.gradle build 26 | - name: Artifact jar 27 | uses: actions/upload-artifact@v2 28 | with: 29 | name: ${{ github.event.repository.name }} 30 | path: ./build/libs/${{ github.event.repository.name }}.jar 31 | - name: Release 32 | uses: softprops/action-gh-release@v1 33 | if: startsWith(github.ref, 'refs/tags/') 34 | with: 35 | files: ./${{ github.event.repository.name }}.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | build/ 3 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/artifacts/Script_Template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $USER_HOME$/GService/Scripts/Precompiled 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations/script_template__botRunGUI_.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 14 | 16 | true 17 | true 18 | false 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/runConfigurations/script_template__botRunHeadless_.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 14 | 16 | true 17 | true 18 | false 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/runConfigurations/script_template__dockerRunGUI_.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 14 | 16 | true 17 | true 18 | false 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/runConfigurations/script_template__dockerRunHeadless_.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 14 | 16 | true 17 | true 18 | false 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = docker/dockerfile:1.2 2 | # Enable BuildKit https://docs.docker.com/develop/develop-images/build_enhancements/ 3 | # Using multistage docker build 4 | # ref: https://docs.docker.com/develop/develop-images/multistage-build/ 5 | # Variable to use across build stages 6 | ARG BUILD_HOME=/usr/app 7 | 8 | # temp container to cache gradle 9 | FROM gradle:7.4.2-jdk17-jammy AS cache 10 | # Environment vars 11 | ARG BUILD_HOME 12 | ENV APP_HOME=$BUILD_HOME/bot 13 | WORKDIR $APP_HOME 14 | # Copy gradle settings and config to /app in the image 15 | COPY build.gradle settings.gradle $APP_HOME 16 | 17 | # Build gradle - caches dependencies 18 | RUN gradle --no-daemon build || return 0 19 | 20 | # Build container 21 | FROM cache AS builder 22 | ARG BUILD_HOME 23 | ENV APP_HOME=$BUILD_HOME/bot 24 | 25 | WORKDIR $APP_HOME 26 | 27 | COPY --from=cache /root/.gradle /root/.gradle 28 | COPY --from=cache $APP_HOME/build.gradle $APP_HOME/settings.gradle $APP_HOME 29 | COPY src/ src/ 30 | 31 | RUN gradle --no-daemon -b build.gradle clean build 32 | 33 | # We need to build the jar for interactive botting 34 | # Note we could run this headless and skip this stage 35 | FROM gradle:7.4.2-jdk17-jammy AS bot 36 | 37 | ARG BUILD_HOME 38 | # Set where to pull OSRSBot from - default OSRSB 39 | ENV ORG=OSRSB 40 | # Set where git should store the OSRSBPlugin project 41 | ENV BOT_REPO=OsrsBot/ 42 | ENV APP_HOME=$BUILD_HOME/ 43 | 44 | WORKDIR $APP_HOME 45 | 46 | # We need to clone the project and cache the git pull - everytime there's something new pushed 47 | # to master it will pull the latest changes 48 | RUN --mount=type=cache,target=/tmp/git_cache/ \ 49 | git clone --single-branch --branch master https://github.com/$ORG/OsrsBot.git /tmp/git_cache/$BOT_REPO; \ 50 | cd /tmp/git_cache/$BOT_REPO \ 51 | && git pull origin master \ 52 | && cp -r ./ $APP_HOME 53 | 54 | RUN gradle --no-daemon clean jar 55 | 56 | # actual container 57 | # Set base image from Docker image repo 58 | # https://adoptium.net/temurin 59 | FROM eclipse-temurin:17-jdk-jammy 60 | 61 | ARG BUILD_HOME 62 | ENV APP_HOME=$BUILD_HOME/bot 63 | # Name of the built OSRSBot jar file 64 | ENV BOT_JAR_FILE OSRSBot.jar 65 | 66 | # Installs XDisplay packages so we can actually view the container (and run the bot) 67 | # Caches our apt-get(s) with BuildKit 68 | # Remove the apt list to save space 69 | RUN --mount=type=cache,target=/var/cache/apt apt-get update \ 70 | && apt-get upgrade -y \ 71 | && apt-get install -yqq --no-install-recommends libxext6 libxrender1 libxtst6 libxi6 \ 72 | && apt-get clean \ 73 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 74 | 75 | # Adds the scripts to the container (copies source files, if you want the built jar comment this out and uncomment the line below) 76 | #COPY --from=builder $APP_HOME/build/scripts root/.config/OsrsBot/Scripts/Sources 77 | COPY --from=builder $APP_HOME/build/libs /root/.config/OsrsBot/Scripts/Precompiled 78 | # Adds the bot jar to the container 79 | COPY --from=bot $BUILD_HOME/$BOT_JAR_FILE $APP_HOME/$BOT_JAR_FILE 80 | # Adds runelite config settings to the container 81 | # COPY /config/.runelite/settings.properties /root/.runelite/settings.properties 82 | # Adds osrsbot account config to the container 83 | # COPY /config/.config/osrsbot_acct.ini /root/.config/osrsbot_acct.ini 84 | 85 | EXPOSE 8080 86 | 87 | # Launch the bot with the GUI 88 | # For the jar location, this must be manually written out as ENTRYPOINT does not allow ARGs to be accessible at runtime 89 | # For further reference check out the following links: 90 | # https://stackoverflow.com/questions/40902445/using-variable-interpolation-in-string-in-docker 91 | # https://docs.docker.com/engine/reference/builder/#environment-replacement 92 | ENTRYPOINT ["java", "-jar", "-debug", "/usr/app/bot/OSRSBot.jar", "--bot-runelite", "--developer-mode"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, OSRSB 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build-bot: 2 | docker build -t bot-image -f Dockerfile.dev . 3 | 4 | run-bot: 5 | docker run -e DISPLAY=host.docker.internal:0 --name bot -it --rm bot-image -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Script Template 2 | ___ 3 | 4 | ## Community 5 | * [Discord](https://discord.gg/CGBXNrHREP) 6 | 7 | ## Building your first script 8 | 9 | ###### Setting up the environment 10 | It is a personal recommendation that you attempt to clone this repository using **IntelliJ** 11 | 12 | This is so the intended template present is loaded as it was created. 13 | 14 | Doing so will allow the run configurations to be prepared for you to simply run the script effortlessly. 15 | 16 | ###### Making Changes 17 | The project uses Gradle to handle dependencies, so if you're interested in adding a new library to your script then 18 | simply add it in whatever manner that library recommends. 19 | 20 | #### API Reference 21 | To explore the methods you can use in your script check out the API References here: 22 | 23 | [OsrsBot API Reference](https://osrsb.github.io/OsrsBot/) 24 | 25 | One for the DaxWalkerRSB API will be added later. 26 | 27 | By default, the project will come with [RuneLite](https://github.com/RuneLite), [OsrsBot](https://github.com/OSRSB/OsrsBot), 28 | and [DaxWalkerRSB](https://github.com/OSRSB/DaxWalkerRSB) already listed as imports for use. 29 | 30 | The script in the example is a basic cannonball making script to outline general script making practices and capabilities. 31 | An advanced script maker can go far beyond this adding their own dependencies, functionalities, 32 | utilizing the WebWalker (DaxWalkerRSB), and even go as far as edit the underlying API if they see the need to. 33 | After all, it is open source. 34 | 35 | ###### Testing your script 36 | ###### *To Run* 37 | To run your script it is as easy as hitting the green play button in **Intellij** 38 | 39 | Using the drop-down menu provided you can easily select from a few different pre-made run configurations like headless mode 40 | or running inside a docker container (and of course whatever variation you choose.) 41 | 42 | ###### *Debugging* 43 | You can use the debugging features present in both **IntelliJ** (the bug button beside the play button) 44 | and utilize some ones present in both 45 | [OsrsBot](https://github.com/OSRSB/OsrsBot) and [RuneLite](https://github.com/RuneLite) 46 | to diagnose any unwanted behavior. 47 | In the future the API will support being launched using an RSPS client for quick testing scripts. 48 | 49 | ###### *Why is it so easy?* 50 | The reason this works so simply is due to Gradle run tasks being configured to enable accessing 51 | [OsrsBot](https://github.com/OSRSB/OsrsBot) 's main method without IntelliJ throwing an error. 52 | Since we have the project set-up to already have settings configured script-template[botRunGUI]. 53 | If not just select that one to launch. Other options are available, so feel free to toy around with them. 54 | 55 | 56 | 57 | ###### Deploying your script 58 | Using **IntelliJ** you should find that compiling your script is rather simple. 59 | In **IntelliJ** build outputs are referred to as **Artifacts**. 60 | 61 | **IMPORTANT** 62 | 63 | When you go to create an artifact ensure that ONLY the compiled source is selected as output 64 | UNLESS you imported an external dependency that wouldn't be used in OsrsBot, DaxWalkerRSB, or 65 | RuneLite 66 | 67 | Instructions: 68 | 69 | To set up an artifact that outputs as a jar (the format one would use in the OsrsBot.jar) simply hit: 70 | 1. File 71 | 2. Project Structure 72 | 3. Artifacts 73 | 4. The plus sign in the center column 74 | 5. Jar 75 | 6. Empty 76 | 7. From Available Elements Open the drop-down for Script_Template 77 | 8. From that drop-down open the one for Main 78 | 9. Double-click 'Script_Template.main' compiled output 79 | 10. Click Ok 80 | 11. Click Apply (in the Project Structure interface) 81 | 12. Click Ok (in the same interface as above) 82 | 13. Your jar will be present in the project's build directory inside libs 83 | 84 | Now you have a script you can use in the OsrsBot.jar OR you can continue to run and test within your build environment. 85 | It is up to you. 86 | 87 | 88 | ###### Where to put your scripts 89 | 90 | To use a script for OsrsBot, traverse to the following location and place the .jar: 91 | 92 | **Windows:** C:\\Users\\[username]\\OsrsBot\\Scripts\\Precompiled \ 93 | **Linux:** /home/[username]/.config/OsrsBot/Scripts/Precompiled \ 94 | **MacOS:** /Users/[username]/Library/Application Support/OsrsBot/Scripts/Precompiled 95 | 96 | Otherwise; if the script is in the form of class files drop them into the Scripts/Sources folder. 97 | 98 | Now you're ready to script. 99 | 100 | ### Docker 101 | The script-template additionally includes a Dockerfile to aid in building containers. The Dockerfile itself is fairly 102 | simple and anyone experienced with Docker should find this all very easy to use. That said it isn't necessary for general 103 | script builders to be utilizing containerization, but decent reasons include wanting to keep the bot files separate from 104 | your actual PC. (Currently the builds target your PC, but execution will occur on the container). 105 | That said there are Gradle tasks for easier Docker building, but some essential instructions are needed first. 106 | 107 | ###### Install Docker: 108 | https://docs.docker.com/engine/install/ 109 | 110 | ###### XServer 111 | For Windows, I personally use: 112 | https://mobaxterm.mobatek.net/ 113 | 114 | For Mac, XQuartz is a nice XServer tool. 115 | [Click this link for extra details on setting that up](https://gist.github.com/sorny/969fe55d85c9b0035b0109a31cbcb088) 116 | 117 | Nix users should be capable of setting up an XServer without instruction. 118 | 119 | 120 | #### Easy Instructions 121 | So provided are run configurations which are accessible next to the green play button at the top 122 | in which you can select options dockerRunGUI or dockerRunHeadless which will both build and run the 123 | docker build. This is by far the easiest method to launch, but should you choose to be difficult then 124 | below are some helpful commands. 125 | 126 | 127 | #### Manual Instructions 128 | 129 | ###### Build Docker: 130 | ``` 131 | docker build -t bot-image . 132 | ``` 133 | 134 | ###### Run Docker: 135 | This will remove the container every time you run it (Fresh container) 136 | 137 | ``` 138 | docker run -e DISPLAY=host.docker.internal:0 -t --rm bot-image 139 | ``` 140 | 141 | Without removing the container 142 | 143 | ``` 144 | docker run -e DISPLAY=host.docker.internal:0 -t bot-image 145 | ``` 146 | Or without docker.host:internal 147 | 148 | ``` 149 | docker run -e DISPLAY="$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'):0.0" --rm -t bot-image 150 | ``` 151 | 152 | Open Terminal in IntelliJ: 153 | Alt+F12 (Windows) 154 | 155 | To connect to a running container with Bash open the terminal in Intellij (or wherever) and then run the following 156 | 157 | ``` 158 | docker container ls 159 | ``` 160 | 161 | Note the name for the container (unless you want to copy the id) 162 | Then with that name run 163 | 164 | ``` 165 | docker container exec -it {container-name} bash 166 | ``` 167 | 168 | For Windows users if you make any mistakes with your Docker setup, check here for some guidance 169 | https://github.com/docker/for-win/issues/6971 170 | 171 | ## [Script Reloading](https://github.com/OSRSB/script-template/wiki/Script-Reloading-and-API-Reloading) 172 | The above link redirects to the wiki page with detailed info on how to appropriately perform script-reloading in the current state of the client 173 | 174 | If you find a bug in any API of OSRSB report it in the respective API library. 175 | 176 | Current libraries are: 177 | 1. [OsrsBot](https://github.com/OSRSB/OsrsBot) 178 | 2. [DaxWalkerRSB](https://github.com/OSRSB/DaxWalkerRSB) 179 | -------------------------------------------------------------------------------- /build-CI.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'maven-publish' 4 | } 5 | 6 | group = 'com.github.OSRSB' 7 | 8 | allprojects { 9 | repositories { 10 | mavenLocal() 11 | maven { url 'https://repo.runelite.net' } 12 | maven { url 'https://jitpack.io' } 13 | mavenCentral() 14 | } 15 | } 16 | 17 | sourceSets { 18 | main { 19 | java { 20 | srcDirs= ["src/main/java"] 21 | } 22 | } 23 | } 24 | 25 | jar { 26 | configurations.implementation.setCanBeResolved(true) 27 | from { 28 | configurations.implementation.filter {it.name.startsWith('Dax')}.collect {zipTree(it)} 29 | } 30 | 31 | exclude 'META-INF/*.RSA' 32 | exclude 'META-INF/*.SF' 33 | exclude 'META-INF/*.DSA' 34 | 35 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE 36 | } 37 | 38 | def runeLiteVersion = getRuneLiteVersion() 39 | 40 | static def getRuneLiteVersion() { 41 | URL url = new URL("http://repo.runelite.net/net/runelite/client/maven-metadata.xml") 42 | URLConnection urlConnection = url.openConnection() 43 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( 44 | urlConnection.getInputStream())) 45 | String latestName = null 46 | String inputLine 47 | while ((inputLine = bufferedReader.readLine()) != null) { 48 | inputLine = inputLine.trim() 49 | if (inputLine.contains("")) { 50 | latestName = inputLine.replace("", "").replace("", "") 51 | } 52 | } 53 | bufferedReader.close() 54 | return latestName 55 | } 56 | 57 | dependencies { 58 | compileOnly 'org.projectlombok:lombok:1.18.22' 59 | annotationProcessor 'org.projectlombok:lombok:1.18.22' 60 | 61 | testImplementation 'junit:junit:4.13.2' 62 | testImplementation 'org.slf4j:slf4j-simple:1.7.36' 63 | 64 | implementation group: 'net.sf.jopt-simple', name:'jopt-simple', version: '5.0.4' 65 | 66 | compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion 67 | 68 | testImplementation group: 'net.runelite', name:'client', version: runeLiteVersion 69 | testImplementation group: 'net.runelite', name:'jshell', version: runeLiteVersion 70 | 71 | implementation 'com.github.OSRSB:OsrsBot:master-SNAPSHOT' 72 | implementation 'com.github.OSRSB:DaxWalkerOSRSBot:master-SNAPSHOT' 73 | } 74 | 75 | tasks.withType(JavaCompile) { 76 | options.encoding = 'UTF-8' 77 | } 78 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'idea' 4 | id 'maven-publish' 5 | } 6 | 7 | allprojects { 8 | repositories { 9 | maven { url "https://jitpack.io" } 10 | } 11 | } 12 | 13 | repositories { 14 | mavenLocal() 15 | maven { 16 | url = 'https://repo.runelite.net' 17 | } 18 | mavenCentral() 19 | } 20 | 21 | def lastSupportedVersion = "1.10.32.1" 22 | def runeLiteVersion = getRuneLiteVersion() 23 | def supportedCheck = false 24 | if (supportedCheck) { 25 | if (runeLiteVersion != lastSupportedVersion) { 26 | println("Warning - client has been updated") 27 | throw new Exception("Out of date (last supported: " + lastSupportedVersion + " current client: " + runeLiteVersion + ")") 28 | } 29 | } 30 | 31 | static def getRuneLiteVersion() { 32 | URL url = new URL("http://repo.runelite.net/net/runelite/client/maven-metadata.xml") 33 | URLConnection urlConnection = url.openConnection() 34 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( 35 | urlConnection.getInputStream())) 36 | String latestName = null 37 | String inputLine 38 | while ((inputLine = bufferedReader.readLine()) != null) { 39 | inputLine = inputLine.trim() 40 | if (inputLine.contains("")) { 41 | latestName = inputLine.replace("", "").replace("", "") 42 | } 43 | } 44 | bufferedReader.close() 45 | return latestName 46 | } 47 | 48 | dependencies { 49 | compileOnly 'org.projectlombok:lombok:1.18.24' 50 | annotationProcessor 'org.projectlombok:lombok:1.18.24' 51 | 52 | //implementation project(":OSRSBot") 53 | 54 | implementation group: 'net.runelite', name: 'client', version: runeLiteVersion 55 | 56 | testImplementation 'junit:junit:4.13.2' 57 | testImplementation 'org.slf4j:slf4j-simple:1.7.36' 58 | 59 | implementation group: 'net.sf.jopt-simple', name:'jopt-simple', version: '5.0.4' 60 | 61 | //implementation group: 'net.runelite', name:'client', version: runeLiteVersion 62 | 63 | testImplementation group: 'net.runelite', name:'client', version: runeLiteVersion 64 | testImplementation group: 'net.runelite', name:'jshell', version: runeLiteVersion 65 | //We want these both at compile and at runtime. 66 | //So we use implementation instead of compileOnly or runtimeOnly 67 | 68 | implementation 'com.github.OSRSB:OSRSBot:master-SNAPSHOT' 69 | //implementation 'com.github.OSRSB:DaxWalkerOSRSBot:master-SNAPSHOT' 70 | //implementation project(":DaxWalkerRSB") 71 | } 72 | 73 | group = 'osrsb' 74 | 75 | tasks.withType(JavaCompile) { 76 | options.encoding = 'UTF-8' 77 | } 78 | 79 | sourceSets { 80 | main { 81 | java { 82 | srcDirs= ["src/main/java"] 83 | } 84 | } 85 | } 86 | 87 | jar { 88 | configurations.implementation.setCanBeResolved(true) 89 | from { 90 | configurations.implementation.filter {it.name.startsWith('Dax')}.collect {zipTree(it)} 91 | } 92 | 93 | exclude 'META-INF/*.RSA' 94 | exclude 'META-INF/*.SF' 95 | exclude 'META-INF/*.DSA' 96 | 97 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE 98 | } 99 | 100 | enum OperatingSystem { 101 | MAC, WINDOWS, LINUX, UNKNOWN 102 | 103 | static def getOperatingSystem() { 104 | final String os = System.getProperty("os.name") 105 | if (os.contains("Mac")) { 106 | return MAC 107 | } else if (os.contains("Windows")) { 108 | return WINDOWS 109 | } else if (os.contains("Linux")) { 110 | return LINUX 111 | } else { 112 | return UNKNOWN 113 | } 114 | } 115 | } 116 | 117 | class ScriptTask extends DefaultTask { 118 | static String getBotScriptDirectory() { 119 | final String NAME = "OsrsBot" 120 | final String SCRIPT_DIRECTORY = "/Scripts/Sources" 121 | final String env = System.getenv(NAME.toUpperCase().concat("_HOME")) 122 | if (env == null || env.isEmpty()) { 123 | String homeDirBuilder = System.getProperty("user.home") 124 | switch(OperatingSystem.getOperatingSystem()) { 125 | case OperatingSystem.LINUX: 126 | homeDirBuilder += File.separator + ".config" 127 | break 128 | case OperatingSystem.MAC: 129 | homeDirBuilder += (homeDirBuilder == null) ? "~" : "" 130 | break 131 | case OperatingSystem.WINDOWS: 132 | //Do nothing 133 | break 134 | default: 135 | //If you're using Solaris or something you're wrong. 136 | break 137 | } 138 | return (homeDirBuilder + File.separator + NAME + SCRIPT_DIRECTORY) 139 | } 140 | return env 141 | } 142 | 143 | def copyLargeDir(File dirFrom, File dirTo) { 144 | if (!dirTo.exists()) { 145 | dirTo.mkdir(); 146 | } 147 | 148 | dirFrom.eachFile(groovy.io.FileType.FILES) { File source -> 149 | File target = new File(dirTo, source.getName()) 150 | target.bytes = source.bytes 151 | } 152 | 153 | dirFrom.eachFile(groovy.io.FileType.DIRECTORIES) { File source -> 154 | File target = new File(dirTo, source.getName()) 155 | copyLargeDir(source, target) 156 | } 157 | } 158 | 159 | @InputDirectory 160 | var scriptDependency = 161 | project.file("${project.buildDir}/classes/java/main") 162 | 163 | @OutputDirectory 164 | var outputDir = 165 | project.file(getBotScriptDirectory()) 166 | 167 | @TaskAction 168 | def copyFiles() { 169 | copyLargeDir(scriptDependency, outputDir) 170 | } 171 | } 172 | 173 | task outputToScriptDirectory(type: ScriptTask) { 174 | group = 'TEST' 175 | dependsOn(classes) 176 | } 177 | 178 | task botRunGUI(type: JavaExec) { 179 | group = "Execution" 180 | description = "Runs the main method within RSB" 181 | classpath = sourceSets.main.compileClasspath + sourceSets.main.runtimeClasspath 182 | getMainClass() set "net.runelite.rsb.botLauncher.Application" 183 | String jvmArgString = (OperatingSystem.MAC == OperatingSystem.getOperatingSystem()) ? 184 | "-debug --add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED" : 185 | "-debug" 186 | jvmArgs jvmArgString.split(" ") 187 | args "--bot-runelite --developer-mode".split(" ") 188 | dependsOn(outputToScriptDirectory) 189 | } 190 | 191 | task botRunHeadless(type: JavaExec) { 192 | group = "Execution" 193 | description = "Runs the main method within RSB" 194 | classpath = sourceSets.main.compileClasspath + sourceSets.main.runtimeClasspath 195 | getMainClass() set "net.runelite.rsb.botLauncher.Application" 196 | String jvmArgString = (OperatingSystem.MAC == OperatingSystem.getOperatingSystem()) ? 197 | "-debug --add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED" : 198 | "-debug" 199 | jvmArgs jvmArgString.split(" ") 200 | args "--bot-runelite --developer-mode --headless".split(" ") 201 | dependsOn(outputToScriptDirectory) 202 | } 203 | 204 | task dockerBuild(type: Exec) { 205 | group = "Docker" 206 | description = "Builds the docker image" 207 | commandLine 'docker', 'build', '-t', 'bot-image', '.' 208 | dependsOn classes 209 | } 210 | 211 | task dockerRunGUI(type: Exec) { 212 | group = "Docker" 213 | description = "Runs the Docker image on the host XServer" 214 | commandLine 'docker', 'run', '-e', 'DISPLAY=host.docker.internal:0', '-t', '--rm', 'bot-image' 215 | dependsOn dockerBuild 216 | } 217 | 218 | task dockerRunHeadless(type: Exec) { 219 | group = "Docker" 220 | description = "Runs the Docker image on the host XServer" 221 | commandLine 'docker', 'run', '-e', 'DISPLAY=host.docker.internal:0', '-t', '--rm', 'bot-image', '--headless' 222 | dependsOn dockerBuild 223 | } 224 | 225 | task dockerCompose(type: Exec) { 226 | group = "Docker" 227 | commandLine 'docker', 'compose', '-f', 'docker-compose.yml', 'up', '--build', '--no-deps', '-d' 228 | } 229 | 230 | task dockerComposeForceBuild(type: Exec) { 231 | group = "Docker" 232 | commandLine 'docker', 'compose', '-f', 'docker-compose.yml', 'build', '--no-cache', 'script' 233 | commandLine 'docker', 'compose', '-f', 'docker-compose.yml', 'up', '--build', '--force-recreate', '--no-deps', '-d' 234 | } 235 | 236 | task dockerComposeWithWireGuard(type: Exec) { 237 | group = "Docker" 238 | commandLine 'docker', 'compose', '-f', 'docker-compose-wireguard.yml', 'up', '--build', '--no-deps', '-d' 239 | } 240 | task dockerComposeWithWireGuardForceBuild(type: Exec) { 241 | group = "Docker" 242 | commandLine 'docker', 'compose', '-f', 'docker-compose-wireguard.yml', 'build', '--no-cache', 'script' 243 | commandLine 'docker', 'compose', '-f', 'docker-compose-wireguard.yml', 'up', '--build', '--force-recreate', '--no-deps', '-d' 244 | } -------------------------------------------------------------------------------- /docker-compose-wireguard.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.1" 3 | services: 4 | wireguard: 5 | image: lscr.io/linuxserver/wireguard:latest 6 | container_name: wireguard 7 | cap_add: 8 | - NET_ADMIN 9 | - SYS_MODULE 10 | environment: 11 | - PUID=1000 12 | - PGID=1000 13 | - TZ=America/New_York 14 | volumes: 15 | - /path/to/wireguard/config:/config # Set to your local config 16 | - /lib/modules:/lib/modules 17 | ports: 18 | - 8080:8080 19 | sysctls: 20 | - net.ipv4.conf.all.src_valid_mark=1 21 | restart: unless-stopped 22 | script: 23 | image: bot-image 24 | build: 25 | dockerfile: Dockerfile 26 | container_name: bot 27 | network_mode: service:wireguard 28 | environment: 29 | - DISPLAY=host.docker.internal:0 30 | restart: unless-stopped -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.1" 3 | services: 4 | script: 5 | image: bot-image 6 | build: 7 | dockerfile: Dockerfile 8 | container_name: bot 9 | environment: 10 | - DISPLAY=host.docker.internal:0 11 | restart: unless-stopped -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRSB/script-template/de3b7fc16c773911b3565f211778d6b10d9fc3ee/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'OSRSBot' 2 | include ":OSRSBot" 3 | include ":DaxWalkerRSB" 4 | project(":OSRSBot").projectDir = file("../OSRSBot") 5 | project(":DaxWalkerRSB").projectDir = file("../DaxWalkerOSRSBot") 6 | -------------------------------------------------------------------------------- /src/main/java/GCannon.java: -------------------------------------------------------------------------------- 1 | import net.runelite.api.Point; 2 | import net.runelite.rsb.event.listener.PaintListener; 3 | import net.runelite.rsb.methods.Skills; 4 | import net.runelite.rsb.script.Script; 5 | import net.runelite.rsb.script.ScriptManifest; 6 | import net.runelite.rsb.wrappers.RSTile; 7 | 8 | import java.awt.*; 9 | 10 | 11 | @ScriptManifest(authors = { "G" }, name = "G Cannon", version = 1.02, description = "" 12 | + "" 13 | + "

G's Cannonball Smither

" 14 | + "
Start the script at a supported location with mould
" 15 | + "in inventory and steel bars visible in the bank

" 16 | + "Supported Locations:
" 17 | + " - Al-Kahrid
" 18 | + " - Edgeville" + "") 19 | public class GCannon extends Script implements PaintListener { 20 | private enum State { 21 | walkTo, smelt, walkBank, bank, error; 22 | } 23 | 24 | final ScriptManifest properties = getClass().getAnnotation( 25 | ScriptManifest.class); 26 | // OTHER VARIABLES 27 | private long scriptStartTime = 0; 28 | private int runEnergy = random(40, 95); 29 | private int startXP = 0; 30 | private int startLvl = 0; 31 | private int stopCount = 0; 32 | private int failCount = 0; 33 | private boolean setAltitude = true; 34 | private int cannonballPrice = 0; 35 | private int steelbarPrice = 0; 36 | private final int anim1 = 899; 37 | private final int anim2 = 827; 38 | private final int cannonball = 2; 39 | private final int ammomould = 4; 40 | private final int steelbar = 2353; 41 | private final RSTile furnace[] = { new RSTile(3110, 3502), 42 | new RSTile(3273, 3186) }; 43 | private final RSTile bankBooth[] = { new RSTile(3097, 3496), 44 | new RSTile(3269, 3169) }; 45 | 46 | private final RSTile furnaceBldg[] = { new RSTile(3108, 3500), 47 | new RSTile(3275, 3184) };; 48 | 49 | private void antiBan() { 50 | final int random = random(1, 24); 51 | switch (random) { 52 | case 1: 53 | if (random(1, 3) == 1) { 54 | ctx.mouse.moveRandomly(300); 55 | } 56 | return; 57 | 58 | case 2: 59 | if (random(1, 10) == 5) { 60 | if (ctx.game.getCurrentTab() != net.runelite.rsb.internal.globval.enums.InterfaceTab.INVENTORY) { 61 | game.openTab(net.runelite.rsb.internal.globval.enums.InterfaceTab.INVENTORY); 62 | } 63 | } 64 | return; 65 | 66 | case 3: 67 | if (random(1, 20) == 10) { 68 | int angle = camera.getAngle() + random(-90, 90); 69 | if (angle < 0) { 70 | angle = 0; 71 | } 72 | if (angle > 359) { 73 | angle = 0; 74 | } 75 | camera.setAngle(angle); 76 | } 77 | return; 78 | default: 79 | return; 80 | } 81 | } 82 | 83 | private RSTile closestTile(final RSTile tiles[]) { 84 | int dist = 999; 85 | RSTile closest = null; 86 | for (final RSTile tile : tiles) { 87 | try { 88 | final int distance = calc.distanceTo(tile); 89 | if (distance < dist) { 90 | dist = distance; 91 | closest = tile; 92 | } 93 | } catch (final Exception e) { 94 | } 95 | } 96 | return closest; 97 | } 98 | 99 | // *******************************************************// 100 | // OTHER METHODS 101 | // *******************************************************// 102 | private void doBank() { 103 | int failCount = 0; 104 | try { 105 | if (!bank.isOpen()) { 106 | if (bank.open()) { 107 | wait(random(500, 750)); 108 | } 109 | } 110 | while (!bank.isOpen()) { 111 | wait(50); 112 | failCount++; 113 | if (failCount > 30) { 114 | return; 115 | } 116 | } 117 | if (bank.isOpen()) { 118 | wait(random(500, 750)); 119 | bank.depositAllExcept(ammomould, steelbar); 120 | if (bank.withdraw(steelbar, 0)) { 121 | wait(random(500, 750)); 122 | } 123 | } 124 | } catch (final Exception e) { 125 | } 126 | } 127 | 128 | private State getState() { 129 | if (!inventory.contains(ammomould)) { 130 | log("You do not have an Ammo Mould in your inventory."); 131 | return State.error; 132 | } 133 | if (inventory.contains(steelbar)) { 134 | if (calc.tileOnScreen(closestTile(furnace))) { 135 | return State.smelt; 136 | } else { 137 | return State.walkTo; 138 | } 139 | } else { 140 | if (calc.tileOnScreen(closestTile(bankBooth))) { 141 | return State.bank; 142 | } else { 143 | return State.walkBank; 144 | } 145 | } 146 | } 147 | 148 | // *******************************************************// 149 | // MAIN LOOP 150 | // *******************************************************// 151 | @Override 152 | public int loop() { 153 | if (!game.isLoggedIn()) { 154 | return 50; 155 | } 156 | 157 | if (startLvl == 0) { 158 | startXP = skills.getCurrentExp(Skills.getIndex("smithing")); 159 | startLvl = skills.getCurrentLevel(Skills 160 | .getIndex("Smithing")); 161 | } 162 | 163 | if (setAltitude) { 164 | camera.setPitch(true); 165 | sleep(random(250, 500)); 166 | setAltitude = false; 167 | } 168 | 169 | startRunning(runEnergy); 170 | 171 | switch (getState()) { 172 | case walkTo: 173 | walkTile(closestTile(furnaceBldg)); 174 | return 50; 175 | case smelt: 176 | makeCannonball(); 177 | return 50; 178 | case walkBank: 179 | walkTile(closestTile(bankBooth)); 180 | return 50; 181 | case bank: 182 | doBank(); 183 | return 50; 184 | case error: 185 | return -1; 186 | } 187 | 188 | return 50; 189 | } 190 | 191 | private void makeCannonball() { 192 | if (inventory.getCount(steelbar) > 0) { 193 | if (!interfaces.get(513).getComponent(15).getText().contains("Steel bar")) { 194 | if (!inventory.itemHasAction(inventory.getItem(steelbar), "Use")) { 195 | return; 196 | } 197 | if (onTile(closestTile(furnace), "Furnace", "Use", 0.75, 0.5, 0)) { 198 | failCount = 0; 199 | while (!interfaces.get(513).getComponent(15).getText().contains( 200 | "Steel bar")) { 201 | sleep(50); 202 | failCount++; 203 | if (failCount > 40) { 204 | return; 205 | } 206 | } 207 | failCount = 0; 208 | } 209 | sleep(random(500, 750)); 210 | } else { 211 | try { 212 | final int x1 = interfaces.get(513).getComponent(3).getArea().x + 5; 213 | final int y1 = interfaces.get(513).getComponent(3).getArea().y + 5; 214 | final int h1 = interfaces.get(513).getComponent(3).getArea().height - 5; 215 | final int w1 = interfaces.get(513).getComponent(3).getArea().width - 5; 216 | mouse.click(random(x1, (x1 + w1)), random(y1, (y1 + h1)), 217 | false); 218 | wait(random(200, 400)); 219 | } catch (final Exception e) { 220 | } 221 | if (menu.doAction("Make All")) { 222 | sleep(random(800, 1600)); 223 | stopCount = 0; 224 | while (stopCount <= 10) { 225 | sleep(100); 226 | antiBan(); 227 | if (getMyPlayer().getAnimation() == -1) { 228 | stopCount++; 229 | } 230 | if (getMyPlayer().getAnimation() == anim1 231 | || getMyPlayer().getAnimation() == anim2) { 232 | stopCount = 0; 233 | } 234 | if (!inventory.contains(steelbar)) { 235 | break; 236 | } 237 | } 238 | stopCount = 0; 239 | } 240 | } 241 | } 242 | } 243 | 244 | // *******************************************************// 245 | // ON FINISH 246 | // *******************************************************// 247 | @Override 248 | public void onFinish() { 249 | getBot().getEventManager().removeListener(this); 250 | } 251 | 252 | // *******************************************************// 253 | // PAINT SCREEN 254 | // *******************************************************// 255 | public void onRepaint(final Graphics g) { 256 | long runTime = 0; 257 | long seconds = 0; 258 | long minutes = 0; 259 | long hours = 0; 260 | int cannonballs = 0; 261 | int currentXP = 0; 262 | int currentLVL = 0; 263 | int gainedXP = 0; 264 | int ballsPerHour = 0; 265 | int profit = 0; 266 | final double xpGain = 25.5; 267 | 268 | runTime = System.currentTimeMillis() - scriptStartTime; 269 | seconds = runTime / 1000; 270 | if (seconds >= 60) { 271 | minutes = seconds / 60; 272 | seconds -= minutes * 60; 273 | } 274 | if (minutes >= 60) { 275 | hours = minutes / 60; 276 | minutes -= hours * 60; 277 | } 278 | 279 | currentLVL = skills.getCurrentLevel(Skills 280 | .getIndex("smithing")); 281 | currentXP = skills.getCurrentExp(Skills.getIndex("smithing")); 282 | gainedXP = currentXP - startXP; 283 | cannonballs = (int) (gainedXP / xpGain * 4); 284 | ballsPerHour = (int) (3600000.0 / runTime * cannonballs); 285 | profit = (cannonballPrice * 4 - steelbarPrice) * (cannonballs / 4); 286 | 287 | if (game.getCurrentTab() == net.runelite.rsb.internal.globval.enums.InterfaceTab.INVENTORY) { 288 | g.setColor(new Color(0, 0, 0, 175)); 289 | g.fillRoundRect(555, 210, 175, 250, 10, 10); 290 | g.setColor(Color.WHITE); 291 | final int[] coords = new int[] { 225, 240, 255, 270, 285, 300, 315, 292 | 330, 345, 360, 375, 390, 405, 420, 435, 450 }; 293 | g.drawString(properties.name(), 561, coords[0]); 294 | g.drawString("Version: " + properties.version(), 561, coords[1]); 295 | g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 296 | 561, coords[2]); 297 | g.drawString("Cannonball: " + cannonballs, 561, coords[4]); 298 | g.drawString("Cannonball/Hour: " + ballsPerHour, 561, coords[5]); 299 | g.drawString("Total Profit: " + profit, 561, coords[6]); 300 | g.drawString("Current Lvl: " + currentLVL, 561, coords[8]); 301 | g.drawString("Lvls Gained: " + (currentLVL - startLvl), 561, 302 | coords[9]); 303 | g.drawString("XP Gained: " + gainedXP, 561, coords[10]); 304 | g.drawString("XP To Next Level: " 305 | + skills.getExpToNextLevel(Skills.getIndex("smithing")), 306 | 561, coords[11]); 307 | g.drawString("% To Next Level: " 308 | + skills.getPercentToNextLevel(Skills 309 | .getIndex("smithing")), 561, coords[12]); 310 | } 311 | } 312 | 313 | // *******************************************************// 314 | // ON START 315 | // *******************************************************// 316 | /* 317 | @Override 318 | public boolean onStart(final Map args) { 319 | scriptStartTime = System.currentTimeMillis(); 320 | 321 | cannonballPrice = grandExchange.loadItemInfo(cannonball) 322 | .getMarketPrice(); 323 | steelbarPrice = grandExchange.loadItemInfo(steelbar).getMarketPrice(); 324 | log("Cannon Ball Value: " + cannonballPrice); 325 | log("Steel Bar Value: " + steelbarPrice); 326 | 327 | return true; 328 | } 329 | 330 | */ 331 | public boolean onTile(final RSTile tile, final String search, 332 | final String action, final double dx, final double dy, 333 | final int height) { 334 | Point checkScreen = null; 335 | checkScreen = calc.tileToScreen(tile, dx, dy, height); 336 | if (!calc.pointOnScreen(checkScreen)) { 337 | walkTile(tile); 338 | sleep(random(340, 1310)); 339 | } 340 | 341 | try { 342 | Point screenLoc = null; 343 | for (int i = 0; i < 30; i++) { 344 | screenLoc = calc.tileToScreen(tile, dx, dy, height); 345 | if (!calc.pointOnScreen(screenLoc)) { 346 | return false; 347 | } 348 | if ((menu.getTargets()[0] + " " + menu.getActions()[0]).toLowerCase().contains( 349 | search.toLowerCase())) { 350 | break; 351 | } 352 | if (mouse.getLocation().equals(screenLoc)) { 353 | break; 354 | } 355 | mouse.move(screenLoc); 356 | } 357 | screenLoc = calc.tileToScreen(tile, height); 358 | if ((menu.getTargets()[0] + " " + menu.getActions()[0]).toLowerCase().contains( 359 | action.toLowerCase())) { 360 | mouse.click(true); 361 | return true; 362 | } else { 363 | mouse.click(false); 364 | return menu.doAction(action); 365 | } 366 | } catch (final Exception e) { 367 | e.printStackTrace(); 368 | return false; 369 | } 370 | } 371 | 372 | private void startRunning(final int energy) { 373 | if (walking.getEnergy() >= energy && !isRunning()) { 374 | runEnergy = random(40, 95); 375 | walking.setRun(true); 376 | sleep(random(500, 750)); 377 | } 378 | } 379 | 380 | private void walkTile(final RSTile tile) { 381 | if (!(calc.distanceTo(walking.getDestination()) <= random(4, 7))) { 382 | if (getMyPlayer().isLocalPlayerMoving()) { 383 | return; 384 | } 385 | } 386 | final Point screen = calc.tileToScreen(tile); 387 | if (calc.pointOnScreen(screen)) { 388 | if (getMyPlayer().isLocalPlayerMoving()) { 389 | return; 390 | } 391 | mouse.move(screen, random(-3, 4), random(-3, 4)); 392 | walking.walkTileOnScreen(tile); 393 | sleep(random(500, 750)); 394 | return; 395 | } else { 396 | walking.walkTo(tile); 397 | sleep(random(500, 750)); 398 | return; 399 | } 400 | } 401 | } -------------------------------------------------------------------------------- /src/main/java/basicloopbot/Main.java: -------------------------------------------------------------------------------- 1 | package basicloopbot; 2 | 3 | //import dax_api.api_lib.DaxWalker; 4 | //import dax_api.api_lib.models.DaxCredentials; 5 | //import dax_api.api_lib.models.DaxCredentialsProvider; 6 | import net.runelite.rsb.methods.Methods; 7 | import net.runelite.rsb.methods.NPCs; 8 | import net.runelite.rsb.script.Script; 9 | import net.runelite.rsb.script.ScriptManifest; 10 | import net.runelite.rsb.wrappers.RSNPC; 11 | import net.runelite.rsb.wrappers.RSPath; 12 | //import net.runelite.rsb.wrappers.subwrap.WalkerTile; 13 | 14 | import java.util.logging.Logger; 15 | 16 | @ScriptManifest( 17 | authors = { "Baby Future" }, name = "Basic Loop Bot", version = 0.1, 18 | description = "" 19 | + "" 20 | + "
Basic example that kills chickens
" 21 | + "" 22 | ) 23 | public class Main extends Script { 24 | 25 | private final int MIN = random(250, 400); // Random minimum value for our loop 26 | private final int MAX = random(700, 900); // Random maximum value for our loop 27 | //private final WalkerTile chickenCoop = new WalkerTile(3233, 3295, 0); 28 | 29 | @Override 30 | public int loop() { 31 | // A Lazy way to catch exceptions - some NPE's can get thrown from the API 32 | // Let's try to find them if it happens 33 | 34 | try { 35 | // We should execute one action at a time, 36 | // when an action is complete we loop again 37 | 38 | // Here's the start of our loop 39 | RSNPC chicken = NPCs.methods.npcs.getNearest("Chicken"); // Find the nearest chicken 40 | // If there's not an NPC available, let's walkt to the area 41 | if (chicken != null) { 42 | Logger.getLogger(getClass().getName()).info("Chicken not null"); 43 | if (getMyPlayer() == null) // Let's make sure our local player isn't Null 44 | return 100; 45 | 46 | if (!chicken.isOnScreen() || (chicken.getLocation() != null && getMyPlayer().getLocation().distanceTo(chicken.getLocation()) > 10)) { 47 | // We're a bit far, let's walk a little closer 48 | RSPath pathToChicken = ctx.walking.getPath(chicken.getLocation()); // We could use DaxWalker here 49 | Logger.getLogger(getClass().getName()).info("Pathing to chicken"); 50 | if (pathToChicken.traverse()) { 51 | return random(1200, 2100); 52 | } 53 | } else if (!chicken.isInCombat() && !chicken.isInteractingWithLocalPlayer() && !getMyPlayer().isInCombat()) { 54 | // We passed our checks, let's attack a chicken now 55 | if (chicken.doAction("Attack")) { 56 | Logger.getLogger(getClass().getName()).info("Attack"); 57 | // We successfully clicked attack 58 | // TODO ideally the API should support a waitUntil type method 59 | // i.e. you click attack and wait until your player is moving / 60 | // isAttacking() returns true 61 | 62 | Methods.sleep(700, 1200); 63 | if (!getMyPlayer().isIdle() || getMyPlayer().isInCombat()) { 64 | // Seems like our attack worked, we can exit 65 | return 0; 66 | } 67 | 68 | // An alternative to the sleep and if statement 69 | /*do { 70 | Methods.sleep(700, 1200); 71 | } while (getMyPlayer().isLocalPlayerMoving());*/ 72 | } 73 | } 74 | } else { 75 | // Chicken is null, we should find one 76 | Logger.getLogger(getClass().getName()).info("Walking"); 77 | //DaxWalker.walkTo(chickenCoop); 78 | } 79 | } catch (NullPointerException e) { 80 | e.printStackTrace(); 81 | } 82 | 83 | // Randomize how often we loop 84 | // Ideally we can use PlayerProfile's that make this random per user/bot 85 | return random(MIN, MAX); 86 | } 87 | 88 | @Override 89 | public boolean onStart() { 90 | // Pass DaxWalker credentials 91 | //DaxWalker.setCredentials(new DaxCredentialsProvider() { 92 | // @Override 93 | // public DaxCredentials getDaxCredentials() { 94 | // return new DaxCredentials("sub_DPjXXzL5DeSiPf", "PUBLIC-KEY"); 95 | // } 96 | //}); 97 | return true; 98 | } 99 | } 100 | --------------------------------------------------------------------------------