Skip to content

Instantly share code, notes, and snippets.

@jbrownsc
Created December 2, 2015 06:21
Show Gist options
  • Save jbrownsc/153a28bd80c92733cbce to your computer and use it in GitHub Desktop.
Save jbrownsc/153a28bd80c92733cbce to your computer and use it in GitHub Desktop.
Crazy cows...
var entities = [],
entityType = null,
entitytypes,
t;
if (__plugin.bukkit) {
entityType = org.bukkit.entity.EntityType;
}
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('spawns', 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,
type = ('' + parameters[0]).toUpperCase();
if (__plugin.bukkit) {
world.spawnEntity(location, entityType[type]);
}
if (__plugin.canary) {
for (i = 0; i < parameters[1]; i++) {
var Canary = Packages.net.canarymod.Canary,
entity = Canary.factory().entityFactory.newEntity(entityType[type], location);
entity.spawn();
entity.motionY = 3;
}
}
}, entities);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment