package us.myles.ViaVersion.protocols.protocol1_9to1_8;

import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;

public class ViaIdleThread implements Runnable {
    @Override
    public void run() {
        for (UserConnection info : Via.getManager().getConnections()) {
            ProtocolInfo protocolInfo = info.getProtocolInfo();
            if (protocolInfo != null && protocolInfo.getPipeline().contains(Protocol1_9To1_8.class)) {
                long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
                if (nextIdleUpdate <= System.currentTimeMillis()) {
                    if (info.getChannel().isOpen()) {
                        Via.getManager().getProviders().get(MovementTransmitterProvider.class).sendPlayer(info);
                    }
                }
            }
        }
    }
}

@@ -416,16 +416,17 @@
 nable %7B%0A
+%0A
     @Ove
@@ -624,19 +624,20 @@
 nfo 
-!
+=
 = null 
-&& 
+%7C%7C !
 prot
@@ -693,20 +693,27 @@
 class)) 
-%7B%0A  
+continue;%0A%0A
         
@@ -720,29 +720,39 @@
     
-  long nextIdleUpdate
+MovementTracker movementTracker
  = i
@@ -781,16 +781,119 @@
 r.class)
+;%0A            if (movementTracker == null) continue;%0A%0A            long nextIdleUpdate = movementTracker
 .getNext
@@ -902,28 +902,24 @@
 lePacket();%0A
-    
             
@@ -970,36 +970,12 @@
 is()
-) %7B%0A                    if (
+ && 
 info
@@ -996,32 +996,24 @@
 isOpen()) %7B%0A
-        
             
@@ -1109,48 +1109,8 @@
 o);%0A
-                    %7D%0A                %7D%0A
     

Fix NPE on proxies in ViaIdleThread Fixes #1878