forked from konatakun/powerbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessageEvent.java
66 lines (54 loc) · 1.41 KB
/
MessageEvent.java
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
package org.powerbot.script;
import java.util.EventListener;
import org.powerbot.bot.AbstractEvent;
/**
* MessageEvent
* An event that represents a message sent by the game to the chat box.
*/
public class MessageEvent extends AbstractEvent {
public static final int MESSAGE_EVENT = 0x20;
private static final long serialVersionUID = 4178447203851407187L;
private final int id;
private final String source, message;
public MessageEvent(final org.powerbot.bot.rt6.client.MessageEntry entry) {
this(entry.getType(), entry.getSender(), entry.getMessage());
}
public MessageEvent(final org.powerbot.bot.rt4.client.MessageEntry entry) {
this(entry.getType(), entry.getSender(), entry.getMessage());
}
public MessageEvent(final int id, final String source, final String message) {
super(MESSAGE_EVENT);
this.id = id;
this.source = source;
this.message = message;
}
/**
* {@inheritDoc}
*/
@Override
public void call(final EventListener eventListener) {
((MessageListener) eventListener).messaged(this);
}
/**
* @return the id of this message.
*/
public int type() {
return id;
}
/**
* @return the name of the sender of this message
*/
public String source() {
return source;
}
/**
* @return the contents of this message
*/
public String text() {
return message;
}
@Override
public String toString() {
return String.format("(%d) [%s]: %s%n", id, source, message);
}
}