Upload 3 files
Browse files- Dockerfile.txt +29 -0
- main.py +576 -0
- requirements.txt +2 -0
Dockerfile.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
EXPOS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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import lodestone
|
| 3 |
+
from lodestone import plugins
|
| 4 |
+
import time
|
| 5 |
+
from lodestone import logger
|
| 6 |
+
from javascript import require
|
| 7 |
+
import requests
|
| 8 |
+
|
| 9 |
+
global created
|
| 10 |
+
created = False
|
| 11 |
+
global chat_history
|
| 12 |
+
chat_history = []
|
| 13 |
+
global plugin_list
|
| 14 |
+
plugin_list = []
|
| 15 |
+
|
| 16 |
+
global bot_list
|
| 17 |
+
bot_list = []
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
css = """
|
| 22 |
+
.error {
|
| 23 |
+
color: red
|
| 24 |
+
}
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def get_bot_status():
|
| 30 |
+
if 'bot' in globals():
|
| 31 |
+
return "Stop Bot"
|
| 32 |
+
else:
|
| 33 |
+
return "Start/Stop Bot"
|
| 34 |
+
|
| 35 |
+
def change_tab():
|
| 36 |
+
return gr.Tabs.update(selected=1)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def create(email, auth, host, port, version, viewer, plugin, enable_viewer, skip_checks):
|
| 43 |
+
try:
|
| 44 |
+
if 'bot' in globals():
|
| 45 |
+
def stop_bot():
|
| 46 |
+
try:
|
| 47 |
+
global bot
|
| 48 |
+
bot.stop()
|
| 49 |
+
gr.Info("Successfully stopped bot!")
|
| 50 |
+
del bot
|
| 51 |
+
except Exception as e:
|
| 52 |
+
print(e)
|
| 53 |
+
pass
|
| 54 |
+
stop_bot()
|
| 55 |
+
return "Already logged in!", "Already logged in!", "Login/Create Bot"
|
| 56 |
+
except Exception as e:
|
| 57 |
+
print(e)
|
| 58 |
+
pass
|
| 59 |
+
if not host or not email or not version:
|
| 60 |
+
gr.Warning("not all fields are filled in!")
|
| 61 |
+
return "Unknown", "Unknown", "Login/Create Bot"
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
global bot
|
| 65 |
+
plugin_str = ""
|
| 66 |
+
if plugin:
|
| 67 |
+
plugin_str += "Plugins: "
|
| 68 |
+
for new_plugin in plugin:
|
| 69 |
+
if new_plugin == "Schematic Builder":
|
| 70 |
+
plugin_str += "Schematic Builder, "
|
| 71 |
+
plugin_list.append(plugins.schematic)
|
| 72 |
+
elif new_plugin == "Cactus Farm Builder":
|
| 73 |
+
plugin_str += "Cactus Farm Builder, "
|
| 74 |
+
plugin_list.append(plugins.cactus)
|
| 75 |
+
elif new_plugin == "Discord Rich Presence":
|
| 76 |
+
plugin_str += "Discord Rich Presence, "
|
| 77 |
+
plugin_list.append(plugins.discordrp)
|
| 78 |
+
else:
|
| 79 |
+
pass
|
| 80 |
+
if enable_viewer == False:
|
| 81 |
+
enable_viewer = True
|
| 82 |
+
elif enable_viewer == True:
|
| 83 |
+
enable_viewer = False
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
bot = lodestone.createBot(
|
| 87 |
+
host=host,
|
| 88 |
+
username=email,
|
| 89 |
+
port=port,
|
| 90 |
+
ls_viewer_port=viewer,
|
| 91 |
+
version=version,
|
| 92 |
+
profilesFolder="./cache",
|
| 93 |
+
auth=auth,
|
| 94 |
+
ls_disable_viewer=enable_viewer,
|
| 95 |
+
ls_skip_checks=skip_checks,
|
| 96 |
+
ls_plugin_list=plugin_list
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
version_check = int(str(bot.bot.version).replace(".",""))
|
| 100 |
+
|
| 101 |
+
if version_check >= 119:
|
| 102 |
+
gr.Warning(f"Beehive viewer does not currently support {bot.bot.version} this will cause the viewer to not work")
|
| 103 |
+
|
| 104 |
+
@bot.on('messagestr')
|
| 105 |
+
def chat_history_add(this, message, messagePosition, jsonMsg, sender, *args):
|
| 106 |
+
message = str(message).replace("\n","")
|
| 107 |
+
if str(sender).lower() == "none":
|
| 108 |
+
chat_history.append(f"{message}")
|
| 109 |
+
else:
|
| 110 |
+
chat_history.append(f"{sender}: {message}")
|
| 111 |
+
|
| 112 |
+
info =f"""Successfully logged in as {bot.username}"""
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
bot_list.append({f"{email}": bot})
|
| 116 |
+
gr.Info(f"Successfully logged in as {bot.username}\n{plugin_str}")
|
| 117 |
+
return bot.username, info, "Stop Bot"
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def create_multiple(email, auth, host, port, version, amount):
|
| 121 |
+
try:
|
| 122 |
+
if 'bot' in globals():
|
| 123 |
+
def stop_bot():
|
| 124 |
+
try:
|
| 125 |
+
global bot
|
| 126 |
+
bot.stop()
|
| 127 |
+
gr.Info("Successfully stopped bot!")
|
| 128 |
+
del bot
|
| 129 |
+
except Exception as e:
|
| 130 |
+
print(e)
|
| 131 |
+
pass
|
| 132 |
+
stop_bot()
|
| 133 |
+
return "Already logged in!", "Already logged in!", "Login/Create Bot"
|
| 134 |
+
except Exception as e:
|
| 135 |
+
print(e)
|
| 136 |
+
pass
|
| 137 |
+
if not host or not email or not version:
|
| 138 |
+
gr.Warning("not all fields are filled in!")
|
| 139 |
+
return "Unknown", "Unknown", "Login/Create Bot"
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
for bots in range(0, amount):
|
| 143 |
+
lodestone.createBot(
|
| 144 |
+
host=host,
|
| 145 |
+
username=email+str(bots),
|
| 146 |
+
port=port,
|
| 147 |
+
ls_disable_viewer=True,
|
| 148 |
+
version=version,
|
| 149 |
+
profilesFolder="./cache",
|
| 150 |
+
auth=auth,
|
| 151 |
+
ls_skip_checks=True,
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
global bot
|
| 155 |
+
bot = amount
|
| 156 |
+
# @bot.on('messagestr')
|
| 157 |
+
# def chat(this, message, messagePosition, jsonMsg, sender, *args):
|
| 158 |
+
# message = str(message).replace("\n","")
|
| 159 |
+
# if str(sender).lower() == "none":
|
| 160 |
+
# chat_history.append(f"{message}")
|
| 161 |
+
# else:
|
| 162 |
+
# chat_history.append(f"{sender}: {message}")
|
| 163 |
+
|
| 164 |
+
info =f"""Successfully created {amount} bots!"""
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
gr.Info(f"Successfully created {amount} bots!")
|
| 169 |
+
return amount, info, "Stop Bot"
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def get_username():
|
| 174 |
+
if 'bot' in globals():
|
| 175 |
+
return bot.username
|
| 176 |
+
else:
|
| 177 |
+
return "None"
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def get_player_health():
|
| 182 |
+
if 'bot' in globals():
|
| 183 |
+
return bot.health
|
| 184 |
+
else:
|
| 185 |
+
return "Unknown"
|
| 186 |
+
|
| 187 |
+
def get_player_food():
|
| 188 |
+
if 'bot' in globals():
|
| 189 |
+
return bot.food
|
| 190 |
+
else:
|
| 191 |
+
return "Unknown"
|
| 192 |
+
|
| 193 |
+
def get_player_experience():
|
| 194 |
+
if 'bot' in globals():
|
| 195 |
+
return bot.experience.level
|
| 196 |
+
else:
|
| 197 |
+
return "Unknown"
|
| 198 |
+
|
| 199 |
+
def get_player_difficulty():
|
| 200 |
+
if 'bot' in globals():
|
| 201 |
+
|
| 202 |
+
if bot.settings.difficulty == 0:
|
| 203 |
+
return "peaceful"
|
| 204 |
+
elif bot.settings.difficulty == 1:
|
| 205 |
+
return "easy"
|
| 206 |
+
elif bot.settings.difficulty == 2:
|
| 207 |
+
return "normal"
|
| 208 |
+
elif bot.settings.difficulty == 3:
|
| 209 |
+
return "hard"
|
| 210 |
+
|
| 211 |
+
else:
|
| 212 |
+
return "Unknown"
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def get_all_data():
|
| 216 |
+
if 'bot' in globals():
|
| 217 |
+
return bot.player
|
| 218 |
+
else:
|
| 219 |
+
return "Unknown"
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def get_latest_chats():
|
| 225 |
+
if 'bot' in globals():
|
| 226 |
+
if len(chat_history) > 200:
|
| 227 |
+
chat_history.clear()
|
| 228 |
+
return "No chat messages yet!"
|
| 229 |
+
string = ""
|
| 230 |
+
for i in chat_history[-40:]:
|
| 231 |
+
string += i + "\n"
|
| 232 |
+
return string
|
| 233 |
+
else:
|
| 234 |
+
return "No chat messages yet!"
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
# def upload_file(files):
|
| 239 |
+
# global build_file
|
| 240 |
+
# file_paths = [file.name for file in files]
|
| 241 |
+
# build_file = file_paths
|
| 242 |
+
# print(file_paths)
|
| 243 |
+
# return file_paths
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def build_schematic(files, x, z):
|
| 247 |
+
if not x or not z or not files:
|
| 248 |
+
gr.Warning("not all fields are filled in!")
|
| 249 |
+
return
|
| 250 |
+
if 'bot' in globals():
|
| 251 |
+
bot.goto(x, z)
|
| 252 |
+
time.sleep(2)
|
| 253 |
+
bot.build_schematic(f'{files.name}')
|
| 254 |
+
else:
|
| 255 |
+
gr.Warning("You need to login first!")
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="The Lodestone Project") as ui:
|
| 260 |
+
with gr.Tab("Bot Settings"):
|
| 261 |
+
# gr.Markdown(requests.get('https://raw.githubusercontent.com/the-lodestone-project/Lodestone/main/README.md').text)
|
| 262 |
+
# gr.Image("https://github.com/the-lodestone-project/Lodestone/blob/main/assets/logo.png?raw=true", min_width=2000)
|
| 263 |
+
with gr.Tab("Signle Bot"):
|
| 264 |
+
email = gr.Textbox(placeholder="Notch", label="Username",info="Username to login with")
|
| 265 |
+
auth = gr.Dropdown(["microsoft", "offline"], value="microsoft", label="Authentication Method",info="Authentication method to login with")
|
| 266 |
+
host = gr.Textbox(placeholder="2b2t.org", label="Server Ip",info="Server ip to connect to")
|
| 267 |
+
port = gr.Number(value=25565, label="Sever Port", info="Server port to connect to. Most servers use 25565",precision=0)
|
| 268 |
+
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")
|
| 269 |
+
with gr.Accordion("Optional Settings", open=False):
|
| 270 |
+
enable_viewer = gr.Checkbox(value=True, label="Enable Viewer", info="Enable the viewer to see the bot's view",interactive=True)
|
| 271 |
+
skip_checks = gr.Checkbox(value=True, label="Skip Checks/Updates", info="Skip checks to speed up the bot",interactive=True)
|
| 272 |
+
viewer = gr.Number(value=5001, label="Viewer Port", info="Viewer port to display the bot's view",precision=0)
|
| 273 |
+
plugin = gr.Dropdown(["Schematic Builder", "Cactus Farm Builder", "Discord Rich Presence"],multiselect=True, label="Plugins",info="Plugins to load on startup")
|
| 274 |
+
btn = gr.Button(value=get_bot_status,variant='primary')
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
out_username = gr.Textbox(value="", label="Logged in as")
|
| 280 |
+
info = gr.Textbox(value="", label="Info")
|
| 281 |
+
|
| 282 |
+
btn.click(create, inputs=[email, auth, host, port, version, viewer, plugin, enable_viewer, skip_checks], outputs=[out_username, info, btn], show_progress="minimal")
|
| 283 |
+
with gr.Tab("Multiple Bots"):
|
| 284 |
+
email = gr.Textbox(placeholder="Notch", label="Username Prefix",info="Username prefix. The bot will login with this prefix and a number after it")
|
| 285 |
+
auth = gr.Dropdown(["offline"], value="offline", label="Authentication Method",info="Authentication method to login with")
|
| 286 |
+
host = gr.Textbox(placeholder="2b2t.org", label="Server Ip",info="Server ip to connect to")
|
| 287 |
+
port = gr.Number(value=25565, label="Sever Port", info="Server port to connect to. Most servers use 25565",precision=0)
|
| 288 |
+
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")
|
| 289 |
+
amount = gr.Slider(minimum=1, maximum=50, step=1, label="Amount", info="Amount of bots to create", interactive=True)
|
| 290 |
+
with gr.Accordion("Optional Settings", open=False):
|
| 291 |
+
enable_viewer = gr.Checkbox(value=False, label="Enable Viewer", info="Enable the viewer to see the bot's view",interactive=False)
|
| 292 |
+
viewer = gr.Number(value=5001, label="Viewer Port", info="Viewer port to display the bot's view",precision=0, interactive=False)
|
| 293 |
+
# plugin = gr.Dropdown(["Schematic Builder", "Cactus Farm Builder", "Discord Rich Presence"],multiselect=True, label="Plugins",info="Plugins to load on startup")
|
| 294 |
+
btn = gr.Button(value=get_bot_status,variant='primary')
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
out_username = gr.Textbox(value="", label="Bot count")
|
| 300 |
+
info = gr.Textbox(value="", label="Info")
|
| 301 |
+
|
| 302 |
+
btn.click(create_multiple, inputs=[email, auth, host, port, version, amount], outputs=[out_username, info, btn], show_progress="minimal")
|
| 303 |
+
|
| 304 |
+
# with gr.Tab("EasyMC"):
|
| 305 |
+
# email = gr.Textbox(placeholder="********************", label="Token",info="Token to login with")
|
| 306 |
+
# host = gr.Textbox(placeholder="2b2t.org", label="Server Ip",info="Server ip to connect to")
|
| 307 |
+
# port = gr.Number(value=25565, label="Sever Port", info="Server port to connect to. Most servers use 25565",precision=0)
|
| 308 |
+
# 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")
|
| 309 |
+
# with gr.Accordion("Optional Settings", open=False):
|
| 310 |
+
# enable_viewer = gr.Checkbox(value=True, label="Enable Viewer", info="Enable the viewer to see the bot's view",interactive=True)
|
| 311 |
+
# skip_checks = gr.Checkbox(value=True, label="Skip Checks/Updates", info="Skip checks to speed up the bot",interactive=True)
|
| 312 |
+
# viewer = gr.Number(value=5001, label="Viewer Port", info="Viewer port to display the bot's view",precision=0)
|
| 313 |
+
# plugin = gr.Dropdown(["Schematic Builder", "Cactus Farm Builder", "Discord Rich Presence"],multiselect=True, label="Plugins",info="Plugins to load on startup")
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
# btn = gr.Button(value=get_bot_status,variant='primary')
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
# out_username = gr.Textbox(value="", label="Logged in as")
|
| 323 |
+
# info = gr.Textbox(value="", label="Info")
|
| 324 |
+
|
| 325 |
+
# btn.click(create, inputs=[email, auth, host, port, version, viewer, plugin, enable_viewer, skip_checks], outputs=[out_username, info, btn], show_progress="minimal")
|
| 326 |
+
|
| 327 |
+
# with gr.Tab("The Altening"):
|
| 328 |
+
# email = gr.Textbox(placeholder="*******@alt.com", label="Token",info="Token to login with")
|
| 329 |
+
# host = gr.Textbox(placeholder="2b2t.org", label="Server Ip",info="Server ip to connect to")
|
| 330 |
+
# port = gr.Number(value=25565, label="Sever Port", info="Server port to connect to. Most servers use 25565",precision=0)
|
| 331 |
+
# 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")
|
| 332 |
+
# with gr.Accordion("Optional Settings", open=False):
|
| 333 |
+
# enable_viewer = gr.Checkbox(value=True, label="Enable Viewer", info="Enable the viewer to see the bot's view",interactive=True)
|
| 334 |
+
# skip_checks = gr.Checkbox(value=True, label="Skip Checks/Updates", info="Skip checks to speed up the bot",interactive=True)
|
| 335 |
+
# viewer = gr.Number(value=5001, label="Viewer Port", info="Viewer port to display the bot's view",precision=0)
|
| 336 |
+
# plugin = gr.Dropdown(["Schematic Builder", "Cactus Farm Builder", "Discord Rich Presence"],multiselect=True, label="Plugins",info="Plugins to load on startup")
|
| 337 |
+
# btn = gr.Button(value=get_bot_status,variant='primary')
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
# out_username = gr.Textbox(value="", label="Logged in as")
|
| 343 |
+
# info = gr.Textbox(value="", label="Info")
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
# btn.click(create, inputs=[email, auth, host, port, version, viewer, plugin, enable_viewer, skip_checks], outputs=[out_username, info, btn], show_progress="minimal")
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
with gr.Tab("Chat"):
|
| 354 |
+
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)
|
| 355 |
+
with gr.Accordion("Advanced Options", open=False):
|
| 356 |
+
with gr.Column(scale=1):
|
| 357 |
+
whisper = gr.Checkbox(value=False, label="Whisper", info="Whisper the message to the player",interactive=True)
|
| 358 |
+
whisper_player = gr.Dropdown([],show_label=False, info="The player to whisper to (Updated every 20 seconds)",interactive=True)
|
| 359 |
+
# get_players = gr.Button("Get Players", variant='primary')
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
with gr.Column(scale=1):
|
| 363 |
+
prefix = gr.Textbox(value="", show_label=False, info="Prefix to add to the start of the message",interactive=True)
|
| 364 |
+
suffix = gr.Textbox(value="", show_label=False, info="Suffix to add to the end of the message",interactive=True)
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
def get_players_def():
|
| 370 |
+
if 'bot' in globals():
|
| 371 |
+
global players
|
| 372 |
+
players = []
|
| 373 |
+
for player in bot.bot.players.valueOf():
|
| 374 |
+
players.append(player)
|
| 375 |
+
players.remove(bot.username)
|
| 376 |
+
return gr.Dropdown(choices=players)
|
| 377 |
+
else:
|
| 378 |
+
return gr.Dropdown([])
|
| 379 |
+
|
| 380 |
+
def just_some_random_update():
|
| 381 |
+
return time.time()
|
| 382 |
+
|
| 383 |
+
updates = gr.Textbox(value=just_some_random_update, every=20, show_label=False, visible=False)
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
updates.change(get_players_def, outputs=[whisper_player])
|
| 387 |
+
|
| 388 |
+
with gr.Row():
|
| 389 |
+
with gr.Column(scale=2, ):
|
| 390 |
+
msg = gr.Textbox(show_label=False, container=False, placeholder="Type an message...", autofocus=True)
|
| 391 |
+
with gr.Column(scale=1, ):
|
| 392 |
+
send_message = gr.Button("Send Message", variant='primary')
|
| 393 |
+
clear = gr.ClearButton([msg, chat],value="Clear Chat History")
|
| 394 |
+
|
| 395 |
+
def respond(message, whisper, whisper_player, prefix, suffix):
|
| 396 |
+
if 'bot' in globals():
|
| 397 |
+
if message != "":
|
| 398 |
+
if whisper and whisper_player != None or "":
|
| 399 |
+
bot.whisper(whisper_player, f"{prefix}{message}{suffix}")
|
| 400 |
+
if not whisper:
|
| 401 |
+
bot.chat(f"{prefix}{message}{suffix}")
|
| 402 |
+
return ""
|
| 403 |
+
else:
|
| 404 |
+
gr.Warning("You need to create a bot first!")
|
| 405 |
+
return ""
|
| 406 |
+
|
| 407 |
+
def delete():
|
| 408 |
+
chat_history.clear()
|
| 409 |
+
|
| 410 |
+
clear.click(delete)
|
| 411 |
+
send_message.click(respond, inputs=[msg, whisper, whisper_player, prefix, suffix],outputs=[msg])
|
| 412 |
+
msg.submit(respond, inputs=[msg, whisper, whisper_player, prefix, suffix],outputs=[msg])
|
| 413 |
+
|
| 414 |
+
with gr.Tab("Plugins"):
|
| 415 |
+
with gr.Accordion("Schematic Builder", open=False):
|
| 416 |
+
|
| 417 |
+
def check():
|
| 418 |
+
if not plugins.schematic in plugin_list:
|
| 419 |
+
return "The Schematic Builder plugin is not loaded"
|
| 420 |
+
else:
|
| 421 |
+
return "pluginloaded"
|
| 422 |
+
|
| 423 |
+
gr.Textbox(value=check, every=30, show_label=False)
|
| 424 |
+
# with gr.Row():
|
| 425 |
+
# with gr.Column(scale=1, ):
|
| 426 |
+
file_output = gr.File(file_types=[".schematic", ".nbt", ".schem"], label="Schematic File (.schematic .nbt .schem)",file_count="single")
|
| 427 |
+
with gr.Row():
|
| 428 |
+
with gr.Column(scale=1, ):
|
| 429 |
+
x = gr.Number(label="X Coordinate",info="The X coord to build at", precision=0)
|
| 430 |
+
with gr.Column(scale=1, ):
|
| 431 |
+
z = gr.Number(label="Z Coordinate",info="The Z coord to build at", precision=0)
|
| 432 |
+
# upload_button = gr.UploadButton("Click to Upload a schematic", file_count="single")
|
| 433 |
+
# upload_button.upload(upload_file, upload_button, file_output)
|
| 434 |
+
build = gr.Button("Build schematic", variant='primary')
|
| 435 |
+
build.click(build_schematic, inputs=[file_output, x, z])
|
| 436 |
+
|
| 437 |
+
|
| 438 |
+
with gr.Accordion("Build Cactus Farm", open=False):
|
| 439 |
+
gr.Markdown("")
|
| 440 |
+
|
| 441 |
+
with gr.Accordion("Auto Farm", open=False):
|
| 442 |
+
with gr.Row():
|
| 443 |
+
with gr.Column(scale=1, ):
|
| 444 |
+
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)
|
| 445 |
+
with gr.Column(scale=1, ):
|
| 446 |
+
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)
|
| 447 |
+
with gr.Column(scale=1, ):
|
| 448 |
+
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)
|
| 449 |
+
|
| 450 |
+
with gr.Row():
|
| 451 |
+
with gr.Column(scale=1, ):
|
| 452 |
+
x = gr.Number(label="X Coordinate",info="The X coord to build at", precision=0)
|
| 453 |
+
with gr.Column(scale=1, ):
|
| 454 |
+
z = gr.Number(label="Z Coordinate",info="The Z coord to build at", precision=0)
|
| 455 |
+
|
| 456 |
+
with gr.Row():
|
| 457 |
+
with gr.Column(scale=1, ):
|
| 458 |
+
x = gr.Number(label="X Coordinate",info="The X coord to build at", precision=0)
|
| 459 |
+
with gr.Column(scale=1, ):
|
| 460 |
+
z = gr.Number(label="Z Coordinate",info="The Z coord to build at", precision=0)
|
| 461 |
+
with gr.Accordion("Optional Settings", open=False):
|
| 462 |
+
gr.Markdown("Optional Settings")
|
| 463 |
+
start_farm = gr.Button("Start auto Farming", variant='primary')
|
| 464 |
+
|
| 465 |
+
with gr.Accordion("Discord Rich Presence", open=False):
|
| 466 |
+
with gr.Row():
|
| 467 |
+
with gr.Column(scale=1, ):
|
| 468 |
+
state = gr.Textbox(label="State",info="The state to display")
|
| 469 |
+
with gr.Column(scale=1, ):
|
| 470 |
+
details = gr.Textbox(label="Details",info="The details to display")
|
| 471 |
+
with gr.Column(scale=1, ):
|
| 472 |
+
large_image = gr.Textbox(label="Large Image (url)",info="The large image to display")
|
| 473 |
+
with gr.Column(scale=1, ):
|
| 474 |
+
large_text = gr.Textbox(label="Large Text",info="The large text to display")
|
| 475 |
+
with gr.Column(scale=1, ):
|
| 476 |
+
small_image = gr.Textbox(label="Small Image (url)",info="The small image to display")
|
| 477 |
+
with gr.Column(scale=1, ):
|
| 478 |
+
small_text = gr.Textbox(label="Small Text",info="The small text to display")
|
| 479 |
+
|
| 480 |
+
def update_presence_def(state="No state provided", details="No details Provided", large_image=None, large_text=None, small_image=None, small_text=None):
|
| 481 |
+
print(details)
|
| 482 |
+
if 'bot' in globals():
|
| 483 |
+
bot.discordrp(state=state, details=details, start=time.time())
|
| 484 |
+
else:
|
| 485 |
+
pass
|
| 486 |
+
|
| 487 |
+
update_presence = gr.Button("Update Presence", variant='primary')
|
| 488 |
+
update_presence.click(update_presence_def, inputs=[state, details, large_image, large_text, small_image, small_text])
|
| 489 |
+
|
| 490 |
+
|
| 491 |
+
with gr.Tab("Movements"):
|
| 492 |
+
with gr.Tab("Basic Movements"):
|
| 493 |
+
with gr.Row():
|
| 494 |
+
with gr.Column(scale=1, ):
|
| 495 |
+
jump = gr.Button("Start Jumping")
|
| 496 |
+
jump = gr.Button("Stop Jumping")
|
| 497 |
+
with gr.Column(scale=1, ):
|
| 498 |
+
jump = gr.Button("Start walking forward")
|
| 499 |
+
jump = gr.Button("Stop walking forward")
|
| 500 |
+
with gr.Tab("Follow Player/Entity"):
|
| 501 |
+
gr.Markdown("")
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
with gr.Tab("Player Info"):
|
| 506 |
+
# refresh_button = gr.Button("Refresh")
|
| 507 |
+
with gr.Accordion("Bot Info", open=False):
|
| 508 |
+
with gr.Row():
|
| 509 |
+
with gr.Column(scale=1):
|
| 510 |
+
health = gr.Textbox(value=get_player_health, label=f"Health", every=5)
|
| 511 |
+
with gr.Column(scale=1):
|
| 512 |
+
food = gr.Textbox(value=get_player_food, label=f"Food", every=5)
|
| 513 |
+
with gr.Column(scale=1):
|
| 514 |
+
experience = gr.Textbox(value=get_player_experience, label=f"Experience Level", every=5)
|
| 515 |
+
with gr.Column(scale=1):
|
| 516 |
+
difficulty = gr.Textbox(value=get_player_difficulty, label=f"Difficulty", every=5)
|
| 517 |
+
with gr.Column(scale=1):
|
| 518 |
+
all_data = gr.Textbox(value=get_all_data, label=f"All Data", every=5)
|
| 519 |
+
with gr.Accordion("Online Player Info", open=False):
|
| 520 |
+
pass
|
| 521 |
+
# refresh_button.click(get_player_info, outputs=[health, food, experience])
|
| 522 |
+
|
| 523 |
+
with gr.Tab("System Resources"):
|
| 524 |
+
# refresh_button = gr.Button("Refresh")
|
| 525 |
+
import psutil
|
| 526 |
+
import platform
|
| 527 |
+
|
| 528 |
+
def cpu():
|
| 529 |
+
return psutil.cpu_percent(interval=5)
|
| 530 |
+
|
| 531 |
+
def ram_used():
|
| 532 |
+
return psutil.virtual_memory().percent
|
| 533 |
+
|
| 534 |
+
def ram_available():
|
| 535 |
+
|
| 536 |
+
ram= psutil.virtual_memory().available / (1024.0 ** 3)
|
| 537 |
+
return "{:.1f}".format(ram)
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
with gr.Row():
|
| 541 |
+
with gr.Column(scale=1):
|
| 542 |
+
health = gr.Textbox(value=ram_used, label=f"Ram Used (%)", every=5)
|
| 543 |
+
with gr.Column(scale=1):
|
| 544 |
+
food = gr.Textbox(value=ram_available, label=f"Available Ram (GB)", every=5)
|
| 545 |
+
with gr.Column(scale=1):
|
| 546 |
+
experience = gr.Textbox(value=cpu, label=f"CPU usage (%)", every=5)
|
| 547 |
+
with gr.Column(scale=1):
|
| 548 |
+
difficulty = gr.Textbox(value=platform.system, label=f"System Type")
|
| 549 |
+
# refresh_button.click(get_player_info, outputs=[health, food, experience])
|
| 550 |
+
|
| 551 |
+
# import os
|
| 552 |
+
# from dotenv import load_dotenv
|
| 553 |
+
# import socket
|
| 554 |
+
# import requests
|
| 555 |
+
# s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 556 |
+
# s.connect(("8.8.8.8", 80))
|
| 557 |
+
# host = s.getsockname()[0]
|
| 558 |
+
# s.close()
|
| 559 |
+
|
| 560 |
+
# load_dotenv()
|
| 561 |
+
|
| 562 |
+
username = "lodestone"
|
| 563 |
+
password = "lodestone"
|
| 564 |
+
|
| 565 |
+
# if not os.path.isfile("/favicon.ico"):
|
| 566 |
+
# img_data = requests.get("https://github.com/the-lodestone-project/Lodestone/raw/main/assets/favicon.png").content
|
| 567 |
+
# with open('/favicon.png', 'wb') as handler:
|
| 568 |
+
# handler.write(img_data)
|
| 569 |
+
|
| 570 |
+
|
| 571 |
+
try:
|
| 572 |
+
logger.info("Running!\nURL: http://localhost:8000\nUsername: lodestone\nPassword: lodestone\n")
|
| 573 |
+
ui.queue().launch(inbrowser=True,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.")
|
| 574 |
+
except OSError:
|
| 575 |
+
raise OSError(f"Port 8000 is already in use!")
|
| 576 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
lodestone
|
| 2 |
+
gradio==3.*
|