Skip to main content

A minecraft server wrapper written in python

Project description

Spinel

A minecraft server wrapper written in python.

This program in its current state only allows you to read the chat and send commands (as the server).

Tutorial

First, install spinel by running pip install spinel in the terminal.

Import Spinel by using import spinel at the top of your file. You'll need a server premade (which can be done with Pyrite). Rename your server .jar file to spinel_server.jar

Now, make an instance of your server with: server = spinel.server(path).

Start the server with server.start().

To read messages and send commands, make a while loop like so:

while True:
    msg = server.latest_message()

    if msg:
        print(msg.raw) # this prints the whole message
        print(msg.author) # this prints the name of the one who sent the message
        print(msg.content) # this prints the message content

        server.write("say Hello, World") # Writes "Hello, World" to the chat repeatedly

Example

import spinel

server = spinel.server()
server.start()

while True:
    msg = server.latest_message()

    if msg:
        print(msg.raw)
        if msg.content.split(" ")[0] == "!math":
            result = eval(msg.content.split(" ")[1])
            output = 'tellraw @a {"text":"' + msg.content.split(" ")[1] + '=' + str(result) + '"}'
            server.write(output)

This code prints all messages to the python terminal and allows the user to perform basic math using the !math command.

Note

If you print just msg, then it will print msg.raw instead. It is reccomended you use msg.raw anyway to be more explicit. You'll need to manually close your server terminal before relaunching

Dependencies

  • os
  • subprocess
  • sys
  • threading
  • queue

Credits

  • Ravbug
  • nigel
  • Winter_Snake
  • vdvman1
  • AjaxGB
  • A2

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

spinel-1.1.4.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

spinel-1.1.4-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file spinel-1.1.4.tar.gz.

File metadata

  • Download URL: spinel-1.1.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for spinel-1.1.4.tar.gz
Algorithm Hash digest
SHA256 9ccd87356f1341d106713340d2226d3c90a2040b781b6002188f008e62240b2e
MD5 3255f68bc464fc30ead7573b34263908
BLAKE2b-256 8a6a587bdaeae317edccf34df1b8ff82a0db30217a65386cb70fbb4d9812c64d

See more details on using hashes here.

Provenance

File details

Details for the file spinel-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: spinel-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for spinel-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 de8f22f0b2b408a1716379c51796b6bc8f7599aba59ef6d0c917b2d5f6bfe46e
MD5 fd188655825c73fc133402b89ad0ad6d
BLAKE2b-256 d53aadecb3c0bf126f0445d0baa9b795689e12c485aef412d8f26bbecd6f2b90

See more details on using hashes here.

Provenance

Supported by

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