ScriptCraft
ScriptCraft lets you create your own mods using Javascript. ScriptCraft uses the CommonJS module system (the same module loading system used by Node.js) so managing your code will be easier. You can also run Javascript code on the in-game command prompt or extend the game by writing plugins that use the Bukkit API in javascript.
Examples:
At the command prompt type:
/js 1 + 1
> 2
... Any javascript code can be evaluated at the in-game command prompt.
/js alert( 'Hello ' + self.name )
> Hello walterh
... Special bukkit variables are available via javascript , for example the server
object is the instance of org.bukkit.Server . Writing event handlers in ScriptCraft is relatively easy...
events.blockBreak( function( event ) {
echo(event.player, 'You broke a block!' );
});
events.playerJoin( function( event ) {
echo( event.player, 'Welcome to the server!' );
});
... Any bukkit event can be handled. The above code prints the name of any player who breaks a block in the game. ScriptCraft comes with some built-in functions to make building easier...
/js box( blocks.wool.black, 4, 9 , 1)
... creates a 2001 Monolith 4 blocks wide by 9 blocks high by 1 block long.
The full bukkit API can be used via javascript to write new mods. Yes - you can write bukkit plugins in javascript! See ScriptCraft on GitHub for more information. Full documentation is available on the github docs page.
A Youtube Video demonstrating Exploding Arrows in ScriptCraft A Youtube video demonstrating a mini-game (SnowBall Fight)
can i make client-side sounds with a script? if yes,can you/someone PLEASE tell me it?
<<reply 1212316="">>
Hi SwimmingFrog,
Could you grab the latest version of the plugin from http://walterhiggins.net/blog/files/scriptcraft/ and let me know if it's still a problem?
@walterhiggins
Yes: here are the errors. (And to further clarify, I had installed js.jar in my java home but I understand you have now bundled it with the plugin so I uninstalled it.)
2013-01-22 16:13:25 [INFO] [ScriptCraftPlugin] Enabling ScriptCraftPlugin v1.4.7-20130121
2013-01-22 16:13:25 [SEVERE] javax.script.ScriptException sun.org.mozilla.javascript.internal.WrappedException Wrapped javax.script.ScriptException sun.org.mozilla.javascript.internal.EcmaError ReferenceError: "Drone" is not defined. (<Unknown source>#4) in <Unknown source> at line number 4 (<Unknown source>#59) in <Unknown source> at line number 59
2013-01-22 16:13:25 [SEVERE] at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
2013-01-22 16:13:25 [SEVERE] at javax.script.AbstractScriptEngine.eval(Unknown Source)
2013-01-22 16:13:25 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftPlugin.onEnable(Unknown Source)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.loadPlugin(CraftServer.java:282)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.enablePlugins(CraftServer.java:264)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.reload(CraftServer.java:593)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.Bukkit.reload(Bukkit.java:184)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchCommand(CraftServer.java:514)
2013-01-22 16:13:25 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchServerCommand(CraftServer.java:506)
2013-01-22 16:13:25 [SEVERE] at net.minecraft.server.v1_4_R1.DedicatedServer.al(DedicatedServer.java:260)
2013-01-22 16:13:25 [SEVERE] at net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:225)
2013-01-22 16:13:26 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494)
2013-01-22 16:13:26 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427)
2013-01-22 16:13:26 [SEVERE] at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)
<<reply 1211515="">>
Hi,
Can you tell me if there are any errors in the server console when you type reload?
Walter
To add a few more details:
*installed version of java:
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)
* when I type
java org.mozilla.javascript.tools.shell.Main
in the shell, I get the expected "js>" prompt
* when I do
/js 1+1
in the minecraft console, I get the expected "2.0" result
/js print('Hello")
returns "11:04:51 [INFO] hello"
but when I do:
/js echo("hello world")
I get the following error:
0:56:06 [INFO] sun.org.mozilla.javascript.internal.EcmaError ReferenceError: "echo" is not defined. (<Unknown source>#1) in <Unknown source> at line number 1
10:56:06 [SEVERE] javax.script.ScriptException sun.org.mozilla.javascript.internal.EcmaError ReferenceError: "echo" is not defined. (<Unknown source>#1) in <Unknown source> at line number 1
10:56:06 [SEVERE] at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
10:56:06 [SEVERE] at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
10:56:06 [SEVERE] at javax.script.AbstractScriptEngine.eval(Unknown Source)
10:56:06 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftPlugin.onCommand(Unknown Source)
10:56:06 [SEVERE] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
10:56:06 [SEVERE] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
10:56:06 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchCommand(CraftServer.java:514)
10:56:06 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchServerCommand(CraftServer.java:506)
10:56:06 [SEVERE] at net.minecraft.server.v1_4_R1.DedicatedServer.al(DedicatedServer.java:260)
10:56:06 [SEVERE] at net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:225)
10:56:06 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494)
10:56:06 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427)
10:56:06 [SEVERE] at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)
@swimmingfrog
Hi, I'll follow up on this later. Thanks.
Thank you so much for making this available. I have been looking for such a tool to get my son and his friends into programming and this is definitely it! I am having trouble getting it to run though (see following error messages). Do I need to install anything other than the standard java command? Also, does it absolutely require java to be installed in the usual location? My installation is somewhere else but I have updated my $PATH envar.
I am running ubuntu 11.1 and craftbukkit 1.4.7-R0.1
2013-01-21 15:54:36 [INFO] [ScriptCraftPlugin] Enabling ScriptCraftPlugin v1.4.7-20130121 2013-01-21 15:54:36 [INFO] [ScriptCraftPlugin] Unzipping drone/blocktype.js 2013-01-21 15:54:36 [SEVERE] javax.script.ScriptException: sun.org.mozilla.javascript.internal.WrappedException: Wrapped javax.script.ScriptException: sun.org.mozil la.javascript.internal.EcmaError: ReferenceError: "Drone" is not defined. (<Unknown source>#4) in <Unknown source> at line number 4 (<Unknown source>#59) in <Unknow n source> at line number 59 2013-01-21 15:54:36 [SEVERE] at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source) 2013-01-21 15:54:36 [SEVERE] at javax.script.AbstractScriptEngine.eval(Unknown Source) 2013-01-21 15:54:36 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftPlugin.onEnable(Unknown Source) 2013-01-21 15:54:36 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217) 2013-01-21 15:54:36 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457) 2013-01-21 15:54:36 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381) 2013-01-21 15:54:36 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.loadPlugin(CraftServer.java:282) 2013-01-21 15:54:36 [SEVERE] at org.bukkit.craftbukkit.v1_4_R1.CraftServer.enablePlugins(CraftServer.java:264) 2013-01-21 15:54:36 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.j(MinecraftServer.java:321) 2013-01-21 15:54:36 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.e(MinecraftServer.java:300) 2013-01-21 15:54:36 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.a(MinecraftServer.java:259) 2013-01-21 15:54:36 [SEVERE] at net.minecraft.server.v1_4_R1.DedicatedServer.init(DedicatedServer.java:149) 2013-01-21 15:54:36 [SEVERE] at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:399) 2013-01-21 15:54:37 [SEVERE] at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)
<<reply 1194450="">>
.. And to follow up on my previous comment - put the javascript code in a .js file in the craftbukkit/js-plugins folder and it will be executed automatically at startup.
<<reply 1194450="">>
In theory yes. I'm not familiar with AuthMe but I gather it's a plugin to help prevent players using a cracked version of minecraft (who have not logged in to minecraft.net) from accessing your bukkit server. I'm not entirely sure but I guess you'd want to listen to the PlayerLoginEvent like this...
Can i make using this Auth plugin like Authme?