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 system

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-1.0.1.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-1.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcws-1.0.1.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-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b5577e0dd008531a41de48f2882909153154d75bfd320fb18a61c838c60b8d09
MD5 9ba64e8728056960a9dd128407197a5e
BLAKE2b-256 62cc324e27e08c3f99ed9671491155b32fc65069ec80ab2008505bde3807133b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcws-1.0.1-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-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0e9dfc86e88a86e4f66a88878afd2daa385a674e26772e0323af6b75b467be7
MD5 62e486a42f189d3d3ce271ab46d516f5
BLAKE2b-256 195cabf5110163f2cab6f98b0ac2324d6f30764b822d5c1444acc5671495560e

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