SHARE
TWEET

Untitled

a guest Apr 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.fruitlabs.lobby.listener;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Effect;
  5. import org.bukkit.GameMode;
  6. import org.bukkit.Material;
  7. import org.bukkit.Sound;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.player.PlayerMoveEvent;
  12. import org.bukkit.event.player.PlayerToggleFlightEvent;
  13. import org.bukkit.util.Vector;
  14.  
  15. import de.fruitlabs.lobby.Lobby;
  16.  
  17. public class PlayerFlightListener implements Listener {
  18.  
  19.     @EventHandler
  20.     public void onMove(final PlayerMoveEvent event) {
  21.         final Player player = event.getPlayer();
  22.         if (!player.isOnGround()) {
  23.             return;
  24.         }
  25.         player.setAllowFlight(true);
  26.     }
  27.    
  28.     @EventHandler
  29.     public void onJump(final PlayerToggleFlightEvent event) {
  30.         final Player player = event.getPlayer();
  31.         if (!event.isFlying()) {
  32.             return;
  33.         }
  34.         if (player.getGameMode() == GameMode.CREATIVE) {
  35.             return;
  36.         }
  37.         final Vector v = player.getLocation().getDirection().multiply(1.5).setY(0.8);
  38.         player.setVelocity(v);
  39.         player.playEffect(player.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
  40.         player.playSound(player.getLocation(), Sound.ENDERDRAGON_WINGS, 1.0f, 1.0f);
  41.         event.setCancelled(true);
  42.         player.setAllowFlight(false);
  43.         player.setFlying(false);
  44.     }
  45.    
  46.     @EventHandler
  47.     public void onMove1(final PlayerMoveEvent e) {
  48.         final Player p = e.getPlayer();
  49.         if (p.getLocation().getBlock().getType() == Material.IRON_PLATE) {
  50.             final Vector v = p.getLocation().getDirection().multiply(3.5).setY(1.5);
  51.             p.setVelocity(v);
  52.             p.playSound(p.getLocation(), Sound.FIREWORK_BLAST, 4.0f, 3.0f);
  53.             for (final Player players : Bukkit.getOnlinePlayers()) {
  54.                 players.playEffect(p.getLocation(), Effect.FIREWORKS_SPARK, 2000);
  55.                 p.getWorld().playEffect(p.getLocation(), Effect.SPELL, 10);
  56.                 p.getWorld().playEffect(p.getLocation(), Effect.INSTANT_SPELL, 10);
  57.             }
  58.         }
  59.     }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top