Python Plugin Loader

Discussion in 'WIP and Development Status' started by masteroftime, Jun 13, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    masteroftime

    I recently looked into some Python integrations and came up withe the idea of adding Python support to Bukkit. After I figured out that it is easy I tried it out and IT WORKS.

    I have already coded a working version which you can check out:
    CraftBukkit-python.jar
    Bukkit-python.jar
    TestPlugin

    And the forks on github:
    Bukkit
    CraftBukkit

    This is not an official build. It should be used for testing purposes only.

    The plugin code is contained in a zip file with .pyp extension. It has to contain a plugin.yaml file which works like the plugin.yaml in java plugins. It also has to contain plugin.py which is executed when the plugin is loaded and should contain the Plugin class.

    The loader doesn't have all features yet: There are no dependencies and the already mentioned issue with the python cache but nevertheless I wan't to enter the testing phase.
    Ignore error messages saying it processes some jar files. These are just info messages with wrong error level.


    So please: If you know some python download and analyze the test plugin, make your own python plugin and report any errors or problems to me.

    I will also eventually add a short tutorial on writing plugins in python so don't request it here.
     
    Clem, Glycan and dragos240 like this.
  2. Offline

    Redyugi

    Wait... Does this mean I can stop with the horrible nightmare called Java, and go back to my dream land of Python???

    Question, do we have to rewrite things such as iConomy to allow it to be used in our Python programs?
     
  3. Offline

    masteroftime

    1. Java is no nightmare
    2. Maybe
    3. It uses Jython so you can use all existing java classes like they were python classes.
     
  4. Offline

    Redyugi

    1. It is when you started out with Python ;) lol
    2. Jython? So it is like this plugin?
     
  5. Offline

    masteroftime

    @Redyugi I think it works like that but this is no plugin but a bukkit mod and I want to make a pull request later so that it will become part of bukkit.
     
  6. Offline

    croxis

    What is the additional memory overhead for the python interpreter?
     
  7. Offline

    Redyugi

    Ah. Well I suppose I'll try it out sometime. :)
     
  8. Offline

    masteroftime

    @croxis Not much. With the test plugin loaded and immidiately after the GC executed it took about 5MB more.
     
  9. Offline

    Redyugi

    @masteroftime Just downloaded it, and tried out your test plugin. Worked :)
    So I think I am gonna start messing around with it. I'll post back later with results.

    EDIT 1:
    Code:
    "{0}".format("Hello")
    Will not work. Easy enough to just use
    Code:
    "" + "Hello" + Variable
    But... OH well, back to testing.

    EDIT 2:
    Simple simple simple teleporting plugin with this.
    /tp <playername> to teleport to someone.
     

    Attached Files:

  10. Offline

    Redyugi

    From another day couple hours of testing, I find it easy to create small plugins. I decided to try some larger projects, such as a PVP Arena plugin.

    Something I noticed from messing around.
    Trying to import any class that can't be found raises an error. For that reason, I have enclosed it in a try/catch to stop the errors.
    Example
    Code:
    try:
        from com.redyugi.plugins import Fake
    except:
        Fake = object
    
    class Fake2(Fake):
        def onEnable():
            pm = self.getServer().getPluginManager()
            if pm.getPlugin(Needed):
                print "Fake2 is enabled, and attached to Needed"
            else:
                print "Fake2 can't find Needed. Disabling"
                self.onDisable()
    
     
  11. Offline

    Clem

    OMFG... You are a God. I just started teaching myself Python 2 days ago, and I have to say, it is the best language I have evar seen! I REALLY hope this gets put into bukkit, because my hosting site, Brohoster, won't allow me to upload any modified bukkit file, they do all the updating. So unless bukkit puts this I won't be able to use it... Honestly dude, this is F**KING AWESOME!!!!!!!!!!!! =D Please try and talk to the Bukkit Administrators!!!

    THANK YOU!
     
  12. Offline

    jonathanyc

    The error seems fine enough to me, and expected. :/
     
  13. Offline

    Redyugi

    @jonathanyc I expected it. I was just showing how I worked around it.
    Yeah, I sent in a support ticket asking them to allow me to upload it a week or so ago, and they were rude about it. Then I heard they were closing, and I was like... time for a VPS. (Which I won't have til pay day :( )
     
  14. Offline

    Clem

    They told me in a nice manner that they weren't going to allow to because of security reasons. Hopefully @masteroftime will log into his bukkit account (last log was Saturday), and this can get added to the official craftbukkit.jar
    :)

    P.S. I just bought a Python book from Barnes n' Noble about 30 minutes ago :D. I'm going to finish up my online tut, then off to the book, then off to The New Boston's video tuts... then I should be good. I <3 Python :D.

    Also if this get's put in I will be able to have interactive content with my server and google site?
     
  15. Offline

    masteroftime

    I was away for a week and I'm currently fighting through the bukkit plugin class loaders so that the python plugins can also work together with the java plugins. Then there will probably be a pull request to get it into bukkit.
     
  16. Offline

    Benjaneer

    OOH! Please do! I really want this. Python and my brain just mesh. Java... not so much. The default python ide is wonderfull. Maybe we can even add info about this to the help interactive prompt thingy in python. That would be amazing. This looks awesome. I will definitely be trying this out tomorrow.

    Hope this becomes a part of bukkit.:)
     
  17. Offline

    Redyugi

    Default IDE is not wonderful. IDLE is just..... Use PyScripter (Windows) or something. You'll find it's much better. :)
    If I had time, I'd help. Wish I could. Good luck though
     
  18. Offline

    Drakia

  19. Offline

    croxis

    Under the GLP sources have to be provided on request. That just means if someone asks for it it has to be shelled out, it doesn't not mean the source has to be posted publicly (unless a ruling changed this or the wording changed). However this site can require more strict rules.
     
  20. Offline

    Drakia

    By posting that the source is required I am requesting said source.
     
  21. Offline

    desmin88

    @Drakia
    Also, EvilSeph said the licenses are applied incorrectly. Therefore being moot and masteroftime doesn't have to provide source, correct me if I'm wrong.
     
  22. Offline

    Drakia

    @desmin88 Erm, no, Bukkit is GPL, CraftBukkit is LGPL, but they are not forcing that license upon PLUGINS, this is a fork of CraftBukkit/Bukkit.
     
  23. Offline

    desmin88

    @Drakia
    Lol, fail on my part.
     
  24. Offline

    zonedabone

    Did you embed the jython jar inside of this?

    Instead of having the files, perhaps have people put the py and pyp files into a jar, just to make it more seamless for the average user.
     
  25. Offline

    masteroftime

    @Drakia no problem it was open source anyway. I just forgot to put the link there

    And as this is just a snapshot of a feature which will be included into official bukkit one day i think it's ok to distribute it.
     
  26. Offline

    Benjaneer

    I love it just the same, at least for learning. The interactive help was insanely useful for me.. i didn't need a book or anything, just that feature. ;) I will look at PyScripter though, thanks for the tip.


    I really can't wait for this to go official! Good Luck. ;)
     
  27. Offline

    Drakia

    Well, whether it's included or not is up to the Bukkit devs, but this is still considered a fork and unofficial build, something they clearly state is not allowed to be posted on the forums.
    We'll see what the admins say though, because in the end it's their call.
     
  28. Offline

    Benjaneer

    Yeah, i know but it looks like it has a good shot at being included.:)
     
  29. Offline

    Drakia

    Did I miss a dev stating this somewhere? As it is, he hasn't made a pull request nor even had staff acknowledge the existence of this addon, so how do you get that it has a good shot at being included?
     
  30. Offline

    dragos240

    This.... this is awesome. Wow, I'm speechless. I love python.
     
Thread Status:
Not open for further replies.

Share This Page