further syntax-highlighting and ignore netbeans folder.
This commit is contained in:
parent
f1925efd87
commit
39b459ab7f
6 changed files with 116 additions and 94 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,3 +13,5 @@ target
|
||||||
build.local.properties
|
build.local.properties
|
||||||
/src/main/javascript/lib/.#tabcomplete.js
|
/src/main/javascript/lib/.#tabcomplete.js
|
||||||
/src/main/javascript/plugins/.#example-1.js
|
/src/main/javascript/plugins/.#example-1.js
|
||||||
|
/nbproject/private/private.xml
|
||||||
|
/nbproject/project.xml
|
||||||
|
|
|
@ -693,29 +693,36 @@ function each time the event is fired.
|
||||||
|
|
||||||
The following code will print a message on screen every time a block is broken in the game
|
The following code will print a message on screen every time a block is broken in the game
|
||||||
|
|
||||||
events.on('block.BlockBreakEvent', function(listener, evt){
|
```javascript
|
||||||
|
events.on( 'block.BlockBreakEvent', function( listener, evt ) {
|
||||||
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
||||||
});
|
} );
|
||||||
|
```
|
||||||
|
|
||||||
To handle an event only once and unregister from further events...
|
To handle an event only once and unregister from further events...
|
||||||
|
|
||||||
events.on('block.BlockBreakEvent', function(listener, evt){
|
```javascript
|
||||||
|
events.on( 'block.BlockBreakEvent', function( listener, evt ) {
|
||||||
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
||||||
evt.handlers.unregister(listener);
|
evt.handlers.unregister( listener );
|
||||||
});
|
} );
|
||||||
|
|
||||||
To unregister a listener *outside* of the listener function...
|
To unregister a listener *outside* of the listener function...
|
||||||
|
|
||||||
var myBlockBreakListener = events.on('block.BlockBreakEvent',function(l,e){ ... });
|
```javascript
|
||||||
...
|
var myBlockBreakListener = events.on( 'block.BlockBreakEvent', function( l, e ) { ... } );
|
||||||
var handlers = org.bukkit.event.block.BlockBreakEvent.getHandlerList();
|
...
|
||||||
handlers.unregister(myBlockBreakListener);
|
var handlers = org.bukkit.event.block.BlockBreakEvent.getHandlerList();
|
||||||
|
handlers.unregister(myBlockBreakListener);
|
||||||
|
```
|
||||||
|
|
||||||
To listen for events using a full class name as the `eventName` parameter...
|
To listen for events using a full class name as the `eventName` parameter...
|
||||||
|
|
||||||
events.on(org.bukkit.event.block.BlockBreakEvent, function(listener, evt){
|
```javascript
|
||||||
|
events.on( org.bukkit.event.block.BlockBreakEvent, function( listener, evt ) {
|
||||||
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
||||||
});
|
} );
|
||||||
|
```
|
||||||
|
|
||||||
[buk2]: http://wiki.bukkit.org/Event_API_Reference
|
[buk2]: http://wiki.bukkit.org/Event_API_Reference
|
||||||
[buk]: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/event/Event.html
|
[buk]: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/event/Event.html
|
||||||
|
@ -950,29 +957,30 @@ an interactive sign.
|
||||||
|
|
||||||
##### plugins/signs/time-of-day.js
|
##### plugins/signs/time-of-day.js
|
||||||
|
|
||||||
var utils = require('utils'),
|
```javascript
|
||||||
|
var utils = require('utils'),
|
||||||
signs = require('signs');
|
signs = require('signs');
|
||||||
|
|
||||||
var onTimeChoice = function(event){
|
var onTimeChoice = function(event){
|
||||||
var selectedIndex = event.number;
|
var selectedIndex = event.number;
|
||||||
// convert to Minecraft time 0 = Dawn, 6000 = midday, 12000 = dusk, 18000 = midnight
|
// convert to Minecraft time 0 = Dawn, 6000 = midday, 12000 = dusk, 18000 = midnight
|
||||||
var time = selectedIndex * 6000;
|
var time = selectedIndex * 6000;
|
||||||
event.player.location.world.setTime(time);
|
event.player.location.world.setTime(time);
|
||||||
};
|
};
|
||||||
|
|
||||||
// signs.menu returns a function which can be called for one or more signs in the game.
|
// signs.menu returns a function which can be called for one or more signs in the game.
|
||||||
var convertToTimeMenu = signs.menu('Time of Day',
|
var convertToTimeMenu = signs.menu('Time of Day',
|
||||||
['Dawn', 'Midday', 'Dusk', 'Midnight'],
|
['Dawn', 'Midday', 'Dusk', 'Midnight'],
|
||||||
onTimeChoice);
|
onTimeChoice);
|
||||||
|
|
||||||
exports.time_sign = function( player ){
|
exports.time_sign = function( player ){
|
||||||
|
|
||||||
var sign = signs.getTargetedBy(player);
|
var sign = signs.getTargetedBy(player);
|
||||||
if (!sign){
|
if ( !sign ) {
|
||||||
throw new Error('You must look at a sign');
|
throw new Error('You must look at a sign');
|
||||||
}
|
}
|
||||||
convertToTimeMenu(sign);
|
convertToTimeMenu(sign);
|
||||||
};
|
};
|
||||||
|
```
|
||||||
|
|
||||||
To use the above function at the in-game prompt, look at an existing
|
To use the above function at the in-game prompt, look at an existing
|
||||||
sign and type...
|
sign and type...
|
||||||
|
@ -990,13 +998,15 @@ the entity has targeted. It is a utility function for use by plugin authors.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
var signs = require('signs'),
|
```javascript
|
||||||
|
var signs = require('signs'),
|
||||||
utils = require('utils');
|
utils = require('utils');
|
||||||
var player = utils.player('tom1234');
|
var player = utils.player('tom1234');
|
||||||
var sign = signs.getTargetedBy( player );
|
var sign = signs.getTargetedBy( player );
|
||||||
if (!sign){
|
if ( !sign ) {
|
||||||
player.sendMessage('Not looking at a sign');
|
player.sendMessage('Not looking at a sign');
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
[buksign]: http://jd.bukkit.org/dev/apidocs/org/bukkit/block/Sign.html
|
[buksign]: http://jd.bukkit.org/dev/apidocs/org/bukkit/block/Sign.html
|
||||||
|
|
||||||
|
|
|
@ -765,7 +765,7 @@ loop. The following `while` loop counts to 100...
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var i = 1;
|
var i = 1;
|
||||||
while (i <= 100){
|
while ( i <= 100 ) {
|
||||||
console.log( i );
|
console.log( i );
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
|
@ -892,12 +892,12 @@ type the following...
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var myskyscraper = function(floors) {
|
var myskyscraper = function(floors) {
|
||||||
if (typeof floors == 'undefined'){
|
var i ;
|
||||||
|
if ( typeof floors == 'undefined' ) {
|
||||||
floors = 10;
|
floors = 10;
|
||||||
}
|
}
|
||||||
this.chkpt('myskyscraper'); // saves the drone position so it can return there later
|
this.chkpt('myskyscraper'); // saves the drone position so it can return there later
|
||||||
for (var i = 0; i < floors; i++)
|
for ( i = 0; i < floors; i++ ) {
|
||||||
{
|
|
||||||
this.box(blocks.iron,20,1,20)
|
this.box(blocks.iron,20,1,20)
|
||||||
.up()
|
.up()
|
||||||
.box0(blocks.glass_pane,20,3,20)
|
.box0(blocks.glass_pane,20,3,20)
|
||||||
|
|
8
src/docs/templates/ypgpm.md
vendored
8
src/docs/templates/ypgpm.md
vendored
|
@ -730,7 +730,7 @@ loop. The following `while` loop counts to 100...
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var i = 1;
|
var i = 1;
|
||||||
while (i <= 100){
|
while ( i <= 100 ) {
|
||||||
console.log( i );
|
console.log( i );
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
|
@ -857,12 +857,12 @@ type the following...
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var myskyscraper = function(floors) {
|
var myskyscraper = function(floors) {
|
||||||
if (typeof floors == 'undefined'){
|
var i ;
|
||||||
|
if ( typeof floors == 'undefined' ) {
|
||||||
floors = 10;
|
floors = 10;
|
||||||
}
|
}
|
||||||
this.chkpt('myskyscraper'); // saves the drone position so it can return there later
|
this.chkpt('myskyscraper'); // saves the drone position so it can return there later
|
||||||
for (var i = 0; i < floors; i++)
|
for ( i = 0; i < floors; i++ ) {
|
||||||
{
|
|
||||||
this.box(blocks.iron,20,1,20)
|
this.box(blocks.iron,20,1,20)
|
||||||
.up()
|
.up()
|
||||||
.box0(blocks.glass_pane,20,3,20)
|
.box0(blocks.glass_pane,20,3,20)
|
||||||
|
|
|
@ -46,29 +46,36 @@ function each time the event is fired.
|
||||||
|
|
||||||
The following code will print a message on screen every time a block is broken in the game
|
The following code will print a message on screen every time a block is broken in the game
|
||||||
|
|
||||||
events.on('block.BlockBreakEvent', function(listener, evt){
|
```javascript
|
||||||
|
events.on( 'block.BlockBreakEvent', function( listener, evt ) {
|
||||||
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
||||||
});
|
} );
|
||||||
|
```
|
||||||
|
|
||||||
To handle an event only once and unregister from further events...
|
To handle an event only once and unregister from further events...
|
||||||
|
|
||||||
events.on('block.BlockBreakEvent', function(listener, evt){
|
```javascript
|
||||||
|
events.on( 'block.BlockBreakEvent', function( listener, evt ) {
|
||||||
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
||||||
evt.handlers.unregister(listener);
|
evt.handlers.unregister( listener );
|
||||||
});
|
} );
|
||||||
|
|
||||||
To unregister a listener *outside* of the listener function...
|
To unregister a listener *outside* of the listener function...
|
||||||
|
|
||||||
var myBlockBreakListener = events.on('block.BlockBreakEvent',function(l,e){ ... });
|
```javascript
|
||||||
...
|
var myBlockBreakListener = events.on( 'block.BlockBreakEvent', function( l, e ) { ... } );
|
||||||
var handlers = org.bukkit.event.block.BlockBreakEvent.getHandlerList();
|
...
|
||||||
handlers.unregister(myBlockBreakListener);
|
var handlers = org.bukkit.event.block.BlockBreakEvent.getHandlerList();
|
||||||
|
handlers.unregister(myBlockBreakListener);
|
||||||
|
```
|
||||||
|
|
||||||
To listen for events using a full class name as the `eventName` parameter...
|
To listen for events using a full class name as the `eventName` parameter...
|
||||||
|
|
||||||
events.on(org.bukkit.event.block.BlockBreakEvent, function(listener, evt){
|
```javascript
|
||||||
|
events.on( org.bukkit.event.block.BlockBreakEvent, function( listener, evt ) {
|
||||||
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
evt.player.sendMessage( evt.player.name + ' broke a block!');
|
||||||
});
|
} );
|
||||||
|
```
|
||||||
|
|
||||||
[buk2]: http://wiki.bukkit.org/Event_API_Reference
|
[buk2]: http://wiki.bukkit.org/Event_API_Reference
|
||||||
[buk]: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/event/Event.html
|
[buk]: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/event/Event.html
|
||||||
|
|
|
@ -38,29 +38,30 @@ an interactive sign.
|
||||||
|
|
||||||
##### plugins/signs/time-of-day.js
|
##### plugins/signs/time-of-day.js
|
||||||
|
|
||||||
var utils = require('utils'),
|
```javascript
|
||||||
|
var utils = require('utils'),
|
||||||
signs = require('signs');
|
signs = require('signs');
|
||||||
|
|
||||||
var onTimeChoice = function(event){
|
var onTimeChoice = function(event){
|
||||||
var selectedIndex = event.number;
|
var selectedIndex = event.number;
|
||||||
// convert to Minecraft time 0 = Dawn, 6000 = midday, 12000 = dusk, 18000 = midnight
|
// convert to Minecraft time 0 = Dawn, 6000 = midday, 12000 = dusk, 18000 = midnight
|
||||||
var time = selectedIndex * 6000;
|
var time = selectedIndex * 6000;
|
||||||
event.player.location.world.setTime(time);
|
event.player.location.world.setTime(time);
|
||||||
};
|
};
|
||||||
|
|
||||||
// signs.menu returns a function which can be called for one or more signs in the game.
|
// signs.menu returns a function which can be called for one or more signs in the game.
|
||||||
var convertToTimeMenu = signs.menu('Time of Day',
|
var convertToTimeMenu = signs.menu('Time of Day',
|
||||||
['Dawn', 'Midday', 'Dusk', 'Midnight'],
|
['Dawn', 'Midday', 'Dusk', 'Midnight'],
|
||||||
onTimeChoice);
|
onTimeChoice);
|
||||||
|
|
||||||
exports.time_sign = function( player ){
|
exports.time_sign = function( player ){
|
||||||
|
|
||||||
var sign = signs.getTargetedBy(player);
|
var sign = signs.getTargetedBy(player);
|
||||||
if (!sign){
|
if ( !sign ) {
|
||||||
throw new Error('You must look at a sign');
|
throw new Error('You must look at a sign');
|
||||||
}
|
}
|
||||||
convertToTimeMenu(sign);
|
convertToTimeMenu(sign);
|
||||||
};
|
};
|
||||||
|
```
|
||||||
|
|
||||||
To use the above function at the in-game prompt, look at an existing
|
To use the above function at the in-game prompt, look at an existing
|
||||||
sign and type...
|
sign and type...
|
||||||
|
@ -78,13 +79,15 @@ the entity has targeted. It is a utility function for use by plugin authors.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
var signs = require('signs'),
|
```javascript
|
||||||
|
var signs = require('signs'),
|
||||||
utils = require('utils');
|
utils = require('utils');
|
||||||
var player = utils.player('tom1234');
|
var player = utils.player('tom1234');
|
||||||
var sign = signs.getTargetedBy( player );
|
var sign = signs.getTargetedBy( player );
|
||||||
if (!sign){
|
if ( !sign ) {
|
||||||
player.sendMessage('Not looking at a sign');
|
player.sendMessage('Not looking at a sign');
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
[buksign]: http://jd.bukkit.org/dev/apidocs/org/bukkit/block/Sign.html
|
[buksign]: http://jd.bukkit.org/dev/apidocs/org/bukkit/block/Sign.html
|
||||||
|
|
||||||
|
|
Reference in a new issue