Inactive [DEV] PythonLoader v0.3.1 - Load Plugins written in Python [1.1-R6]

Discussion in 'Inactive/Unsupported Plugins' started by masteroftime, Aug 8, 2011.

  1. Offline

    masteroftime

    PythonLoader 0.3
    This plugin allows developers to code bukkit plugins in the python programming language. The plugins in python can either use a thin wrapper to the standard Bukkit API, or the newer decorator API. For more detailed instructions for installing this plugin and how to code plugins, take a look into the Readme on Github.

    Features:
    • Load bukkit plugins written in python.
    Installation:
    Put PythonLoader.jar into plugins directory and jython.jar into lib directory (within bukkit folder not plugins folder).

    PythonLoader
    Jython (By downloading and using Jython you accept the Jython License)
    Source Code

    I have to give special credits to @lahwran who created the whole decorator API and corrected many of my mistakes. :)

    Changelog: Version 0.3.1

    Version 0.3.1
    • Updated to CB 1.1-R6
    Version 0.3
    • Updated to CB 1.1-R1
    • Changed to new EventHandling System
    Version 0.2
    • Added decorator API
    • Invalid plugin exceptions are thrown when an invalid python plugin is loaded
    • Seperate Python Interpreter for each plugin
    • JavaPlugin's event executor creation is now directly used
    Version 0.1.1
    • Changed plugin.yaml to plugin.yml
    • Removed some debug output
    Version 0.1
    • First official release.
     
  2. Hey guys, I need help with fixing the following error:

    Code:
    Traceback (most recent call last):
      File "<iostream>", line 38, in onPlayerMove
    TypeError: createExplosion(): self arg can't be coerced to org.bukkit.World
    
        at org.python.core.PyException.fillInStackTrace(PyException.java:70)
        at java.lang.Throwable.<init>(Throwable.java:181)
        at java.lang.Exception.<init>(Unknown Source)
        at java.lang.RuntimeException.<init>(Unknown Source)
        at org.python.core.PyException.<init>(PyException.java:46)
        at org.python.core.PyException.<init>(PyException.java:43)
        at org.python.core.PyException.<init>(PyException.java:61)
        at org.python.core.Py.TypeError(Py.java:221)
        at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209)
        at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:312)
        at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:321)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:167)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
        at org.python.core.PyObject.__call__(PyObject.java:357)
        at org.python.core.PyObject.__call__(PyObject.java:361)
        at org.python.pycode._pyx1.onPlayerMove$5(<iostream>:39)
        at org.python.pycode._pyx1.call_function(<iostream>)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
        at org.python.core.PyFunction.__call__(PyFunction.java:387)
        at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
        at org.python.core.PyMethod.__call__(PyMethod.java:211)
        at org.python.core.PyMethod.__call__(PyMethod.java:201)
        at org.python.core.PyMethod.__call__(PyMethod.java:196)
        at org.python.core.PyObject._jcallexc(PyObject.java:3502)
        at org.python.core.PyObject._jcall(PyObject.java:3534)
        at org.python.proxies.__main__$Pl$1.onPlayerMove(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader$7.execute(JavaPluginLoader.java:286)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:180)
        at net.minecraft.server.Packet10Flying.a(SourceFile:126)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:92)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:108)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:471)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)


    This error appears, when using the following Script:

    http://pastebin.com/yzRJQKAs

    In hope, greets Brainsucker :)
     
  3. Offline

    Nekroze

    Can anyone explain how to do this, i the python loader and jython files to my C:/Python/Libs folder (which from documentation is the default place it should look) but i still do not get auto-completion in Pyscripter (latest version)
    do i need to put bukkit.jar in there aswell as any other plugins i want to use (like spout) to get autocompletetion?

    Thanks in advance
     
  4. Offline

    MalcolmLC

    wait , you can get auto complete doing that 0_O , I just learned somthing today .
     
  5. Offline

    Nekroze

    well at least i have taught someone how NOT to accomplish something... good start?
     
  6. Offline

    MalcolmLC

    XD, I was going to wait untill some one answers your question to test it out . Im new to this stuff :p
     
  7. Offline

    jsalles

    Love it, use it. Java is such a headache.

    Thanks!
     
  8. Offline

    MalcolmLC

    Can any one explain to me how to make a command , I keep trying but i fail so hard :(
     
  9. Offline

    jsalles

    In the .yml file you need to specify it :D

    Code:
    name: HiRyan
    main: TestPlugin
    version: 0.3
    commands:
        ryan: <--- HERE
            description: Hi Ryan :D
            usage: /<command>
     
  10. Offline

    MalcolmLC

    I was messing around trying to make a plugin to spam the chat ,
    and Im haivng this weird problem,
    I wanted the plugin to use any int arguments after the /spamme command as the second or sole number for the
    bif range() and when it does that to send it to the player , but When I log into my little server and type /spamme and a number , the console spames me ( ha! ) with some information that basicaly says there were two arguments given even though I only used args[0].
    here is the code btw (well not all of it but the part that the problem is coming from )
    Code:
    class malcolmjunk():
        def spammer(myrange= 0):
            for each_number in range(myrange):
                 sender.sendMessage(each_number)
    ##global target identifyers
    junk =malcolmjunk()
    ##end globals
    @hook.enable
    def onenable():
        print "[Cspammer]--Enabled"
    @hook.disable
    def ondisable():
        print "[Cspammer]--Disabled"
    """This is where the commands are """
    @hook.command
    def sb (sender,commad,label, args):
        sender.sendMessage("You have activated the sb command ")
        return true
    @hook.command
    def spamme(sender,command,label,args):
        if args[0] != 0:
            print "The player typed a number as a argument"
            sender.sendMessage(junk.spammer(args[0]))
        else:
            print "The player did not type a number as an argument"
            sender.sendMessage("The following was not a number"+ args)
        return true
     
  11. Offline

    jsalles

    I'm trying to replicate this, I haven't used the Decorator API yet so this'll be a learning experience for me as well!

    :D
     
    MalcolmLC likes this.
  12. Offline

    MalcolmLC

    you could either use a plugins.yml or the other metadata thing so you dont have to make 2 files of it , would you like me ot just send you my little spamming plugin ?
     
  13. Offline

    WhosDaMan

    Open at your own risk.
    Show Spoiler
    THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU
     
  14. Offline

    jsalles

    After some familiarization, I've successfully created this spammer plugin using the decorator API.

    Code:
    class malcolmjunk():
        def spammer(self, sender, myrange):
            for each_number in range(myrange):
                 sender.sendMessage("[Spammer] %s" % each_number)
    
    junk =malcolmjunk()
    
    @hook.command("spamme", usage="/<command>",
                    desc="Spam yourself, do it.")
    def spamme(sender,command,label,args):
        if len(args) != 0:
            #print "The player typed something as a argument"
            bob = eval(args[0])
            junk.spammer(sender,bob)
        else:
            # This doesn't really work, I never implemented a "check for number" function.
            #print "The player did not type a number as an argument"
            sender.sendMessage("The following was not a number %s" % args[0])
        return True
     
  15. Offline

    iarspider

    Attached Files:

    MalcolmLC likes this.
  16. Offline

    Nekroze

    still no details on how to get auto-completion working? I am using pyscripter, however i will use pretty much anything that can accomplish this.
     
    Clem likes this.
  17. Offline

    iarspider

    @Nekroze: try Eclipse+PyDev or NetBeans. I have tried the former, and it works - kind of.

    @masteroftime: could you please update your PythonPlugin class to use "New" configuration"?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  18. Offline

    Nekroze

    ok but what do i actualy have to add to where to link in bukkit and stuff, maybe other plugins aswell to get autocompletion from them? i will download eclipse to try it but i have never used it and dont know what to add to where or whatever needs to be done. i have however used netbeans before so would perfer to continue to use that one if at all possible
     
  19. Offline

    DragonSoulSong

    I don't know personally about netbeans, but I do know that in Eclipse you should be able to right-click on a project in the package browser on the left side and select "Build Path > Configure Build Path..." and that should take you to a dialog in which you simply click on the button that says "Add External JARs" and then navigate to and select the bukkit jar.
     
  20. Offline

    Nekroze

    cool will check for that mate thanks, if its at all different i will report back in case anyone else is wondering.

    EDIT: after looking around in the python project settings and stuff in netbeans there doesnt seem to be anything remotely like that setting... any other suggestions? i can see what i beleive is the netbeans equivilant of this when i start a java project but nothing of the like for python.
     
  21. Offline

    MalcolmLC

    Will there be a new version out soon , or even like a beta ?
     
  22. Offline

    Fusioneko

    I would like to see another update, it's definitely something in the right direction.

    I see this as something with great potential.
     
    MalcolmLC likes this.
  23. Offline

    MalcolmLC

    I was trying to get some of the messages in a little plugin I wanted to make to be gold .
    but after I import ChatColor and I try adding a message to an example command like this :
    Code:
    print (ChatColor.GOLD + " some random string " )
    all I get is an error from the console that says this :
    Code:
      File "<iostream>", line 14, in onEnable
    TypeError: cannot concatenate 'str' and 'org.bukkit.ChatColor' objects
     
  24. Offline

    gcq

    @MalcolmLC i think you need to convert the "org.bukkit.ChatColor" object to a string object.

    I don't know if with that type of object, you can use "str(ChatColor.GOLD)" or not, just try it. This will return a string object. You can use this one with the print function.

    print (str(ChatColor.GOLD) + " some random string ")

    ;)
     
  25. Offline

    MalcolmLC

    I love you , so so much.
     
    gcq likes this.
  26. Offline

    xXKebobXx

    So i would like to use this but i was wondering if it works on python 3.1.2, and if it works on the new RB 1597 if not we need someone to get in here and update this beautiful plugin.
     
    Clem likes this.
  27. Offline

    philipborg

    Does it work to make spout plugins using python?
     
  28. Offline

    masteroftime

    This plugin uses Jython so the highest Python version supported is unfortunately 2.5. That's why the next step on the roadmap would be to use a different library like JPype or Jepp which uses the original Python interpreter.

    However school has dragged my attention away from Bukkit so I didn't have the time to continue the developement of PythonLoader. I also don't know if it works with the newest version of Bukkit.
     
  29. Offline

    lahwran

    http://lucene.apache.org/pylucene/jcc/documentation/readme.html

    JPype and Jepp are both out of date. JCC, however, is not. JCC would require special parameters on the bukkit command line, so we'd want to not discontinue jython support, but we could unify the apis and simply allow server administrators to install the JCC version as a speedup. JCC would expose features not available in jython, and there would be some of the same the other way, so we'd want to allow plugins to mark themselves compatible with one or both.

    Also, JCC has a python 3 version, though it's experimental.
     
  30. Offline

    TACTICALboom

    How did i just find this? This plugin is my dream...(and that's coming from a guy thats a hardcore java/C# developer)
    //EDIT: Didn't work on latest RB :(
     
  31. Offline

    Clem

    @masteroftime when an RB for 1.1 comes out will you be updating your ingenious plugin which I still think Dinnerbone should have put directly into bukkit -_-.
     
    TACTICALboom likes this.

Share This Page