From e285bb68915762dd19b7fed5771ee36a755a9e28 Mon Sep 17 00:00:00 2001 From: walterhiggins Date: Sat, 21 Nov 2015 17:07:40 +0000 Subject: [PATCH] added new entities and spawn modules --- build.properties | 2 +- release-notes.md | 17 +++++++++++ src/main/js/modules/entities.js | 18 +++++++++++ src/main/js/modules/spawn.js | 18 +++++++++++ src/main/js/plugins/drone/contrib/spawn.js | 8 +++++ src/main/js/plugins/spawn.js | 35 +++++----------------- 6 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 src/main/js/modules/entities.js create mode 100644 src/main/js/modules/spawn.js create mode 100644 src/main/js/plugins/drone/contrib/spawn.js 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