Package de.kiridevs.kiricore.managers
Class MessageService
java.lang.Object
de.kiridevs.kiricore.managers.MessageService
public class MessageService
extends java.lang.Object
The MessageService class can be used to send preset messages with
preset prefixes more easily.
-
Constructor Summary
Constructors Constructor Description MessageService(java.util.Map<java.lang.String,Prefix> prefixMap, java.util.Map<java.lang.String,java.lang.String> defaultMessages)Constructor of the MessageService class. -
Method Summary
Modifier and Type Method Description voidbroadcastMessage(java.lang.String content)Sends a message to the whole server using the console version of the required "info" prefix in the prefixMapvoidbroadcastMessage(java.lang.String messageKey, @Nullable java.util.List<java.lang.String> completionArgs)Sends a message to the whole server using the console version of the required "info" prefix in the prefixMapvoidsendCustomMessage(org.bukkit.command.CommandSender recipient, java.lang.String prefixKey, java.lang.String content)Sends a message to a specified recipient using a Prefix specified before by passing it in the prefixMapvoidsendCustomMessage(org.bukkit.command.CommandSender recipient, java.lang.String prefixKey, java.lang.String messageKey, @Nullable java.util.List<java.lang.String> completionArgs)Sends a message specified before in the defaultMessages to a specified recipient using a Prefix specified before by passing it in the prefixMap.voidsendErrorMessage(org.bukkit.command.CommandSender recipient, java.lang.String content)Sends a message specified in content to the passed recipient, using the required "error" prefix in the prefixMapvoidsendErrorMessage(org.bukkit.command.CommandSender recipient, java.lang.String messageKey, @Nullable java.util.List<java.lang.String> completionArgs)Sends the preset message with the passed key to the passed recipient, using the required "error" prefix in the prefixMapvoidsendInfoMessage(org.bukkit.command.CommandSender recipient, java.lang.String content)Sends a message specified in content to the passed recipient, using the required "info" prefix in the prefixMapvoidsendInfoMessage(org.bukkit.command.CommandSender recipient, java.lang.String messageKey, @Nullable java.util.List<java.lang.String> completionArgs)Sends the preset message with the passed key to the passed recipient, using the required "info" prefix in the prefixMapvoidsendSuccessMessage(org.bukkit.command.CommandSender recipient, java.lang.String content)Sends a message specified in content to the passed recipient, using the required "success" prefix in the prefixMapvoidsendSuccessMessage(org.bukkit.command.CommandSender recipient, java.lang.String messageKey, @Nullable java.util.List<java.lang.String> completionArgs)Sends the preset message with the passed key to the passed recipient, using the required "success" prefix in the prefixMap
-
Constructor Details
-
MessageService
public MessageService(java.util.Map<java.lang.String,Prefix> prefixMap, java.util.Map<java.lang.String,java.lang.String> defaultMessages)Constructor of the MessageService class. Saves- Parameters:
prefixMap- The map to be used when resolving prefixes. Needs to contain keys "success", "error", or "info" with Non-Null values.defaultMessages- The map to be used resolving default messages. Value-Strings ("messages") can include placeholders in the format {X}, which can be replaced with their values when sending the actual messages.- Throws:
java.lang.IllegalArgumentException- Thrown when the Map passed for prefixMap doesn't include one of "success", "error" or "info"
-
-
Method Details
-
sendSuccessMessage
public void sendSuccessMessage(org.bukkit.command.CommandSender recipient, java.lang.String content)Sends a message specified in content to the passed recipient, using the required "success" prefix in the prefixMap- Parameters:
recipient- The CommandSender object to send the message tocontent- A String which will be sent to the recipient as a chat message.
-
sendSuccessMessage
public void sendSuccessMessage(org.bukkit.command.CommandSender recipient, java.lang.String messageKey, @Nullable @Nullable java.util.List<java.lang.String> completionArgs)Sends the preset message with the passed key to the passed recipient, using the required "success" prefix in the prefixMap- Parameters:
recipient- The CommandSender object to send the message tomessageKey- The key the preset message was specified with in the defaultMessagescompletionArgs- Used to add more information to placeholder-including preset messages. "{0}" in the default message will be replaced with completionArgs[0] and so on. Can be null.- Throws:
java.lang.IllegalArgumentException- Thrown when messageKey is not a valid key in the defaultMessages
-
sendErrorMessage
public void sendErrorMessage(org.bukkit.command.CommandSender recipient, java.lang.String content)Sends a message specified in content to the passed recipient, using the required "error" prefix in the prefixMap- Parameters:
recipient- The CommandSender object to send the message tocontent- A String which will be sent to the recipient as a chat message.
-
sendErrorMessage
public void sendErrorMessage(org.bukkit.command.CommandSender recipient, java.lang.String messageKey, @Nullable @Nullable java.util.List<java.lang.String> completionArgs)Sends the preset message with the passed key to the passed recipient, using the required "error" prefix in the prefixMap- Parameters:
recipient- The CommandSender object to send the message tomessageKey- The key the preset message was specified with in the defaultMessagescompletionArgs- Used to add more information to placeholder-including preset messages. "{0}" in the default message will be replaced wit completionArgs[0] and so on. Can be null.- Throws:
java.lang.IllegalArgumentException- Thrown when messageKey is not a valid key in the defaultMessages
-
sendInfoMessage
public void sendInfoMessage(org.bukkit.command.CommandSender recipient, java.lang.String content)Sends a message specified in content to the passed recipient, using the required "info" prefix in the prefixMap- Parameters:
recipient- The CommandSender object to send the message tocontent- A String which will be sent to the recipient as a chat message.
-
sendInfoMessage
public void sendInfoMessage(org.bukkit.command.CommandSender recipient, java.lang.String messageKey, @Nullable @Nullable java.util.List<java.lang.String> completionArgs)Sends the preset message with the passed key to the passed recipient, using the required "info" prefix in the prefixMap- Parameters:
recipient- The CommandSender object to send the message tomessageKey- The key the preset message was specified with in the defaultMessagescompletionArgs- Used to add more information to placeholder-including preset messages. "{0}" in the default message will be replaced with completionArgs[0] and so on. Can be null.- Throws:
java.lang.IllegalArgumentException- Thrown when messageKey is not a valid key in the defaultMessages
-
broadcastMessage
public void broadcastMessage(java.lang.String content)Sends a message to the whole server using the console version of the required "info" prefix in the prefixMap- Parameters:
content- The String which will be broadcast across the server as a chat message
-
broadcastMessage
public void broadcastMessage(java.lang.String messageKey, @Nullable @Nullable java.util.List<java.lang.String> completionArgs)Sends a message to the whole server using the console version of the required "info" prefix in the prefixMap- Parameters:
messageKey- The key of the message preset in defaultMessagescompletionArgs- Used to add more information to placeholder-including preset messages. "{0}" in the default message will be replaced with completionArgs[0] and so on. Can be null.- Throws:
java.lang.IllegalArgumentException- Thrown when the value passed in messageKey is not a valid key in defaultMessages.
-
sendCustomMessage
public void sendCustomMessage(org.bukkit.command.CommandSender recipient, java.lang.String prefixKey, java.lang.String content)Sends a message to a specified recipient using a Prefix specified before by passing it in the prefixMap- Parameters:
recipient- The CommandSender to send the message toprefixKey- The key of the prefix to use in prefixMapcontent- The String to send to the recipient as a chat message
-
sendCustomMessage
public void sendCustomMessage(org.bukkit.command.CommandSender recipient, java.lang.String prefixKey, java.lang.String messageKey, @Nullable @Nullable java.util.List<java.lang.String> completionArgs)Sends a message specified before in the defaultMessages to a specified recipient using a Prefix specified before by passing it in the prefixMap.- Parameters:
recipient- The CommandSender to send the message toprefixKey- The key of the prefix to use in prefixMapmessageKey- The key of the message to send in defaultMessagescompletionArgs- Used to add more information to placeholder-including preset messages."{0}" in the default message will be replaced with completionArgs[0] and so on. Can be null.
-