├── assets ├── test ├── 345.png ├── Screenshot from 2023-11-27 20-53-44.png └── 9990F441-DB4B-4BE1-AAE6-2E8A3EBC5D12.png ├── .dockerignore ├── requirements.txt ├── docker_build.sh ├── LICENSE ├── Dockerfile ├── .gitignore ├── .github └── workflows │ └── docker-publish.yml ├── README.md └── main.py /assets/test: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | docker_build.sh 2 | plugins/ -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | lodestone 2 | gradio==3.* -------------------------------------------------------------------------------- /assets/345.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-lodestone-project/Beehive/HEAD/assets/345.png -------------------------------------------------------------------------------- /docker_build.sh: -------------------------------------------------------------------------------- 1 | sudo docker build . -t thelodestoneproject/beehive 2 | sudo docker push thelodestoneproject/beehive 3 | -------------------------------------------------------------------------------- /assets/Screenshot from 2023-11-27 20-53-44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-lodestone-project/Beehive/HEAD/assets/Screenshot from 2023-11-27 20-53-44.png -------------------------------------------------------------------------------- /assets/9990F441-DB4B-4BE1-AAE6-2E8A3EBC5D12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-lodestone-project/Beehive/HEAD/assets/9990F441-DB4B-4BE1-AAE6-2E8A3EBC5D12.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Lodestone 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Use an official Python runtime as a parent image 2 | FROM python:3.11-slim 3 | # Set the working directory to /app 4 | WORKDIR /app 5 | 6 | # Copy the current directory contents into the container at /app 7 | COPY . /app 8 | 9 | # Run the command to install any necessary dependencies 10 | RUN pip install --no-cache-dir -U lodestone gradio==3.* 11 | ENV NODE_VERSION=18.18.2 12 | RUN apt-get update 13 | RUN apt-get -qq -y install curl 14 | RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash 15 | ENV NVM_DIR=/root/.nvm 16 | RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} 17 | RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} 18 | RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} 19 | ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" 20 | RUN python -m javascript --install mineflayer 21 | RUN python -m javascript --install prismarine-viewer 22 | RUN python -m javascript --install minecraft-data 23 | RUN python -m javascript --install mineflayer-pathfinder 24 | RUN python -m javascript --install mineflayer-collectblock 25 | EXPOSE 8000 26 | EXPOSE 5000 27 | EXPOSE 5001 28 | EXPOSE 5002 29 | ENV RUN_DOCKER Yes 30 | CMD ["python", "main.py"] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | cache/ 162 | plugins/ 163 | -------------------------------------------------------------------------------- /.github/workflows/docker-publish.yml: -------------------------------------------------------------------------------- 1 | name: Docker 2 | 3 | # This workflow uses actions that are not certified by GitHub. 4 | # They are provided by a third-party and are governed by 5 | # separate terms of service, privacy policy, and support 6 | # documentation. 7 | 8 | on: 9 | schedule: 10 | - cron: '23 12 * * *' 11 | push: 12 | branches: [ "main" ] 13 | # Publish semver tags as releases. 14 | tags: [ 'v*.*.*' ] 15 | pull_request: 16 | branches: [ "main" ] 17 | 18 | env: 19 | # Use docker.io for Docker Hub if empty 20 | REGISTRY: ghcr.io 21 | # github.repository as / 22 | IMAGE_NAME: ${{ github.repository }} 23 | 24 | 25 | jobs: 26 | build: 27 | 28 | runs-on: ubuntu-latest 29 | permissions: 30 | contents: read 31 | packages: write 32 | # This is used to complete the identity challenge 33 | # with sigstore/fulcio when running outside of PRs. 34 | id-token: write 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v3 39 | 40 | # Install the cosign tool except on PR 41 | # https://github.com/sigstore/cosign-installer 42 | - name: Install cosign 43 | if: github.event_name != 'pull_request' 44 | uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 45 | with: 46 | cosign-release: 'v2.1.1' 47 | 48 | # Set up BuildKit Docker container builder to be able to build 49 | # multi-platform images and export cache 50 | # https://github.com/docker/setup-buildx-action 51 | - name: Set up Docker Buildx 52 | uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 53 | 54 | # Login against a Docker registry except on PR 55 | # https://github.com/docker/login-action 56 | - name: Log into registry ${{ env.REGISTRY }} 57 | if: github.event_name != 'pull_request' 58 | uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 59 | with: 60 | registry: ${{ env.REGISTRY }} 61 | username: ${{ github.actor }} 62 | password: ${{ secrets.GITHUB_TOKEN }} 63 | 64 | # Extract metadata (tags, labels) for Docker 65 | # https://github.com/docker/metadata-action 66 | - name: Extract Docker metadata 67 | id: meta 68 | uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 69 | with: 70 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 71 | 72 | # Build and push Docker image with Buildx (don't push on PR) 73 | # https://github.com/docker/build-push-action 74 | - name: Build and push Docker image 75 | id: build-and-push 76 | uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 77 | with: 78 | context: . 79 | push: ${{ github.event_name != 'pull_request' }} 80 | tags: ${{ steps.meta.outputs.tags }} 81 | labels: ${{ steps.meta.outputs.labels }} 82 | cache-from: type=gha 83 | cache-to: type=gha,mode=max 84 | 85 | # Sign the resulting Docker image digest except on PRs. 86 | # This will only write to the public Rekor transparency log when the Docker 87 | # repository is public to avoid leaking data. If you would like to publish 88 | # transparency data even for private images, pass --force to cosign below. 89 | # https://github.com/sigstore/cosign 90 | - name: Sign the published Docker image 91 | if: ${{ github.event_name != 'pull_request' }} 92 | env: 93 | # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable 94 | TAGS: ${{ steps.meta.outputs.tags }} 95 | DIGEST: ${{ steps.build-and-push.outputs.digest }} 96 | # This step uses the identity token to provision an ephemeral certificate 97 | # against the sigstore community Fulcio instance. 98 | run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 |
5 | Beehive 6 |
7 |

8 | 9 |

🤖 An free and fully open source alternative for paid minecraft bots.

10 | 11 |

12 | Node version 13 | Python 14 | javascript 15 | Hungarian 16 |

17 | 18 |

19 | About • 20 | Features • 21 | Install 22 |

