Class Utils

java.lang.Object
emu.grasscutter.utils.Utils

public final class Utils extends Object
  • Field Details

    • random

      public static final Random random
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • randomRange

      public static int randomRange(int min, int max)
    • randomFloatRange

      public static float randomFloatRange(float min, float max)
    • getDist

      public static double getDist(Position pos1, Position pos2)
    • getCurrentSeconds

      public static int getCurrentSeconds()
    • lowerCaseFirstChar

      public static String lowerCaseFirstChar(String s)
    • toString

      public static String toString(InputStream inputStream) throws IOException
      Throws:
      IOException
    • logByteArray

      public static void logByteArray(byte[] array)
    • bytesToHex

      public static String bytesToHex(byte[] bytes)
    • bytesToHex

      public static String bytesToHex(io.netty.buffer.ByteBuf buf)
    • byteBufToArray

      public static byte[] byteBufToArray(io.netty.buffer.ByteBuf buf)
    • abilityHash

      public static int abilityHash(String str)
    • toFilePath

      public static String toFilePath(String path)
      Creates a string with the path to a file.
      Parameters:
      path - The path to the file.
      Returns:
      A path using the operating system's file separator.
    • fileExists

      public static boolean fileExists(String path)
      Checks if a file exists on the file system.
      Parameters:
      path - The path to the file.
      Returns:
      True if the file exists, false otherwise.
    • createFolder

      public static boolean createFolder(String path)
      Creates a folder on the file system.
      Parameters:
      path - The path to the folder.
      Returns:
      True if the folder was created, false otherwise.
    • copyFromResources

      public static boolean copyFromResources(String resource, String destination)
      Copies a file from the archive's resources to the file system.
      Parameters:
      resource - The path to the resource.
      destination - The path to copy the resource to.
      Returns:
      True if the file was copied, false otherwise.
    • requireNonNullElseGet

      public static <T> T requireNonNullElseGet(T nonNull, T fallback)
      Get object with null fallback.
      Parameters:
      nonNull - The object to return if not null.
      fallback - The object to return if null.
      Returns:
      One of the two provided objects.
    • logObject

      public static void logObject(Object object)
      Logs an object to the console.
      Parameters:
      object - The object to log.
    • startupCheck

      public static void startupCheck()
      Checks for required files and folders before startup.
    • GetNextTimestampOfThisHour

      public static int GetNextTimestampOfThisHour(int hour, String timeZone, int param)
    • GetNextTimestampOfThisHourInNextWeek

      public static int GetNextTimestampOfThisHourInNextWeek(int hour, String timeZone, int param)
    • GetNextTimestampOfThisHourInNextMonth

      public static int GetNextTimestampOfThisHourInNextMonth(int hour, String timeZone, int param)