walterhiggins / ScriptCraft

Write Minecraft Plugins in JavaScript.
MIT License
1.84k stars 380 forks source link

Update to spigot-1.17.jar: No JavaScript Engine available (mac) #457

Open nickmalleson opened 3 years ago

nickmalleson commented 3 years ago

I have recently upgdated to Spigot 1.17. Now if I try to run any javascript commands from within the game nothing happens, and I get this message from the server (the following is produced if I try to do 1+1, but the same happens for any ScriptCraft functions):

[14:51:17] [Server thread/INFO]: nsm99999 issued server command: /js 1+1 
[14:51:17] [Server thread/ERROR]: [scriptcraft] No JavaScript Engine available. ScriptCraft will not work without Javascript.

I also had to update my version of java (on MacOS Big Sur) for the Spigot update, so that may be causing the problem. My version is:

$ java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment Homebrew (build 16.0.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 16.0.1+0, mixed mode, sharing)

Any ideas? I realise that this may not be a ScriptCraft problem, but I guess others on macs might experience it with the new Java update.

Thanks in advance! (And thanks for ScriptCraft, it's fantastic, my kids have just discovered the castle() method and are desperate to try it out)

LexiHDev commented 3 years ago

Nashorn Engine is what ScriptCraft uses.

https://github.com/walterhiggins/ScriptCraft/blob/6f5771d4c842ea86143ae5d5c9e022292bcd0de6/src/docs/java/jscript.java#L10

As of Java 15, the Nashorn Engine was removed due to maintanence costs. Minecraft 1.17 depends on versions of Java 16 and newer.

https://openjdk.java.net/jeps/372

A possible solution is to use a standalone version of Nashhorn available at https://github.com/szegedi/nashorn

nickmalleson commented 3 years ago

Thanks @AdrianHDev . Any pointers about how to make ScriptCraft aware of the standalone version of Nashorn? I have tried putting the Nashorn jar in the same directory as the spigot server, and starting with something like:

java -jar spigot.jar -cp nashorn-core-15.2.jar

but I get the same error about no JavaScript engine being available.

LexiHDev commented 3 years ago

Hey! Sorry, that would be something @walterhiggins would have to implement.

davidyang commented 3 years ago

Hey ScriptCrafters - I was able to get a working version with Java 16 using the Standalone Nashorn. It's really messy (I don't do any Java development and so don't understand the toolchain).

The branch is here: https://github.com/davidyang/Scriptcraft

It still works with ant (I added Ivy and changed the .classpath since I was using Eclipse to get autocomplete).

Would love to merge this into main and have a working Scriptcraft - this really is the best plugin for building in Minecraft that I've found.

Flying--Dutchman commented 2 years ago

@davidyang Your version thows me the following error:

Could not initialize class org.openjdk.nashorn.internal.runtime.Context$AnonymousContextCodeInstaller

Is there anything about the build/deploy process that I'm missing?

polish-penguin-dev commented 1 year ago

https://github.com/walterhiggins/ScriptCraft/issues/452 Someone has released a patched version for GraalVM (https://github.com/ediloren/ScriptCraft) Hopefully the re-compiled JAR will work for you