Package cn.nukkit.utils
Class Utils
java.lang.Object
cn.nukkit.utils.Utils
- Author:
- MagicDroidX (Nukkit Project)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final Integer[]
static final boolean[]
static final boolean[]
static final SplittableRandom
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
calLinearFunction
(Vector3 pos1, Vector3 pos2, double element, int type) static <T> T[][]
clone2dArray
(T[][] array) static void
static UUID
dataToUUID
(byte[]... params) static UUID
dataToUUID
(String... params) static int
dynamic
(int value) A way to tell the java compiler to do not replace the users of apublic static final int
constant with the value defined in it, forcing the JVM to get the value directly from the class, preventing binary incompatible changes.static <T> T
dynamic
(T value) A way to tell the java compiler to do not replace the users of apublic static final
constant with the value defined in it, forcing the JVM to get the value directly from the class, preventing binary incompatible changes.static String
static String
static Block[]
getLevelBlocks
(Level level, AxisAlignedBB bb) static <T,
U, V> Map<U, V> getOrCreate
(Map<T, Map<U, V>> map, T key) static <T,
U, V extends U>
UgetOrCreate
(Map<T, U> map, Class<V> clazz, T key) static boolean
hasCollisionBlocks
(Level level, AxisAlignedBB bb) static boolean
hasCollisionTickCachedBlocks
(Level level, AxisAlignedBB bb) static boolean
isByteArrayEmpty
(byte[] array) static boolean
static byte[]
static boolean
rand()
static double
rand
(double min, double max) static int
rand
(int min, int max) static String
static String
readFile
(InputStream inputStream) static String
static <T> void
reverseArray
(T[] data) static <T> T[]
reverseArray
(T[] array, boolean copy) static String
static void
static Object[][]
splitArray
(Object[] arrayToSplit, int chunkSize) static long
toABGR
(int argb) static int
static long
toRGB
(byte r, byte g, byte b, byte a) static void
writeFile
(File file, InputStream content) static void
static void
writeFile
(String fileName, InputStream content) static void
static void
-
Field Details
-
EMPTY_INTEGERS
-
random
-
ACCORDING_X_OBTAIN_Y
- See Also:
-
ACCORDING_Y_OBTAIN_X
- See Also:
-
isPlant
public static final boolean[] isPlant -
isPlantOrFluid
public static final boolean[] isPlantOrFluid
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
safeWrite
@PowerNukkitOnly @Since("1.4.0.0-PN") public static void safeWrite(File currentFile, Consumer<File> operation) throws IOException - Throws:
IOException
-
writeFile
- Throws:
IOException
-
writeFile
- Throws:
IOException
-
writeFile
- Throws:
IOException
-
writeFile
- Throws:
IOException
-
readFile
- Throws:
IOException
-
readFile
- Throws:
IOException
-
readFile
- Throws:
IOException
-
copyFile
- Throws:
IOException
-
getAllThreadDumps
-
getExceptionMessage
-
dataToUUID
-
dataToUUID
-
rtrim
-
isByteArrayEmpty
public static boolean isByteArrayEmpty(byte[] array) -
toRGB
public static long toRGB(byte r, byte g, byte b, byte a) -
toABGR
public static long toABGR(int argb) -
splitArray
-
reverseArray
public static <T> void reverseArray(T[] data) -
reverseArray
public static <T> T[] reverseArray(T[] array, boolean copy) -
clone2dArray
public static <T> T[][] clone2dArray(T[][] array) -
getOrCreate
-
getOrCreate
-
toInt
-
parseHexBinary
-
rand
-
rand
-
rand
-
dynamic
A way to tell the java compiler to do not replace the users of apublic static final int
constant with the value defined in it, forcing the JVM to get the value directly from the class, preventing binary incompatible changes.- Parameters:
value
- The value to be assigned to the field.- Returns:
- The same value that was passed as parameter
-
dynamic
A way to tell the java compiler to do not replace the users of apublic static final
constant with the value defined in it, forcing the JVM to get the value directly from the class, preventing binary incompatible changes.- Parameters:
value
- The value to be assigned to the field.- Returns:
- The same value that was passed as parameter
-
zipFolder
@PowerNukkitOnly @Since("1.4.0.0-PN") public static void zipFolder(Path sourceFolderPath, Path zipPath) throws IOException - Throws:
IOException
-
isInteger
-
getLevelBlocks
@PowerNukkitXOnly @Since("1.6.0.0-PNX") public static Block[] getLevelBlocks(Level level, AxisAlignedBB bb) -
calLinearFunction
@PowerNukkitXOnly @Since("1.6.0.0-PNX") public static double calLinearFunction(Vector3 pos1, Vector3 pos2, double element, int type) -
hasCollisionBlocks
@PowerNukkitXOnly @Since("1.6.0.0-PNX") public static boolean hasCollisionBlocks(Level level, AxisAlignedBB bb) -
hasCollisionTickCachedBlocks
@PowerNukkitXOnly @Since("1.6.0.0-PNX") public static boolean hasCollisionTickCachedBlocks(Level level, AxisAlignedBB bb)
-