Giter Site home page Giter Site logo

PyPlugins - Python Plugin Loader

GitHub GitHub release (latest by date) GitHub Release Date GitHub All Releases Spigot Spiget Downloads Spiget Stars Spiget tested server versions bStats Players bStats Servers

PyPlugins - is a plugins loader for Bukkit/Spigot (PaperMC) to load plugins are written on Python 2.7 (via Jython 2.7.2).

The creation of the plugin was inspired by Macuyiko/minecraft-python, masteroftime/Python-Plugin-Loader and cyberlis/pploader.

Installation


PyPlugins (loader)


Available two versions of the loader plugin:

  • with included Jython (recommended to use);
  • without Jython (requires inclusion of jython.jar in the folder server/lib/)

Steps:

  1. Put PyPlugins-with[out]-Jython-*.*.*.jar (download link) in your server/plugins/ directory
  2. Run server

Python plugins install


  1. Put the <PluginName>.pyplugin sources (directory or zip file) in your server/plugins/ directory
  2. Run server

Create plugin on Python

The PyPlugins contains a few way to create plugin for Spigot on Python.

It's can be:

  1. Clear Java-like approach (just write the code as a Java plugin, but using Python);
  2. Using internal pyplugins-framework (recomended);

First approach examples you can see here.

The next paragrphes about internal pyplugins-framework.

Plugin sources

Your plugin can use the following paths to the plugin source code:

  • A zip whos name ends in either .pyplugin.zip, _pyplugin.zip or just .pyplugin
  • A directory whose name ends in .pyplugin or _pyplugin (actual for windows users)

Zips with the .pyplugin extension are recommended if you release any plugins. When you use a zip, your must specify your own metadata; it will not allow guessed metadata.

When using a dir or a zip, your zip or dir must contain a main python file (with names: main.py, plugin.py, __main__.py or __init__.py) and a plugin.yml configuration file containing metadata (see the following section).

Plugin metadata

Plugins require metadata. The absolute minimum metadata is a name version and main class. The 'main' field of plugin metadata has special behavior:

  • the main is used to search for a main class before searching the default class name.

plugin.yml is able to set all metadata fields that exist in bukkit, and should be used for all plugins that you release. plugin.yml is used in all java plugins (as it is the only option for java plugins). as such, opening up java plugin jars is a good way to learn what can go in it. Or you can read about it here http://wiki.bukkit.org/Plugin_YAML Here isan example of plugin.yml:

name: SamplePlugin
main: SampleClass
version: 0.1-dev
commands:
    samplecommand:
        description: send a sample message
        usage: /<command>

Summary of fields:

  • "main" - name of main python file or name of main class
  • "name" - name of plugin to show in /plugins list and such. used to name the config directory. for this reason it must not equal the full name of the plugin file.
  • "version" - version of plugin. shown in errors, and other plugins can access it
  • "website" - mainly for people reading the code

Clear Java-like approach


Minimum requirements:

  • Main class have to be extended from PythonPlugin class. (You don't have to import it, because it is auto imported on startup of loader plugin).
  • Your main class must have onEnable() and onDisable() methods.

Code example and learn more..

The pyplugins-framework approach


The same as Java-like minimum requirements:

  • Main class have to be extended from PythonPlugin class. (You don't have to import it, because it is auto imported on startup of loader plugin).
  • Your main class must have onEnable() and onDisable() methods.

Handlers are available to easily create your Python plugin:

  • PythonCommandExecutor class (CommandsAPI)

    You can inherit your own PluginNameCommandExecutor class from PythonCommandExecutor to make handlers for "executeCommand" and "onTabComplete" actions (the command must be declared in plugin.yml). Just create methods for these actions and make the commands attribute of your PluginNameCommandExecutor class with instances of PyCommand class (with command and methods names). Also can be used as commands list acceptor (functional approach) and able to get PyCommands as first argument on initialization.

  • PythonListener class (EventsAPI)

    Similar to CommandsAPI, but with PythonListener class as parent, the listeners attribute (for save your handlers) of class with instances of PyEventHandler (requires name of method to execute, Bukkit event object and (optional) Bukkit ptiority object). Also can be used as listener list acceptor (functional approach) and able to get PyEventHandlers as first argument on initialization.

And more! Read..

Links

Donate

Follow Sponsor button on GitHub page.

Statistics

Development

NOTE:

bStats version 2.x.x does not allow the use of the org.bukkit.plugin.Plugin class for plugins and requires org.bukkit.plugin.java.JavaPlugin.

PyPlugins currently uses bStats 1.8, and needs to be added from the local jar:

mvn install:install-file -Dfile=bstats-bukkit-1.8.jar -DgroupId=org.bstats -DartifactId=bstats-bukkit -Dversion=1.8 -Dpackaging=jar

Author: @dmytrohoi

Minecraft PyPlugins's Projects

pyplugins icon pyplugins

Python Plugins loader plugin for Minecraft Spigot (Jython)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.