From 921ba53556066ee16cb212e564ee9403fb6a73ff Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 2 Jun 2017 18:44:37 +1000 Subject: [PATCH] SPIGOT-3283: Don't allow plugin induced infinite velocity / position --- .../org/bukkit/craftbukkit/entity/CraftEntity.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 2e81ea8660..2027026854 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -236,10 +236,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return new Vector(entity.motX, entity.motY, entity.motZ); } - public void setVelocity(Vector vel) { - entity.motX = vel.getX(); - entity.motY = vel.getY(); - entity.motZ = vel.getZ(); + public void setVelocity(Vector velocity) { + Preconditions.checkArgument(velocity != null, "velocity"); + velocity.checkFinite(); + entity.motX = velocity.getX(); + entity.motY = velocity.getY(); + entity.motZ = velocity.getZ(); entity.velocityChanged = true; } @@ -269,6 +271,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } public boolean teleport(Location location, TeleportCause cause) { + Preconditions.checkArgument(location != null, "location"); + location.checkFinite(); + if (entity.isVehicle() || entity.dead) { return false; }