…
// run through a privileged action so we don't access stuff we
// shouldn't
Subject subject = player.getSubject();
Subject.doAsPrivileged(subject, new PrivilegedAction<Object>() {
public Object run() {
boolean error = false;
try {
Class<?> clz = getGroovyScriptEngine().loadScriptByName(argHolder.command); // loads the command using the engine
MudPermission permission = new MudPermission(clz.getName());
AccessController.checkPermission(permission);
return doCommand(argHolder.command, argHolder.args, player);
} catch (ResourceException e) {
logger.error(e, e);
error = true;
} catch (ScriptException e) {
logger.error(e, e);
error = true;
} finally {
if (error) {
try {
player.getTerminalOutput().writeln("You cannot do that.");
} catch (IOException e) {
logger.error(e, e);
}
}
}
return null;
}
}, null);
}
…
Thanks elanthis. I was already 90% sold on Lua (as opposed to Ruby), but that just made it 100%. I've actually been reading the Lua tutorials, syntax guide and info on the C API - it all seems pretty straightforward. Wish me luck! And wish luck to my minions that I force this upon… :devil: