Class ColorManager

java.lang.Object
nl.minetopiasdb.api.playerdata.ColorManager

public class ColorManager extends Object
Class for handling levelcolor, prefixcolor and chatcolor.
  • Constructor Details

    • ColorManager

      public ColorManager()
  • Method Details

    • getInstance

      public static ColorManager getInstance()
      Get the instance of ColorHandler.
      Returns:
      instance of ColorHandler.
    • getColors

      public List<String> getColors(UUID uuid, ColorType type)
      Get a list of the colors for the given player and colortype
      Parameters:
      uuid - UUID of the player
      type - colortype
      Returns:
      List of colors (with the starting '&' char)
    • getColorsWithExpiration

      public HashMap<String,​Long> getColorsWithExpiration(UUID uuid, ColorType type)
      Get a HashMap containing colors and their expiration date
      Parameters:
      uuid - UUID of the player
      type - colortype
      Returns:
      HashMap of colors (with the starting '&' char) and their expiration date in milliseconds since epoch
    • removeFromCache

      public void removeFromCache(UUID uuid, ColorType type)
      Remove given UUID from the color cache.
      Parameters:
      uuid - UUID of the player
      type - colortype
    • addColor

      public void addColor(UUID uuid, String color, ColorType type)
      Give a player access to a chatcolor. The SQL statement happens asynchronously.
      Parameters:
      uuid - UUID of the player
      color - chatcolor that player needs access to (has to start with &)
      type - colortype
    • addColor

      public CompletableFuture<Boolean> addColor(UUID uuid, ColorType type, String color, Long expiration)
      Give a player access to a chatcolor. The SQL statement happens asynchronously.
      Parameters:
      uuid - UUID of the player
      type - colortype
      color - chatcolor that player needs access to (has to start with &)
      expiration - moment of expiration, null when this color doesn't expire
      Returns:
      CompletableFuture containing a boolean that is true when adding the color was succesful
    • addColors

      public void addColors(UUID uuid, ColorType type, String... colors)
      Give a player access to multiple chatcolors at once. The SQL statement happens asynchronously.
      Parameters:
      uuid - UUID of the player
      colors - chatcolors that player needs access to (has to start with &)
      type - colortype
    • addColors

      public CompletableFuture<Integer> addColors(UUID uuid, ColorType type, Map<String,​Long> colors)
      Give a player access to multiple chatcolors at once. The SQL statement happens asynchronously.
      Parameters:
      uuid - UUID of the player
      type - colortype
      colors - Map containing chatcolors that player needs access to (has to start with &). The Map value (Long) represents expiry. A value of null or -1 will be seen as never expiring.
      Returns:
      sum of all inserted row IDs
    • removeColor

      public CompletableFuture<Boolean> removeColor(UUID uuid, ColorType type, String color)
      Revoke a player his access to a chatcolor.
      Parameters:
      uuid - UUID of the player.
      color - chatcolor that gets revoked from given player (has to start with &)
      type - colortype
      Returns:
      true if removal was successful
    • removeColor

      public void removeColor(UUID uuid, String color, ColorType type)
      Revoke a player his access to a chatcolor. The SQL statement happens asynchronously.
      Parameters:
      uuid - UUID of the player.
      color - chatcolor that gets revoked from given player (has to start with &)
      type - colortype
    • reset

      public void reset(UUID uuid, ColorType type)
      Remove all the chatcolors a player has.
      Parameters:
      uuid - UUID of the player.
      type - colortype
    • swap

      public void swap(UUID a, UUID b, ColorType type)
      Swap all colors from a specific colortype from uuid a and uuid b
      Parameters:
      a - First UUID
      b - Second UUID
      type - colortype