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

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


public class Commandtpohere extends EssentialsCommand
{
	public Commandtpohere()
	{
		super("tpohere");
	}

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

		//Just basically the old tphere command
		User p = getPlayer(server, args, 0, true);

		// Check if user is offline
		if (p.getBase() instanceof OfflinePlayer)
		{
			throw new NoSuchFieldException(Util.i18n("playerNotFound"));
		}

		// Verify permission
		if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
		{
			p.getTeleport().now(user, false);
			user.sendMessage(Util.i18n("teleporting"));
		}
		else
		{
			throw new NoSuchFieldException(Util.i18n("playerNotFound"));
		}
	}
}