<commit_before>package us.myles.ViaVersion;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import org.bukkit.scheduler.BukkitRunnable;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
import us.myles.ViaVersion.util.PipelineUtil;
import us.myles.ViaVersion.util.ReflectionUtil;

import java.util.Map;
import java.util.UUID;

public class ViaIdleThread extends BukkitRunnable {
    private final Map<UUID, UserConnection> portedPlayers;
    private final Object idlePacket;

    public ViaIdleThread(Map<UUID, UserConnection> portedPlayers) {
        this.portedPlayers = portedPlayers;
        try {
            Class<?> idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying");
            idlePacket = idlePacketClass.newInstance();
        } catch (InstantiationException | IllegalArgumentException | IllegalAccessException | ClassNotFoundException e) {
            throw new RuntimeException("Couldn't find/make player idle packet, help!", e);
        }
    }

    @Override
    public void run() {
        for (UserConnection info : portedPlayers.values()) {
            if (info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
                long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
                if (nextIdleUpdate <= System.currentTimeMillis()) {
                    ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", info.getChannel().pipeline());
                    context.fireChannelRead(idlePacket);

                    info.get(MovementTracker.class).incrementIdlePacket();
                }
            }
        }
    }
}<commit_msg>Fix Disconnect Issue (It's not really harmful but still)<commit_after>package us.myles.ViaVersion;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import org.bukkit.scheduler.BukkitRunnable;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
import us.myles.ViaVersion.util.PipelineUtil;
import us.myles.ViaVersion.util.ReflectionUtil;

import java.util.Map;
import java.util.UUID;

public class ViaIdleThread extends BukkitRunnable {
    private final Map<UUID, UserConnection> portedPlayers;
    private final Object idlePacket;

    public ViaIdleThread(Map<UUID, UserConnection> portedPlayers) {
        this.portedPlayers = portedPlayers;
        try {
            Class<?> idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying");
            idlePacket = idlePacketClass.newInstance();
        } catch (InstantiationException | IllegalArgumentException | IllegalAccessException | ClassNotFoundException e) {
            throw new RuntimeException("Couldn't find/make player idle packet, help!", e);
        }
    }

    @Override
    public void run() {
        for (UserConnection info : portedPlayers.values()) {
            if (info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
                long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
                if (nextIdleUpdate <= System.currentTimeMillis()) {
                    ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", info.getChannel().pipeline());
                    if(info.getChannel().isOpen()) {
                        if (context != null) {
                            context.fireChannelRead(idlePacket);

                            info.get(MovementTracker.class).incrementIdlePacket();
                        }
                    }
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09611041405269762, 'fraction_numerical': 0.008030112923462986, 'mean_word_length': 3.0756646216768915, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2975850', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1110, 'n_words': 186}