summaryrefslogtreecommitdiffstats
path: root/Essentials/src/net/ess3/commands/Commandfireball.java
blob: e8237908626adc6bb3f2772078950e415ec905eb (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
package net.ess3.commands;

import net.ess3.api.IUser;
import org.bukkit.entity.*;
import org.bukkit.util.Vector;


public class Commandfireball extends EssentialsCommand
{
	@Override
	protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
	{
		Class<? extends Entity> clazz = Fireball.class;
		if (args.length > 0)
		{
			if(args[0].equalsIgnoreCase("small"))
			{
				clazz = SmallFireball.class;
			}
			else if(args[0].equalsIgnoreCase("arrow"))
			{
				clazz = Arrow.class;
			}
			else if(args[0].equalsIgnoreCase("skull"))
			{
				clazz = WitherSkull.class;
			}
			else if(args[0].equalsIgnoreCase("egg"))
			{
				clazz = Egg.class;
			}
			else if(args[0].equalsIgnoreCase("snowball"))
			{
				clazz = Snowball.class;
			}
			else if(args[0].equalsIgnoreCase("expbottle"))
			{
				clazz = ThrownExpBottle.class;
			}
			else if(args[0].equalsIgnoreCase("large"))
			{
				clazz = LargeFireball.class;
			}
		}

		final Player player = user.getPlayer();

		final Vector direction = player.getEyeLocation().getDirection().multiply(2);
		Projectile projectile = (Projectile)user.getPlayer().getWorld().spawn(user.getPlayer().getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), clazz);
		projectile.setShooter(user.getPlayer());
		projectile.setVelocity(direction);
	}
}