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

import com.earth2me.essentials.Trade;
import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;


public class Commandtppos extends EssentialsCommand
{
	public Commandtppos()
	{
		super("tppos");
	}

	@Override
	public void run(Server server, User user, String commandLabel, String[] args) throws Exception
	{
		if (args.length < 3)
		{
			throw new NotEnoughArgumentsException();
		}

		int x = Integer.parseInt(args[0]);
		int y = Integer.parseInt(args[1]);
		int z = Integer.parseInt(args[2]);
		Location l = new Location(user.getWorld(), x, y, z);
		if (args.length > 3) {
			l.setYaw(Float.parseFloat(args[3]));
		}
		if (args.length > 4) {
			l.setPitch(Float.parseFloat(args[4]));
		}
		Trade charge = new Trade(this.getName(), ess);
		charge.isAffordableFor(user);
		user.sendMessage(Util.i18n("teleporting"));
		user.getTeleport().teleport(l, charge);
		throw new NoChargeException();
	}
}