// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.npc.role;

import java.util.logging.Level;
import com.hypixel.hytale.server.npc.NPCPlugin;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.core.inventory.Inventory;
import com.hypixel.hytale.server.npc.util.InventoryHelper;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.entities.NPCEntity;

public class RoleUtils
{
    public static void setHotbarItems(@Nonnull final NPCEntity npcComponent, @Nonnull final String[] hotbarItems) {
        final Inventory inventory = npcComponent.getInventory();
        for (byte i = 0; i < hotbarItems.length; ++i) {
            InventoryHelper.setHotbarItem(inventory, hotbarItems[i], i);
        }
    }
    
    public static void setOffHandItems(@Nonnull final NPCEntity npcComponent, @Nonnull final String[] offHandItems) {
        final Inventory inventory = npcComponent.getInventory();
        for (byte i = 0; i < offHandItems.length; ++i) {
            InventoryHelper.setOffHandItem(inventory, offHandItems[i], i);
        }
    }
    
    public static void setItemInHand(@Nonnull final NPCEntity npcComponent, @Nullable final String itemInHand) {
        if (!InventoryHelper.useItem(npcComponent.getInventory(), itemInHand)) {
            NPCPlugin.get().getLogger().at(Level.WARNING).log("NPC of type '%s': Failed to use item '%s'", npcComponent.getRoleName(), itemInHand);
        }
    }
    
    public static void setArmor(@Nonnull final NPCEntity npcComponent, @Nullable final String armor) {
        if (!InventoryHelper.useArmor(npcComponent.getInventory().getArmor(), armor)) {
            NPCPlugin.get().getLogger().at(Level.WARNING).log("NPC of type '%s': Failed to use armor '%s'", npcComponent.getRoleName(), armor);
        }
    }
}
