Merge pull request #231 from carlrobert/patch-11

Bukkit and CanaryMod links corrected. jslint.
This commit is contained in:
Walter Higgins 2015-04-16 21:25:05 +01:00
commit 52070cffdc

View file

@ -1,3 +1,6 @@
'use strict';
/*global Packages, __plugin, command, echo, isOp, org */
/*jslint nomen: true, indent: 2 */
/*************************************************************************
## Spawn Plugin
@ -12,41 +15,47 @@ Allows in-game operators to easily spawn creatures at current location.
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>
<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)
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 {
var entities = [],
entityType = null,
entitytypes,
t;
if (__plugin.bukkit) {
entityType = org.bukkit.entity.EntityType;
}
var entitytypes = entityType.values();
for ( var t in entitytypes ) {
if ( entitytypes[t] && entitytypes[t].ordinal ) {
if (__plugin.canary) {
entityType = Packages.net.canarymod.api.entity.EntityType;
}
entitytypes = entityType.values();
for (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' );
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.' );
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);
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);
entity.spawn();
}
}, entities );
}, entities);