Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HashMap<Player, Double> lastY = new HashMap<>();
- HashMap<Player, Double> lastDiff = new HashMap<>();
- HashMap<Player, Integer> lv = new HashMap<>();
- public MotionC(String name, CheckType type, boolean enabled, boolean punishable, int max) {
- super(name, type, enabled, punishable, max);
- ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Plugin.get(),
- PacketType.Play.Client.POSITION,
- PacketType.Play.Client.POSITION_LOOK) {
- @Override
- public void onPacketReceiving(PacketEvent e) {
- Player p = e.getPlayer();
- PlayerUtils data = new PlayerUtils(p);
- double y = p.getLocation().getY();
- if(!lastY.containsKey(p))
- {
- lastY.put(p, y);
- return;
- }
- if(data.isNearLiquid())
- {
- lastY.put(p, y);
- return;
- }
- if(data.blockNearHead())
- {
- lastY.put(p, y);
- return;
- }
- if(data.isNearClimbable() || data.isOnClimbable())
- {
- lastY.put(p, y);
- return;
- }
- double ly = lastY.get(p);
- lastY.put(p, y);
- double diff = y-ly;
- if(!lastDiff.containsKey(p))
- {
- lastDiff.put(p, diff);
- return;
- }
- double lDiff = lastDiff.get(p);
- lastDiff.put(p, diff);
- if(!p.isFlying() && diff == lDiff && diff != 0.0D)
- {
- if(!lv.containsKey(p))
- {
- lv.put(p, 1);
- }else
- {
- lv.put(p, lv.get(p)+1);
- }
- if(lv.get(p) > 1)
- {
- flag(p, "Ydist = " + diff + ", Last-Ydist = " + lDiff + ", Is-Flying = " + p.isFlying());
- lv.put(p, 0);
- }
- }else
- {
- lv.put(p, 0);
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement