Skip to main content

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

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.4.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcws-0.0.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file mcws-0.0.4.tar.gz.

File metadata

  • Download URL: mcws-0.0.4.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

Hashes for mcws-0.0.4.tar.gz
Algorithm Hash digest
SHA256 86d30dedc81d3ac6c6b9d8c4a63026bdcb34f5477db79090f53d652b14b28cfe
MD5 66603ceeb05eb8523dec51659c2c3058
BLAKE2b-256 a133ef6b2d660e0c40285dc140103be9701047d5c76b56860b41f1ab001c867b

See more details on using hashes here.

File details

Details for the file mcws-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mcws-0.0.4-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

Hashes for mcws-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 70e63ce8ce944b7a11cc7641631d2199d4b8c23d017ece3826c97a447f51a6f9
MD5 6a90144e80d0dc85f411fae73e18b4c0
BLAKE2b-256 5dbc1cd3d95481249309cfbaa944045fa18c8cfc2e8f4cc8f227fb70e2fa4053

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page