@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
 public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
   Player p = event.getPlayer();
   if (FlyingPlayer.isFlying(p)) {
     event.setCancelled(p.getGameMode() != GameMode.CREATIVE);
   }
 }
 @EventHandler
 public void doubleJump(PlayerToggleFlightEvent event) {
   final Player player = event.getPlayer();
   if (event.isFlying() && FOPM_TFM_Util.isDoubleJumper(player)) {
     player.setFlying(false);
     Vector jump = player.getLocation().getDirection().multiply(2).setY(1.1);
     player.setVelocity(player.getVelocity().add(jump));
     event.setCancelled(true);
   }
 }
 @EventHandler
 public void onPlayerFlying(PlayerToggleFlightEvent event) {
   if (dEntity.isNPC(event.getPlayer())) {
     return;
   }
   state = event.isFlying();
   cancelled = event.isCancelled();
   this.event = event;
   fire();
   event.setCancelled(cancelled);
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onFly(PlayerToggleFlightEvent tfe) {
    Player p = tfe.getPlayer();

    Game g = Main.getInstance().getGameManager().getGameOfPlayer(p);
    if (g == null) {
      return;
    }

    if (g.getState() == GameState.STOPPED) {
      return;
    }

    if (g.getState() == GameState.RUNNING && g.isSpectator(p)) {
      tfe.setCancelled(false);
      return;
    }

    tfe.setCancelled(true);
  }
  @EventHandler
  public void onPlayerStopFlying(PlayerToggleFlightEvent e) {

    Player p = e.getPlayer();

    if (ArenaManager.isPlayerPlaying(p)
        && ArenaManager.getPlayersArena(p).getState() == Arena.ArenaState.INGAME) {
      if (!e.isFlying()) {
        e.setCancelled(true);
        p.setFlying(true);
      }
    }
  }
Beispiel #6
0
  @EventHandler
  public static void onFly(PlayerToggleFlightEvent event) {
    Player p = event.getPlayer();
    if (p.getGameMode() != GameMode.CREATIVE && event.isFlying()) {
      event.setCancelled(true);

      Vector jump = p.getLocation().getDirection().multiply(0.4).setY(1.1);
      p.setVelocity(p.getVelocity().add(jump));
      p.setAllowFlight(false);
      p.setFallDistance(1);
      p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 100, 1);
      ParticleEffect.CLOUD.display(1, 1, 1, 1, 20, p.getLocation(), 20);
    }
  }