// Path: src/main/java/com/dumptruckman/chestrestock/api/LootTable.java
// public interface LootTable {
// 
//     /**
//      * Adds the loot table to an inventory.
//      *
//      * @param inv The inventory to add the loot table to.
//      */
//     void addToInventory(Inventory inv);
// 
//     /**
//      * Interface to describe a LootSection, which is a single section of the yaml file.
//      */
//     interface LootSection {
// 
//         /**
//          * @return The number of rolls for the section.
//          */
//         int getRolls();
// 
//         /**
//          * @return A map of the children section with keys representing the chance of that section.  The value
//          * is a Set since multiple sections may have the same chance.
//          */
//         Map<Float, Set<LootSection>> getChildSections();
// 
//         /**
//          * @return True if only one child should be picked for this LootSection.
//          */
//         boolean isSplit();
// 
//         /**
//          * @return The total of all the chances for all the children of this LootSection.
//          */
//         float getTotalWeight();
// 
//         /**
//          * @return The chance for this LootSection to be chosen.
//          */
//         float getChance();
//     }
// 
//     /**
//      * Interface to describe a LootSection that represents an Item (the default kind of LootSection).
//      */
//     interface ItemSection extends LootSection {
// 
//         /**
//          * @return The item this LootSection represents.
//          */
//         ItemStack getItem();
// 
//         /**
//          * @return The enchant section for this LootSection or null if none exists.
//          */
//         EnchantSection getEnchantSection();
//     }
// 
//     /**
//      * Interface to describe a LootSection that represents an item enchantment.
//      */
//     static interface EnchantSection extends LootSection {
// 
//         /**
//          * @return The enchantment represented by this LootSection.
//          */
//         Enchantment getEnchantment();
// 
//         /**
//          * @return The level of the enchantment.
//          */
//         int getLevel();
//     }
// }
// 
// Path: src/main/java/com/dumptruckman/chestrestock/api/LootTable.java
// interface ItemSection extends LootSection {
// 
//     /**
//      * @return The item this LootSection represents.
//      */
//     ItemStack getItem();
// 
//     /**
//      * @return The enchant section for this LootSection or null if none exists.
//      */
//     EnchantSection getEnchantSection();
// }


