mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Move passenger-handling to CraftEntity
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
parent
eb1386fbbb
commit
0258613d15
2 changed files with 26 additions and 27 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() + '}';
|
||||
|
|
Loading…
Reference in a new issue