Post install problem: '/js up()' causes ScriptException
nickmalleson opened this issue ยท 4 comments
I'm new to ScriptCraft, so apologies in advance if I've done something stupid. I am using ScriptCraft version 3.4.0 (https://github.com/walterhiggins/ScriptCraft/releases/tag/3.4.0) running with spigot-1.16.2 on OS X Catalina (10.15.6). I have successfully installed the ScriptCraft plugin and can make the simple 'greet' mod to print my username. But if I try to run the command
/js up().box( blocks.wool.black, 4, 9, 1 )
I get the following error:
Error: java.lang.RuntimeException: javax.script.ScriptException: ReferenceError: "up" is not defined in <eval> at line number 1
(full stack trace below).
A few commands work, e.g. \js blocks.oak
returns "5"
but any function calls give similar errors to the one above.
There are also some warnings thrown when the server stars up which may be relevant:
[05:37:56] [Server thread/ERROR]: [scriptcraft] Plugin /Users/nick/minecraft/scriptcraft/plugins/arrows.js Error: Error executing module /Users/nick/minecraft/scriptcraft/plugins/arrows.js line #336 : Error executing module drone line #undefined : java.lang.ClassNotFoundException: org.bukkit.craftbukkit.v1_16_R2.util.CraftEvil
undefined
> undefined
[05:37:56] [Server thread/ERROR]: [scriptcraft] Plugin /Users/nick/minecraft/scriptcraft/plugins/drone/contrib/cottage.js Error: Error executing module /Users/nick/minecraft/scriptcraft/plugins/drone/contrib/cottage.js line #158 : Drone.extend is not a function
}
Any ideas why function calls don't work?
Thanks in advance,
Nick
Full stack trace from /js up().box( blocks.wool.black, 4, 9, 1 )
:
[05:31:46] [Server thread/INFO]: nsm99999 issued server command: /js up().box( blocks.wool.black, 4, 9, 1 )
[05:31:46] [Server thread/ERROR]: [scriptcraft] Error while trying to evaluate javascript: up().box( blocks.wool.black, 4, 9, 1 ), Error: java.lang.RuntimeException: javax.script.ScriptException: ReferenceError: "up" is not defined in <eval> at line number 1
[05:31:46] [Server thread/ERROR]: [scriptcraft] javax.script.ScriptException: java.lang.RuntimeException: javax.script.ScriptException: ReferenceError: "up" is not defined in <eval> at line number 1 in <eval> at line number 695 at column number 8
[05:31:46] [Server thread/WARN]: javax.script.ScriptException: java.lang.RuntimeException: javax.script.ScriptException: ReferenceError: "up" is not defined in <eval> at line number 1 in <eval> at line number 695 at column number 8
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:477)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:399)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:197)
[05:31:46] [Server thread/WARN]: at org.scriptcraftjs.bukkit.ScriptCraftPlugin.onCommand(ScriptCraftPlugin.java:75)
[05:31:46] [Server thread/WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[05:31:46] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
[05:31:46] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R2.CraftServer.dispatchCommand(CraftServer.java:756)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.PlayerConnection.handleCommand(PlayerConnection.java:1697)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.PlayerConnection.a(PlayerConnection.java:1540)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.PacketPlayInChat.a(PacketPlayInChat.java:47)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.PacketPlayInChat.a(PacketPlayInChat.java:1)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.TickTask.run(SourceFile:18)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.IAsyncTaskHandler.executeTask(SourceFile:144)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.IAsyncTaskHandler.executeNext(SourceFile:118)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.MinecraftServer.ba(MinecraftServer.java:941)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.MinecraftServer.executeNext(MinecraftServer.java:934)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.IAsyncTaskHandler.awaitTasks(SourceFile:127)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.MinecraftServer.sleepForTick(MinecraftServer.java:918)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.MinecraftServer.w(MinecraftServer.java:850)
[05:31:46] [Server thread/WARN]: at net.minecraft.server.v1_16_R2.MinecraftServer.lambda$0(MinecraftServer.java:164)
[05:31:46] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:830)
[05:31:46] [Server thread/WARN]: Caused by: <eval>:695:8 java.lang.RuntimeException: javax.script.ScriptException: ReferenceError: "up" is not defined in <eval> at line number 1
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAException.create(ECMAException.java:113)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$531$\^eval\_.__onEnable#__onCommand(<eval>:695)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:646)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:202)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:393)
[05:31:46] [Server thread/WARN]: ... 21 more
[05:31:46] [Server thread/WARN]: Caused by: java.lang.RuntimeException: javax.script.ScriptException: ReferenceError: "up" is not defined in <eval> at line number 1
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:116)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.objects.NativeArray.forEach(NativeArray.java:1580)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$531$\^eval\_.__onEnable#__onCommand(<eval>:649)
[05:31:46] [Server thread/WARN]: ... 26 more
[05:31:46] [Server thread/WARN]: Caused by: javax.script.ScriptException: ReferenceError: "up" is not defined in <eval> at line number 1
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:477)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:461)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:413)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:409)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:162)
[05:31:46] [Server thread/WARN]: at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$66$19876A$\^eval\_.__onEnable#engineEval(<eval>:598)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$514$21161A$\^eval\_.__onEnable#__onCommand#L:649(<eval>:650)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.objects.NativeArray$9.forEach(NativeArray.java:1577)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.arrays.IteratorAction.apply(IteratorAction.java:110)
[05:31:46] [Server thread/WARN]: ... 28 more
[05:31:46] [Server thread/WARN]: Caused by: <eval>:1 ReferenceError: "up" is not defined
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1616)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$592$\^eval\_/0x0000000801b6f440.:program(<eval>:1)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
[05:31:46] [Server thread/WARN]: at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:456)
[05:31:46] [Server thread/WARN]: ... 36 more
Confirmed. I have same issue -- first time setting up ScriptCraft as well. /js 1+1
works fine, the 'blocks howl' demo works fine, but /js up()
throws an exception.
The exceptions above are easy to fix:
(As you seem to use MC 1.16.2, possibly, you also should integrate the changes from pull request "minor workable fix for drone on 1.15.x and 1.16.x #443", before...)
Find these lines in your spigot server folder ./scriptcraft/modules/drone/index.js (must be about line 349)
console.log('Drone using CraftEvil.setTypeIdAndData method');
var CraftEvil = Java.type(server.class.package.name + '.util.CraftEvil');
return function(block, typeId, data, applyPhysics) {
and change them to become these lines:
console.log('Drone using CraftEvil.setTypeIdAndData method');
var CraftEvil = Java.type(server.class.package.name + '.legacy.CraftEvil');
return function(block, typeId, data, applyPhysics) {
Greetings,
Markus
Thanks Markus, changing those three lines worked a treat. I didn't integrate the changes from #443 but will do that first if I hit any other problems. I'll leave this open in case you intend to integrate the changes into the main branch first.
And thanks for helping this great library, I'm playing minecraft with my son and am tricking him into learning to code without him realising it :-)
Huge thanks @Markus-1974