<commit_before>package io.github.thatsmusic99.headsplus.commands;

import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.api.events.SellHeadEvent;
import io.github.thatsmusic99.headsplus.commands.maincommand.DebugPrint;
import io.github.thatsmusic99.headsplus.config.MessagesManager;
import io.github.thatsmusic99.headsplus.config.MainConfig;
import io.github.thatsmusic99.headsplus.inventories.InventoryManager;
import io.github.thatsmusic99.headsplus.managers.PersistenceManager;
import io.github.thatsmusic99.headsplus.managers.SellableHeadsManager;
import io.github.thatsmusic99.headsplus.util.CachedValues;
import io.github.thatsmusic99.headsplus.util.HPUtils;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

@CommandInfo(
        commandname = "sellhead",
        permission = "headsplus.sellhead",
        maincommand = false,
        usage = "/sellhead [All|Head ID] [#]",
        descriptionPath = "descriptions.sellhead"
)
public class SellHead implements CommandExecutor, IHeadsPlusCommand, TabCompleter {

	private final MessagesManager hpc = MessagesManager.get();
	private final int[] slots;

	public SellHead() {
	    slots = new int[45];
	    slots[44] = 45; // off-hand slot
	    for (int i = 0; i < 44; i++) {
            slots[i] = i;
        }
    }

    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
		try {
		    if (!(MainConfig.get().getMainFeatures().SELL_HEADS && HeadsPlus.get().isVaultEnabled())) {
                hpc.sendMessage("commands.errors.disabled", sender);
                return true;
            }
		    if (!(sender instanceof Player)) {
                hpc.sendMessage("commands.errors.not-a-player", sender);
                return true;
            }
		    Player player = (Player) sender;
		    if (args.length == 0) {
		        // Open the GUI
                if (MainConfig.get().getSellingHeads().USE_GUI && player.hasPermission("headsplus.sellhead.gui")) {
                    HashMap<String, String> context = new HashMap<>();
                    context.put("section", "mobs");
                    InventoryManager.getManager(player).open(InventoryManager.InventoryType.SELLHEAD_CATEGORY, context);
                    return true;
                } else {
                    // Get the item in the player's hand
                    ItemStack item = player.getInventory().getItemInMainHand();
                    // If the item exists and is sellable,
                    if (!PersistenceManager.get().isSellable(item)) return true;
                    // Get the ID
                    String id = PersistenceManager.get().getSellType(item);
                    if (!SellableHeadsManager.get().isRegistered(id)) return true;
                    double price = SellableHeadsManager.get().getPrice(id) * item.getAmount();
                    SellData data = new SellData(player);
                    data.addID(id, item.getAmount());
                    data.addSlot(player.getInventory().getHeldItemSlot(), item.getAmount());
                    pay(player, data, price);<commit_msg>Fix #65<commit_after>package io.github.thatsmusic99.headsplus.commands;

import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.api.events.SellHeadEvent;
import io.github.thatsmusic99.headsplus.commands.maincommand.DebugPrint;
import io.github.thatsmusic99.headsplus.config.MessagesManager;
import io.github.thatsmusic99.headsplus.config.MainConfig;
import io.github.thatsmusic99.headsplus.inventories.InventoryManager;
import io.github.thatsmusic99.headsplus.managers.PersistenceManager;
import io.github.thatsmusic99.headsplus.managers.SellableHeadsManager;
import io.github.thatsmusic99.headsplus.util.CachedValues;
import io.github.thatsmusic99.headsplus.util.HPUtils;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

@CommandInfo(
        commandname = "sellhead",
        permission = "headsplus.sellhead",
        maincommand = false,
        usage = "/sellhead [All|Head ID] [#]",
        descriptionPath = "descriptions.sellhead"
)
public class SellHead implements CommandExecutor, IHeadsPlusCommand, TabCompleter {

	private final MessagesManager hpc = MessagesManager.get();
	private final int[] slots;

	public SellHead() {
	    slots = new int[45];
	    slots[44] = 45; // off-hand slot
	    for (int i = 0; i < 44; i++) {
            slots[i] = i;
        }
    }

    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
		try {
		    if (!(MainConfig.get().getMainFeatures().SELL_HEADS && HeadsPlus.get().isVaultEnabled())) {
                hpc.sendMessage("commands.errors.disabled", sender);
                return true;
            }
		    if (!(sender instanceof Player)) {
                hpc.sendMessage("commands.errors.not-a-player", sender);
                return true;
            }
		    Player player = (Player) sender;
		    if (args.length == 0) {
		        // Open the GUI
                if (MainConfig.get().getSellingHeads().USE_GUI && player.hasPermission("headsplus.sellhead.gui")) {
                    HashMap<String, String> context = new HashMap<>();
                    context.put("section", "mobs");
                    InventoryManager.getManager(player).open(InventoryManager.InventoryType.SELLHEAD_CATEGORY, context);
                    return true;
                } else {
                    // Get the item in the player's hand
                    ItemStack item = player.getInventory().getItemInMainHand();
                    // If the item exists and is sellable,
                    if (!PersistenceManager.get().isSellable(item)) {
                        MessagesManager.get().sendMessage("commands.sellhead.false-head", player);
                        return true;
                    }
                    // Get the ID
                    String id = PersistenceManager.get().getSellType(item);
                    if (!SellableHeadsManager.get().isRegistered(id)) {
                        MessagesManager.get().sendMessage("commands.sellhead.false-head", player);
                        return true;
                    }
                    double price = SellableHeadsManager.get().getPrice(id) * item.getAmount();
                    SellData data = new SellData(player);
                    data.addID(id, item.getAmount());
                    data.addSlot(player.getInventory().getHeldItemSlot(), item.getAmount());
                    pay(player, data, price);
{'fraction_non_alphanumeric': 0.11182317551660999, 'fraction_numerical': 0.008631964425843578, 'mean_word_length': 2.637963843958135, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6347101', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2142, 'n_words': 410}