mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-24 18:07:39 +01:00
Implemented new player flight methods. This implements BUKKIT-1281. This also fixes BUKKIT-1146.
This commit is contained in:
parent
ca8b9a0bb4
commit
8fb141bfa0
@ -577,14 +577,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().getFoodData().foodLevel = value;
|
||||
}
|
||||
|
||||
public boolean getAllowFlight() {
|
||||
return getHandle().itemInWorldManager.player.abilities.canFly;
|
||||
}
|
||||
|
||||
public void setAllowFlight(boolean flight) {
|
||||
getHandle().itemInWorldManager.player.abilities.canFly = flight;
|
||||
}
|
||||
|
||||
public Location getBedSpawnLocation() {
|
||||
World world = getServer().getWorld(getHandle().spawnWorld);
|
||||
if ((world != null) && (getHandle().getBed() != null)) {
|
||||
@ -813,4 +805,30 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void disconnect(String reason) {
|
||||
conversationTracker.abandonAllConversations();
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
return getHandle().abilities.isFlying;
|
||||
}
|
||||
|
||||
public void setFlying(boolean value) {
|
||||
if (!getAllowFlight() && value) {
|
||||
throw new IllegalArgumentException("Cannot make player fly if getAllowFlight() is false");
|
||||
}
|
||||
|
||||
getHandle().abilities.isFlying = value;
|
||||
getHandle().updateAbilities();
|
||||
}
|
||||
|
||||
public boolean getAllowFlight() {
|
||||
return getHandle().abilities.canFly;
|
||||
}
|
||||
|
||||
public void setAllowFlight(boolean value) {
|
||||
if (isFlying() && !value) {
|
||||
getHandle().abilities.canFly = false;
|
||||
}
|
||||
|
||||
getHandle().abilities.canFly = value;
|
||||
getHandle().updateAbilities();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user