Class MessageBuilder

java.lang.Object
com.kamikazejam.kamicommon.util.MessageBuilder

public class MessageBuilder extends Object
A utility class for sending building messages built from a config.
The primary function of this class is to grab either a string or string list from the config.
It will detect which one to use and the server owner can configure it as either.
The secondary function of this class is to send messages translated, and with PAPI placeholders replaced
  • Constructor Details

    • MessageBuilder

      public MessageBuilder(String message)
      Creates a new MessageBuilder from a string
      Parameters:
      message - The message to send
    • MessageBuilder

      public MessageBuilder(Collection<String> lines)
      Creates a new MessageBuilder from a list of strings
      Parameters:
      lines - The lines to send
    • MessageBuilder

      public MessageBuilder(String... lines)
      Creates a new MessageBuilder from a list of strings
      Parameters:
      lines - The lines to send
    • MessageBuilder

      public MessageBuilder(ConfigurationSection section, String key)
      Creates a new MessageBuilder from a configuration key
      Parameters:
      section - The section to search the key in
      key - The key pointing to the message. This class will detect if the key points to a string or a list of strings, and then handle things accordingly.
    • MessageBuilder

      public MessageBuilder(KamiConfig config, String key)
      Creates a new MessageBuilder from a configuration key
      Parameters:
      config - The KamiConfig to search the key in
      key - The key pointing to the message. This class will detect if the key points to a string or a list of strings, and then handle things accordingly.
    • MessageBuilder

      public MessageBuilder(ConfigurationSection config, String key)
      Creates a new MessageBuilder from a configuration key
      Parameters:
      config - The ConfigurationSection to search the key in
      key - The key pointing to the message. This class will detect if the key points to a string or a list of strings, and then handle things accordingly.
    • MessageBuilder

      public MessageBuilder(FileConfiguration config, String key)
      Creates a new MessageBuilder from a configuration key
      Parameters:
      config - The FileConfiguration to search the key in
      key - The key pointing to the message. This class will detect if the key points to a string or a list of strings, and then handle things accordingly.
  • Method Details

    • of

      public static MessageBuilder of(String message)
    • of

      public static MessageBuilder of(List<String> lines)
    • of

      public static MessageBuilder of(String... lines)
    • of

      public static MessageBuilder of(ConfigurationSection config, String key)
    • of

      public static MessageBuilder of(FileConfiguration config, String key)
    • of

      public static MessageBuilder of(KamiConfig config, String key)
    • of

      public static MessageBuilder of(ConfigurationSection section, String key)
    • replace

      public MessageBuilder replace(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Replaces all instances of a string with another string
      Parameters:
      key - The string to replace
      value - The string to replace it with
      Returns:
      The MessageBuilder instance (for chaining)
    • replaceLine

      public MessageBuilder replaceLine(String find, List<String> replacement)
      Searches for the find placeholder in the text, and replaces that entire line with replacement
      Parameters:
      find - The string to search for in the lore
      replacement - The lines to swap in, in place of the entire line containing find
      Returns:
      The MessageBuilder with replaced lore
    • send

      public MessageBuilder send(@NotNull @NotNull CommandSender sender)
      Sends the message to a CommandSender
      Parameters:
      sender - The CommandSender to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • send

      public MessageBuilder send(@NotNull @NotNull CommandSender... senders)
      Sends the message to a CommandSender
      Parameters:
      senders - The CommandSender to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • send

      public MessageBuilder send(@NotNull @NotNull List<CommandSender> senders)
      Sends the message to a CommandSender
      Parameters:
      senders - The CommandSender to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • send

      public MessageBuilder send(@NotNull @NotNull Player player)
      Sends the message to a CommandSender
      Parameters:
      player - The Player to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • send

      public MessageBuilder send(@NotNull @NotNull Player... players)
      Sends the message to a CommandSender
      Parameters:
      players - The Player(s) to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • sendAll

      public MessageBuilder sendAll(boolean consoleToo)
      Sends the message to all Online Players
      Parameters:
      consoleToo - If true, the message will also be sent to the console
    • sendAll

      public MessageBuilder sendAll()
      Sends the message to all Online Players (and console)