Fixed events-helper to include all non-abstract handlers.
Added items.js module and fixed sounds.js (more work needed on items.js)
This commit is contained in:
parent
4d230bd514
commit
e3078804ab
9 changed files with 282 additions and 47 deletions
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
<target name="gen-events-helper" depends="compile-docs,server-setup,init">
|
<target name="gen-events-helper" depends="compile-docs,server-setup,init">
|
||||||
<mkdir dir="${dist}/js/lib"/>
|
<mkdir dir="${dist}/js/lib"/>
|
||||||
<java classname="jscript" failonerror="true" fork="true" output="${dist}/js/lib/events-helper.js">
|
<java classname="jscript" failonerror="true" fork="true" output="${dist}/js/lib/events-helper.js" error="${dist}/geneventserror.log">
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement path="${build}"/>
|
<pathelement path="${build}"/>
|
||||||
<pathelement path="${minecraft.dir}/craftbukkit.jar"/>
|
<pathelement path="${minecraft.dir}/craftbukkit.jar"/>
|
||||||
|
|
|
@ -59,6 +59,8 @@ Walter Higgins
|
||||||
* [events.horseJump()](#eventshorsejump)
|
* [events.horseJump()](#eventshorsejump)
|
||||||
* [events.entityCombust()](#eventsentitycombust)
|
* [events.entityCombust()](#eventsentitycombust)
|
||||||
* [events.entityRegainHealth()](#eventsentityregainhealth)
|
* [events.entityRegainHealth()](#eventsentityregainhealth)
|
||||||
|
* [events.entityCombustByBlock()](#eventsentitycombustbyblock)
|
||||||
|
* [events.entityCombustByEntity()](#eventsentitycombustbyentity)
|
||||||
* [events.playerLeashEntity()](#eventsplayerleashentity)
|
* [events.playerLeashEntity()](#eventsplayerleashentity)
|
||||||
* [events.pigZap()](#eventspigzap)
|
* [events.pigZap()](#eventspigzap)
|
||||||
* [events.itemDespawn()](#eventsitemdespawn)
|
* [events.itemDespawn()](#eventsitemdespawn)
|
||||||
|
@ -76,6 +78,7 @@ Walter Higgins
|
||||||
* [events.creatureSpawn()](#eventscreaturespawn)
|
* [events.creatureSpawn()](#eventscreaturespawn)
|
||||||
* [events.foodLevelChange()](#eventsfoodlevelchange)
|
* [events.foodLevelChange()](#eventsfoodlevelchange)
|
||||||
* [events.entityInteract()](#eventsentityinteract)
|
* [events.entityInteract()](#eventsentityinteract)
|
||||||
|
* [events.entityBreakDoor()](#eventsentitybreakdoor)
|
||||||
* [events.entityCreatePortal()](#eventsentitycreateportal)
|
* [events.entityCreatePortal()](#eventsentitycreateportal)
|
||||||
* [events.sheepRegrowWool()](#eventssheepregrowwool)
|
* [events.sheepRegrowWool()](#eventssheepregrowwool)
|
||||||
* [events.explosionPrime()](#eventsexplosionprime)
|
* [events.explosionPrime()](#eventsexplosionprime)
|
||||||
|
@ -92,27 +95,35 @@ Walter Higgins
|
||||||
* [events.blockGrow()](#eventsblockgrow)
|
* [events.blockGrow()](#eventsblockgrow)
|
||||||
* [events.blockPistonRetract()](#eventsblockpistonretract)
|
* [events.blockPistonRetract()](#eventsblockpistonretract)
|
||||||
* [events.blockDispense()](#eventsblockdispense)
|
* [events.blockDispense()](#eventsblockdispense)
|
||||||
|
* [events.blockBreak()](#eventsblockbreak)
|
||||||
* [events.paintingPlace()](#eventspaintingplace)
|
* [events.paintingPlace()](#eventspaintingplace)
|
||||||
* [events.lightningStrike()](#eventslightningstrike)
|
* [events.lightningStrike()](#eventslightningstrike)
|
||||||
* [events.vehicleEnter()](#eventsvehicleenter)
|
* [events.vehicleEnter()](#eventsvehicleenter)
|
||||||
* [events.vehicleMove()](#eventsvehiclemove)
|
* [events.vehicleMove()](#eventsvehiclemove)
|
||||||
* [events.vehicleCreate()](#eventsvehiclecreate)
|
* [events.vehicleCreate()](#eventsvehiclecreate)
|
||||||
* [events.asyncPlayerPreLogin()](#eventsasyncplayerprelogin)
|
* [events.asyncPlayerPreLogin()](#eventsasyncplayerprelogin)
|
||||||
|
* [events.playerUnleashEntity()](#eventsplayerunleashentity)
|
||||||
* [events.playerPreLogin()](#eventsplayerprelogin)
|
* [events.playerPreLogin()](#eventsplayerprelogin)
|
||||||
* [events.inventoryPickupItem()](#eventsinventorypickupitem)
|
* [events.inventoryPickupItem()](#eventsinventorypickupitem)
|
||||||
* [events.inventoryMoveItem()](#eventsinventorymoveitem)
|
* [events.inventoryMoveItem()](#eventsinventorymoveitem)
|
||||||
* [events.furnaceBurn()](#eventsfurnaceburn)
|
* [events.furnaceBurn()](#eventsfurnaceburn)
|
||||||
* [events.inventory()](#eventsinventory)
|
* [events.inventory()](#eventsinventory)
|
||||||
* [events.brew()](#eventsbrew)
|
* [events.brew()](#eventsbrew)
|
||||||
|
* [events.furnaceExtract()](#eventsfurnaceextract)
|
||||||
* [events.furnaceSmelt()](#eventsfurnacesmelt)
|
* [events.furnaceSmelt()](#eventsfurnacesmelt)
|
||||||
* [events.inventoryClose()](#eventsinventoryclose)
|
* [events.inventoryClose()](#eventsinventoryclose)
|
||||||
* [events.inventoryDrag()](#eventsinventorydrag)
|
* [events.inventoryDrag()](#eventsinventorydrag)
|
||||||
* [events.inventoryClick()](#eventsinventoryclick)
|
* [events.inventoryClick()](#eventsinventoryclick)
|
||||||
|
* [events.inventoryCreative()](#eventsinventorycreative)
|
||||||
* [events.hangingPlace()](#eventshangingplace)
|
* [events.hangingPlace()](#eventshangingplace)
|
||||||
* [events.hangingBreak()](#eventshangingbreak)
|
* [events.hangingBreak()](#eventshangingbreak)
|
||||||
* [events.worldSave()](#eventsworldsave)
|
* [events.worldSave()](#eventsworldsave)
|
||||||
* [events.structureGrow()](#eventsstructuregrow)
|
* [events.structureGrow()](#eventsstructuregrow)
|
||||||
* [events.entityDamage()](#eventsentitydamage)
|
* [events.entityDamage()](#eventsentitydamage)
|
||||||
|
* [events.entityTargetLivingEntity()](#eventsentitytargetlivingentity)
|
||||||
|
* [events.playerDeath()](#eventsplayerdeath)
|
||||||
|
* [events.entityDamageByBlock()](#eventsentitydamagebyblock)
|
||||||
|
* [events.entityDamageByEntity()](#eventsentitydamagebyentity)
|
||||||
* [events.entityPortal()](#eventsentityportal)
|
* [events.entityPortal()](#eventsentityportal)
|
||||||
* [events.entityPortalExit()](#eventsentityportalexit)
|
* [events.entityPortalExit()](#eventsentityportalexit)
|
||||||
* [events.signChange()](#eventssignchange)
|
* [events.signChange()](#eventssignchange)
|
||||||
|
@ -130,6 +141,7 @@ Walter Higgins
|
||||||
* [events.enchantItem()](#eventsenchantitem)
|
* [events.enchantItem()](#eventsenchantitem)
|
||||||
* [events.prepareItemEnchant()](#eventsprepareitemenchant)
|
* [events.prepareItemEnchant()](#eventsprepareitemenchant)
|
||||||
* [events.paintingBreak()](#eventspaintingbreak)
|
* [events.paintingBreak()](#eventspaintingbreak)
|
||||||
|
* [events.paintingBreakByEntity()](#eventspaintingbreakbyentity)
|
||||||
* [events.weatherChange()](#eventsweatherchange)
|
* [events.weatherChange()](#eventsweatherchange)
|
||||||
* [events.thunderChange()](#eventsthunderchange)
|
* [events.thunderChange()](#eventsthunderchange)
|
||||||
* [events.vehicleEntityCollision()](#eventsvehicleentitycollision)
|
* [events.vehicleEntityCollision()](#eventsvehicleentitycollision)
|
||||||
|
@ -156,7 +168,6 @@ Walter Higgins
|
||||||
* [events.playerChat()](#eventsplayerchat)
|
* [events.playerChat()](#eventsplayerchat)
|
||||||
* [events.playerAchievementAwarded()](#eventsplayerachievementawarded)
|
* [events.playerAchievementAwarded()](#eventsplayerachievementawarded)
|
||||||
* [events.playerBedLeave()](#eventsplayerbedleave)
|
* [events.playerBedLeave()](#eventsplayerbedleave)
|
||||||
* [events.playerChannel()](#eventsplayerchannel)
|
|
||||||
* [events.playerStatisticIncrement()](#eventsplayerstatisticincrement)
|
* [events.playerStatisticIncrement()](#eventsplayerstatisticincrement)
|
||||||
* [events.playerToggleSprint()](#eventsplayertogglesprint)
|
* [events.playerToggleSprint()](#eventsplayertogglesprint)
|
||||||
* [events.playerInteractEntity()](#eventsplayerinteractentity)
|
* [events.playerInteractEntity()](#eventsplayerinteractentity)
|
||||||
|
@ -169,6 +180,7 @@ Walter Higgins
|
||||||
* [events.playerToggleFlight()](#eventsplayertoggleflight)
|
* [events.playerToggleFlight()](#eventsplayertoggleflight)
|
||||||
* [events.playerAnimation()](#eventsplayeranimation)
|
* [events.playerAnimation()](#eventsplayeranimation)
|
||||||
* [events.asyncPlayerChat()](#eventsasyncplayerchat)
|
* [events.asyncPlayerChat()](#eventsasyncplayerchat)
|
||||||
|
* [events.playerRegisterChannel()](#eventsplayerregisterchannel)
|
||||||
* [events.playerMove()](#eventsplayermove)
|
* [events.playerMove()](#eventsplayermove)
|
||||||
* [events.playerTeleport()](#eventsplayerteleport)
|
* [events.playerTeleport()](#eventsplayerteleport)
|
||||||
* [events.playerBucketFill()](#eventsplayerbucketfill)
|
* [events.playerBucketFill()](#eventsplayerbucketfill)
|
||||||
|
@ -184,8 +196,13 @@ Walter Higgins
|
||||||
* [events.serviceUnregister()](#eventsserviceunregister)
|
* [events.serviceUnregister()](#eventsserviceunregister)
|
||||||
* [events.prepareItemCraft()](#eventsprepareitemcraft)
|
* [events.prepareItemCraft()](#eventsprepareitemcraft)
|
||||||
* [events.inventoryOpen()](#eventsinventoryopen)
|
* [events.inventoryOpen()](#eventsinventoryopen)
|
||||||
|
* [events.craftItem()](#eventscraftitem)
|
||||||
|
* [events.hangingBreakByEntity()](#eventshangingbreakbyentity)
|
||||||
|
* [events.blockMultiPlace()](#eventsblockmultiplace)
|
||||||
|
* [events.entityBlockForm()](#eventsentityblockform)
|
||||||
* [events.playerBucketEmpty()](#eventsplayerbucketempty)
|
* [events.playerBucketEmpty()](#eventsplayerbucketempty)
|
||||||
* [events.playerPortal()](#eventsplayerportal)
|
* [events.playerPortal()](#eventsplayerportal)
|
||||||
|
* [events.playerUnregisterChannel()](#eventsplayerunregisterchannel)
|
||||||
* [events.pluginDisable()](#eventsplugindisable)
|
* [events.pluginDisable()](#eventsplugindisable)
|
||||||
* [events.pluginEnable()](#eventspluginenable)
|
* [events.pluginEnable()](#eventspluginenable)
|
||||||
* [Blocks Module](#blocks-module)
|
* [Blocks Module](#blocks-module)
|
||||||
|
@ -1023,6 +1040,22 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.entityCombustByBlock()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the entity.EntityCombustByBlockEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.entityCombustByEntity()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the entity.EntityCombustByEntityEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.playerLeashEntity()
|
### events.playerLeashEntity()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1159,6 +1192,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.entityBreakDoor()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the entity.EntityBreakDoorEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.entityCreatePortal()
|
### events.entityCreatePortal()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1287,6 +1328,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.blockBreak()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the block.BlockBreakEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.paintingPlace()
|
### events.paintingPlace()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1335,6 +1384,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.playerUnleashEntity()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the player.PlayerUnleashEntityEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.playerPreLogin()
|
### events.playerPreLogin()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1383,6 +1440,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.furnaceExtract()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the inventory.FurnaceExtractEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.furnaceSmelt()
|
### events.furnaceSmelt()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1415,6 +1480,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.inventoryCreative()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the inventory.InventoryCreativeEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.hangingPlace()
|
### events.hangingPlace()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1455,6 +1528,38 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.entityTargetLivingEntity()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the entity.EntityTargetLivingEntityEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.playerDeath()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the entity.PlayerDeathEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.entityDamageByBlock()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the entity.EntityDamageByBlockEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.entityDamageByEntity()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the entity.EntityDamageByEntityEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.entityPortal()
|
### events.entityPortal()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1591,6 +1696,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.paintingBreakByEntity()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the painting.PaintingBreakByEntityEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.weatherChange()
|
### events.weatherChange()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1799,14 +1912,6 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.playerChannel()
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* callback - A function which is called whenever the player.PlayerChannelEvent event is fired
|
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
|
||||||
|
|
||||||
### events.playerStatisticIncrement()
|
### events.playerStatisticIncrement()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -1903,6 +2008,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.playerRegisterChannel()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the player.PlayerRegisterChannelEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.playerMove()
|
### events.playerMove()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -2023,6 +2136,38 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.craftItem()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the inventory.CraftItemEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.hangingBreakByEntity()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the hanging.HangingBreakByEntityEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.blockMultiPlace()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the block.BlockMultiPlaceEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.entityBlockForm()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the block.EntityBlockFormEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.playerBucketEmpty()
|
### events.playerBucketEmpty()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -2039,6 +2184,14 @@ beginning programmers to explore the events at the server console window.
|
||||||
|
|
||||||
* priority - optional - see events.on() for more information.
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
|
### events.playerUnregisterChannel()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
* callback - A function which is called whenever the player.PlayerUnregisterChannelEvent event is fired
|
||||||
|
|
||||||
|
* priority - optional - see events.on() for more information.
|
||||||
|
|
||||||
### events.pluginDisable()
|
### events.pluginDisable()
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
@ -2128,20 +2281,20 @@ This new `input()` function is best illustrated by example. The following code i
|
||||||
var input = require('input');
|
var input = require('input');
|
||||||
exports.numberguess = function(player){
|
exports.numberguess = function(player){
|
||||||
var randomNumber = Math.ceil(Math.random() * 10);
|
var randomNumber = Math.ceil(Math.random() * 10);
|
||||||
input( player, 'Think of a number between 1 and 10 (q to quit)', function( guess, repeat ) {
|
input( player, 'Think of a number between 1 and 10 (q to quit)', function( guess, guesser, repeat ) {
|
||||||
if ( guess == 'q'){
|
if ( guess == 'q'){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( +guess !== randomNumber ) {
|
if ( +guess !== randomNumber ) {
|
||||||
if (+guess < randomNumber ) {
|
if (+guess < randomNumber ) {
|
||||||
player.sendMessage('Too low - guess again');
|
guesser.sendMessage('Too low - guess again');
|
||||||
}
|
}
|
||||||
if (+guess > randomNumber ) {
|
if (+guess > randomNumber ) {
|
||||||
player.sendMessage('Too high - guess again');
|
guesser.sendMessage('Too high - guess again');
|
||||||
}
|
}
|
||||||
repeat();
|
repeat();
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage('You guessed correctly');
|
guesser.sendMessage('You guessed correctly');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2158,8 +2311,8 @@ The callback is bound to an object which has the following properties:
|
||||||
The callback function as well as being bound to an object with the above properties (so you can use this.value inside your callback to get the value which has just been input), can also take the following parameters (in exact order):
|
The callback function as well as being bound to an object with the above properties (so you can use this.value inside your callback to get the value which has just been input), can also take the following parameters (in exact order):
|
||||||
|
|
||||||
* value
|
* value
|
||||||
* repeat
|
|
||||||
* sender
|
* sender
|
||||||
|
* repeat
|
||||||
|
|
||||||
The `value` parameter will be the same as `this.value`, the `repeat` parameter will be the same as `this.repeat` and so on.
|
The `value` parameter will be the same as `this.value`, the `repeat` parameter will be the same as `this.repeat` and so on.
|
||||||
|
|
||||||
|
@ -2368,11 +2521,23 @@ a simpler way to play sounds. All of the org.bukkit.Sound Enum values are attach
|
||||||
### Usage:
|
### Usage:
|
||||||
|
|
||||||
var sounds = require('sounds');
|
var sounds = require('sounds');
|
||||||
sounds.play( self, sounds.VILLAGER_NO , 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch
|
sounds.play( org.bukkit.Sound.VILLAGER_NO , self, 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch
|
||||||
sounds.play( self, sounds.VILLAGER_NO ); // same as previous statement
|
sounds.play( org.bukkit.Sound.VILLAGER_NO , self ); // same as previous statement
|
||||||
|
|
||||||
The play() function takes either a Location object or any object which has a location.
|
The play() function takes either a Location object or any object which has a location.
|
||||||
The volume parameter is in the range 0 to 1 and the pitch parameter is in the range 0 to 4.
|
The volume parameter is in the range 0 to 1 and the pitch parameter is in the range 0 to 4.
|
||||||
|
|
||||||
|
In addition, a play function is provided for each possible sound using the following rules:
|
||||||
|
|
||||||
|
1. The sound is converted from ALL_CAPS_UNDERSCORE to camelCase so for example there is a sounds.villagerNo() function which will play the VILLAGER_NO sound.
|
||||||
|
2. Each such function can take 3 parameters: location (which can be either an actual Location object or an object which has a location), volume and pitch
|
||||||
|
3. Or... each such function can be called without parameters meaning the sound will be played for all online players to hear.
|
||||||
|
|
||||||
|
sounds.villagerNo(self, 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch at invoker's location
|
||||||
|
|
||||||
|
sounds.villagerNo(); // plays VILLAGER_NO sound for all players online.
|
||||||
|
|
||||||
|
These methods are provided for convenience to help beginners explore sounds using TAB completion.
|
||||||
String class extensions
|
String class extensions
|
||||||
-----------------------
|
-----------------------
|
||||||
The following chat-formatting methods are added to the javascript String class..
|
The following chat-formatting methods are added to the javascript String class..
|
||||||
|
|
|
@ -1014,7 +1014,7 @@ Open your favorite editor and type the following code into a new file
|
||||||
in your scriptcraft/plugins directory...
|
in your scriptcraft/plugins directory...
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function flightStatus( player ) {
|
exports.flightStatus = function( player ) {
|
||||||
if ( player.flying ) {
|
if ( player.flying ) {
|
||||||
player.sendMessage( 'Hey, You are flying!' );
|
player.sendMessage( 'Hey, You are flying!' );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
# 2014 05 12
|
||||||
|
|
||||||
|
Turn off modality for conversations which are started via the 'input' module.
|
||||||
|
(with modality on, player.sendMessage() is suppressed but player.sendRawMessage() isn't.
|
||||||
|
turning modality off as devs would expect player.sendMessage() to work - I did anyway)
|
||||||
|
|
||||||
|
|
||||||
# 2014 05 10
|
# 2014 05 10
|
||||||
|
|
||||||
Further simplification of events handling. The events.on() function can still be used but additional functions are now provided for each type of event.
|
Further simplification of events handling. The events.on() function can still be used but additional functions are now provided for each type of event.
|
||||||
|
|
2
src/docs/templates/ypgpm.md
vendored
2
src/docs/templates/ypgpm.md
vendored
|
@ -978,7 +978,7 @@ Open your favorite editor and type the following code into a new file
|
||||||
in your scriptcraft/plugins directory...
|
in your scriptcraft/plugins directory...
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function flightStatus( player ) {
|
exports.flightStatus = function( player ) {
|
||||||
if ( player.flying ) {
|
if ( player.flying ) {
|
||||||
player.sendMessage( 'Hey, You are flying!' );
|
player.sendMessage( 'Hey, You are flying!' );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,6 +2,8 @@ var File = java.io.File,
|
||||||
FileReader = java.io.FileReader,
|
FileReader = java.io.FileReader,
|
||||||
FileInputStream = java.io.FileInputStream,
|
FileInputStream = java.io.FileInputStream,
|
||||||
out = java.lang.System.out,
|
out = java.lang.System.out,
|
||||||
|
err = java.lang.System.err,
|
||||||
|
Modifier = java.lang.reflect.Modifier,
|
||||||
ZipInputStream = java.util.zip.ZipInputStream,
|
ZipInputStream = java.util.zip.ZipInputStream,
|
||||||
zis = new ZipInputStream(new FileInputStream('./target/minecraft/craftbukkit.jar')),
|
zis = new ZipInputStream(new FileInputStream('./target/minecraft/craftbukkit.jar')),
|
||||||
entry = null;
|
entry = null;
|
||||||
|
@ -39,17 +41,9 @@ while ( ( entry = zis.nextEntry) != null) {
|
||||||
var name = '' + entry.name;
|
var name = '' + entry.name;
|
||||||
if (name.match(/org\/bukkit\/event\/.+Event\.class$/)){
|
if (name.match(/org\/bukkit\/event\/.+Event\.class$/)){
|
||||||
name = name.replace(/\//g,'.').replace('.class','');
|
name = name.replace(/\//g,'.').replace('.class','');
|
||||||
|
var clz = java.lang.Class.forName(name);
|
||||||
// abstract events don't have a static getHandlerList method so
|
var isAbstract = Modifier.isAbstract(clz.getModifiers());
|
||||||
// shouldn't be added to this module
|
if ( isAbstract ) {
|
||||||
var hasHandlerList = false;
|
|
||||||
try {
|
|
||||||
hasHandlerList = engine.eval(name + '.getHandlerList');
|
|
||||||
} catch ( ex ) {
|
|
||||||
// exception is thrown for JRE7
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( !hasHandlerList ) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var parts = name.split('.');
|
var parts = name.split('.');
|
||||||
|
|
|
@ -20,20 +20,20 @@ This new `input()` function is best illustrated by example. The following code i
|
||||||
var input = require('input');
|
var input = require('input');
|
||||||
exports.numberguess = function(player){
|
exports.numberguess = function(player){
|
||||||
var randomNumber = Math.ceil(Math.random() * 10);
|
var randomNumber = Math.ceil(Math.random() * 10);
|
||||||
input( player, 'Think of a number between 1 and 10 (q to quit)', function( guess, repeat ) {
|
input( player, 'Think of a number between 1 and 10 (q to quit)', function( guess, guesser, repeat ) {
|
||||||
if ( guess == 'q'){
|
if ( guess == 'q'){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( +guess !== randomNumber ) {
|
if ( +guess !== randomNumber ) {
|
||||||
if (+guess < randomNumber ) {
|
if (+guess < randomNumber ) {
|
||||||
player.sendMessage('Too low - guess again');
|
guesser.sendMessage('Too low - guess again');
|
||||||
}
|
}
|
||||||
if (+guess > randomNumber ) {
|
if (+guess > randomNumber ) {
|
||||||
player.sendMessage('Too high - guess again');
|
guesser.sendMessage('Too high - guess again');
|
||||||
}
|
}
|
||||||
repeat();
|
repeat();
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage('You guessed correctly');
|
guesser.sendMessage('You guessed correctly');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -50,8 +50,8 @@ The callback is bound to an object which has the following properties:
|
||||||
The callback function as well as being bound to an object with the above properties (so you can use this.value inside your callback to get the value which has just been input), can also take the following parameters (in exact order):
|
The callback function as well as being bound to an object with the above properties (so you can use this.value inside your callback to get the value which has just been input), can also take the following parameters (in exact order):
|
||||||
|
|
||||||
* value
|
* value
|
||||||
* repeat
|
|
||||||
* sender
|
* sender
|
||||||
|
* repeat
|
||||||
|
|
||||||
The `value` parameter will be the same as `this.value`, the `repeat` parameter will be the same as `this.repeat` and so on.
|
The `value` parameter will be the same as `this.value`, the `repeat` parameter will be the same as `this.repeat` and so on.
|
||||||
|
|
||||||
|
@ -64,21 +64,22 @@ function asyncInput( sender, promptMesg, callback) {
|
||||||
var repeat = function(){
|
var repeat = function(){
|
||||||
asyncInput( sender, promptMesg, callback);
|
asyncInput( sender, promptMesg, callback);
|
||||||
};
|
};
|
||||||
var prompt = new bkPrompt( ) {
|
var prompt = new bkPrompt( {
|
||||||
getPromptText: function( ctx ) {
|
getPromptText: function( ctx ) {
|
||||||
return promptMesg;
|
return promptMesg;
|
||||||
},
|
},
|
||||||
acceptInput: function( ctx, value ) {
|
acceptInput: function( ctx, value ) {
|
||||||
callback.apply( { repeat: repeat, sender: sender, message: promptMesg, value: value },
|
callback.apply( { repeat: repeat, sender: sender, message: promptMesg, value: value },
|
||||||
[value, repeat, sender]);
|
[value, sender, repeat]);
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
blocksForInput: function( ctx ) {
|
blocksForInput: function( ctx ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
new bkConversationFactory( __plugin )
|
new bkConversationFactory( __plugin )
|
||||||
.withModality( true )
|
.withModality( false )
|
||||||
.withFirstPrompt( prompt )
|
.withFirstPrompt( prompt )
|
||||||
.buildConversation( sender )
|
.buildConversation( sender )
|
||||||
.begin( );
|
.begin( );
|
||||||
|
|
27
src/main/js/modules/items.js
Normal file
27
src/main/js/modules/items.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
var bkItemStack = org.bukkit.inventory.ItemStack,
|
||||||
|
bkMaterial = org.bukkit.Material
|
||||||
|
var items = function(material, amount){
|
||||||
|
material = material.toUpperCase();
|
||||||
|
return new bkItemStack(bkMaterial[material],amount);
|
||||||
|
};
|
||||||
|
module.exports = items;
|
||||||
|
|
||||||
|
var materials = bkMaterial.values();
|
||||||
|
|
||||||
|
for (var i = 0;i < materials.length; i++ ){
|
||||||
|
var name = (''+materials[i].name()).toLowerCase();
|
||||||
|
name = name.replace(/(_.)/g,function(a){ return a.replace(/_/,'').toUpperCase(); });
|
||||||
|
|
||||||
|
items[name] = (function(material){
|
||||||
|
return function(amount){
|
||||||
|
if (typeof amount == 'undefined'){
|
||||||
|
amount = 1;
|
||||||
|
}
|
||||||
|
if (typeof amount == 'number'){
|
||||||
|
return new bkItemStack(material, amount);
|
||||||
|
} else {
|
||||||
|
return amount == material;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(materials[i]);
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
var bkSound = org.bukkit.Sound,
|
var bkSound = org.bukkit.Sound,
|
||||||
bkLocation = org.bukkit.Location,
|
bkLocation = org.bukkit.Location,
|
||||||
i = 0,
|
i = 0,
|
||||||
|
foreach = require('utils').foreach,
|
||||||
allSounds = bkSound.values(),
|
allSounds = bkSound.values(),
|
||||||
len = allSounds.length,
|
len = allSounds.length,
|
||||||
sound,
|
sound,
|
||||||
|
@ -9,7 +10,33 @@ var bkSound = org.bukkit.Sound,
|
||||||
for ( ; i < len; i++ ) {
|
for ( ; i < len; i++ ) {
|
||||||
sound = allSounds[i];
|
sound = allSounds[i];
|
||||||
soundName = '' + sound.name();
|
soundName = '' + sound.name();
|
||||||
exports[soundName] = sound;
|
var methodName = soundName.toLowerCase().replace(/_(.)/g,function(a,b){ return b.toUpperCase();});
|
||||||
|
exports[methodName] = (function(sound){
|
||||||
|
return function()
|
||||||
|
{
|
||||||
|
switch (arguments.length) {
|
||||||
|
case 3:
|
||||||
|
exports.play(sound, arguments[0], arguments[1], arguments[2]);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
// TODO: possible combinations:
|
||||||
|
// location, volume,
|
||||||
|
// volume pitch
|
||||||
|
exports.play(sound, arguments[0],arguments[1]);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
exports.play(sound, arguments[0]);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
// play the sound at full vol, medium pitch for all players
|
||||||
|
//
|
||||||
|
foreach(server.onlinePlayers,function(player){
|
||||||
|
exports.play(sound, player, 1, 0);
|
||||||
|
});
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(sound);
|
||||||
}
|
}
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
## Sounds Module
|
## Sounds Module
|
||||||
|
@ -20,13 +47,25 @@ a simpler way to play sounds. All of the org.bukkit.Sound Enum values are attach
|
||||||
### Usage:
|
### Usage:
|
||||||
|
|
||||||
var sounds = require('sounds');
|
var sounds = require('sounds');
|
||||||
sounds.play( self, sounds.VILLAGER_NO , 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch
|
sounds.play( org.bukkit.Sound.VILLAGER_NO , self, 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch
|
||||||
sounds.play( self, sounds.VILLAGER_NO ); // same as previous statement
|
sounds.play( org.bukkit.Sound.VILLAGER_NO , self ); // same as previous statement
|
||||||
|
|
||||||
The play() function takes either a Location object or any object which has a location.
|
The play() function takes either a Location object or any object which has a location.
|
||||||
The volume parameter is in the range 0 to 1 and the pitch parameter is in the range 0 to 4.
|
The volume parameter is in the range 0 to 1 and the pitch parameter is in the range 0 to 4.
|
||||||
|
|
||||||
|
In addition, a play function is provided for each possible sound using the following rules:
|
||||||
|
|
||||||
|
1. The sound is converted from ALL_CAPS_UNDERSCORE to camelCase so for example there is a sounds.villagerNo() function which will play the VILLAGER_NO sound.
|
||||||
|
2. Each such function can take 3 parameters: location (which can be either an actual Location object or an object which has a location), volume and pitch
|
||||||
|
3. Or... each such function can be called without parameters meaning the sound will be played for all online players to hear.
|
||||||
|
|
||||||
|
sounds.villagerNo(self, 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch at invoker's location
|
||||||
|
|
||||||
|
sounds.villagerNo(); // plays VILLAGER_NO sound for all players online.
|
||||||
|
|
||||||
|
These methods are provided for convenience to help beginners explore sounds using TAB completion.
|
||||||
***/
|
***/
|
||||||
exports.play = function(locationOrHasLocation, sound, volume, pitch) {
|
exports.play = function(sound, locationOrHasLocation, volume, pitch) {
|
||||||
var location = null;
|
var location = null;
|
||||||
if (!locationOrHasLocation)
|
if (!locationOrHasLocation)
|
||||||
return;
|
return;
|
||||||
|
@ -38,11 +77,13 @@ exports.play = function(locationOrHasLocation, sound, volume, pitch) {
|
||||||
location = locationOrHasLocation;
|
location = locationOrHasLocation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!location)
|
if (!location){
|
||||||
|
console.warn('sounds.play() needs a location');
|
||||||
return;
|
return;
|
||||||
if (!volume)
|
}
|
||||||
|
if (typeof volume == 'undefined')
|
||||||
volume = 1;
|
volume = 1;
|
||||||
if (!pitch)
|
if (typeof pitch == 'undefined')
|
||||||
pitch = 0;
|
pitch = 1;
|
||||||
location.world.playSound(location, sound, volume, pitch);
|
location.world.playSound(location, sound, volume, pitch);
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue