blob: 22989d4f9806327b70203d778a4330400fddbddd (
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
|
package com.earth2me.essentials.chat;
import com.earth2me.essentials.ChargeException;
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 EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer
{
private final transient Map<PlayerChatEvent, String> charges;
public EssentialsChatPlayerListenerHighest(final Server server,
final IEssentials ess,
final Map<String, IEssentialsChatListener> listeners,
final Map<PlayerChatEvent, String> charges)
{
super(server, ess, listeners);
this.charges = charges;
}
@Override
public void onPlayerChat(final PlayerChatEvent event)
{
String charge = charges.remove(event);
if (charge == null)
{
charge = "chat";
}
if (isAborted(event))
{
return;
}
/**
* This file should handle charging the user for the action before returning control back
*/
final User user = ess.getUser(event.getPlayer());
try
{
charge(user, charge);
}
catch (ChargeException e)
{
ess.showError(user, e, charge);
event.setCancelled(true);
return;
}
}
}
|