[DEV] jxpl - javax.script Plugin Loader r12, r14 [1597 (1.0.1-R1), 1.1]

Discussion in 'Inactive/Unsupported Plugins' started by angelsl, Oct 27, 2011.

  1. Offline

    angelsl

  2. Offline

    MonsieurApple

  3. Offline

    angelsl

    jxpl r7 released
    • Added GPL v3 header
    • Avoid possibility that onLoad() isn't called
    • Add PluginHelper.log(level, message, exception)

    jxpl r8 released
    • Support for bukkit's built-in YAML configuration
     
  4. Offline

    Kaikz

    Yay jxpl is back from the dead. :D
     
    angelsl likes this.
  5. Offline

    ekgame

    Any plans for LUA support?
     
  6. Offline

    angelsl

    That list up there is not exhaustive. jxpl will support any language that supports JSR 223 (javax.script).

    I did some searching. http://sourceforge.net/projects/luaj/ There you go. Just plop lib/luaj-jse-2.0.2.jar in the classpath in front of Craftbukkit and jxpl should detect it and register it appropriately; you'll see the log message if it's working correctly.
     
  7. Offline

    ninjacreep3r

    I'm new with all this minecraft server and all so what does this do?
     
  8. Offline

    angelsl

    This provides a way for developers to write plugins for Bukkit in any script languages providing a JSR 223 interface.
     
  9. Offline

    Sp0ng3b0b

    Very NICE!

    But any possibility for PHP? :D Would be the shizzle. Im gewd at it, but i fail at java xD
     
  10. Offline

    angelsl

    jxpl r9 released
    • Loads script engine jars from plugins/jxpl/lib/; no more hacking the jar or classpath.
    • Log output prefixed with [jxpl]
    • Some code refactoring
    jxpl r10 released
    • Avoid duplicate listeners after reload by deregistering listeners on disable
    Doesn't seem like. The only JSR223-compatible PHP engine I found out there is Quercus, which doesn't implement Invocable. Sorry.
     
  11. I need to know how can i make 2 commands in PDF, because i can't add second (many errors in console) and how to make for example mob spawn function.:)
     
  12. Offline

    angelsl

    I'll assume you're using JavaScript...
    Code:
    importPackage(org.bukkit.entity);
    importPackage(java.lang);
    SCRIPT_PDF = {
        "name" : "SpawnMob",
        "version" : "1",
        "commands" : {
                "spawnmob" : { "description" : "Spawns a monster. Monster names are case-sensitive!", "usage" : "/<command> <monster>", "permission" : "spawnmob.command" },
                "command2" : { "descrption" : "Another command", "usage" : "/<command>" } // 2 commands
            },
        "permissions" : {
                "spawnmob.command" : { "description" : "Allows access to /spawnmob" }
            }
        };
    
    function onEnable() {}
    
    function onDisable() {}
    
    function onCommand(p, command, cl, args)
    {
        command = command.getName().toLowerCase();
        if(command == "spawnmob") {
            if(args.length < 1) { p.sendMessage("Usage: /spawnmob <monster>"); return true; }
            var cType = CreatureType.fromName(args[0]);
            p.getWorld().spawnCreature(p.getLocation(), cType);
            p.sendMessage("Spawned one " + cType);
            return true;
        } else if(command == "command2") {
            p.sendMessage("You called /command2.");
            return true;
        } else return false;
    }
    
     
  13. Offline

    nacs

    angelsl likes this.
  14. Thanks :)
     
  15. Offline

    nacs

    On a mac, I'm getting this exception (obviously Applescript isn't supported but is there a way to stop this exception?).

    Code:
    06:59:17 [INFO] [jxpl] Initialising jxpl on server version "git-Bukkit-1.0.1-R1-1-g1e6a083-b1602jnks (MC: 1.0.1)", Bukkit version "1.0.1-R2-SNAPSHOT"
    06:59:18 [WARNING] [jxpl] Failed to load script engine "AppleScriptEngine 1.1"! Is the engine Invocable?
    java.lang.ClassCastException: apple.applescript.AppleScriptEngine cannot be cast to javax.script.Invocable
        at org.angelsl.bukkit.jxpl.ScriptLoader.<init>(ScriptLoader.java:48)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.bukkit.plugin.SimplePluginManager.registerInterface(SimplePluginManager.java:87)
        at org.angelsl.bukkit.jxpl.JxplPlugin.onLoad(JxplPlugin.java:77)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:154)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:127)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    06:59:18 [INFO] [jxpl] Adding file extension ".js" for scripting engine "Mozilla Rhino".
    Also getting this exception when trying to use 2 of your sample scripts:
    Code:
    07:07:25 [SEVERE] [jxpl] Not loading script "jxpl.command.js"; SCRIPT_PDF not of type Map<String, Object>.
    07:07:25 [SEVERE] Could not load 'scripts/jxpl.command.js' in folder 'scripts': SCRIPT_PDF not of type Map<String, Object>
    org.bukkit.plugin.InvalidDescriptionException: SCRIPT_PDF not of type Map<String, Object>
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:115)
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:97)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
        at org.angelsl.bukkit.jxpl.JxplPlugin.onLoad(JxplPlugin.java:85)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:154)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:127)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    07:07:25 [SEVERE] [jxpl] Not loading script "spawn.js"; SCRIPT_PDF not of type Map<String, Object>.
    07:07:25 [SEVERE] Could not load 'scripts/spawn.js' in folder 'scripts': SCRIPT_PDF not of type Map<String, Object>
    org.bukkit.plugin.InvalidDescriptionException: SCRIPT_PDF not of type Map<String, Object>
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:115)
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:97)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
        at org.angelsl.bukkit.jxpl.JxplPlugin.onLoad(JxplPlugin.java:85)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:154)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:127)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
     
  16. Offline

    pudd1nG

    Getting the same as nacs :)
     
  17. Offline

    angelsl

    I'll have jxpl ignore AppleScript in release 11.. Thanks!
    Are both of you on Mac OS X? It seems like a problem with Apple's JRE. I'm on Java 7 Update 1 64-bit on Windows 7 and I'm unable to reproduce:
    Code:
    21:15:03 [INFO] [jxpl] Initialising jxpl on server version "git-Bukkit-1.0.1-R1-b1597jnks (MC: 1.0.1)", Bukkit version "1.0.1-R1"
    21:15:03 [INFO] [jxpl] Adding file extension ".js" for scripting engine "Mozilla Rhino".
    21:15:03 [INFO] [jxpl] Loaded script "jxpl.command.js" ([jxpl.command] version [2] by [])
    21:15:03 [INFO] [jxpl] Loaded script "SpawnMob.js" ([SpawnMob] version [1] by [])
    Thanks again! :x
     
  18. Code:
    function onEnable() {
        helper.log(Level.INFO, "JustSpawnMob loaded!");
        helper.registerEvent(Event.Type.PLAYER_JOIN, Event.Priority.Lowest, "onPlayerJoin");
    }
    What should i set for "Level." ? Because there are some errors on that line with Level.
     
  19. Offline

    angelsl

    You need to import java.util.logging, at the top, like my example scripts:
    Code:
    importPackage(java.util.logging);
    
     
  20. Offline

    nacs

    I am yes. If Java 7 is required, then this is the likely problem. Mac ships with a Apple-modified runtime (so the Java app GUIs fit the look of the rest of OS X and such) -- so we're on 1.6:
    Code:
    $java -version
    java version "1.6.0_29"
    Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
    Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
    Our Linux based server is also using 1.6 so it would be great to have 1.6 support if it Java 7 is required atm.
     
  21. Offline

    pudd1nG

    I am on centos with no real urge to update. Is the any work arounds?
     
  22. Offline

    angelsl

    I don't think Java 7 is required; I'm also running jxpl on my server which runs Java 6 and those scripts work fine..

    Could you try this: Download ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3.zip and drop js.jar into plugins/jxpl/lib/, and try those scripts again?
     
  23. Offline

    nacs

    Same error:

    Code:
    01:56:28 [INFO] [jxpl] Initialising jxpl on server version "git-Bukkit-1.0.1-R1-1-g1e6a083-b1602jnks (MC: 1.0.1)", Bukkit version "1.0.1-R2-SNAPSHOT"
    01:56:28 [INFO] [jxpl] Injected JAR at "/Users/nacs/My Games/minecraft/plugins/jxpl/lib/js.jar".
    01:56:28 [INFO] [jxpl] Adding file extension ".js" for scripting engine "Mozilla Rhino".
    01:56:30 [WARNING] [jxpl] Failed to load script engine "AppleScriptEngine 1.1"! Is the engine Invocable?
    
    ---applescript exception removed--
    
    01:56:30 [SEVERE] [jxpl] Not loading script "jxpl.command.js"; SCRIPT_PDF not of type Map<String, Object>.
    01:56:30 [SEVERE] Could not load 'scripts/jxpl.command.js' in folder 'scripts': SCRIPT_PDF not of type Map<String, Object>
    org.bukkit.plugin.InvalidDescriptionException: SCRIPT_PDF not of type Map<String, Object>
    	at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:115)
    ...
     
  24. Offline

    angelsl

    This is weird.. I need to leave now but I'll test it out when I get back, with Jenkins CB 1602.

    Is there any way to contact you outside of this thread? It's kinda hard to communicate like this.. IRC perhaps?
     
  25. Offline

    nacs

    It seems I can't message you via forums (although I can message others) and I'd rather PM the contact info. Perhaps you've disabled messaging in your settings?
     
  26. Where do i need to upload Rhino files ? Because i'm getting errors with Rhino.
     
  27. Offline

    angelsl

    Sorry, I've enabled messaging.. though I'd rather communicate via IRC if possible. I'm in Bukkit and Spout's IRC channel most of the time.
    What errors exactly? Please show me a stack trace.
     
  28. Code:
    2011-12-15 22:03:03 [INFO] [jxpl] Initialising jxpl on server version "git-Bukkit-1.0.1-R1-b1597jnks (MC: 1.0.1)", Bukkit version "1.0.1-R1"
    2011-12-15 22:03:03 [INFO] [jxpl] Adding file extension ".js" for scripting engine "Mozilla Rhino".
    2011-12-15 22:03:03 [SEVERE] javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "gimportPackage" is not defined. (<Unknown source>#4) in <Unknown source> at line number 4
    2011-12-15 22:03:03 [SEVERE]     at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at javax.script.AbstractScriptEngine.eval(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at org.angelsl.bukkit.jxpl.ScriptLoader.getScriptEngine(ScriptLoader.java:126)
    2011-12-15 22:03:03 [SEVERE]     at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:105)
    2011-12-15 22:03:03 [SEVERE]     at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:97)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
    2011-12-15 22:03:03 [SEVERE]     at org.angelsl.bukkit.jxpl.JxplPlugin.onLoad(JxplPlugin.java:85)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:154)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:434)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.Bukkit.reload(Bukkit.java:187)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:22)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:378)
    2011-12-15 22:03:03 [SEVERE]     at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:374)
    2011-12-15 22:03:03 [SEVERE]     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:564)
    2011-12-15 22:03:03 [SEVERE]     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:541)
    2011-12-15 22:03:03 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
    2011-12-15 22:03:03 [SEVERE]     at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    2011-12-15 22:03:03 [SEVERE] Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "gimportPackage" is not defined. (<Unknown source>#4)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.ScriptRuntime.getNameFunctionAndThis(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.Interpreter.interpret(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.InterpretedFunction.call(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     at sun.org.mozilla.javascript.internal.Context.evaluateReader(Unknown Source)
    2011-12-15 22:03:03 [SEVERE]     ... 19 more
    2011-12-15 22:03:03 [WARNING] [jxpl] Error while evaluating script!
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "gimportPackage" is not defined. (<Unknown source>#4) in <Unknown source> at line number 4
        at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
        at javax.script.AbstractScriptEngine.eval(Unknown Source)
        at org.angelsl.bukkit.jxpl.ScriptLoader.getScriptEngine(ScriptLoader.java:126)
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:105)
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:97)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
        at org.angelsl.bukkit.jxpl.JxplPlugin.onLoad(JxplPlugin.java:85)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:154)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:434)
        at org.bukkit.Bukkit.reload(Bukkit.java:187)
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:22)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:378)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:374)
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:564)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:541)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "gimportPackage" is not defined. (<Unknown source>#4)
        at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(Unknown Source)
        at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(Unknown Source)
        at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(Unknown Source)
        at sun.org.mozilla.javascript.internal.ScriptRuntime.getNameFunctionAndThis(Unknown Source)
        at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Unknown Source)
        at sun.org.mozilla.javascript.internal.Interpreter.interpret(Unknown Source)
        at sun.org.mozilla.javascript.internal.InterpretedFunction.call(Unknown Source)
        at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(Unknown Source)
        at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(Unknown Source)
        at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(Unknown Source)
        at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(Unknown Source)
        at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(Unknown Source)
        at sun.org.mozilla.javascript.internal.Context.evaluateReader(Unknown Source)
        ... 19 more
    2011-12-15 22:03:03 [SEVERE] null initializing jxpl v10 (Is it up to date?)
    java.lang.NullPointerException
        at org.angelsl.bukkit.jxpl.Utils.getOrExcept(Utils.java:94)
        at org.angelsl.bukkit.jxpl.ScriptPlugin.<init>(ScriptPlugin.java:74)
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:106)
        at org.angelsl.bukkit.jxpl.ScriptLoader.loadPlugin(ScriptLoader.java:97)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
        at org.angelsl.bukkit.jxpl.JxplPlugin.onLoad(JxplPlugin.java:85)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:154)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:434)
        at org.bukkit.Bukkit.reload(Bukkit.java:187)
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:22)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:378)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:374)
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:564)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:541)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
     
  29. Offline

    angelsl

    I'd suggest you actually read the error next time.
    Code:
    2011-12-15 22:03:03 [SEVERE] Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "gimportPackage" is not defined. (<Unknown source>#4)
    Try fixing the typo and removing the extra 'g'.
     
  30. Sorry for that, just read ^^

    Okay, now no errors, but i can't image how can i add "getDamage()" event ? I just need to cancel damage by returning false or smth.

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

Share This Page