summaryrefslogtreecommitdiffstats
path: root/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java
blob: 84d207e8c455b1dbf54f195f5cb152565e1d001f (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
package com.earth2me.essentials.xmpp;

import com.earth2me.essentials.Console;
import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;


public class Commandxmpp extends EssentialsCommand
{
	public Commandxmpp()
	{
		super("xmpp");
	}

	@Override
	protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException
	{
		if (args.length < 2)
		{
			throw new NotEnoughArgumentsException();
		}

		final String address = EssentialsXMPP.getInstance().getAddress(args[0]);
		if (address == null)
		{
			sender.sendMessage("§cThere are no players matching that name.");
		}
		else
		{
			final String message = getFinalArg(args, 1);
			final String senderName = sender instanceof Player ? ess.getUser(sender).getDisplayName() : Console.NAME;
			sender.sendMessage("[" + senderName + ">" + address + "] " + message);
			EssentialsXMPP.getInstance().sendMessage(address, "[" + senderName + "] " + message);
		}
	}
}