![Latest Snapshot](https://img.shields.io/badge/dynamic/xml?color=orange&label=Latest%20Snapshot&query=%2F%2Fmetadata%2Fversioning%2Fversions%2Fversion%5Blast()%5D&url=https%3A%2F%2Frepo.magicmq.dev%2Frepository%2Fmaven-snapshots%2Fdev%2Fmagicmq%2Fpyspigot%2Fmaven-metadata.xml)
PySpigot is a Spigot/Bukkit plugin that can load, compile, and run Python scripts. These scripts can make use of Java standard libraries, as well as the Bukkit/Spigot API and APIs of any other loaded plugins.
PySpigot utilizes Jython, a Java implementation of Python that runs entirely on the JVM.
The major drawback of Jython is that it currently only supports Python 2. Work towards a Python 3 implementation is currently ongoing over at Jython's GitHub repository.
Regarding different avenues, other Python-Java interop projects support Python 3. One such example is Py4J, which is more akin to a "network bridge" between the Python and Java runtimes rather than a true Python implementation. Although it supports Python 3, Py4J would be incredibly difficult to implement as a scripting engine for Bukkit, as it relies heavily on time-consuming I/O operations and Callbacks, which would make the Minecraft server quite unstable. Additionally, Py4J would require a CPython installation (regular Python) on the same machine, a rather difficult requirement to fulfill when working within a containerized Minecraft instance (such as Pterodactyl, shared hosting providers, etc.).
When I began this project, I looked at using several libraries, Py4J included. I came to the conclusion that, although Jython only supports Python 2, it has several key advantages over other libraries in this specific use case, including:
Thus, for the foreseeable future, PySpigot will continue to utilize Jython.
PySpigot has many features, including:
You can download the latest version of PySpigot from the releases page, or from Spigot. Drop it into your plugins folder, and you're ready to begin writing scripts.
PySpigot also has an official Discord server for support, updates, and announcements. Click here to join.
For complete documentation on writing/loading/running scripts, using PySpigot's provided managers, and using the plugin in general, see PySpigot's documentation.
For Java developers, PySpigot has an API! See the Javadocs for complete documentation of API available for you to use.
Add the following repository:
<repository>
<id>magicmq-repo</id>
<url>https://repo.magicmq.dev/repository/maven-releases/</url>
</repository>
Then, add the following dependency:
<dependency>
<groupId>dev.magicmq</groupId>
<artifactId>pyspigot</artifactId>
<version>{VERSION}</version>
<scope>provided</scope>
</dependency>
Replace {VERSION}
with the version shown above, without the v
.
Add the following repository:
repositories {
...
magicmq-repo { url 'https://repo.magicmq.dev/repository/maven-releases/' }
}
Then, add the following dependency:
dependencies {
...
compileOnly 'dev.magicmq:pyspigot:{VERSION}'
}
Replace {VERSION}
with the version shown above, without the v
.
Releases are also published on GitHub here. You may download the JAR and import it yourself into your IDE of choice, or you may install it into your local repository.
Building requires Maven and Git. Maven 3+ is recommended for building the project. Follow these steps:
git clone https://github.com/magicmq/PySpigot.git
cd PySpigot
mvn clean package
target
directory.Do you have any issues or suggestions? Submit an issue report.