Advertisement
Guest User

WaterCombat

a guest
Mar 25th, 2015
379
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package nl.Flamedek.WaterCombat;
  2.  
  3. import org.bukkit.event.EventHandler;
  4. import org.bukkit.event.Listener;
  5. import org.bukkit.event.player.PlayerVelocityEvent;
  6. import org.bukkit.plugin.java.JavaPlugin;
  7.  
  8. public class WaterCombat extends JavaPlugin implements Listener {
  9.    
  10.     @Override
  11.     public void onEnable() {
  12.         getServer().getPluginManager().registerEvents(this, this);
  13.     }
  14.    
  15.     @EventHandler
  16.     public void onHit(PlayerVelocityEvent event) {
  17.         // check if is in water
  18.         if(event.getPlayer().getLocation().getBlock().isLiquid()) {
  19.             // if so, lower velocity
  20.             event.getPlayer().setVelocity(event.getVelocity().multiply(0.55));
  21.            
  22.         }
  23.     }
  24. }
Advertisement
RAW Paste Data Copied
Advertisement