This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
scriptcraft/src/main/js/plugins/spawn.js
walterhiggins 19162c3688 First phase of transition from Bukkit to Canary.
Some of the plugins are not yet supported.
If you're feeling brave you can build from source using ant.
2014-09-29 23:42:41 +01:00

53 lines
1.5 KiB
JavaScript

/*************************************************************************
## Spawn Plugin
Allows in-game operators to easily spawn creatures at current location.
### Usage
/jsp spawn cow
/jsp spawn sheep
/jsp spawn wolf
This command supports TAB completion so to see a list of possible
entitities, type `/jsp spawn ' at the in-game command prompt, then
press TAB. Visit
<http://jd.bukkit.org/beta/apidocs/org/bukkit/entity/EntityType.html>
for a list of possible entities (creatures) which can be spawned.
***/
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());
}
}
command( 'spawn', function( parameters, sender ) {
if ( !isOp(sender) ) {
echo( sender, 'Only operators can perform this command' );
return;
}
var location = sender.location;
if ( !location ) {
echo( sender, 'You have no location. This command only works in-game.' );
return;
}
var world = location.world || sender.world;
var type = ('' + parameters[0]).toUpperCase();
if (__plugin.bukkit){
world.spawnEntity( location, entityType[type] );
} else {
var Canary = Packages.net.canarymod.Canary;
var entity = Canary.factory().entityFactory.newEntity(entityType[type], location);
entity.spawn();
}
}, entities );