diff --git a/docs/API-Reference.md b/docs/API-Reference.md index 6c67d28..34c6967 100644 --- a/docs/API-Reference.md +++ b/docs/API-Reference.md @@ -4913,7 +4913,7 @@ This differs from example 2 in that the function will only print a message for operators. command('op-hello', function (parameters, player) { - if (!player.op){ + if ( !isOp(player) ){ echo( player, 'Only operators can do this.'); 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 player. -What's also notable about this example is how it uses the [Bukkit -API][bkapi]. The code... +What's also notable about this example is how it uses the `isOp()` function. The code... - if (event.player.op) + if ( isOp(event.player) ) -... is a succinct way of accessing object properties which in Java -would have to be written as ... - - if (event.getPlayer().isOp()) - -... ScriptCraft uses a special version of JavaScript which comes +ScriptCraft uses a special version of JavaScript which comes bundled with Java (Minecraft is written in Java) and JavaScript 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 @@ -5101,7 +5095,7 @@ cleaner and more readable. Similarly where you see a method like [bkapi]: http://jd.bukkit.org/dev/apidocs/ events.on( 'player.PlayerJoinEvent', function( event ) { - if ( event.player.op ) { + if ( isOp(event.player) ) { echo( event.player, 'Welcome to ' + __plugin); } }); diff --git a/docs/YoungPersonsGuideToProgrammingMinecraft.md b/docs/YoungPersonsGuideToProgrammingMinecraft.md index d540c2b..78f7430 100644 --- a/docs/YoungPersonsGuideToProgrammingMinecraft.md +++ b/docs/YoungPersonsGuideToProgrammingMinecraft.md @@ -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 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 diff --git a/lib/CanaryMod-1.7.10-1.1.3-SNAPSHOT-shaded.jar b/lib/CanaryMod-1.7.10-1.1.3-SNAPSHOT-shaded.jar index dec2f27..7856a76 100644 Binary files a/lib/CanaryMod-1.7.10-1.1.3-SNAPSHOT-shaded.jar and b/lib/CanaryMod-1.7.10-1.1.3-SNAPSHOT-shaded.jar differ diff --git a/src/docs/templates/ypgpm.md b/src/docs/templates/ypgpm.md index e33c213..b21e06d 100644 --- a/src/docs/templates/ypgpm.md +++ b/src/docs/templates/ypgpm.md @@ -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 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 @@ -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 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 -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 ... /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 whether or not you're currently flying. Type the `/js flightStatus()` command while on the ground and while flying. The message displayed in diff --git a/src/main/js/plugins/alias/alias.js b/src/main/js/plugins/alias/alias.js index 8daada3..9b0998c 100644 --- a/src/main/js/plugins/alias/alias.js +++ b/src/main/js/plugins/alias/alias.js @@ -104,7 +104,7 @@ var _remove = function( params, player ) { else{ echo( player, 'Alias ' + params[0] + ' does not exist.' ); } - if ( player.op ) { + if ( isOp(player) ) { if ( _store.global[params[0]] ) { delete _store.global[params[0]]; } @@ -112,7 +112,7 @@ var _remove = function( params, player ) { }; var _global = function( params, player ) { - if ( !player.op ) { + if ( !isOp(player) ) { echo( player, 'Only operators can set global aliases. ' + 'You need to be an operator to perform this command.' ); return; diff --git a/src/main/js/plugins/classroom/classroom.js b/src/main/js/plugins/classroom/classroom.js index d4f3f0e..a4f529c 100644 --- a/src/main/js/plugins/classroom/classroom.js +++ b/src/main/js/plugins/classroom/classroom.js @@ -148,7 +148,7 @@ var classroom = plugin('classroom', { /* 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 ); echo( sender, 'Only operators can use this function'); return; diff --git a/src/main/js/plugins/examples/example-3-hello-ops-only.js b/src/main/js/plugins/examples/example-3-hello-ops-only.js index c310272..5c7893a 100644 --- a/src/main/js/plugins/examples/example-3-hello-ops-only.js +++ b/src/main/js/plugins/examples/example-3-hello-ops-only.js @@ -22,7 +22,7 @@ This differs from example 2 in that the function will only print a message for operators. command('op-hello', function (parameters, player) { - if (!player.op){ + if ( !isOp(player) ){ echo( player, 'Only operators can do this.'); return; } @@ -34,7 +34,7 @@ command( 'op-hello', function( parameters, player ) { /* this is how you limit based on player privileges */ - if ( !player.op ) { + if ( !isOp(player) ) { echo( player, 'Only operators can do this.' ); return; } diff --git a/src/main/js/plugins/examples/example-7-hello-events.js b/src/main/js/plugins/examples/example-7-hello-events.js index 3bf4100..f893cf3 100644 --- a/src/main/js/plugins/examples/example-7-hello-events.js +++ b/src/main/js/plugins/examples/example-7-hello-events.js @@ -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 player. -What's also notable about this example is how it uses the [Bukkit -API][bkapi]. The code... +What's also notable about this example is how it uses the `isOp()` function. The code... - if (event.player.op) + if ( isOp(event.player) ) -... is a succinct way of accessing object properties which in Java -would have to be written as ... - - if (event.getPlayer().isOp()) - -... ScriptCraft uses a special version of JavaScript which comes +ScriptCraft uses a special version of JavaScript which comes bundled with Java (Minecraft is written in Java) and JavaScript 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 @@ -79,7 +73,7 @@ cleaner and more readable. Similarly where you see a method like [bkapi]: http://jd.bukkit.org/dev/apidocs/ events.on( 'player.PlayerJoinEvent', function( event ) { - if ( event.player.op ) { + if ( isOp(event.player) ) { echo( event.player, 'Welcome to ' + __plugin); } });