Class CommentedLanguageConfig

java.lang.Object
studio.magemonkey.codex.mccore.config.CommentedConfig
studio.magemonkey.codex.mccore.config.CommentedLanguageConfig

public class CommentedLanguageConfig extends CommentedConfig

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 Details

    • CommentedLanguageConfig

      public CommentedLanguageConfig(org.bukkit.plugin.java.JavaPlugin plugin, String file)

      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 reference
      file - path to the language file
  • Method Details

    • getMessage

      public List<String> getMessage(String key, String def)

      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
      def - The default value to be returned if one does not exist
      Returns:
      unfiltered message or null if an invalid key
    • getMessage

      public List<String> getMessage(String key)

      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 message
      player - whether or not it is for a player
      filterType - type of built-in filter to use
      filters - custom filters to use
      Returns:
      filtered message or null if an invalid key
    • sendMessage

      public void sendMessage(String key, org.bukkit.command.CommandSender target)
      Sends a message without any filters
      Parameters:
      key - key for the language message
      target - 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 message
      target - recipient of the message
      filterType - type of built-in filter to use
      filters - custom filters to use
    • sendMessage

      public void sendMessage(String key, org.bukkit.Location loc, double radius)
      Sends a message to an area without any filters
      Parameters:
      key - key for the language message
      loc - location to send the message from
      radius - 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 message
      loc - location to send the message from
      radius - radius to send the message across
      filterType - type of built-in filter to use
      filters - custom filters to use
    • sendMessage

      public void sendMessage(String key, Collection<UUID> targetIds)
      Sends a message without any filters to a list of players represented by their IDs
      Parameters:
      key - key for the language message
      targetIds - 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 message
      targetIds - ids of the recipients of the message
      filterType - type of built-in filter to use
      filters - custom filters to use