<commit_before>package pl.asie.charset.lib.audio;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import pl.asie.charset.api.audio.AudioPacket;
import pl.asie.charset.api.audio.IAudioSink;
import pl.asie.charset.lib.ModCharsetLib;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public abstract class AudioPacketCharset extends AudioPacket {
    protected final int id;
    protected final byte[] data;
    protected final int time;

    public AudioPacketCharset(int id, byte[] data, int time) {
        this.id = id;
        this.data = data;
        this.time = time;
    }

    public abstract PacketAudioData.Codec getCodec();

    @Override
    public void beginPropagation() {

    }

    @Override
    public void endPropagation() {
        PacketAudioData packet = new PacketAudioData(id, getCodec(), sinks, data, time);

        Map<WorldServer, Set<IAudioSink>> worlds = new HashMap<>();
        for (IAudioSink sink : sinks) {
            if (worlds.containsKey(sink.getWorld())) {
                worlds.get(sink.getWorld()).add(sink);
            } else {
                HashSet<IAudioSink> sinkLocal = new HashSet<>();
                sinkLocal.add(sink);
                worlds.put((WorldServer) sink.getWorld(), sinkLocal);
            }
        }

        for (WorldServer world : worlds.keySet()) {
            for (IAudioSink sink : worlds.get(world)) {
                BlockPos pos = new BlockPos(sink.getPos());
                for (EntityPlayerMP player : world.getMinecraftServer().getPlayerList().getPlayerList()) {
                    if (player.worldObj.provider.getDimension() == world.provider.getDimension()) {
                        if (world.getPlayerChunkMap().isPlayerWatchingChunk(player, pos.getX() >> 4, pos.getZ() >> 4)) {
                            ModCharsetLib.packet.sendTo(packet, player);
                        }
                    }
                }
            }
        }
    }
}
<commit_msg>fixed potential packet spam<commit_after>package pl.asie.charset.lib.audio;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import pl.asie.charset.api.audio.AudioPacket;
import pl.asie.charset.api.audio.IAudioSink;
import pl.asie.charset.lib.ModCharsetLib;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public abstract class AudioPacketCharset extends AudioPacket {
    protected final int id;
    protected final byte[] data;
    protected final int time;

    public AudioPacketCharset(int id, byte[] data, int time) {
        this.id = id;
        this.data = data;
        this.time = time;
    }

    public abstract PacketAudioData.Codec getCodec();

    @Override
    public void beginPropagation() {

    }

    @Override
    public void endPropagation() {
        PacketAudioData packet = new PacketAudioData(id, getCodec(), sinks, data, time);

        Map<WorldServer, Set<IAudioSink>> worlds = new HashMap<>();
        for (IAudioSink sink : sinks) {
            if (worlds.containsKey(sink.getWorld())) {
                worlds.get(sink.getWorld()).add(sink);
            } else {
                HashSet<IAudioSink> sinkLocal = new HashSet<>();
                sinkLocal.add(sink);
                worlds.put((WorldServer) sink.getWorld(), sinkLocal);
            }
        }

        for (WorldServer world : worlds.keySet()) {
            for (EntityPlayerMP player : world.getMinecraftServer().getPlayerList().getPlayerList()) {
                if (player.worldObj.provider.getDimension() == world.provider.getDimension()) {
                    for (IAudioSink sink : worlds.get(world)) {
                       BlockPos pos = new BlockPos(sink.getPos());
                        if (world.getPlayerChunkMap().isPlayerWatchingChunk(player, pos.getX() >> 4, pos.getZ() >> 4)) {
                            ModCharsetLib.packet.sendTo(packet, player);
                            break;
                        }
                    }
                }
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.11356092935040303, 'fraction_numerical': 0.000948316737790422, 'mean_word_length': 2.1817496229260933, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '6271530', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1204, 'n_words': 246}