<commit_before>package net.acomputerdog.starterkits;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.*;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class PluginStarterKits extends JavaPlugin implements Listener {

    private ItemStack[] kit;
    private boolean kitsEnabled;
    private File configFile;
    private File playerFile;
    private Set<String> kittedPlayers;

    //don't reset during onEnable or onDisable
    private boolean reloading = false;

    @Override
    public void onEnable() {
        try {
            kittedPlayers = new HashSet<>();
            if (!getDataFolder().isDirectory() && !getDataFolder().mkdirs()) {
                getLogger().warning("Unable to create data directory!");
            }
            configFile = new File(getDataFolder(), "config.yml");
            if (!configFile.isFile()) {
                copyConfig();
            }
            playerFile = new File(getDataFolder(), "players.lst");
            if (!playerFile.isFile()) {
                savePlayers();
            }
            readConfiguration();
            //don't register events or load players if they are not needed
            if (kitsEnabled) {
                loadPlayers();
                if (!reloading) { //don't register events twice
                    getServer().getPluginManager().registerEvents(this, this);
                }
            } else {
                getLogger().info("Kits disabled; not loading players.");
            }
        } catch (Exception e) {
            super.setEnabled(false);
            throw new RuntimeException("Exception starting up!", e);
        }
    }

    @Override
    public void onDisable() {
        kittedPlayers = null;
        configFile = null;
        playerFile = null;
        kit = null;
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlayerJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        String uuid = p.getUniqueId().toString();
        if (!kittedPlayers.contains(uuid) && p.hasPermission("starterkits.receive")) {
            try {
                registerPlayer(uuid);
                p.getInventory().addItem(kit);
            } catch (IOException ex) {
                getLogger().warning("Exception giving kit to player: " + uuid);
                ex.printStackTrace();
                p.sendMessage(ChatColor.RED + "An exception occurred giving you a starter kit!  Please report this, and/or reconnect to try again.");
            }
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        switch (command.getName().toLowerCase()) {
            case "reload":
                reloading = true;
                onDisable();
                onEnable();
                reloading = false;
                break;
            default:
                sender.sendMessage(ChatColor.RED + "Unknown command!");
        }
        return true;
    }

    private void registerPlayer(String uuid) throws IOException {
        kittedPlayers.add(uuid);
        savePlayers();
    }<commit_msg>Fix reload and /reloadkits<commit_after>package net.acomputerdog.starterkits;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.*;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class PluginStarterKits extends JavaPlugin implements Listener {

    private ItemStack[] kit;
    private boolean kitsEnabled;
    private File configFile;
    private File playerFile;
    private Set<String> kittedPlayers;

    @Override
    public void onEnable() {
        try {
            kittedPlayers = new HashSet<>();
            if (!getDataFolder().isDirectory() && !getDataFolder().mkdirs()) {
                getLogger().warning("Unable to create data directory!");
            }
            configFile = new File(getDataFolder(), "config.yml");
            if (!configFile.isFile()) {
                copyConfig();
            }
            playerFile = new File(getDataFolder(), "players.lst");
            if (!playerFile.isFile()) {
                savePlayers();
            }
            readConfiguration();
            //don't register events or load players if they are not needed
            if (kitsEnabled) {
                loadPlayers();
                getServer().getPluginManager().registerEvents(this, this);
            } else {
                getLogger().info("Kits disabled; not loading players.");
            }
        } catch (Exception e) {
            super.setEnabled(false);
            throw new RuntimeException("Exception starting up!", e);
        }
    }

    @Override
    public void onDisable() {
        kittedPlayers = null;
        configFile = null;
        playerFile = null;
        kit = null;

        HandlerList.unregisterAll((JavaPlugin) this);
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlayerJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        String uuid = p.getUniqueId().toString();
        if (!kittedPlayers.contains(uuid) && p.hasPermission("starterkits.receive")) {
            try {
                registerPlayer(uuid);
                p.getInventory().addItem(kit);
            } catch (IOException ex) {
                getLogger().warning("Exception giving kit to player: " + uuid);
                ex.printStackTrace();
                p.sendMessage(ChatColor.RED + "An exception occurred giving you a starter kit!  Please report this, and/or reconnect to try again.");
            }
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        switch (command.getName().toLowerCase()) {
            case "reloadkits":
                if (sender.hasPermission("starterkits.reload")) {
                    onDisable();
                    onEnable();
                    sender.sendMessage(ChatColor.AQUA + "Reload complete.");
                    getLogger().info("Reloaded.");
                } else {
                    sender.sendMessage(ChatColor.RED + "You do not have permission.");
                }
                break;
            default:
                sender.sendMessage(ChatColor.RED + "Unknown command!  Please report this error!");
        }
        return true;
    }

    private void registerPlayer(String uuid) throws IOException {
        kittedPlayers.add(uuid);
        savePlayers();
    }
{'fraction_non_alphanumeric': 0.10472972972972973, 'fraction_numerical': 0.0, 'mean_word_length': 2.2070833333333333, 'pattern_counts': {'":': 2, '<': 7, '<?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': '5447842', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1942, 'n_words': 476}