SPIGOT-3283: Don't allow plugin induced infinite velocity / position

This commit is contained in:
md_5 2017-06-02 18:44:37 +10:00
parent 9496c2dad1
commit 921ba53556

View File

@ -236,10 +236,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return new Vector(entity.motX, entity.motY, entity.motZ); return new Vector(entity.motX, entity.motY, entity.motZ);
} }
public void setVelocity(Vector vel) { public void setVelocity(Vector velocity) {
entity.motX = vel.getX(); Preconditions.checkArgument(velocity != null, "velocity");
entity.motY = vel.getY(); velocity.checkFinite();
entity.motZ = vel.getZ(); entity.motX = velocity.getX();
entity.motY = velocity.getY();
entity.motZ = velocity.getZ();
entity.velocityChanged = true; entity.velocityChanged = true;
} }
@ -269,6 +271,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} }
public boolean teleport(Location location, TeleportCause cause) { public boolean teleport(Location location, TeleportCause cause) {
Preconditions.checkArgument(location != null, "location");
location.checkFinite();
if (entity.isVehicle() || entity.dead) { if (entity.isVehicle() || entity.dead) {
return false; return false;
} }