Move passenger-handling to CraftEntity

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
CraftBukkit/Spigot 2011-03-29 23:06:53 +02:00
parent eb1386fbbb
commit 0258613d15
2 changed files with 26 additions and 27 deletions

View file

@ -196,4 +196,30 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public void setMomentum(Vector value) {
setVelocity(value);
}
public CraftEntity getPassenger() {
return isEmpty() ? null : (CraftEntity) getHandle().passenger.getBukkitEntity();
}
public boolean setPassenger(org.bukkit.entity.Entity passenger) {
if (passenger instanceof CraftEntity){
((CraftEntity) passenger).getHandle().setPassengerOf(getHandle());
return true;
} else {
return false;
}
}
public boolean isEmpty() {
return getHandle().passenger == null;
}
public boolean eject() {
if (getHandle().passenger == null) {
return false;
}
getHandle().passenger.setPassengerOf(null);
return true;
}
}

View file

@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.entity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Vehicle;
/**
@ -14,32 +13,6 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
super(server, entity);
}
public Entity getPassenger() {
return isEmpty() ? null : (getHandle().passenger.getBukkitEntity());
}
public boolean setPassenger(Entity passenger) {
if (passenger instanceof CraftEntity){
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
return true;
} else {
return false;
}
}
public boolean isEmpty() {
return getHandle().passenger == null;
}
public boolean eject() {
if (getHandle().passenger == null) {
return false;
}
getHandle().passenger.setPassengerOf(null);
return true;
}
@Override
public String toString() {
return "CraftVehicle{passenger=" + getPassenger() + '}';