Jython ;) You know you want it.

Discussion in 'Bukkit Discussion' started by taos, Jun 20, 2011.

  1. Offline

    taos

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I have been searching now for a while for a way of bridging jython into a bukkit plugin, I gave up and cooked my own and this is what I came up with.

    Code (Text):
    1. package com.jakob.jython;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4. import org.python.core.PyObject;
    5. import org.python.util.PythonInterpreter;
    6.  
    7. import java.util.logging.Logger;
    8.  
    9. public class EmbeddedJython extends JavaPlugin {
    10.  
    11.     private static final Logger log = Logger.getLogger("Minecraft");
    12.     private PythonInterpreter interpreter;
    13.  
    14.     public void onEnable() {
    15.         log.info("JythonTest enabled");
    16.         this.interpreter = new PythonInterpreter();
    17.         log.info("Jython interpreter fired up and cooking on gas");
    18.  
    19.         log.info("Firing exec");
    20.         this.interpreter.exec("b = [a*2 for a in xrange(4)]");
    21.         PyObject result = this.interpreter.get("b");
    22.         log.info(result.toString());
    23.     }
    24.  
    25.     public void onDisable() {
    26.         log.info("Jython disabled");
    27.     }
    28.  
    29. }
    30.  
    You will need to build the jar with jython and the latest bukkit build. But ;) it works
     
  2. Offline

    Redyugi

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    See this, as well.
     
  3. Offline

    taos

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I see people have beaten me to it again :(
     

Share This Page