Add self-riding check to Entity#addPassenger

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2021-12-29 10:48:15 +11:00
parent 7a54f9da31
commit 5a3105919b

View File

@ -662,6 +662,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override @Override
public boolean addPassenger(org.bukkit.entity.Entity passenger) { public boolean addPassenger(org.bukkit.entity.Entity passenger) {
Preconditions.checkArgument(passenger != null, "passenger == null"); Preconditions.checkArgument(passenger != null, "passenger == null");
Preconditions.checkArgument(!this.equals(passenger), "Entity cannot ride itself.");
return ((CraftEntity) passenger).getHandle().startRiding(getHandle(), true); return ((CraftEntity) passenger).getHandle().startRiding(getHandle(), true);
} }