mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-11 18:02:08 +01:00
Use jdk method for array comparison
This commit is contained in:
parent
db9906d0ae
commit
9a74051cdb
@ -350,7 +350,7 @@ public final class CommandManager {
|
||||
for (var entry : syntaxesArguments.entrySet()) {
|
||||
final var parsedArguments = entry.getValue();
|
||||
final int index = i + 1;
|
||||
if (ArrayUtils.sameStart(arguments, parsedArguments, index)) {
|
||||
if (Arrays.mismatch(arguments, 0, index, parsedArguments, 0, index) == -1) {
|
||||
final Argument<?> sharedArgument = parsedArguments[i];
|
||||
final var sharedSyntax = entry.getKey();
|
||||
final var indexed = new IndexedArgument(sharedSyntax, sharedArgument, i);
|
||||
|
@ -4,7 +4,6 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.LongConsumer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@ -53,27 +52,6 @@ public final class ArrayUtils {
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if two arrays share the same start until {@code length}.
|
||||
*
|
||||
* @param first the first array
|
||||
* @param second the second array
|
||||
* @param length the length to check (0-length)
|
||||
* @param <T> the type of the arrays
|
||||
* @return true if both arrays share the same start
|
||||
*/
|
||||
public static <T> boolean sameStart(@NotNull T[] first, @NotNull T[] second, int length) {
|
||||
if (Math.min(first.length, second.length) < length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!Objects.equals(first[i], second[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean empty(byte[] array) {
|
||||
for (byte b : array) {
|
||||
if (b != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user