Skip to content

Commit ddf67d6

Browse files
committed
Fixed JavaDoc
1 parent 746866e commit ddf67d6

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@
88
import org.bukkit.event.entity.EntityDamageByEntityEvent;
99
import org.bukkit.event.entity.EntityDeathEvent;
1010

11+
/**
12+
* Class providing all event listeners required for the plugin
13+
*/
1114
public class EventListener implements Listener
1215
{
1316
private final TalkingMobs plugin;
1417
private final Message message;
1518

19+
/**
20+
* Constructor of the class
21+
* @param pluginInstance The instance of this plugin (Instance of the TalkingMobs class)
22+
* @param messageInstance The instance of the Message class
23+
*/
1624
public EventListener(TalkingMobs pluginInstance, Message messageInstance)
1725
{
1826
plugin = pluginInstance;
@@ -31,6 +39,7 @@ public void onEntityAttacked(EntityDamageByEntityEvent event)
3139
{
3240
Entity damager = event.getDamager();
3341
Entity entity = event.getEntity();
42+
3443
if (damager instanceof Player && !entity.isDead())
3544
{
3645
message.sendMessage(entity, (Player) damager, Message.EventType.attacked);

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

+20-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.bukkit.entity.Player;
99

1010
/**
11-
* Class to send mob messages to players
11+
* Class providing methods to send mob messages to players
1212
*/
1313
public class Message
1414
{
@@ -50,6 +50,12 @@ public Message(TalkingMobs pluginInstance)
5050
plugin = pluginInstance;
5151
}
5252

53+
/**
54+
* 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
56+
* @param eventType The event type of the message
57+
* @return A string containing the message
58+
*/
5359
private String getMessage(Entity mob, EventType eventType)
5460
{
5561
List<String> messages;
@@ -75,6 +81,11 @@ private String getMessage(Entity mob, EventType eventType)
7581
return null;
7682
}
7783

84+
/**
85+
* Check whether the player has the permission to receive mob messages
86+
* @param player The player which should be checked
87+
* @return True if the player has the permission, false otherwise
88+
*/
7889
private boolean isAllowed(Player player)
7990
{
8091
return player.hasPermission("talkingmobs.receive");
@@ -109,6 +120,12 @@ public boolean isEnabled(Player player)
109120
return plugin.getConfig().getBoolean("players." + player.getName() + ".enabled.all", true);
110121
}
111122

123+
/**
124+
* Format the message and send it to the player
125+
* Formatting includes replacing %player% with the name of the player and translating color codes.
126+
* @param player The player which should receive the message
127+
* @param message The message to send
128+
*/
112129
private void sendFormattedMessage(Player player, String message)
113130
{
114131
String formattedMessage = message.replaceAll("%player%", player.getName());
@@ -120,7 +137,7 @@ private void sendFormattedMessage(Player player, String message)
120137
* Send a mob message to the player
121138
* @param mob The mob which sends the message
122139
* @param player The player which should receive the message
123-
* @param messageType The type of the message
140+
* @param eventType The event type
124141
*/
125142
public void sendMessage(Entity mob, Player player, EventType eventType)
126143
{
@@ -137,7 +154,7 @@ public void sendMessage(Entity mob, Player player, EventType eventType)
137154
/**
138155
* Send a mob message to all players
139156
* @param mob The mob which sends the message
140-
* @param messageType The type of the message
157+
* @param eventType The event type
141158
*/
142159
public void sendMessage(Entity mob, EventType eventType)
143160
{

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
4444
eventTypes.add(eventType.toString());
4545
}
4646

47-
sender.sendMessage("/talkingmobs toggle <type> - Toggle messages send by mobs (Type is optional and can be used to only toggle the specified message type)");
47+
sender.sendMessage("/talkingmobs toggle <type> - Toggle messages sent by mobs (Type is optional and can be used to only toggle the specified message type)");
4848
sender.sendMessage("");
4949
sender.sendMessage("Message types: " + StringUtils.join(eventTypes, ", "));
5050

@@ -60,6 +60,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
6060
{
6161
sender.sendMessage(ChatColor.RED + "You do not have the required permissions for this command!");
6262
}
63+
6364
return true;
6465
case "toggle":
6566
if (sender instanceof Player)
@@ -106,10 +107,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
106107
{
107108
sender.sendMessage(ChatColor.RED + "This command can only be run by a player!");
108109
}
110+
109111
return true;
110112
}
111113
}
112114
}
115+
113116
return false;
114117
}
115118
}

0 commit comments

Comments
 (0)