Last night I added the ability to configure custom console commands on the server. It's entirely up to a particular server configuration which commands are setup and who gets them. I thought some might be interested in this, though.
As a test, I've implemented a "respawn" command and a "tp" (teleport) command.
The server has had a scripting engine embedded in it for a while now and I use groovy to generate the server status page for the public server. This is the first chance I've gotten to expand it to handle client-sent console commands.
The way the server is setup right now is that anything in the ./scripts directory that matches *.init.groovy is executed when the server starts up. Facilities are provided for hooking into the various server events like playerConnected or playerDisconnected. Groovy makes it kind of nice to make sort of a customized language for dealing with things.
This latest update also adds the ability to attach console commands to a player when they login.
As an example, here is the one that gives just me the ability to respawn and teleport people:
on( [playerConnected] ) {
type, event ->
conn = event.getConnection();
p = conn.getAttribute( "player" );
if( !p.get("userInfo.userId").equals( "pspeed" ) )
return;
println( "Adding admin commands to " + p.get("userInfo.userId") );
addShellCommand( conn, "respawn", "Moves you back to the starting location.", null ) {
respawn( conn, console );
}
addShellCommand( conn, "tp", "Teleports a player.", null ) {
/// Snipped code that parses the parameters for clarity...
console.echo( "Warping " + from + " to:" + x + ", " + y + ", " + z );
warp( tpPlayer, x + 0.5, y + 0.5, z );
}
}
}
You can see the on( [event type] ) nice customization that makes it easy to run code on one or more different event types. The rest checks to see if it's me and then adds the commands. This could just as easily check to see if the player object has specific permissions, etc..
The point isn't that there is a teleport command here but how easy it is to add. (This is not a very user friendly teleport and I want to handle in-game teleporting in a different way... I added this because it helps me jump around to the parts of the world that need degriefing.)
Next will be to add a versioning module to the world and then the console backup/restore/etc. commands. Hopefully that won't take very long and I can get an intermediate release out soon... with the property system to follow in a release 5 or 6 days later. Then back to physics.
Note: this next version also includes scriptable client tools (you know, where you currently have block types and objects... there will be additional stuff) but that's another story.