apply frank's changes to templates/ypgpm.md

This commit is contained in:
walterhiggins 2014-12-22 15:23:06 +00:00
parent 691d5eb1c3
commit ed863e460c
8 changed files with 18 additions and 30 deletions

View file

@ -4913,7 +4913,7 @@ This differs from example 2 in that the function will only print a
message for operators. message for operators.
command('op-hello', function (parameters, player) { command('op-hello', function (parameters, player) {
if (!player.op){ if ( !isOp(player) ){
echo( player, 'Only operators can do this.'); echo( player, 'Only operators can do this.');
return; return;
} }
@ -5060,17 +5060,11 @@ In the example below, if a player joins the server and is an operator,
then the ScriptCraft plugin information will be displayed to that then the ScriptCraft plugin information will be displayed to that
player. player.
What's also notable about this example is how it uses the [Bukkit What's also notable about this example is how it uses the `isOp()` function. The code...
API][bkapi]. The code...
if (event.player.op) if ( isOp(event.player) )
... is a succinct way of accessing object properties which in Java ScriptCraft uses a special version of JavaScript which comes
would have to be written as ...
if (event.getPlayer().isOp())
... ScriptCraft uses a special version of JavaScript which comes
bundled with Java (Minecraft is written in Java) and JavaScript in bundled with Java (Minecraft is written in Java) and JavaScript in
Java can access properties of Java objects more succinctly than in Java can access properties of Java objects more succinctly than in
Java itself. What this means in practice is that when you're perusing Java itself. What this means in practice is that when you're perusing
@ -5101,7 +5095,7 @@ cleaner and more readable. Similarly where you see a method like
[bkapi]: http://jd.bukkit.org/dev/apidocs/ [bkapi]: http://jd.bukkit.org/dev/apidocs/
events.on( 'player.PlayerJoinEvent', function( event ) { events.on( 'player.PlayerJoinEvent', function( event ) {
if ( event.player.op ) { if ( isOp(event.player) ) {
echo( event.player, 'Welcome to ' + __plugin); echo( event.player, 'Welcome to ' + __plugin);
} }
}); });

View file

@ -777,7 +777,7 @@ exports.hiAll = function () {
} }
``` ```
... save the file, at the in-game command prompt type `js refresh()` and ... save the file, at the in-game command prompt type `/js refresh()` and
then type `/js hiAll()`. This will send the message `Hi!` to all of then type `/js hiAll()`. This will send the message `Hi!` to all of
the players connected to your server. You've done this using a `for` the players connected to your server. You've done this using a `for`
loop and arrays. Arrays and `for` loops are used heavily in all types loop and arrays. Arrays and `for` loops are used heavily in all types

View file

@ -741,7 +741,7 @@ exports.hiAll = function () {
} }
``` ```
... save the file, at the in-game command prompt type `js refresh()` and ... save the file, at the in-game command prompt type `/js refresh()` and
then type `/js hiAll()`. This will send the message `Hi!` to all of then type `/js hiAll()`. This will send the message `Hi!` to all of
the players connected to your server. You've done this using a `for` the players connected to your server. You've done this using a `for`
loop and arrays. Arrays and `for` loops are used heavily in all types loop and arrays. Arrays and `for` loops are used heavily in all types
@ -913,7 +913,7 @@ floor. When the loop is done I return the drone to where it started.
The last 2 lines load the drone module (it must be loaded before I can The last 2 lines load the drone module (it must be loaded before I can
add new features to it) and the last line extends the 'Drone' object add new features to it) and the last line extends the 'Drone' object
so that now it can build skyscrapers among other things. Once you've so that now it can build skyscrapers among other things. Once you've
typed in the above code and saved the file, type `reload` in your typed in the above code and saved the file, type `/js refresh()` in your
in-game prompt, then type ... in-game prompt, then type ...
/js myskyscraper(2); /js myskyscraper(2);
@ -987,7 +987,7 @@ exports.flightStatus = function( player ) {
} }
``` ```
... now type `/reload` at the in-game prompt then type `/js ... now type `/js refresh()` at the in-game prompt then type `/js
flightStatus(self)` and an appropriate message will appear based on flightStatus(self)` and an appropriate message will appear based on
whether or not you're currently flying. Type the `/js flightStatus()` whether or not you're currently flying. Type the `/js flightStatus()`
command while on the ground and while flying. The message displayed in command while on the ground and while flying. The message displayed in

