2015-04-10 22:25:44 +02:00
|
|
|
'use strict';
|
|
|
|
/*global Packages, __plugin, command, echo, isOp, org */
|
|
|
|
/*jslint nomen: true, indent: 2 */
|
2014-01-12 12:26:26 +01:00
|
|
|
/*************************************************************************
|
|
|
|
## 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
|
2015-04-10 22:25:44 +02:00
|
|
|
<https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html> (CanaryMod)
|
|
|
|
or <http://docs.visualillusionsent.net/CanaryLib/1.0.0/net/canarymod/api/entity/EntityType.html> (Bukkit)
|
|
|
|
|
2014-01-12 12:26:26 +01:00
|
|
|
for a list of possible entities (creatures) which can be spawned.
|
|
|
|
|
|
|
|
***/
|
2015-04-10 22:25:44 +02:00
|
|
|
var entities = [],
|
|
|
|
entityType = null,
|
|
|
|
entitytypes,
|
|
|
|
t;
|
|
|
|
if (__plugin.bukkit) {
|
2014-09-30 00:42:41 +02:00
|
|
|
entityType = org.bukkit.entity.EntityType;
|
|
|
|
}
|
2015-04-10 22:25:44 +02:00
|
|
|
if (__plugin.canary) {
|
|
|
|
entityType = Packages.net.canarymod.api.entity.EntityType;
|
|
|
|
}
|
|
|
|
entitytypes = entityType.values();
|
|
|
|
for (t in entitytypes) {
|
|
|
|
if (entitytypes[t] && entitytypes[t].ordinal) {
|
2014-01-30 00:11:40 +01:00
|
|
|
entities.push(entitytypes[t].name());
|
2014-01-29 20:49:15 +01:00
|
|
|
}
|
2014-01-12 12:26:26 +01:00
|
|
|
}
|
2014-09-30 00:42:41 +02:00
|
|
|
|
2015-04-10 22:25:44 +02:00
|
|
|
command('spawn', function (parameters, sender) {
|
|
|
|
if (!isOp(sender)) {
|
|
|
|
echo(sender, 'Only operators can perform this command');
|
2014-01-29 20:49:15 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var location = sender.location;
|
2015-04-10 22:25:44 +02:00
|
|
|
if (!location) {
|
|
|
|
echo(sender, 'You have no location. This command only works in-game.');
|
2014-01-30 00:11:40 +01:00
|
|
|
return;
|
|
|
|
}
|
2015-04-10 22:25:44 +02:00
|
|
|
var world = location.world || sender.world,
|
|
|
|
type = ('' + parameters[0]).toUpperCase();
|
|
|
|
if (__plugin.bukkit) {
|
|
|
|
world.spawnEntity(location, entityType[type]);
|
|
|
|
}
|
|
|
|
if (__plugin.canary) {
|
|
|
|
var Canary = Packages.net.canarymod.Canary,
|
|
|
|
entity = Canary.factory().entityFactory.newEntity(entityType[type], location);
|
2014-09-30 00:42:41 +02:00
|
|
|
entity.spawn();
|
|
|
|
}
|
2015-04-10 22:25:44 +02:00
|
|
|
}, entities);
|