Create a fake Minecraft server in Python with Quarry

When I searched for a Minecraft library on Pypi, there was a library called Quarry, so I tried using it.

Installation

only this.

pip install quarry

Create a fake server

From the conclusion, it works with this.

from twisted.internet import reactor
from quarry.net.server import ServerFactory, ServerProtocol


class QuarryProtocol(ServerProtocol):
    def player_joined(self):
        ServerProtocol.player_joined(self)
        self.close("Pong!")

class QuarryFactory(ServerFactory):
    protocol = QuarryProtocol
    motd = "Powered by Quarry!"

def main():
    factory = QuarryFactory()
    factory.listen("")
    reactor.run()


if __name__ == "__main__":
    main()

Even if you run the script, nothing will come out, but that is the correct answer.

Now if you connect with Minecraft, you should get a disconnect message saying Pong !.

Try to play with

ServerFactory

A class that allows you to turn on / off the server motd and online mode (cracking countermeasure function), change the server image, and so on.

Property

Required. Assign the `` `ServerProtocol``` class. Details will be described later.

A description of the server. That is displayed in the server list.

Specify the server icon. Sizes up to 64x64 in PNG format (should have been).

Maximum number of player connections. You have to set it to at least 1.

Do you want to enable Mojang online authentication? If there is no particular reason, leave it as True.

ServerProtocol

This class handles processing such as when a player is connected.

There are some functions, but I will write only as much as I can understand.

function

-- player_joined (replacement function)

What to do when a player comes in. If online mode is turned on, this function will be called when authentication is complete. Also, it seems that the player_joined function of the parent class is called.

Calling this function will disconnect the player. If you enter a character in the argument, that character will be displayed in the disconnection message on the player side.

Afterword

If you use this library, you may be able to use it as some kind of authentication server. I think it's a pretty interesting library.

If you are interested, there seems to be a document, so please take a look there. (English)

https://quarry.readthedocs.io/en/latest/index.html

Recommended Posts

Create a fake Minecraft server in Python with Quarry
Create a virtual environment with conda in Python
Create a new page in confluence with Python
Create a dictionary in Python
Create a directory with python
Create a DI Container in Python
Create a virtual environment with Python!
Create a binary file in Python
Create a Kubernetes Operator in Python
Create a random string in Python
Create a child account for connect with Stripe in Python
Let's create a script that registers with Ideone.com in Python.
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Create a Python function decorator with Class
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
Create a simple GUI app in Python
[Python] Create a virtual environment with Anaconda
Let's create a free group with Python
Create a JSON object mapper in Python
How to create a heatmap with an arbitrary domain in Python
Create a word frequency counter with Python 3.4
[GPS] Create a kml file in Python
Create a record with attachments in KINTONE using the Python requests module
Create a frame with transparent background with tkinter [Python]
Create a Vim + Python test environment in 1 minute
Create a GIF file using Pillow in Python
[Python] Get the files in a folder with Python
Create a LINE BOT with Minette for Python
I want to create a window in Python
Create a standard normal distribution graph in Python
How to create a JSON file in Python
Create a page that loads infinitely with python
Start a simple Python web server with Docker
Create a python3 build environment with Sublime Text3
Set up a test SMTP server in Python.
Create a color bar with Python + Qt (PySide)
Create an image with characters in python (Japanese)
Steps to create a Twitter bot with python
Launch a web server with Python and Flask
Create a simple momentum investment model in Python
Work in a virtual environment with Python virtualenv.
Create a color-specified widget with Python + Qt (PySide)
Create a datetime object from a string in Python (Python 3.3)
Set up a simple SMTP server in Python
Create a Photoshop format file (.psd) with python
Create a package containing global commands in Python
Create a MIDI file in Python using pretty_midi
Create a loop antenna pattern in Python in KiCad
Create a Python console application easily with Click
Create a "Hello World" (HTTP) server with Tornado
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Create a web server in Go language (net/http) (2)
Create an API server quickly with Python + Falcon
Create a Python module
Create SpatiaLite in Python
Create a Python environment
DNS server in Python ....
Local server with python
Put Docker in Windows Home and run a simple web server with Python
Create a Django project and application in a Python virtual environment and start the server