diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 9fac33bd5a..c21e49b95f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1,6 +1,8 @@ package org.bukkit.craftbukkit.entity; +import com.google.common.base.Function; import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; import java.util.List; import java.util.Set; import java.util.UUID; @@ -331,13 +333,37 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { Preconditions.checkArgument(!this.equals(passenger), "Entity cannot ride itself."); if (passenger instanceof CraftEntity) { eject(); - ((CraftEntity) passenger).getHandle().startRiding(getHandle()); - return true; + return ((CraftEntity) passenger).getHandle().startRiding(getHandle()); } else { return false; } } + @Override + public List getPassengers() { + return Lists.newArrayList(Lists.transform(getHandle().passengers, new Function() { + @Override + public org.bukkit.entity.Entity apply(Entity input) { + return input.getBukkitEntity(); + } + })); + } + + @Override + public boolean addPassenger(org.bukkit.entity.Entity passenger) { + Preconditions.checkArgument(passenger != null, "passenger == null"); + + return ((CraftEntity) passenger).getHandle().a(getHandle(), true); + } + + @Override + public boolean removePassenger(org.bukkit.entity.Entity passenger) { + Preconditions.checkArgument(passenger != null, "passenger == null"); + + ((CraftEntity) passenger).getHandle().stopRiding(); + return true; + } + public boolean isEmpty() { return !getHandle().isVehicle(); } @@ -347,7 +373,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return false; } - getPassenger().leaveVehicle(); + getHandle().az(); // PAIL: rename return true; }