PPloader

PPLoader - Python Plugin Loader

This plugin allows developers to code bukkit plugins in the python programming language. The plugins in python use standard Bukkit API with some little changes. For more detailed instructions for installing this plugin and how to code plugins, take a look into the Readme on Github.

Features

  1. Load bukkit plugins written in python2.7.
  2. Load/Unload/Reload any python plugin without server restarting

Commands

  1. /pploader load <plugin_file> plugin_file could be any which ends with .pyp, .py.zip, .py.dir (.py.dir must be folder) example: /pploader load test.py.dir
  2. /pploader unload <Plugin_Name> Plugin_Name should be name of your plugin which specified in your plugin.yml
  3. /pploader reload <Plugin_Name> <plugin_file>

Installation

  1. Put pploader.jar in your <you_server_dir>/plugins/
  2. Put jython.jar in your <you_server_dir>/lib/ (within bukkit folder not plugins folder).
  3. Put your python plugin (.pyp, .py.zip, .py.dir ) in your <you_server_dir>/plugins/
  4. [Re-]Start bukkit

Downloads

PPLoader 1.1.0
Jython (By downloading and using Jython you accept the Jython License. Use Jython 2.7beta2 - Standalone Installer)
Source Code
Documentation The Readme on github contains an introduction to creating plugins in python

Tips & Tricks:

Project forked from [Python Plugin Loader](http://dev.bukkit.org/bukkit-plugins/python-plugin-loader/)

Class (bukkit standard) API

To write a plugin with this api is almost identical to writing one in java, so much so that you can safely use the documentation on how to write a java plugin; simply translate it into python. the java2py tool may even work on existing java plugins (though no promises).

Main class have to be extended from PythonPlugin class. (You don't have to import it, because it is auto imported on plugin startup by scripts/preload.py in pploader.jar). Your main class must have onEnable and onDisable method. (Don't forget to put your files in dir with name which ends .py.dir and put it in plugins folder For example: you can create folder sample.py.dir in you plugins folder and after that put your plugin.yml and plugin.py in it)

plugin.yml

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

plugin.py

    class SampleClass(PythonPlugin):
        def onEnable(self):            
            print "sample plugin enabled"
        
        def onDisable(self):
            print "sample plugin disabled"

Event Handlers

Event Handlers is the main part of any plugin. Вся логика обычно именно здесь. Создание Event Handlers немного отличается от стандартного java api. As usual you must create Listener class, but extend it from PythonListener class. (You don't have to import it, because it is auto imported on plugin startup by scripts/preload.py in pploader.jar). Methods of Listener class which will be event handlers must be decorated with PythonEventHandler. You must pass EventType and EventPriority to PythonEventHandler decorator. Example:

plugin.yml

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

plugin.py

    from org.bukkit.event import EventPriority
    from org.bukkit.event.player import PlayerJoinEvent

    class SimpleListener(PythonListener):
        def __init__(self, plugin):
            self.plugin = plugin
            PythonListener.__init__(self)

        @PythonEventHandler(PlayerJoinEvent, EventPriority.NORMAL)
        def onPlayerJoin(self, event):
            event.getPlayer().sendMessage('Wellcome to rccraft server')
            
    class SampleClass(PythonPlugin):
        def onEnable(self):
            pm = self.getServer().getPluginManager()
            self.listener = SimpleListener(self)
            pm.registerEvents(self.listener, self)
            print "sample plugin enabled"

        def onDisable(self):
            print "sample plugin disabled"

        def onCommand(self, sender, command, label, args):
            return False

Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

Categories

Members

Recent Files