summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
blob: ddadda860cde31eae2b43d5dd9170faa4b420cab (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
45
46
47
48
49
50
51
52
53
package com.earth2me.essentials.commands;

import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.Essentials;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;


public class Commandheal extends EssentialsCommand
{
	public Commandheal()
	{
		super("heal");
	}

	@Override
	public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
	{
		if (args.length > 0 && user.isAuthorized("essentials.heal.others"))
		{
			if (!user.isAuthorized("essentials.heal.cooldown.bypass")) user.healCooldown();
			user.charge(this);
			for (Player p : server.matchPlayer(args[0]))
			{
				p.setHealth(20);
				user.sendMessage("§7Healed " + p.getDisplayName() + ".");
			}
			return;
		}
		
		if (!user.isAuthorized("essentials.heal.cooldown.bypass")) user.healCooldown();
		user.charge(this);
		user.setHealth(20);
		user.sendMessage("§7You have been healed.");
	}

	@Override
	public void run(Server server, Essentials parent, CommandSender sender, String commandLabel, String[] args) throws Exception
	{
		if (args.length < 1)
		{
			sender.sendMessage("Usage: /" + commandLabel + " [player]");
			return;
		}

		for (Player p : server.matchPlayer(args[0]))
		{
			p.setHealth(20);
			sender.sendMessage("Healed " + p.getDisplayName() + ".");
		}
	}
}