java.lang.Object
net.sacredlabyrinth.phaed.simpleclans.Helper

public final class Helper extends Object
Author:
phaed
  • Method Details

    • forLanguageTag

      @NotNull public static @NotNull Locale forLanguageTag(@Nullable @Nullable String languageTag)
    • toLanguageTag

      @Contract("null -> null") @Nullable public static @Nullable String toLanguageTag(@Nullable @Nullable Locale locale)
    • getPathsIn

      public static Set<Path> getPathsIn(String path, Predicate<? super Path> filter)
    • getClasses

      public static Set<Class<?>> getClasses(String packageName)
    • getSubTypesOf

      public static <T> Set<Class<? extends T>> getSubTypesOf(String packageName, Class<?> type)
    • ranksFromJson

      @Nullable public static @Nullable List<Rank> ranksFromJson(@Nullable @Nullable String json)
      Parses a list of ranks from the specified Json String
      Parameters:
      json - the Json String
      Returns:
      a list of ranks or null if the JSON String is null/empty
    • defaultRankFromJson

      @Nullable public static @Nullable String defaultRankFromJson(@Nullable @Nullable String json)
      Parses the default rank from the specified Json String
      Parameters:
      json - the Json String
      Returns:
      the default rank or null if not found and/or it does not exist
    • ranksToJson

      public static String ranksToJson(List<Rank> ranks, @Nullable @Nullable String defaultRank)
      Converts a list of ranks and the default rank to a JSON String
      Parameters:
      ranks - the ranks
      defaultRank - the default rank
      Returns:
      a JSON String
    • resignTimesToJson

      public static String resignTimesToJson(Map<String,Long> resignTimes)
      Converts a resign times map to a JSON String
      Parameters:
      resignTimes - the resign times
      Returns:
      a JSON String
    • resignTimesFromJson

      @Nullable public static @Nullable Map<String,Long> resignTimesFromJson(String json)
      Converts a JSON String to a resign times map
      Parameters:
      json - JSON String
      Returns:
      a map
    • getDelayTo

      public static long getDelayTo(int hour, int minute)
      Returns the delay in seconds to the specified hour and minute.
      Parameters:
      hour - hour
      minute - minute
      Returns:
      the delay in seconds
    • getColorName

      public static String getColorName(String playerName)
      Get a players full color name if he is online
      Parameters:
      playerName -
      Returns:
    • fromArrayToList

      public static List<String> fromArrayToList(String... values)
      Converts string array to ArrayList<String>, remove empty strings
      Parameters:
      values -
      Returns:
    • fromArrayToSet

      @Deprecated public static Set<String> fromArrayToSet(String... values)
      Deprecated.
      Converts string array to HashSet<String>, remove empty strings
      Parameters:
      values -
      Returns:
    • toArray

      public static String[] toArray(List<String> list)
      Converts ArrayList<String> to string array
      Parameters:
      list -
      Returns:
    • fromPermissionArray

      public static String[] fromPermissionArray()
      Converts the Permission values array to a String array
      Returns:
    • cleanTag

      public static String cleanTag(String tag)
      Cleans up the tag from color codes and makes it lowercase
      Parameters:
      tag -
      Returns:
    • generatePageSeparator

      public static String generatePageSeparator(String sep)
      Generates page separator line
      Parameters:
      sep -
      Returns:
    • stripOffLinePlayers

      public static List<ClanPlayer> stripOffLinePlayers(List<ClanPlayer> in)
      Remove offline players from a ClanPlayer array
      Parameters:
      in -
      Returns:
    • escapeQuotes

      public static String escapeQuotes(@Nullable @Nullable String str)
      Escapes single quotes
      Parameters:
      str -
      Returns:
    • toLocationString

      public static String toLocationString(org.bukkit.Location loc)
      Returns a prettier coordinate
      Parameters:
      loc -
      Returns:
    • sortByValue

      public static <K, V extends Comparable<V>> Map<K,V> sortByValue(Map<K,V> map)
      Sorts a Map by value
      Parameters:
      map - the Map to sort
      Returns:
      the Map sorted
    • formatMaxInactiveDays

      public static String formatMaxInactiveDays(int max)
      Formats max inactive days to an infinity symbol if it's negative or 0
      Parameters:
      max - inactive days
      Returns:
      formatted message
    • getFormattedClanStatus

      @NotNull public static @NotNull String getFormattedClanStatus(Clan clan, org.bukkit.command.CommandSender sender)