<commit_before>package com.minelittlepony.client.pony;

import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.common.util.MoreStreams;
import com.minelittlepony.hdskins.ISkinCacheClearListener;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.IPonyManager;
import com.minelittlepony.settings.PonyConfig;
import com.minelittlepony.settings.PonyLevel;
import com.minelittlepony.util.chron.ChronicCache;
import com.minelittlepony.util.math.MathUtil;

import javax.annotation.Nullable;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceReloadListener;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

/**
 * The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin.
 *
 */
public class PonyManager implements IPonyManager, ResourceReloadListener, ISkinCacheClearListener {

    private static final Gson GSON = new Gson();

    /**
     * All currently loaded background ponies.
     */
    private List<Identifier> backgroundPonyList = Lists.newArrayList();

    private final PonyConfig config;

    private final ChronicCache<Identifier, Pony> poniesCache = new ChronicCache<>();

    public PonyManager(PonyConfig config) {
        this.config = config;
    }

    @Override
    public IPony getPony(Identifier resource) {
        return poniesCache.retrieve(resource, Pony::new);
    }

    @Override
    public IPony getPony(PlayerEntity player) {
        Identifier skin = getSkin(player);
        UUID uuid = player.getGameProfile().getId();

        if (Pony.getBufferedImage(skin) == null) {
            return getDefaultPony(uuid);
        }

        return getPony(skin, uuid);
    }

    @Nullable
    Identifier getSkin(PlayerEntity player) {
        if (player instanceof AbstractClientPlayerEntity) {
            return ((AbstractClientPlayerEntity)player).getSkinTexture();
        }

        return null;
    }

    public IPony getPony(PlayerListEntry playerInfo) {
        Identifier skin = playerInfo.getSkinTexture();
        UUID uuid = playerInfo.getProfile().getId();

        if (Pony.getBufferedImage(skin) == null) {
            return getDefaultPony(uuid);
        }

        return getPony(skin, uuid);
    }

    @Override
    public IPony getPony(Identifier resource, UUID uuid) {
        IPony pony = getPony(resource);

        if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
            return getBackgroundPony(uuid);
        }

        return pony;
    }

    @Override
    public IPony getDefaultPony(UUID uuid) {
        if (config.getPonyLevel() != PonyLevel.PONIES) {
            return getPony(DefaultSkinHelper.getTexture(uuid));
        }

        return getBackgroundPony(uuid);
    }

    @Override
    public IPony getBackgroundPony(UUID uuid) {
        if (getNumberOfPonies() == 0 || isUser(uuid)) {
            return getPony(IPonyManager.getDefaultSkin(uuid));
        }

        int bgi = MathUtil.mod(uuid.hashCode(), getNumberOfPonies());

        return getPony(backgroundPonyList.get(bgi));
    }

    private boolean isUser(UUID uuid) {
        return MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.getUuid().equals(uuid);
    }

    @Override
    public IPony removePony(Identifier resource) {
        return poniesCache.remove(resource);
    }

    @Override
    public CompletableFuture<Void> reload(Synchronizer sync, ResourceManager sender, Profiler profiler, Profiler profile2, Executor executor, Executor executor2) {
        return CompletableFuture.runAsync(() -> {
            profiler.push("Reloading all background ponies");
            reloadAll(sender);
            profiler.endTick();
        });
    }

    public void reloadAll(ResourceManager resourceManager) {<commit_msg>I now know what these parameters are!<commit_after>package com.minelittlepony.client.pony;

import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.common.util.MoreStreams;
import com.minelittlepony.hdskins.ISkinCacheClearListener;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.IPonyManager;
import com.minelittlepony.settings.PonyConfig;
import com.minelittlepony.settings.PonyLevel;
import com.minelittlepony.util.chron.ChronicCache;
import com.minelittlepony.util.math.MathUtil;

import javax.annotation.Nullable;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceReloadListener;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

/**
 * The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin.
 *
 */
public class PonyManager implements IPonyManager, ResourceReloadListener, ISkinCacheClearListener {

    private static final Gson GSON = new Gson();

    /**
     * All currently loaded background ponies.
     */
    private List<Identifier> backgroundPonyList = Lists.newArrayList();

    private final PonyConfig config;

    private final ChronicCache<Identifier, Pony> poniesCache = new ChronicCache<>();

    public PonyManager(PonyConfig config) {
        this.config = config;
    }

    @Override
    public IPony getPony(Identifier resource) {
        return poniesCache.retrieve(resource, Pony::new);
    }

    @Override
    public IPony getPony(PlayerEntity player) {
        Identifier skin = getSkin(player);
        UUID uuid = player.getGameProfile().getId();

        if (Pony.getBufferedImage(skin) == null) {
            return getDefaultPony(uuid);
        }

        return getPony(skin, uuid);
    }

    @Nullable
    Identifier getSkin(PlayerEntity player) {
        if (player instanceof AbstractClientPlayerEntity) {
            return ((AbstractClientPlayerEntity)player).getSkinTexture();
        }

        return null;
    }

    public IPony getPony(PlayerListEntry playerInfo) {
        Identifier skin = playerInfo.getSkinTexture();
        UUID uuid = playerInfo.getProfile().getId();

        if (Pony.getBufferedImage(skin) == null) {
            return getDefaultPony(uuid);
        }

        return getPony(skin, uuid);
    }

    @Override
    public IPony getPony(Identifier resource, UUID uuid) {
        IPony pony = getPony(resource);

        if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
            return getBackgroundPony(uuid);
        }

        return pony;
    }

    @Override
    public IPony getDefaultPony(UUID uuid) {
        if (config.getPonyLevel() != PonyLevel.PONIES) {
            return getPony(DefaultSkinHelper.getTexture(uuid));
        }

        return getBackgroundPony(uuid);
    }

    @Override
    public IPony getBackgroundPony(UUID uuid) {
        if (getNumberOfPonies() == 0 || isUser(uuid)) {
            return getPony(IPonyManager.getDefaultSkin(uuid));
        }

        int bgi = MathUtil.mod(uuid.hashCode(), getNumberOfPonies());

        return getPony(backgroundPonyList.get(bgi));
    }

    private boolean isUser(UUID uuid) {
        return MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.getUuid().equals(uuid);
    }

    @Override
    public IPony removePony(Identifier resource) {
        return poniesCache.remove(resource);
    }

    @Override
    public CompletableFuture<Void> reload(Synchronizer sync, ResourceManager sender, Profiler profiler, Profiler profile2, Executor backendExecutor, Executor mainThreadExecutor) {
        return CompletableFuture.runAsync(() -> {
            profiler.push("Reloading all background ponies");
            reloadAll(sender);
            profiler.endTick();
        }, backendExecutor);
    }

    public void reloadAll(ResourceManager resourceManager) {
{'fraction_non_alphanumeric': 0.09734991887506761, 'fraction_numerical': 0.0005408328826392645, 'mean_word_length': 3.550196850393701, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4152466', 'n_tokens_mistral': 2709, 'n_tokens_neox': 2684, 'n_words': 549}