<commit_before>package info.faceland.strife.managers;

import com.tealcube.minecraft.bukkit.TextUtils;
import info.faceland.strife.util.LogUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;

import java.util.*;

public class EntityEquipmentManager {

  private final Map<String, ItemStack> itemMap;

  public EntityEquipmentManager() {
    this.itemMap = new HashMap<>();
  }

  public Map<String, ItemStack> getItemMap() {
    return itemMap;
  }

  public ItemStack getItem(String key) {
    return itemMap.getOrDefault(key, null);
  }

  public void loadEquipmentItem(String key, ConfigurationSection cs) {
    Material material;
    String type = cs.getString("material");
    try {
      material = Material.valueOf(type);
    } catch (Exception e) {
      LogUtil.printWarning("Skipping item " + key + " for invalid material");
      return;
    }

    ItemStack itemStack;
    SkullType skullType = null;
    if (material != Material.SKULL_ITEM) {
      itemStack = new ItemStack(material);
    } else {
      skullType = SkullType.valueOf(cs.getString("skull-type", "ZOMBIE"));
      itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) skullType.ordinal());
    }
    ItemMeta meta = itemStack.getItemMeta();

    String name = cs.getString("name", "");
    if (StringUtils.isNotBlank(name)) {
      meta.setDisplayName(TextUtils.color(name));
    }

    List<String> lore = new ArrayList<>();
    for (String line : cs.getStringList("lore")) {
      lore.add(TextUtils.color(line));
    }
    meta.setLore(lore);

    itemStack.setItemMeta(meta);

    if (material == Material.SKULL_ITEM && skullType == SkullType.PLAYER) {
      UUID uuid = UUID.fromString(cs.getString("uuid", "b4064ecc-5508-4848-ae4d-f12fbebd0a52"));
      SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
      skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(uuid));<commit_msg>Allowing equipment items to have data and making them unbreakable<commit_after>package info.faceland.strife.managers;

import com.tealcube.minecraft.bukkit.TextUtils;
import info.faceland.strife.util.LogUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;

import java.util.*;

public class EntityEquipmentManager {

  private final Map<String, ItemStack> itemMap;

  public EntityEquipmentManager() {
    this.itemMap = new HashMap<>();
  }

  public Map<String, ItemStack> getItemMap() {
    return itemMap;
  }

  public ItemStack getItem(String key) {
    return itemMap.getOrDefault(key, null);
  }

  public void loadEquipmentItem(String key, ConfigurationSection cs) {
    Material material;
    String type = cs.getString("material");
    try {
      material = Material.valueOf(type);
    } catch (Exception e) {
      LogUtil.printWarning("Skipping item " + key + " for invalid material");
      return;
    }

    ItemStack itemStack;
    SkullType skullType = null;
    if (material != Material.SKULL_ITEM) {
      short data = (short) cs.getInt("data", 0);
      itemStack = new ItemStack(material, 1, data);
    } else {
      skullType = SkullType.valueOf(cs.getString("skull-type", "ZOMBIE"));
      itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) skullType.ordinal());
    }
    ItemMeta meta = itemStack.getItemMeta();

    String name = cs.getString("name", "");
    if (StringUtils.isNotBlank(name)) {
      meta.setDisplayName(TextUtils.color(name));
    }

    List<String> lore = new ArrayList<>();
    for (String line : cs.getStringList("lore")) {
      lore.add(TextUtils.color(line));
    }
    meta.setLore(lore);
    meta.setUnbreakable(true);

    itemStack.setItemMeta(meta);

    if (material == Material.SKULL_ITEM && skullType == SkullType.PLAYER) {
      UUID uuid = UUID.fromString(cs.getString("uuid", "b4064ecc-5508-4848-ae4d-f12fbebd0a52"));
      SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
      skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(uuid));
{'fraction_non_alphanumeric': 0.12400995700384702, 'fraction_numerical': 0.009504412763068567, 'mean_word_length': 3.994350282485876, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4556923', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1412, 'n_words': 274}