import com.dumptruckman.chestrestock.api.LootTable;
import com.dumptruckman.chestrestock.api.LootTable.ItemSection;
import com.dumptruckman.minecraft.pluginbase.util.Logging;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;
                enchantLevel = randGen.nextInt(enchantLevel) + 1;
                Logging.finest("Using random enchant level for " + enchantment + ": " + enchantLevel);
            }
            item.addUnsafeEnchantment(enchantment, enchantLevel);
        }
        Logging.finest("Total weight of '" + enchantSection + "': " + enchantSection.getTotalWeight());
        float splitPicker = randGen.nextFloat() * enchantSection.getTotalWeight();
        float currentWeight = 0F;
        boolean splitPicked = false;
        for (Map.Entry<Float, Set<LootSection>> entry : enchantSection.getChildSections().entrySet()) {
            for (LootSection childSection : entry.getValue()) {
                if (!(childSection instanceof EnchantSection)) {
                    continue;
                }
                EnchantSection childEnchantSection = (EnchantSection) childSection;
                if (enchantSection.isSplit()) {
                    currentWeight += entry.getKey();
                    Logging.finest("splitPicker: " + splitPicker + " <= " + currentWeight);
                    if (splitPicker <= currentWeight) {
                        Logging.finest("Picked split: Adding " + childEnchantSection + " to item "
                                + childEnchantSection.getRolls() + " times");
                        for (int i = 0; i < childEnchantSection.getRolls(); i++) {
                            addEnchantToItem(item, childEnchantSection);
                        }
                        splitPicked = true;
                        break;
                    }
                } else {
                    for (int i = 0; i < childEnchantSection.getRolls(); i++) {
                        float chance = entry.getKey();
// Path: src/main/java/com/dumptruckman/chestrestock/api/LootTable.java
// public interface LootTable {
// 
//     /**
//      * Adds the loot table to an inventory.
//      *
//      * @param inv The inventory to add the loot table to.
//      */
//     void addToInventory(Inventory inv);
// 
//     /**
//      * Interface to describe a LootSection, which is a single section of the yaml file.
//      */
//     interface LootSection {
// 
//         /**
//          * @return The number of rolls for the section.
//          */
//         int getRolls();
// 
//         /**
//          * @return A map of the children section with keys representing the chance of that section.  The value
//          * is a Set since multiple sections may have the same chance.
//          */
//         Map<Float, Set<LootSection>> getChildSections();
// 
//         /**
//          * @return True if only one child should be picked for this LootSection.
//          */
//         boolean isSplit();
// 
//         /**
//          * @return The total of all the chances for all the children of this LootSection.
//          */
//         float getTotalWeight();
// 
//         /**
//          * @return The chance for this LootSection to be chosen.
//          */
//         float getChance();
//     }
// 
//     /**
//      * Interface to describe a LootSection that represents an Item (the default kind of LootSection).
//      */
//     interface ItemSection extends LootSection {
// 
//         /**
//          * @return The item this LootSection represents.
//          */
//         ItemStack getItem();
// 
//         /**
//          * @return The enchant section for this LootSection or null if none exists.
//          */
//         EnchantSection getEnchantSection();
//     }
// 
//     /**
//      * Interface to describe a LootSection that represents an item enchantment.
//      */
//     static interface EnchantSection extends LootSection {
// 
//         /**
//          * @return The enchantment represented by this LootSection.
//          */
//         Enchantment getEnchantment();
// 
//         /**
//          * @return The level of the enchantment.
//          */
//         int getLevel();
//     }
// }
// 
// Path: src/main/java/com/dumptruckman/chestrestock/api/LootTable.java
// interface ItemSection extends LootSection {
// 
//     /**
//      * @return The item this LootSection represents.
//      */
//     ItemStack getItem();
// 
//     /**
//      * @return The enchant section for this LootSection or null if none exists.
//      */
//     EnchantSection getEnchantSection();
// }


// Path: src/main/java/com/dumptruckman/chestrestock/DefaultLootTable.java
import com.dumptruckman.chestrestock.api.LootTable;
import com.dumptruckman.chestrestock.api.LootTable.ItemSection;
import com.dumptruckman.minecraft.pluginbase.util.Logging;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;

                enchantLevel = randGen.nextInt(enchantLevel) + 1;
                Logging.finest("Using random enchant level for " + enchantment + ": " + enchantLevel);
            }
            item.addUnsafeEnchantment(enchantment, enchantLevel);
        }
        Logging.finest("Total weight of '" + enchantSection + "': " + enchantSection.getTotalWeight());
        float splitPicker = randGen.nextFloat() * enchantSection.getTotalWeight();
        float currentWeight = 0F;
        boolean splitPicked = false;
        for (Map.Entry<Float, Set<LootSection>> entry : enchantSection.getChildSections().entrySet()) {
            for (LootSection childSection : entry.getValue()) {
                if (!(childSection instanceof EnchantSection)) {
                    continue;
                }
                EnchantSection childEnchantSection = (EnchantSection) childSection;
                if (enchantSection.isSplit()) {
                    currentWeight += entry.getKey();
                    Logging.finest("splitPicker: " + splitPicker + " <= " + currentWeight);
                    if (splitPicker <= currentWeight) {
                        Logging.finest("Picked split: Adding " + childEnchantSection + " to item "
                                + childEnchantSection.getRolls() + " times");
                        for (int i = 0; i < childEnchantSection.getRolls(); i++) {
                            addEnchantToItem(item, childEnchantSection);
                        }
                        splitPicked = true;
                        break;
                    }
                } else {
                    for (int i = 0; i < childEnchantSection.getRolls(); i++) {
                        float chance = entry.getKey();
                        int successfulRolls = (int) chance;