mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-07 23:52:11 -07:00
SPIGOT-3283: Add finite checking util methods to Location / Vectors
By: md_5 <git@md-5.net>
This commit is contained in:
@@ -6,7 +6,6 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -555,6 +554,19 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if each component of this Location is finite.
|
||||
*
|
||||
* @throws IllegalArgumentException if any component is not finite
|
||||
*/
|
||||
public void checkFinite() throws IllegalArgumentException {
|
||||
NumberConversions.checkFinite(x, "x not finite");
|
||||
NumberConversions.checkFinite(y, "y not finite");
|
||||
NumberConversions.checkFinite(z, "z not finite");
|
||||
NumberConversions.checkFinite(pitch, "pitch not finite");
|
||||
NumberConversions.checkFinite(yaw, "yaw not finite");
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely converts a double (location coordinate) to an int (block
|
||||
* coordinate)
|
||||
|
@@ -7,7 +7,6 @@ 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,
|
||||
@@ -616,6 +615,17 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
||||
return new BlockVector(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if each component of this Vector is finite.
|
||||
*
|
||||
* @throws IllegalArgumentException if any component is not finite
|
||||
*/
|
||||
public void checkFinite() throws IllegalArgumentException {
|
||||
NumberConversions.checkFinite(x, "x not finite");
|
||||
NumberConversions.checkFinite(y, "y not finite");
|
||||
NumberConversions.checkFinite(z, "z not finite");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the threshold used for equals().
|
||||
*
|
||||
|
Reference in New Issue
Block a user