Package emu.grasscutter.utils
Class Utils
java.lang.Object
emu.grasscutter.utils.Utils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intabilityHash(String str) static byte[]byteBufToArray(io.netty.buffer.ByteBuf buf) static StringbytesToHex(byte[] bytes) static StringbytesToHex(io.netty.buffer.ByteBuf buf) static booleancopyFromResources(String resource, String destination) Copies a file from the archive's resources to the file system.static booleancreateFolder(String path) Creates a folder on the file system.static booleanfileExists(String path) Checks if a file exists on the file system.static intstatic doublestatic intGetNextTimestampOfThisHour(int hour, String timeZone, int param) static intGetNextTimestampOfThisHourInNextMonth(int hour, String timeZone, int param) static intGetNextTimestampOfThisHourInNextWeek(int hour, String timeZone, int param) static voidlogByteArray(byte[] array) static voidLogs an object to the console.static Stringstatic floatrandomFloatRange(float min, float max) static intrandomRange(int min, int max) static <T> TrequireNonNullElseGet(T nonNull, T fallback) Get object with null fallback.static voidChecks for required files and folders before startup.static StringtoFilePath(String path) Creates a string with the path to a file.static StringtoString(InputStream inputStream)
-
Field Details
-
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
-
getCurrentSeconds
public static int getCurrentSeconds() -
lowerCaseFirstChar
-
toString
- Throws:
IOException
-
logByteArray
public static void logByteArray(byte[] array) -
bytesToHex
-
bytesToHex
-
byteBufToArray
public static byte[] byteBufToArray(io.netty.buffer.ByteBuf buf) -
abilityHash
-
toFilePath
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
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
Creates a folder on the file system.- Parameters:
path- The path to the folder.- Returns:
- True if the folder was created, false otherwise.
-
copyFromResources
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
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
-
GetNextTimestampOfThisHourInNextWeek
-
GetNextTimestampOfThisHourInNextMonth
-