Package redempt.redlib.commandmanager
Class Messages
java.lang.Object
redempt.redlib.commandmanager.Messages
Represents a list of messages loaded from a file with defaults
-
Method Summary
Modifier and TypeMethodDescriptionGets a color-formatted message by namestatic MessagesgetLoaded(org.bukkit.plugin.Plugin plugin) Gets the Messages which have been loaded for a specific plugin, if they existorg.bukkit.plugin.Pluginstatic Messagesload(InputStream defaults, Path path) Loads messages from a file and writes missing defaultsstatic Messagesload(org.bukkit.plugin.Plugin plugin) Loads messages from a file, messages.txt, and writes missing defaults loaded from the plugin resource called messages.txtstatic Messagesload(org.bukkit.plugin.Plugin plugin, InputStream defaults) Loads messages from a file, messages.txt, and writes missing defaultsstatic Messagesload(org.bukkit.plugin.Plugin plugin, InputStream defaults, String filename) Loads messages from a file and writes missing defaultsstatic StringDetermines which plugin is calling this method, finds its loaded messages, and returns the message with the given name.setFormatter(UnaryOperator<String> formatter) Sets the function which will be used to format message strings before they are returned
-
Method Details
-
load
Loads messages from a file and writes missing defaults- Parameters:
defaults- The InputStream for default messages. UsePlugin.getResource(String)for this.path- The path of the file in the plugin folder to load messages from- Returns:
- The Messages instance with messages loaded.
-
load
Loads messages from a file and writes missing defaults- Parameters:
plugin- The plugin loading the messagesdefaults- The InputStream for default messages. UsePlugin.getResource(String)for this.filename- The name of the file in the plugin folder to load messages from- Returns:
- The Messages instance with messages loaded.
-
getLoaded
Gets the Messages which have been loaded for a specific plugin, if they exist- Parameters:
plugin- The plugin to get the Messages for- Returns:
- The Messages object, or null
-
load
Loads messages from a file, messages.txt, and writes missing defaults- Parameters:
plugin- The plugin loading the messagesdefaults- The InputStream for default messages. UsePlugin.getResource(String)for this.- Returns:
- The Messages instance with messages loaded.
-
load
Loads messages from a file, messages.txt, and writes missing defaults loaded from the plugin resource called messages.txt- Parameters:
plugin- The plugin loading the messages- Returns:
- The Messages instance with messages loaded.
-
msg
Determines which plugin is calling this method, finds its loaded messages, and returns the message with the given name.- Parameters:
message- The name of the message- Returns:
- The message, which has been formatted with & as the color character.
- Throws:
IllegalStateException- if your plugin has not loaded any messages
-
setFormatter
Sets the function which will be used to format message strings before they are returned- Parameters:
formatter- The function to format messages- Returns:
- Itself
-
getPlugin
public org.bukkit.plugin.Plugin getPlugin()- Returns:
- The plugin these messages belong to
-
get
Gets a color-formatted message by name- Parameters:
msg- The name of the message- Returns:
- The message, which has been formatted with & as the color character.
-