Skip to content

Commit bf030c5

Browse files
committed
Updated README
Some code cleanup Removed not used juit Maven dependency
1 parent a61c4c7 commit bf030c5

File tree

5 files changed

+55
-52
lines changed

5 files changed

+55
-52
lines changed

README.md

+17-22
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,43 @@
1-
TalkingMobs
2-
===========
1+
# TalkingMobs
32

43
A Bukkit plugin which let mobs talk to the player
54

65

7-
Installation
8-
============
6+
## Installation
97

10-
Currently you have to build the project using maven to get the jar file (See section *Build*).
8+
You can get latest jar file from [bukkit.org](http://dev.bukkit.org/bukkit-plugins/talkingmobs).
119

12-
A working jar file will be provided soon.
10+
You may also check out the project from the repository and build it yourself (See Build section).
1311

1412

15-
Build
16-
=====
13+
## Build
1714

1815
You can build the project in the following 2 steps:
1916

20-
* Check out the repository
21-
* Build the jar file using maven: *mvn clean install*
17+
* Check out the repository
18+
* Build the jar file using maven: *mvn clean package*
2219

23-
Note: Maven is required to build the project
20+
**Note:** JDK 1.7 and Maven is required to build the project!
2421

2522

26-
Permissions
27-
===========
23+
## Permissions
2824

2925
TalkingMobs knows the following permissions:
3026

31-
* talkingmobs - Required to access the /talkingmobs command (Default: everyone)
32-
* talkingmobs.receive - Allow to receive messages from mobs (Default: everyone)
33-
* talkingmobs.reload - Allow to reload the configuration (Default: op)
34-
* talkingmobs.* - Allow access to all features (Default: op)
27+
* talkingmobs - Required to access the /talkingmobs command (Default: everyone)
28+
* talkingmobs.receive - Allow to receive messages from mobs (Default: everyone)
29+
* talkingmobs.reload - Allow to reload the configuration (Default: op)
30+
* talkingmobs.* - Allow access to all features (Default: op)
3531

3632

37-
The /talkingmobs command
38-
========================
33+
## The /talkingmobs command
3934

4035
The /talkingmobs command is the one and only command provided by this plugin.
4136

4237
*Usage: /talkingmobs [subcommand] [arguments]*
4338

4439
The following sub commands are currently available:
4540

46-
* help - Show the help of the plugin
47-
* reload - Reload the configuration
48-
* toggle [type] - Toggle messages sent by mobs (Type is optional and can be used to only toggle the specified event type)
41+
* help - Show the help of the plugin
42+
* reload - Reload the configuration
43+
* toggle [type] - Toggle messages sent by mobs (Type is optional and can be used to only toggle the specified event type)

pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
</repositories>
2222

2323
<dependencies>
24-
<dependency>
25-
<groupId>junit</groupId>
26-
<artifactId>junit</artifactId>
27-
<version>3.8.1</version>
28-
<scope>test</scope>
29-
</dependency>
3024
<dependency>
3125
<groupId>org.bukkit</groupId>
3226
<artifactId>bukkit</artifactId>

src/main/java/net/minearea/talkingmobs/EventListener.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@
1313
/**
1414
* Class providing all event listeners required for the plugin
1515
*/
16-
public class EventListener implements Listener
16+
class EventListener implements Listener
1717
{
18-
private final TalkingMobs plugin;
1918
private final Message message;
2019

2120
/**
2221
* Constructor of the class
23-
* @param pluginInstance The instance of this plugin (Instance of the TalkingMobs class)
22+
*
2423
* @param messageInstance The instance of the Message class
2524
*/
26-
public EventListener(TalkingMobs pluginInstance, Message messageInstance)
25+
public EventListener(Message messageInstance)
2726
{
28-
plugin = pluginInstance;
2927
message = messageInstance;
3028
}
3129

src/main/java/net/minearea/talkingmobs/Message.java

+30-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package net.minearea.talkingmobs;
22

3-
import java.util.List;
4-
import java.util.Random;
5-
import java.util.logging.Level;
63
import org.bukkit.ChatColor;
74
import org.bukkit.entity.Entity;
85
import org.bukkit.entity.Player;
96

7+
import java.util.List;
8+
import java.util.Random;
9+
import java.util.logging.Level;
10+
1011
/**
1112
* Class providing methods to send mob messages to players
1213
*/
@@ -43,6 +44,7 @@ public enum EventType
4344

4445
/**
4546
* Initialize the message class
47+
*
4648
* @param pluginInstance The instance of this plugin ('this' in TalkingMobs class)
4749
*/
4850
public Message(TalkingMobs pluginInstance)
@@ -52,8 +54,10 @@ public Message(TalkingMobs pluginInstance)
5254

5355
/**
5456
* 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
5659
* @param eventType The event type of the message
60+
*
5761
* @return A string containing the message
5862
*/
5963
private String getMessage(Entity mob, EventType eventType)
@@ -87,7 +91,9 @@ private String getMessage(Entity mob, EventType eventType)
8791

8892
/**
8993
* Check whether the player has the permission to receive mob messages
94+
*
9095
* @param player The player which should be checked
96+
*
9197
* @return True if the player has the permission, false otherwise
9298
*/
9399
private boolean isAllowed(Player player)
@@ -97,8 +103,10 @@ private boolean isAllowed(Player player)
97103

98104
/**
99105
* 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
101108
* @param eventType The message type which should be checked
109+
*
102110
* @return True if talking mobs of the specified type is enabled, false otherwise
103111
*/
104112
public boolean isEnabled(Player player, EventType eventType)
@@ -116,7 +124,9 @@ public boolean isEnabled(Player player, EventType eventType)
116124

117125
/**
118126
* Check if talking mobs is enabled for the specified player
127+
*
119128
* @param player The player for which the state should be checked
129+
*
120130
* @return True if talking mobs is enabled, false otherwise
121131
*/
122132
public boolean isEnabled(Player player)
@@ -127,7 +137,8 @@ public boolean isEnabled(Player player)
127137
/**
128138
* Format the message and send it to the player
129139
* 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
131142
* @param message The message to send
132143
*/
133144
private void sendFormattedMessage(Player player, String message)
@@ -139,8 +150,9 @@ private void sendFormattedMessage(Player player, String message)
139150

140151
/**
141152
* 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
144156
* @param eventType The event type
145157
*/
146158
public void sendMessage(Entity mob, Player player, EventType eventType)
@@ -157,15 +169,16 @@ public void sendMessage(Entity mob, Player player, EventType eventType)
157169

158170
/**
159171
* 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
161174
* @param eventType The event type
162175
*/
163176
public void sendMessage(Entity mob, EventType eventType)
164177
{
165178
String message = getMessage(mob, eventType);
166179
if (message != null)
167180
{
168-
for (Player player: plugin.getServer().getOnlinePlayers())
181+
for (Player player : plugin.getServer().getOnlinePlayers())
169182
{
170183
if (isAllowed(player) && isEnabled(player, eventType))
171184
{
@@ -177,9 +190,10 @@ public void sendMessage(Entity mob, EventType eventType)
177190

178191
/**
179192
* 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
183197
*/
184198
public void setEnabled(Player player, EventType eventType, Boolean state)
185199
{
@@ -191,14 +205,15 @@ public void setEnabled(Player player, EventType eventType, Boolean state)
191205

192206
/**
193207
* Enable or disable talking mobs for the specified player
208+
*
194209
* @param player The player for which the state should be changed
195-
* @param state The new state
210+
* @param state The new state
196211
*/
197212
public void setEnabled(Player player, Boolean state)
198213
{
199214
plugin.getConfig().set("players." + player.getName() + ".enabled.all", state);
200215

201-
for (EventType eventType: EventType.values())
216+
for (EventType eventType : EventType.values())
202217
{
203218
plugin.getConfig().set("players." + player.getName() + ".enabled." + eventType.toString(), state);
204219
}

src/main/java/net/minearea/talkingmobs/TalkingMobs.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package net.minearea.talkingmobs;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
53
import org.apache.commons.lang.StringUtils;
64
import org.bukkit.ChatColor;
75
import org.bukkit.command.Command;
@@ -10,6 +8,9 @@
108
import org.bukkit.plugin.PluginManager;
119
import org.bukkit.plugin.java.JavaPlugin;
1210

11+
import java.util.ArrayList;
12+
import java.util.List;
13+
1314
public final class TalkingMobs extends JavaPlugin
1415
{
1516
private final Message message = new Message(this);
@@ -21,7 +22,7 @@ public void onEnable()
2122
saveConfig();
2223

2324
PluginManager pluginManager = getServer().getPluginManager();
24-
pluginManager.registerEvents(new EventListener(this, message), this);
25+
pluginManager.registerEvents(new EventListener(message), this);
2526
}
2627

2728
@Override
@@ -42,7 +43,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
4243
}
4344

4445
List<String> eventTypes = new ArrayList<>();
45-
for (Message.EventType eventType: Message.EventType.values())
46+
for (Message.EventType eventType : Message.EventType.values())
4647
{
4748
eventTypes.add(eventType.toString());
4849
}

0 commit comments

Comments
 (0)