Bukkit and CanaryMod links corrected. jslint.

The bukkit link was broken, btw.
This commit is contained in:
Robert Storlind 2015-04-10 22:25:44 +02:00
parent 051ccc0c6d
commit baac1cbe3f

View file

@ -1,3 +1,6 @@
'use strict';
/*global Packages, __plugin, command, echo, isOp, org */
/*jslint nomen: true, indent: 2 */
/************************************************************************* /*************************************************************************
## Spawn Plugin ## 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 This command supports TAB completion so to see a list of possible
entitities, type `/jsp spawn ' at the in-game command prompt, then entitities, type `/jsp spawn ' at the in-game command prompt, then
press TAB. Visit 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. for a list of possible entities (creatures) which can be spawned.
***/ ***/
var entities = []; var entities = [],
var entityType = null; entityType = null,
if (__plugin.canary){ entitytypes,
entityType = Packages.net.canarymod.api.entity.EntityType; t;
}else { if (__plugin.bukkit) {
entityType = org.bukkit.entity.EntityType; entityType = org.bukkit.entity.EntityType;
} }
var entitytypes = entityType.values(); if (__plugin.canary) {
for ( var t in entitytypes ) { entityType = Packages.net.canarymod.api.entity.EntityType;
if ( entitytypes[t] && entitytypes[t].ordinal ) { }
entitytypes = entityType.values();
for (t in entitytypes) {
if (entitytypes[t] && entitytypes[t].ordinal) {
entities.push(entitytypes[t].name()); entities.push(entitytypes[t].name());
} }
} }
command( 'spawn', function( parameters, sender ) { command('spawn', function (parameters, sender) {
if ( !isOp(sender) ) { if (!isOp(sender)) {
echo( sender, 'Only operators can perform this command' ); echo(sender, 'Only operators can perform this command');
return; return;
} }
var location = sender.location; var location = sender.location;
if ( !location ) { if (!location) {
echo( sender, 'You have no location. This command only works in-game.' ); echo(sender, 'You have no location. This command only works in-game.');
return; return;
} }
var world = location.world || sender.world; var world = location.world || sender.world,
var type = ('' + parameters[0]).toUpperCase(); type = ('' + parameters[0]).toUpperCase();
if (__plugin.bukkit){ if (__plugin.bukkit) {
world.spawnEntity( location, entityType[type] ); world.spawnEntity(location, entityType[type]);
} else { }
var Canary = Packages.net.canarymod.Canary; if (__plugin.canary) {
var entity = Canary.factory().entityFactory.newEntity(entityType[type], location); var Canary = Packages.net.canarymod.Canary,
entity = Canary.factory().entityFactory.newEntity(entityType[type], location);
entity.spawn(); entity.spawn();
} }
}, entities ); }, entities);