Use `checkIndex`

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-05-07 10:58:19 +02:00
parent 35ae8bc07a
commit 2720d9ada2
1 changed files with 2 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package net.minestom.server.utils.collection;
import org.jetbrains.annotations.ApiStatus;
import java.util.AbstractList;
import java.util.Objects;
import java.util.function.IntFunction;
@ApiStatus.Internal
@ -18,8 +19,7 @@ public final class IntMappedArray<R> extends AbstractList<R> {
@Override
public R get(int index) {
final int[] elements = this.elements;
if (index < 0 || index >= elements.length)
throw new IndexOutOfBoundsException("Index " + index + " is out of bounds for length " + elements.length);
Objects.checkIndex(index, elements.length);
return function.apply(elements[index]);
}