001 package org.bukkit.event.player; 002 003 import org.bukkit.entity.Player; 004 import org.bukkit.event.Cancellable; 005 import org.bukkit.event.HandlerList; 006 007 /** 008 * Called when a player toggles their flying state 009 */ 010 public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable { 011 private static final HandlerList handlers = new HandlerList(); 012 private final boolean isFlying; 013 private boolean cancel = false; 014 015 public PlayerToggleFlightEvent(final Player player, final boolean isFlying) { 016 super(player); 017 this.isFlying = isFlying; 018 } 019 020 /** 021 * Returns whether the player is trying to start or stop flying. 022 * 023 * @return flying state 024 */ 025 public boolean isFlying() { 026 return isFlying; 027 } 028 029 public boolean isCancelled() { 030 return cancel; 031 } 032 033 public void setCancelled(boolean cancel) { 034 this.cancel = cancel; 035 } 036 037 @Override 038 public HandlerList getHandlers() { 039 return handlers; 040 } 041 042 public static HandlerList getHandlerList() { 043 return handlers; 044 } 045 }