Facebook
From PietregTM, 5 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 226
  1. public class PlayerMoveListener implements Listener {
  2.        
  3.   @EventHandler
  4.   public void onMove(PlayerMoveEvent e)
  5.   {
  6.     if (e.isCancelled()) {
  7.       return;
  8.     }
  9.     Player p = e.getPlayer();
  10.     Combat c = CombatManager.getCombat(p);
  11.     if (c.hasFight())
  12.     {
  13.       Location to = e.getTo();
  14.       Location from = e.getFrom();
  15.       if (((from.getBlockX() != to.getBlockX()) || (from.getBlockY() != to.getBlockY()) || (from.getBlockZ() != to.getBlockZ())) && (ChatUtil.Location(Config.SPAWNLINE_MINX, Config.SPAWNLINE_MAXX, Config.SPAWNLINE_MINZ, Config.SPAWNLINE_MAXZ, to)))
  16.       {
  17.         Location l = p.getLocation().subtract(10, 80, 10);
  18.         double distance = p.getLocation().distance(l);
  19.         Vector v = l.toVector().add(new Vector(1, 1, 1)).multiply(3.0D / distance);
  20.         p.setVelocity(v.multiply(4.5D).setY(0.5));
  21.         ChatUtil.sendTitleMessage(p, Config.MESSAGES_TITLE, Config.SPAWNLINE_MESSAGE, 75, 70, 65);
  22.         e.setCancelled(true);
  23.         return;
  24.       }
  25.     }
  26.   }
  27. }
  28.