Is not loading my .js file
ToxicityEXE opened this issue ยท 3 comments
I hope my English level is enough for your understanding, I use Ubuntu, I installed the ScriptCraft plugin properly, then I created a .js file in this location: Server/scriptcraft/plugins/"file.js"/, so I started the server, I entered then I inserted the code for running my script /js file.js
(I have already refreshed it), then throws me this error
[08:50:50 INFO]: user issued server command: /js file.js
[08:50:50 ERROR]: [scriptcraft] Error while trying to evaluate javascript: file.js, Error: javax.script.ScriptException: ReferenceError: "file" is not defined in at line number 1
[08:50:50 ERROR]: [scriptcraft] javax.script.ScriptException: javax.script.ScriptException: ReferenceError: "file" is not defined in at line number 1 in at line number 638 at column number 8
The rest of the error:
[08:50:50 WARN]: javax.script.ScriptException: javax.script.ScriptException: ReferenceError: "file" is not defined in at line number 1 in at line number 638 at column number 8
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:392)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:190)
[08:50:50 WARN]: at org.scriptcraftjs.bukkit.ScriptCraftPlugin.onCommand(ScriptCraftPlugin.java:76)
[08:50:50 WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
[08:50:50 WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140)
[08:50:50 WARN]: at org.bukkit.craftbukkit.v1_10_R1.CraftServer.dispatchCommand(CraftServer.java:626)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.PlayerConnection.handleCommand(PlayerConnection.java:1299)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:1159)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(SourceFile:37)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(SourceFile:9)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13)
[08:50:50 WARN]: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[08:50:50 WARN]: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:688)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:361)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:643)
[08:50:50 WARN]: at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:547)
[08:50:50 WARN]: at java.lang.Thread.run(Thread.java:748)
[08:50:50 WARN]: Caused by: :638:8 javax.script.ScriptException: ReferenceError: "file" is not defined in at line number 1
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ECMAException.create(ECMAException.java:113)
[08:50:50 WARN]: at jdk.nashorn.internal.scripts.Script$Recompilation$2495$^eval_.__onEnable#__onCommand(:638)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:628)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:386)
[08:50:50 WARN]: ... 18 more
[08:50:50 WARN]: Caused by: javax.script.ScriptException: ReferenceError: "file" is not defined in at line number 1[08:57:12 INFO]: [scriptcraft] Disabling scriptcraft v3.2.1-2016-12-23
[08:57:12 INFO]: [scriptcraft] Enabling scriptcraft v3.2.1-2016-12-23
[08:57:12 WARN]: Enabled plugin with unregistered PluginClassLoader scriptcraft v3.2.1-2016-12-23
[08:57:12 WARN]: [scriptcraft] cow-clicker minigame is not yet supported in CanaryMod and Craftbukkit
[08:57:12 INFO]: [scriptcraft] js-patch setTimeout() test complete[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
[08:50:50 WARN]: at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
[08:50:50 WARN]: at jdk.nashorn.internal.scripts.Script$Recompilation$2495$^eval_.__onEnable#__onCommand(:613)
[08:50:50 WARN]: ... 23 more
[08:50:50 WARN]: Caused by: :1 ReferenceError: "file" is not defined
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
[08:50:50 WARN]: at jdk.nashorn.internal.objects.Global.noSuchProperty(Global.java:1441)
[08:50:50 WARN]: at jdk.nashorn.internal.scripts.Script$2511$^eval_.:program(:1)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
[08:50:50 WARN]: at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
[08:50:50 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
[08:50:50 WARN]: ... 28 more
No errors when refreshing:
[08:57:12 INFO]: [scriptcraft] Disabling scriptcraft v3.2.1-2016-12-23
[08:57:12 INFO]: [scriptcraft] Enabling scriptcraft v3.2.1-2016-12-23
[08:57:12 WARN]: Enabled plugin with unregistered PluginClassLoader scriptcraft v3.2.1-2016-12-23
[08:57:12 WARN]: [scriptcraft] cow-clicker minigame is not yet supported in CanaryMod and Craftbukkit
[08:57:12 INFO]: [scriptcraft] js-patch setTimeout() test complete
So this is really blowing my brain off, I just don't understand why, the plugin is not reading my own files, I'm using craftbukkit v1.10.2, I can see that is reading the line of code like if I want to evaluate something like /js myFile.js
= /js eval(myFile.js)
but with the default or example files works just fine
/js arrows.explode(self)
.
I tried with the lastest version of minecraft and craftbukkit (1.12.2) but still not working
Never mind, I just had to write some code and then it worked just fine, if anyone is having this trouble, is just a matter of code, if you want to use a function in your .js file you will need to write this exports.Function_Name = function(params){ //Some code }
(exports
is very important in order to the function be loaded in-game) and then just call it in-game
/js Function_Name(params)
, as simple as that... you guys can close this thread.
pd: I apologize if my grammar is bad, I tried my best.