Guest User

Untitled

a guest
Aug 18th, 2019
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HashMap<Player, Double> lastY = new HashMap<>();
  2. HashMap<Player, Double> lastDiff = new HashMap<>();
  3. HashMap<Player, Integer> lv = new HashMap<>();
  4.  
  5. public MotionC(String name, CheckType type, boolean enabled, boolean punishable, int max) {
  6. super(name, type, enabled, punishable, max);
  7. ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Plugin.get(),
  8. PacketType.Play.Client.POSITION,
  9. PacketType.Play.Client.POSITION_LOOK) {
  10. @Override
  11. public void onPacketReceiving(PacketEvent e) {
  12. Player p = e.getPlayer();
  13. PlayerUtils data = new PlayerUtils(p);
  14.  
  15. double y = p.getLocation().getY();
  16.  
  17. if(!lastY.containsKey(p))
  18. {
  19. lastY.put(p, y);
  20. return;
  21. }
  22.  
  23. if(data.isNearLiquid())
  24. {
  25. lastY.put(p, y);
  26. return;
  27. }
  28.  
  29. if(data.blockNearHead())
  30. {
  31. lastY.put(p, y);
  32. return;
  33. }
  34.  
  35. if(data.isNearClimbable() || data.isOnClimbable())
  36. {
  37. lastY.put(p, y);
  38. return;
  39. }
  40.  
  41. double ly = lastY.get(p);
  42. lastY.put(p, y);
  43.  
  44. double diff = y-ly;
  45.  
  46. if(!lastDiff.containsKey(p))
  47. {
  48. lastDiff.put(p, diff);
  49. return;
  50. }
  51.  
  52. double lDiff = lastDiff.get(p);
  53. lastDiff.put(p, diff);
  54.  
  55. if(!p.isFlying() && diff == lDiff && diff != 0.0D)
  56. {
  57. if(!lv.containsKey(p))
  58. {
  59. lv.put(p, 1);
  60. }else
  61. {
  62. lv.put(p, lv.get(p)+1);
  63. }
  64.  
  65. if(lv.get(p) > 1)
  66. {
  67. flag(p, "Ydist = " + diff + ", Last-Ydist = " + lDiff + ", Is-Flying = " + p.isFlying());
  68. lv.put(p, 0);
  69. }
  70. }else
  71. {
  72. lv.put(p, 0);
  73. }
  74.  
  75. }
  76. });
  77. }
RAW Paste Data