23 | 24 | ## About 📬 25 | 26 | Project Beehive is an open source Minecraft bot with a goal to provide players access to helpful gameplay features at no cost. Developed with a clean user interface, Project Beehive offers various plugins and options similar to paid alternatives out there. The project is completely free, open source, and welcoming to contributions from the Minecraft community. Check the wiki for information on plugins, setup guides, contributing, and more. We aim to provide Minecraft players with an easy-to-use bot to enhance their gameplay experience without needing to pay. Feel free to open issues for bugs, suggestions, or questions! 27 | 28 | ## Freature and Plugins 🕹 29 | 30 | | Plugin | Description | Available | 31 | | --------------------- | ----------------------------------------- | ----------- | 32 | | Defender | Follows and attacks nearby players | No | 33 | | Shield Aura | Follows and protects owner | No | 34 | | Schematic Builder | Builds structures from schematics | Yes | 35 | | Raid Alerts | Sends alerts on explosions and mob spawns | No | 36 | | Area Miner | Mines designated areas | No | 37 | | Hypixel Auto Crafting | Automates Hypixel crafting tasks | No | 38 | | Chat Spy | Views the bot's chat | Yes | 39 | | Sugar Cane Farmer | Harvests and stores sugar cane | Coming soon | 40 | | Ore Miner | Mines ores using X-ray | Coming soon | 41 | | Cactus Farm Builder | Builds cactus farms | Yes | 42 | | Auto AFK | Automates farming tasks | Coming soon | 43 | | Container Viewer | Checks bots' inventories | Coming soon | 44 | | Chat to Discord | Forwards chat to Discord | Yes | 45 | | Knockback | Simulates knockback physics | Yes | 46 | | Chatbot | Responds to chat commands | Yes | 47 | | Captcha Breaker | Solves in-game captchas | No | 48 | | Sand Printer | Places sand blocks | No | 49 | | Wander | Moves bots randomly | Yes | 50 | | Farm Builder | Builds sugar cane farms | No | 51 | | Auto Fisher | Gets max fishing level | No | 52 | | Ban Checker | Checks if accounts are banned | No | 53 | | Auto Eater | Eats when hungry or damaged | Yes | 54 | | Crop Farmer | Farms crops | Coming soon | 55 | | Inventory Manager | Manages bot inventories | No | 56 | | Mob Aura | Attacks nearby mobs | No | 57 | | Netherwart Farmer | Farms nether wart | No | 58 | | Tree Farmer | Farms trees | No | 59 | | GUI Captcha Breaker | Solves GUI captchas | No | 60 | | No Fall | Prevents fall damage | Yes | 61 | | Killaura | Attacks nearby players | Coming soon | 62 | | Tunneler | Digs tunnels and mines ore | No | 63 | | Anti-Captcha | Solves chat captchas | No | 64 | | Auto Armor | Equips best armor automatically | Coming soon | 65 | | Chat to Discord | Forwards chat to Discord | Yes | 66 | | Anti-Cheat Compliance | Bypasses anti-cheat plugins | No | 67 | | Container Navigator | Navigates container GUIs | No | 68 | 69 | ## How To Install 📥 70 | 71 | ### Docker 🐳 (Not recommended at the moment) 72 | 73 | Using Docker at the moment is not recommended as it may be slower updated than the python version below. 74 | 75 | If you have Docker installed, you can easily get Project Beehive up and running. Follow the steps below: 76 | 77 | 1. Open your terminal. 78 | 2. Pull the Docker image from the Docker Hub using the following command: 79 | 80 | ```bash 81 | docker pull ghcr.io/the-lodestone-project/beehive:latest 82 | ``` 83 | 84 | After pulling the image, run the Docker container with the following command: 85 | 86 | ```bash 87 | docker run -p 8000:8000 ghcr.io/the-lodestone-project/beehive:latest 88 | ``` 89 | 90 | This command will start Project Beehive and map it to port 8000 on your local machine. 91 | 92 | Open your web browser and navigate to http://localhost:8000 to access the bot. 93 | Please note that Docker must be installed and running on your machine to execute these steps. If you don't have Docker installed, you can download it from [here](https://docs.docker.com/get-docker/). 94 | 95 | ### Python 🐍 96 | 97 | If you dont have Docker installed, you can easily get Project Beehive up and running using python. Follow the steps below: 98 | 99 | 1. Open your terminal. 100 | 2. Clone the latest version of this repository using the following command: 101 | 102 | ```bash 103 | git clone https://github.com/the-lodestone-project/Beehive.git 104 | ``` 105 | 106 | 3. Move to the new directory: 107 | 108 | ```bash 109 | cd Beehive 110 | ``` 111 | 112 | 4. Install all the dependencies using following command: 113 | 114 | ```bash 115 | pip install -r requirements.txt 116 | ``` 117 | 118 | After cloning the repository and installing all the dependencies, run the python script with the following command: 119 | 120 | ```bash 121 | python main.py 122 | ``` 123 | 124 | This command will start Project Beehive and map it to port 8000 on your local machine. 125 | 126 | Open your web browser and navigate to http://localhost:8000 to access the bot. 127 | Please note that Python and pip must be installed and running on your machine to execute these steps. If you don't have python and pip installed, you can download it from [here](https://www.python.org/downloads/). 128 | 129 | ## images: 130 | 131 | ![alt text](https://i.imgur.com/RRHOgzp.png) 132 | 133 |
134 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import gradio as gr 2 | import lodestone 3 | from lodestone import plugins 4 | import time 5 | from lodestone import logger 6 | import glob 7 | import os 8 | from importlib import import_module 9 | import json 10 | from javascript import require 11 | import sys 12 | import threading 13 | import os 14 | import math 15 | import random 16 | import requests 17 | 18 | global created 19 | created = False 20 | global chat_history 21 | chat_history = [] 22 | global plugin_list 23 | plugin_list = [] 24 | global anti_afk_task_bool 25 | anti_afk_task_bool = True 26 | global bot_list 27 | bot_list = [] 28 | 29 | global auto_scripts 30 | auto_scripts = {} 31 | 32 | 33 | 34 | def get_bot_status(): 35 | if 'bot' in globals(): 36 | return "Stop Bot" 37 | else: 38 | return "Create Bot" 39 | 40 | 41 | 42 | def anti_afk_loop(): 43 | global anti_afk_task_bool 44 | while anti_afk_task_bool: 45 | try: 46 | yaw = 2 * random.random() * math.pi - (0.5 * math.pi) 47 | pitch = random.random() * math.pi - (0.5 * math.pi) 48 | bot.bot.look(yaw, pitch, False) 49 | time.sleep(3) 50 | bot.set_control_state('jump', True) 51 | if bot.entity.isInWater: 52 | bot.set_control_state('jump', False) 53 | time.sleep(3) 54 | bot.set_control_state('jump', False) 55 | time.sleep(2) 56 | arm = 'right' if random.random() < 0.5 else 'left' 57 | bot.bot.swingArm({'hand':arm}) 58 | except: 59 | break 60 | 61 | def is_open(ip,port): 62 | if "localhost" in ip: 63 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 64 | s.settimeout(10) 65 | try: 66 | s.connect((ip, int(port))) 67 | s.shutdown(2) 68 | s.settimeout(None) 69 | return True, 0 70 | except: 71 | return False, 0 72 | else: 73 | try: 74 | status = requests.get(f"https://api.mcstatus.io/v2/status/java/{ip}:{port}").json() 75 | if status["srv_record"]['port'] != port: 76 | port = status["srv_record"]['port'] 77 | gr.Warning(f"Server port is {port} not {port}!") 78 | return True, port 79 | elif status["srv_record"]['port'] == port: 80 | return True, 0 81 | else: 82 | return False, 0 83 | except: 84 | return True, 0 85 | 86 | 87 | global installed_plugins 88 | installed_plugins = [] 89 | isExist = os.path.exists("plugins") 90 | if not isExist: 91 | os.makedirs("plugins") 92 | 93 | isExist = os.path.exists("plugins/__init__.py") 94 | if not isExist: 95 | with open('plugins/__init__.py', 'w') as fp: 96 | pass 97 | 98 | for plugin in glob.glob("plugins/*.py"): 99 | if not "__init__" in plugin: 100 | name = plugin.replace(".py", "").replace("plugins/", "") 101 | installed_plugins.append(name) 102 | 103 | def create(email, auth, host, port, version, viewer, plugin, enable_viewer, skip_checks, anti_afk): 104 | 105 | email = email.replace(" ", "") 106 | host = host.replace(" ", "") 107 | host = host.replace(",", ".") 108 | 109 | try: 110 | if 'bot' in globals(): 111 | def stop_bot(): 112 | try: 113 | global bot 114 | bot.stop() 115 | gr.Info("Successfully stopped bot!") 116 | del bot 117 | except Exception as e: 118 | print(e) 119 | pass 120 | stop_bot() 121 | return "Already logged in!", "Already logged in!", "Create Bot" 122 | except Exception as e: 123 | print(e) 124 | pass 125 | if not host or not email or not version: 126 | gr.Warning("not all fields are filled in!") 127 | return "Unknown", "Unknown", "Create Bot" 128 | 129 | check, check_port = is_open(host, port) 130 | 131 | if not check_port == 0: 132 | port = check_port 133 | 134 | if check == False: 135 | gr.Warning("Server is offline!") 136 | return "Unknown", "Unknown", "Create Bot" 137 | 138 | if version == "auto": 139 | gr.Warning("Lodestone does currently not support version 1.20.2. Please make sure the server is running a supported version!") 140 | 141 | gr.Warning("If its your first time logging in you may need to login using the terminal!") 142 | 143 | global bot 144 | plugins = [] 145 | for plugin_ in plugin: 146 | try: 147 | plugins.append(import_module("plugins." + plugin_).plugin) 148 | except Exception as e: 149 | print(e) 150 | continue 151 | 152 | # plugin_str = "" 153 | # if plugin: 154 | # plugin_str += "Plugins: " 155 | # for new_plugin in plugin: 156 | # if new_plugin == "Schematic Builder": 157 | # plugin_str += "Schematic Builder, " 158 | # plugin_list.append(plugins.schematic) 159 | # elif new_plugin == "Cactus Farm Builder": 160 | # plugin_str += "Cactus Farm Builder, " 161 | # plugin_list.append(plugins.cactus) 162 | # elif new_plugin == "Discord Rich Presence": 163 | # plugin_str += "Discord Rich Presence, " 164 | # plugin_list.append(plugins.discordrp) 165 | # else: 166 | # pass 167 | if enable_viewer == False: 168 | enable_viewer = True 169 | elif enable_viewer == True: 170 | enable_viewer = False 171 | 172 | 173 | bot = lodestone.createBot( 174 | host=host, 175 | username=email, 176 | port=port, 177 | ls_viewer_port=viewer, 178 | version=version, 179 | profilesFolder="./cache", 180 | auth=auth, 181 | ls_disable_viewer=enable_viewer, 182 | ls_skip_checks=skip_checks, 183 | ls_plugin_list=plugins 184 | ) 185 | 186 | version_check = int(str(bot.bot.version).replace(".","")) 187 | 188 | if version_check >= 119: 189 | gr.Warning(f"Beehive viewer does not currently support {bot.bot.version} this will cause the viewer to not work") 190 | 191 | @bot.on('messagestr') 192 | def chat_history_add(this, message, messagePosition, jsonMsg, sender, *args): 193 | message = str(message).replace("\n","") 194 | if str(sender).lower() == "none": 195 | chat_history.append(f"{message}") 196 | else: 197 | chat_history.append(f"{sender}: {message}") 198 | 199 | 200 | if auto_scripts: 201 | for script_name, script_data in auto_scripts.items(): 202 | if script_data["event"] == "Start once spawn": 203 | for text in script_data["script"]: 204 | if text != "": 205 | bot.chat(text) 206 | time.sleep(script_data["delay"]) 207 | gr.Info(f"Successfully ran script {script_name}") 208 | elif script_data["event"] == "Start on time (See Advanced Options)": 209 | def run_time_script(): 210 | while True: 211 | for text in script_data["script"]: 212 | if text != "": 213 | bot.chat(text) 214 | time.sleep(script_data["delay"]) 215 | time.sleep(script_data["every"]) 216 | threading.Thread(target=run_time_script, daemon=True).start() 217 | else: 218 | pass 219 | 220 | 221 | if anti_afk == True: 222 | global anti_afk_task 223 | anti_afk_task = threading.Thread(target=anti_afk_loop) 224 | anti_afk_task.start() 225 | gr.Info("Successfully started anti afk! You can disable this on the Movements tab") 226 | 227 | 228 | info =f"""Successfully logged in as {bot.username}""" 229 | 230 | 231 | bot_list.append({f"{email}": bot}) 232 | gr.Info(f"Successfully logged in as {bot.username}") 233 | return bot.username, info, "Stop Bot" 234 | 235 | 236 | def create_multiple(email, auth, host, port, version, amount): 237 | try: 238 | if 'bot' in globals(): 239 | def stop_bot(): 240 | try: 241 | global bot 242 | bot.stop() 243 | gr.Info("Successfully stopped bot!") 244 | del bot 245 | except Exception as e: 246 | print(e) 247 | pass 248 | stop_bot() 249 | return "Already logged in!", "Already logged in!", "Create Bot" 250 | except Exception as e: 251 | print(e) 252 | pass 253 | if not host or not email or not version: 254 | gr.Warning("not all fields are filled in!") 255 | return "Unknown", "Unknown", "Create Bot" 256 | 257 | 258 | for bots in range(0, amount): 259 | lodestone.createBot( 260 | host=host, 261 | username=email+str(bots), 262 | port=port, 263 | ls_disable_viewer=True, 264 | version=version, 265 | profilesFolder="./cache", 266 | auth=auth, 267 | ls_skip_checks=True, 268 | ) 269 | 270 | global bot 271 | bot = amount 272 | # @bot.on('messagestr') 273 | # def chat(this, message, messagePosition, jsonMsg, sender, *args): 274 | # message = str(message).replace("\n","") 275 | # if str(sender).lower() == "none": 276 | # chat_history.append(f"{message}") 277 | # else: 278 | # chat_history.append(f"{sender}: {message}") 279 | 280 | info =f"""Successfully created {amount} bots!""" 281 | 282 | 283 | 284 | gr.Info(f"Successfully created {amount} bots!") 285 | return amount, info, "Stop Bot" 286 | 287 | 288 | 289 | def get_username(): 290 | if 'bot' in globals(): 291 | return bot.username 292 | else: 293 | return "None" 294 | 295 | 296 | 297 | def get_player_health(): 298 | if 'bot' in globals(): 299 | return bot.health 300 | else: 301 | return "Unknown" 302 | 303 | def get_player_food(): 304 | if 'bot' in globals(): 305 | return bot.food 306 | else: 307 | return "Unknown" 308 | 309 | def get_player_experience(): 310 | if 'bot' in globals(): 311 | return bot.experience.level 312 | else: 313 | return "Unknown" 314 | 315 | def get_player_difficulty(): 316 | if 'bot' in globals(): 317 | 318 | if bot.settings.difficulty == 0: 319 | return "peaceful" 320 | elif bot.settings.difficulty == 1: 321 | return "easy" 322 | elif bot.settings.difficulty == 2: 323 | return "normal" 324 | elif bot.settings.difficulty == 3: 325 | return "hard" 326 | 327 | else: 328 | return "Unknown" 329 | 330 | 331 | def get_all_data(): 332 | if 'bot' in globals(): 333 | return bot.player 334 | else: 335 | return "Unknown" 336 | 337 | 338 | 339 | 340 | def get_latest_chats(): 341 | if 'bot' in globals(): 342 | if len(chat_history) > 200: 343 | chat_history.clear() 344 | return "No chat messages yet!" 345 | string = "" 346 | for i in chat_history[-40:]: 347 | string += i + "\n" 348 | return string 349 | else: 350 | return "No chat messages yet!" 351 | 352 | 353 | 354 | # def upload_file(files): 355 | # global build_file 356 | # file_paths = [file.name for file in files] 357 | # build_file = file_paths 358 | # print(file_paths) 359 | # return file_paths 360 | 361 | 362 | def build_schematic(files, x, z): 363 | if not files: 364 | gr.Warning("not all fields are filled in!") 365 | return 366 | if 'bot' in globals(): 367 | if not x or not z: 368 | if x != 0 or z != 0: 369 | bot.goto(x=x, y=0, z=z) 370 | time.sleep(2) 371 | gr.Info(f"Successfully building schematic at {x}, {z}") 372 | bot.build_schematic(f'{files.name}') 373 | else: 374 | gr.Warning("You need to login first!") 375 | 376 | 377 | 378 | with gr.Blocks(theme=gr.themes.Soft(), title="The Lodestone Project", css=".output_image { display: block; margin: auto; }") as ui: 379 | with gr.Accordion("How to use", open=False): 380 | gr.Markdown("""# How to Use Project Beehive 381 | 382 | ## Creating Bots 383 | 384 | Go to the "Bot Settings" tab. 385 | 386 | ### Single Bot 387 | 388 | 1. Enter your desired username, authentication method, server IP, port, and version. 389 | 2. (Optional) Enable viewing, skip checks, anti-AFK, choose plugins, and set viewer port. 390 | 3. Click the "Create Bot" button. 391 | 392 | ### Multiple Bots 393 | 394 | 1. Enter a username prefix, authentication method, server IP, port, version, and number of bots. 395 | 2. (Optional) Enable viewing and set viewer port. 396 | 3. Click the "Create Bots" button. 397 | 398 | ## Controlling the Bot 399 | 400 | ### Chatting 401 | 402 | Go to the "Chat" tab. 403 | 404 | 1. Type a message in the text box. 405 | 2. (Optional) Enable whispering to choose a player, and add prefixes/suffixes. 406 | 3. Click "Send Message" or press Enter to send the message. 407 | 408 | ## Using Plugins 409 | 410 | Go to the "Plugins" tab. 411 | 412 | ### Downloading Plugins 413 | 414 | 1. Go to the Plugin Manager tab. 415 | 2. Find a plugin and click "Download". 416 | 3. Restart the app to load the new plugin. 417 | 418 | ### Using Schematic Builder 419 | 420 | 1. Go to the Schematic Builder tab. 421 | 2. Upload your .schematic file. 422 | 3. (Optional) Set coordinates to build at. 423 | 4. Click "Build Schematic". 424 | 425 | ### Enabling Discord Rich Presence 426 | 427 | 1. Go to the Discord Rich Presence tab. 428 | 2. Enter a state, details, images, and text. 429 | 3. Click "Update Presence" to set the status. 430 | 431 | ### Writing Custom Plugins 432 | 433 | 1. Go to the Custom Plugins tab. 434 | 2. Enter Python code to execute. 435 | 3. Click "Run" to run the code on the bot. 436 | 437 | Let me know if you need any clarification or have additional questions! 438 | 439 | ### Moving 440 | 441 | Go to the "Movements" tab. 442 | 443 | 1. Click buttons to make the bot jump, walk in directions, or start/stop anti-AFK. 444 | 445 | ### Automating 446 | 447 | Go to the "Automation" tab. 448 | 449 | 1. Enter chat commands into the script text area. 450 | 2. (Optional) Set frequency and delay options. 451 | 3. Enter a script name. 452 | 4. Choose a start option like on spawn or timed. 453 | 5. Click "Add Script". 454 | 455 | ## Monitoring 456 | 457 | Go to the "Player Info" and "System Resources" tabs to monitor health, food, experience and more. All data updates automatically. 458 | """) 459 | # with gr.Tab("Welcome to project Behive!"): 460 | # gr.Markdown("Project Beehive is an open source Minecraft bot with a goal to provide players access to helpful gameplay features at no cost. Developed with a clean user interface, Project Beehive offers various plugins and options similar to paid alternatives out there. The project is completely free, open source, and welcoming to contributions from the Minecraft community. Check the wiki for information on plugins, setup guides, contributing, and more. We aim to provide Minecraft players with an easy-to-use bot to enhance their gameplay experience without needing to pay.") 461 | 462 | 463 | 464 | with gr.Tab("Bot Settings"): 465 | # gr.Markdown(requests.get('https://raw.githubusercontent.com/the-lodestone-project/Lodestone/main/README.md').text) 466 | # gr.Image("https://github.com/the-lodestone-project/Lodestone/blob/main/assets/logo.png?raw=true", min_width=2000) 467 | with gr.Tab("Single Bot"): 468 | with gr.Row(): 469 | with gr.Column(scale=2, ): 470 | email = gr.Textbox(placeholder="Notch", label="Username",info="Username to login with") 471 | auth = gr.Dropdown(["microsoft", "offline"], value="microsoft", label="Authentication Method",info="Authentication method to login with") 472 | host = gr.Textbox(placeholder="2b2t.org", label="Server Ip",info="Server ip to connect to") 473 | port = gr.Number(value=25565, label="Sever Port", info="Server port to connect to. Most servers use 25565",precision=0) 474 | version = gr.Dropdown(["auto","1.20", "1.19", "1.18", "1.17", "1.16.4", "1.16", "1.15", "1.14", "1.13", "1.12", "1.11", "1.10", "1.9", "1.8"], value="auto", label="Version",info="Version to connect with. Use auto to automatically detect the version of the server") 475 | with gr.Accordion("Optional Settings", open=False): 476 | enable_viewer = gr.Checkbox(value=True, label="Enable Viewer", info="Enable the viewer to see the bot's view",interactive=True) 477 | skip_checks = gr.Checkbox(value=True, label="Skip Checks/Updates", info="Skip checks to speed up the bot",interactive=True) 478 | anti_afk = gr.Checkbox(value=True, label="Anti AFK", info="Enable anti afk",interactive=True) 479 | viewer = gr.Number(value=5001, label="Viewer Port", info="Viewer port to display the bot's view",precision=0) 480 | plugin = gr.Dropdown(installed_plugins,multiselect=True, label="Plugins",info="Plugins to load on startup") 481 | btn = gr.Button(value=get_bot_status,variant='primary', every=5) 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | with gr.Column(scale=1, visible=False): 490 | out_username = gr.Textbox(value="", label="Logged in as") 491 | info = gr.Textbox(value="", label="Info") 492 | 493 | with gr.Column(scale=1, ): 494 | 495 | def get_skin(): 496 | if 'bot' in globals(): 497 | if bot.local_auth == "offline": 498 | return "https://github.com/the-lodestone-project/Beehive/blob/main/assets/345.png?raw=true" 499 | else: 500 | return f"https://mc-heads.net/player/{bot.bot.username}/345" 501 | else: 502 | return "https://github.com/the-lodestone-project/Beehive/blob/main/assets/345.png?raw=true" 503 | 504 | skin = gr.Image(value=get_skin, label="Skin", every=10, width=500, show_download_button=False, elem_id="output_image") 505 | 506 | 507 | 508 | btn.click(create, inputs=[email, auth, host, port, version, viewer, plugin, enable_viewer, skip_checks, anti_afk], outputs=[out_username, info, btn], show_progress="minimal") 509 | with gr.Tab("Multiple Bots"): 510 | with gr.Column(scale=1): 511 | email = gr.Textbox(placeholder="Notch", label="Username Prefix",info="Username prefix. The bot will login with this prefix and a number after it") 512 | auth = gr.Dropdown(["offline"], value="offline", label="Authentication Method",info="Authentication method to login with") 513 | host = gr.Textbox(placeholder="2b2t.org", label="Server Ip",info="Server ip to connect to") 514 | port = gr.Number(value=25565, label="Sever Port", info="Server port to connect to. Most servers use 25565",precision=0) 515 | version = gr.Dropdown(["auto","1.20", "1.19", "1.18", "1.17", "1.16.4", "1.16", "1.15", "1.14", "1.13", "1.12", "1.11", "1.10", "1.9", "1.8"], value="auto", label="Version",info="Version to connect with. Use auto to automatically detect the version of the server") 516 | amount = gr.Slider(minimum=1, maximum=50, step=1, label="Amount", info="Amount of bots to create", interactive=True) 517 | with gr.Accordion("Optional Settings", open=False): 518 | enable_viewer = gr.Checkbox(value=False, label="Enable Viewer", info="Enable the viewer to see the bot's view",interactive=False) 519 | viewer = gr.Number(value=5001, label="Viewer Port", info="Viewer port to display the bot's view",precision=0, interactive=False) 520 | # plugin = gr.Dropdown(["Schematic Builder", "Cactus Farm Builder", "Discord Rich Presence"],multiselect=True, label="Plugins",info="Plugins to load on startup") 521 | btn = gr.Button(value=get_bot_status,variant='primary', every=5) 522 | 523 | 524 | 525 | 526 | out_username = gr.Textbox(value="", label="Bot count") 527 | info = gr.Textbox(value="", label="Info") 528 | 529 | 530 | btn.click(create_multiple, inputs=[email, auth, host, port, version, amount], outputs=[out_username, info, btn], show_progress="minimal") 531 | 532 | with gr.Tab("Chat"): 533 | chat = gr.Textbox(value=get_latest_chats,every=2,label="Chat History (Updated every 2 seconds)",lines=20, max_lines=20, min_width=100, autoscroll=True, autofocus=False) 534 | with gr.Accordion("Advanced Options", open=False): 535 | with gr.Column(scale=1): 536 | whisper = gr.Checkbox(value=False, label="Whisper", info="Whisper the message to the player",interactive=True) 537 | whisper_player = gr.Dropdown([],show_label=False, info="The player to whisper to (Updated every 20 seconds)",interactive=True) 538 | # get_players = gr.Button("Get Players", variant='primary') 539 | 540 | 541 | with gr.Column(scale=1): 542 | prefix = gr.Textbox(value="", show_label=False, info="Prefix to add to the start of the message",interactive=True) 543 | suffix = gr.Textbox(value="", show_label=False, info="Suffix to add to the end of the message",interactive=True) 544 | 545 | 546 | 547 | 548 | def get_players_def(): 549 | if 'bot' in globals(): 550 | global players 551 | players = [] 552 | for player in bot.bot.players.valueOf(): 553 | players.append(player) 554 | players.remove(bot.username) 555 | return gr.Dropdown(choices=players) 556 | else: 557 | return gr.Dropdown([]) 558 | 559 | def just_some_random_update(): 560 | return time.time() 561 | 562 | updates = gr.Textbox(value=just_some_random_update, every=20, show_label=False, visible=False) 563 | 564 | 565 | updates.change(get_players_def, outputs=[whisper_player]) 566 | 567 | with gr.Row(): 568 | with gr.Column(scale=2, ): 569 | msg = gr.Textbox(show_label=False, container=False, placeholder="Type an message...", autofocus=True) 570 | with gr.Column(scale=1, ): 571 | send_message = gr.Button("Send Message", variant='primary') 572 | clear = gr.ClearButton([msg, chat],value="Clear Chat History") 573 | 574 | def respond(message, whisper, whisper_player, prefix, suffix): 575 | if 'bot' in globals(): 576 | if message != "": 577 | if whisper and whisper_player != None or "": 578 | bot.whisper(whisper_player, f"{prefix}{message}{suffix}") 579 | if not whisper: 580 | bot.chat(f"{prefix}{message}{suffix}") 581 | return "" 582 | else: 583 | gr.Warning("You need to create a bot first!") 584 | return "" 585 | 586 | def delete(): 587 | chat_history.clear() 588 | 589 | clear.click(delete) 590 | send_message.click(respond, inputs=[msg, whisper, whisper_player, prefix, suffix],outputs=[msg]) 591 | msg.submit(respond, inputs=[msg, whisper, whisper_player, prefix, suffix],outputs=[msg]) 592 | 593 | with gr.Tab("Plugins"): 594 | with gr.Tab("Plugin Manager"): 595 | 596 | def download_plugin(plugin_data): 597 | plugin_files = list(plugin_data['files']) 598 | for file in plugin_files: 599 | plugin = requests.get(f"https://raw.githubusercontent.com/the-lodestone-project/Plugins/main/plugins/{file}") 600 | with open(f"plugins/{file}", "wb") as f: 601 | f.write(plugin.content) 602 | 603 | gr.Warning("Please restart to load the plugin! (You can do this by clicking the restart button on the 'Restart & Settings' tab)") 604 | return gr.Button("Requires Restart", interactive=False, variant='stop') 605 | 606 | plugin_index = requests.get("https://raw.githubusercontent.com/the-lodestone-project/Plugins/main/plugin_index.json").json() 607 | for plugin_name, plugin_data in plugin_index.items(): 608 | with gr.Row(variant="panel"): 609 | with gr.Column(scale=4): 610 | with gr.Accordion(f"{plugin_name} - {plugin_data['description']} - v{plugin_data['version']}", open=False): 611 | with gr.Column(scale=1, ): 612 | plugin_obj = gr.JSON(plugin_data, container=False, show_label=False) 613 | with gr.Column(scale=1): 614 | isExist = os.path.exists(f"plugins/{plugin_name}.py") 615 | if isExist: 616 | gr.Button(f"Installed", interactive=False) 617 | else: 618 | plugin_name = gr.Button(f"Download", variant='primary') 619 | plugin_name.click(download_plugin, inputs=[plugin_obj], outputs=[plugin_name]) 620 | 621 | delete_plugins_button = gr.Button("Remove All Plugins", variant='stop') 622 | def delete_plugins_function(): 623 | for plugin in glob.glob("plugins/*.py"): 624 | if not "__init__" in plugin: 625 | os.remove(plugin) 626 | gr.Info("Successfully removed all plugins!") 627 | gr.Warning("Please restart to clean the plugin cache! (You can do this by clicking the restart button on the 'Restart & Settings' tab)") 628 | delete_plugins_button.click(delete_plugins_function) 629 | 630 | 631 | with gr.Tab("Installed Plugins"): 632 | if not installed_plugins == []: 633 | if "schematic_builder" in str(installed_plugins): 634 | with gr.Tab("Schematic Builder"): 635 | file_output = gr.File(file_types=[".schematic", ".nbt", ".schem"], label="Schematic File (.schematic .nbt .schem)",file_count="single") 636 | with gr.Accordion("Advanced Options", open=False): 637 | with gr.Row(): 638 | with gr.Column(scale=1, ): 639 | x = gr.Number(label="X Coordinate",info="The X coord to build at", precision=0) 640 | with gr.Column(scale=1, ): 641 | z = gr.Number(label="Z Coordinate",info="The Z coord to build at", precision=0) 642 | build = gr.Button("Build schematic", variant='primary') 643 | build.click(build_schematic, inputs=[file_output, x, z]) 644 | 645 | if "cactus_farm_builder" in str(installed_plugins): 646 | with gr.Tab("Build Cactus Farm"): 647 | gr.Markdown("") 648 | 649 | if "auto_farmer" in str(installed_plugins): 650 | with gr.Tab("Auto Farm"): 651 | with gr.Row(): 652 | with gr.Column(scale=1, ): 653 | crop_type = gr.Dropdown(["wheat_seeds", "wheat", "beetroot_seeds", "beetroot", "carrot", "potato", "poisonous_potato", "melon", "melon_slice", "melon_seeds", "melon_stem", "attached_melon_stem", "pumpkin", "carved_pumpkin", "pumpkin_seeds", "pumpkin_stem", "attached_pumpkin_stem", "torchflower_seeds", "torchflower_crop", "torchflower", "pitcher_pod", "pitcher_crop", "pitcher_plant", "farmland", "bamboo", "cocoa_beans", "sugar_cane", "sweet_berries", "cactus", "mushrooms", "kelp", "sea_pickle", "nether_wart", "chorus_fruit", "fungus", "glow_berries"], label="Crop Type",info="The Crop type to farm", interactive=True) 654 | with gr.Column(scale=1, ): 655 | seed_name = gr.Dropdown(["wheat_seeds", "wheat", "beetroot_seeds", "beetroot", "carrot", "potato", "poisonous_potato", "melon", "melon_slice", "melon_seeds", "melon_stem", "attached_melon_stem", "pumpkin", "carved_pumpkin", "pumpkin_seeds", "pumpkin_stem", "attached_pumpkin_stem", "torchflower_seeds", "torchflower_crop", "torchflower", "pitcher_pod", "pitcher_crop", "pitcher_plant", "farmland", "bamboo", "cocoa_beans", "sugar_cane", "sweet_berries", "cactus", "mushrooms", "kelp", "sea_pickle", "nether_wart", "chorus_fruit", "fungus", "glow_berries"], label="Seed Name",info="The Seed name to plant back", interactive=True) 656 | with gr.Column(scale=1, ): 657 | harvest_name = gr.Dropdown(["wheat_seeds", "wheat", "beetroot_seeds", "beetroot", "carrot", "potato", "poisonous_potato", "melon", "melon_slice", "melon_seeds", "melon_stem", "attached_melon_stem", "pumpkin", "carved_pumpkin", "pumpkin_seeds", "pumpkin_stem", "attached_pumpkin_stem", "torchflower_seeds", "torchflower_crop", "torchflower", "pitcher_pod", "pitcher_crop", "pitcher_plant", "farmland", "bamboo", "cocoa_beans", "sugar_cane", "sweet_berries", "cactus", "mushrooms", "kelp", "sea_pickle", "nether_wart", "chorus_fruit", "fungus", "glow_berries"], label="Harvest Name",info="The block name to harvest", interactive=True) 658 | 659 | with gr.Row(): 660 | with gr.Column(scale=1, ): 661 | x = gr.Number(label="X Coordinate",info="The X coord to build at", precision=0) 662 | with gr.Column(scale=1, ): 663 | z = gr.Number(label="Z Coordinate",info="The Z coord to build at", precision=0) 664 | 665 | with gr.Row(): 666 | with gr.Column(scale=1, ): 667 | x = gr.Number(label="X Coordinate",info="The X coord to build at", precision=0) 668 | with gr.Column(scale=1, ): 669 | z = gr.Number(label="Z Coordinate",info="The Z coord to build at", precision=0) 670 | with gr.Accordion("Optional Settings", open=False): 671 | gr.Markdown("Optional Settings") 672 | start_farm = gr.Button("Start auto Farming", variant='primary') 673 | 674 | 675 | if "discordrp" in str(installed_plugins): 676 | with gr.Tab("Discord Rich Presence"): 677 | with gr.Row(): 678 | with gr.Column(scale=1, ): 679 | state = gr.Textbox(label="State",info="The state to display") 680 | with gr.Column(scale=1, ): 681 | details = gr.Textbox(label="Details",info="The details to display") 682 | with gr.Column(scale=1, ): 683 | large_image = gr.Textbox(label="Large Image (url)",info="The large image to display") 684 | with gr.Column(scale=1, ): 685 | large_text = gr.Textbox(label="Large Text",info="The large text to display") 686 | with gr.Column(scale=1, ): 687 | small_image = gr.Textbox(label="Small Image (url)",info="The small image to display") 688 | with gr.Column(scale=1, ): 689 | small_text = gr.Textbox(label="Small Text",info="The small text to display") 690 | 691 | def update_presence_def(state="No state provided", details="No details Provided", large_image=None, large_text=None, small_image=None, small_text=None): 692 | print(details) 693 | if 'bot' in globals(): 694 | bot.discordrp(state=state, details=details, start=time.time()) 695 | gr.Info("Successfully updated presence!") 696 | else: 697 | pass 698 | 699 | update_presence = gr.Button("Update Presence", variant='primary') 700 | update_presence.click(update_presence_def, inputs=[state, details, large_image, large_text, small_image, small_text]) 701 | else: 702 | gr.Textbox(value="No plugins installed!\nIf you have installed plugins please restart.", show_label=False, interactive=False) 703 | with gr.Tab("Custom Plugins"): 704 | command = gr.Textbox(placeholder="bot.run_custom_command()", label="Custom Plugins",info="Run your own custom plugins") 705 | run = gr.Button("Run", variant='primary') 706 | def run_custom_plugin(command): 707 | if 'bot' in globals(): 708 | if command != "": 709 | try: 710 | exec(command) 711 | gr.Info(f"Successfully ran command {command}") 712 | return command 713 | except: 714 | gr.Warning("Invalid command!") 715 | return command 716 | return command 717 | else: 718 | gr.Warning("You need to login first!") 719 | return command 720 | 721 | run.click(run_custom_plugin, inputs=[command], outputs=[command]) 722 | 723 | with gr.Tab("Movements"): 724 | with gr.Tab("Anti AFK"): 725 | def check_if_anti_afk(): 726 | if anti_afk_task_bool == True and 'bot' in globals(): 727 | return "Stop Anti AFK" 728 | else: 729 | return "Start Anti AFK" 730 | 731 | def start_and_stop_anti_afk(): 732 | global anti_afk_task_bool 733 | if 'bot' in globals(): 734 | if anti_afk_task_bool == True: 735 | 736 | anti_afk_task_bool = False 737 | gr.Info("Successfully stopped anti afk!") 738 | else: 739 | global anti_afk_task 740 | anti_afk_task_bool = True 741 | anti_afk_task = threading.Thread(target=anti_afk_loop) 742 | anti_afk_task.start() 743 | gr.Info("Successfully started anti afk!") 744 | else: 745 | gr.Warning("You need to login first!") 746 | 747 | 748 | start_anti_afk = gr.Button(value=check_if_anti_afk, every=5, variant='primary') 749 | 750 | 751 | 752 | start_anti_afk.click(start_and_stop_anti_afk) 753 | 754 | 755 | 756 | with gr.Tab("Basic Movements"): 757 | with gr.Row(): 758 | with gr.Column(scale=1, ): 759 | jump = gr.Button("Start Jumping") 760 | jump = gr.Button("Stop Jumping") 761 | with gr.Column(scale=1, ): 762 | jump = gr.Button("Start walking forward") 763 | jump = gr.Button("Stop walking forward") 764 | with gr.Tab("Follow Player/Entity"): 765 | gr.Markdown("") 766 | 767 | 768 | with gr.Tab("Automation"): 769 | with gr.Tab("Script Scheduler"): 770 | with gr.Row(): 771 | with gr.Column(scale=2, ): 772 | new_script = gr.Textbox(placeholder="Enter your chat commands here.",every=2,label="Automated Script",lines=20, max_lines=20, min_width=100, autoscroll=True, autofocus=False) 773 | with gr.Column(scale=1, ): 774 | with gr.Accordion("Active Scripts", open=True): 775 | def get_active_scripts(): 776 | # string = "" 777 | # for script_name, script_data in auto_scripts.items(): 778 | # string += f"""### {script_data['name']}\nCommands:\n""" 779 | # scripts = [text for text in str(script_data["script"]).split("\n")] 780 | # for text in scripts: 781 | # if text != "": 782 | # string += f"""* {text}\n""" 783 | # string += f"""\n""" 784 | # string += f"""Every {script_data['every']} seconds\n\n""" 785 | # string += f"""Delay: {script_data['delay']} seconds\n\n""" 786 | # string += """---\n""" 787 | # return string 788 | return auto_scripts 789 | 790 | gr.JSON(value=get_active_scripts, label="Active Scripts (Updated every 5 seconds)", every=5) 791 | with gr.Accordion("Advanced Script Options", open=False): 792 | every_time = gr.Number(value=100, label="Every (seconds)",info="How often to run the script (in seconds)",interactive=True) 793 | script_delay = gr.Slider(minimum=1, maximum=50, step=1, label="Delay (seconds)",info="Delay between chat commands (in seconds)",interactive=True) 794 | 795 | with gr.Row(): 796 | with gr.Column(scale=2, ): 797 | script_name = gr.Textbox(show_label=False, container=False, placeholder="Script Name", autofocus=True) 798 | with gr.Column(scale=1, ): 799 | script_start_on = gr.Dropdown(choices=["Start once spawn", "Start on time (See Advanced Options)"], value="Start once spawn", show_label=False, container=False, ) 800 | with gr.Column(scale=1, ): 801 | add_script_to = gr.Button("Add Script", variant='primary') 802 | clear = gr.ClearButton([script_name],value="Remove All Scripts") 803 | 804 | def delete(): 805 | auto_scripts.clear() 806 | gr.Info("Successfully removed all scripts!") 807 | 808 | 809 | def add_script(new_script, every_time, script_name, script_start_on, script_delay): 810 | global auto_scripts 811 | if not new_script or not every_time or not script_name or not script_start_on: 812 | gr.Warning("not all fields are filled in!") 813 | return new_script, script_name 814 | else: 815 | commands = [text for text in str(new_script).split("\n")] 816 | auto_scripts[script_name] = {"script": commands, "every": every_time, "name": script_name, "event": script_start_on, "delay": script_delay} 817 | gr.Info(f"Successfully added script {script_name} to the scheduler!") 818 | return "", "" 819 | 820 | clear.click(delete) 821 | add_script_to.click(add_script, inputs=[new_script, every_time, script_name, script_start_on, script_delay], outputs=[new_script, script_name]) 822 | 823 | 824 | 825 | with gr.Tab("Player Info"): 826 | # refresh_button = gr.Button("Refresh") 827 | with gr.Accordion("Bot Info", open=False): 828 | with gr.Row(): 829 | with gr.Column(scale=1): 830 | health = gr.Textbox(value=get_player_health, label=f"Health", every=5) 831 | with gr.Column(scale=1): 832 | food = gr.Textbox(value=get_player_food, label=f"Food", every=5) 833 | with gr.Column(scale=1): 834 | experience = gr.Textbox(value=get_player_experience, label=f"Experience Level", every=5) 835 | with gr.Column(scale=1): 836 | difficulty = gr.Textbox(value=get_player_difficulty, label=f"Difficulty", every=5) 837 | with gr.Column(scale=1): 838 | all_data = gr.Textbox(value=get_all_data, label=f"All Data", every=5) 839 | with gr.Accordion("Online Player Info", open=False): 840 | pass 841 | # refresh_button.click(get_player_info, outputs=[health, food, experience]) 842 | 843 | with gr.Tab("System Resources"): 844 | # refresh_button = gr.Button("Refresh") 845 | import psutil 846 | import platform 847 | 848 | def cpu(): 849 | return psutil.cpu_percent(interval=5) 850 | 851 | def ram_used(): 852 | return psutil.virtual_memory().percent 853 | 854 | def ram_available(): 855 | 856 | ram= psutil.virtual_memory().available / (1024.0 ** 3) 857 | return "{:.1f}".format(ram) 858 | 859 | 860 | with gr.Row(): 861 | with gr.Column(scale=1): 862 | health = gr.Textbox(value=ram_used, label=f"Ram Used (%)", every=5) 863 | with gr.Column(scale=1): 864 | food = gr.Textbox(value=ram_available, label=f"Available Ram (GB)", every=5) 865 | with gr.Column(scale=1): 866 | experience = gr.Textbox(value=cpu, label=f"CPU usage (%)", every=5) 867 | with gr.Column(scale=1): 868 | difficulty = gr.Textbox(value=platform.system, label=f"System Type") 869 | 870 | with gr.Tab("Restart & Settings"): 871 | restart = gr.Button("Restart", variant='stop') 872 | def restart_program(): 873 | gr.Info("Restarting... (please refresh the page after 15 seconds)") 874 | time.sleep(3) 875 | """Restarts the current program, with file objects and descriptors 876 | cleanup 877 | """ 878 | 879 | try: 880 | p = psutil.Process(os.getpid()) 881 | for handler in p.open_files() + p.connections(): 882 | os.close(handler.fd) 883 | except Exception as e: 884 | print(e) 885 | 886 | python = sys.executable 887 | os.execl(python, python, *sys.argv) 888 | restart.click(restart_program) 889 | 890 | 891 | username = "lodestone" 892 | password = "lodestone" 893 | 894 | 895 | try: 896 | logger.info("Running!\nURL: http://localhost:8000\nUsername: lodestone\nPassword: lodestone\n") 897 | SECRET_KEY = os.environ.get('RUN_DOCKER', False) 898 | 899 | if SECRET_KEY: 900 | ui.queue().launch(ssl_verify=False, server_name="0.0.0.0",server_port=8000, show_api=False, auth=(f'{username}', f'{password}'), share=False, quiet=True, auth_message="Please login with your set username and password. These are not your Minecraft credentials.") 901 | else: 902 | import socket 903 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 904 | s.connect(("8.8.8.8", 80)) 905 | ip = s.getsockname()[0] 906 | s.close() 907 | ui.queue().launch(ssl_verify=False, server_name=f"{ip}",server_port=8000, show_api=False, auth=(f'{username}', f'{password}'), share=False, quiet=True, auth_message="Please login with your set username and password. These are not your Minecraft credentials.") 908 | except OSError: 909 | raise OSError(f"Port 8000 is already in use!") --------------------------------------------------------------------------------