@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user