Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

Don't allow plugins to set problematic velocity vectors #412

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,13 @@ public void attack(Entity entity) {

if (!event.isCancelled()) {
if (!velocity.equals(event.getVelocity())) {
player.setVelocity(event.getVelocity());
// Nacho start - don't allow plugins to set problematic velocity vectors
org.bukkit.util.Vector newVelocity = event.getVelocity();
if(newVelocity.getX() != newVelocity.getX()) newVelocity.setX(0);
if(newVelocity.getY() != newVelocity.getY()) newVelocity.setY(0);
if(newVelocity.getZ() != newVelocity.getZ()) newVelocity.setZ(0);
// Nacho end
player.setVelocity(newVelocity);
}
((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity));
entity.velocityChanged = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,13 @@ public void track(List<EntityHuman> list)
if (event.isCancelled()) {
cancelled = true;
} else if (!velocity.equals(event.getVelocity())) {
player.setVelocity(event.getVelocity());
// Nacho start - don't allow plugins to set problematic velocity vectors
org.bukkit.util.Vector newVelocity = event.getVelocity();
if(newVelocity.getX() != newVelocity.getX()) newVelocity.setX(0);
if(newVelocity.getY() != newVelocity.getY()) newVelocity.setY(0);
if(newVelocity.getZ() != newVelocity.getZ()) newVelocity.setZ(0);
// Nacho end
player.setVelocity(newVelocity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ public void setVelocity(Vector vel) {
}
}
// Paper end

// Nacho start - don't allow plugins to set problematic velocity vectors
Preconditions.checkArgument(vel.getX() == vel.getX() && vel.getY() == vel.getY() && vel.getZ() == vel.getZ(), "Illegal velocity vector: " + vel);
// Nacho end

entity.motX = vel.getX();
entity.motY = vel.getY();
Expand Down