summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
blob: a5cde8d3fb03879c8f9dac5ad11602dfffbb9148 (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.Charge;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;


public class Commandhome extends EssentialsCommand
{
	public Commandhome()
	{
		super("home");
	}

	@Override
	public void run(Server server, User user, String commandLabel, String[] args) throws Exception
	{
		Charge charge = new Charge(this);
		charge.isAffordableFor(user);
		if(args.length > 0 && user.isAuthorized("essentials.home.others"))
		{
			User u;
			try
			{
				u = getPlayer(server, args, 0);
			}
			catch(NoSuchFieldException ex)
			{
				u = ess.getOfflineUser(args[0]);
			}
			if (u == null)
			{
				throw new Exception(Util.i18n("playerNotFound"));
			}
			user.getTeleport().home(u, charge);
			return;
		}
		user.getTeleport().home(charge);
	}
}