summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2015-02-26 21:23:26 +1100
committermd_5 <git@md-5.net>2015-02-26 21:23:26 +1100
commitfb96a1afa922ee61b6a66420f640d6fef9771145 (patch)
tree552f2414c2a384de248ee0cbc7104c3414966846
parent9f071ab402a8cdab804626d58bfc19855e8a8e05 (diff)
downloadbukkit-fb96a1afa922ee61b6a66420f640d6fef9771145.tar
bukkit-fb96a1afa922ee61b6a66420f640d6fef9771145.tar.gz
bukkit-fb96a1afa922ee61b6a66420f640d6fef9771145.tar.lz
bukkit-fb96a1afa922ee61b6a66420f640d6fef9771145.tar.xz
bukkit-fb96a1afa922ee61b6a66420f640d6fef9771145.zip
Move checkFinite methods to a util class.
-rw-r--r--src/main/java/org/bukkit/Location.java17
-rw-r--r--src/main/java/org/bukkit/util/NumberConversions.java12
-rw-r--r--src/main/java/org/bukkit/util/Vector.java7
3 files changed, 16 insertions, 20 deletions
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index 21f98cb5..583dbe8f 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -6,6 +6,7 @@ import java.util.Map;
import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.util.NumberConversions;
+import static org.bukkit.util.NumberConversions.checkFinite;
import org.bukkit.util.Vector;
/**
@@ -188,7 +189,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param yaw new rotation's yaw
*/
public void setYaw(float yaw) {
- checkFiniteFloat(yaw, "yaw must be finite");
+ checkFinite(yaw, "yaw must be finite");
this.yaw = yaw;
}
@@ -223,7 +224,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param pitch new incline's pitch
*/
public void setPitch(float pitch) {
- checkFiniteFloat(pitch, "pitch must be finite");
+ checkFinite(pitch, "pitch must be finite");
this.pitch = pitch;
}
@@ -601,16 +602,4 @@ public class Location implements Cloneable, ConfigurationSerializable {
return new Location(world, NumberConversions.toDouble(args.get("x")), NumberConversions.toDouble(args.get("y")), NumberConversions.toDouble(args.get("z")), NumberConversions.toFloat(args.get("yaw")), NumberConversions.toFloat(args.get("pitch")));
}
-
- private static void checkFinite(double d, String message) {
- if (Double.isNaN(d) || Double.isInfinite(d)) {
- throw new IllegalArgumentException(message);
- }
- }
-
- private static void checkFiniteFloat(float d, String message) {
- if (Float.isNaN(d) || Float.isInfinite(d)) {
- throw new IllegalArgumentException(message);
- }
- }
}
diff --git a/src/main/java/org/bukkit/util/NumberConversions.java b/src/main/java/org/bukkit/util/NumberConversions.java
index 29f81d01..4bc79028 100644
--- a/src/main/java/org/bukkit/util/NumberConversions.java
+++ b/src/main/java/org/bukkit/util/NumberConversions.java
@@ -101,4 +101,16 @@ public final class NumberConversions {
}
return 0;
}
+
+ public static void checkFinite(double d, String message) {
+ if (Double.isNaN(d) || Double.isInfinite(d)) {
+ throw new IllegalArgumentException(message);
+ }
+ }
+
+ public static void checkFinite(float d, String message) {
+ if (Float.isNaN(d) || Float.isInfinite(d)) {
+ throw new IllegalArgumentException(message);
+ }
+ }
}
diff --git a/src/main/java/org/bukkit/util/Vector.java b/src/main/java/org/bukkit/util/Vector.java
index 7cd60481..be8cf41a 100644
--- a/src/main/java/org/bukkit/util/Vector.java
+++ b/src/main/java/org/bukkit/util/Vector.java
@@ -7,6 +7,7 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
+import static org.bukkit.util.NumberConversions.checkFinite;
/**
* Represents a mutable vector. Because the components of Vectors are mutable,
@@ -646,10 +647,4 @@ public class Vector implements Cloneable, ConfigurationSerializable {
return new Vector(x, y, z);
}
-
- private static void checkFinite(double d, String message) {
- if (Double.isNaN(d) || Double.isInfinite(d)) {
- throw new IllegalArgumentException(message);
- }
- }
}