summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandjump.java
blob: 65a1085e1b4925d59caaec3181cbd9751e68ae2e (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
package com.earth2me.essentials.commands;

import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.TargetBlock;
import com.earth2me.essentials.User;


public class Commandjump extends EssentialsCommand
{
	public Commandjump()
	{
		super("jump");
	}

	@Override
	public void run(Server server, User user, String commandLabel, String[] args) throws Exception
	{
		Location loc;
		Location cloc = user.getLocation();

		try
		{
			loc = new TargetBlock(user, 100, 2.65).getTargetBlock().getLocation();
			loc.setYaw(cloc.getYaw());
			loc.setPitch(cloc.getPitch());
			loc = new TargetBlock(loc).getPreviousBlock().getLocation();
			loc.setYaw(cloc.getYaw());
			loc.setPitch(cloc.getPitch());
			loc.setY(loc.getY() + 1);
		}
		catch (NullPointerException ex)
		{
			throw new Exception("That would hurt your computer's brain.", ex);
		}

		user.canAfford(this);
		user.getTeleport().teleport(loc, this.getName());
	}
}