blob: b79d10f1ee5918bc8a54de35915c5d547e616f07 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
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.IReplyTo;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
public class Commandr extends EssentialsCommand
{
public Commandr()
{
super("r");
}
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
String message = getFinalArg(args, 0);
IReplyTo replyTo;
String senderName;
if (sender.isPlayer())
{
User user = ess.getUser(sender.getPlayer());
message = FormatUtil.formatMessage(user, "essentials.msg", message);
replyTo = user;
senderName = user.getDisplayName();
}
else
{
message = FormatUtil.replaceFormat(message);
replyTo = Console.getConsoleReplyTo();
senderName = Console.NAME;
}
final CommandSource target = replyTo.getReplyTo();
if (target == null || (target.isPlayer() && !target.getPlayer().isOnline()))
{
throw new Exception(tl("foreverAlone"));
}
final String targetName = target.isPlayer() ? target.getPlayer().getDisplayName() : Console.NAME;
sender.sendMessage(tl("msgFormat", tl("me"), targetName, message));
if (target.isPlayer())
{
User player = ess.getUser(target.getPlayer());
if (sender.isPlayer() && player.isIgnoredPlayer(ess.getUser(sender.getPlayer())))
{
return;
}
}
target.sendMessage(tl("msgFormat", senderName, tl("me"), message));
replyTo.setReplyTo(target);
if (target != sender)
{
if (target.isPlayer())
{
ess.getUser(target.getPlayer()).setReplyTo(sender);
}
else
{
Console.getConsoleReplyTo().setReplyTo(sender);
}
}
}
}
|