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.3.tar.gz (6.4 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.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcws-0.0.3.tar.gz
  • Upload date:
  • Size: 6.4 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.3.tar.gz
Algorithm Hash digest
SHA256 2935e82a27825b7f9b0b45faaba690aa919671f783c62d8d7aaa09e1e96495f4
MD5 ab095f7b93f0ac8f0cbff2ef412a6d1a
BLAKE2b-256 759caaedc783e63dba1862ca81a8e1e3bf7f878c542e71595ca5a6c047b62a37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcws-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1cb3391188059128e1526a65da2354e342cda9754fd94b7d2ee87999700ade38
MD5 c5cb07729791e4c3662ae1c3efc0a663
BLAKE2b-256 3c082f86005c6403a1932276097cfa413c701c62fcb16e04a61e9cd8c657607e

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