mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Improve error message when attempting to access an illegal index in CollisionMatrix.
This commit is contained in:
@@ -161,7 +161,8 @@ public final class CollisionMatrix {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix)).toString();
|
||||
return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix))
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,8 +210,9 @@ public final class CollisionMatrix {
|
||||
* @throws ArrayIndexOutOfBoundsException If the specified coordinate pair does not fit in this matrix.
|
||||
*/
|
||||
private int indexOf(int x, int y) {
|
||||
Preconditions.checkElementIndex(x, width, "X coordinate must be [0, " + width + "), received " + x + ".");
|
||||
Preconditions.checkElementIndex(y, length, "Y coordinate must be [0, " + length + "), received " + y + ".");
|
||||
int index = y * width + x;
|
||||
Preconditions.checkElementIndex(index, matrix.length, "Index out of bounds.");
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user