diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-03-22 22:04:13 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-03-22 22:04:13 +0000 |
commit | 8fb141bfa0b8d01de6c4680e69f1c29a0acc51d8 (patch) | |
tree | 0c9af5e83f45defd74b6995ed5cfad2bc6320866 /src | |
parent | ca8b9a0bb40b7e5bbaeca0f25ff0e386847da8ea (diff) | |
download | craftbukkit-8fb141bfa0b8d01de6c4680e69f1c29a0acc51d8.tar craftbukkit-8fb141bfa0b8d01de6c4680e69f1c29a0acc51d8.tar.gz craftbukkit-8fb141bfa0b8d01de6c4680e69f1c29a0acc51d8.tar.lz craftbukkit-8fb141bfa0b8d01de6c4680e69f1c29a0acc51d8.tar.xz craftbukkit-8fb141bfa0b8d01de6c4680e69f1c29a0acc51d8.zip |
Implemented new player flight methods. This implements BUKKIT-1281. This also fixes BUKKIT-1146.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 4c882ac5..6898c063 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -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(); + } } |