Skip to content

Commit f2428a5

Browse files
committed
readme fixes
1 parent 609f024 commit f2428a5

2 files changed

Lines changed: 309 additions & 318 deletions

File tree

README.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,48 @@
22

33
By: Seppe "Macuyiko" vanden Broucke
44

5-
`minecraft-python` is a Spigot plugin which provides server administrators with a Python interpreter console which can be used to administer running servers using the full arsenal provided by the Spigot API. It should be relatively easy to port to other Minecraft servers (Canary support was dropped since the project has ceased activity).
5+
**Note:** This project is currently under heavy updates. The README will be expanded soon.
66

7-
More background information on how this project came to be can be found on [this blog post](http://blog.macuyiko.com/post/2015/rebuilding-our-jython-console-plugin-for-minecraft.html).
7+
`minecraft-python` is a Spigot plugin providing the ability to control Minecraft using Python. Contrary to other approaches, this project aims to expose the whole Bukkit API to Python, instead of only providing a few commands or wrappers by hardcoding these in a Spigot plugin.
88

9-
You can watch a [Youtube](https://www.youtube.com/watch?v=j4JfwS5hNlw) video showing off some of the possibilities.
9+
More background information on how this project came to be can be found on [this blog post](http://blog.macuyiko.com/post/2015/rebuilding-our-jython-console-plugin-for-minecraft.html) (a bit outdated at the moment).
1010

11-
The implementation is based on Jython. This has the benefit that the whole Spigot API can be utilized at runtime, i.e. *without* having to register commands to the Spigot plugin itself (though you can define such commands using the interpreter itself at runtime) and without having to type commands through the Minecraft client's chat window, i.e. this deliberately avoids the approach of [ScriptCraft](http://scriptcraftjs.org/) (another great plugin, but we have a different aim here). This makes the plugin itself very simple and always in line with the Spigot API, but also adds some extra complexity, as you might have to peruse the Spigot Javadocs to find your way through all methods.
11+
You can watch a [Youtube](https://www.youtube.com/watch?v=j4JfwS5hNlw) video showing off some of the possibilities (also a bit outdated by now but gets the idea across).
1212

13-
Other than allowing cool administration possibilities, the console also provides a fun way to learn Python together with Minecraft. Students can see the results of their code immediately reflected in their Minecraft world. The folks over at [Game Start](http://www.gamestartschool.com/) are currently experimenting with using this. If you'd be interesting in collaborate somehow as well, I'm happy to chat.
13+
## Implementation
1414

15-
## Setup
16-
17-
The code is composed out of the following items:
18-
19-
* `ServerPythonInterpreterPlugin`: contains the plugin source code as an Eclipse project. Compatible both with Spigot.
20-
* `ServerEditorWeb`: contains the source code for a simple Java-based Python editor you can use to connect to the server.
21-
22-
Assuming you already have installed Spigot in `SERVER_DIR`, the plugin is installed as follows:
15+
Currently, two Python "engines" are implemented providing Minecraft <-> Python interoperability.
2316

24-
* Place `ServerPythonInterpreterPlugin/python` in `SERVER_DIR` (i.e. you will get a `SERVER_DIR/python` folder). (This step is optional but will allow you to use some shortcut functions.)
25-
* Place `ServerPythonInterpreterPlugin/lib-common` in `SERVER_DIR` (i.e. you will get a `SERVER_DIR/lib-common` folder).
17+
* One is based on Jython. This has the benefit that the complete Python interpreter system runs inside of the JVM, but comes with the drawback that it only supports Python 2
18+
* A new engine was added recently, based on Py4j. This allows for full Python 3 support
2619

27-
Upon starting, the plugin will create a config file where the following parameters can be set:
20+
Utilizing the plugin differs somewhat depending on which engine you use:
2821

29-
* `pythonconsole.serverconsole.password [string]`: interpreter server password (default: swordfish) (not meant to be a strong protection)
30-
* `pythonconsole.serverconsole.telnetport [int]`: port to bind the TCP interpreter server to (default: 44444), set to -1 to disable
31-
* `pythonconsole.serverconsole.websocketport [int]`: port to bind the WebSocket interpreter server to (default: 44445), set to -1 to disable
22+
* With the Jython based system, you have the ability to interact with a Jython interpreter through a telnet server, websocket server, and through chat commands (`/jy`, `/jyload` and `/jyrestart`). An HTTP server exposes a web based editor which'll connect to the websocket server. A telnet command can be used to connect to the telnet server. Note that all intepreters run server-side. No local Python installation is required. A built-in Python module, `mcjyapi`, provides some predefined handy commands. Putting `.py` files in a `python-plugins` directory runs these as "plugins" when starting up the plugin. This interpreter keeps running and can be used to set up global hooks. Other interpreters will be cleaned out after some period of inactivity.
23+
* With the Py4j based system, you'll need to install a Python 3 interpreter manually and use Py4j to connect to the Java gateway server started by the plugin. Chat commands `pyload` and `pyrestart` are available.
3224

33-
## Usage
25+
A word about these commands `/jy <code>` runs a line of Python code on a Jython intepreter (each player gets their own interpreter). A `.` (dot) prefix can be used in case indentation with whitespace needs to be provided. `jyrestart` restarts the Jython interpreter. `jyload <file>` takes a local Python file (in the running directory or on the Desktop of the server) and executes it in the Jython interpreter. `pyrestart` restarts the Py4j gateway. `pyload <file>` takes a local Python file (in the running directory or on the Desktop of the server) but simply executes it by calling the OS' `python` executable (not as useful), though stdout and stderr are redirected to the chat window. A running `python` executable will be killed off if it runs too long here.
3426

35-
Logging into the interpreter server can be done using telnet, e.g. `telnet 127.0.0.1 44444` you will be prompted for the password and an interpreter will be spawned after successful authentication:
27+
## Comparison
3628

37-
![](https://camo.githubusercontent.com/6fea3b76ec29006ef0e423dc78d3993bc9489797/687474703a2f2f696d6775722e636f6d2f676f4c684733392e706e67)
29+
The explicit goal of this project is to allow programming Minecraft using Python and to provide the full Bukkit API in this environment without resorting to manually wrapping these through a Spigot plugin. Other interesting projects are:
3830

39-
You can also initiate a RAW connection using PuTTy (make sure to enable "Implicit CR in every LF"):
31+
* https://github.com/ammaraskar/pyCraft: modern, Python3-compatible, well-documented library for communication with a MineCraft server. This is on the networking level, however.
32+
* https://github.com/r1chardj0n3s/pycode-minecraft: similar to command blocks, this plugin allows to code scripts on "Python Blocks". Also uses Jython internally.
33+
* https://github.com/martinohanlon/mcpi: combines https://github.com/py3minepi/py3minepi and https://github.com/martinohanlon/minecraft-stuff. Exposes only some basic commands by sending them over the wire to Minecraft Pi.
34+
* https://github.com/zhuowei/RaspberryJuice: a plugin that implements the Minecraft Pi API, so that `mcpi` above can be used together with a normal Minecraft server. https://github.com/wensheng/JuicyRaspberryPie extends this a little bit, https://www.nostarch.com/programwithminecraft uses `RaspberryJuice` + `mcpi` to write its examples
35+
* http://scriptcraftjs.org/: similar approach, but uses JavaScript and adds more boilerplate code between the JS engine <-> Java interaction. A bit outdated, sadly
4036

41-
![](https://camo.githubusercontent.com/6ddb498f728187442e1fca2add801a978d907e75/687474703a2f2f692e696d6775722e636f6d2f316b553276744c2e706e67)
42-
43-
After logging in, it's a good idea to execute `from mcapi_spigot import *` as your first command. This will load in the `mcapi_spigot.py` file included in the distribution which makes a lot of things easier. If you don't want to use the pre-made functions, you can import any Spigot API class as follows: `from org.bukkit import Bukkit` (see the Spigot API docs or `mcapi_spigot.py` for more examples).
37+
## Setup
4438

45-
It's generally more pleasant to use web based editor to connect to the websocket server, see `ServerEditorWeb` to do so:
46-
47-
![](http://i.imgur.com/8ZoH8KG.png)
39+
As of its latest version, the plugin is installed just like any other Spigot plugin. On boot, `lib-common` and `python` and `lib-http` directories will be created automatically. Config files can be modified to enable/disable servers.
4840

4941
## Example
5042

5143
Below is a short example of what you can do with the interpreter:
5244

5345
# Import some modules
54-
from mcapi_spigot import *
46+
from mcjyapi_spigot import *
5547
from time import sleep
5648
from random import randint
5749

@@ -130,12 +122,11 @@ Below is a short example of what you can do with the interpreter:
130122
# Remove event hook
131123
unregister_hook(listener)
132124

133-
134125
def cmd_growme(caller, params):
135126
loc = lookingat(player("Macuyiko")).getLocation()
136127
world.generateTree(loc, TreeType.BIRCH)
137128

138-
register_command('growme', cmd_growme)
129+
register_command('growme', cmd_growme)
139130

140131
## License
141132

0 commit comments

Comments
 (0)