View file

@ -104,7 +104,7 @@ var _remove = function( params, player ) {
else{ else{
echo( player, 'Alias ' + params[0] + ' does not exist.' ); echo( player, 'Alias ' + params[0] + ' does not exist.' );
} }
if ( player.op ) { if ( isOp(player) ) {
if ( _store.global[params[0]] ) { if ( _store.global[params[0]] ) {
delete _store.global[params[0]]; delete _store.global[params[0]];
} }
@ -112,7 +112,7 @@ var _remove = function( params, player ) {
}; };
var _global = function( params, player ) { var _global = function( params, player ) {
if ( !player.op ) { if ( !isOp(player) ) {
echo( player, 'Only operators can set global aliases. ' + echo( player, 'Only operators can set global aliases. ' +
'You need to be an operator to perform this command.' ); 'You need to be an operator to perform this command.' );
return; return;

View file

@ -148,7 +148,7 @@ var classroom = plugin('classroom', {
/* /*
only operators should be allowed run this function only operators should be allowed run this function
*/ */
if ( !sender.op ) { if ( !isOp(sender) ) {
console.log( 'Attempt to set classroom scripting without credentials: ' + sender.name ); console.log( 'Attempt to set classroom scripting without credentials: ' + sender.name );
echo( sender, 'Only operators can use this function'); echo( sender, 'Only operators can use this function');
return; return;

View file

@ -22,7 +22,7 @@ This differs from example 2 in that the function will only print a
message for operators. message for operators.
command('op-hello', function (parameters, player) { command('op-hello', function (parameters, player) {
if (!player.op){ if ( !isOp(player) ){
echo( player, 'Only operators can do this.'); echo( player, 'Only operators can do this.');
return; return;
} }
@ -34,7 +34,7 @@ command( 'op-hello', function( parameters, player ) {
/* /*
this is how you limit based on player privileges this is how you limit based on player privileges
*/ */
if ( !player.op ) { if ( !isOp(player) ) {
echo( player, 'Only operators can do this.' ); echo( player, 'Only operators can do this.' );
return; return;
} }

View file

@ -38,17 +38,11 @@ In the example below, if a player joins the server and is an operator,
then the ScriptCraft plugin information will be displayed to that then the ScriptCraft plugin information will be displayed to that
player. player.
What's also notable about this example is how it uses the [Bukkit What's also notable about this example is how it uses the `isOp()` function. The code...
API][bkapi]. The code...
if (event.player.op) if ( isOp(event.player) )
... is a succinct way of accessing object properties which in Java ScriptCraft uses a special version of JavaScript which comes
would have to be written as ...
if (event.getPlayer().isOp())
... ScriptCraft uses a special version of JavaScript which comes
bundled with Java (Minecraft is written in Java) and JavaScript in bundled with Java (Minecraft is written in Java) and JavaScript in
Java can access properties of Java objects more succinctly than in Java can access properties of Java objects more succinctly than in
Java itself. What this means in practice is that when you're perusing Java itself. What this means in practice is that when you're perusing
@ -79,7 +73,7 @@ cleaner and more readable. Similarly where you see a method like
[bkapi]: http://jd.bukkit.org/dev/apidocs/ [bkapi]: http://jd.bukkit.org/dev/apidocs/
events.on( 'player.PlayerJoinEvent', function( event ) { events.on( 'player.PlayerJoinEvent', function( event ) {
if ( event.player.op ) { if ( isOp(event.player) ) {
echo( event.player, 'Welcome to ' + __plugin); echo( event.player, 'Welcome to ' + __plugin);
} }
}); });