summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
blob: 507e1d7d35e5a17cf86b31072b1c12fc0a09cf28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.earth2me.essentials.commands;

import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.Ocelot;

// This command is not documented on the wiki #EasterEgg
public class Commandkittycannon extends EssentialsCommand
{
	private static final Random random = new Random();

	public Commandkittycannon()
	{
		super("kittycannon");
	}

	@Override
	protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
	{
		final Mob cat = Mob.OCELOT;
		final Ocelot ocelot = (Ocelot)cat.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
		if (ocelot == null)
		{
			return;
		}
		final int i = random.nextInt(Ocelot.Type.values().length);
		ocelot.setCatType(Ocelot.Type.values()[i]);
		ocelot.setTamed(true);
		ocelot.setBaby();
		ocelot.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));

		class KittyCannonExplodeTask implements Runnable
		{
			@Override
			public void run()
			{
				final Location loc = ocelot.getLocation();
				ocelot.remove();
				loc.getWorld().createExplosion(loc, 0F);
			}
		}
		ess.scheduleSyncDelayedTask(new KittyCannonExplodeTask(), 20);

	}
}