diff --git a/build.properties b/build.properties index d8eeaff..2e167e0 100644 --- a/build.properties +++ b/build.properties @@ -1 +1 @@ -scriptcraft-version=3.1.10 +scriptcraft-version=3.1.11 diff --git a/release-notes.md b/release-notes.md index f36ea48..96200af 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,5 +1,22 @@ RELEASE NOTES ============= +3.1.11 Release (2015 11 21) +--------------------------- + +Added new modules + +* entities +* spawn + +And new Drone function `spawn()` + +To use: +Point at a block then type... +``` +/js spawn('ZOMBIE').fwd().times(5).right().back(5).times(6) +``` + +... unleash a horde of zombies (in 5x6 grid formation). 3.1.10 Release (2015 08 16) --------------------------- diff --git a/src/main/js/modules/entities.js b/src/main/js/modules/entities.js new file mode 100644 index 0000000..5bd3d8d --- /dev/null +++ b/src/main/js/modules/entities.js @@ -0,0 +1,18 @@ +/*global __plugin, org, Packages, module, exports*/ +'use strict'; +var entities = {}, + entitytypes, + t, i, name; +if (__plugin.bukkit) { + entitytypes = org.bukkit.entity.EntityType.values(); +} +if (__plugin.canary) { + entitytypes = Packages.net.canarymod.api.entity.EntityType.values(); +} +for (t in entitytypes) { + if (entitytypes[t] && entitytypes[t].ordinal) { + name = entitytypes[t].name(); + entities[name] = entitytypes[t]; + } +} +module.exports = entities; diff --git a/src/main/js/modules/spawn.js b/src/main/js/modules/spawn.js new file mode 100644 index 0000000..f8dbb4d --- /dev/null +++ b/src/main/js/modules/spawn.js @@ -0,0 +1,18 @@ +/*global require, module, __plugin, Packages*/ +'use strict'; +var entities = require('entities'); + +module.exports = function(entityType, location){ + if (typeof entityType === 'string'){ + entityType = entities[entityType]; + } + var world = location.world; + if (__plugin.bukkit){ + world.spawnEntity( location, entityType); + } + if (__plugin.canary){ + var Canary = Packages.net.canarymod.Canary, + entityInstance = Canary.factory().entityFactory.newEntity(entityType, location); + entityInstance.spawn(); + } +}; diff --git a/src/main/js/plugins/drone/contrib/spawn.js b/src/main/js/plugins/drone/contrib/spawn.js new file mode 100644 index 0000000..24f86c0 --- /dev/null +++ b/src/main/js/plugins/drone/contrib/spawn.js @@ -0,0 +1,8 @@ +'use strict'; +var spawnFn = require('spawn'), + Drone = require('drone') + ; +function spawn(entityType){ + spawnFn(entityType, this.getBlock().location); +} +Drone.extend(spawn); diff --git a/src/main/js/plugins/spawn.js b/src/main/js/plugins/spawn.js index dd6272f..b9a4ecc 100644 --- a/src/main/js/plugins/spawn.js +++ b/src/main/js/plugins/spawn.js @@ -21,23 +21,12 @@ or