1
1
package net .minearea .talkingmobs ;
2
2
3
- import java .util .List ;
4
- import java .util .Random ;
5
- import java .util .logging .Level ;
6
3
import org .bukkit .ChatColor ;
7
4
import org .bukkit .entity .Entity ;
8
5
import org .bukkit .entity .Player ;
9
6
7
+ import java .util .List ;
8
+ import java .util .Random ;
9
+ import java .util .logging .Level ;
10
+
10
11
/**
11
12
* Class providing methods to send mob messages to players
12
13
*/
@@ -43,6 +44,7 @@ public enum EventType
43
44
44
45
/**
45
46
* Initialize the message class
47
+ *
46
48
* @param pluginInstance The instance of this plugin ('this' in TalkingMobs class)
47
49
*/
48
50
public Message (TalkingMobs pluginInstance )
@@ -52,8 +54,10 @@ public Message(TalkingMobs pluginInstance)
52
54
53
55
/**
54
56
* Get a random message for the specified mob and event type
55
- * @param mob The entity of the mob for which the message should be fetched
57
+ *
58
+ * @param mob The entity of the mob for which the message should be fetched
56
59
* @param eventType The event type of the message
60
+ *
57
61
* @return A string containing the message
58
62
*/
59
63
private String getMessage (Entity mob , EventType eventType )
@@ -87,7 +91,9 @@ private String getMessage(Entity mob, EventType eventType)
87
91
88
92
/**
89
93
* Check whether the player has the permission to receive mob messages
94
+ *
90
95
* @param player The player which should be checked
96
+ *
91
97
* @return True if the player has the permission, false otherwise
92
98
*/
93
99
private boolean isAllowed (Player player )
@@ -97,8 +103,10 @@ private boolean isAllowed(Player player)
97
103
98
104
/**
99
105
* Check if talking mobs of the specified message type is enabled for the specified player
100
- * @param player The player for which the state should be checked
106
+ *
107
+ * @param player The player for which the state should be checked
101
108
* @param eventType The message type which should be checked
109
+ *
102
110
* @return True if talking mobs of the specified type is enabled, false otherwise
103
111
*/
104
112
public boolean isEnabled (Player player , EventType eventType )
@@ -116,7 +124,9 @@ public boolean isEnabled(Player player, EventType eventType)
116
124
117
125
/**
118
126
* Check if talking mobs is enabled for the specified player
127
+ *
119
128
* @param player The player for which the state should be checked
129
+ *
120
130
* @return True if talking mobs is enabled, false otherwise
121
131
*/
122
132
public boolean isEnabled (Player player )
@@ -127,7 +137,8 @@ public boolean isEnabled(Player player)
127
137
/**
128
138
* Format the message and send it to the player
129
139
* Formatting includes replacing %player% with the name of the player and translating color codes.
130
- * @param player The player which should receive the message
140
+ *
141
+ * @param player The player which should receive the message
131
142
* @param message The message to send
132
143
*/
133
144
private void sendFormattedMessage (Player player , String message )
@@ -139,8 +150,9 @@ private void sendFormattedMessage(Player player, String message)
139
150
140
151
/**
141
152
* Send a mob message to the player
142
- * @param mob The mob which sends the message
143
- * @param player The player which should receive the message
153
+ *
154
+ * @param mob The mob which sends the message
155
+ * @param player The player which should receive the message
144
156
* @param eventType The event type
145
157
*/
146
158
public void sendMessage (Entity mob , Player player , EventType eventType )
@@ -157,15 +169,16 @@ public void sendMessage(Entity mob, Player player, EventType eventType)
157
169
158
170
/**
159
171
* Send a mob message to all players
160
- * @param mob The mob which sends the message
172
+ *
173
+ * @param mob The mob which sends the message
161
174
* @param eventType The event type
162
175
*/
163
176
public void sendMessage (Entity mob , EventType eventType )
164
177
{
165
178
String message = getMessage (mob , eventType );
166
179
if (message != null )
167
180
{
168
- for (Player player : plugin .getServer ().getOnlinePlayers ())
181
+ for (Player player : plugin .getServer ().getOnlinePlayers ())
169
182
{
170
183
if (isAllowed (player ) && isEnabled (player , eventType ))
171
184
{
@@ -177,9 +190,10 @@ public void sendMessage(Entity mob, EventType eventType)
177
190
178
191
/**
179
192
* Enable or disable talking mobs of the specified message type for the specified player
180
- * @param player The player for which the state should be changed
181
- * @param messageType The message type of which the state should be set
182
- * @param state The new state
193
+ *
194
+ * @param player The player for which the state should be changed
195
+ * @param eventType The event type of which the state should be set
196
+ * @param state The new state
183
197
*/
184
198
public void setEnabled (Player player , EventType eventType , Boolean state )
185
199
{
@@ -191,14 +205,15 @@ public void setEnabled(Player player, EventType eventType, Boolean state)
191
205
192
206
/**
193
207
* Enable or disable talking mobs for the specified player
208
+ *
194
209
* @param player The player for which the state should be changed
195
- * @param state The new state
210
+ * @param state The new state
196
211
*/
197
212
public void setEnabled (Player player , Boolean state )
198
213
{
199
214
plugin .getConfig ().set ("players." + player .getName () + ".enabled.all" , state );
200
215
201
- for (EventType eventType : EventType .values ())
216
+ for (EventType eventType : EventType .values ())
202
217
{
203
218
plugin .getConfig ().set ("players." + player .getName () + ".enabled." + eventType .toString (), state );
204
219
}
0 commit comments