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
|
package com.earth2me.essentials.chat;
import com.earth2me.essentials.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import java.util.Map;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerChatEvent;
public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer
{
public EssentialsChatPlayerListenerNormal(Server server, IEssentials ess, Map<String, IEssentialsChatListener> listeners)
{
super(server, ess, listeners);
}
@Override
public void onPlayerChat(final PlayerChatEvent event)
{
if (isAborted(event))
{
return;
}
/**
* This file should handle detection of the local chat features... if local chat is enabled, we need to handle
* it here
*/
final User user = ess.getUser(event.getPlayer());
final String chatType = getChatType(event.getMessage());
long radius = ess.getSettings().getChatRadius();
if (radius < 1)
{
return;
}
radius *= radius;
try
{
if (event.getMessage().length() > 0 && chatType.length() > 0)
{
StringBuilder permission = new StringBuilder();
permission.append("essentials.chat.").append(chatType);
StringBuilder command = new StringBuilder();
command.append("chat-").append(chatType);
StringBuilder format = new StringBuilder();
format.append(chatType).append("Format");
StringBuilder errorMsg = new StringBuilder();
errorMsg.append("notAllowedTo").append(chatType.substring(0, 1).toUpperCase()).append(chatType.substring(1));
if (user.isAuthorized(permission.toString()))
{
charge(user, command.toString());
event.setMessage(event.getMessage().substring(1));
event.setFormat(_(format.toString(), event.getFormat()));
return;
}
user.sendMessage(_(errorMsg.toString()));
event.setCancelled(true);
return;
}
}
catch (ChargeException ex)
{
ess.showError(user, ex, "Shout");
event.setCancelled(true);
return;
}
sendLocalChat(user, radius, event);
}
}
|