summaryrefslogtreecommitdiffstats
path: root/EssentialsChat/src/net/ess3/chat/EssentialsLocalChatEvent.java
blob: d3bafa9847cb5fa46f3afa87f452429551143a65 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package net.ess3.chat;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.AsyncPlayerChatEvent;


public class EssentialsLocalChatEvent extends Event implements Cancellable
{
	private Player player;
	private String message;
	private String format = "<%1$s> %2$s";
	private long radius;
	private boolean cancelled = false;
	private AsyncPlayerChatEvent parentEvent = null;
	private static final HandlerList handlers = new HandlerList();

	public EssentialsLocalChatEvent(final Player player, final String message, final String format, final long radius)
	{
		this.player = player;
		this.message = message;
		this.format = format;
		this.radius = radius;
	}

	public EssentialsLocalChatEvent(final AsyncPlayerChatEvent event, final long radius)
	{
		this(event.getPlayer(), event.getMessage(), event.getFormat(), radius);
		this.parentEvent = event;
	}

	@Override
	public boolean isCancelled()
	{
		return cancelled;
	}

	@Override
	public void setCancelled(final boolean cancel)
	{
		this.cancelled = cancel;
	}

	public String getMessage()
	{
		return message;
	}

	public void setMessage(final String message)
	{
		this.message = message;
	}

	public void setPlayer(final Player player)
	{
		this.player = player;
	}

	public Player getPlayer()
	{
		return player;
	}

	public String getFormat()
	{
		return format;
	}

	public void setFormat(final String format)
	{
		// Oh for a better way to do this!
		try
		{
			String.format(format, player, message);
		}
		catch (RuntimeException ex)
		{
			ex.fillInStackTrace();
			throw ex;
		}
		this.format = format;
	}

	public long getRadius()
	{
		return radius;
	}

	public void setRadius(final long radius)
	{
		this.radius = radius;
	}

	public AsyncPlayerChatEvent getParentEvent()
	{
		return parentEvent;
	}

	@Override
	public HandlerList getHandlers()
	{
		return handlers;
	}

	public static HandlerList getHandlerList()
	{
		return handlers;
	}
}