Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public class Knockback implements Listener {
  2.  
  3. private main plugin = main.getPlugin(main.class);
  4.  
  5. @EventHandler
  6. public void onPunch(EntityDamageByEntityEvent e) {
  7.  
  8. if (e.getEntity() instanceof Player) {
  9. if (e.getDamager() instanceof Player) {
  10. if (!(ZoutMoreKB.zout.contains(e.getDamager().getName()))){
  11. Player p = (Player) e.getDamager();
  12. Player t = (Player) e.getEntity();
  13.  
  14. Location l = t.getLocation().subtract(p.getLocation());
  15. double distance = t.getLocation().distance(p.getLocation());
  16. Vector v = l.toVector().multiply(0.26 / distance);
  17. if (sumoArraylists.players.contains(p.getName()) && sumoArraylists.players.contains(t.getName())) {
  18. t.setVelocity(v);
  19. }
  20. }
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement