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

import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;


public class Commandhelpop extends EssentialsCommand
{
	public Commandhelpop()
	{
		super("helpop");
	}

	@Override
	public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
	{
		user.setDisplayNick();
		final String message = sendMessage(server, user.getSource(), user.getDisplayName(), args);
		if (!user.isAuthorized("essentials.helpop.receive"))
		{
			user.sendMessage(message);
		}
	}

	@Override
	public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
	{
		sendMessage(server, sender, Console.NAME, args);
	}

	private String sendMessage(final Server server, final CommandSource sender, final String from, final String[] args) throws Exception
	{
		if (args.length < 1)
		{
			throw new NotEnoughArgumentsException();
		}
		final String message = tl("helpOp", from, FormatUtil.stripFormat(getFinalArg(args, 0)));
		server.getLogger().log(Level.INFO, message);
		ess.broadcastMessage("essentials.helpop.receive", message);
		return message;
	}
}