Permalink
Browse files

Fixed auto enabled flight

Fixes CMDBOOK-2409
  • Loading branch information...
DarkArc committed Jul 20, 2014
1 parent a99b16d commit 71b2d53d8f3af9b0a996b1c157b1c049507d5a72
Showing with 15 additions and 3 deletions.
  1. +15 −3 src/main/java/com/sk89q/commandbook/FlightComponent.java
@@ -182,9 +182,21 @@ public void walkSpeed(CommandContext args, CommandSender sender) throws CommandE
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
FlightSession session = sessions.getSession(FlightSession.class, event.getPlayer());
if (config.autoEnable && CommandBook.inst().hasPermission(event.getPlayer(), "commandbook.flight.onjoin")) {
event.getPlayer().setAllowFlight(session.canFly = true);
if (config.autoEnable) {
final Player player = event.getPlayer();
CommandBook.server().getScheduler().runTaskLater(CommandBook.inst(), new Runnable() {
@Override
public void run() {
if (CommandBook.inst().hasPermission(player, "commandbook.flight.onjoin")) {
FlightSession session = sessions.getSession(FlightSession.class, player);
player.setAllowFlight(session.canFly = true);
//noinspection deprecation
if (!player.isOnGround()) {
player.setFlying(true);
}
}
}
}, 1);
}
}

0 comments on commit 71b2d53

Please sign in to comment.