forked from EssentialsX/Essentials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandxmpp.java
More file actions
34 lines (29 loc) · 1.34 KB
/
Commandxmpp.java
File metadata and controls
34 lines (29 loc) · 1.34 KB
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
package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import org.bukkit.ChatColor;
import org.bukkit.Server;
public class Commandxmpp extends EssentialsCommand {
public Commandxmpp() {
super("xmpp");
}
@Override
protected void run(final Server server, final CommandSource 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(ChatColor.RED + "There are no players matching that name.");
return;
}
final String message = getFinalArg(args, 1);
final String senderName = sender.isPlayer() ? ess.getUser(sender.getPlayer()).getDisplayName() : Console.displayName();
sender.sendMessage("[" + senderName + ">" + address + "] " + message);
if (!EssentialsXMPP.getInstance().sendMessage(address, "[" + senderName + "] " + message)) {
sender.sendMessage(ChatColor.RED + "Error sending message.");
}
}
}