Moved getVehicle, leaveVehicle and isInsideVehicle from CraftLivingEntity to CraftEntity. Addresses BUKKIT-811

This commit is contained in:
TomyLobo 2011-10-25 15:53:43 +02:00 committed by EvilSeph
parent 1394926e53
commit 53e4a034f4
2 changed files with 22 additions and 26 deletions

View file

@ -9,6 +9,7 @@ import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
@ -342,4 +343,25 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
server.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
public boolean isInsideVehicle() {
return getHandle().vehicle != null;
}
public boolean leaveVehicle() {
if (getHandle().vehicle == null) {
return false;
}
getHandle().setPassengerOf(null);
return true;
}
public org.bukkit.entity.Entity getVehicle() {
if (getHandle().vehicle == null) {
return null;
}
return getHandle().vehicle.getBukkitEntity();
}
}

View file

@ -128,32 +128,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return launchProjectile(Arrow.class);
}
public boolean isInsideVehicle() {
return getHandle().vehicle != null;
}
public boolean leaveVehicle() {
if (getHandle().vehicle == null) {
return false;
}
getHandle().setPassengerOf(null);
return true;
}
public Vehicle getVehicle() {
if (getHandle().vehicle == null) {
return null;
}
org.bukkit.entity.Entity vehicle = (getHandle().vehicle.getBukkitEntity());
if (vehicle instanceof Vehicle) {
return (Vehicle) vehicle;
}
return null;
}
public int getRemainingAir() {
return getHandle().getAirTicks();
}