Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
Some code cleanup
Removed not used juit Maven dependency
  • Loading branch information
Programie committed Jul 31, 2013
1 parent a61c4c7 commit bf030c5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 52 deletions.
39 changes: 17 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
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.

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

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)
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
</repositories>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/net/minearea/talkingmobs/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
45 changes: 30 additions & 15 deletions src/main/java/net/minearea/talkingmobs/Message.java
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -157,15 +169,16 @@ 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)
{
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))
{
Expand All @@ -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)
{
Expand All @@ -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);
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/minearea/talkingmobs/TalkingMobs.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -42,7 +43,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

List<String> eventTypes = new ArrayList<>();
for (Message.EventType eventType: Message.EventType.values())
for (Message.EventType eventType : Message.EventType.values())
{
eventTypes.add(eventType.toString());
}
Expand Down

0 comments on commit bf030c5

Please sign in to comment.