-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdospawn.js
More file actions
31 lines (28 loc) · 1019 Bytes
/
dospawn.js
File metadata and controls
31 lines (28 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//sets up entity list and Canary variable (borrowed from spawn command)
var entities = [];
var entityType = null;
if (__plugin.canary){
entityType = Packages.net.canarymod.api.entity.EntityType;
}else {
entityType = org.bukkit.entity.EntityType;
}
var entitytypes = entityType.values();
for ( var t in entitytypes ) {
if ( entitytypes[t] && entitytypes[t].ordinal ) {
entities.push(entitytypes[t].name());
}
}
var Canary = Packages.net.canarymod.Canary;
// we export the function for use in Scriptcraft by other functions
exports.dospawn = function(type, location){
// checks to make sure type is in the entity list and sets it to "PIG" if not.
var usetype = (entities.indexOf(type.toUpperCase()) == -1) ? "PIG" : type.toUpperCase();
if (__plugin.canary){
var entity = Canary.factory().entityFactory.newEntity(entityType[usetype], location);
entity.spawn();
} else {
var world = location.world;
var entity = world.spawnEntity(location, entityType[usetype]);
}
return entity;
}