From 8c555c431422b6949ae752624e0910fa1938bee1 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 4 Jan 2017 10:52:59 +1100 Subject: [PATCH] SPIGOT-2640: API for multiple passengers per entity By: md_5 --- .../main/java/org/bukkit/entity/Entity.java | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java index 759e3f0d94..b4a70518a8 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -179,30 +179,62 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * multiple passengers, this will only return the primary passenger. * * @return an entity + * @deprecated entities may have multiple passengers, use + * {@link #getPassengers()} */ - public abstract Entity getPassenger(); + @Deprecated + public Entity getPassenger(); /** * Set the passenger of a vehicle. * * @param passenger The new passenger. * @return false if it could not be done for whatever reason + * @deprecated entities may have multiple passengers, use + * {@link #getPassengers()} */ - public abstract boolean setPassenger(Entity passenger); + @Deprecated + public boolean setPassenger(Entity passenger); + + /** + * Gets a list of passengers of this vehicle. + *

+ * The returned list will not be directly linked to the entity's current + * passengers, and no guarantees are made as to its mutability. + * + * @return list of entities corresponding to current passengers. + */ + public List getPassengers(); + + /** + * Add a passenger to the vehicle. + * + * @param passenger The passenger to add + * @return false if it could not be done for whatever reason + */ + public boolean addPassenger(Entity passenger); + + /** + * Remove a passenger from the vehicle. + * + * @param passenger The passenger to remove + * @return false if it could not be done for whatever reason + */ + public boolean removePassenger(Entity passenger); /** * Check if a vehicle has passengers. * * @return True if the vehicle has no passengers. */ - public abstract boolean isEmpty(); + public boolean isEmpty(); /** * Eject any passenger. * * @return True if there was a passenger. */ - public abstract boolean eject(); + public boolean eject(); /** * Returns the distance this entity has fallen