public class ArrayHelper
extends java.lang.Object
Constructor and Description |
---|
ArrayHelper() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String[] |
addStringAtIndex(java.lang.String[] array,
int indexToAddAt,
java.lang.String value)
Add a value at a certain spot in the index, shift everything after it one place further
|
static <T> boolean |
arrayHasNull(T[] array)
Checks if an array or any of its elements are null, or if the array is empty.
|
static java.lang.String |
concat(int start,
java.lang.String divider,
java.lang.String... strings)
Concatenate a string array with a specified start position and divider.
|
static <T> boolean |
contains(T[] array,
T value)
Checks if an array contains a value.
|
static java.lang.String[] |
decodeStringArray(net.minecraft.network.PacketBuffer buffer)
Reads a string array from a buffer.
|
static java.util.List<java.lang.String> |
decodeStringList(net.minecraft.network.PacketBuffer buffer)
Reads a string list from a buffer.
|
static boolean[][] |
deepCopy(boolean[][] array) |
static <T> T[][] |
deepCopy(T[][] array) |
static <T> T[][][] |
deepCopy(T[][][] array) |
static void |
encodeArray(net.minecraft.network.PacketBuffer buffer,
IEncodeable[] array)
Encodes an array into a buffer.
|
static void |
encodeList(net.minecraft.network.PacketBuffer buffer,
java.util.List<? extends IEncodeable> list)
Encodes a list into a buffer.
|
static void |
encodeStringArray(net.minecraft.network.PacketBuffer buffer,
java.lang.String[] array)
Encodes a string array into a buffer.
|
static void |
encodeStringList(net.minecraft.network.PacketBuffer buffer,
java.util.List<java.lang.String> list)
Encodes a list into a buffer.
|
static <T> int |
indexOf(T[] array,
T object) |
static net.minecraft.util.text.IFormattableTextComponent |
join(net.minecraft.util.text.IFormattableTextComponent delimiter,
net.minecraft.util.text.IFormattableTextComponent... texts)
Join an array of IFormattableTextComponent with a delimiter
|
static <T> void |
validateArrayNonNull(T[] array)
Validates that an array and its elements are non-null, and the array is not empty.
|
public static <T> int indexOf(T[] array, T object)
public static <T> boolean contains(T[] array, T value)
array
- The array to search for a value in.value
- The value to find in the array.public static <T> boolean arrayHasNull(T[] array)
array
- The array to check.public static <T> void validateArrayNonNull(T[] array)
array
- The array to check.java.lang.IllegalArgumentException
- If the array validation fails.public static void encodeArray(net.minecraft.network.PacketBuffer buffer, IEncodeable[] array)
buffer
- The buffer to encode the array into.array
- The array to encode.public static void encodeList(net.minecraft.network.PacketBuffer buffer, java.util.List<? extends IEncodeable> list)
buffer
- The buffer to encode the list into.list
- The list to encode.public static void encodeStringList(net.minecraft.network.PacketBuffer buffer, java.util.List<java.lang.String> list)
buffer
- The buffer to encode the list into.list
- The list to encode.public static void encodeStringArray(net.minecraft.network.PacketBuffer buffer, java.lang.String[] array)
buffer
- The buffer to encode the array into.array
- The array to encode.public static java.util.List<java.lang.String> decodeStringList(net.minecraft.network.PacketBuffer buffer)
buffer
- The buffer to read from.public static java.lang.String[] decodeStringArray(net.minecraft.network.PacketBuffer buffer)
buffer
- The buffer to read from.public static boolean[][] deepCopy(boolean[][] array)
public static <T> T[][] deepCopy(T[][] array)
public static <T> T[][][] deepCopy(T[][][] array)
public static java.lang.String[] addStringAtIndex(java.lang.String[] array, int indexToAddAt, java.lang.String value)
array
- given arrayindexToAddAt
- index where the value should be addedvalue
- to be addedpublic static net.minecraft.util.text.IFormattableTextComponent join(net.minecraft.util.text.IFormattableTextComponent delimiter, net.minecraft.util.text.IFormattableTextComponent... texts)
delimiter
- between each texttexts
- array of textpublic static java.lang.String concat(int start, java.lang.String divider, java.lang.String... strings)
start
- Index in the array at where to begin concatenation.divider
- String to place between concatenated strings.strings
- The string array to concatenate.