Interface AdditionsUtils


public interface AdditionsUtils
General Utils class that holds general utility methods.
  • Method Details

    • getLanguage

      String getLanguage(ActionSender sender)
      Get the Vault language of a sender.
      Parameters:
      sender - Sender to check.
      Returns:
      Vault language when found, null otherwise.
    • getLanguage

      String getLanguage(org.bukkit.entity.Player player)
      Get the Vault language of a player.
      Parameters:
      player - Player to check.
      Returns:
      Vault language when found, null otherwise.
    • sendCenteredMessage

      void sendCenteredMessage(ActionSender player, String message)
      Send a horizontally centered message to the player.
      Parameters:
      player - Player to send the message to.
      message - Message to send.
    • getGameMode

      org.bukkit.GameMode getGameMode(String input)
      Get the GameMode from a string.
      Parameters:
      input - String to check.
      Returns:
      GameMode when found, null otherwise.
    • evaluate

      double evaluate(String input)
      Resolve a mathematical expression with JavaScript.
      Parameters:
      input - Expression to resolve.
      Returns:
      Result of the expression.
    • c

      String c(String message)
      Color a string.
      Parameters:
      message - String to color.
      Returns:
      Colored String.
    • logToConsole

      void logToConsole(String message, boolean severe)
      Log a message to the console.
      Parameters:
      message - Message to log.
      severe - Whether it should be sent as an error.
    • calculateChance

      boolean calculateChance(double chance)
      Calculate if a random number between 0-100 is lower than the given chance.
      Parameters:
      chance - Chance to check.
      Returns:
      true when validated, false otherwise.
    • executeScript

      String executeScript(String script)
      Execute a JavaScript script.
      Parameters:
      script - Piece of code to execute.
      Returns:
      The result of the script.
    • calculateIfChances

      boolean calculateIfChances(String value)
      Execute the [IF] action parameters and check if they are true.
      Parameters:
      value - Value of the IF action to check.
      Returns:
      true when script equals true, false otherwise.
    • parseStatics

      String parseStatics(String message, ActionSender sender)
      Parse all placeholders of a player to the message. Supports PAPI and MvdW PAPI.
      Parameters:
      message - Message to parse.
      sender - Placeholder owner.
      Returns:
      String with parsed placeholders.
    • parseStatics

      List<String> parseStatics(List<String> messages, ActionSender sender)
      Parse all placeholders of a player to the messages. Supports PAPI and MvdW PAPI.
      Parameters:
      messages - Messages to parse.
      sender - Placeholder owner.
      Returns:
      List of String with parsed placeholders.
    • parseStatics

      String parseStatics(String message, org.bukkit.entity.Player player)
      Parse all placeholders of a player to the message. Supports PAPI and MvdW PAPI.
      Parameters:
      message - Message to parse.
      player - Placeholder owner.
      Returns:
      String with parsed placeholders.
    • c

      List<String> c(List<String> messages)
      Color a list of strings.
      Parameters:
      messages - List of String to color.
      Returns:
      List of colored String.
    • sendCooldownMessage

      void sendCooldownMessage(org.bukkit.entity.Player player, String message, long cooldown)
      Send the cooldown message to a player. Replaces %time% with the formatted cooldown time.
      Parameters:
      player - Player to send message to.
      message - Message to send.
      cooldown - Cooldown in ticks.
    • isInt

      boolean isInt(String string)
      Check if a string is an integer.
      Parameters:
      string - String to check.
      Returns:
      true when integer, false otherwise.
    • isLong

      boolean isLong(String string)
      Check if a string is a long.
      Parameters:
      string - String to check.
      Returns:
      true when long, false otherwise.
    • isDouble

      boolean isDouble(String string)
      Check if a string is a double.
      Parameters:
      string - String to check.
      Returns:
      true when double, false otherwise.
    • isFloat

      boolean isFloat(String string)
      Check if a string is a float.
      Parameters:
      string - String to check.
      Returns:
      true when float, false otherwise.
    • isBoolean

      boolean isBoolean(String string)
      Check if a string is a boolean.
      Parameters:
      string - String to check.
      Returns:
      true when boolean, false otherwise.
    • replaceHEXColors

      String replaceHEXColors(String message)
      Replace all HEX colors with bukkit encoding in a string.
      Parameters:
      message - String to replace HEX colors of.
      Returns:
      Same string with bukkit encoded colors instead of raw HEXes.
    • getHEXColor

      org.bukkit.Color getHEXColor(String message)
      Get the HEX color from a string. Could start with or without #, in format of RGB or RRGGBB.
      Parameters:
      message - String to get the hex color of.
      Returns:
      Color when found, null otherwise.
    • getCommandMap

      org.bukkit.command.CommandMap getCommandMap()
      Get the Bukkit command map used for registering commands.
      Returns:
      Bukkit CommandMap.
    • registerCommand

      void registerCommand(String plugin, org.bukkit.command.Command command)
      Register a command to Bukkit.
      Parameters:
      plugin - Name of the plugin that the command belongs to.
      command - Command to register.
    • setTotalExperience

      void setTotalExperience(org.bukkit.entity.Player player, int experience)
      Set the total experience of a player.
      Parameters:
      player - Player to update.
      experience - Number of experience to set.
    • getExpAtLevel

      int getExpAtLevel(int level)
      Get the Bukkit experience required for one level.
      Parameters:
      level - Level to get the experience of.
      Returns:
      number of experience needed for that level.
    • determinePlayerTablist

      StringBuilder[] determinePlayerTablist(org.bukkit.entity.Player player)
      Get the header and footer of the tablist group of the player.
      Parameters:
      player - Player to check.
      Returns:
      Array of StringBuilder with the Header and Footer, null when not found.
    • getArrayFrom

      String getArrayFrom(String[] array, int start, int end)
      Get a sublist of an array as a string, joined by a space.
      Parameters:
      array - String array to join.
      start - Start index to start joining from (inclusive).
      end - End index to stop joining at (exlusive).
      Returns:
      All array sublist items joined by a space.
    • getArrayFrom

      String getArrayFrom(String[] array, int start)
      Get a sublist of an array as a string, joined by a space.
      Parameters:
      array - String array to join.
      start - Start index to start joining from (inclusive).
      Returns:
      All array sublist items joined by a space.