Clarify exception messages for invalid view distances (#7510)

This commit is contained in:
Noah van der Aa 2022-03-04 11:23:28 +01:00 committed by GitHub
parent b9f26bb1e9
commit 63aa4d3319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,7 +123,7 @@ index 66501c3b0eb92d946ef77bbd3f36ebcc0d3023af..153f07bac06093b43a1f5b0f8e1a46ff
} }
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..9ad84dc6f0463dbbbdd53723edcc2a3ebc63de24 index 0000000000000000000000000000000000000000..bdd4cc040111d18b82d3ebeb5dbe2537cf148090
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java +++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
@@ -0,0 +1,1108 @@ @@ -0,0 +1,1108 @@
@ -326,7 +326,7 @@ index 0000000000000000000000000000000000000000..9ad84dc6f0463dbbbdd53723edcc2a3e
+ +
+ public void setSendDistance(final int distance) { + public void setSendDistance(final int distance) {
+ if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE + 1)) { + if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE + 1)) {
+ throw new IllegalArgumentException(Integer.toString(distance)); + throw new IllegalArgumentException("Send distance must be a number between " + MIN_VIEW_DISTANCE + " and " + (MAX_VIEW_DISTANCE + 1) + ", or -1, got: " + distance);
+ } + }
+ this.rawSendDistance = distance; + this.rawSendDistance = distance;
+ } + }
@ -338,7 +338,7 @@ index 0000000000000000000000000000000000000000..9ad84dc6f0463dbbbdd53723edcc2a3e
+ +
+ public void setLoadDistance(final int distance) { + public void setLoadDistance(final int distance) {
+ if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE + 1)) { + if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE + 1)) {
+ throw new IllegalArgumentException(Integer.toString(distance)); + throw new IllegalArgumentException("Load distance must be a number between " + MIN_VIEW_DISTANCE + " and " + (MAX_VIEW_DISTANCE + 1) + ", or -1, got: " + distance);
+ } + }
+ this.rawLoadDistance = distance; + this.rawLoadDistance = distance;
+ } + }
@ -349,7 +349,7 @@ index 0000000000000000000000000000000000000000..9ad84dc6f0463dbbbdd53723edcc2a3e
+ +
+ public void setTickDistance(final int distance) { + public void setTickDistance(final int distance) {
+ if (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE) { + if (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE) {
+ throw new IllegalArgumentException(Integer.toString(distance)); + throw new IllegalArgumentException("View distance must be a number between " + MIN_VIEW_DISTANCE + " and " + MAX_VIEW_DISTANCE + ", got: " + distance);
+ } + }
+ this.rawTickDistance = distance; + this.rawTickDistance = distance;
+ } + }
@ -942,7 +942,7 @@ index 0000000000000000000000000000000000000000..9ad84dc6f0463dbbbdd53723edcc2a3e
+ +
+ public void setTargetSendViewDistance(final int distance) { + public void setTargetSendViewDistance(final int distance) {
+ if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE + 1)) { + if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE + 1)) {
+ throw new IllegalArgumentException(Integer.toString(distance)); + throw new IllegalArgumentException("Send view distance must be a number between " + MIN_VIEW_DISTANCE + " and " + (MAX_VIEW_DISTANCE + 1) + " or -1, got: " + distance);
+ } + }
+ this.sendViewDistance = distance; + this.sendViewDistance = distance;
+ } + }
@ -953,7 +953,7 @@ index 0000000000000000000000000000000000000000..9ad84dc6f0463dbbbdd53723edcc2a3e
+ +
+ public void setTargetNoTickViewDistance(final int distance) { + public void setTargetNoTickViewDistance(final int distance) {
+ if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE)) { + if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE)) {
+ throw new IllegalArgumentException(Integer.toString(distance)); + throw new IllegalArgumentException("Simulation distance must be a number between " + MIN_VIEW_DISTANCE + " and " + MAX_VIEW_DISTANCE + " or -1, got: " + distance);
+ } + }
+ this.loadViewDistance = distance == -1 ? -1 : distance + 1; + this.loadViewDistance = distance == -1 ? -1 : distance + 1;
+ } + }
@ -964,7 +964,7 @@ index 0000000000000000000000000000000000000000..9ad84dc6f0463dbbbdd53723edcc2a3e
+ +
+ public void setTargetTickViewDistance(final int distance) { + public void setTargetTickViewDistance(final int distance) {
+ if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE)) { + if (distance != -1 && (distance < MIN_VIEW_DISTANCE || distance > MAX_VIEW_DISTANCE)) {
+ throw new IllegalArgumentException(Integer.toString(distance)); + throw new IllegalArgumentException("View distance must be a number between " + MIN_VIEW_DISTANCE + " and " + MAX_VIEW_DISTANCE + " or -1, got: " + distance);
+ } + }
+ this.tickViewDistance = distance; + this.tickViewDistance = distance;
+ } + }