Simple way to talk to the minecraft websocket api
Project description
Mcws
Simple way to talk to the minecraft websocket api
Features
- Simple command system
- Event system
- Extension system
- Converter
Installation
pip install mcws
Quickstart
Create hello world command
import mcws
server = mcws.Server("+")
@server.command()
async def hello_world(ws):
ws.send("Hello Minecraft World!")
server.run()
Create diamond giver
import mcws
server = mcws.Server("+")
@server.command()
async def diamond(ws):
ws.send_command("/give @a diamond")
server.run()
Mcws events
Mcws events
import mcws
server = mcws.Server("+")
@server.event("OnReady")
async def on_ready():
print(f"Listen ws//{server.ip}:{server.port}")
@server.event("OnConnected")
async def on_connected():
print("Connected")
@server.event("OnDisconnected")
async def on_disconnected():
print("Disconnected")
server.run()
Minecraft websocket api events
Players message
import mcws
server = mcws.Server("+")
@server.event("PlayerMessage")
async def on_message(ws):
ws.send(f"Hello {ws.player}")
server.run()
Block destroyed
import mcws
server = mcws.Server("+")
@server.event("BlockBroken")
async def on_block_destroyed(ws):
print(f"Nooooooooo poor block of {ws.block}")
server.run()
Mcws Extension code
Quickstart
from mcws import Extension
import mcws
server = mcws.Server("+")
ext = Extension()
# extension
@ext.command()
async def my_command(ws):
ws.send("Hello World!")
# server
server.add_extension(ext)
server.run()
Better separation
main.py
import mcws
server = mcws.Server("+")
server.load("extension") # file path not name file
server.run()
extension.py
from mcws import Extension
ext = Extension()
@ext.command()
async def diamond(ws):
ws.send_command("/give @a diamond")
def setup(server):
server.add_extension(ext)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mcws-0.0.2.tar.gz
(6.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
mcws-0.0.2-py3-none-any.whl
(7.8 kB
view details)
File details
Details for the file mcws-0.0.2.tar.gz.
File metadata
- Download URL: mcws-0.0.2.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3ceebb6aa7a85cbfb1b2b68bdd30d67121babd06eb2d84e5de4044b2b6ff8b8
|
|
| MD5 |
b9c064dde8eeed2a38051065773c4b83
|
|
| BLAKE2b-256 |
b9e953d2bd36a8d4f11533066e0bda2b7655041102c7826ba2ce7fdf3cb2a157
|
File details
Details for the file mcws-0.0.2-py3-none-any.whl.
File metadata
- Download URL: mcws-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0e6504c7eca5dc233dd08ba936ce144a2680e9a5e60616bfe023fcfdebf3855
|
|
| MD5 |
ab7a93aa22909d949d8ce4a536880cc2
|
|
| BLAKE2b-256 |
b3f86d8e88a4d71d0f67e61d6db88ec9bd15cefa599b5b60cb699d3607f5f712
|