From 8d2376c482a284ebca209b9991da1aaa9cc0ba80 Mon Sep 17 00:00:00 2001 From: Walter Higgins Date: Sun, 15 Oct 2017 12:14:17 +0100 Subject: [PATCH] Documented all of the sounds functions --- build.xml | 5 + docs/API-Reference.md | 811 ++++++++++++++++++++++++++- src/docs/js/generateApiDocs.js | 28 +- src/docs/js/generateEventsHelper.js | 3 +- src/docs/js/generateItemsDoc.js | 10 +- src/docs/js/generateSoundsDoc.js | 109 ++++ src/docs/js/generateTOC.js | 48 +- src/main/js/modules/bukkit/sounds.js | 4 +- src/main/js/modules/sounds.js | 27 - 9 files changed, 944 insertions(+), 101 deletions(-) create mode 100644 src/docs/js/generateSoundsDoc.js diff --git a/build.xml b/build.xml index 498e9cddb..b49ecbc0d 100644 --- a/build.xml +++ b/build.xml @@ -94,6 +94,10 @@ out="${dist}/items.md" err="${dist}/gen-items-error.log" /> + + @@ -101,6 +105,7 @@ + diff --git a/docs/API-Reference.md b/docs/API-Reference.md index fad5eb2b0..b62464a50 100644 --- a/docs/API-Reference.md +++ b/docs/API-Reference.md @@ -436,8 +436,6 @@ Walter Higgins * [signs.getTargetedBy() function](#signsgettargetedby-function) * [The slash Module](#the-slash-module) * [The slash() function](#the-slash-function) - * [Sounds Module](#sounds-module) - * [Usage (Bukkit) :](#usage-bukkit-) * [Spawn Module](#spawn-module) * [Parameters](#parameters) * [Example](#example-2) @@ -507,8 +505,12 @@ Walter Higgins * [Usage](#usage-13) * [Items module (CanaryMod version)](#items-module-canarymod-version) * [Usage](#usage-14) - * [Entities module](#entities-module) + * [Sounds module (SpigotMC version)](#sounds-module-spigotmc-version) * [Usage](#usage-15) + * [Sounds module (CanaryMod version)](#sounds-module-canarymod-version) + * [Usage](#usage-16) + * [Entities module](#entities-module) + * [Usage](#usage-17) ## Modules in Scriptcraft @@ -5279,31 +5281,6 @@ slash([ ], johnDoe); ``` -## Sounds Module - -This module is a simple wrapper around the Bukkit Sound class and provides -a simpler way to play sounds. All of the org.bukkit.Sound Enum values are attached. - -### Usage (Bukkit) : - - var sounds = require('sounds'); - sounds.play( bukkit.sound.VILLAGER_NO , self, 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch - sounds.play( 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 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. ## Spawn Module Provides a single function to 'spawn' an entity at a given location. @@ -7362,6 +7339,784 @@ The following functions are provided: * zombieHead() +## Sounds module (SpigotMC version) + +This module provides a simple way to play sounds. + +### Usage + + var sounds = require("sounds"); + // plays ENTITY_WOLF_HOWL sound at full volume and medium pitch + sounds.play( org.bukkit.Sound.ENTITY_WOLF_HOWL, self, 1, 0); + // same as previous statement + sounds.play( org.bukkit.Sound.ENTITY_WOLF_HOWL , self ); + +The play() function takes as parameters: + + * A Sound value (see https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html for a list of possible values) + * A Location orbject or any object which has a location + * The Volume parameter is in the range 0 to 1 (default: 1) + * The Pitch parameter is in the range 0 to 4 (default: 0) + +In addition, the Sounds module provides a suite of helper functions - one for each possible sound. + + var sounds = require("sounds"); + // same as previous examples + sounds.entityWolfHowl( self ); + +Each of the following functions takes as parameters: + + * A Location orbject or any object which has a location + * The Volume parameter is in the range 0 to 1 (default: 1) + * The Pitch parameter is in the range 0 to 4 (default: 0) + +The following functions are provided for convenience and to help beginners explore sounds using TAB completion: + + * ambientCave() + * blockAnvilBreak() + * blockAnvilDestroy() + * blockAnvilFall() + * blockAnvilHit() + * blockAnvilLand() + * blockAnvilPlace() + * blockAnvilStep() + * blockAnvilUse() + * blockBrewingStandBrew() + * blockChestClose() + * blockChestLocked() + * blockChestOpen() + * blockChorusFlowerDeath() + * blockChorusFlowerGrow() + * blockClothBreak() + * blockClothFall() + * blockClothHit() + * blockClothPlace() + * blockClothStep() + * blockComparatorClick() + * blockDispenserDispense() + * blockDispenserFail() + * blockDispenserLaunch() + * blockEnchantmentTableUse() + * blockEndGatewaySpawn() + * blockEndPortalFrameFill() + * blockEndPortalSpawn() + * blockEnderchestClose() + * blockEnderchestOpen() + * blockFenceGateClose() + * blockFenceGateOpen() + * blockFireAmbient() + * blockFireExtinguish() + * blockFurnaceFireCrackle() + * blockGlassBreak() + * blockGlassFall() + * blockGlassHit() + * blockGlassPlace() + * blockGlassStep() + * blockGrassBreak() + * blockGrassFall() + * blockGrassHit() + * blockGrassPlace() + * blockGrassStep() + * blockGravelBreak() + * blockGravelFall() + * blockGravelHit() + * blockGravelPlace() + * blockGravelStep() + * blockIronDoorClose() + * blockIronDoorOpen() + * blockIronTrapdoorClose() + * blockIronTrapdoorOpen() + * blockLadderBreak() + * blockLadderFall() + * blockLadderHit() + * blockLadderPlace() + * blockLadderStep() + * blockLavaAmbient() + * blockLavaExtinguish() + * blockLavaPop() + * blockLeverClick() + * blockMetalBreak() + * blockMetalFall() + * blockMetalHit() + * blockMetalPlace() + * blockMetalPressureplateClickOff() + * blockMetalPressureplateClickOn() + * blockMetalStep() + * blockNoteBasedrum() + * blockNoteBass() + * blockNoteBell() + * blockNoteChime() + * blockNoteFlute() + * blockNoteGuitar() + * blockNoteHarp() + * blockNoteHat() + * blockNotePling() + * blockNoteSnare() + * blockNoteXylophone() + * blockPistonContract() + * blockPistonExtend() + * blockPortalAmbient() + * blockPortalTravel() + * blockPortalTrigger() + * blockRedstoneTorchBurnout() + * blockSandBreak() + * blockSandFall() + * blockSandHit() + * blockSandPlace() + * blockSandStep() + * blockShulkerBoxClose() + * blockShulkerBoxOpen() + * blockSlimeBreak() + * blockSlimeFall() + * blockSlimeHit() + * blockSlimePlace() + * blockSlimeStep() + * blockSnowBreak() + * blockSnowFall() + * blockSnowHit() + * blockSnowPlace() + * blockSnowStep() + * blockStoneBreak() + * blockStoneButtonClickOff() + * blockStoneButtonClickOn() + * blockStoneFall() + * blockStoneHit() + * blockStonePlace() + * blockStonePressureplateClickOff() + * blockStonePressureplateClickOn() + * blockStoneStep() + * blockTripwireAttach() + * blockTripwireClickOff() + * blockTripwireClickOn() + * blockTripwireDetach() + * blockWaterAmbient() + * blockWaterlilyPlace() + * blockWoodBreak() + * blockWoodButtonClickOff() + * blockWoodButtonClickOn() + * blockWoodFall() + * blockWoodHit() + * blockWoodPlace() + * blockWoodPressureplateClickOff() + * blockWoodPressureplateClickOn() + * blockWoodStep() + * blockWoodenDoorClose() + * blockWoodenDoorOpen() + * blockWoodenTrapdoorClose() + * blockWoodenTrapdoorOpen() + * enchantThornsHit() + * entityArmorstandBreak() + * entityArmorstandFall() + * entityArmorstandHit() + * entityArmorstandPlace() + * entityArrowHit() + * entityArrowHitPlayer() + * entityArrowShoot() + * entityBatAmbient() + * entityBatDeath() + * entityBatHurt() + * entityBatLoop() + * entityBatTakeoff() + * entityBlazeAmbient() + * entityBlazeBurn() + * entityBlazeDeath() + * entityBlazeHurt() + * entityBlazeShoot() + * entityBoatPaddleLand() + * entityBoatPaddleWater() + * entityBobberRetrieve() + * entityBobberSplash() + * entityBobberThrow() + * entityCatAmbient() + * entityCatDeath() + * entityCatHiss() + * entityCatHurt() + * entityCatPurr() + * entityCatPurreow() + * entityChickenAmbient() + * entityChickenDeath() + * entityChickenEgg() + * entityChickenHurt() + * entityChickenStep() + * entityCowAmbient() + * entityCowDeath() + * entityCowHurt() + * entityCowMilk() + * entityCowStep() + * entityCreeperDeath() + * entityCreeperHurt() + * entityCreeperPrimed() + * entityDonkeyAmbient() + * entityDonkeyAngry() + * entityDonkeyChest() + * entityDonkeyDeath() + * entityDonkeyHurt() + * entityEggThrow() + * entityElderGuardianAmbient() + * entityElderGuardianAmbientLand() + * entityElderGuardianCurse() + * entityElderGuardianDeath() + * entityElderGuardianDeathLand() + * entityElderGuardianFlop() + * entityElderGuardianHurt() + * entityElderGuardianHurtLand() + * entityEnderdragonAmbient() + * entityEnderdragonDeath() + * entityEnderdragonFireballExplode() + * entityEnderdragonFlap() + * entityEnderdragonGrowl() + * entityEnderdragonHurt() + * entityEnderdragonShoot() + * entityEndereyeDeath() + * entityEndereyeLaunch() + * entityEndermenAmbient() + * entityEndermenDeath() + * entityEndermenHurt() + * entityEndermenScream() + * entityEndermenStare() + * entityEndermenTeleport() + * entityEndermiteAmbient() + * entityEndermiteDeath() + * entityEndermiteHurt() + * entityEndermiteStep() + * entityEnderpearlThrow() + * entityEvocationFangsAttack() + * entityEvocationIllagerAmbient() + * entityEvocationIllagerCastSpell() + * entityEvocationIllagerDeath() + * entityEvocationIllagerHurt() + * entityEvocationIllagerPrepareAttack() + * entityEvocationIllagerPrepareSummon() + * entityEvocationIllagerPrepareWololo() + * entityExperienceBottleThrow() + * entityExperienceOrbPickup() + * entityFireworkBlast() + * entityFireworkBlastFar() + * entityFireworkLargeBlast() + * entityFireworkLargeBlastFar() + * entityFireworkLaunch() + * entityFireworkShoot() + * entityFireworkTwinkle() + * entityFireworkTwinkleFar() + * entityGenericBigFall() + * entityGenericBurn() + * entityGenericDeath() + * entityGenericDrink() + * entityGenericEat() + * entityGenericExplode() + * entityGenericExtinguishFire() + * entityGenericHurt() + * entityGenericSmallFall() + * entityGenericSplash() + * entityGenericSwim() + * entityGhastAmbient() + * entityGhastDeath() + * entityGhastHurt() + * entityGhastScream() + * entityGhastShoot() + * entityGhastWarn() + * entityGuardianAmbient() + * entityGuardianAmbientLand() + * entityGuardianAttack() + * entityGuardianDeath() + * entityGuardianDeathLand() + * entityGuardianFlop() + * entityGuardianHurt() + * entityGuardianHurtLand() + * entityHorseAmbient() + * entityHorseAngry() + * entityHorseArmor() + * entityHorseBreathe() + * entityHorseDeath() + * entityHorseEat() + * entityHorseGallop() + * entityHorseHurt() + * entityHorseJump() + * entityHorseLand() + * entityHorseSaddle() + * entityHorseStep() + * entityHorseStepWood() + * entityHostileBigFall() + * entityHostileDeath() + * entityHostileHurt() + * entityHostileSmallFall() + * entityHostileSplash() + * entityHostileSwim() + * entityHuskAmbient() + * entityHuskDeath() + * entityHuskHurt() + * entityHuskStep() + * entityIllusionIllagerAmbient() + * entityIllusionIllagerCastSpell() + * entityIllusionIllagerDeath() + * entityIllusionIllagerHurt() + * entityIllusionIllagerMirrorMove() + * entityIllusionIllagerPrepareBlindness() + * entityIllusionIllagerPrepareMirror() + * entityIrongolemAttack() + * entityIrongolemDeath() + * entityIrongolemHurt() + * entityIrongolemStep() + * entityItemBreak() + * entityItemPickup() + * entityItemframeAddItem() + * entityItemframeBreak() + * entityItemframePlace() + * entityItemframeRemoveItem() + * entityItemframeRotateItem() + * entityLeashknotBreak() + * entityLeashknotPlace() + * entityLightningImpact() + * entityLightningThunder() + * entityLingeringpotionThrow() + * entityLlamaAmbient() + * entityLlamaAngry() + * entityLlamaChest() + * entityLlamaDeath() + * entityLlamaEat() + * entityLlamaHurt() + * entityLlamaSpit() + * entityLlamaStep() + * entityLlamaSwag() + * entityMagmacubeDeath() + * entityMagmacubeHurt() + * entityMagmacubeJump() + * entityMagmacubeSquish() + * entityMinecartInside() + * entityMinecartRiding() + * entityMooshroomShear() + * entityMuleAmbient() + * entityMuleChest() + * entityMuleDeath() + * entityMuleHurt() + * entityPaintingBreak() + * entityPaintingPlace() + * entityParrotAmbient() + * entityParrotDeath() + * entityParrotEat() + * entityParrotFly() + * entityParrotHurt() + * entityParrotImitateBlaze() + * entityParrotImitateCreeper() + * entityParrotImitateElderGuardian() + * entityParrotImitateEnderdragon() + * entityParrotImitateEnderman() + * entityParrotImitateEndermite() + * entityParrotImitateEvocationIllager() + * entityParrotImitateGhast() + * entityParrotImitateHusk() + * entityParrotImitateIllusionIllager() + * entityParrotImitateMagmacube() + * entityParrotImitatePolarBear() + * entityParrotImitateShulker() + * entityParrotImitateSilverfish() + * entityParrotImitateSkeleton() + * entityParrotImitateSlime() + * entityParrotImitateSpider() + * entityParrotImitateStray() + * entityParrotImitateVex() + * entityParrotImitateVindicationIllager() + * entityParrotImitateWitch() + * entityParrotImitateWither() + * entityParrotImitateWitherSkeleton() + * entityParrotImitateWolf() + * entityParrotImitateZombie() + * entityParrotImitateZombiePigman() + * entityParrotImitateZombieVillager() + * entityParrotStep() + * entityPigAmbient() + * entityPigDeath() + * entityPigHurt() + * entityPigSaddle() + * entityPigStep() + * entityPlayerAttackCrit() + * entityPlayerAttackKnockback() + * entityPlayerAttackNodamage() + * entityPlayerAttackStrong() + * entityPlayerAttackSweep() + * entityPlayerAttackWeak() + * entityPlayerBigFall() + * entityPlayerBreath() + * entityPlayerBurp() + * entityPlayerDeath() + * entityPlayerHurt() + * entityPlayerHurtDrown() + * entityPlayerHurtOnFire() + * entityPlayerLevelup() + * entityPlayerSmallFall() + * entityPlayerSplash() + * entityPlayerSwim() + * entityPolarBearAmbient() + * entityPolarBearBabyAmbient() + * entityPolarBearDeath() + * entityPolarBearHurt() + * entityPolarBearStep() + * entityPolarBearWarning() + * entityRabbitAmbient() + * entityRabbitAttack() + * entityRabbitDeath() + * entityRabbitHurt() + * entityRabbitJump() + * entitySheepAmbient() + * entitySheepDeath() + * entitySheepHurt() + * entitySheepShear() + * entitySheepStep() + * entityShulkerAmbient() + * entityShulkerBulletHit() + * entityShulkerBulletHurt() + * entityShulkerClose() + * entityShulkerDeath() + * entityShulkerHurt() + * entityShulkerHurtClosed() + * entityShulkerOpen() + * entityShulkerShoot() + * entityShulkerTeleport() + * entitySilverfishAmbient() + * entitySilverfishDeath() + * entitySilverfishHurt() + * entitySilverfishStep() + * entitySkeletonAmbient() + * entitySkeletonDeath() + * entitySkeletonHorseAmbient() + * entitySkeletonHorseDeath() + * entitySkeletonHorseHurt() + * entitySkeletonHurt() + * entitySkeletonShoot() + * entitySkeletonStep() + * entitySlimeAttack() + * entitySlimeDeath() + * entitySlimeHurt() + * entitySlimeJump() + * entitySlimeSquish() + * entitySmallMagmacubeDeath() + * entitySmallMagmacubeHurt() + * entitySmallMagmacubeSquish() + * entitySmallSlimeDeath() + * entitySmallSlimeHurt() + * entitySmallSlimeJump() + * entitySmallSlimeSquish() + * entitySnowballThrow() + * entitySnowmanAmbient() + * entitySnowmanDeath() + * entitySnowmanHurt() + * entitySnowmanShoot() + * entitySpiderAmbient() + * entitySpiderDeath() + * entitySpiderHurt() + * entitySpiderStep() + * entitySplashPotionBreak() + * entitySplashPotionThrow() + * entitySquidAmbient() + * entitySquidDeath() + * entitySquidHurt() + * entityStrayAmbient() + * entityStrayDeath() + * entityStrayHurt() + * entityStrayStep() + * entityTntPrimed() + * entityVexAmbient() + * entityVexCharge() + * entityVexDeath() + * entityVexHurt() + * entityVillagerAmbient() + * entityVillagerDeath() + * entityVillagerHurt() + * entityVillagerNo() + * entityVillagerTrading() + * entityVillagerYes() + * entityVindicationIllagerAmbient() + * entityVindicationIllagerDeath() + * entityVindicationIllagerHurt() + * entityWitchAmbient() + * entityWitchDeath() + * entityWitchDrink() + * entityWitchHurt() + * entityWitchThrow() + * entityWitherAmbient() + * entityWitherBreakBlock() + * entityWitherDeath() + * entityWitherHurt() + * entityWitherShoot() + * entityWitherSkeletonAmbient() + * entityWitherSkeletonDeath() + * entityWitherSkeletonHurt() + * entityWitherSkeletonStep() + * entityWitherSpawn() + * entityWolfAmbient() + * entityWolfDeath() + * entityWolfGrowl() + * entityWolfHowl() + * entityWolfHurt() + * entityWolfPant() + * entityWolfShake() + * entityWolfStep() + * entityWolfWhine() + * entityZombieAmbient() + * entityZombieAttackDoorWood() + * entityZombieAttackIronDoor() + * entityZombieBreakDoorWood() + * entityZombieDeath() + * entityZombieHorseAmbient() + * entityZombieHorseDeath() + * entityZombieHorseHurt() + * entityZombieHurt() + * entityZombieInfect() + * entityZombiePigAmbient() + * entityZombiePigAngry() + * entityZombiePigDeath() + * entityZombiePigHurt() + * entityZombieStep() + * entityZombieVillagerAmbient() + * entityZombieVillagerConverted() + * entityZombieVillagerCure() + * entityZombieVillagerDeath() + * entityZombieVillagerHurt() + * entityZombieVillagerStep() + * itemArmorEquipChain() + * itemArmorEquipDiamond() + * itemArmorEquipElytra() + * itemArmorEquipGeneric() + * itemArmorEquipGold() + * itemArmorEquipIron() + * itemArmorEquipLeather() + * itemBottleEmpty() + * itemBottleFill() + * itemBottleFillDragonbreath() + * itemBucketEmpty() + * itemBucketEmptyLava() + * itemBucketFill() + * itemBucketFillLava() + * itemChorusFruitTeleport() + * itemElytraFlying() + * itemFirechargeUse() + * itemFlintandsteelUse() + * itemHoeTill() + * itemShieldBlock() + * itemShieldBreak() + * itemShovelFlatten() + * itemTotemUse() + * musicCreative() + * musicCredits() + * musicDragon() + * musicEnd() + * musicGame() + * musicMenu() + * musicNether() + * record11() + * record13() + * recordBlocks() + * recordCat() + * recordChirp() + * recordFar() + * recordMall() + * recordMellohi() + * recordStal() + * recordStrad() + * recordWait() + * recordWard() + * uiButtonClick() + * uiToastChallengeComplete() + * uiToastIn() + * uiToastOut() + * weatherRain() + * weatherRainAbove() + + +## Sounds module (CanaryMod version) + +This module provides a simple way to play sounds. + +### Usage + + var sounds = require("sounds"); + // plays WOLF_HOWL sound at full volume and medium pitch + sounds.play( Packages.net.canarymod.api.world.effects.SoundEffect.Type.WOLF_HOWL, self, 1, 0); + // same as previous statement + sounds.play( Packages.net.canarymod.api.world.effects.SoundEffect.Type.WOLF_HOWL, self ); + +The play() function takes as parameters: + + * A Sound value (see https://ci.visualillusionsent.net/job/CanaryLib/javadoc/net/canarymod/api/world/effects/SoundEffect.Type.html for a list of possible values) + * A Location orbject or any object which has a location + * The Volume parameter is in the range 0 to 1 (default: 1) + * The Pitch parameter is in the range 0 to 4 (default: 0) + +In addition, the Sounds module provides a suite of helper functions - one for each possible sound. + + var sounds = require("sounds"); + // same as previous examples + sounds.wolfHowl( self ); + +Each of the following functions takes as parameters: + + * A Location orbject or any object which has a location + * The Volume parameter is in the range 0 to 1 (default: 1) + * The Pitch parameter is in the range 0 to 4 (default: 0) + +The following functions are provided for convenience and to help beginners explore sounds using TAB completion: + + * ambienceCave() + * ambienceRain() + * ambienceThunder() + * anvilBreak() + * anvilLand() + * anvilUse() + * batDeath() + * batHurt() + * batIdle() + * batLoop() + * batTakeoff() + * blazeBreath() + * blazeDeath() + * blazeHit() + * bow() + * bowHit() + * breath() + * burp() + * catHiss() + * catHit() + * catMeow() + * catPurr() + * catPurreow() + * chestClosed() + * chestOpen() + * chickenHurt() + * chickenPlop() + * chickenSay() + * chickenStep() + * click() + * cowHurt() + * cowSay() + * cowStep() + * creeperDeath() + * creeperSay() + * digCloth() + * digGrass() + * digGravel() + * digSand() + * digSnow() + * digStone() + * digWood() + * doorClose() + * doorOpen() + * drink() + * eat() + * enderdragonEnd() + * enderdragonGrowl() + * enderdragonHit() + * enderdragonWings() + * endermanDeath() + * endermanHit() + * endermanIdle() + * endermanPortal() + * endermanScream() + * endermanStare() + * explode() + * fallBig() + * fallSmall() + * fire() + * fireIgnite() + * fizz() + * fuse() + * ghastAffectionateScream() + * ghastCharge() + * ghastDeath() + * ghastFireball() + * ghastMoan() + * ghastScream() + * glass() + * hurt() + * hurtFlesh() + * irongolemDeath() + * irongolemHit() + * irongolemThrow() + * irongolemWalk() + * itemBreak() + * itemPickup() + * lava() + * lavaPop() + * levelUp() + * liquidSplash() + * magmacubeBig() + * magmacubeJump() + * magmacubeSmall() + * minecartBase() + * minecartInside() + * noteBass() + * noteBassAttack() + * noteBassDrum() + * noteHat() + * notePiano() + * notePling() + * noteSnare() + * orb() + * pigDeath() + * pigSay() + * pigStep() + * pistonIn() + * pistonOut() + * portal() + * portalTravel() + * portalTrigger() + * sheepSay() + * sheepShear() + * sheepStep() + * silverfishHit() + * silverfishKil() + * silverfishSay() + * silverfishStep() + * skeletonDeath() + * skeletonHurt() + * skeletonSay() + * skeletonStep() + * slimeAttack() + * slimeBig() + * slimeSmall() + * spiderDeath() + * spiderSay() + * spiderStep() + * splash() + * stepGrass() + * stepGravel() + * stepLadder() + * stepSand() + * stepSnow() + * stepStone() + * stepWood() + * stepWool() + * swim() + * water() + * witherDeath() + * witherHurt() + * witherIdle() + * witherShoot() + * witherSpawn() + * wolfBark() + * wolfDeath() + * wolfGrowl() + * wolfHowl() + * wolfHurt() + * wolfPant() + * wolfShake() + * wolfStep() + * wolfWhine() + * woodClick() + * zombieDeath() + * zombieHurt() + * zombieInfect() + * zombieMetal() + * zombiePigAngry() + * zombiePigDeath() + * zombiePigHurt() + * zombiePigIdle() + * zombieRemedy() + * zombieSay() + * zombieUnfect() + * zombieWood() + * zombieWoodbreak() + + ## Entities module The Entities module provides a suite of functions - one for each possible entity type. It acts as a helper or enumerated module to assist in use with the `spawn` module and command. diff --git a/src/docs/js/generateApiDocs.js b/src/docs/js/generateApiDocs.js index 467dbf712..325ebee6e 100644 --- a/src/docs/js/generateApiDocs.js +++ b/src/docs/js/generateApiDocs.js @@ -13,12 +13,12 @@ function foreach(array, func){ function find(dir,store,re) { var files = dir.listFiles(); foreach (files, function(filename){ - filename = "" + filename; + filename = '' + filename; var file = new File(filename); if (file.isDirectory()) { find(file,store,re); } else { - if (typeof re == "undefined") + if (typeof re == 'undefined') store.push(filename); else if (filename.match(re)) store.push(filename); @@ -91,18 +91,18 @@ var store = []; find(new io.File(dir),store,/\/[a-zA-Z0-9_\-]+\.js$/); store.sort(sorter([ - /lib\/scriptcraft\.js$/, - /lib\/require\.js$/, - /lib\/plugin\.js$/, - /lib\/events\.js$/, - /lib\/events\-helper\-canary/, - /lib\/events\-helper\-bukkit/, - /lib\//, - /modules\/drone\/index\.js/, - /modules\/drone\//, - /plugins\/drone\//, - /modules\//, - /examples\// + /lib\/scriptcraft\.js$/, + /lib\/require\.js$/, + /lib\/plugin\.js$/, + /lib\/events\.js$/, + /lib\/events\-helper\-canary/, + /lib\/events\-helper\-bukkit/, + /lib\//, + /modules\/drone\/index\.js/, + /modules\/drone\//, + /plugins\/drone\//, + /modules\//, + /examples\// ])); var contents = []; diff --git a/src/docs/js/generateEventsHelper.js b/src/docs/js/generateEventsHelper.js index b367ed71a..a823e213d 100644 --- a/src/docs/js/generateEventsHelper.js +++ b/src/docs/js/generateEventsHelper.js @@ -1,3 +1,4 @@ +/*global args*/ args = Array.prototype.slice.call(args,1); // [0] = type, [1] = lib.jar [2] = blockX, [3] = classX var File = java.io.File, @@ -88,7 +89,7 @@ names.forEach(function(name) { ' * priority - optional - see events.on() for more information.', '', '***/' -//http://jd.bukkit.org/rb/apidocs/org/bukkit/event/player/PlayerJoinEvent.html + //http://jd.bukkit.org/rb/apidocs/org/bukkit/event/player/PlayerJoinEvent.html ]; for (var i = 0; i < comment.length; i++){ out.println(comment[i]); diff --git a/src/docs/js/generateItemsDoc.js b/src/docs/js/generateItemsDoc.js index fe5715fe6..6ac5fe130 100644 --- a/src/docs/js/generateItemsDoc.js +++ b/src/docs/js/generateItemsDoc.js @@ -1,8 +1,6 @@ -args = Array.prototype.slice.call(args,1); -// [0] = type, [1] = lib.jar [2] = blockX, [3] = classX -var out = java.lang.System.out, - err = java.lang.System.err, - entry = null; +'use strict'; +/*global cmItemTypeClass*/ +var out = java.lang.System.out; var content = [ '', '## Items module (SpigotMC version)', @@ -69,7 +67,7 @@ for ( i = 0;i < materials.length; i++ ){ enumVals.sort(); content = content.concat(enumVals); content.push(''); -for (var i = 0; i< content.length; i++){ +for ( i = 0; i< content.length; i++){ out.println(content[i]); } diff --git a/src/docs/js/generateSoundsDoc.js b/src/docs/js/generateSoundsDoc.js new file mode 100644 index 000000000..e1d0599b3 --- /dev/null +++ b/src/docs/js/generateSoundsDoc.js @@ -0,0 +1,109 @@ +var out = java.lang.System.out; +var content = [ + '', + '## Sounds module (SpigotMC version)', + '', + 'This module provides a simple way to play sounds.', + '', + '### Usage', + '', + ' var sounds = require("sounds");', + ' // plays ENTITY_WOLF_HOWL sound at full volume and medium pitch', + ' sounds.play( org.bukkit.Sound.ENTITY_WOLF_HOWL, self, 1, 0); ', + ' // same as previous statement', + ' sounds.play( org.bukkit.Sound.ENTITY_WOLF_HOWL , self );', + '', + 'The play() function takes as parameters:', + '', + ' * A Sound value (see https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html for a list of possible values)', + ' * A Location orbject or any object which has a location', + ' * The Volume parameter is in the range 0 to 1 (default: 1)', + ' * The Pitch parameter is in the range 0 to 4 (default: 0)', + '', + 'In addition, the Sounds module provides a suite of helper functions - one for each possible sound. ', + '', + ' var sounds = require("sounds");', + ' // same as previous examples', + ' sounds.entityWolfHowl( self );', + '', + 'Each of the following functions takes as parameters:', + '', + ' * A Location orbject or any object which has a location', + ' * The Volume parameter is in the range 0 to 1 (default: 1)', + ' * The Pitch parameter is in the range 0 to 4 (default: 0)', + '', + 'The following functions are provided for convenience and to help beginners explore sounds using TAB completion:', + '' +]; + +var enumVals = [], i; +var sound, soundName, sounds = org.bukkit.Sound.values(); +for (i = 0; i < sounds.length; i++ ){ + sound = sounds[i]; + soundName = '' + sound.name(); + var methodName = soundName.toLowerCase().replace(/_(.)/g,function(a,b){ + return b.toUpperCase(); + }); + enumVals.push(' * ' + methodName + '()'); +} +enumVals.sort(); +content = content.concat(enumVals); +content.push(''); +for (i = 0; i< content.length; i++){ + out.println(content[i]); +} + +content = [ + '', + '## Sounds module (CanaryMod version)', + '', + 'This module provides a simple way to play sounds.', + '', + '### Usage', + '', + ' var sounds = require("sounds");', + ' // plays WOLF_HOWL sound at full volume and medium pitch', + ' sounds.play( Packages.net.canarymod.api.world.effects.SoundEffect.Type.WOLF_HOWL, self, 1, 0); ', + ' // same as previous statement', + ' sounds.play( Packages.net.canarymod.api.world.effects.SoundEffect.Type.WOLF_HOWL, self );', + '', + 'The play() function takes as parameters:', + '', + ' * A Sound value (see https://ci.visualillusionsent.net/job/CanaryLib/javadoc/net/canarymod/api/world/effects/SoundEffect.Type.html for a list of possible values)', + ' * A Location orbject or any object which has a location', + ' * The Volume parameter is in the range 0 to 1 (default: 1)', + ' * The Pitch parameter is in the range 0 to 4 (default: 0)', + '', + 'In addition, the Sounds module provides a suite of helper functions - one for each possible sound. ', + '', + ' var sounds = require("sounds");', + ' // same as previous examples', + ' sounds.wolfHowl( self );', + '', + 'Each of the following functions takes as parameters:', + '', + ' * A Location orbject or any object which has a location', + ' * The Volume parameter is in the range 0 to 1 (default: 1)', + ' * The Pitch parameter is in the range 0 to 4 (default: 0)', + '', + 'The following functions are provided for convenience and to help beginners explore sounds using TAB completion:', + '' +]; + +enumVals = []; +sounds = Packages.net.canarymod.api.world.effects.SoundEffect.Type.values(); +for (i = 0; i < sounds.length; i++ ){ + sound = sounds[i]; + soundName = '' + sound.name(); + methodName = soundName.toLowerCase().replace(/_(.)/g,function(a,b){ + return b.toUpperCase(); + }); + enumVals.push(' * ' + methodName + '()'); +} +enumVals.sort(); +content = content.concat(enumVals); +content.push(''); +for (i = 0; i< content.length; i++){ + out.println(content[i]); +} + diff --git a/src/docs/js/generateTOC.js b/src/docs/js/generateTOC.js index 22e35df68..b80bff092 100644 --- a/src/docs/js/generateTOC.js +++ b/src/docs/js/generateTOC.js @@ -2,9 +2,9 @@ args = Array.prototype.slice.call(args,1); // wph 20140105 trim not availabe in String on Mac OS. if (typeof String.prototype.trim == 'undefined'){ - String.prototype.trim = function(){ - return this.replace(/^\s+|\s+$/g,''); - }; + String.prototype.trim = function(){ + return this.replace(/^\s+|\s+$/g,''); + }; } var template = args[0]; @@ -16,35 +16,35 @@ var contents = [], line = undefined; var br = new BufferedReader( new FileReader(template) ); while ( (line = br.readLine()) != null){ - contents.push(line); + contents.push(line); } br.close(); var anchors = {}; var createLink = function(text){ - var result = text.replace(/_/g,'_'); - result = result.replace(/[^a-zA-Z0-9 _\-]/g,''); - result = result.replace(/ /g,'-'); - var result = result.toLowerCase(); - if (anchors[result]){ - result = result + '-' + (anchors[result]++); - } - anchors[result] = 1; - return result; + var result = text.replace(/_/g,'_'); + result = result.replace(/[^a-zA-Z0-9 _\-]/g,''); + result = result.replace(/ /g,'-'); + var result = result.toLowerCase(); + if (anchors[result]){ + result = result + '-' + (anchors[result]++); + } + anchors[result] = 1; + return result; }; java.lang.System.out.println('## Table of Contents'); for (var i = 0; i < contents.length; i++){ - line = contents[i]; - if (line.match(/^##\s+/)){ - var h2 = line.match(/^##\s+(.*)/)[1].trim(); - var link = createLink(h2); - java.lang.System.out.println(' * [' + h2 + '](#' + link + ')'); - } - if (line.match(/^###\s+/)){ - var h3 = line.match(/^###\s+(.*)/)[1].trim(); - var link = createLink(h3); - java.lang.System.out.println(' * [' + h3 + '](#' + link + ')'); - } + line = contents[i]; + if (line.match(/^##\s+/)){ + var h2 = line.match(/^##\s+(.*)/)[1].trim(); + var link = createLink(h2); + java.lang.System.out.println(' * [' + h2 + '](#' + link + ')'); + } + if (line.match(/^###\s+/)){ + var h3 = line.match(/^###\s+(.*)/)[1].trim(); + var link = createLink(h3); + java.lang.System.out.println(' * [' + h3 + '](#' + link + ')'); + } } diff --git a/src/main/js/modules/bukkit/sounds.js b/src/main/js/modules/bukkit/sounds.js index 88e8a01c3..6c755fb86 100644 --- a/src/main/js/modules/bukkit/sounds.js +++ b/src/main/js/modules/bukkit/sounds.js @@ -32,7 +32,9 @@ function play(sound, locationOrHasLocation, volume, pitch) { for ( ; i < len; i++ ) { sound = allSounds[i]; soundName = '' + sound.name(); - var methodName = soundName.toLowerCase().replace(/_(.)/g,function(a,b){ return b.toUpperCase();}); + var methodName = soundName.toLowerCase().replace(/_(.)/g,function(a,b){ + return b.toUpperCase(); + }); exports[methodName] = (function(sound){ return function() { diff --git a/src/main/js/modules/sounds.js b/src/main/js/modules/sounds.js index 4065cc39e..2a8c480ba 100644 --- a/src/main/js/modules/sounds.js +++ b/src/main/js/modules/sounds.js @@ -1,30 +1,3 @@ -/************************************************************************* -## Sounds Module - -This module is a simple wrapper around the Bukkit Sound class and provides -a simpler way to play sounds. All of the org.bukkit.Sound Enum values are attached. - -### Usage (Bukkit) : - - var sounds = require('sounds'); - sounds.play( bukkit.sound.VILLAGER_NO , self, 1, 0); // plays VILLAGER_NO sound at full volume and medium pitch - sounds.play( 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 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. -***/ if (__plugin.canary) { module.exports = require('./canary/sounds'); } else {