diff --git a/README.md b/README.md index b0e5eaf..725e189 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,36 @@ -TalkingMobs -=========== +# TalkingMobs A Bukkit plugin which let mobs talk to the player -Installation -============ +## Installation -Currently you have to build the project using maven to get the jar file (See section *Build*). +You can get latest jar file from [bukkit.org](http://dev.bukkit.org/bukkit-plugins/talkingmobs). -A working jar file will be provided soon. +You may also check out the project from the repository and build it yourself (See Build section). -Build -===== +## Build You can build the project in the following 2 steps: - * Check out the repository - * Build the jar file using maven: *mvn clean install* + * Check out the repository + * Build the jar file using maven: *mvn clean package* -Note: Maven is required to build the project +**Note:** JDK 1.7 and Maven is required to build the project! -Permissions -=========== +## Permissions TalkingMobs knows the following permissions: - * talkingmobs - Required to access the /talkingmobs command (Default: everyone) - * talkingmobs.receive - Allow to receive messages from mobs (Default: everyone) - * talkingmobs.reload - Allow to reload the configuration (Default: op) - * talkingmobs.* - Allow access to all features (Default: op) + * talkingmobs - Required to access the /talkingmobs command (Default: everyone) + * talkingmobs.receive - Allow to receive messages from mobs (Default: everyone) + * talkingmobs.reload - Allow to reload the configuration (Default: op) + * talkingmobs.* - Allow access to all features (Default: op) -The /talkingmobs command -======================== +## The /talkingmobs command The /talkingmobs command is the one and only command provided by this plugin. @@ -43,6 +38,6 @@ The /talkingmobs command is the one and only command provided by this plugin. The following sub commands are currently available: - * help - Show the help of the plugin - * reload - Reload the configuration - * toggle [type] - Toggle messages sent by mobs (Type is optional and can be used to only toggle the specified event type) + * help - Show the help of the plugin + * reload - Reload the configuration + * toggle [type] - Toggle messages sent by mobs (Type is optional and can be used to only toggle the specified event type) \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8313268..54386ff 100644 --- a/pom.xml +++ b/pom.xml @@ -21,12 +21,6 @@ - - junit - junit - 3.8.1 - test - org.bukkit bukkit diff --git a/src/main/java/net/minearea/talkingmobs/EventListener.java b/src/main/java/net/minearea/talkingmobs/EventListener.java index 1809a1a..d2e81a1 100644 --- a/src/main/java/net/minearea/talkingmobs/EventListener.java +++ b/src/main/java/net/minearea/talkingmobs/EventListener.java @@ -13,19 +13,17 @@ /** * Class providing all event listeners required for the plugin */ -public class EventListener implements Listener +class EventListener implements Listener { - private final TalkingMobs plugin; private final Message message; /** * Constructor of the class - * @param pluginInstance The instance of this plugin (Instance of the TalkingMobs class) + * * @param messageInstance The instance of the Message class */ - public EventListener(TalkingMobs pluginInstance, Message messageInstance) + public EventListener(Message messageInstance) { - plugin = pluginInstance; message = messageInstance; } diff --git a/src/main/java/net/minearea/talkingmobs/Message.java b/src/main/java/net/minearea/talkingmobs/Message.java index 858de87..bb23e17 100644 --- a/src/main/java/net/minearea/talkingmobs/Message.java +++ b/src/main/java/net/minearea/talkingmobs/Message.java @@ -1,12 +1,13 @@ package net.minearea.talkingmobs; -import java.util.List; -import java.util.Random; -import java.util.logging.Level; import org.bukkit.ChatColor; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import java.util.List; +import java.util.Random; +import java.util.logging.Level; + /** * Class providing methods to send mob messages to players */ @@ -43,6 +44,7 @@ public enum EventType /** * Initialize the message class + * * @param pluginInstance The instance of this plugin ('this' in TalkingMobs class) */ public Message(TalkingMobs pluginInstance) @@ -52,8 +54,10 @@ public Message(TalkingMobs pluginInstance) /** * Get a random message for the specified mob and event type - * @param mob The entity of the mob for which the message should be fetched + * + * @param mob The entity of the mob for which the message should be fetched * @param eventType The event type of the message + * * @return A string containing the message */ private String getMessage(Entity mob, EventType eventType) @@ -87,7 +91,9 @@ private String getMessage(Entity mob, EventType eventType) /** * Check whether the player has the permission to receive mob messages + * * @param player The player which should be checked + * * @return True if the player has the permission, false otherwise */ private boolean isAllowed(Player player) @@ -97,8 +103,10 @@ private boolean isAllowed(Player player) /** * Check if talking mobs of the specified message type is enabled for the specified player - * @param player The player for which the state should be checked + * + * @param player The player for which the state should be checked * @param eventType The message type which should be checked + * * @return True if talking mobs of the specified type is enabled, false otherwise */ public boolean isEnabled(Player player, EventType eventType) @@ -116,7 +124,9 @@ public boolean isEnabled(Player player, EventType eventType) /** * Check if talking mobs is enabled for the specified player + * * @param player The player for which the state should be checked + * * @return True if talking mobs is enabled, false otherwise */ public boolean isEnabled(Player player) @@ -127,7 +137,8 @@ public boolean isEnabled(Player player) /** * Format the message and send it to the player * Formatting includes replacing %player% with the name of the player and translating color codes. - * @param player The player which should receive the message + * + * @param player The player which should receive the message * @param message The message to send */ private void sendFormattedMessage(Player player, String message) @@ -139,8 +150,9 @@ private void sendFormattedMessage(Player player, String message) /** * Send a mob message to the player - * @param mob The mob which sends the message - * @param player The player which should receive the message + * + * @param mob The mob which sends the message + * @param player The player which should receive the message * @param eventType The event type */ public void sendMessage(Entity mob, Player player, EventType eventType) @@ -157,7 +169,8 @@ public void sendMessage(Entity mob, Player player, EventType eventType) /** * Send a mob message to all players - * @param mob The mob which sends the message + * + * @param mob The mob which sends the message * @param eventType The event type */ public void sendMessage(Entity mob, EventType eventType) @@ -165,7 +178,7 @@ public void sendMessage(Entity mob, EventType eventType) String message = getMessage(mob, eventType); if (message != null) { - for (Player player: plugin.getServer().getOnlinePlayers()) + for (Player player : plugin.getServer().getOnlinePlayers()) { if (isAllowed(player) && isEnabled(player, eventType)) { @@ -177,9 +190,10 @@ public void sendMessage(Entity mob, EventType eventType) /** * Enable or disable talking mobs of the specified message type for the specified player - * @param player The player for which the state should be changed - * @param messageType The message type of which the state should be set - * @param state The new state + * + * @param player The player for which the state should be changed + * @param eventType The event type of which the state should be set + * @param state The new state */ public void setEnabled(Player player, EventType eventType, Boolean state) { @@ -191,14 +205,15 @@ public void setEnabled(Player player, EventType eventType, Boolean state) /** * Enable or disable talking mobs for the specified player + * * @param player The player for which the state should be changed - * @param state The new state + * @param state The new state */ public void setEnabled(Player player, Boolean state) { plugin.getConfig().set("players." + player.getName() + ".enabled.all", state); - for (EventType eventType: EventType.values()) + for (EventType eventType : EventType.values()) { plugin.getConfig().set("players." + player.getName() + ".enabled." + eventType.toString(), state); } diff --git a/src/main/java/net/minearea/talkingmobs/TalkingMobs.java b/src/main/java/net/minearea/talkingmobs/TalkingMobs.java index 5e58280..167d0c2 100644 --- a/src/main/java/net/minearea/talkingmobs/TalkingMobs.java +++ b/src/main/java/net/minearea/talkingmobs/TalkingMobs.java @@ -1,7 +1,5 @@ package net.minearea.talkingmobs; -import java.util.ArrayList; -import java.util.List; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -10,6 +8,9 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import java.util.ArrayList; +import java.util.List; + public final class TalkingMobs extends JavaPlugin { private final Message message = new Message(this); @@ -21,7 +22,7 @@ public void onEnable() saveConfig(); PluginManager pluginManager = getServer().getPluginManager(); - pluginManager.registerEvents(new EventListener(this, message), this); + pluginManager.registerEvents(new EventListener(message), this); } @Override @@ -42,7 +43,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } List eventTypes = new ArrayList<>(); - for (Message.EventType eventType: Message.EventType.values()) + for (Message.EventType eventType : Message.EventType.values()) { eventTypes.add(eventType.toString()); }