Jython ;) You know you want it.

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

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

    taos

    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:
    package com.jakob.jython;
    
    import org.bukkit.plugin.java.JavaPlugin;
    import org.python.core.PyObject;
    import org.python.util.PythonInterpreter;
    
    import java.util.logging.Logger;
     
    public class EmbeddedJython extends JavaPlugin {
    
        private static final Logger log = Logger.getLogger("Minecraft");
        private PythonInterpreter interpreter;
    
        public void onEnable() {
            log.info("JythonTest enabled");
            this.interpreter = new PythonInterpreter();
            log.info("Jython interpreter fired up and cooking on gas");
    
            log.info("Firing exec");
            this.interpreter.exec("b = [a*2 for a in xrange(4)]");
            PyObject result = this.interpreter.get("b");
            log.info(result.toString());
        }
    
        public void onDisable() {
            log.info("Jython disabled");
        }
    
    }
    
    You will need to build the jar with jython and the latest bukkit build. But ;) it works
     
  2. Offline

    Redyugi

    See this, as well.
     
  3. Offline

    taos

    I see people have beaten me to it again :(
     
Thread Status:
Not open for further replies.

Share This Page