3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Move passenger-handling to CraftEntity

Dieser Commit ist enthalten in:
Erik Broes 2011-03-29 23:06:53 +02:00
Ursprung 195423cd0b
Commit ec74fe8e37
2 geänderte Dateien mit 26 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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() + '}';