1
+ package com .dinnerbone .bukkit .chat .events ;
2
+
3
+ import java .util .HashMap ;
4
+ import java .util .Map ;
5
+ import org .bukkit .command .CommandSender ;
6
+ import org .bukkit .entity .Player ;
7
+ import org .bukkit .event .Event ;
8
+
9
+ /**
10
+ * Thrown when someone requests a WHOIS on a player
11
+ */
12
+ public class WhoisRequestEvent extends Event {
13
+ private final CommandSender sender ;
14
+ private final Player player ;
15
+ private final Map <String , String > result = new HashMap <String , String >();
16
+
17
+ public WhoisRequestEvent (CommandSender sender , Player player ) {
18
+ super ("WHOIS_REQUEST" );
19
+ this .sender = sender ;
20
+ this .player = player ;
21
+ }
22
+
23
+ /**
24
+ * Gets the target player to display details about
25
+ *
26
+ * @return Player target of this event
27
+ */
28
+ public Player getPlayer () {
29
+ return player ;
30
+ }
31
+
32
+ /**
33
+ * Gets the {@link CommandSender} who requested the WHOIS report
34
+ *
35
+ * @return The origin of this request
36
+ */
37
+ public CommandSender getSender () {
38
+ return sender ;
39
+ }
40
+
41
+ /**
42
+ * Sets the specified field of this report to the given value.
43
+ * Use null if you wish to remove that field.
44
+ *
45
+ * @param field Name of the field to set
46
+ * @param value New value of the field (or null to remove)
47
+ */
48
+ public void setField (String field , String value ) {
49
+ if (value == null ) {
50
+ result .remove (field );
51
+ } else {
52
+ result .put (field , value );
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Gets a field which is already collected by this report.
58
+ *
59
+ * @param field Name of the field to retrieve
60
+ * @return Value contained in that field, or null if none exist
61
+ */
62
+ public String getField (String field ) {
63
+ return result .get (field );
64
+ }
65
+
66
+ /**
67
+ * Returns all fields collected by this report so far
68
+ *
69
+ * @return Map<Name, Value> of all collected fields
70
+ */
71
+ public Map <String , String > getFields () {
72
+ return result ;
73
+ }
74
+ }
0 commit comments