Class Utils

java.lang.Object
de.craftsblock.craftsnet.utils.Utils

public class Utils extends Object
This utility class provides helper methods for general operations.
Since:
2.1.1-SNAPSHOT
  • Field Details

    • IP_SEARCHER

      public static final Pattern IP_SEARCHER
      A Pattern instance which searches for ip addresses.
    • patternGroupNameExtractPattern

      public static final Pattern patternGroupNameExtractPattern
      A regular expression pattern used to extract group names from a regular expression pattern string. This pattern matches named capturing groups defined in regular expression patterns.
  • Method Details

    • getThreadByName

      @Nullable public static @Nullable Thread getThreadByName(String name)
      Retrieves a thread by its name from the currently running threads.

      This method searches through all currently running threads and returns the thread with the specified name. If no thread with the given name is found, it returns null.

      Parameters:
      name - The name of the thread to retrieve.
      Returns:
      The thread with the specified name, or null if not found.
      Throws:
      SecurityException - If a security manager exists and its SecurityManager.checkPermission(Permission) method denies access to the current thread.
    • getGroupNames

      public static List<String> getGroupNames(Pattern pattern)
      Extracts the group names of a Pattern.
      Parameters:
      pattern - The pattern, from which the group names should be extracted.
      Returns:
      A List<String> which contains the group names in the right order.
    • getGroupNames

      public static List<String> getGroupNames(String regex)
      Extracts the group names of a Pattern.
      Parameters:
      regex - The pattern, from which the group names should be extracted.
      Returns:
      A List<String> which contains the group names in the right order.
    • blurIPs

      public static String blurIPs(String phrase)
      Blurs IPv4 and IPv6 ip addresses in an string.
      Parameters:
      phrase - The string where the readable ips are present
      Returns:
      The string containing the blurred ip addresses.
      Since:
      3.4.0-SNAPSHOT