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

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


public class Commandtpa extends EssentialsCommand
{
	public Commandtpa()
	{
		super("tpa");
	}

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

		User p = getPlayer(server, args, 0);
		if (!p.isTeleportEnabled())
		{
			throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
		}
		charge(user);
		if (!p.isIgnoredPlayer(user.getName()))
		{
			p.requestTeleport(user, false);
			p.sendMessage(Util.format("teleportRequest", user.getDisplayName()));
			p.sendMessage(Util.i18n("typeTpaccept"));
			p.sendMessage(Util.i18n("typeTpdeny"));
		}
		user.sendMessage(Util.format("requestSent", p.getDisplayName()));
	}
}