<commit_before>package tc.oc.commons.bukkit.stats;

import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.CommandSender;
import tc.oc.commons.bukkit.chat.Audiences;
import tc.oc.commons.bukkit.chat.HeaderComponent;
import tc.oc.commons.bukkit.chat.PlayerComponent;
import tc.oc.commons.bukkit.commands.UserFinder;
import tc.oc.commons.bukkit.nick.IdentityProvider;
import tc.oc.commons.core.chat.Audience;
import tc.oc.commons.core.chat.Component;
import tc.oc.commons.core.commands.CommandFutureCallback;
import tc.oc.commons.core.commands.Commands;
import tc.oc.minecraft.scheduler.SyncExecutor;

import javax.inject.Inject;
import java.util.HashMap;

public class StatsCommands implements Commands {

    private final SyncExecutor syncExecutor;
    private final UserFinder userFinder;
    private final Audiences audiences;
    private final IdentityProvider identityProvider;

    @Inject
    StatsCommands(UserFinder userFinder, SyncExecutor executor, Audiences audiences, IdentityProvider identityProvider) {
        this.userFinder = userFinder;
        this.syncExecutor = executor;
        this.audiences = audiences;
        this.identityProvider = identityProvider;
    }

    @Command(
            aliases = { "stats"},
            usage = "[player]",
            desc = "Shows a player's stats",
            min = 0,
            max = 1
    )
    @CommandPermissions("projectares.stats")
    public void listStats(final CommandContext args, final CommandSender sender) throws CommandException {
        syncExecutor.callback(
                userFinder.findUser(sender, args, 0, UserFinder.Default.SENDER),
                CommandFutureCallback.onSuccess(sender, args, result -> {
                    HashMap<String, Double> stats = StatsUtil.getStats(result.user);

                    Audience audience = audiences.get(sender);

                    audience.sendMessage(new HeaderComponent(new Component(ChatColor.AQUA)
                            .translate("stats.list", new PlayerComponent(identityProvider.currentIdentity(result.user)))));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.kills", new Component(String.format("%,d", (int)(double)stats.get("kills")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.deaths", new Component(String.format("%,d", (int)(double)stats.get("deaths")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.kd", new Component(String.format("%.2f", stats.get("kd")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.wools", new Component(String.format("%,d", (int)(double)stats.get("wool_placed")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.cores", new Component(String.format("%,d", (int)(double)stats.get("cores_leaked")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.monuments", new Component(String.format("%,d", (int)(double)stats.get("destroyables_destroyed")), ChatColor.BLUE)));
                })
        );
    }

}<commit_msg>Fix /stats revealing identities<commit_after>package tc.oc.commons.bukkit.stats;

import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.CommandSender;
import tc.oc.commons.bukkit.chat.Audiences;
import tc.oc.commons.bukkit.chat.HeaderComponent;
import tc.oc.commons.bukkit.chat.PlayerComponent;
import tc.oc.commons.bukkit.commands.UserFinder;
import tc.oc.commons.bukkit.nick.Identity;
import tc.oc.commons.bukkit.nick.IdentityProvider;
import tc.oc.commons.core.chat.Audience;
import tc.oc.commons.core.chat.Component;
import tc.oc.commons.core.commands.CommandFutureCallback;
import tc.oc.commons.core.commands.Commands;
import tc.oc.minecraft.scheduler.SyncExecutor;

import javax.inject.Inject;
import java.util.HashMap;

public class StatsCommands implements Commands {

    private final SyncExecutor syncExecutor;
    private final UserFinder userFinder;
    private final Audiences audiences;
    private final IdentityProvider identityProvider;

    @Inject
    StatsCommands(UserFinder userFinder, SyncExecutor executor, Audiences audiences, IdentityProvider identityProvider) {
        this.userFinder = userFinder;
        this.syncExecutor = executor;
        this.audiences = audiences;
        this.identityProvider = identityProvider;
    }

    @Command(
            aliases = { "stats"},
            usage = "[player]",
            desc = "Shows a player's stats",
            min = 0,
            max = 1
    )
    @CommandPermissions("projectares.stats")
    public void listStats(final CommandContext args, final CommandSender sender) throws CommandException {
        syncExecutor.callback(
                userFinder.findLocalPlayer(sender, args, 0, UserFinder.Default.SENDER),
                CommandFutureCallback.onSuccess(sender, args, result -> {
                    HashMap<String, Double> stats = StatsUtil.getStats(result.user);

                    Audience audience = audiences.get(sender);
                    Identity playerIdentity = identityProvider.currentIdentity(result.user);

                    if (!playerIdentity.isRevealed(sender)) {
                        stats.put("kills", 0.0);
                        stats.put("deaths", 0.0);
                        stats.put("kd", 0.0);
                        stats.put("kk", 0.0);
                        stats.put("wool_placed", 0.0);
                        stats.put("cores_leaked", 0.0);
                        stats.put("destroyables_destroyed", 0.0);
                        stats.put("tkrate", 0.0);
                    }

                    audience.sendMessage(new HeaderComponent(new Component(ChatColor.AQUA)
                            .translate("stats.list", new PlayerComponent(playerIdentity))));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.kills", new Component(String.format("%,d", (int)(double)stats.get("kills")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.deaths", new Component(String.format("%,d", (int)(double)stats.get("deaths")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.kd", new Component(String.format("%.2f", stats.get("kd")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.wools", new Component(String.format("%,d", (int)(double)stats.get("wool_placed")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.cores", new Component(String.format("%,d", (int)(double)stats.get("cores_leaked")), ChatColor.BLUE)));
                    audience.sendMessage(new Component(ChatColor.AQUA)
                            .translate("stats.monuments", new Component(String.format("%,d", (int)(double)stats.get("destroyables_destroyed")), ChatColor.BLUE)));
                })
        );
    }

}
{'fraction_non_alphanumeric': 0.11879813154904684, 'fraction_numerical': 0.005302360813028658, 'mean_word_length': 2.6846511627906975, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '681173', 'n_tokens_mistral': 2197, 'n_tokens_neox': 2167, 'n_words': 354}