summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
blob: d4759802a83d30a30988f3fa0f55a178114446e2 (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
49
50
51
52
53
54
55
56
57
58
package com.earth2me.essentials.commands;

import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.entity.*;
import org.bukkit.util.Vector;


public class Commandfireball extends EssentialsCommand
{
	public Commandfireball()
	{
		super("fireball");
	}

	@Override
	protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
	{
		Class<? extends Entity> type = Fireball.class;
		Projectile projectile;
		int speed = 2;
		if (args.length > 0)
		{
			if (args[0].equalsIgnoreCase("small"))
			{
				type = SmallFireball.class;
			}
			else if (args[0].equalsIgnoreCase("arrow"))
			{
				type = Arrow.class;
			}
			else if (args[0].equalsIgnoreCase("skull"))
			{
				type = WitherSkull.class;
			}
			else if (args[0].equalsIgnoreCase("egg"))
			{
				type = Egg.class;
			}
			else if(args[0].equalsIgnoreCase("snowball"))
			{
				type = Snowball.class;
			}
			else if(args[0].equalsIgnoreCase("expbottle"))
			{
				type = ThrownExpBottle.class;
			}
			else if(args[0].equalsIgnoreCase("large"))
			{
				type = LargeFireball.class;
			}
		}
		final Vector direction = user.getBase().getEyeLocation().getDirection().multiply(speed);
		projectile = (Projectile)user.getWorld().spawn(user.getBase().getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), type);
		projectile.setShooter(user.getBase());
		projectile.setVelocity(direction);
	}
}