<commit_before>package org.royaldev.royalcommands.serializable;

import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Serializable ItemStack
 * <p/>
 * Needed for SerializableCraftInventory
 *
 * @author jkcclemens
 * @see SerializableCraftInventory
 * @see SerializableCraftEnchantment
 * @since 0.2.4pre
 */
public class SerializableItemStack implements Serializable {

    static final long serialVersionUID = -5056202252395200062L;

    /**
     * Amount of items in the ItemStack - defaults to 0
     */
    private int amount = 0;
    /**
     * Durability, or damage, of the items in the ItemStack - defaults to 0
     */
    private short durability = 0;
    /**
     * Item ID of the ItemStack - defaults to 0
     */
    private int type = 0;
    /**
     * Map containing enchantments and their respective levels on this ItemStack - defaults to an empty map
     */
    private Map<SerializableCraftEnchantment, Integer> enchantments = new HashMap<SerializableCraftEnchantment, Integer>();
    /**
     * Material data on this ItemStack - defaults to 0
     */
    private byte materialData = 0;
    /**
     * The tag on the ItemStack, commonly used for written book data - defaults to null
     */
    private SerializableNBTTagCompound tag = null;

    /**
     * Serializable ItemStack for saving to files.
     *
     * @param i ItemStack to convert
     */
    public SerializableItemStack(ItemStack i) {
        if (i == null) return;
        amount = i.getAmount();
        durability = i.getDurability();
        for (Enchantment e : i.getEnchantments().keySet())
            enchantments.put(new SerializableCraftEnchantment(e), i.getEnchantments().get(e));
        type = i.getTypeId();
        materialData = i.getData().getData();
        tag = new SerializableNBTTagCompound(((CraftItemStack) i).getHandle().getTag());
    }

    /**
     * Returns a SIS to an ItemStack (keeps enchantments, amount, data, and durability)
     *
     * @return Original ItemStack
     */
    public ItemStack getItemStack() {
        CraftItemStack cis = new CraftItemStack(type, amount, durability, materialData);
        cis.setDurability(durability);
        for (SerializableCraftEnchantment sce : enchantments.keySet())
            cis.addUnsafeEnchantment(sce.getEnchantment(), enchantments.get(sce));
        if (tag != null) cis.getHandle().setTag(tag.getNBTTagCompound());
        return cis;
    }

}<commit_msg>Fixed: Enchantments in /pack<commit_after>package org.royaldev.royalcommands.serializable;

import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Serializable ItemStack
 * <p/>
 * Needed for SerializableCraftInventory
 *
 * @author jkcclemens
 * @see SerializableCraftInventory
 * @see SerializableCraftEnchantment
 * @since 0.2.4pre
 */
public class SerializableItemStack implements Serializable {

    static final long serialVersionUID = -5056202252395200062L;

    /**
     * Amount of items in the ItemStack - defaults to 0
     */
    private int amount = 0;
    /**
     * Durability, or damage, of the items in the ItemStack - defaults to 0
     */
    private short durability = 0;
    /**
     * Item ID of the ItemStack - defaults to 0
     */
    private int type = 0;
    /**
     * Map containing enchantments and their respective levels on this ItemStack - defaults to an empty map
     */
    private Map<SerializableCraftEnchantment, Integer> enchantments = new HashMap<SerializableCraftEnchantment, Integer>();
    /**
     * Material data on this ItemStack - defaults to 0
     */
    private byte materialData = 0;
    /**
     * The tag on the ItemStack, commonly used for written book data - defaults to null
     */
    private SerializableNBTTagCompound tag = null;

    /**
     * Serializable ItemStack for saving to files.
     *
     * @param i ItemStack to convert
     */
    public SerializableItemStack(ItemStack i) {
        if (i == null) return;
        amount = i.getAmount();
        durability = i.getDurability();
        for (Enchantment e : i.getEnchantments().keySet())
            enchantments.put(new SerializableCraftEnchantment(e), i.getEnchantments().get(e));
        type = i.getTypeId();
        materialData = i.getData().getData();
        tag = new SerializableNBTTagCompound(((CraftItemStack) i).getHandle().getTag());
    }

    /**
     * Returns a SIS to an ItemStack (keeps enchantments, amount, data, and durability)
     *
     * @return Original ItemStack
     */
    public ItemStack getItemStack() {
        CraftItemStack cis = new CraftItemStack(type, amount, durability, materialData);
        if (tag != null) cis.getHandle().setTag(tag.getNBTTagCompound());
        cis.setDurability(durability);
        for (SerializableCraftEnchantment sce : enchantments.keySet())
            cis.addUnsafeEnchantment(sce.getEnchantment(), enchantments.get(sce));
        return cis;
    }

}
{'fraction_non_alphanumeric': 0.10001916075876605, 'fraction_numerical': 0.011496455259628282, 'mean_word_length': 2.9816933638443937, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7488874', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1530, 'n_words': 415}