<commit_before>package xyz.whynospaces.superhumans;

import net.md_5.bungee.api.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Banner;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.util.ArrayList;
import java.util.List;

public class SuperHumanFactory {

    public SuperHuman getSuperHumanByName(String name) {
        if(isSuperHuman(name)) {
            String configPath = "superhumans." + name;
            return new SuperHuman(SuperHumans.instance.getConfig().getString(configPath + "display-name"),
                    deserializePotionEffect(name),
                    deserializeItems(name));
        }
        return null;
    }

    public boolean isSuperHuman(String name) {
        for(String heroes : SuperHumans.instance.getConfig().getConfigurationSection("superhumans").getKeys(false)) {
            return name.equalsIgnoreCase(heroes);
        }
        return false;
    }

    public List<PotionEffect> deserializePotionEffect(String name) {
        List<PotionEffect> deserializedPotionEffects = new ArrayList<PotionEffect>();

        for(String serializedPotion : SuperHumans.instance.getConfig().getStringList("superhumans." + name + ".potion-effects")) {
            String potions = serializedPotion.split(":")[0];
            Integer amplifier = Integer.parseInt(serializedPotion.split(":")[1]);
            if(PotionEffectType.getByName(potions) != null) {
                deserializedPotionEffects.add(PotionEffectType.getByName(potions).createEffect(Integer.MAX_VALUE, amplifier));
            }
        }

        return deserializedPotionEffects;
    }

    public List<ItemStack> deserializeItems(String name) {
        List<ItemStack> deserializedItems = new ArrayList<ItemStack>();
        String configPath = "superhumans." + name + ".items";

        for(String items : SuperHumans.instance.getConfig().getConfigurationSection(configPath).getKeys(false)) {
            configPath = configPath + "." + items + ".";
            ItemStack item = new ItemStack(Material.valueOf(SuperHumans.instance.getConfig().getString(configPath + "material")),
                    SuperHumans.instance.getConfig().getInt(configPath + "amount"));
            ItemMeta itemMeta = item.getItemMeta();

            if(SuperHumans.instance.getConfig().getString(configPath + "display-name") != null) {
                itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', SuperHumans.instance.getConfig().getString(configPath + ".display-name")));
            }

            if(SuperHumans.instance.getConfig().getString(configPath + "leather-armor-color") != null
                    && (item.getType() == Material.LEATHER_HELMET
                    || item.getType() == Material.LEATHER_CHESTPLATE
                    || item.getType() == Material.LEATHER_LEGGINGS
                    || item.getType() == Material.LEATHER_BOOTS)) {
                String[] rgb_string = SuperHumans.instance.getConfig().getString(configPath + "leather-armor-color").split(":");
                int R = Integer.parseInt(rgb_string[0]);
                int G = Integer.parseInt(rgb_string[1]);
                int B = Integer.parseInt(rgb_string[2]);
                ((LeatherArmorMeta)itemMeta).setColor(Color.fromRGB(R, G, B));
            }

            if(SuperHumans.instance.getConfig().getConfigurationSection(configPath + "shield-meta") != null<commit_msg>Forgot to add enchantments to items. Fixed.<commit_after>package xyz.whynospaces.superhumans;

import net.md_5.bungee.api.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Banner;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.util.ArrayList;
import java.util.List;

public class SuperHumanFactory {

    public SuperHuman getSuperHumanByName(String name) {
        if(isSuperHuman(name)) {
            String configPath = "superhumans." + name;
            return new SuperHuman(SuperHumans.instance.getConfig().getString(configPath + "display-name"),
                    deserializePotionEffect(name),
                    deserializeItems(name));
        }
        return null;
    }

    public boolean isSuperHuman(String name) {
        for(String heroes : SuperHumans.instance.getConfig().getConfigurationSection("superhumans").getKeys(false)) {
            return name.equalsIgnoreCase(heroes);
        }
        return false;
    }

    public List<PotionEffect> deserializePotionEffect(String name) {
        List<PotionEffect> deserializedPotionEffects = new ArrayList<PotionEffect>();

        for(String serializedPotion : SuperHumans.instance.getConfig().getStringList("superhumans." + name + ".potion-effects")) {
            String potions = serializedPotion.split(":")[0];
            Integer amplifier = Integer.parseInt(serializedPotion.split(":")[1]);
            if(PotionEffectType.getByName(potions) != null) {
                deserializedPotionEffects.add(PotionEffectType.getByName(potions).createEffect(Integer.MAX_VALUE, amplifier));
            }
        }

        return deserializedPotionEffects;
    }

    public List<ItemStack> deserializeItems(String name) {
        List<ItemStack> deserializedItems = new ArrayList<ItemStack>();
        String configPath = "superhumans." + name + ".items";

        for(String items : SuperHumans.instance.getConfig().getConfigurationSection(configPath).getKeys(false)) {
            configPath = configPath + "." + items + ".";
            ItemStack item = new ItemStack(Material.valueOf(SuperHumans.instance.getConfig().getString(configPath + "material")),
                    SuperHumans.instance.getConfig().getInt(configPath + "amount"));
            ItemMeta itemMeta = item.getItemMeta();

            if(SuperHumans.instance.getConfig().getString(configPath + "display-name") != null) {
                itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', SuperHumans.instance.getConfig().getString(configPath + ".display-name")));
            }

            if(SuperHumans.instance.getConfig().getStringList(configPath + "enchantments") != null) {
                for(String serializedEnchantment : SuperHumans.instance.getConfig().getStringList(configPath + "enchantments")) {
                    Enchantment enchantment = Enchantment.getByName(serializedEnchantment.split(":")[0]);
                    int level = Integer.parseInt(serializedEnchantment.split(":")[1]);
                    itemMeta.addEnchant(enchantment, level, true);
                }
            }

            if(SuperHumans.instance.getConfig().getString(configPath + "leather-armor-color") != null
                    && (item.getType() == Material.LEATHER_HELMET
                    || item.getType() == Material.LEATHER_CHESTPLATE
                    || item.getType() == Material.LEATHER_LEGGINGS
                    || item.getType() == Material.LEATHER_BOOTS)) {
                String[] rgb_string = SuperHumans.instance.getConfig().getString(configPath + "leather-armor-color").split(":");
                int R = Integer.parseInt(rgb_string[0]);
                int G = Integer.parseInt(rgb_string[1]);
                int B = Integer.parseInt(rgb_string[2]);
                ((LeatherArmorMeta)itemMeta).setColor(Color.fromRGB(R, G, B));
            }

            if(SuperHumans.instance.getConfig().getConfigurationSection(configPath + "shield-meta") != null
{'fraction_non_alphanumeric': 0.12024615384615385, 'fraction_numerical': 0.001723076923076923, 'mean_word_length': 3.034756703078451, 'pattern_counts': {'":': 8, '<': 15, '<?xml version=': 0, '>': 15, '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': '678077', 'n_tokens_mistral': 2360, 'n_tokens_neox': 2254, 'n_words': 329}