<commit_before>package net.md_5.bungee.protocol;

import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;

import java.util.UUID;

@RequiredArgsConstructor
public abstract class DefinedPacket
{
    private static final int MAX_STRING_ARRAY_LENGTH = 512;
    private static final int MAX_BYTE_ARRAY_LENGTH = Short.MAX_VALUE;

    public static void writeString(String s, ByteBuf buf)
    {
        Preconditions.checkArgument( s.length() <= Short.MAX_VALUE, "Cannot send string longer than Short.MAX_VALUE (got %s characters)", s.length() );

        byte[] b = s.getBytes( Charsets.UTF_8 );
        writeVarInt( b.length, buf );
        buf.writeBytes( b );
    }

    public static String readString(ByteBuf buf)
    {
        int len = readVarInt( buf );
        Preconditions.checkArgument( len <= Short.MAX_VALUE, "Cannot receive string longer than Short.MAX_VALUE (got %s characters)", len );

        byte[] b = new byte[ len ];
        buf.readBytes( b );

        return new String( b, Charsets.UTF_8 );
    }

    public static void writeArray(byte[] b, ByteBuf buf)
    {
        Preconditions.checkArgument(b.length <= MAX_BYTE_ARRAY_LENGTH, "Cannot write byte array longer than %s (got %s)", MAX_BYTE_ARRAY_LENGTH, b.length);
        writeVarInt( b.length, buf );
        buf.writeBytes( b );
    }
<commit_msg>Use the limit @Thinkofname added to Spigot CraftBukkit<commit_after>package net.md_5.bungee.protocol;

import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;

import java.util.UUID;

@RequiredArgsConstructor
public abstract class DefinedPacket
{
    private static final int MAX_STRING_ARRAY_LENGTH = 512;
    private static final int MAX_BYTE_ARRAY_LENGTH = 256;

    public static void writeString(String s, ByteBuf buf)
    {
        Preconditions.checkArgument( s.length() <= Short.MAX_VALUE, "Cannot send string longer than Short.MAX_VALUE (got %s characters)", s.length() );

        byte[] b = s.getBytes( Charsets.UTF_8 );
        writeVarInt( b.length, buf );
        buf.writeBytes( b );
    }

    public static String readString(ByteBuf buf)
    {
        int len = readVarInt( buf );
        Preconditions.checkArgument( len <= Short.MAX_VALUE, "Cannot receive string longer than Short.MAX_VALUE (got %s characters)", len );

        byte[] b = new byte[ len ];
        buf.readBytes( b );

        return new String( b, Charsets.UTF_8 );
    }

    public static void writeArray(byte[] b, ByteBuf buf)
    {
        Preconditions.checkArgument(b.length <= MAX_BYTE_ARRAY_LENGTH, "Cannot write byte array longer than %s (got %s)", MAX_BYTE_ARRAY_LENGTH, b.length);
        writeVarInt( b.length, buf );
        buf.writeBytes( b );
    }

{'fraction_non_alphanumeric': 0.10278804165267047, 'fraction_numerical': 0.0050386294927779645, 'mean_word_length': 3.372980910425844, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '2769452', 'n_tokens_mistral': 906, 'n_tokens_neox': 889, 'n_words': 255}