Search in sources :

Example 1 with ArmorType

use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.

the class InventoryManager method dropInventory.

public void dropInventory(OfflinePlayer player, Location location) {
    Validate.notNull(player, "player must not be null!");
    Validate.notNull(location, "location must not be null!");
    World world = location.getWorld();
    Validate.notNull(world, "location must have a valid world!");
    StoredInventory storedInventory = getStoredInventory(player);
    if (storedInventory == null) {
        return;
    }
    for (int slot = 0; slot < 36; slot++) {
        ItemStack item = storedInventory.getItem(slot);
        dropItem(item, player, location, CitizensSlotType.INVENTORY);
    }
    ArmorType[] armorTypeArray = ArmorType.values();
    for (ArmorType armorType : armorTypeArray) {
        ItemStack item = storedInventory.getArmor(armorType);
        dropItem(item, player, location, CitizensSlotType.ARMOR);
    }
    ItemStack item = storedInventory.getOffHandItem();
    dropItem(item, player, location, CitizensSlotType.OFFHAND);
    removeStoredInventory(player);
}
Also used : StoredInventory(combatlogx.expansion.compatibility.citizens.object.StoredInventory) World(org.bukkit.World) ItemStack(org.bukkit.inventory.ItemStack) ArmorType(com.github.sirblobman.api.item.ArmorType)

Example 2 with ArmorType

use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.

the class StoredInventory method save.

public void save(CitizensExpansion expansion, ConfigurationSection configuration) {
    ItemStack mainHand = getMainHandItem();
    saveItemStack(expansion, configuration, "main-hand", mainHand);
    ItemStack offHand = getOffHandItem();
    saveItemStack(expansion, configuration, "off-hand", offHand);
    ArmorType[] armorTypeArray = ArmorType.values();
    for (ArmorType armorType : armorTypeArray) {
        ItemStack item = getArmor(armorType);
        String armorTypeName = armorType.name();
        String armorTypePath = ("armor." + armorTypeName);
        saveItemStack(expansion, configuration, armorTypePath, item);
    }
    for (int slot = 0; slot < 36; slot++) {
        ItemStack item = getItem(slot);
        String slotName = Integer.toString(slot);
        String slotPath = ("content." + slotName);
        saveItemStack(expansion, configuration, slotPath, item);
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) ArmorType(com.github.sirblobman.api.item.ArmorType)

Example 3 with ArmorType

use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.

the class InventoryManager method equipNPC.

public void equipNPC(OfflinePlayer player, NPC npc) {
    Validate.notNull(player, "player must not be null!");
    Validate.notNull(npc, "npc must not be null!");
    Equipment equipmentTrait = npc.getOrAddTrait(Equipment.class);
    StoredInventory storedInventory = getStoredInventory(player);
    if (storedInventory == null) {
        return;
    }
    ItemStack mainHandItem = storedInventory.getMainHandItem();
    if (mainHandItem != null) {
        equipmentTrait.set(EquipmentSlot.HAND, mainHandItem);
    }
    if (VersionUtility.getMinorVersion() > 8) {
        ItemStack offHandItem = storedInventory.getOffHandItem();
        if (offHandItem != null) {
            equipmentTrait.set(EquipmentSlot.OFF_HAND, offHandItem);
        }
    }
    ArmorType[] armorTypeArray = ArmorType.values();
    for (ArmorType armorType : armorTypeArray) {
        ItemStack item = storedInventory.getArmor(armorType);
        if (item != null) {
            org.bukkit.inventory.EquipmentSlot bukkitSlot = armorType.getSlot();
            EquipmentSlot slot = getNpcSlotFromBukkitSlot(bukkitSlot);
            equipmentTrait.set(slot, item);
        }
    }
}
Also used : StoredInventory(combatlogx.expansion.compatibility.citizens.object.StoredInventory) Equipment(net.citizensnpcs.api.trait.trait.Equipment) EquipmentSlot(net.citizensnpcs.api.trait.trait.Equipment.EquipmentSlot) ItemStack(org.bukkit.inventory.ItemStack) ArmorType(com.github.sirblobman.api.item.ArmorType)

Example 4 with ArmorType

use of com.github.sirblobman.api.item.ArmorType in project CombatLogX by SirBlobman.

the class StoredInventory method createFrom.

public static StoredInventory createFrom(CitizensExpansion expansion, ConfigurationSection configuration) {
    Validate.notNull(configuration, "configuration must not be null!");
    StoredInventory storedInventory = new StoredInventory();
    ArmorType[] armorTypeArray = ArmorType.values();
    for (ArmorType armorType : armorTypeArray) {
        String armorTypeName = armorType.name();
        String armorTypePath = ("armor." + armorTypeName);
        ItemStack item = loadItemStack(expansion, configuration, armorTypePath);
        storedInventory.setArmor(armorType, item);
    }
    ItemStack mainHand = loadItemStack(expansion, configuration, "main-hand");
    ItemStack offHand = loadItemStack(expansion, configuration, "off-hand");
    storedInventory.setMainHand(mainHand);
    storedInventory.setOffHand(offHand);
    for (int slot = 0; slot < 36; slot++) {
        String slotName = Integer.toString(slot);
        String slotPath = ("content." + slotName);
        ItemStack item = loadItemStack(expansion, configuration, slotPath);
        storedInventory.setItemStack(slot, item);
    }
    return storedInventory;
}
Also used : ArmorType(com.github.sirblobman.api.item.ArmorType) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

ArmorType (com.github.sirblobman.api.item.ArmorType)4 ItemStack (org.bukkit.inventory.ItemStack)4 StoredInventory (combatlogx.expansion.compatibility.citizens.object.StoredInventory)2 Equipment (net.citizensnpcs.api.trait.trait.Equipment)1 EquipmentSlot (net.citizensnpcs.api.trait.trait.Equipment.EquipmentSlot)1 World (org.bukkit.World)1