Guest User

Untitled

a guest
Sep 5th, 2014
186
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Jump extends JavaPlugin implements Listener {
  2.     public void onEnable(){
  3.         getServer().getPluginManager().registerEvents(this, this);
  4.     }
  5.    
  6.     @EventHandler
  7.     public void onPlayerToggleFlight(PlayerToggleFlightEvent event){
  8.        Player player = event.getPlayer();
  9.        if (player.getGameMode() == GameMode.CREATIVE)
  10.            return;
  11.        event.setCancelled(true);
  12.        player.setAllowFlight(false);
  13.        player.setFlying(false);
  14.        player.setVelocity(player.getLocation().getDirection()
  15.                .multiply(1.5).setY(1));
  16.    
  17.     }
  18.    
  19.     @EventHandler
  20.     public void onPlayerMove(PlayerMoveEvent event) {
  21.  
  22.         Player player = event.getPlayer();
  23.         if ((player.getGameMode() != GameMode.CREATIVE)
  24.                 && (player.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR)
  25.                 && (!player.isFlying()))
  26.             player.setAllowFlight(true);
  27.        
  28.  
  29.     }
  30. }
RAW Paste Data