Class CommentedLanguageConfig
A special kind of configuration for handling language files
Provides methods for sending and retrieving messages from the configuration for both players and the console using various kinds of filters.
The language configuration works off of the defaults you include in the file when you build your plugin. At least one default is required to instantiate this class.
This config supports comments and UTF-8 encoding for Strings.
-
Constructor Summary
ConstructorsConstructorDescriptionCommentedLanguageConfig(org.bukkit.plugin.java.JavaPlugin plugin, String file) Constructs a language config from the defaults in the file -
Method Summary
Modifier and TypeMethodDescriptiongetMessage(String key) Gets a message without any filtersgetMessage(String key, boolean player, FilterType filterType, CustomFilter... filters) Gets a message using the provided filtersgetMessage(String key, String def) Gets a message without any filtersvoidsendMessage(String key, Collection<UUID> targetIds) Sends a message without any filters to a list of players represented by their IDsvoidsendMessage(String key, Collection<UUID> targetIds, FilterType filterType, CustomFilter... filters) Sends a message using the provided filters to a list of players represented by their IDsvoidsendMessage(String key, org.bukkit.command.CommandSender target) Sends a message without any filtersvoidsendMessage(String key, org.bukkit.command.CommandSender target, FilterType filterType, CustomFilter... filters) Sends a message using the provided filtersvoidsendMessage(String key, org.bukkit.Location loc, double radius) Sends a message to an area without any filtersvoidsendMessage(String key, org.bukkit.Location loc, double radius, FilterType filterType, CustomFilter... filters) Sends a message to an area using the provided filtersMethods inherited from class studio.magemonkey.codex.mccore.config.CommentedConfig
checkDefaults, clear, getConfig, getConfigFile, getFileName, getPlugin, reload, save, saveDefaultConfig, trim
-
Constructor Details
-
CommentedLanguageConfig
Constructs a language config from the defaults in the file
If no default exists, an exception will be thrown because no messages would be available.
- Parameters:
plugin- plugin referencefile- path to the language file
-
-
Method Details
-
getMessage
Gets a message without any filters
You can use this method instead of the sendMessage methods if you want to manipulate the string outside of the provided filters before sending the message.
- Parameters:
key- key for the language messagedef- The default value to be returned if one does not exist- Returns:
- unfiltered message or null if an invalid key
-
getMessage
Gets a message without any filters
You can use this method instead of the sendMessage methods if you want to manipulate the string outside of the provided filters before sending the message.
- Parameters:
key- key for the language message- Returns:
- unfiltered message or null if an invalid key
-
getMessage
public List<String> getMessage(String key, boolean player, FilterType filterType, CustomFilter... filters) Gets a message using the provided filters
You can use this method instead of the sendMessage methods if you want to manipulate the string outside of the provided filters before sending the message.
If the key is not in the language configuration, null will be returned
- Parameters:
key- key for the language messageplayer- whether or not it is for a playerfilterType- type of built-in filter to usefilters- custom filters to use- Returns:
- filtered message or null if an invalid key
-
sendMessage
Sends a message without any filters- Parameters:
key- key for the language messagetarget- recipient of the message
-
sendMessage
public void sendMessage(String key, org.bukkit.command.CommandSender target, FilterType filterType, CustomFilter... filters) Sends a message using the provided filters- Parameters:
key- key for the language messagetarget- recipient of the messagefilterType- type of built-in filter to usefilters- custom filters to use
-
sendMessage
Sends a message to an area without any filters- Parameters:
key- key for the language messageloc- location to send the message fromradius- radius to send the message across
-
sendMessage
public void sendMessage(String key, org.bukkit.Location loc, double radius, FilterType filterType, CustomFilter... filters) Sends a message to an area using the provided filters- Parameters:
key- key for the language messageloc- location to send the message fromradius- radius to send the message acrossfilterType- type of built-in filter to usefilters- custom filters to use
-
sendMessage
Sends a message without any filters to a list of players represented by their IDs- Parameters:
key- key for the language messagetargetIds- ids of the recipients of the message
-
sendMessage
public void sendMessage(String key, Collection<UUID> targetIds, FilterType filterType, CustomFilter... filters) Sends a message using the provided filters to a list of players represented by their IDs- Parameters:
key- key for the language messagetargetIds- ids of the recipients of the messagefilterType- type of built-in filter to usefilters- custom filters to use
-